# prefer-spread

Rule `unicorn/prefer-spread`. Prefer the spread operator over `Array.from(…)`, `Array#concat(…)`, `Array#{slice,toSpliced}()`, and trivial `for…of` copies.

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/prefer-spread` | no | safe | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/prefer-spread.md) |
| Oxlint | `unicorn/prefer-spread` | no | safe | plugin `unicorn`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/prefer-spread.html) |

## Code examples

### Incorrect: the rule reports this

```js
Array.from(set).map(element => foo(element));
```

```js
const array = array1.concat(array2);
```

```js
const copy = array.slice();
```

### Correct: the rule accepts this

```js
[...set].map(element => foo(element));
```

```js
const array = [...array1, ...array2];
```

```js
const copy = [...array];
```

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

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/prefer-spread": "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% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [eslint/prefer-spread](https://lintradar.dev/rules/eslint/prefer-spread.md): Require spread operators instead of `.apply()`
- [unicorn/prefer-export-from](https://lintradar.dev/rules/unicorn/prefer-export-from.md): Prefer `export…from` when re-exporting.
- [unicorn/switch-case-braces](https://lintradar.dev/rules/unicorn/switch-case-braces.md): Enforce consistent brace style for `case` clauses.
- [unicorn/no-confusing-array-with](https://lintradar.dev/rules/unicorn/no-confusing-array-with.md): Disallow confusing uses of `Array#with()`.
- [unicorn/switch-case-break-position](https://lintradar.dev/rules/unicorn/switch-case-break-position.md): Enforce consistent `break`/`return`/`continue`/`throw` position in `case` clauses.
- [unicorn/no-await-expression-member](https://lintradar.dev/rules/unicorn/no-await-expression-member.md): Disallow member access from await expression.

---

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