Repository: eslint/eslint
File: tests/lib/rules/logical-assignment-operators.js (JavaScript)

Code before:
            options: ["never"]
        }, {
            code: "a = b",
            options: ["never"]
        }, {
            code: "a += b",
            options: ["never"]
        }, {
            code: "a -= b",
            options: ["never"]
        }, {
            code: "a.b = a.b || c",
            options: ["never"]
        },

        // 3 or more operands
        {
            code: "a = a && b || c",
            options: ["always"]
        },
        {
            code: "a = a && b && c || d",
            options: ["always"]
        },
        {
            code: "a = (a || b) || c", // Ignore parentheses if used.
            options: ["always"]
        },
        {
            code: "a = (a && b) && c", // Ignore parentheses if used.
            options: ["always"]
        }
    ],
    invalid: [

        // Assignment
        {
            code: "a = a || b",
            output: "a ||= b",
            errors: [{ messageId: "assignment", type: "AssignmentExpression", data: { operator: "||=" }, suggestions: [] }]
        }, {
            code: "a = a && b",
            output: "a &&= b",
            errors: [{ messageId: "assignment", type: "AssignmentExpression", data: { operator: "&&=" }, suggestions: [] }]
        }, {
            code: "a = a ?? b",
            output: "a ??= b",
            errors: [{ messageId: "assignment", type: "AssignmentExpression", data: { operator: "??=" }, suggestions: [] }]
        }, {
            code: "foo = foo || bar",
            output: "foo ||= bar",

Review comment (suggestion):
```suggestion
            code: "a = (a || b) || c", // Allow if parentheses are used.
```

Rewording a bit to clarify since the rule doesn't ignore parentheses (in fact, they affect the logic by making the expression allowed).

Code after:
            options: ["never"]
        }, {
            code: "a = b",
            options: ["never"]
        }, {
            code: "a += b",
            options: ["never"]
        }, {
            code: "a -= b",
            options: ["never"]
        }, {
            code: "a.b = a.b || c",
            options: ["never"]
        },

        // 3 or more operands
        {
            code: "a = a && b || c",
            options: ["always"]
        },
        {
            code: "a = a && b && c || d",
            options: ["always"]
        },
        {
            code: "a = (a || b) || c", // Allow if parentheses are used.
            options: ["always"]
        },
        {
            code: "a = (a && b) && c", // Allow if parentheses are used.
            options: ["always"]
        },
        {
            code: "a = (a ?? b) ?? c", // Allow if parentheses are used.
            options: ["always"]
        }
    ],
    invalid: [

        // Assignment
        {
            code: "a = a || b",
            output: "a ||= b",
            errors: [{ messageId: "assignment", type: "AssignmentExpression", data: { operator: "||=" }, suggestions: [] }]
        }, {
            code: "a = a && b",
            output: "a &&= b",
            errors: [{ messageId: "assignment", type: "AssignmentExpression", data: { operator: "&&=" }, suggestions: [] }]
        }, {
            code: "a = a ?? b",
            output: "a ??= b",