From ca8934e256297bcfec4edbefb0d2f510204bf26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCrg=C3=BCn=20Day=C4=B1o=C4=9Flu?= Date: Sun, 14 Jan 2024 00:18:48 +0100 Subject: [PATCH] remove unnecessary rule --- src/index.js | 2 -- src/rules/prefer-positive-conditions.js | 44 ------------------------- 2 files changed, 46 deletions(-) delete mode 100644 src/rules/prefer-positive-conditions.js diff --git a/src/index.js b/src/index.js index 3c5f71a..45aa022 100644 --- a/src/index.js +++ b/src/index.js @@ -99,7 +99,6 @@ module.exports = { "grules/prefer-literal-bigint": "error", "grules/prefer-negation-operator-boolean": "error", "grules/prefer-negation-operator-number": "error", - "grules/prefer-positive-conditions": "error", "grules/prefer-property-access-at": "error", "grules/prefer-property-access-object-entries": "error", @@ -178,7 +177,6 @@ module.exports = { "prefer-literal-bigint": require("./rules/prefer-literal-bigint.js"), "prefer-negation-operator-boolean": require("./rules/prefer-negation-operator-boolean.js"), "prefer-negation-operator-number": require("./rules/prefer-negation-operator-number.js"), - "prefer-positive-conditions": require("./rules/prefer-positive-conditions.js"), "prefer-property-access-at": require("./rules/prefer-property-access-at.js"), "prefer-property-access-object-entries": require("./rules/prefer-property-access-object-entries.js"), }, diff --git a/src/rules/prefer-positive-conditions.js b/src/rules/prefer-positive-conditions.js deleted file mode 100644 index 5172271..0000000 --- a/src/rules/prefer-positive-conditions.js +++ /dev/null @@ -1,44 +0,0 @@ -module.exports = { - meta: { - fixable: "code", - }, - create: (context) => { - const checkNode = (node) => { - if ( - node.type === "LogicalExpression" && - (node.operator === "&&" || node.operator === "||") - ) { - if ( - node.left.type === "UnaryExpression" && - node.right.type === "UnaryExpression" && - node.left.operator === "!" && - node.right.operator === "!" - ) { - context.report({ - node, - message: - "Avoid multiple negated conditions in logical AND expressions", - fix: (fixer) => { - const sourceCode = context.getSourceCode(); - const leftArgument = sourceCode.getText(node.left.argument); - const rightArgument = sourceCode.getText(node.right.argument); - - const fixedExpression = `!(${leftArgument} ${ - node.operator === "&&" ? "||" : "&&" - } ${rightArgument})`; - - return fixer.replaceText(node, fixedExpression); - }, - }); - } else { - checkNode(node.left); - checkNode(node.right); - } - } - }; - - return { - LogicalExpression: checkNode, - }; - }, -};