# no-uniq-key

Rule `sonarjs/no-uniq-key`. JSX list components keys should match up between renders

- 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: #1323 by reach, #624 by growth

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
function generateButtons(props) {
  return props.buttons.map((button, index) => {
    <Button key={Math.random()}>{button.number}</Button>
  });
}
```

### Correct: the rule accepts this

```js
function generateButtons(props) {
  return props.buttons.map((button, index) => {
    <Button key={button.number}>{button.number}</Button>
  });
}
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/no-uniq-key": "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-unenclosed-multiline-block](https://lintradar.dev/rules/sonarjs/no-unenclosed-multiline-block.md): Multiline blocks should be enclosed in curly braces
- [sonarjs/no-unthrown-error](https://lintradar.dev/rules/sonarjs/no-unthrown-error.md): Errors should not be created without being thrown
- [sonarjs/no-undefined-argument](https://lintradar.dev/rules/sonarjs/no-undefined-argument.md): "undefined" should not be passed as the value of optional parameters
- [sonarjs/no-unused-collection](https://lintradar.dev/rules/sonarjs/no-unused-collection.md): Collection contents should be used
- [sonarjs/no-try-promise](https://lintradar.dev/rules/sonarjs/no-try-promise.md): Promise rejections should not be caught by "try" blocks
- [sonarjs/no-unused-vars](https://lintradar.dev/rules/sonarjs/no-unused-vars.md): Unused local variables and functions should be removed

---

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