prefer-spread
What it does
Section titled “What it does”Reports f.apply(undefined, args), f.apply(null, args), o.m.apply(o, args) and o['m'].apply(o, args), where the first argument is null, undefined, or the same object that the method is read from. f.apply(this, args), o.m.apply(p, args) with another object, and an array literal or a spread (...args) as the arguments are not reported.
Why it matters
Section titled “Why it matters”When the call keeps the same this, apply only spreads an array into arguments, which the spread syntax says directly: f(...args) and o.m(...args). The apply form needs the reader to know the first argument is ignored.
To fix, write the call with ...args.
Example
Section titled “Example”...function f() {...}f.apply(undefined, b);f.apply(null, [1]);o[m].apply(o, b);function g() { let d;...Configuration
Section titled “Configuration”js: lint: rules: prefer-spread: warn # off (default), warn, errorEnabled by the presets: js/typescript-eslint-recommended.
Suppress one line with sudsy-disable-next-line prefer-spread in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint | prefer-spread |
full |