mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
tools: update eslint to 8.38.0
PR-URL: https://github.com/nodejs/node/pull/47475 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
This commit is contained in:
1 parent
24840832bd
commit
60dc249cd5
886 files changed
+1961
-1987
No files matched your search
+42
@@ -14,6 +14,12 @@ const
|
||||
astUtils = require("../shared/ast-utils"),
|
||||
Traverser = require("../shared/traverser");
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Type Definitions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
/** @typedef {import("eslint-scope").Variable} Variable */
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Private
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -639,6 +645,42 @@ class SourceCode extends TokenStore {
|
||||
return this.scopeManager.scopes[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all of the declared variables in the scope associated
|
||||
* with `node`. 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.
|
||||
* @returns {Array<Variable>} An array of variable nodes representing
|
||||
* the declared variables in the scope associated with `node`.
|
||||
*/
|
||||
getDeclaredVariables(node) {
|
||||
return this.scopeManager.getDeclaredVariables(node);
|
||||
}
|
||||
|
||||
/* eslint-disable class-methods-use-this -- node is owned by SourceCode */
|
||||
/**
|
||||
* Gets all the ancestors of a given node
|
||||
* @param {ASTNode} node The node
|
||||
* @returns {Array<ASTNode>} All the ancestor nodes in the AST, not including the provided node, starting
|
||||
* from the root node at index 0 and going inwards to the parent node.
|
||||
* @throws {TypeError} When `node` is missing.
|
||||
*/
|
||||
getAncestors(node) {
|
||||
|
||||
if (!node) {
|
||||
throw new TypeError("Missing required argument: node.");
|
||||
}
|
||||
|
||||
const ancestorsStartingAtParent = [];
|
||||
|
||||
for (let ancestor = node.parent; ancestor; ancestor = ancestor.parent) {
|
||||
ancestorsStartingAtParent.push(ancestor);
|
||||
}
|
||||
|
||||
return ancestorsStartingAtParent.reverse();
|
||||
}
|
||||
/* eslint-enable class-methods-use-this -- node is owned by SourceCode */
|
||||
|
||||
}
|
||||
|
||||
module.exports = SourceCode;
|
||||
Reference in new issue
Block a user