oxc/crates/oxc_span
DonIsaac b3c3125138 feat(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, {}) }
  ```
2024-08-10 04:50:09 +00:00
..
src feat(linter): overhaul unicorn/no-useless-spread (#4791) 2024-08-10 04:50:09 +00:00
Cargo.toml Release crates v0.24.0 (#4749) 2024-08-08 14:00:57 +08:00
CHANGELOG.md Release crates v0.24.0 (#4749) 2024-08-08 14:00:57 +08:00