Repository navigation
feat(linter): no accumulating spread - #1607
Conversation
CodSpeed Performance ReportMerging #1607 will not alter performanceComparing Summary
|
|
Love this! Let me test this on our internal repos before landing, if all goes well I may mark this as correctness (or perhaps introduce a new |
|
My vote is a new performance category; I'm planning on migrating eslint-plugin-react-perf too |
any updates? Can I merge this? |
|
I've been afk, will get to this soon. |
|
Testing in the vscode repo: False positives: |
|
@camc314 Do you have the time to clean up this rule (also sync its name and tests with Biome)? https://biomejs.dev/linter/rules/no-accumulating-spread |
yes, will try to do today. i've fixed the naming ect, will work on the falst positive - i think if we cross a function boundary, we can just break out of that loop where we check for |
Boshen
left a comment
There was a problem hiding this comment.
Last changes:
Bring in the valid and invalid cases from Biome:
Creates a new nursery-level rule,
no-reduce-spread, that prevents spreading accumulator objects/arrays inArray.prototype.reduce.The Tl;Dr of why this should be avoided is because it drastically increases time/memory complexity in reductions. In general, it turns potentially
O(1)/O(n)memory operations intoO(n)/O(n^2), andO(n)time intoO(n^2). For more details, refer to this helpful blog post.Note that this rule doesn't exist in ESLint's default rule set or any other ESLint plugin, although it looks like there's been some interest in it in the past. Since there is no reference implementation to compare against, and thus this could potentially have bugs, I've decided to make this a nursery-level rule until we're sure it's stable and useful.
Edit: