`no-array-reduce` should not apply where it's not easily replaceable (objects, JSX)
See original GitHub issueApplying the rule on this code would mean either adding an IIFE with a for-of loop inside or splitting the object declaration from the application (which requires assertions or dead code in TypeScript)
I think this would be a similar exception to #1348 (of which this issue might be a slight duplicate)
return {
huge: 'object',
with: 'many',
keys: array.reduce(etc)
};
<Display>
<Title>{title}</Title>
<Modal>
<List>{array.reduce(reducer)}</List>
</Modal>
</Display>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Updating React state when state is an array of objects
What I'm having trouble with is then updating the array and then subsequently updating state without mutation. //make sure we're not mutating state...
Read more >JSX In Depth - React
React thinks <hello /> is an HTML tag because it's not capitalized: ... This is a component and should be capitalized:function Hello(props) {...
Read more >Immutability in React: Should you mutate objects?
String values are immutable, but string objects are not. If an object is immutable, you cannot change its state or the value of...
Read more >Render a String with Non-breaking Spaces in React | Pluralsight
React has successfully done so with its easy-to-understand component ... You can write JavaScript in a React component to do almost anything ...
Read more >Do React Hooks Replace Redux?. TL;DR - Medium
Since the React hooks API was introduced, a lot of questions have risen about whether or not React hooks will replace Redux.
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
This is a remarkably stupid rule. Instead of simply teaching programmers to use
reduce
well, just ban it entirely. Really?If you can replace it with
map
, then you are using it wrongly. If you can replace it withfilter
, then you are using it wrongly. And there is no reason to believe that those who usefor-of
instead will write any more intelligible code.This rule is patronizing and rude. These rules should help discern good usage from poor usage, not tell me what I can or cannot use.
I don’t really understand why the argument, I disabled
no-array-reduce
myself. I also disabled some rules wrote by myself, I wrote them not because it’s right, it’s because someone need it.