From 59b160624bd725a1254024bcbbd28b7529c04c64 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Mon, 18 Mar 2024 19:32:02 +0100 Subject: [PATCH] refactor: switch to eslint flat config (#121) * refactor: switch to eslint flat config * remove .eslintignore --- .eslintignore | 1 - .eslintrc.cjs | 30 -------------- Makefile.js | 38 ------------------ eslint.config.js | 46 ++++++++++++++++++++++ lib/index.js | 1 - lib/pattern-visitor.js | 7 ++-- lib/referencer.js | 20 +++++----- lib/scope-manager.js | 6 +-- lib/scope.js | 54 +++++++++++++++++++++----- package.json | 14 +++---- tests/arguments.js | 2 - tests/catch-scope.js | 2 - tests/es6-arrow-function-expression.js | 2 - tests/es6-block-scope.js | 2 - tests/es6-catch.js | 2 - tests/es6-class.js | 2 - tests/es6-default-parameters.js | 35 ++++------------- tests/es6-destructuring-assignments.js | 2 - tests/es6-import.js | 2 - tests/es6-iteration-scope.js | 2 - tests/es6-new-target.js | 2 - tests/es6-object.js | 2 - tests/es6-rest-args.js | 2 - tests/es6-switch.js | 2 - tests/es6-template-literal.js | 2 - tests/function-expression-name.js | 2 - tests/get-declared-variables.js | 11 +++++- tests/global-increment.js | 2 - tests/implied-strict.js | 2 - tests/label.js | 2 - tests/nodejs-scope.js | 2 - tests/references.js | 2 - tests/typescript.js | 2 - tests/util/ecma-version.js | 1 + tests/with-scope.js | 2 - 35 files changed, 133 insertions(+), 175 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.cjs create mode 100644 eslint.config.js diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 09a8422..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -!.eslintrc.js diff --git a/.eslintrc.cjs b/.eslintrc.cjs deleted file mode 100644 index 3b591b1..0000000 --- a/.eslintrc.cjs +++ /dev/null @@ -1,30 +0,0 @@ -"use strict"; - -module.exports = { - root: true, - extends: [ - "eslint", - "plugin:node/recommended-module" - ], - parserOptions: { - sourceType: "module", - ecmaVersion: "2020" - }, - overrides: [ - { - files: ["tests/**/*"], - env: { - mocha: true - } - }, - { - files: ["*.cjs"], - extends: ["eslint", "plugin:node/recommended-script"], - parserOptions: { - sourceType: "script", - ecmaVersion: "2020" - } - } - ], - ignorePatterns: ["/dist", "/coverage"] -}; diff --git a/Makefile.js b/Makefile.js index 31b2c95..8e5eb39 100644 --- a/Makefile.js +++ b/Makefile.js @@ -4,9 +4,7 @@ * @copyright jQuery Foundation and other contributors, https://jquery.org/ * MIT License */ -/* global echo, exec, exit, set, target */ -/* eslint no-console: 0*/ //------------------------------------------------------------------------------ // Requirements //------------------------------------------------------------------------------ @@ -40,15 +38,12 @@ const NODE = "node", // Utilities - intentional extra space at the end of each string MOCHA = `${NODE_MODULES}/mocha/bin/_mocha `, - ESLINT = `${NODE} ${NODE_MODULES}/eslint/bin/eslint `, // If switching back to Istanbul when may be working with ESM // ISTANBUL = `${NODE} ${NODE_MODULES}/istanbul/lib/cli.js `, C8 = `${NODE} ${NODE_MODULES}/c8/bin/c8.js`, // Files - MAKEFILE = "./Makefile.js", - JS_FILES = "lib/**/*.js", TEST_FILES = "tests/*.js", CJS_TEST_FILES = "tests/*.cjs"; @@ -60,39 +55,6 @@ target.all = function() { target.test(); }; -target.lint = function() { - let errors = 0, - lastReturn; - - echo("Validating Makefile.js"); - lastReturn = exec(ESLINT + MAKEFILE); - if (lastReturn.code !== 0) { - errors++; - } - - echo("Validating JavaScript files"); - lastReturn = exec(ESLINT + JS_FILES); - if (lastReturn.code !== 0) { - errors++; - } - - echo("Validating JavaScript test files"); - lastReturn = exec(ESLINT + TEST_FILES); - if (lastReturn.code !== 0) { - errors++; - } - - echo("Validating CJS JavaScript test files"); - lastReturn = exec(ESLINT + CJS_TEST_FILES); - if (lastReturn.code !== 0) { - errors++; - } - - if (errors) { - exit(1); - } -}; - target.test = function() { let errors = 0; let lastReturn = exec(`${NODE} ${MOCHA} -- -R progress -c ${CJS_TEST_FILES}`); diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..aef0b6c --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,46 @@ +import eslintConfigESLint from "eslint-config-eslint"; +import globals from "globals"; +import eslintPluginChaiFriendly from "eslint-plugin-chai-friendly"; + +export default [ + { + ignores: [ + "dist/", + "coverage/" + ] + }, + ...eslintConfigESLint, + { + files: ["lib/**"], + rules: { + "no-underscore-dangle": "off" + } + }, + { + files: ["tests/**"], + ignores: ["tests/util/**"], + languageOptions: { + globals: { + ...globals.mocha + } + }, + plugins: { + "chai-friendly": eslintPluginChaiFriendly + }, + rules: { + "no-unused-expressions": "off", + "chai-friendly/no-unused-expressions": "error" + } + }, + { + files: ["Makefile.js"], + languageOptions: { + globals: { + ...globals.shelljs + } + }, + rules: { + "no-console": "off" + } + } +]; diff --git a/lib/index.js b/lib/index.js index 03ae395..afe7c7a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -45,7 +45,6 @@ * The main interface is the {@link analyze} function. * @module escope */ -/* eslint no-underscore-dangle: ["error", { "allow": ["__currentScope"] }] */ import assert from "assert"; diff --git a/lib/pattern-visitor.js b/lib/pattern-visitor.js index a9ff48e..212409c 100644 --- a/lib/pattern-visitor.js +++ b/lib/pattern-visitor.js @@ -22,8 +22,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* eslint-disable no-undefined */ - import estraverse from "estraverse"; import esrecurse from "esrecurse"; @@ -38,6 +36,9 @@ function getLast(xs) { return xs[xs.length - 1] || null; } +/** + * Visitor for destructuring patterns. + */ class PatternVisitor extends esrecurse.Visitor { static isPattern(node) { const nodeType = node.type; @@ -66,7 +67,7 @@ class PatternVisitor extends esrecurse.Visitor { this.callback(pattern, { topLevel: pattern === this.rootPattern, - rest: lastRestElement !== null && lastRestElement !== undefined && lastRestElement.argument === pattern, + rest: lastRestElement !== null && lastRestElement !== void 0 && lastRestElement.argument === pattern, assignments: this.assignments }); } diff --git a/lib/referencer.js b/lib/referencer.js index b8f3c58..07938c1 100644 --- a/lib/referencer.js +++ b/lib/referencer.js @@ -22,9 +22,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* eslint-disable no-underscore-dangle */ -/* eslint-disable no-undefined */ - import estraverse from "estraverse"; import esrecurse from "esrecurse"; import Reference from "./reference.js"; @@ -51,7 +48,7 @@ function traverseIdentifierInPattern(options, rootPattern, referencer, callback) visitor.visit(rootPattern); // Process the right hand nodes recursively. - if (referencer !== null && referencer !== undefined) { + if (referencer !== null && referencer !== void 0) { visitor.rightHandNodes.forEach(referencer.visit, referencer); } } @@ -62,6 +59,9 @@ function traverseIdentifierInPattern(options, rootPattern, referencer, callback) // FIXME: Now, we don't create module environment, because the context is // implementation dependent. +/** + * Visitor for import specifiers. + */ class Importer extends esrecurse.Visitor { constructor(declaration, referencer) { super(null, referencer.options); @@ -108,7 +108,9 @@ class Importer extends esrecurse.Visitor { } } -// Referencing variables and creating bindings. +/** + * Referencing variables and creating bindings. + */ class Referencer extends esrecurse.Visitor { constructor(options, scopeManager) { super(null, options); @@ -432,7 +434,7 @@ class Referencer extends esrecurse.Visitor { this.currentScope().__referencing(node); } - // eslint-disable-next-line class-methods-use-this + // eslint-disable-next-line class-methods-use-this -- Desired as instance method PrivateIdentifier() { // Do nothing. @@ -482,9 +484,9 @@ class Referencer extends esrecurse.Visitor { this.visitProperty(node); } - BreakStatement() {} // eslint-disable-line class-methods-use-this + BreakStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method - ContinueStatement() {} // eslint-disable-line class-methods-use-this + ContinueStatement() {} // eslint-disable-line class-methods-use-this -- Desired as instance method LabeledStatement(node) { this.visit(node.body); @@ -643,7 +645,7 @@ class Referencer extends esrecurse.Visitor { this.visit(local); } - MetaProperty() { // eslint-disable-line class-methods-use-this + MetaProperty() { // eslint-disable-line class-methods-use-this -- Desired as instance method // do nothing. } diff --git a/lib/scope-manager.js b/lib/scope-manager.js index f59eac0..2a63c0d 100644 --- a/lib/scope-manager.js +++ b/lib/scope-manager.js @@ -22,8 +22,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* eslint-disable no-underscore-dangle */ - import { BlockScope, CatchScope, @@ -180,9 +178,9 @@ class ScopeManager { return null; } - attach() { } // eslint-disable-line class-methods-use-this + attach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method - detach() { } // eslint-disable-line class-methods-use-this + detach() { } // eslint-disable-line class-methods-use-this -- Desired as instance method __nestScope(scope) { if (scope instanceof GlobalScope) { diff --git a/lib/scope.js b/lib/scope.js index 4e5a732..5bed887 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -22,9 +22,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/* eslint-disable no-underscore-dangle */ -/* eslint-disable no-undefined */ - import estraverse from "estraverse"; import Reference from "./reference.js"; @@ -160,7 +157,8 @@ class Scope { /** * The tainted variables of this scope, as { Variable.name : * boolean }. - * @member {Map} Scope#taints */ + * @member {Map} Scope#taints + */ this.taints = new Map(); /** @@ -339,7 +337,7 @@ class Scope { // To override by function scopes. // References in default parameters isn't resolved to variables which are in their function body. - __isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars + __isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars -- Desired as instance method with signature return true; } @@ -373,17 +371,17 @@ class Scope { } __addDeclaredVariablesOfNode(variable, node) { - if (node === null || node === undefined) { + if (node === null || node === void 0) { return; } let variables = this.__declaredVariables.get(node); - if (variables === null || variables === undefined) { + if (variables === null || variables === void 0) { variables = []; this.__declaredVariables.set(node, variables); } - if (variables.indexOf(variable) === -1) { + if (!variables.includes(variable)) { variables.push(variable); } } @@ -490,7 +488,7 @@ class Scope { * @function Scope#isArgumentsMaterialized * @returns {boolean} arguemnts materialized */ - isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this + isArgumentsMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method return true; } @@ -499,7 +497,7 @@ class Scope { * @function Scope#isThisMaterialized * @returns {boolean} this materialized */ - isThisMaterialized() { // eslint-disable-line class-methods-use-this + isThisMaterialized() { // eslint-disable-line class-methods-use-this -- Desired as instance method return true; } @@ -516,6 +514,9 @@ class Scope { } } +/** + * Global scope. + */ class GlobalScope extends Scope { constructor(scopeManager, block) { super(scopeManager, "global", null, block, false); @@ -577,12 +578,18 @@ class GlobalScope extends Scope { } } +/** + * Module scope. + */ class ModuleScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "module", upperScope, block, false); } } +/** + * Function expression name scope. + */ class FunctionExpressionNameScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "function-expression-name", upperScope, block, false); @@ -599,12 +606,18 @@ class FunctionExpressionNameScope extends Scope { } } +/** + * Catch scope. + */ class CatchScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "catch", upperScope, block, false); } } +/** + * With statement scope. + */ class WithScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "with", upperScope, block, false); @@ -627,18 +640,27 @@ class WithScope extends Scope { } } +/** + * Block scope. + */ class BlockScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "block", upperScope, block, false); } } +/** + * Switch scope. + */ class SwitchScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "switch", upperScope, block, false); } } +/** + * Function scope. + */ class FunctionScope extends Scope { constructor(scopeManager, upperScope, block, isMethodDefinition) { super(scopeManager, "function", upperScope, block, isMethodDefinition); @@ -716,24 +738,36 @@ class FunctionScope extends Scope { } } +/** + * Scope of for, for-in, and for-of statements. + */ class ForScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "for", upperScope, block, false); } } +/** + * Class scope. + */ class ClassScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "class", upperScope, block, false); } } +/** + * Class field initializer scope. + */ class ClassFieldInitializerScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "class-field-initializer", upperScope, block, true); } } +/** + * Class static block scope. + */ class ClassStaticBlockScope extends Scope { constructor(scopeManager, upperScope, block) { super(scopeManager, "class-static-block", upperScope, block, true); diff --git a/package.json b/package.json index 5248d97..f313d5a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "scripts": { "build": "rollup -c", "build:update-version": "node tools/update-version.js", - "lint": "node Makefile.js lint", + "lint": "eslint . --report-unused-disable-directives", "prelint": "npm run build", "prepublishOnly": "npm run build:update-version && npm run build", "pretest": "npm run build", @@ -46,20 +46,20 @@ "estraverse": "^5.2.0" }, "devDependencies": { - "@typescript-eslint/parser": "^4.28.1", + "@typescript-eslint/parser": "^7.1.1", "c8": "^7.7.3", "chai": "^4.3.4", - "eslint": "^7.29.0", - "eslint-config-eslint": "^7.0.0", - "eslint-plugin-jsdoc": "^35.4.1", - "eslint-plugin-node": "^11.1.0", + "eslint": "^8.57.0", + "eslint-config-eslint": "^9.0.0", + "eslint-plugin-chai-friendly": "^0.7.4", "eslint-release": "^3.2.0", "eslint-visitor-keys": "^4.0.0", "espree": "^10.0.1", + "globals": "^14.0.0", "mocha": "^9.0.1", "npm-license": "^0.3.3", "rollup": "^2.52.7", "shelljs": "^0.8.4", - "typescript": "^4.3.5" + "typescript": "^5.4.2" } } diff --git a/tests/arguments.js b/tests/arguments.js index 268f210..6616160 100644 --- a/tests/arguments.js +++ b/tests/arguments.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/catch-scope.js b/tests/catch-scope.js index e27f7f6..3ef11e8 100644 --- a/tests/catch-scope.js +++ b/tests/catch-scope.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/es6-arrow-function-expression.js b/tests/es6-arrow-function-expression.js index 87beafc..c47f25c 100644 --- a/tests/es6-arrow-function-expression.js +++ b/tests/es6-arrow-function-expression.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/es6-block-scope.js b/tests/es6-block-scope.js index 7f18f07..939003a 100644 --- a/tests/es6-block-scope.js +++ b/tests/es6-block-scope.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { getSupportedEcmaVersions } from "./util/ecma-version.js"; diff --git a/tests/es6-catch.js b/tests/es6-catch.js index 26419f3..5997b66 100644 --- a/tests/es6-catch.js +++ b/tests/es6-catch.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/es6-class.js b/tests/es6-class.js index 6c149aa..1d38cb2 100644 --- a/tests/es6-class.js +++ b/tests/es6-class.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/es6-default-parameters.js b/tests/es6-default-parameters.js index ef7f28d..b523fa7 100644 --- a/tests/es6-default-parameters.js +++ b/tests/es6-default-parameters.js @@ -21,9 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ -/* eslint-disable guard-for-in */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; @@ -36,9 +33,7 @@ describe("ES6 default parameters:", () => { ArrowExpression: "let foo = (a, b = 0) => {};" }; - for (const name in patterns) { - const code = patterns[name]; - + for (const [name, code] of Object.entries(patterns)) { it(name, () => { const numVars = name === "ArrowExpression" ? 2 : 3; const ast = espree(code); @@ -80,9 +75,7 @@ describe("ES6 default parameters:", () => { ` }; - for (const name in patterns) { - const code = patterns[name]; - + for (const [name, code] of Object.entries(patterns)) { it(name, () => { const numVars = name === "ArrowExpression" ? 1 : 2; const ast = espree(code); @@ -124,9 +117,7 @@ describe("ES6 default parameters:", () => { ` }; - for (const name in patterns) { - const code = patterns[name]; - + for (const [name, code] of Object.entries(patterns)) { it(name, () => { const numVars = name === "ArrowExpression" ? 1 : 2; const ast = espree(code); @@ -168,9 +159,7 @@ describe("ES6 default parameters:", () => { ` }; - for (const name in patterns) { - const code = patterns[name]; - + for (const [name, code] of Object.entries(patterns)) { it(name, () => { const numVars = name === "ArrowExpression" ? 1 : 2; const ast = espree(code); @@ -212,9 +201,7 @@ describe("ES6 default parameters:", () => { ` }; - for (const name in patterns) { - const code = patterns[name]; - + for (const [name, code] of Object.entries(patterns)) { it(name, () => { const ast = espree(code); @@ -255,9 +242,7 @@ describe("ES6 default parameters:", () => { ` }; - for (const name in patterns) { - const code = patterns[name]; - + for (const [name, code] of Object.entries(patterns)) { it(name, () => { const numVars = name === "ArrowExpression" ? 2 : 3; const ast = espree(code); @@ -299,9 +284,7 @@ describe("ES6 default parameters:", () => { ` }; - for (const name in patterns) { - const code = patterns[name]; - + for (const [name, code] of Object.entries(patterns)) { it(name, () => { const numVars = name === "ArrowExpression" ? 2 : 3; const ast = espree(code); @@ -343,9 +326,7 @@ describe("ES6 default parameters:", () => { ` }; - for (const name in patterns) { - const code = patterns[name]; - + for (const [name, code] of Object.entries(patterns)) { it(name, () => { const ast = espree(code); diff --git a/tests/es6-destructuring-assignments.js b/tests/es6-destructuring-assignments.js index 9a85808..c9ca803 100644 --- a/tests/es6-destructuring-assignments.js +++ b/tests/es6-destructuring-assignments.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/es6-import.js b/tests/es6-import.js index 7c66588..be52076 100644 --- a/tests/es6-import.js +++ b/tests/es6-import.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { getSupportedEcmaVersions } from "./util/ecma-version.js"; diff --git a/tests/es6-iteration-scope.js b/tests/es6-iteration-scope.js index f8b0613..b032ef6 100644 --- a/tests/es6-iteration-scope.js +++ b/tests/es6-iteration-scope.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { getSupportedEcmaVersions } from "./util/ecma-version.js"; diff --git a/tests/es6-new-target.js b/tests/es6-new-target.js index dc10c58..2ffd9f1 100644 --- a/tests/es6-new-target.js +++ b/tests/es6-new-target.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/es6-object.js b/tests/es6-object.js index e94967d..cf6df9a 100644 --- a/tests/es6-object.js +++ b/tests/es6-object.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/es6-rest-args.js b/tests/es6-rest-args.js index 36dc61e..0e13957 100644 --- a/tests/es6-rest-args.js +++ b/tests/es6-rest-args.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/es6-switch.js b/tests/es6-switch.js index 13971ba..a8f4d3f 100644 --- a/tests/es6-switch.js +++ b/tests/es6-switch.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { getSupportedEcmaVersions } from "./util/ecma-version.js"; diff --git a/tests/es6-template-literal.js b/tests/es6-template-literal.js index d72a5bb..23aea3d 100644 --- a/tests/es6-template-literal.js +++ b/tests/es6-template-literal.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/function-expression-name.js b/tests/function-expression-name.js index ef238d8..54445ce 100644 --- a/tests/function-expression-name.js +++ b/tests/function-expression-name.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/get-declared-variables.js b/tests/get-declared-variables.js index 48b54eb..1fd8253 100644 --- a/tests/get-declared-variables.js +++ b/tests/get-declared-variables.js @@ -29,7 +29,16 @@ import { analyze } from "../lib/index.js"; const { visit } = esrecurse; describe("ScopeManager.prototype.getDeclaredVariables", () => { - /* eslint-disable jsdoc/require-jsdoc */ + + + /** + * Asserts that nodes of the given type declare expected variables. + * @param {Object} ast The AST to check. + * @param {string} type The node type to check. + * @param {string[][]} expectedNamesList List of expected variable names for each node of the given type. + * @throws {Error} If the list of declared variables doesn't match the expected list. + * @returns {void} + */ function verify(ast, type, expectedNamesList) { const scopeManager = analyze(ast, { ecmaVersion: 6, diff --git a/tests/global-increment.js b/tests/global-increment.js index 53517d9..c4e8634 100644 --- a/tests/global-increment.js +++ b/tests/global-increment.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/implied-strict.js b/tests/implied-strict.js index 9168a49..cc4bcf6 100644 --- a/tests/implied-strict.js +++ b/tests/implied-strict.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { getSupportedEcmaVersions } from "./util/ecma-version.js"; diff --git a/tests/label.js b/tests/label.js index f3330b3..3d0ff19 100644 --- a/tests/label.js +++ b/tests/label.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/nodejs-scope.js b/tests/nodejs-scope.js index d532075..cd75985 100644 --- a/tests/nodejs-scope.js +++ b/tests/nodejs-scope.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/references.js b/tests/references.js index b9b4213..d25dcc3 100644 --- a/tests/references.js +++ b/tests/references.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js"; diff --git a/tests/typescript.js b/tests/typescript.js index 8ac53c2..aa42927 100644 --- a/tests/typescript.js +++ b/tests/typescript.js @@ -3,8 +3,6 @@ * @author Reyad Attiyat */ -/* eslint-disable no-unused-expressions */ - //------------------------------------------------------------------------------ // Requirements //------------------------------------------------------------------------------ diff --git a/tests/util/ecma-version.js b/tests/util/ecma-version.js index befc4ff..22cc674 100644 --- a/tests/util/ecma-version.js +++ b/tests/util/ecma-version.js @@ -16,6 +16,7 @@ import * as espree from "espree"; * * getSupportedEcmaVersions({ min: 8 }) * // => [8, 2017, 9, 2018, 10, 2019, 11, 2020, 12, 2021, 13, 2022] + * */ export function getSupportedEcmaVersions({ min = 0 } = {}) { return espree.supportedEcmaVersions diff --git a/tests/with-scope.js b/tests/with-scope.js index f90bd33..fc21010 100644 --- a/tests/with-scope.js +++ b/tests/with-scope.js @@ -21,8 +21,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -/* eslint-disable no-unused-expressions */ - import { expect } from "chai"; import espree from "./util/espree.js"; import { analyze } from "../lib/index.js";