# operator-assignment

Rule `eslint/operator-assignment`. Require or disallow assignment operator shorthand where possible

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `operator-assignment` | no | safe | package `eslint` | [docs](https://eslint.org/docs/latest/rules/operator-assignment) |
| Oxlint | `operator-assignment` | no | unsafe | plugin `eslint`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/operator-assignment.html) |
| Biome | `style/useShorthandAssign` | no | unsafe | group style, since 1.3.0 | [docs](https://biomejs.dev/linter/rules/use-shorthand-assign/) |

## Code examples

### Incorrect: the rule reports this

```js
x = x + y;
x = y * x;
x[0] = x[0] / y;
x.y = x.y << z;
```

```js
x *= y;
x ^= (y + z) / foo();
```

### Correct: the rule accepts this

```js
x = y;
x += y;
x = y * z;
x = (x * y) * z;
x[0] /= y;
x[foo()] = x[foo()] % 2;
x = y + x; // `+` is not always commutative (e.g. x = "abc")
```

```js
x = x + y;
x.y = x.y / a.b;
```

Examples from the ESLint documentation.

## Enable it

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

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "operator-assignment": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "useShorthandAssign": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb base](https://lintradar.dev/presets/airbnb-base.md) | ESLint | `eslint-config-airbnb-base` | 241 | 6.5M | +2.1% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [unicorn/operator-assignment](https://lintradar.dev/rules/unicorn/operator-assignment.md): Require assignment operator shorthand where possible.
- [eslint/no-multi-assign](https://lintradar.dev/rules/eslint/no-multi-assign.md): Disallow use of chained assignment expressions
- [eslint/no-else-return](https://lintradar.dev/rules/eslint/no-else-return.md): Disallow `else` blocks after `return` statements in `if` statements
- [eslint/no-lonely-if](https://lintradar.dev/rules/eslint/no-lonely-if.md): Disallow `if` statements as the only statement in `else` blocks
- [eslint/prefer-destructuring](https://lintradar.dev/rules/eslint/prefer-destructuring.md): Require destructuring from arrays and/or objects
- [eslint/no-await-in-loop](https://lintradar.dev/rules/eslint/no-await-in-loop.md): Disallow `await` inside of loops

---

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