# prefer-iterator-concat

Rule `unicorn/prefer-iterator-concat`. Prefer `Iterator.concat(…)` over temporary spread arrays.

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

## Linters

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

## Code examples

### Incorrect: the rule reports this

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

```js
for (const item of [...foo, ...bar]);
```

### Correct: the rule accepts this

```js
const set = new Set(Iterator.concat(foo, bar));
```

```js
for (const item of Iterator.concat(foo, bar));
```

```js
new Set([first, ...rest]);
```

Examples from the ESLint documentation.

## Enable it

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

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

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/prefer-iterator-concat": "error",
    },
  },
];
```

## Related rules

- [unicorn/prefer-json-import](https://lintradar.dev/rules/unicorn/prefer-json-import.md): Prefer JSON imports over reading and parsing JSON files.
- [unicorn/prefer-error-is-error](https://lintradar.dev/rules/unicorn/prefer-error-is-error.md): Prefer `Error.isError()` when checking for errors.
- [unicorn/prefer-dispose](https://lintradar.dev/rules/unicorn/prefer-dispose.md): Prefer using `using`/`await using` over manual `try`/`finally` resource disposal.
- [unicorn/no-unused-properties](https://lintradar.dev/rules/unicorn/no-unused-properties.md): Disallow unused object properties.
- [unicorn/prefer-regexp-escape](https://lintradar.dev/rules/unicorn/prefer-regexp-escape.md): Prefer `RegExp.escape()` for escaping strings to use in regular expressions.
- [unicorn/prefer-short-arrow-method](https://lintradar.dev/rules/unicorn/prefer-short-arrow-method.md): Prefer arrow function properties over methods with a single return.

---

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