tools: update eslint to 8.39.0

PR-URL: https://github.com/nodejs/node/pull/47789
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Mestery <mestery@protonmail.com>
This commit is contained in:
Node.js GitHub Bot authored and Moshe Atlow committed 2023-07-07 00:06:10 +03:00
1 parent 706c87db50
commit 951cc7b624
670 files changed
+4617 -6584

No files matched your search

+47 -4
View File
@@ -646,12 +646,12 @@ class SourceCode extends TokenStore {
}
/**
* Gets all of the declared variables in the scope associated
* with `node`. This is a convenience method that passes through
* Get the variables that `node` defines.
* This is a convenience method that passes through
* to the same method on the `scopeManager`.
* @param {ASTNode} node The node from which to retrieve the scope to check.
* @param {ASTNode} node The node for which the variables are obtained.
* @returns {Array<Variable>} An array of variable nodes representing
* the declared variables in the scope associated with `node`.
* the variables that `node` defines.
*/
getDeclaredVariables(node) {
return this.scopeManager.getDeclaredVariables(node);
@@ -681,6 +681,49 @@ class SourceCode extends TokenStore {
}
/* eslint-enable class-methods-use-this -- node is owned by SourceCode */
/**
* Marks a variable as used in the current scope
* @param {string} name The name of the variable to mark as used.
* @param {ASTNode} [refNode] The closest node to the variable reference.
* @returns {boolean} True if the variable was found and marked as used, false if not.
*/
markVariableAsUsed(name, refNode = this.ast) {
const currentScope = this.getScope(refNode);
let initialScope = currentScope;
/*
* When we are in an ESM or CommonJS module, we need to start searching
* from the top-level scope, not the global scope. For ESM the top-level
* scope is the module scope; for CommonJS the top-level scope is the
* outer function scope.
*
* Without this check, we might miss a variable declared with `var` at
* the top-level because it won't exist in the global scope.
*/
if (
currentScope.type === "global" &&
currentScope.childScopes.length > 0 &&
// top-level scopes refer to a `Program` node
currentScope.childScopes[0].block === this.ast
) {
initialScope = currentScope.childScopes[0];
}
for (let scope = initialScope; scope; scope = scope.upper) {
const variable = scope.variables.find(scopeVar => scopeVar.name === name);
if (variable) {
variable.eslintUsed = true;
return true;
}
}
return false;
}
}
module.exports = SourceCode;