# no-redundant-assignments

Rule `sonarjs/no-redundant-assignments`. Assignments should not be redundant

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1306 by reach, #607 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-redundant-assignments` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-4165/) |

## Code examples

### Incorrect: the rule reports this

```js
a = b;
c = a;
b = c; // Noncompliant: c and b are already the same
```

### Correct: the rule accepts this

```js
a = b;
c = a;
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-redundant-assignments": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/no-primitive-wrappers](https://lintradar.dev/rules/sonarjs/no-primitive-wrappers.md): Wrapper objects should not be used for primitive types
- [sonarjs/no-redundant-boolean](https://lintradar.dev/rules/sonarjs/no-redundant-boolean.md): Boolean literals should not be used in comparisons
- [sonarjs/no-parameter-reassignment](https://lintradar.dev/rules/sonarjs/no-parameter-reassignment.md): Initial values of parameters, caught exceptions, and loop variables should not be ignored
- [sonarjs/no-redundant-jump](https://lintradar.dev/rules/sonarjs/no-redundant-jump.md): Jump statements should not be redundant
- [sonarjs/no-os-command-from-path](https://lintradar.dev/rules/sonarjs/no-os-command-from-path.md): OS commands should not rely on PATH resolution
- [sonarjs/no-redundant-optional](https://lintradar.dev/rules/sonarjs/no-redundant-optional.md): Optional properties should not redundantly include 'undefined'

---

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