# no-duplicate-string

Rule `sonarjs/no-duplicate-string`. String literals should not be duplicated

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2146 by reach

## Linters

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

## Enable it

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

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

## Related rules

- [sonarjs/no-commented-code](https://lintradar.dev/rules/sonarjs/no-commented-code.md): Sections of code should not be commented out
- [sonarjs/no-empty-test-file](https://lintradar.dev/rules/sonarjs/no-empty-test-file.md): Test files should contain at least one test case
- [sonarjs/no-collapsible-if](https://lintradar.dev/rules/sonarjs/no-collapsible-if.md): Mergeable "if" statements should be combined
- [sonarjs/no-for-in-iterable](https://lintradar.dev/rules/sonarjs/no-for-in-iterable.md): "for in" should not be used with iterables
- [sonarjs/no-built-in-override](https://lintradar.dev/rules/sonarjs/no-built-in-override.md): Built-in objects should not be overridden
- [sonarjs/no-function-declaration-in-block](https://lintradar.dev/rules/sonarjs/no-function-declaration-in-block.md): Function declarations should not be made within blocks

---

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