From a41fdc07404a7675d14183fab245fb8f49dcb858 Mon Sep 17 00:00:00 2001 From: Milos Djermanovic Date: Fri, 13 Sep 2019 04:28:35 +0200 Subject: [PATCH] Fix: Remove autofixer for no-unsafe-negation (#12157) --- lib/rules/no-unsafe-negation.js | 12 ++---------- tests/lib/rules/no-unsafe-negation.js | 6 ------ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/lib/rules/no-unsafe-negation.js b/lib/rules/no-unsafe-negation.js index f394f674259..717e5f6be39 100644 --- a/lib/rules/no-unsafe-negation.js +++ b/lib/rules/no-unsafe-negation.js @@ -51,7 +51,7 @@ module.exports = { }, schema: [], - fixable: "code", + fixable: null, messages: { unexpected: "Unexpected negating the left operand of '{{operator}}' operator." } @@ -70,15 +70,7 @@ module.exports = { node, loc: node.left.loc, messageId: "unexpected", - data: { operator: node.operator }, - - fix(fixer) { - const negationToken = sourceCode.getFirstToken(node.left); - const fixRange = [negationToken.range[1], node.range[1]]; - const text = sourceCode.text.slice(fixRange[0], fixRange[1]); - - return fixer.replaceTextRange(fixRange, `(${text})`); - } + data: { operator: node.operator } }); } } diff --git a/tests/lib/rules/no-unsafe-negation.js b/tests/lib/rules/no-unsafe-negation.js index 8316aad0227..6ac24541248 100644 --- a/tests/lib/rules/no-unsafe-negation.js +++ b/tests/lib/rules/no-unsafe-negation.js @@ -34,32 +34,26 @@ ruleTester.run("no-unsafe-negation", rule, { invalid: [ { code: "!a in b", - output: "!(a in b)", errors: [unexpectedInError] }, { code: "(!a in b)", - output: "(!(a in b))", errors: [unexpectedInError] }, { code: "!(a) in b", - output: "!((a) in b)", errors: [unexpectedInError] }, { code: "!a instanceof b", - output: "!(a instanceof b)", errors: [unexpectedInstanceofError] }, { code: "(!a instanceof b)", - output: "(!(a instanceof b))", errors: [unexpectedInstanceofError] }, { code: "!(a) instanceof b", - output: "!((a) instanceof b)", errors: [unexpectedInstanceofError] } ]