Skip to content

Chore: Switch escope to eslint-scope #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.9.0",
"eslint-config-not-an-aardvark": "^2.1.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-self": "^1.2.1",
"eslint-scope": "^5.1.1",
"espree": "^7.3.0",
"estraverse": "^5.0.0",
"lodash": "^4.17.2",
Expand Down
30 changes: 15 additions & 15 deletions tests/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -27,7 +27,7 @@ describe('utils', () => {
'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');
});
});
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('utils', () => {

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]),
Expand Down Expand Up @@ -148,8 +148,8 @@ describe('utils', () => {

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');
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('utils', () => {
};
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]);
});
Expand All @@ -189,7 +189,7 @@ describe('utils', () => {
};
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]);
});
Expand All @@ -211,8 +211,8 @@ describe('utils', () => {
'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');
});
});
Expand All @@ -229,8 +229,8 @@ describe('utils', () => {

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');
Expand Down Expand Up @@ -274,8 +274,8 @@ describe('utils', () => {

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(
Expand Down Expand Up @@ -343,8 +343,8 @@ describe('utils', () => {

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) {
Expand Down