1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
Description: Use eslint-scope (not escope)
Origin: upstream, https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/commit/8eccc37
Bug: https://github.com/not-an-aardvark/eslint-plugin-eslint-plugin/issues/109
Author: fisker Cheung <lionkay@gmail.com>
Last-Update: 2021-04-30
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/package.json
+++ b/package.json
@@ -7,7 +7,6 @@
"license": "MIT",
"scripts": {
"lint": "eslint . --ignore-pattern \"!.*\"",
- "pretest": "npm run lint",
"generate-readme-table": "node build/generate-readme-table.js",
"generate-release": "node-release-script",
"test": "mocha tests --recursive"
@@ -33,11 +32,11 @@
"@not-an-aardvark/node-release-script": "^0.1.0",
"chai": "^4.1.0",
"dirty-chai": "^2.0.1",
- "escope": "^3.6.0",
"eslint": "^7.0.0-alpha.3",
"eslint-config-not-an-aardvark": "^2.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-self": "^1.0.1",
+ "eslint-scope": "^5.1.1",
"espree": "^6.2.1",
"estraverse": "^5.0.0",
"lodash": "^4.17.2",
--- a/tests/lib/utils.js
+++ b/tests/lib/utils.js
@@ -3,7 +3,7 @@
const util = require('util');
const lodash = require('lodash');
const espree = require('espree');
-const escope = require('escope');
+const eslintScope = require('eslint-scope');
const estraverse = require('estraverse');
const assert = require('chai').assert;
const utils = require('../../lib/utils');
@@ -27,7 +27,7 @@
'module.exports = { create: async function foo() {} }',
].forEach(noRuleCase => {
it(`returns null for ${noRuleCase}`, () => {
- const ast = espree.parse(noRuleCase, { ecmaVersion: 8 });
+ const ast = espree.parse(noRuleCase, { ecmaVersion: 8, range: true });
assert.isNull(utils.getRuleInfo(ast), 'Expected no rule to be found');
});
});
@@ -114,7 +114,7 @@
Object.keys(CASES).forEach(ruleSource => {
it(ruleSource, () => {
- const ast = espree.parse(ruleSource, { ecmaVersion: 6 });
+ const ast = espree.parse(ruleSource, { ecmaVersion: 6, range: true });
const ruleInfo = utils.getRuleInfo(ast);
assert(
lodash.isMatch(ruleInfo, CASES[ruleSource]),
@@ -148,8 +148,8 @@
Object.keys(CASES).forEach(ruleSource => {
it(ruleSource, () => {
- const ast = espree.parse(ruleSource, { ecmaVersion: 6 });
- const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
+ const ast = espree.parse(ruleSource, { ecmaVersion: 6, range: true });
+ const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
const identifiers = utils.getContextIdentifiers(scope, ast);
assert(identifiers instanceof Set, 'getContextIdentifiers should return a Set');
@@ -178,7 +178,7 @@
};
Object.keys(CASES).forEach(objectSource => {
it(objectSource, () => {
- const ast = espree.parse(objectSource, { ecmaVersion: 6 });
+ const ast = espree.parse(objectSource, { ecmaVersion: 6, range: true });
assert.strictEqual(utils.getKeyName(ast.body[0].expression.properties[0]), CASES[objectSource]);
});
@@ -189,7 +189,7 @@
};
Object.keys(CASES_ES9).forEach(objectSource => {
it(objectSource, () => {
- const ast = espree.parse(objectSource, { ecmaVersion: 9 });
+ const ast = espree.parse(objectSource, { ecmaVersion: 9, range: true });
assert.strictEqual(utils.getKeyName(ast.body[0].expression.properties[0]), CASES_ES9[objectSource]);
});
@@ -211,8 +211,8 @@
'new RuleTester().run(foo, bar, notAnObject)',
].forEach(noTestsCase => {
it(`returns no tests for ${noTestsCase}`, () => {
- const ast = espree.parse(noTestsCase, { ecmaVersion: 8 });
- const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
+ const ast = espree.parse(noTestsCase, { ecmaVersion: 8, range: true });
+ const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
assert.deepEqual(utils.getTestInfo(scope, ast), [], 'Expected no tests to be found');
});
});
@@ -229,8 +229,8 @@
Object.keys(CASES).forEach(testSource => {
it(testSource, () => {
- const ast = espree.parse(testSource, { ecmaVersion: 6 });
- const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
+ const ast = espree.parse(testSource, { ecmaVersion: 6, range: true });
+ const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
const testInfo = utils.getTestInfo(scope, ast);
assert.strictEqual(testInfo.length, 1, 'Expected to find one test run');
@@ -274,8 +274,8 @@
Object.keys(CASES).forEach(testSource => {
it(testSource, () => {
- const ast = espree.parse(testSource, { ecmaVersion: 6 });
- const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
+ const ast = espree.parse(testSource, { ecmaVersion: 6, range: true });
+ const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
const testInfo = utils.getTestInfo(scope, ast);
assert.strictEqual(
@@ -343,8 +343,8 @@
Object.keys(CASES).forEach(testSource => {
it(testSource, () => {
- const ast = espree.parse(testSource, { ecmaVersion: 6 });
- const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
+ const ast = espree.parse(testSource, { ecmaVersion: 6, range: true });
+ const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
estraverse.traverse(ast, {
enter (node, parent) {
|