Comparing version 8.37.0 to 8.38.0
@@ -31,2 +31,3 @@ /** | ||
let stack = []; | ||
const sourceCode = context.getSourceCode(); | ||
@@ -87,3 +88,3 @@ /** | ||
// Gets declared variables, and checks its references. | ||
const variables = context.getDeclaredVariables(node); | ||
const variables = sourceCode.getDeclaredVariables(node); | ||
@@ -90,0 +91,0 @@ for (let i = 0; i < variables.length; ++i) { |
@@ -299,3 +299,3 @@ /** | ||
]](node) { | ||
for (const variable of context.getDeclaredVariables(node)) { | ||
for (const variable of sourceCode.getDeclaredVariables(node)) { | ||
if (isGoodName(variable.name)) { | ||
@@ -350,3 +350,3 @@ continue; | ||
ImportDeclaration(node) { | ||
for (const variable of context.getDeclaredVariables(node)) { | ||
for (const variable of sourceCode.getDeclaredVariables(node)) { | ||
if (isGoodName(variable.name)) { | ||
@@ -353,0 +353,0 @@ continue; |
@@ -162,3 +162,3 @@ /** | ||
// Skip recursive functions. | ||
const nameVar = context.getDeclaredVariables(node)[0]; | ||
const nameVar = sourceCode.getDeclaredVariables(node)[0]; | ||
@@ -165,0 +165,0 @@ if (isFunctionName(nameVar) && nameVar.references.length > 0) { |
@@ -81,3 +81,3 @@ /** | ||
if (node.callee.name === "require" && !isShadowed(currentScope, node.callee)) { | ||
const isGoodRequire = context.getAncestors().every(parent => ACCEPTABLE_PARENTS.has(parent.type)); | ||
const isGoodRequire = sourceCode.getAncestors(node).every(parent => ACCEPTABLE_PARENTS.has(parent.type)); | ||
@@ -84,0 +84,0 @@ if (!isGoodRequire) { |
@@ -34,16 +34,7 @@ /** | ||
fixable: "code", | ||
schema: { | ||
anyOf: [ | ||
{ | ||
type: "array", | ||
items: [ | ||
{ | ||
enum: ["always", "never"] | ||
} | ||
], | ||
minItems: 0, | ||
maxItems: 1 | ||
} | ||
] | ||
}, | ||
schema: [ | ||
{ | ||
enum: ["always", "never"] | ||
} | ||
], | ||
messages: { | ||
@@ -50,0 +41,0 @@ missing: "Missing '()' invoking a constructor.", |
@@ -34,2 +34,4 @@ /** | ||
const sourceCode = context.getSourceCode(); | ||
/** | ||
@@ -53,3 +55,3 @@ * Finds and reports references that are non initializer and writable. | ||
function checkForClass(node) { | ||
context.getDeclaredVariables(node).forEach(checkVariable); | ||
sourceCode.getDeclaredVariables(node).forEach(checkVariable); | ||
} | ||
@@ -56,0 +58,0 @@ |
@@ -34,2 +34,4 @@ /** | ||
const sourceCode = context.getSourceCode(); | ||
/** | ||
@@ -49,3 +51,3 @@ * Finds and reports references that are non initializer and writable. | ||
if (node.kind === "const") { | ||
context.getDeclaredVariables(node).forEach(checkVariable); | ||
sourceCode.getDeclaredVariables(node).forEach(checkVariable); | ||
} | ||
@@ -52,0 +54,0 @@ } |
@@ -18,3 +18,3 @@ /** | ||
docs: { | ||
description: "Disallow division operators explicitly at the beginning of regular expressions", | ||
description: "Disallow equal signs explicitly at the beginning of regular expressions", | ||
recommended: false, | ||
@@ -21,0 +21,0 @@ url: "https://eslint.org/docs/rules/no-div-regex" |
@@ -32,2 +32,4 @@ /** | ||
const sourceCode = context.getSourceCode(); | ||
//-------------------------------------------------------------------------- | ||
@@ -53,3 +55,3 @@ // Helpers | ||
function checkParams(node) { | ||
const variables = context.getDeclaredVariables(node); | ||
const variables = sourceCode.getDeclaredVariables(node); | ||
@@ -56,0 +58,0 @@ for (let i = 0; i < variables.length; ++i) { |
@@ -34,2 +34,4 @@ /** | ||
const sourceCode = context.getSourceCode(); | ||
/** | ||
@@ -48,3 +50,3 @@ * Finds and reports references that are non initializer and writable. | ||
CatchClause(node) { | ||
context.getDeclaredVariables(node).forEach(checkVariable); | ||
sourceCode.getDeclaredVariables(node).forEach(checkVariable); | ||
} | ||
@@ -51,0 +53,0 @@ }; |
@@ -34,2 +34,4 @@ /** | ||
const sourceCode = context.getSourceCode(); | ||
/** | ||
@@ -69,3 +71,3 @@ * Reports a reference if is non initializer and writable. | ||
function checkForFunction(node) { | ||
context.getDeclaredVariables(node).forEach(checkVariable); | ||
sourceCode.getDeclaredVariables(node).forEach(checkVariable); | ||
} | ||
@@ -72,0 +74,0 @@ |
@@ -203,3 +203,3 @@ /** | ||
for (const variable of context.getDeclaredVariables(node)) { | ||
for (const variable of sourceCode.getDeclaredVariables(node)) { | ||
const shouldCheckMembers = variable.defs.some( | ||
@@ -206,0 +206,0 @@ d => d.node.type === "ImportNamespaceSpecifier" |
@@ -71,5 +71,6 @@ /** | ||
* and "marks it" as valid if any. | ||
* @param {ASTNode} node The current node to check. | ||
* @returns {void} | ||
*/ | ||
function markLoneBlock() { | ||
function markLoneBlock(node) { | ||
if (loneBlocks.length === 0) { | ||
@@ -79,3 +80,3 @@ return; | ||
const block = context.getAncestors().pop(); | ||
const block = sourceCode.getAncestors(node).pop(); | ||
@@ -122,3 +123,3 @@ if (loneBlocks[loneBlocks.length - 1] === block) { | ||
if (node.kind === "let" || node.kind === "const") { | ||
markLoneBlock(); | ||
markLoneBlock(node); | ||
} | ||
@@ -129,3 +130,3 @@ }; | ||
if (sourceCode.getScope(node).isStrict) { | ||
markLoneBlock(); | ||
markLoneBlock(node); | ||
} | ||
@@ -132,0 +133,0 @@ }; |
@@ -35,3 +35,3 @@ /** | ||
IfStatement(node) { | ||
const ancestors = context.getAncestors(), | ||
const ancestors = sourceCode.getAncestors(node), | ||
parent = ancestors.pop(), | ||
@@ -38,0 +38,0 @@ grandparent = ancestors.pop(); |
@@ -73,2 +73,3 @@ /** | ||
const ignoredPropertyAssignmentsForRegex = context.options[0] && context.options[0].ignorePropertyModificationsForRegex || []; | ||
const sourceCode = context.getSourceCode(); | ||
@@ -218,3 +219,3 @@ /** | ||
function checkForFunction(node) { | ||
context.getDeclaredVariables(node).forEach(checkVariable); | ||
sourceCode.getDeclaredVariables(node).forEach(checkVariable); | ||
} | ||
@@ -221,0 +222,0 @@ |
@@ -102,2 +102,3 @@ /** | ||
const restrictDefaultExports = context.options[0] && context.options[0].restrictDefaultExports; | ||
const sourceCode = context.getSourceCode(); | ||
@@ -180,3 +181,3 @@ /** | ||
} else if (declaration.type === "VariableDeclaration") { | ||
context.getDeclaredVariables(declaration) | ||
sourceCode.getDeclaredVariables(declaration) | ||
.map(v => v.defs.find(d => d.parent === declaration)) | ||
@@ -183,0 +184,0 @@ .map(d => d.name) // Identifier nodes |
@@ -46,6 +46,7 @@ /** | ||
const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]); | ||
const sourceCode = context.getSourceCode(); | ||
return { | ||
"VariableDeclaration, :function, CatchClause"(node) { | ||
for (const variable of context.getDeclaredVariables(node)) { | ||
for (const variable of sourceCode.getDeclaredVariables(node)) { | ||
if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) { | ||
@@ -52,0 +53,0 @@ context.report({ |
@@ -87,2 +87,3 @@ /** | ||
const allowInObjectDestructuring = typeof options.allowInObjectDestructuring !== "undefined" ? options.allowInObjectDestructuring : true; | ||
const sourceCode = context.getSourceCode(); | ||
@@ -217,3 +218,3 @@ //------------------------------------------------------------------------- | ||
function checkForDanglingUnderscoreInVariableExpression(node) { | ||
context.getDeclaredVariables(node).forEach(variable => { | ||
sourceCode.getDeclaredVariables(node).forEach(variable => { | ||
const definition = variable.defs.find(def => def.node === node); | ||
@@ -220,0 +221,0 @@ const identifierNode = definition.name; |
@@ -73,3 +73,4 @@ /** | ||
allowTaggedTemplates = config.allowTaggedTemplates || false, | ||
enforceForJSX = config.enforceForJSX || false; | ||
enforceForJSX = config.enforceForJSX || false, | ||
sourceCode = context.getSourceCode(); | ||
@@ -184,3 +185,3 @@ /** | ||
ExpressionStatement(node) { | ||
if (Checker.isDisallowed(node.expression) && !isDirective(node, context.getAncestors())) { | ||
if (Checker.isDisallowed(node.expression) && !isDirective(node, sourceCode.getAncestors(node))) { | ||
context.report({ node, messageId: "unusedExpression" }); | ||
@@ -187,0 +188,0 @@ } |
@@ -558,3 +558,3 @@ /** | ||
const def = variable.defs[0]; | ||
const params = context.getDeclaredVariables(def.node); | ||
const params = sourceCode.getDeclaredVariables(def.node); | ||
const posteriorParams = params.slice(params.indexOf(variable) + 1); | ||
@@ -561,0 +561,0 @@ |
@@ -213,3 +213,3 @@ /** | ||
} | ||
const variables = context.getDeclaredVariables(declarator); | ||
const variables = sourceCode.getDeclaredVariables(declarator); | ||
@@ -272,3 +272,3 @@ return variables.some(hasReferenceInTDZ(declarator.init)); | ||
function canFix(node) { | ||
const variables = context.getDeclaredVariables(node); | ||
const variables = sourceCode.getDeclaredVariables(node); | ||
const scopeNode = getScopeNode(node); | ||
@@ -275,0 +275,0 @@ |
@@ -266,3 +266,3 @@ /** | ||
// Skip recursive functions. | ||
const nameVar = context.getDeclaredVariables(node)[0]; | ||
const nameVar = sourceCode.getDeclaredVariables(node)[0]; | ||
@@ -269,0 +269,0 @@ if (isFunctionName(nameVar) && nameVar.references.length > 0) { |
@@ -496,3 +496,3 @@ /** | ||
if (node.kind === "let" && !isInitOfForStatement(node)) { | ||
variables.push(...context.getDeclaredVariables(node)); | ||
variables.push(...sourceCode.getDeclaredVariables(node)); | ||
} | ||
@@ -499,0 +499,0 @@ } |
@@ -44,2 +44,3 @@ /** | ||
const ALLOW_EMPTY_REJECT = context.options.length && context.options[0].allowEmptyReject; | ||
const sourceCode = context.getSourceCode(); | ||
@@ -104,3 +105,3 @@ //---------------------------------------------------------------------- | ||
) { | ||
context.getDeclaredVariables(node.arguments[0]) | ||
sourceCode.getDeclaredVariables(node.arguments[0]) | ||
@@ -107,0 +108,0 @@ /* |
@@ -81,2 +81,6 @@ /** | ||
const [patternNode, flagsNode] = refNode.arguments; | ||
if (patternNode && patternNode.type === "SpreadElement") { | ||
continue; | ||
} | ||
const pattern = getStringIfConstant(patternNode, scope); | ||
@@ -83,0 +87,0 @@ const flags = getStringIfConstant(flagsNode, scope); |
@@ -86,3 +86,3 @@ /** | ||
if (isTypeofExpression(node)) { | ||
const parent = context.getAncestors().pop(); | ||
const parent = sourceCode.getAncestors(node).pop(); | ||
@@ -89,0 +89,0 @@ if (parent.type === "BinaryExpression" && OPERATORS.has(parent.operator)) { |
@@ -43,3 +43,3 @@ /** | ||
const afterToken = sourceCode.getTokenAfter(node); | ||
const ancestors = context.getAncestors(); | ||
const ancestors = sourceCode.getAncestors(node); | ||
const grandparent = ancestors[ancestors.length - 1]; | ||
@@ -46,0 +46,0 @@ |
@@ -346,3 +346,3 @@ /** | ||
isComparisonOperator(node.operator) && | ||
!(exceptRange && isRangeTest(context.getAncestors().pop())) | ||
!(exceptRange && isRangeTest(sourceCode.getAncestors(node).pop())) | ||
) { | ||
@@ -349,0 +349,0 @@ context.report({ |
@@ -18,2 +18,8 @@ /** | ||
//------------------------------------------------------------------------------ | ||
// Type Definitions | ||
//------------------------------------------------------------------------------ | ||
/** @typedef {import("eslint-scope").Variable} Variable */ | ||
//------------------------------------------------------------------------------ | ||
// Private | ||
@@ -643,4 +649,40 @@ //------------------------------------------------------------------------------ | ||
/** | ||
* 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; |
{ | ||
"name": "eslint", | ||
"version": "8.37.0", | ||
"version": "8.38.0", | ||
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>", | ||
@@ -66,3 +66,3 @@ "description": "An AST-based pattern checker for JavaScript.", | ||
"@eslint/eslintrc": "^2.0.2", | ||
"@eslint/js": "8.37.0", | ||
"@eslint/js": "8.38.0", | ||
"@humanwhocodes/config-array": "^0.11.8", | ||
@@ -69,0 +69,0 @@ "@humanwhocodes/module-importer": "^1.0.1", |
@@ -247,7 +247,2 @@ [![npm version](https://img.shields.io/npm/v/eslint.svg)](https://www.npmjs.com/package/eslint) | ||
</td><td align="center" valign="top" width="11%"> | ||
<a href="https://github.com/btmills"> | ||
<img src="https://github.com/btmills.png?s=75" width="75" height="75"><br /> | ||
Brandon Mills | ||
</a> | ||
</td><td align="center" valign="top" width="11%"> | ||
<a href="https://github.com/fasttime"> | ||
@@ -254,0 +249,0 @@ <img src="https://github.com/fasttime.png?s=75" width="75" height="75"><br /> |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2877449
68117
299
+ Added@eslint/js@8.38.0(transitive)
- Removed@eslint/js@8.37.0(transitive)
Updated@eslint/js@8.38.0