# no-misleading-array-reverse

Rule `sonarjs/no-misleading-array-reverse`. Array-mutating methods should not be used misleadingly

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: yes
- Autofix: yes, in at least one linter
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1297 by reach, #598 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-misleading-array-reverse` | yes | suggestion | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-4043/) |

## Code examples

### Incorrect: the rule reports this

```js
var b = a.reverse(); // Noncompliant
var d = c.sort(); // Noncompliant
```

### Correct: the rule accepts this

```js
var b = [...a].reverse();  // de-structure and create a new array, so reverse doesn't impact 'a'
a.reverse();

c.sort(); // this sorts array in place
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-misleading-array-reverse": "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-mime-sniff](https://lintradar.dev/rules/sonarjs/no-mime-sniff.md): Browsers should not be allowed to perform MIME type sniffing
- [sonarjs/no-misleading-character-class](https://lintradar.dev/rules/sonarjs/no-misleading-character-class.md): Unicode Grapheme Clusters should be avoided inside regex character classes
- [sonarjs/no-literal-call](https://lintradar.dev/rules/sonarjs/no-literal-call.md): Literals should not be used as functions
- [sonarjs/no-mutate-reactive-state-in-updated-hook](https://lintradar.dev/rules/sonarjs/no-mutate-reactive-state-in-updated-hook.md): Reactive state should not be unconditionally mutated inside Vue's "updated" lifecycle hook
- [sonarjs/no-labels](https://lintradar.dev/rules/sonarjs/no-labels.md): Labels should not be used
- [sonarjs/no-nested-assignment](https://lintradar.dev/rules/sonarjs/no-nested-assignment.md): Assignments should not be made from within sub-expressions

---

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