Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Prevent parseForESLint() behavior from changing after parse() is called #559

Merged
merged 6 commits into from
Dec 25, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/analyze-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ module.exports = function(ast, parserOptions) {
};

if (OriginalReferencer._babelEslintPatched) {
options._skipBabelEslintGlobals = true;
require("./patch-eslint-scope")(parserOptions);
return escope.analyze(ast, options);
}

Expand Down
9 changes: 7 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
"use strict";

exports.parse = function(code, options) {
return require("./parse-with-patch")(code, options);
return exports.parseForESLint(code, options).ast;
};

exports.parseForESLint = function(code, options) {
options = options || {};
options.ecmaVersion = options.ecmaVersion || 6;
options.sourceType = options.sourceType || "module";
options.allowImportExportEverywhere =
options.allowImportExportEverywhere || false;

if (options.eslintVisitorKeys && options.eslintScopeManager) {
return require("./parse-with-scope")(code, options);
}

return { ast: require("./parse-with-patch")(code, options) };
};

Expand Down
Loading