# logical-assignment-operators πŸ“ Require or disallow logical assignment operator shorthand. πŸ’ΌπŸš« This rule is enabled in the βœ… `recommended` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). This rule is _disabled_ in the β˜‘οΈ `unopinionated` [config](https://github.com/sindresorhus/eslint-plugin-unicorn#recommended-config). πŸ”§πŸ’‘ This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions). This rule is the same as the built-in ESLint [`logical-assignment-operators`](https://eslint.org/docs/latest/rules/logical-assignment-operators) rule, but when `enforceForIfStatements` is enabled, falsy `if` assignments are reported with suggestions for both `||=` and `??=` instead of being autofixed. ## Replacement for ESLint `logical-assignment-operators` This rule replaces ESLint's built-in `logical-assignment-operators` rule, which Unicorn presets disable when this rule is enabled. ## Examples ```js /* eslint unicorn/logical-assignment-operators: ["error", "always", {"enforceForIfStatements": true}] */ // ❌ if (!foo) { foo = bar; } // βœ… foo ||= bar; // βœ… foo ??= bar; ``` ## Options This rule supports the same options as ESLint `logical-assignment-operators`.