Skip to content

Commit 8eccc37

Browse files
authored
Chore: Switch escope to eslint-scope (#109)
* Chore: Switch `escope` to `eslint-scope` * Add range to AST * Fix
1 parent 31951d4 commit 8eccc37

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"license": "MIT",
88
"scripts": {
99
"lint": "eslint . --ignore-pattern \"!.*\"",
10-
"pretest": "npm run lint",
1110
"generate-readme-table": "node build/generate-readme-table.js",
1211
"generate-release": "node-release-script",
1312
"test": "mocha tests --recursive"
@@ -33,11 +32,11 @@
3332
"@not-an-aardvark/node-release-script": "^0.1.0",
3433
"chai": "^4.1.0",
3534
"dirty-chai": "^2.0.1",
36-
"escope": "^3.6.0",
3735
"eslint": "^7.9.0",
3836
"eslint-config-not-an-aardvark": "^2.1.0",
3937
"eslint-plugin-node": "^11.1.0",
4038
"eslint-plugin-self": "^1.2.1",
39+
"eslint-scope": "^5.1.1",
4140
"espree": "^7.3.0",
4241
"estraverse": "^5.0.0",
4342
"lodash": "^4.17.2",

tests/lib/utils.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const util = require('util');
44
const lodash = require('lodash');
55
const espree = require('espree');
6-
const escope = require('escope');
6+
const eslintScope = require('eslint-scope');
77
const estraverse = require('estraverse');
88
const assert = require('chai').assert;
99
const utils = require('../../lib/utils');
@@ -27,7 +27,7 @@ describe('utils', () => {
2727
'module.exports = { create: async function foo() {} }',
2828
].forEach(noRuleCase => {
2929
it(`returns null for ${noRuleCase}`, () => {
30-
const ast = espree.parse(noRuleCase, { ecmaVersion: 8 });
30+
const ast = espree.parse(noRuleCase, { ecmaVersion: 8, range: true });
3131
assert.isNull(utils.getRuleInfo(ast), 'Expected no rule to be found');
3232
});
3333
});
@@ -114,7 +114,7 @@ describe('utils', () => {
114114

115115
Object.keys(CASES).forEach(ruleSource => {
116116
it(ruleSource, () => {
117-
const ast = espree.parse(ruleSource, { ecmaVersion: 6 });
117+
const ast = espree.parse(ruleSource, { ecmaVersion: 6, range: true });
118118
const ruleInfo = utils.getRuleInfo(ast);
119119
assert(
120120
lodash.isMatch(ruleInfo, CASES[ruleSource]),
@@ -148,8 +148,8 @@ describe('utils', () => {
148148

149149
Object.keys(CASES).forEach(ruleSource => {
150150
it(ruleSource, () => {
151-
const ast = espree.parse(ruleSource, { ecmaVersion: 6 });
152-
const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
151+
const ast = espree.parse(ruleSource, { ecmaVersion: 6, range: true });
152+
const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
153153
const identifiers = utils.getContextIdentifiers(scope, ast);
154154

155155
assert(identifiers instanceof Set, 'getContextIdentifiers should return a Set');
@@ -178,7 +178,7 @@ describe('utils', () => {
178178
};
179179
Object.keys(CASES).forEach(objectSource => {
180180
it(objectSource, () => {
181-
const ast = espree.parse(objectSource, { ecmaVersion: 6 });
181+
const ast = espree.parse(objectSource, { ecmaVersion: 6, range: true });
182182

183183
assert.strictEqual(utils.getKeyName(ast.body[0].expression.properties[0]), CASES[objectSource]);
184184
});
@@ -189,7 +189,7 @@ describe('utils', () => {
189189
};
190190
Object.keys(CASES_ES9).forEach(objectSource => {
191191
it(objectSource, () => {
192-
const ast = espree.parse(objectSource, { ecmaVersion: 9 });
192+
const ast = espree.parse(objectSource, { ecmaVersion: 9, range: true });
193193

194194
assert.strictEqual(utils.getKeyName(ast.body[0].expression.properties[0]), CASES_ES9[objectSource]);
195195
});
@@ -211,8 +211,8 @@ describe('utils', () => {
211211
'new RuleTester().run(foo, bar, notAnObject)',
212212
].forEach(noTestsCase => {
213213
it(`returns no tests for ${noTestsCase}`, () => {
214-
const ast = espree.parse(noTestsCase, { ecmaVersion: 8 });
215-
const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
214+
const ast = espree.parse(noTestsCase, { ecmaVersion: 8, range: true });
215+
const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
216216
assert.deepEqual(utils.getTestInfo(scope, ast), [], 'Expected no tests to be found');
217217
});
218218
});
@@ -229,8 +229,8 @@ describe('utils', () => {
229229

230230
Object.keys(CASES).forEach(testSource => {
231231
it(testSource, () => {
232-
const ast = espree.parse(testSource, { ecmaVersion: 6 });
233-
const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
232+
const ast = espree.parse(testSource, { ecmaVersion: 6, range: true });
233+
const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
234234
const testInfo = utils.getTestInfo(scope, ast);
235235

236236
assert.strictEqual(testInfo.length, 1, 'Expected to find one test run');
@@ -274,8 +274,8 @@ describe('utils', () => {
274274

275275
Object.keys(CASES).forEach(testSource => {
276276
it(testSource, () => {
277-
const ast = espree.parse(testSource, { ecmaVersion: 6 });
278-
const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
277+
const ast = espree.parse(testSource, { ecmaVersion: 6, range: true });
278+
const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
279279
const testInfo = utils.getTestInfo(scope, ast);
280280

281281
assert.strictEqual(
@@ -343,8 +343,8 @@ describe('utils', () => {
343343

344344
Object.keys(CASES).forEach(testSource => {
345345
it(testSource, () => {
346-
const ast = espree.parse(testSource, { ecmaVersion: 6 });
347-
const scope = escope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
346+
const ast = espree.parse(testSource, { ecmaVersion: 6, range: true });
347+
const scope = eslintScope.analyze(ast, { ignoreEval: true, ecmaVersion: 6, sourceType: 'script', nodejsScope: true });
348348

349349
estraverse.traverse(ast, {
350350
enter (node, parent) {

0 commit comments

Comments
 (0)