# no-duplicate-set-values

Rule `unicorn/no-duplicate-set-values`. Disallow duplicate values in `Set` constructor array literals.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #1039 by reach, #1294 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-duplicate-set-values` | no | no | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-duplicate-set-values.md) |

## Code examples

### Incorrect: the rule reports this

```js
const set = new Set([
  'foo',
  'bar',
  'foo',
]);
```

```js
const foo = 2;
const set = new Set([foo, 2]);
```

```js
const set = new Set([foo.bar, foo.bar]);
```

### Correct: the rule accepts this

```js
const set = new Set([
  'foo',
  'bar',
]);
```

```js
const foo = 2;
const set = new Set([foo, 3]);
```

```js
const set = new Set([foo.bar, foo.baz]);
```

Examples from the ESLint documentation.

## Enable it

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

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-duplicate-set-values": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/no-computed-property-existence-check](https://lintradar.dev/rules/unicorn/no-computed-property-existence-check.md): Disallow dynamic object property existence checks.
- [unicorn/no-incorrect-query-selector](https://lintradar.dev/rules/unicorn/no-incorrect-query-selector.md): Disallow incorrect `querySelector()` and `querySelectorAll()` usage.
- [unicorn/no-asterisk-prefix-in-documentation-comments](https://lintradar.dev/rules/unicorn/no-asterisk-prefix-in-documentation-comments.md): Disallow asterisk prefixes and shared indentation in multiline comments.
- [unicorn/no-incorrect-template-string-interpolation](https://lintradar.dev/rules/unicorn/no-incorrect-template-string-interpolation.md): Disallow incorrect template literal interpolation syntax.
- [unicorn/no-array-splice](https://lintradar.dev/rules/unicorn/no-array-splice.md): Prefer `Array#toSpliced()` over `Array#splice()`.
- [unicorn/no-leading-empty-lines](https://lintradar.dev/rules/unicorn/no-leading-empty-lines.md): Disallow empty lines at the beginning of a file.

---

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