Remove monkeypatching dead code (babel/babel-eslint#737)
This commit is contained in:
parent
47de99e1b8
commit
2b9ee42ded
@ -327,11 +327,6 @@ module.exports = function(ast, parserOptions) {
|
|||||||
fallback,
|
fallback,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (OriginalReferencer._babelEslintPatched) {
|
|
||||||
require("./patch-eslint-scope")(parserOptions);
|
|
||||||
return escope.analyze(ast, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
options.childVisitorKeys = childVisitorKeys;
|
options.childVisitorKeys = childVisitorKeys;
|
||||||
|
|
||||||
const scopeManager = new escope.ScopeManager(options);
|
const scopeManager = new escope.ScopeManager(options);
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
"homepage": "https://github.com/babel/babel-eslint",
|
"homepage": "https://github.com/babel/babel-eslint",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run lint && npm run test-only",
|
"test": "npm run lint && npm run test-only",
|
||||||
"test-only": "cd test && mocha --require fixtures/preprocess-to-patch.js specs && cd -",
|
"test-only": "cd test && mocha specs && cd -",
|
||||||
"lint": "eslint .",
|
"lint": "eslint .",
|
||||||
"lint-fix": "npm run lint -- --fix",
|
"lint-fix": "npm run lint -- --fix",
|
||||||
"precommit": "lint-staged",
|
"precommit": "lint-staged",
|
||||||
|
|||||||
@ -1,6 +0,0 @@
|
|||||||
"use strict"
|
|
||||||
|
|
||||||
const babelEslint = require("../..")
|
|
||||||
|
|
||||||
// Apply monkeypatch to eslint-scope.
|
|
||||||
babelEslint.parse("var x = 0;")
|
|
||||||
@ -223,3 +223,14 @@ function strictSuite() {
|
|||||||
// it
|
// it
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
describe("https://github.com/babel/babel-eslint/issues/558", () => {
|
||||||
|
it("doesn't crash with eslint-plugin-import", () => {
|
||||||
|
const engine = new eslint.CLIEngine({ ignore: false });
|
||||||
|
engine.executeOnFiles([
|
||||||
|
"fixtures/eslint-plugin-import/a.js",
|
||||||
|
"fixtures/eslint-plugin-import/b.js",
|
||||||
|
"fixtures/eslint-plugin-import/c.js",
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
const eslint = require("eslint");
|
|
||||||
const assert = require("assert");
|
|
||||||
const babelEslint = require("../..");
|
|
||||||
const espree = require("espree");
|
|
||||||
const assertImplementsAST = require("../helpers/assert-implements-ast");
|
|
||||||
|
|
||||||
describe("https://github.com/babel/babel-eslint/issues/558", () => {
|
|
||||||
it("don't crash with eslint-plugin-import", () => {
|
|
||||||
const engine = new eslint.CLIEngine({ ignore: false });
|
|
||||||
engine.executeOnFiles([
|
|
||||||
"../test/fixtures/eslint-plugin-import/a.js",
|
|
||||||
"../test/fixtures/eslint-plugin-import/b.js",
|
|
||||||
"../test/fixtures/eslint-plugin-import/c.js",
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This test ensures that the enhanced referencer does not get used if eslint-scope has already been
|
|
||||||
* monkeypatched, because this causes some correctness issues. For example, if the enhanced referencer
|
|
||||||
* is used after the original referencer is monkeypatched, type annotation references are counted twice.
|
|
||||||
*/
|
|
||||||
it("does not visit type annotations multiple times after monkeypatching and calling parseForESLint()", () => {
|
|
||||||
assertImplementsAST(
|
|
||||||
espree.parse("foo", { sourceType: "module" }),
|
|
||||||
babelEslint.parse("foo", {})
|
|
||||||
);
|
|
||||||
const parseResult = babelEslint.parseForESLint(
|
|
||||||
"type Foo = {}; function x(): Foo {}",
|
|
||||||
{
|
|
||||||
eslintVisitorKeys: true,
|
|
||||||
eslintScopeManager: true,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
assert(parseResult.visitorKeys);
|
|
||||||
assert(parseResult.scopeManager);
|
|
||||||
|
|
||||||
const fooVariable = parseResult.scopeManager.getDeclaredVariables(
|
|
||||||
parseResult.ast.body[0]
|
|
||||||
)[0];
|
|
||||||
|
|
||||||
assert.strictEqual(fooVariable.references.length, 1);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
Loading…
x
Reference in New Issue
Block a user