Rule proposal: `no-reduce-spread`
See original GitHub issueUsing spread inside a reduce call can turn a O(n) algorithm into O(n**2). See https://www.richsnapp.com/article/2019/06-09-reduce-spread-anti-pattern
Fail
const result = items.reduce((acc, item) => ({
...acc,
[item.name]: item.value,
}, {});
Pass
const result = items.reduce((acc, item) => {
acc[item.name] = item.value;
return acc;
}, {})
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (4 by maintainers)
Top Results From Across the Web
SEC Proposed Rules
SEC Proposed Rules · Regulation NMS: Minimum Pricing Increments, Access Fees, and Transparency of Better Priced Orders · File No: S7-30-22 · Comments...
Read more >Rule proposal: `no-reduce-spread` #1335 - Issuehunt
Do you want to disallow spread usage in just reduce or are there other array iterator functions (ie. map , filter , etc.)...
Read more >Reopening of Comment Periods for “Private Fund Advisers
Finally, the proposed rules would amend the Advisers Act compliance rule, which would affect all registered investment advisers, to better ...
Read more >Federal Register/Vol. 87, No. 46/Wednesday, March 9, 2022 ...
ACTION: Proposed rule. SUMMARY: The Securities and Exchange. Commission is proposing new rules under the Investment Advisers Act of.
Read more >The Most Curious Rule Proposal in Securities and Exchange ...
I write this post in response to the release (the “Proposing Release”) regarding proposed rules (the “Proposed Rules”) under the Investment ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Isn’t this already covered by
no-reduce
? Both examples are IMHO pretty bad compared to a plain loop:Would that rule be smart enough to recognize when the item would need to be mapped? This failure example wouldn’t translate directly without mapping the object to an array first