From 095ca63971ce2d7350af845714b2b5766b418c82 Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 2 Sep 2025 16:35:15 +0800 Subject: [PATCH 1/6] Refactor --- rules/fix/remove-argument.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/rules/fix/remove-argument.js b/rules/fix/remove-argument.js index 38a435c41c..63b1a41f3e 100644 --- a/rules/fix/remove-argument.js +++ b/rules/fix/remove-argument.js @@ -1,30 +1,35 @@ import {isCommaToken} from '@eslint-community/eslint-utils'; import {getParentheses} from '../utils/parentheses.js'; -export default function removeArgument(fixer, node, sourceCode) { - const callExpression = node.parent; - const index = callExpression.arguments.indexOf(node); +export default function * removeObjectProperty(fixer, node, context) { + const {sourceCode} = context; + for (const token of sourceCode.getTokens(node)) { + yield fixer.remove(token); + } + const parentheses = getParentheses(node, sourceCode); - const firstToken = parentheses[0] || node; - const lastToken = parentheses.at(-1) || node; + for (const token of parentheses) { + yield fixer.remove(token); + } - let [start] = sourceCode.getRange(firstToken); - let [, end] = sourceCode.getRange(lastToken); + const firstToken = parentheses[0] ?? node; + const lastToken = parentheses.at(-1) ?? node; + + const callExpression = node.parent; + const index = callExpression.arguments.indexOf(node); if (index !== 0) { const commaToken = sourceCode.getTokenBefore(firstToken); - [start] = sourceCode.getRange(commaToken); + yield fixer.remove(commaToken); } // If the removed argument is the only argument, the trailing comma must be removed too /* c8 ignore start */ if (callExpression.arguments.length === 1) { - const tokenAfter = sourceCode.getTokenBefore(lastToken); + const tokenAfter = sourceCode.getTokenAfter(lastToken); if (isCommaToken(tokenAfter)) { - [, end] = sourceCode.getRange(tokenAfter); + yield fixer.remove(tokenAfter); } } /* c8 ignore end */ - - return fixer.removeRange([start, end]); } From f6a1b3f58a4d26eb99d44fcb194caf51731de40a Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 2 Sep 2025 16:35:29 +0800 Subject: [PATCH 2/6] no-array-method-this-argument --- rules/no-array-method-this-argument.js | 27 ++- test/no-array-method-this-argument.js | 19 ++ .../no-array-method-this-argument.js.md | 206 ++++++++++++------ .../no-array-method-this-argument.js.snap | Bin 2241 -> 2498 bytes 4 files changed, 168 insertions(+), 84 deletions(-) diff --git a/rules/no-array-method-this-argument.js b/rules/no-array-method-this-argument.js index a26aeacdb0..24f2527774 100644 --- a/rules/no-array-method-this-argument.js +++ b/rules/no-array-method-this-argument.js @@ -71,14 +71,15 @@ const ignored = [ 'underscore.some', ]; -function removeThisArgument(thisArgumentNode, sourceCode) { - return fixer => removeArgument(fixer, thisArgumentNode, sourceCode); +function removeThisArgument(thisArgumentNode, context) { + return fixer => removeArgument(fixer, thisArgumentNode, context); } -function useBoundFunction(callbackNode, thisArgumentNode, sourceCode) { +function useBoundFunction(callbackNode, thisArgumentNode, context) { return function * (fixer) { - yield removeThisArgument(thisArgumentNode, sourceCode)(fixer); + yield * removeThisArgument(thisArgumentNode, context)(fixer); + const {sourceCode} = context; const callbackParentheses = getParentheses(callbackNode, sourceCode); const isParenthesized = callbackParentheses.length > 0; const callbackLastToken = isParenthesized @@ -99,7 +100,7 @@ function useBoundFunction(callbackNode, thisArgumentNode, sourceCode) { } function getProblem({ - sourceCode, + context, callExpression, callbackNode, thisArgumentNode, @@ -115,16 +116,16 @@ function getProblem({ const isArrowCallback = callbackNode.type === 'ArrowFunctionExpression'; if (isArrowCallback) { - const thisArgumentHasSideEffect = hasSideEffect(thisArgumentNode, sourceCode); + const thisArgumentHasSideEffect = hasSideEffect(thisArgumentNode, context.sourceCode); if (thisArgumentHasSideEffect) { problem.suggest = [ { messageId: SUGGESTION_REMOVE, - fix: removeThisArgument(thisArgumentNode, sourceCode), + fix: removeThisArgument(thisArgumentNode, context), }, ]; } else { - problem.fix = removeThisArgument(thisArgumentNode, sourceCode); + problem.fix = removeThisArgument(thisArgumentNode, context); } return problem; @@ -133,11 +134,11 @@ function getProblem({ problem.suggest = [ { messageId: SUGGESTION_REMOVE, - fix: removeThisArgument(thisArgumentNode, sourceCode), + fix: removeThisArgument(thisArgumentNode, context), }, { messageId: SUGGESTION_BIND, - fix: useBoundFunction(callbackNode, thisArgumentNode, sourceCode), + fix: useBoundFunction(callbackNode, thisArgumentNode, context), }, ]; @@ -146,8 +147,6 @@ function getProblem({ /** @param {import('eslint').Rule.RuleContext} context */ const create = context => { - const {sourceCode} = context; - // Prototype methods context.on('CallExpression', callExpression => { if ( @@ -175,7 +174,7 @@ const create = context => { } return getProblem({ - sourceCode, + context, callExpression, callbackNode: callExpression.arguments[0], thisArgumentNode: callExpression.arguments[1], @@ -199,7 +198,7 @@ const create = context => { } return getProblem({ - sourceCode, + context, callExpression, callbackNode: callExpression.arguments[1], thisArgumentNode: callExpression.arguments[2], diff --git a/test/no-array-method-this-argument.js b/test/no-array-method-this-argument.js index c175e9194b..73e59a2d8e 100644 --- a/test/no-array-method-this-argument.js +++ b/test/no-array-method-this-argument.js @@ -1,3 +1,4 @@ +import {outdent} from 'outdent'; import {getTester, parsers} from './utils/test.js'; const {test} = getTester(import.meta); @@ -90,6 +91,24 @@ test.snapshot({ 'array.map(() => {}, thisArgumentHasSideEffect())', 'Array.from(iterableOrArrayLike, () => {}, thisArgumentHasSideEffect())', 'Array.fromAsync(iterableOrArrayLike, () => {}, thisArgumentHasSideEffect())', + outdent` + array.map( + () => {} /* comment 1 */ , + /* comment 2 */ + ( + /* comment 3 */ + ( + /* comment 4 */ + there.are/* comment 5 */.many.comments + /* comment 6 */ + ) + /* comment 7 */ + ) + /* comment 8 */ + , + /* comment 9 */ + ) + `, ], }); diff --git a/test/snapshots/no-array-method-this-argument.js.md b/test/snapshots/no-array-method-this-argument.js.md index afce7e93cc..f5b862da4e 100644 --- a/test/snapshots/no-array-method-this-argument.js.md +++ b/test/snapshots/no-array-method-this-argument.js.md @@ -15,7 +15,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.every(() => {})␊ + 1 | array.every(() => {} )␊ ` > Error 1/1 @@ -36,7 +36,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.filter(() => {})␊ + 1 | array.filter(() => {} )␊ ` > Error 1/1 @@ -57,7 +57,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.find(() => {})␊ + 1 | array.find(() => {} )␊ ` > Error 1/1 @@ -78,7 +78,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.findIndex(() => {})␊ + 1 | array.findIndex(() => {} )␊ ` > Error 1/1 @@ -99,7 +99,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.findLast(() => {})␊ + 1 | array.findLast(() => {} )␊ ` > Error 1/1 @@ -120,7 +120,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.findLastIndex(() => {})␊ + 1 | array.findLastIndex(() => {} )␊ ` > Error 1/1 @@ -141,7 +141,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.flatMap(() => {})␊ + 1 | array.flatMap(() => {} )␊ ` > Error 1/1 @@ -162,7 +162,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.forEach(() => {})␊ + 1 | array.forEach(() => {} )␊ ` > Error 1/1 @@ -183,7 +183,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.map(() => {})␊ + 1 | array.map(() => {} )␊ ` > Error 1/1 @@ -204,7 +204,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | Array.from(iterableOrArrayLike, () => {})␊ + 1 | Array.from(iterableOrArrayLike, () => {} )␊ ` > Error 1/1 @@ -225,7 +225,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | Array.fromAsync(iterableOrArrayLike, () => {})␊ + 1 | Array.fromAsync(iterableOrArrayLike, () => {} )␊ ` > Error 1/1 @@ -246,7 +246,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.map(() => {},)␊ + 1 | array.map(() => {} ,)␊ ` > Error 1/1 @@ -267,7 +267,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | array.map(() => {},)␊ + 1 | array.map(() => {} ,)␊ ` > Error 1/1 @@ -288,7 +288,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | Array.from(iterableOrArrayLike, () => {},)␊ + 1 | Array.from(iterableOrArrayLike, () => {} ,)␊ ` > Error 1/1 @@ -309,7 +309,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | Array.fromAsync(iterableOrArrayLike, () => {},)␊ + 1 | Array.fromAsync(iterableOrArrayLike, () => {} ,)␊ ` > Error 1/1 @@ -335,7 +335,7 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/1: Remove this argument.␊ - 1 | array.map(() => {})␊ + 1 | array.map(() => {} )␊ ` ## invalid(17): Array.from(iterableOrArrayLike, () => {}, thisArgumentHasSideEffect()) @@ -354,7 +354,7 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/1: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, () => {})␊ + 1 | Array.from(iterableOrArrayLike, () => {} )␊ ` ## invalid(18): Array.fromAsync(iterableOrArrayLike, () => {}, thisArgumentHasSideEffect()) @@ -373,7 +373,73 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/1: Remove this argument.␊ - 1 | Array.fromAsync(iterableOrArrayLike, () => {})␊ + 1 | Array.fromAsync(iterableOrArrayLike, () => {} )␊ + ` + +## invalid(19): array.map( () => {} /* comment 1 */ , /* comment 2 */ ( /* comment 3 */ ( /* comment 4 */ there.are/* comment 5 */.many.comments /* comment 6 */ ) /* comment 7 */ ) /* comment 8 */ , /* comment 9 */ ) + +> Input + + `␊ + 1 | array.map(␊ + 2 | () => {} /* comment 1 */ ,␊ + 3 | /* comment 2 */␊ + 4 | (␊ + 5 | /* comment 3 */␊ + 6 | (␊ + 7 | /* comment 4 */␊ + 8 | there.are/* comment 5 */.many.comments␊ + 9 | /* comment 6 */␊ + 10 | )␊ + 11 | /* comment 7 */␊ + 12 | )␊ + 13 | /* comment 8 */␊ + 14 | ,␊ + 15 | /* comment 9 */␊ + 16 | )␊ + ` + +> Output + + `␊ + 1 | array.map(␊ + 2 | () => {} /* comment 1 */ ␊ + 3 | /* comment 2 */␊ + 4 | ␊ + 5 | /* comment 3 */␊ + 6 | ␊ + 7 | /* comment 4 */␊ + 8 | /* comment 5 */␊ + 9 | /* comment 6 */␊ + 10 | ␊ + 11 | /* comment 7 */␊ + 12 | ␊ + 13 | /* comment 8 */␊ + 14 | ,␊ + 15 | /* comment 9 */␊ + 16 | )␊ + ` + +> Error 1/1 + + `␊ + 1 | array.map(␊ + 2 | () => {} /* comment 1 */ ,␊ + 3 | /* comment 2 */␊ + 4 | (␊ + 5 | /* comment 3 */␊ + 6 | (␊ + 7 | /* comment 4 */␊ + > 8 | there.are/* comment 5 */.many.comments␊ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use the \`this\` argument in \`Array#map()\`.␊ + 9 | /* comment 6 */␊ + 10 | )␊ + 11 | /* comment 7 */␊ + 12 | )␊ + 13 | /* comment 8 */␊ + 14 | ,␊ + 15 | /* comment 9 */␊ + 16 | )␊ ` ## invalid(1): array.map(callback, thisArgument) @@ -392,11 +458,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | array.map(callback)␊ + 1 | array.map(callback )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | array.map(callback.bind(thisArgument))␊ + 1 | array.map(callback.bind(thisArgument) )␊ ` ## invalid(2): Array.from(iterableOrArrayLike, callback, thisArgument) @@ -415,11 +481,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, callback)␊ + 1 | Array.from(iterableOrArrayLike, callback )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.from(iterableOrArrayLike, callback.bind(thisArgument))␊ + 1 | Array.from(iterableOrArrayLike, callback.bind(thisArgument) )␊ ` ## invalid(3): Array.fromAsync(iterableOrArrayLike, callback, thisArgument) @@ -438,11 +504,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.fromAsync(iterableOrArrayLike, callback)␊ + 1 | Array.fromAsync(iterableOrArrayLike, callback )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.fromAsync(iterableOrArrayLike, callback.bind(thisArgument))␊ + 1 | Array.fromAsync(iterableOrArrayLike, callback.bind(thisArgument) )␊ ` ## invalid(4): array.map(callback, (0, thisArgument)) @@ -461,11 +527,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | array.map(callback)␊ + 1 | array.map(callback )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | array.map(callback.bind((0, thisArgument)))␊ + 1 | array.map(callback.bind((0, thisArgument)) )␊ ` ## invalid(5): Array.from(iterableOrArrayLike, callback, (0, thisArgument)) @@ -484,11 +550,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, callback)␊ + 1 | Array.from(iterableOrArrayLike, callback )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.from(iterableOrArrayLike, callback.bind((0, thisArgument)))␊ + 1 | Array.from(iterableOrArrayLike, callback.bind((0, thisArgument)) )␊ ` ## invalid(6): Array.fromAsync(iterableOrArrayLike, callback, (0, thisArgument)) @@ -507,11 +573,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.fromAsync(iterableOrArrayLike, callback)␊ + 1 | Array.fromAsync(iterableOrArrayLike, callback )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.fromAsync(iterableOrArrayLike, callback.bind((0, thisArgument)))␊ + 1 | Array.fromAsync(iterableOrArrayLike, callback.bind((0, thisArgument)) )␊ ` ## invalid(7): array.map(function () {}, thisArgument) @@ -530,11 +596,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | array.map(function () {})␊ + 1 | array.map(function () {} )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | array.map(function () {}.bind(thisArgument))␊ + 1 | array.map(function () {}.bind(thisArgument) )␊ ` ## invalid(8): Array.from(iterableOrArrayLike, function () {}, thisArgument) @@ -553,11 +619,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, function () {})␊ + 1 | Array.from(iterableOrArrayLike, function () {} )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.from(iterableOrArrayLike, function () {}.bind(thisArgument))␊ + 1 | Array.from(iterableOrArrayLike, function () {}.bind(thisArgument) )␊ ` ## invalid(9): array.map(function callback () {}, thisArgument) @@ -576,11 +642,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | array.map(function callback () {})␊ + 1 | array.map(function callback () {} )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | array.map(function callback () {}.bind(thisArgument))␊ + 1 | array.map(function callback () {}.bind(thisArgument) )␊ ` ## invalid(10): Array.from(iterableOrArrayLike, function callback () {}, thisArgument) @@ -599,11 +665,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, function callback () {})␊ + 1 | Array.from(iterableOrArrayLike, function callback () {} )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.from(iterableOrArrayLike, function callback () {}.bind(thisArgument))␊ + 1 | Array.from(iterableOrArrayLike, function callback () {}.bind(thisArgument) )␊ ` ## invalid(11): Array.fromAsync(iterableOrArrayLike, function callback () {}, thisArgument) @@ -622,11 +688,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.fromAsync(iterableOrArrayLike, function callback () {})␊ + 1 | Array.fromAsync(iterableOrArrayLike, function callback () {} )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.fromAsync(iterableOrArrayLike, function callback () {}.bind(thisArgument))␊ + 1 | Array.fromAsync(iterableOrArrayLike, function callback () {}.bind(thisArgument) )␊ ` ## invalid(12): array.map( foo as bar, (( thisArgument )),) @@ -645,11 +711,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | array.map( foo as bar,)␊ + 1 | array.map( foo as bar ,)␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | array.map( (foo as bar).bind((( thisArgument ))),)␊ + 1 | array.map( (foo as bar).bind((( thisArgument ))) ,)␊ ` ## invalid(13): Array.from(iterableOrArrayLike, foo as bar, (( thisArgument )),) @@ -668,11 +734,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, foo as bar,)␊ + 1 | Array.from(iterableOrArrayLike, foo as bar ,)␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.from(iterableOrArrayLike, (foo as bar).bind((( thisArgument ))),)␊ + 1 | Array.from(iterableOrArrayLike, (foo as bar).bind((( thisArgument ))) ,)␊ ` ## invalid(14): Array.fromAsync(iterableOrArrayLike, foo as bar, (( thisArgument )),) @@ -691,11 +757,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.fromAsync(iterableOrArrayLike, foo as bar,)␊ + 1 | Array.fromAsync(iterableOrArrayLike, foo as bar ,)␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.fromAsync(iterableOrArrayLike, (foo as bar).bind((( thisArgument ))),)␊ + 1 | Array.fromAsync(iterableOrArrayLike, (foo as bar).bind((( thisArgument ))) ,)␊ ` ## invalid(15): array.map( (( foo as bar )), (( thisArgument )),) @@ -714,11 +780,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | array.map( (( foo as bar )),)␊ + 1 | array.map( (( foo as bar )) ,)␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | array.map( (( foo as bar )).bind((( thisArgument ))),)␊ + 1 | array.map( (( foo as bar )).bind((( thisArgument ))) ,)␊ ` ## invalid(16): Array.from(iterableOrArrayLike, (( foo as bar )), (( thisArgument )),) @@ -737,11 +803,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, (( foo as bar )),)␊ + 1 | Array.from(iterableOrArrayLike, (( foo as bar )) ,)␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.from(iterableOrArrayLike, (( foo as bar )).bind((( thisArgument ))),)␊ + 1 | Array.from(iterableOrArrayLike, (( foo as bar )).bind((( thisArgument ))) ,)␊ ` ## invalid(17): Array.fromAsync(iterableOrArrayLike, (( foo as bar )), (( thisArgument )),) @@ -760,11 +826,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.fromAsync(iterableOrArrayLike, (( foo as bar )),)␊ + 1 | Array.fromAsync(iterableOrArrayLike, (( foo as bar )) ,)␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.fromAsync(iterableOrArrayLike, (( foo as bar )).bind((( thisArgument ))),)␊ + 1 | Array.fromAsync(iterableOrArrayLike, (( foo as bar )).bind((( thisArgument ))) ,)␊ ` ## invalid(18): array.map( (( 0, callback )), (( thisArgument )),) @@ -783,11 +849,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | array.map( (( 0, callback )),)␊ + 1 | array.map( (( 0, callback )) ,)␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | array.map( (( 0, callback )).bind((( thisArgument ))),)␊ + 1 | array.map( (( 0, callback )).bind((( thisArgument ))) ,)␊ ` ## invalid(19): Array.from(iterableOrArrayLike, (( 0, callback )), (( thisArgument )),) @@ -806,11 +872,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, (( 0, callback )),)␊ + 1 | Array.from(iterableOrArrayLike, (( 0, callback )) ,)␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.from(iterableOrArrayLike, (( 0, callback )).bind((( thisArgument ))),)␊ + 1 | Array.from(iterableOrArrayLike, (( 0, callback )).bind((( thisArgument ))) ,)␊ ` ## invalid(20): Array.fromAsync(iterableOrArrayLike, (( 0, callback )), (( thisArgument )),) @@ -829,11 +895,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.fromAsync(iterableOrArrayLike, (( 0, callback )),)␊ + 1 | Array.fromAsync(iterableOrArrayLike, (( 0, callback )) ,)␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.fromAsync(iterableOrArrayLike, (( 0, callback )).bind((( thisArgument ))),)␊ + 1 | Array.fromAsync(iterableOrArrayLike, (( 0, callback )).bind((( thisArgument ))) ,)␊ ` ## invalid(21): array.map((0, () => {}), thisArgument) @@ -852,11 +918,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | array.map((0, () => {}))␊ + 1 | array.map((0, () => {}) )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | array.map((0, () => {}).bind(thisArgument))␊ + 1 | array.map((0, () => {}).bind(thisArgument) )␊ ` ## invalid(22): Array.from(iterableOrArrayLike, (0, () => {}), thisArgument) @@ -875,11 +941,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, (0, () => {}))␊ + 1 | Array.from(iterableOrArrayLike, (0, () => {}) )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.from(iterableOrArrayLike, (0, () => {}).bind(thisArgument))␊ + 1 | Array.from(iterableOrArrayLike, (0, () => {}).bind(thisArgument) )␊ ` ## invalid(23): Array.fromAsync(iterableOrArrayLike, (0, () => {}), thisArgument) @@ -898,11 +964,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.fromAsync(iterableOrArrayLike, (0, () => {}))␊ + 1 | Array.fromAsync(iterableOrArrayLike, (0, () => {}) )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.fromAsync(iterableOrArrayLike, (0, () => {}).bind(thisArgument))␊ + 1 | Array.fromAsync(iterableOrArrayLike, (0, () => {}).bind(thisArgument) )␊ ` ## invalid(24): array.map(callback.bind(foo), thisArgument) @@ -921,11 +987,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | array.map(callback.bind(foo))␊ + 1 | array.map(callback.bind(foo) )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | array.map(callback.bind(foo).bind(thisArgument))␊ + 1 | array.map(callback.bind(foo).bind(thisArgument) )␊ ` ## invalid(25): Array.from(iterableOrArrayLike, callback.bind(foo), thisArgument) @@ -944,11 +1010,11 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.from(iterableOrArrayLike, callback.bind(foo))␊ + 1 | Array.from(iterableOrArrayLike, callback.bind(foo) )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.from(iterableOrArrayLike, callback.bind(foo).bind(thisArgument))␊ + 1 | Array.from(iterableOrArrayLike, callback.bind(foo).bind(thisArgument) )␊ ` ## invalid(26): Array.fromAsync(iterableOrArrayLike, callback.bind(foo), thisArgument) @@ -967,9 +1033,9 @@ Generated by [AVA](https://avajs.dev). ␊ --------------------------------------------------------------------------------␊ Suggestion 1/2: Remove this argument.␊ - 1 | Array.fromAsync(iterableOrArrayLike, callback.bind(foo))␊ + 1 | Array.fromAsync(iterableOrArrayLike, callback.bind(foo) )␊ ␊ --------------------------------------------------------------------------------␊ Suggestion 2/2: Use a bound function.␊ - 1 | Array.fromAsync(iterableOrArrayLike, callback.bind(foo).bind(thisArgument))␊ + 1 | Array.fromAsync(iterableOrArrayLike, callback.bind(foo).bind(thisArgument) )␊ ` diff --git a/test/snapshots/no-array-method-this-argument.js.snap b/test/snapshots/no-array-method-this-argument.js.snap index 4ea59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8r)V%YsIe2xreWupCcP#y8F1yJiLgT*A z`W?jMG3S5F5Ftv8KOFNEU?6J429%|C6gG#sSxhsi+JzpfZH-A_+k@yiNyE&0aVmi;BBihL%qhV zXZ5i6_8269PF&QvpjWJRlOjjH;Y^5(>^rv3YTVp_FMh_V(p~34ghw+$yJ|X$bCyVD PqXP9mNVahU<81%{R1Hd8 From e6da129562ab720e2e5906053999bd5692c2f80b Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 2 Sep 2025 16:36:15 +0800 Subject: [PATCH 3/6] no-unnecessary-array-flat-depth --- rules/no-unnecessary-array-flat-depth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/no-unnecessary-array-flat-depth.js b/rules/no-unnecessary-array-flat-depth.js index c9a2229786..6924c504e2 100644 --- a/rules/no-unnecessary-array-flat-depth.js +++ b/rules/no-unnecessary-array-flat-depth.js @@ -26,7 +26,7 @@ const create = context => { node: numberOne, messageId: MESSAGE_ID, /** @param {import('eslint').Rule.RuleFixer} fixer */ - fix: fixer => removeArgument(fixer, numberOne, context.sourceCode), + fix: fixer => removeArgument(fixer, numberOne, context), }; }); }; From 20798932d7f80ad07e512d8167b5e9ddc2d1e0c6 Mon Sep 17 00:00:00 2001 From: fisker Date: Tue, 2 Sep 2025 16:37:20 +0800 Subject: [PATCH 4/6] prefer-json-parse-buffer --- rules/prefer-json-parse-buffer.js | 2 +- test/snapshots/prefer-json-parse-buffer.js.md | 46 +++++++++--------- .../prefer-json-parse-buffer.js.snap | Bin 1769 -> 1787 bytes 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/rules/prefer-json-parse-buffer.js b/rules/prefer-json-parse-buffer.js index 13a61b734e..5f5f4760e9 100644 --- a/rules/prefer-json-parse-buffer.js +++ b/rules/prefer-json-parse-buffer.js @@ -139,7 +139,7 @@ const create = context => ({ return { node: charsetNode, messageId: MESSAGE_ID, - fix: fixer => removeArgument(fixer, charsetNode, sourceCode), + fix: fixer => removeArgument(fixer, charsetNode, context), }; }, }); diff --git a/test/snapshots/prefer-json-parse-buffer.js.md b/test/snapshots/prefer-json-parse-buffer.js.md index c31ba36ec1..e201178f45 100644 --- a/test/snapshots/prefer-json-parse-buffer.js.md +++ b/test/snapshots/prefer-json-parse-buffer.js.md @@ -15,7 +15,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | JSON.parse(await fs.readFile(file));␊ + 1 | JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -36,7 +36,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | JSON.parse(await fs.readFile(file,));␊ + 1 | JSON.parse(await fs.readFile(file ,));␊ ` > Error 1/1 @@ -57,7 +57,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | JSON.parse(await fs.readFile(file));␊ + 1 | JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -78,7 +78,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | JSON.parse(await fs.readFileSync(file));␊ + 1 | JSON.parse(await fs.readFileSync(file ));␊ ` > Error 1/1 @@ -99,7 +99,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | JSON.parse(fs.readFileSync(file));␊ + 1 | JSON.parse(fs.readFileSync(file ));␊ ` > Error 1/1 @@ -120,7 +120,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const CHARSET = "UTF8"; JSON.parse(await fs.readFile(file));␊ + 1 | const CHARSET = "UTF8"; JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -141,7 +141,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const EIGHT = 8; JSON.parse(await fs.readFile(file));␊ + 1 | const EIGHT = 8; JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -162,7 +162,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | JSON.parse(await fs["readFile"](file));␊ + 1 | JSON.parse(await fs["readFile"](file ));␊ ` > Error 1/1 @@ -183,7 +183,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | JSON.parse(await fs.readFile(file));␊ + 1 | JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -204,7 +204,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const EIGHT = 8; JSON.parse(await fs.readFile(file));␊ + 1 | const EIGHT = 8; JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -225,7 +225,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | JSON.parse(await fs.readFile(file));␊ + 1 | JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -246,7 +246,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const encoding = "utf8";JSON.parse(await fs.readFile(file));␊ + 1 | const encoding = "utf8";JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -267,7 +267,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const CHARSET = "utF-8", readingOptions = {encoding: CHARSET}; JSON.parse(await fs.readFile(file));␊ + 1 | const CHARSET = "utF-8", readingOptions = {encoding: CHARSET}; JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -288,7 +288,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const EIGHT = 8, ENCODING = "encoding"; JSON.parse(await fs.readFile(file));␊ + 1 | const EIGHT = 8, ENCODING = "encoding"; JSON.parse(await fs.readFile(file ));␊ ` > Error 1/1 @@ -310,7 +310,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const string = await fs.readFile(file);␊ + 1 | const string = await fs.readFile(file );␊ 2 | JSON.parse(string);␊ ` @@ -334,7 +334,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | let string = await fs.readFile(file);␊ + 1 | let string = await fs.readFile(file );␊ 2 | JSON.parse(string);␊ ` @@ -360,7 +360,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const foo = await await fs.readFile(file);␊ + 1 | const foo = await await fs.readFile(file );␊ 2 | const bar = await await foo;␊ 3 | const baz = await bar;␊ 4 | JSON.parse(baz);␊ @@ -390,7 +390,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | var foo = await fs.readFile(file);␊ + 1 | var foo = await fs.readFile(file );␊ 2 | let bar = await foo;␊ 3 | const baz = await bar;␊ 4 | JSON.parse(baz);␊ @@ -425,7 +425,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const foo = fs.readFile(file);␊ + 1 | const foo = fs.readFile(file );␊ 2 | async function fn1() {␊ 3 | const bar = await foo;␊ 4 |␊ @@ -467,7 +467,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const buffer = fs.readFile(file); /* Should report */␊ + 1 | const buffer = fs.readFile(file ); /* Should report */␊ 2 | const foo = buffer;␊ 3 | async function fn1() {␊ 4 | const buffer = fs.readFile(file, "utf8"); /* Should NOT report */␊ @@ -507,7 +507,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const buffer = fs.readFile(file); /* Should report */␊ + 1 | const buffer = fs.readFile(file ); /* Should report */␊ 2 | const foo = buffer;␊ 3 | async function fn1() {␊ 4 | const buffer = fs.readFile(file, "utf8"); /* Should NOT report */␊ @@ -553,7 +553,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const foo = fs.readFile(file);␊ + 1 | const foo = fs.readFile(file );␊ 2 | function fn1() {␊ 3 | JSON.parse(foo);␊ 4 |␊ @@ -589,7 +589,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | const string = await NOT_A_FS_MODULE.readFile(file);␊ + 1 | const string = await NOT_A_FS_MODULE.readFile(file );␊ 2 | JSON.parse(string);␊ ` diff --git a/test/snapshots/prefer-json-parse-buffer.js.snap b/test/snapshots/prefer-json-parse-buffer.js.snap index a2af0e0d35ec63472e9b1742759dc1b17a92a8bd..4de67d1d95188d92bc39a82542c7a649ef01215d 100644 GIT binary patch literal 1787 zcmVlcMiLk z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Fsj{S&n65oru~21o>drN zym`Ta1wcx>&l56E6DB_N+s4y^yYTvTaso|L%Wpm3GXU>^hmbLzOcK_dqDSzRH z@R=*xHK2@jpj}xoVqt;*^bM+ztDqBxC=WMLHGZe8#{ZxSHvK@y`^ToSe)wlacRs#4 zN_BQ<%wA~76q&@)5*e%Dwss`40?~B3OA_Y3g;@}#h51?~ETv4kduT-0*bJNtfxfWjRuBL|mp#$G2fVrcJl;!5$>j z;9!Z|m>e4Vq(Iy%euNUa$}~wHRsuFT2%{AKA)P}W&Xjmq_3`-lFFEY?E-#x~-aNfI zyR>;WH?y*k3HAo3j8647yxy`=`el2eQ$+qB@$H}a{m##bi(h%Z@}ti@*mr Date: Tue, 2 Sep 2025 16:39:13 +0800 Subject: [PATCH 5/6] Fix --- .../no-unnecessary-length-or-infinity-rule.js | 2 +- .../no-unnecessary-array-splice-count.js.md | 36 +++++++++--------- .../no-unnecessary-array-splice-count.js.snap | Bin 927 -> 945 bytes test/snapshots/no-unnecessary-slice-end.js.md | 18 ++++----- .../no-unnecessary-slice-end.js.snap | Bin 618 -> 627 bytes 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/rules/shared/no-unnecessary-length-or-infinity-rule.js b/rules/shared/no-unnecessary-length-or-infinity-rule.js index 5de807fb6c..13f5476298 100644 --- a/rules/shared/no-unnecessary-length-or-infinity-rule.js +++ b/rules/shared/no-unnecessary-length-or-infinity-rule.js @@ -72,7 +72,7 @@ function listen(context, {methods, messageId}) { messageId, data: messageData, /** @param {import('eslint').Rule.RuleFixer} fixer */ - fix: fixer => removeArgument(fixer, secondArgument, context.sourceCode), + fix: fixer => removeArgument(fixer, secondArgument, context), }; }); } diff --git a/test/snapshots/no-unnecessary-array-splice-count.js.md b/test/snapshots/no-unnecessary-array-splice-count.js.md index fbbcb7ccf8..cdb015cfb5 100644 --- a/test/snapshots/no-unnecessary-array-splice-count.js.md +++ b/test/snapshots/no-unnecessary-array-splice-count.js.md @@ -15,7 +15,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.splice(1)␊ + 1 | foo.splice(1 )␊ ` > Error 1/1 @@ -36,7 +36,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.splice(1)␊ + 1 | foo?.splice(1 )␊ ` > Error 1/1 @@ -57,7 +57,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.splice(1,)␊ + 1 | foo.splice(1 ,)␊ ` > Error 1/1 @@ -78,7 +78,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.splice(1)␊ + 1 | foo.splice(1 )␊ ` > Error 1/1 @@ -99,7 +99,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.splice(1)␊ + 1 | foo.splice(1 )␊ ` > Error 1/1 @@ -120,7 +120,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.splice(1)␊ + 1 | foo?.splice(1 )␊ ` > Error 1/1 @@ -141,7 +141,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.splice(1)␊ + 1 | foo?.splice(1 )␊ ` > Error 1/1 @@ -162,7 +162,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.splice(1)␊ + 1 | foo?.splice(1 )␊ ` > Error 1/1 @@ -183,7 +183,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.bar.splice(1)␊ + 1 | foo.bar.splice(1 )␊ ` > Error 1/1 @@ -204,7 +204,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.toSpliced(1)␊ + 1 | foo.toSpliced(1 )␊ ` > Error 1/1 @@ -225,7 +225,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.toSpliced(1)␊ + 1 | foo?.toSpliced(1 )␊ ` > Error 1/1 @@ -246,7 +246,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.toSpliced(1,)␊ + 1 | foo.toSpliced(1 ,)␊ ` > Error 1/1 @@ -267,7 +267,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.toSpliced(1)␊ + 1 | foo.toSpliced(1 )␊ ` > Error 1/1 @@ -288,7 +288,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.toSpliced(1)␊ + 1 | foo.toSpliced(1 )␊ ` > Error 1/1 @@ -309,7 +309,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.toSpliced(1)␊ + 1 | foo?.toSpliced(1 )␊ ` > Error 1/1 @@ -330,7 +330,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.toSpliced(1)␊ + 1 | foo?.toSpliced(1 )␊ ` > Error 1/1 @@ -351,7 +351,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.toSpliced(1)␊ + 1 | foo?.toSpliced(1 )␊ ` > Error 1/1 @@ -372,7 +372,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.bar.toSpliced(1)␊ + 1 | foo.bar.toSpliced(1 )␊ ` > Error 1/1 diff --git a/test/snapshots/no-unnecessary-array-splice-count.js.snap b/test/snapshots/no-unnecessary-array-splice-count.js.snap index 71888021c8eaf1cef3f1aa3b9b71c2ab709f5525..17e06d1f1cb3c9d6eb1fbdd212e64372c7ac2af7 100644 GIT binary patch literal 945 zcmV;i15W%wRzVX%K`z0K(6G zgsI14i2KdBB(ZQl3S&Yc5@Qc>9%sA*7(eUg;{0*ic*I3K5kQ>F`HEzUf^eP$jIt=_ zfD8sZ1BA|Fuo>a#uYmSjoOZAX)Yg4B_9SNPN)N+>P)Kw-e*~mokiM>j9M2GOC1J){ zm+=jBKuaJO0ibK-gqBk7eMIj9%&+JXE$7@f&}kQRIS5)c8@j2B4TN$50Ae`hqx;Ds zeg|$o!3lfMmg4o;x)+iHJK=(z3WA+$t=G6+SeRc_m(;tn57oIl>YTcC9|1iBe(V?y zn$$}c{4e0`AB4B*V!9a}9IrE!U{amB?sn?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error 1/1 @@ -57,7 +57,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.slice(1,)␊ + 1 | foo.slice(1 ,)␊ ` > Error 1/1 @@ -78,7 +78,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.slice(1)␊ + 1 | foo.slice(1 )␊ ` > Error 1/1 @@ -99,7 +99,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.slice(1)␊ + 1 | foo.slice(1 )␊ ` > Error 1/1 @@ -120,7 +120,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.slice(1)␊ + 1 | foo?.slice(1 )␊ ` > Error 1/1 @@ -141,7 +141,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.slice(1)␊ + 1 | foo?.slice(1 )␊ ` > Error 1/1 @@ -162,7 +162,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo?.slice(1)␊ + 1 | foo?.slice(1 )␊ ` > Error 1/1 @@ -183,7 +183,7 @@ Generated by [AVA](https://avajs.dev). > Output `␊ - 1 | foo.bar.slice(1)␊ + 1 | foo.bar.slice(1 )␊ ` > Error 1/1 diff --git a/test/snapshots/no-unnecessary-slice-end.js.snap b/test/snapshots/no-unnecessary-slice-end.js.snap index 92d7479429111530501da16174f2be7bfca7aec8..cb036a4d0afa22d7aaa8d9ceb38781c3c50beb62 100644 GIT binary patch literal 627 zcmV-(0*w7ZRzVUB5j0Fdw?J=+_+K+o`5IfNl+mhXYj0Pn^5+a$ltd!zZre|rBx53#PnU(X8piiM)-`o$G!MNvtGqQPC?`}HH_vaLHsp(NW?ok*+0qh^z7_N;W#x$GRD zsY}k4DJTH=(6j0bJY;nq@<8q;df+gF9Ij>^z{pw~iB5Izkgi);%fA@_paYFsvJz~XkY!=(nHAd!+cxKb?cmIk$n^*D}V@XNjdI%k01`wg^m zLZW5V*Ugj%Z9pNNMHbV9g@tJ!3HMW`mb(e4=S6kVzNX%3sL}?fqB?}?(Ny0f;a>ix zdjDZnZyTsfe?oQLk zPi$}H44FV1OfqIaAYIS0yp@yXEQVT{5Y>4@b(u=q9ISUyZ?|kwo6GggS^E(Q-`KJ? zm+U`BJ7ds3$e;~mOGu%+1lK#LwHqYYp?soH50Nk-p{6(I5lwNL@5g1iXjneXu&gFK zbsm>CH=YDr!PE7ZLG^J^4Yr;WY*$f-WsRg=!9WK1){}Wul(yrz-3qWN_54bOPVm)%0M-Erh4o214h;<@+k7WJAlkAHD00w~0%khCt zrj(FfXe5#bFa^5Dp}}Rl0W9jq+gxf83SudFiz~&Veq~gfSc{@C0Bo=b-3-QPTG zrvzF>eceoO&;}II1!QrJu%M9+k?viB)N(b!^rE0H+n2O_7O1qrnV^m>Xs92MZZ~^R z%l~0fZyBa5e=>F5iPE4{BEYVo?ur!HluM2w@M%(Z>A<1rrthcr_QE#z9_?>Av!!e%*nduT!H~V5 zBJ0bJkV5wfthZ5XH%P2wd7exUkuD~gCKqP`O=z0$r$xDJP(DbZtjF6;9#u9sp88w< zv$a=#eciA7TQ3N-k5PwJ60OxPPt@O0 Date: Tue, 2 Sep 2025 16:51:51 +0800 Subject: [PATCH 6/6] FIx name --- rules/fix/remove-argument.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/fix/remove-argument.js b/rules/fix/remove-argument.js index 63b1a41f3e..5f48d37501 100644 --- a/rules/fix/remove-argument.js +++ b/rules/fix/remove-argument.js @@ -1,7 +1,7 @@ import {isCommaToken} from '@eslint-community/eslint-utils'; import {getParentheses} from '../utils/parentheses.js'; -export default function * removeObjectProperty(fixer, node, context) { +export default function * removeArgument(fixer, node, context) { const {sourceCode} = context; for (const token of sourceCode.getTokens(node)) { yield fixer.remove(token);