# no-useless-compound-assignment

Rule `unicorn/no-useless-compound-assignment`. Disallow useless compound assignments such as `x += 0`.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #959 by reach, #1214 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-useless-compound-assignment` | no | suggestion | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-useless-compound-assignment.md) |

## Code examples

### Incorrect: the rule reports this

```js
let total = getTotal();
total += 0;
```

```js
price *= 1;
```

```js
function update(count) {
  return count -= 0;
}
```

### Correct: the rule accepts this

```js
let total = getTotal();
```

```js
// (remove the line)
```

```js
function update(count) {
  return count;
}
```

Examples from the ESLint documentation.

## Enable it

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

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-useless-compound-assignment": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/no-useless-coercion](https://lintradar.dev/rules/unicorn/no-useless-coercion.md): Disallow useless type coercions of values that are already of the target type.
- [unicorn/no-useless-continue](https://lintradar.dev/rules/unicorn/no-useless-continue.md): Disallow useless `continue` statements.
- [unicorn/no-useless-boolean-cast](https://lintradar.dev/rules/unicorn/no-useless-boolean-cast.md): Disallow unnecessary `Boolean()` casts in array predicate callbacks.
- [unicorn/no-useless-delete-check](https://lintradar.dev/rules/unicorn/no-useless-delete-check.md): Disallow unnecessary existence checks before deletion.
- [unicorn/no-url-in-search-params](https://lintradar.dev/rules/unicorn/no-url-in-search-params.md): Disallow passing full URLs to `URLSearchParams`.
- [unicorn/no-useless-logical-operand](https://lintradar.dev/rules/unicorn/no-useless-logical-operand.md): Disallow unnecessary operands in logical expressions involving boolean literals.

---

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