---
title: "lint/dead-code/no-self-assignment"
pagination: false
---

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

<RuleId id="lint/dead-code/no-self-assignment" />

In the [`dead-code`](/docs/rules/sets/dead-code) set. Safe fix. Intent: correctness.

## What it does

Detects and removes self-assignments where a variable or property is assigned to itself.

## Configuration

```toml title="pun.toml"
[lint.rules]
"dead-code/no-self-assignment" = "error"
```

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

## Replaces

- [`Pun/no_self_assignment`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/) (pun)
- [`SimplifyMirrorAssign`](https://getrector.com/rule-detail/simplify-mirror-assign-rector) (rector)
- [`no-self-assignment`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#no-self-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/dead-code/no-mirror-assignment`

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