Skip to content

unicorn/prefer-spread Style

🛠️ An auto-fix is available for this rule for some violations.

What it does

Enforces the use of the spread operator (...) over outdated patterns.

Why is this bad?

Using the spread operator is more concise and readable.

Examples

Examples of incorrect code for this rule:

javascript
const foo = Array.from(set);
const foo = Array.from(new Set([1, 2]));

Examples of correct code for this rule:

javascript
[...set].map(() => {});
Array.from(...argumentsArray);

References

Released under the MIT License.