# logical-assignment-operators

Rule `eslint/logical-assignment-operators`. Require or disallow logical assignment operator shorthand

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 2.2M weekly downloads of presets that enable it
- Trend: +137.0% last quarter
- Rank: #1493 by reach, #86 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `logical-assignment-operators` | no | safe | package `eslint` | [docs](https://eslint.org/docs/latest/rules/logical-assignment-operators) |
| Oxlint | `logical-assignment-operators` | no | no | plugin `eslint`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/logical-assignment-operators.html) |

## Code examples

### Incorrect: the rule reports this

```js
a = a || b
a = a && b
a = a ?? b
a || (a = b)
a && (a = b)
a ?? (a = b)
a = a || b || c
a = a && b && c
a = a ?? b ?? c
```

```js
a ||= b
a &&= b
a ??= b
```

```js
if (a) a = b // <=> a &&= b
if (!a) a = b // <=> a ||= b

if (a == null) a = b // <=> a ??= b
if (a === null || a === undefined) a = b // <=> a ??= b
```

### Correct: the rule accepts this

```js
a = b
a += b
a ||= b
a = b || c
a || (b = c)

if (a) a = b

a = (a || b) || c
```

```js
a = a || b
a = a && b
a = a ?? b
```

```js
if (a) b = c
if (a === 0) a = b
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "logical-assignment-operators": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "logical-assignment-operators": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [unicorn/logical-assignment-operators](https://lintradar.dev/rules/unicorn/logical-assignment-operators.md): Require or disallow logical assignment operator shorthand
- [eslint/no-negated-condition](https://lintradar.dev/rules/eslint/no-negated-condition.md): Disallow negated conditions
- [eslint/prefer-named-capture-group](https://lintradar.dev/rules/eslint/prefer-named-capture-group.md): Enforce using named capture group in regular expression
- [eslint/require-await](https://lintradar.dev/rules/eslint/require-await.md): Disallow async functions which have no `await` expression
- [eslint/no-warning-comments](https://lintradar.dev/rules/eslint/no-warning-comments.md): Disallow specified warning terms in comments
- [eslint/no-restricted-imports](https://lintradar.dev/rules/eslint/no-restricted-imports.md): Disallow specified modules when loaded by `import`

---

Web page: https://lintradar.dev/rules/eslint/logical-assignment-operators. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
