Skip to content

Commit

Permalink
Fix: Remove autofixer for no-unsafe-negation (#12157)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjermanovic authored and mysticatea committed Sep 13, 2019
1 parent e38f5fd commit a41fdc0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
12 changes: 2 additions & 10 deletions lib/rules/no-unsafe-negation.js
Expand Up @@ -51,7 +51,7 @@ module.exports = {
},

schema: [],
fixable: "code",
fixable: null,
messages: {
unexpected: "Unexpected negating the left operand of '{{operator}}' operator."
}
Expand All @@ -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 }
});
}
}
Expand Down
6 changes: 0 additions & 6 deletions tests/lib/rules/no-unsafe-negation.js
Expand Up @@ -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]
}
]
Expand Down

0 comments on commit a41fdc0

Please sign in to comment.