prefer-spread-for-shallow-copy-and-expansion
Rewrite conservative shallow-expansion patterns to spread syntax in modern JavaScript and TypeScript code.
What It Rewrites
Array.from(iterable)to[...iterable]whenArrayresolves to the global built-in, nomapFn/thisArgis passed, and the argument is statically known to be iterablestr.split('')to[...str]when the receiver is an ASCII-only literal string by default, or when--param aggressive=trueis used
Preserved Cases
Array.from(items, mapFn)andArray.from(items, mapFn, thisArg)- Shadowed
Array.from(...) Array.from(...)on array-like but non-iterable valuesslice(...)andtoSpliced(...)calls, including zero-argument forms- Optional-chaining calls such as
obj?.slice()andstr?.split('') split('')on non-literal, non-ASCII, or escaped string values by default- Mixed/scalar
concat(...)calls such asarr.concat(1) concat(...)calls that use spread arguments, because they are not a faithful one-step spread-literal rewriteconcat(...)calls, including dense literal cases, becauseconcat/slicefamily behavior can depend on sparse arrays,Symbol.isConcatSpreadable, andArray[Symbol.species]
Target Files
The workflow scans:
**/*.{js,jsx,mjs,cjs,ts,tsx}
The workflow skips:
**/*.d.ts**/dist/****/vendor/****/node_modules/****/*.min.js
Usage
bash
Enable more permissive split('') rewrites:
bash
Development
bash
License
MIT