diff --git a/lib/rules/no-logical-assignment-operators.js b/lib/rules/no-logical-assignment-operators.js index 0ee2ff11..aac2fd4b 100644 --- a/lib/rules/no-logical-assignment-operators.js +++ b/lib/rules/no-logical-assignment-operators.js @@ -31,7 +31,7 @@ module.exports = { node: operatorToken, messageId: "forbidden", fix(fixer) { - if (utils.hasSideEffect(node.left, sourceCode)) { + if (node.left.type !== "Identifier") { return null } const newOperator = node.operator.slice(-1) diff --git a/tests/lib/rules/no-logical-assignment-operators.js b/tests/lib/rules/no-logical-assignment-operators.js index 2ca99732..0e26d537 100644 --- a/tests/lib/rules/no-logical-assignment-operators.js +++ b/tests/lib/rules/no-logical-assignment-operators.js @@ -40,7 +40,7 @@ new RuleTester().run("no-logical-assignment-operators", rule, { }, { code: "a.b ||= c", - output: "a.b = a.b || (c)", + output: null, errors: ["ES2021 logical assignment operators are forbidden."], }, {