javascript-no-useless-spread-unicorn-aligned
Removes semantically redundant spread syntax in JavaScript and TypeScript source, aligned with eslint-plugin-unicorn/no-useless-spread, while staying conservative about runtime behavior.
What It Rewrites
- Array literals that spread a literal array with no holes, such as
const x = [1, ...[2, 3]]toconst x = [1, 2, 3] - Function and constructor calls that spread a literal array with no holes, such as
fn(...[a, b])tofn(a, b)andnew C(...[a, b])tonew C(a, b) - Object literals that spread a plain object literal with only static data properties and no key conflicts, such as
{x: 0, ...{a: 1}, y: 2}to{x: 0, a: 1, y: 2}
Preserve Cases
- Sparse arrays such as
[...[ ,1]]and[...[, ,]] - Non-literal or unknown spread operands such as
[...arr],fn(...args), andnew C(...factory()) - Object spreads with getters, setters, methods, computed keys,
__proto__, or duplicate-key conflicts - Objects with sibling spread properties that are not statically provable as safe to inline
Target Files
**/*.{js,mjs,cjs}via the JavaScript parser**/*.tsvia the TypeScript parser**/*.{jsx,tsx}via the TSX parser
Default exclusions: **/node_modules/**, **/dist/**, **/build/**, **/coverage/**, **/vendor/**, **/*.test.*, **/*.spec.*, **/test/**, **/tests/**, **/__tests__/**, **/__mocks__/**, **/*.config.*, and **/*.example.*
Usage
bash
Development
bash
License
MIT