Commits
Click on a commit to change the comparison rangefeat(linter): overhaul unicorn/no-useless-spread (#4791)
I got tired of seeing useless spreads on ternaries and `arr.reduce()` within my company's internal codebase so I overhauled this rule.
## Changes
- add fixer for object spreads
```js
const before = { a, ...{ b, c }, d }
const after = { a, b, c, d } // fixer does not dedupe spaces before `b`
```
- recursively check for useless clones on complex expressions. This rule now catches and auto-fixes the following cases:
```js
// ternaries when both branches create a new array or object
const obj = { ...(foo ? { a: 1 } : { b: 2 }) }
// recursive, so this can support complex cases
const arr = [ ...(foo ? a.map(fn) : bar ? Array.from(iter) : await Promise.all(bar)) ]
// reduce functions where the initial accumulator creates a new object or array
const obj = { ...(arr.reduce(fn, {}) }
```