Comparing version 9.16.0 to 9.17.0
@@ -110,3 +110,3 @@ /** | ||
messages.forEach(problem => { | ||
if (Object.hasOwn(problem, "fix")) { | ||
if (Object.hasOwn(problem, "fix") && problem.fix) { | ||
fixes.push(problem); | ||
@@ -113,0 +113,0 @@ } else { |
/** | ||
* @fileoverview Rule to enforce default clauses in switch statements to be last | ||
* @fileoverview Rule to enforce `default` clauses in switch statements to be last | ||
* @author Milos Djermanovic | ||
@@ -18,3 +18,3 @@ */ | ||
docs: { | ||
description: "Enforce default clauses in switch statements to be last", | ||
description: "Enforce `default` clauses in switch statements to be last", | ||
recommended: false, | ||
@@ -21,0 +21,0 @@ url: "https://eslint.org/docs/latest/rules/default-case-last" |
/** | ||
* @fileoverview enforce "for" loop update clause moving the counter in the right direction.(for-direction) | ||
* @fileoverview enforce `for` loop update clause moving the counter in the right direction.(for-direction) | ||
* @author Aladdin-ADD<hh_2013@foxmail.com> | ||
@@ -24,3 +24,3 @@ */ | ||
docs: { | ||
description: "Enforce \"for\" loop update clause moving the counter in the right direction", | ||
description: "Enforce `for` loop update clause moving the counter in the right direction", | ||
recommended: true, | ||
@@ -27,0 +27,0 @@ url: "https://eslint.org/docs/latest/rules/for-direction" |
/** | ||
* @fileoverview Disallow reassignment of function parameters. | ||
* @fileoverview Disallow reassigning function parameters. | ||
* @author Nat Burns | ||
@@ -19,3 +19,3 @@ */ | ||
docs: { | ||
description: "Disallow reassigning `function` parameters", | ||
description: "Disallow reassigning function parameters", | ||
recommended: false, | ||
@@ -22,0 +22,0 @@ url: "https://eslint.org/docs/latest/rules/no-param-reassign" |
/** | ||
* @fileoverview Rule to flag when using javascript: urls | ||
* @fileoverview Rule to disallow `javascript:` URLs | ||
* @author Ilya Volodin | ||
@@ -21,3 +21,3 @@ */ | ||
docs: { | ||
description: "Disallow `javascript:` urls", | ||
description: "Disallow `javascript:` URLs", | ||
recommended: false, | ||
@@ -37,3 +37,3 @@ url: "https://eslint.org/docs/latest/rules/no-script-url" | ||
/** | ||
* Check whether a node's static value starts with "javascript:" or not. | ||
* Check whether a node's static value starts with `javascript:` or not. | ||
* And report an error for unexpected script URL. | ||
@@ -40,0 +40,0 @@ * @param {ASTNode} node node to check |
@@ -53,2 +53,4 @@ /** | ||
hasSuggestions: true, | ||
schema: [ | ||
@@ -102,3 +104,4 @@ { | ||
unusedVar: "'{{varName}}' is {{action}} but never used{{additional}}.", | ||
usedIgnoredVar: "'{{varName}}' is marked as ignored but is used{{additional}}." | ||
usedIgnoredVar: "'{{varName}}' is marked as ignored but is used{{additional}}.", | ||
removeVar: "Remove unused variable '{{varName}}'." | ||
} | ||
@@ -177,2 +180,3 @@ }, | ||
return "parameter"; | ||
default: | ||
@@ -838,2 +842,598 @@ return "variable"; | ||
/** | ||
* fixes unused variables | ||
* @param {Object} fixer fixer object | ||
* @param {Object} unusedVar unused variable to fix | ||
* @returns {Object} fixer object | ||
*/ | ||
function handleFixes(fixer, unusedVar) { | ||
const id = unusedVar.identifiers[0]; | ||
const parent = id.parent; | ||
const parentType = parent.type; | ||
const tokenBefore = sourceCode.getTokenBefore(id); | ||
const tokenAfter = sourceCode.getTokenAfter(id); | ||
const isFunction = astUtils.isFunction; | ||
const isLoop = astUtils.isLoop; | ||
const allWriteReferences = unusedVar.references.filter(ref => ref.isWrite()); | ||
/** | ||
* get range from token before of a given node | ||
* @param {ASTNode} node node of identifier | ||
* @param {number} skips number of token to skip | ||
* @returns {number} start range of token before the identifier | ||
*/ | ||
function getPreviousTokenStart(node, skips) { | ||
return sourceCode.getTokenBefore(node, skips).range[0]; | ||
} | ||
/** | ||
* get range to token after of a given node | ||
* @param {ASTNode} node node of identifier | ||
* @param {number} skips number of token to skip | ||
* @returns {number} end range of token after the identifier | ||
*/ | ||
function getNextTokenEnd(node, skips) { | ||
return sourceCode.getTokenAfter(node, skips).range[1]; | ||
} | ||
/** | ||
* get the value of token before of a given node | ||
* @param {ASTNode} node node of identifier | ||
* @returns {string} value of token before the identifier | ||
*/ | ||
function getTokenBeforeValue(node) { | ||
return sourceCode.getTokenBefore(node).value; | ||
} | ||
/** | ||
* get the value of token after of a given node | ||
* @param {ASTNode} node node of identifier | ||
* @returns {string} value of token after the identifier | ||
*/ | ||
function getTokenAfterValue(node) { | ||
return sourceCode.getTokenAfter(node).value; | ||
} | ||
/** | ||
* Check if an array has a single element with null as other element. | ||
* @param {ASTNode} node ArrayPattern node | ||
* @returns {boolean} true if array has single element with other null elements | ||
*/ | ||
function hasSingleElement(node) { | ||
return node.elements.filter(e => e !== null).length === 1; | ||
} | ||
/** | ||
* check whether import specifier has an import of particular type | ||
* @param {ASTNode} node ImportDeclaration node | ||
* @param {string} type type of import to check | ||
* @returns {boolean} true if import specifier has import of specified type | ||
*/ | ||
function hasImportOfCertainType(node, type) { | ||
return node.specifiers.some(e => e.type === type); | ||
} | ||
/** | ||
* Check whether declaration is safe to remove or not | ||
* @param {ASTNode} nextToken next token of unused variable | ||
* @param {ASTNode} prevToken previous token of unused variable | ||
* @returns {boolean} true if declaration is not safe to remove | ||
*/ | ||
function isDeclarationNotSafeToRemove(nextToken, prevToken) { | ||
return ( | ||
(nextToken.type === "String") || | ||
( | ||
prevToken && | ||
!astUtils.isSemicolonToken(prevToken) && | ||
!astUtils.isOpeningBraceToken(prevToken) | ||
) | ||
); | ||
} | ||
/** | ||
* give fixes for unused variables in function parameters | ||
* @param {ASTNode} node node to check | ||
* @returns {Object} fixer object | ||
*/ | ||
function fixFunctionParameters(node) { | ||
const parentNode = node.parent; | ||
if (isFunction(parentNode)) { | ||
// remove unused function parameter if there is only a single parameter | ||
if (parentNode.params.length === 1) { | ||
return fixer.removeRange(node.range); | ||
} | ||
// remove first unused function parameter when there are multiple parameters | ||
if (getTokenBeforeValue(node) === "(" && getTokenAfterValue(node) === ",") { | ||
return fixer.removeRange([node.range[0], getNextTokenEnd(node)]); | ||
} | ||
// remove unused function parameters except first one when there are multiple parameters | ||
return fixer.removeRange([getPreviousTokenStart(node), node.range[1]]); | ||
} | ||
return null; | ||
} | ||
/** | ||
* fix unused variable declarations and function parameters | ||
* @param {ASTNode} node parent node to identifier | ||
* @returns {Object} fixer object | ||
*/ | ||
function fixVariables(node) { | ||
const parentNode = node.parent; | ||
// remove unused declared variables such as var a = b; or var a = b, c; | ||
if (parentNode.type === "VariableDeclarator") { | ||
// skip variable in for (const [ foo ] of bar); | ||
if (isLoop(parentNode.parent.parent)) { | ||
return null; | ||
} | ||
/* | ||
* remove unused declared variable with single declaration such as 'var a = b;' | ||
* remove complete declaration when there is an unused variable in 'const { a } = foo;', same for arrays. | ||
*/ | ||
if (parentNode.parent.declarations.length === 1) { | ||
// if next token is a string it could become a directive if node is removed -> no suggestion. | ||
const nextToken = sourceCode.getTokenAfter(parentNode.parent); | ||
// if previous token exists and is not ";" or "{" not sure about ASI rules -> no suggestion. | ||
const prevToken = sourceCode.getTokenBefore(parentNode.parent); | ||
if (nextToken && isDeclarationNotSafeToRemove(nextToken, prevToken)) { | ||
return null; | ||
} | ||
return fixer.removeRange(parentNode.parent.range); | ||
} | ||
/* | ||
* remove unused declared variable with multiple declaration except first one such as 'var a = b, c = d;' | ||
* fix 'let bar = "hello", { a } = foo;' to 'let bar = "hello";' if 'a' is unused, same for arrays. | ||
*/ | ||
if (getTokenBeforeValue(parentNode) === ",") { | ||
return fixer.removeRange([getPreviousTokenStart(parentNode), parentNode.range[1]]); | ||
} | ||
/* | ||
* remove first unused declared variable when there are multiple declarations | ||
* fix 'let { a } = foo, bar = "hello";' to 'let bar = "hello";' if 'a' is unused, same for arrays. | ||
*/ | ||
return fixer.removeRange([parentNode.range[0], getNextTokenEnd(parentNode)]); | ||
} | ||
// fixes [{a: {k}}], [{a: [k]}] | ||
if (getTokenBeforeValue(node) === ":") { | ||
if (parentNode.parent.type === "ObjectPattern") { | ||
// eslint-disable-next-line no-use-before-define -- due to interdependency of functions | ||
return fixObjectWithValueSeparator(node); | ||
} | ||
} | ||
// fix unused function parameters | ||
return fixFunctionParameters(node); | ||
} | ||
/** | ||
* fix nested object like { a: { b } } | ||
* @param {ASTNode} node parent node to check | ||
* @returns {Object} fixer object | ||
*/ | ||
function fixNestedObjectVariable(node) { | ||
const parentNode = node.parent; | ||
// fix for { a: { b: { c: { d } } } } | ||
if ( | ||
parentNode.parent.parent.parent.type === "ObjectPattern" && | ||
parentNode.parent.properties.length === 1 | ||
) { | ||
return fixNestedObjectVariable(parentNode.parent); | ||
} | ||
// fix for { a: { b } } | ||
if (parentNode.parent.type === "ObjectPattern") { | ||
// fix for unused variables in dectructured object with single property in variable decalartion and function parameter | ||
if (parentNode.parent.properties.length === 1) { | ||
return fixVariables(parentNode.parent); | ||
} | ||
// fix for first unused property when there are multiple properties such as '{ a: { b }, c }' | ||
if (getTokenBeforeValue(parentNode) === "{") { | ||
return fixer.removeRange( | ||
[parentNode.range[0], getNextTokenEnd(parentNode)] | ||
); | ||
} | ||
// fix for unused property except first one when there are multiple properties such as '{ k, a: { b } }' | ||
return fixer.removeRange([getPreviousTokenStart(parentNode), parentNode.range[1]]); | ||
} | ||
return null; | ||
} | ||
/** | ||
* fix unused variables in array and nested array | ||
* @param {ASTNode} node parent node to check | ||
* @returns {Object} fixer object | ||
*/ | ||
function fixNestedArrayVariable(node) { | ||
const parentNode = node.parent; | ||
// fix for nested arrays [[ a ]] | ||
if (parentNode.parent.type === "ArrayPattern" && hasSingleElement(parentNode)) { | ||
return fixNestedArrayVariable(parentNode); | ||
} | ||
if (hasSingleElement(parentNode)) { | ||
// fixes { a: [{ b }] } or { a: [[ b ]] } | ||
if (getTokenBeforeValue(parentNode) === ":") { | ||
return fixVariables(parentNode); | ||
} | ||
// fixes [a, ...[[ b ]]] or [a, ...[{ b }]] | ||
if (parentNode.parent.type === "RestElement") { | ||
// eslint-disable-next-line no-use-before-define -- due to interdependency of functions | ||
return fixRestInPattern(parentNode.parent); | ||
} | ||
// fix unused variables in destructured array in variable declaration or function parameter | ||
return fixVariables(parentNode); | ||
} | ||
// remove last unused array element | ||
if ( | ||
getTokenBeforeValue(node) === "," && | ||
getTokenAfterValue(node) === "]" | ||
) { | ||
return fixer.removeRange([getPreviousTokenStart(node), node.range[1]]); | ||
} | ||
// remove unused array element | ||
return fixer.removeRange(node.range); | ||
} | ||
/** | ||
* fix cases like {a: {k}} or {a: [k]} | ||
* @param {ASTNode} node parent node to check | ||
* @returns {Object} fixer object | ||
*/ | ||
function fixObjectWithValueSeparator(node) { | ||
const parentNode = node.parent.parent; | ||
// fix cases like [{a : { b }}] or [{a : [ b ]}] | ||
if ( | ||
parentNode.parent.type === "ArrayPattern" && | ||
parentNode.properties.length === 1 | ||
) { | ||
return fixNestedArrayVariable(parentNode); | ||
} | ||
// fix cases like {a: {k}} or {a: [k]} | ||
return fixNestedObjectVariable(node); | ||
} | ||
/** | ||
* fix ...[[a]] or ...[{a}] like patterns | ||
* @param {ASTNode} node parent node to check | ||
* @returns {Object} fixer object | ||
*/ | ||
function fixRestInPattern(node) { | ||
const parentNode = node.parent; | ||
// fix ...[[a]] or ...[{a}] in function parameters | ||
if (isFunction(parentNode)) { | ||
if (parentNode.params.length === 1) { | ||
return fixer.removeRange(node.range); | ||
} | ||
return fixer.removeRange([getPreviousTokenStart(node), node.range[1]]); | ||
} | ||
// fix rest in nested array pattern like [[a, ...[b]]] | ||
if (parentNode.type === "ArrayPattern") { | ||
// fix [[...[b]]] | ||
if (hasSingleElement(parentNode)) { | ||
if (parentNode.parent.type === "ArrayPattern") { | ||
return fixNestedArrayVariable(parentNode); | ||
} | ||
// fix 'const [...[b]] = foo; and function foo([...[b]]) {} | ||
return fixVariables(parentNode); | ||
} | ||
// fix [[a, ...[b]]] | ||
return fixer.removeRange([getPreviousTokenStart(node), node.range[1]]); | ||
} | ||
return null; | ||
} | ||
// skip fix when variable has references that would be left behind | ||
if (allWriteReferences.some(ref => ref.identifier.range[0] !== id.range[0])) { | ||
return null; | ||
} | ||
// remove declared variables such as var a; or var a, b; | ||
if (parentType === "VariableDeclarator") { | ||
if (parent.parent.declarations.length === 1) { | ||
// prevent fix of variable in forOf and forIn loops. | ||
if (isLoop(parent.parent.parent) && parent.parent.parent.body !== parent.parent) { | ||
return null; | ||
} | ||
// removes only variable not semicolon in 'if (foo()) var bar;' or in 'loops' or in 'with' statement. | ||
if ( | ||
parent.parent.parent.type === "IfStatement" || | ||
isLoop(parent.parent.parent) || | ||
(parent.parent.parent.type === "WithStatement" && parent.parent.parent.body === parent.parent) | ||
) { | ||
return fixer.replaceText(parent.parent, ";"); | ||
} | ||
// if next token is a string it could become a directive if node is removed -> no suggestion. | ||
const nextToken = sourceCode.getTokenAfter(parent.parent); | ||
// if previous token exists and is not ";" or "{" not sure about ASI rules -> no suggestion. | ||
const prevToken = sourceCode.getTokenBefore(parent.parent); | ||
if (nextToken && isDeclarationNotSafeToRemove(nextToken, prevToken)) { | ||
return null; | ||
} | ||
// remove unused declared variable with single declaration like 'var a = b;' | ||
return fixer.removeRange(parent.parent.range); | ||
} | ||
// remove unused declared variable with multiple declaration except first one like 'var a = b, c = d;' | ||
if (tokenBefore.value === ",") { | ||
return fixer.removeRange([tokenBefore.range[0], parent.range[1]]); | ||
} | ||
// remove first unused declared variable when there are multiple declarations | ||
return fixer.removeRange([parent.range[0], getNextTokenEnd(parent)]); | ||
} | ||
// remove variables in object patterns | ||
if (parent.parent.type === "ObjectPattern") { | ||
if (parent.parent.properties.length === 1) { | ||
// fix [a, ...{b}] | ||
if (parent.parent.parent.type === "RestElement") { | ||
return fixRestInPattern(parent.parent.parent); | ||
} | ||
// fix [{ a }] | ||
if (parent.parent.parent.type === "ArrayPattern") { | ||
return fixNestedArrayVariable(parent.parent); | ||
} | ||
/* | ||
* var {a} = foo; | ||
* function a({a}) {} | ||
* fix const { a: { b } } = foo; | ||
*/ | ||
return fixVariables(parent.parent); | ||
} | ||
// fix const { a:b } = foo; | ||
if (tokenBefore.value === ":") { | ||
// remove first unused variable in const { a:b } = foo; | ||
if (getTokenBeforeValue(parent) === "{" && getTokenAfterValue(parent) === ",") { | ||
return fixer.removeRange([parent.range[0], getNextTokenEnd(parent)]); | ||
} | ||
// remove unused variables in const { a: b, c: d } = foo; except first one | ||
return fixer.removeRange([getPreviousTokenStart(parent), id.range[1]]); | ||
} | ||
} | ||
// remove unused variables inside an array | ||
if (parentType === "ArrayPattern") { | ||
if (hasSingleElement(parent)) { | ||
// fix [a, ...[b]] | ||
if (parent.parent.type === "RestElement") { | ||
return fixRestInPattern(parent.parent); | ||
} | ||
// fix [ [a] ] | ||
if (parent.parent.type === "ArrayPattern") { | ||
return fixNestedArrayVariable(parent); | ||
} | ||
/* | ||
* fix var [a] = foo; | ||
* fix function foo([a]) {} | ||
* fix const { a: [b] } = foo; | ||
*/ | ||
return fixVariables(parent); | ||
} | ||
// if "a" is unused in [a, b ,c] fixes to [, b, c] | ||
if (tokenBefore.value === "," && tokenAfter.value === ",") { | ||
return fixer.removeRange(id.range); | ||
} | ||
} | ||
// remove unused rest elements | ||
if (parentType === "RestElement") { | ||
// fix [a, ...rest] | ||
if (parent.parent.type === "ArrayPattern") { | ||
if (hasSingleElement(parent.parent)) { | ||
// fix [[...rest]] when there is only rest element | ||
if ( | ||
parent.parent.parent.type === "ArrayPattern" | ||
) { | ||
return fixNestedArrayVariable(parent.parent); | ||
} | ||
// fix 'const [...rest] = foo;' and 'function foo([...rest]) {}' | ||
return fixVariables(parent.parent); | ||
} | ||
// fix [a, ...rest] | ||
return fixer.removeRange([getPreviousTokenStart(id, 1), id.range[1]]); | ||
} | ||
// fix { a, ...rest} | ||
if (parent.parent.type === "ObjectPattern") { | ||
// fix 'const {...rest} = foo;' and 'function foo({...rest}) {}' | ||
if (parent.parent.properties.length === 1) { | ||
return fixVariables(parent.parent); | ||
} | ||
// fix { a, ...rest} when there are multiple properties | ||
return fixer.removeRange([getPreviousTokenStart(id, 1), id.range[1]]); | ||
} | ||
// fix function foo(...rest) {} | ||
if (isFunction(parent.parent)) { | ||
// remove unused rest in function parameter if there is only single parameter | ||
if (parent.parent.params.length === 1) { | ||
return fixer.removeRange(parent.range); | ||
} | ||
// remove unused rest in function parameter if there multiple parameter | ||
return fixer.removeRange([getPreviousTokenStart(parent), parent.range[1]]); | ||
} | ||
} | ||
if (parentType === "AssignmentPattern") { | ||
// fix [a = aDefault] | ||
if (parent.parent.type === "ArrayPattern") { | ||
return fixNestedArrayVariable(parent); | ||
} | ||
// fix {a = aDefault} | ||
if (parent.parent.parent.type === "ObjectPattern") { | ||
if (parent.parent.parent.properties.length === 1) { | ||
// fixes [{a = aDefault}] | ||
if (parent.parent.parent.parent.type === "ArrayPattern") { | ||
return fixNestedArrayVariable(parent.parent.parent); | ||
} | ||
// fix 'const {a = aDefault} = foo;' and 'function foo({a = aDefault}) {}' | ||
return fixVariables(parent.parent.parent); | ||
} | ||
// fix unused 'a' in {a = aDefault} if it is the first property | ||
if ( | ||
getTokenBeforeValue(parent.parent) === "{" && | ||
getTokenAfterValue(parent.parent) === "," | ||
) { | ||
return fixer.removeRange([parent.parent.range[0], getNextTokenEnd(parent.parent)]); | ||
} | ||
// fix unused 'b' in {a, b = aDefault} if it is not the first property | ||
return fixer.removeRange([getPreviousTokenStart(parent.parent), parent.parent.range[1]]); | ||
} | ||
// fix unused assignment patterns in function parameters | ||
if (isFunction(parent.parent)) { | ||
return fixFunctionParameters(parent); | ||
} | ||
} | ||
// remove unused functions | ||
if (parentType === "FunctionDeclaration" && parent.id === id) { | ||
return fixer.removeRange(parent.range); | ||
} | ||
// remove unused default import | ||
if (parentType === "ImportDefaultSpecifier") { | ||
// remove unused default import when there are not other imports | ||
if ( | ||
!hasImportOfCertainType(parent.parent, "ImportSpecifier") && | ||
!hasImportOfCertainType(parent.parent, "ImportNamespaceSpecifier") | ||
) { | ||
return fixer.removeRange([parent.range[0], parent.parent.source.range[0]]); | ||
} | ||
// remove unused default import when there are other imports also | ||
return fixer.removeRange([id.range[0], tokenAfter.range[1]]); | ||
} | ||
if (parentType === "ImportSpecifier") { | ||
// remove unused imports when there is a single import | ||
if (parent.parent.specifiers.filter(e => e.type === "ImportSpecifier").length === 1) { | ||
// remove unused import when there is no default import | ||
if (!hasImportOfCertainType(parent.parent, "ImportDefaultSpecifier")) { | ||
return fixer.removeRange(parent.parent.range); | ||
} | ||
// fixes "import foo from 'module';" to "import 'module';" | ||
return fixer.removeRange([getPreviousTokenStart(parent, 1), tokenAfter.range[1]]); | ||
} | ||
if (getTokenBeforeValue(parent) === "{") { | ||
return fixer.removeRange([parent.range[0], getNextTokenEnd(parent)]); | ||
} | ||
return fixer.removeRange([getPreviousTokenStart(parent), parent.range[1]]); | ||
} | ||
if (parentType === "ImportNamespaceSpecifier") { | ||
if (hasImportOfCertainType(parent.parent, "ImportDefaultSpecifier")) { | ||
return fixer.removeRange([getPreviousTokenStart(parent), parent.range[1]]); | ||
} | ||
// fixes "import * as foo from 'module';" to "import 'module';" | ||
return fixer.removeRange([parent.range[0], parent.parent.source.range[0]]); | ||
} | ||
// skip error in catch(error) variable | ||
if (parentType === "CatchClause") { | ||
return null; | ||
} | ||
// remove unused declared classes | ||
if (parentType === "ClassDeclaration") { | ||
return fixer.removeRange(parent.range); | ||
} | ||
// remove unused varible that is in a sequence [a,b] fixes to [a] | ||
if (tokenBefore?.value === ",") { | ||
return fixer.removeRange([tokenBefore.range[0], id.range[1]]); | ||
} | ||
// remove unused varible that is in a sequence inside function arguments and object pattern | ||
if (tokenAfter.value === ",") { | ||
// fix function foo(a, b) {} | ||
if (tokenBefore.value === "(") { | ||
return fixer.removeRange([id.range[0], tokenAfter.range[1]]); | ||
} | ||
// fix const {a, b} = foo; | ||
if (tokenBefore.value === "{") { | ||
return fixer.removeRange([id.range[0], tokenAfter.range[1]]); | ||
} | ||
} | ||
if (parentType === "ArrowFunctionExpression" && parent.params.length === 1 && tokenAfter?.value !== ")") { | ||
return fixer.replaceText(id, "()"); | ||
} | ||
return fixer.removeRange(id.range); | ||
} | ||
//-------------------------------------------------------------------------- | ||
@@ -867,3 +1467,14 @@ // Public | ||
? getAssignedMessageData(unusedVar) | ||
: getDefinedMessageData(unusedVar) | ||
: getDefinedMessageData(unusedVar), | ||
suggest: [ | ||
{ | ||
messageId: "removeVar", | ||
data: { | ||
varName: unusedVar.name | ||
}, | ||
fix(fixer) { | ||
return handleFixes(fixer, unusedVar); | ||
} | ||
} | ||
] | ||
}); | ||
@@ -870,0 +1481,0 @@ |
@@ -312,2 +312,11 @@ /** | ||
if (targetAssignment.variable.references.some(ref => ref.identifier.type !== "Identifier")) { | ||
/** | ||
* Skip checking for a variable that has at least one non-identifier reference. | ||
* It's generated by plugins and cannot be handled reliably in the core rule. | ||
*/ | ||
return; | ||
} | ||
const readReferences = targetAssignment.variable.references.filter(reference => reference.isRead()); | ||
@@ -314,0 +323,0 @@ |
/** | ||
* @fileoverview Prefers object spread property over Object.assign | ||
* @fileoverview Rule to disallow using `Object.assign` with an object literal as the first argument and prefer the use of object spread instead | ||
* @author Sharmila Jesupaul | ||
@@ -249,3 +249,3 @@ */ | ||
description: | ||
"Disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead", | ||
"Disallow using `Object.assign` with an object literal as the first argument and prefer the use of object spread instead", | ||
recommended: false, | ||
@@ -252,0 +252,0 @@ url: "https://eslint.org/docs/latest/rules/prefer-object-spread" |
/** | ||
* @fileoverview Rule to enforce the use of `u` flag on RegExp. | ||
* @fileoverview Rule to enforce the use of `u` or `v` flag on regular expressions. | ||
* @author Toru Nagashima | ||
@@ -51,3 +51,3 @@ */ | ||
docs: { | ||
description: "Enforce the use of `u` or `v` flag on RegExp", | ||
description: "Enforce the use of `u` or `v` flag on regular expressions", | ||
recommended: false, | ||
@@ -54,0 +54,0 @@ url: "https://eslint.org/docs/latest/rules/require-unicode-regexp" |
@@ -13,3 +13,3 @@ /** | ||
["test_only", "Used only for testing."], | ||
["unstable_config_lookup_from_file", "Look up eslint.config.js from the file being linted."], | ||
["unstable_config_lookup_from_file", "Look up `eslint.config.js` from the file being linted."], | ||
["unstable_ts_config", "Enable TypeScript configuration files."] | ||
@@ -16,0 +16,0 @@ ]); |
{ | ||
"name": "eslint", | ||
"version": "9.16.0", | ||
"version": "9.17.0", | ||
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>", | ||
@@ -105,3 +105,3 @@ "description": "An AST-based pattern checker for JavaScript.", | ||
"@eslint/eslintrc": "^3.2.0", | ||
"@eslint/js": "9.16.0", | ||
"@eslint/js": "9.17.0", | ||
"@eslint/plugin-kit": "^0.2.3", | ||
@@ -115,3 +115,3 @@ "@humanfs/node": "^0.16.6", | ||
"chalk": "^4.0.0", | ||
"cross-spawn": "^7.0.5", | ||
"cross-spawn": "^7.0.6", | ||
"debug": "^4.3.2", | ||
@@ -159,3 +159,3 @@ "escape-string-regexp": "^4.0.0", | ||
"eslint-plugin-eslint-plugin": "^6.0.0", | ||
"eslint-plugin-expect-type": "^0.4.0", | ||
"eslint-plugin-expect-type": "^0.6.0", | ||
"eslint-plugin-yml": "^1.14.0", | ||
@@ -162,0 +162,0 @@ "eslint-release": "^3.3.0", |
@@ -303,3 +303,3 @@ [![npm version](https://img.shields.io/npm/v/eslint.svg)](https://www.npmjs.com/package/eslint) | ||
<p><a href="https://www.serptriumph.com/"><img src="https://images.opencollective.com/serp-triumph5/fea3074/logo.png" alt="SERP Triumph" height="64"></a> <a href="https://www.jetbrains.com/"><img src="https://images.opencollective.com/jetbrains/fe76f99/logo.png" alt="JetBrains" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="64"></a> <a href="https://www.workleap.com"><img src="https://avatars.githubusercontent.com/u/53535748?u=d1e55d7661d724bf2281c1bfd33cb8f99fe2465f&v=4" alt="Workleap" height="64"></a></p><h3>Bronze Sponsors</h3> | ||
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340?v=4" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a></p> | ||
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://syntax.fm"><img src="https://github.com/syntaxfm.png" alt="Syntax" height="32"></a> <a href="https://www.wordhint.net/"><img src="https://images.opencollective.com/wordhint/be86813/avatar.png" alt="WordHint" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340?v=4" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104?v=4" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465?v=4" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a></p> | ||
<h3>Technology Sponsors</h3> | ||
@@ -306,0 +306,0 @@ Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work. |
3370234
80281
+ Added@eslint/js@9.17.0(transitive)
- Removed@eslint/js@9.16.0(transitive)
Updated@eslint/js@9.17.0
Updatedcross-spawn@^7.0.6