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

Commit

Permalink
fix escope patch and improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Dec 25, 2017
1 parent 1dff112 commit db14da0
Show file tree
Hide file tree
Showing 13 changed files with 499 additions and 481 deletions.
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

0 comments on commit db14da0

Please sign in to comment.