---
title: "lint/style/prefer-compound-assignment"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="lint/style/prefer-compound-assignment" />

In the [`code-quality`](/docs/rules/sets/code-quality) set. Unsafe fix: it can change behaviour.

## What it does

Shorthand notation for operators should be used if possible.

## Configuration

```toml title="pun.toml"
[lint.rules]
"style/prefer-compound-assignment" = "error"
```

To skip it in some files, add an [override](/docs/configuration/pun-toml#lint) or a [`@pun-ignore-file`](/docs/configuration/ignore-comments) comment.

## Replaces

- [`long_to_shorthand_operator`](https://cs.symfony.com/doc/rules/operator/long_to_shorthand_operator.html) (php-cs-fixer, risky)
- [`CombinedAssign`](https://getrector.com/rule-detail/combined-assign-rector) (rector)
- [`use-compound-assignment`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#use-compound-assignment) (mago-linter)

## Merged rules

These old IDs are now this rule. A config that still names one stops with an error. See [merged rules](/docs/migrate/merged-rules).

- `lint/operators/prefer-shorthand-operator`

[More lint/style rules](/docs/rules/lint/style) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
