From 5eb89a61f3ef0f2bbb52edbba79e491ecb49c187 Mon Sep 17 00:00:00 2001 From: "weiran.zsd" Date: Sat, 9 Feb 2019 00:41:17 +0800 Subject: [PATCH] Update: remove prefer-spread autofix (fixes #11330) --- lib/rules/prefer-spread.js | 15 ++------------- tests/lib/rules/prefer-spread.js | 16 ---------------- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/lib/rules/prefer-spread.js b/lib/rules/prefer-spread.js index 790fd3b82aa..5f3a477329b 100644 --- a/lib/rules/prefer-spread.js +++ b/lib/rules/prefer-spread.js @@ -59,7 +59,7 @@ module.exports = { }, schema: [], - fixable: "code" + fixable: null }, create(context) { @@ -78,18 +78,7 @@ module.exports = { if (isValidThisArg(expectedThis, thisArg, sourceCode)) { context.report({ node, - message: "Use the spread operator instead of '.apply()'.", - fix(fixer) { - if (expectedThis && expectedThis.type !== "Identifier") { - - // Don't fix cases where the `this` value could be a computed expression. - return null; - } - - const propertyDot = sourceCode.getFirstTokenBetween(applied, node.callee.property, token => token.value === "."); - - return fixer.replaceTextRange([propertyDot.range[0], node.range[1]], `(...${sourceCode.getText(node.arguments[1])})`); - } + message: "Use the spread operator instead of '.apply()'." }); } } diff --git a/tests/lib/rules/prefer-spread.js b/tests/lib/rules/prefer-spread.js index 7e9681770cf..1e11dd6c44a 100644 --- a/tests/lib/rules/prefer-spread.js +++ b/tests/lib/rules/prefer-spread.js @@ -44,50 +44,34 @@ ruleTester.run("prefer-spread", rule, { invalid: [ { code: "foo.apply(undefined, args);", - output: "foo(...args);", errors }, { code: "foo.apply(void 0, args);", - output: "foo(...args);", errors }, { code: "foo.apply(null, args);", - output: "foo(...args);", errors }, { code: "obj.foo.apply(obj, args);", - output: "obj.foo(...args);", errors }, { - - // Not fixed: a.b.c might activate getters code: "a.b.c.foo.apply(a.b.c, args);", - output: null, errors }, { - - // Not fixed: a.b(x, y).c might activate getters code: "a.b(x, y).c.foo.apply(a.b(x, y).c, args);", - output: null, errors }, { - - // Not fixed (not an identifier) code: "[].concat.apply([ ], args);", - output: null, errors }, { - - // Not fixed (not an identifier) code: "[].concat.apply([\n/*empty*/\n], args);", - output: null, errors } ]