forked from oxc-project/oxc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linter): add
oxc/no-map-spread
(oxc-project#6751)
Adds a new performance rule that disallows using object and array spreads in `map` and `flatMap` to modify/merge arrays and objects. I've currently added it to `nursery` so we can battle-harden it before making it generally available as a `perf` rule. ```ts // needless O(n) spread on `x`, making this an O(n^2) operation const x = arr.map(x => { return { ...x, foo: getFoo(x.id) } }) // Object.assign is better here const x = arr.map(x => { return Object.assign(x, { foo: getFoo(x.id) }) }) ```
- Loading branch information
Showing
5 changed files
with
1,207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.