# no-useless-set-construction

Rule `unicorn/no-useless-set-construction`. Disallow unnecessary `Set` construction around `Set` methods.

- Source: unicorn
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 40.5M weekly downloads of presets that enable it
- Trend: +81.2% last quarter
- Rank: #437 by reach, #429 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-useless-set-construction` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-useless-set-construction.md) |
| Biome | `nursery/noUselessSetConstruction` | yes | unsafe | group nursery, since 2.6.9 | [docs](https://biomejs.dev/linter/rules/no-useless-set-construction/) |

## Code examples

### Incorrect: the rule reports this

```js
selected.intersection(new Set(records.keys()));
selected.union(new Set(other));
selected.difference(new Set(other.values()));
```

```js
new Set(selected).union(other);
new Set(selected.keys()).isSubsetOf(other);
```

```js
const combined = new Set(selected.union(other));
```

### Correct: the rule accepts this

```js
selected.intersection(records);
selected.union(other);
selected.difference(other);
```

```js
selected.union(other);
selected.isSubsetOf(other);
```

```js
const combined = selected.union(other);
```

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-useless-set-construction": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "noUselessSetConstruction": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Biome recommended](https://lintradar.dev/presets/biome-recommended.md) | Biome | `@biomejs/biome` | 491 | 28.5M | +106.8% |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [Unicorn unopinionated](https://lintradar.dev/presets/unicorn-unopinionated.md) | ESLint | `eslint-plugin-unicorn` | 236 | 9.5M | +30.3% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/no-unnecessary-string-trim](https://lintradar.dev/rules/unicorn/no-unnecessary-string-trim.md): Disallow `String#trim()` before `String#startsWith()` or `String#endsWith()`.
- [unicorn/no-xor-as-exponentiation](https://lintradar.dev/rules/unicorn/no-xor-as-exponentiation.md): Disallow the bitwise XOR operator where exponentiation was likely intended.
- [unicorn/no-unnecessary-nested-ternary](https://lintradar.dev/rules/unicorn/no-unnecessary-nested-ternary.md): Disallow unnecessary nested ternary expressions.
- [unicorn/prefer-block-statement-over-iife](https://lintradar.dev/rules/unicorn/prefer-block-statement-over-iife.md): Prefer block statements over IIFEs used only for scoping.
- [unicorn/no-subtraction-comparison](https://lintradar.dev/rules/unicorn/no-subtraction-comparison.md): Prefer comparing values directly over subtracting and comparing to `0`.
- [unicorn/prefer-boolean-return](https://lintradar.dev/rules/unicorn/prefer-boolean-return.md): Prefer directly returning boolean expressions over `if` statements.

---

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