Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upRule discussion: Arrow function should not return assignment #1204
Comments
This comment has been minimized.
This comment has been minimized.
|
I actually think is a quite good rule to have since it's quite uncommon to want to return an assignment value. This is currently enforced regardless of wether it is an arrow function or not btw, so In your code it seems like there is no need to modify sets.reduce((acc, set) => acc + set.size, 0) |
This comment has been minimized.
This comment has been minimized.
|
@LinusU For some reason I had to mutate the accumulator, thanks for the tip Also, looks like the |
This comment has been minimized.
This comment has been minimized.
|
No stress |
tom-sherman commentedSep 24, 2018
•
edited
What version of standard?
v12.0.1
What operating system, Node.js, and npm version?
Node.js
What did you expect to happen?
When trying to sum the sizes of an array of Sets I tried to write
What actually happened?
Standard shows the error
I don't think this rule is helpful in this scenario, I can't use Array.reduce at all in this scenario AFAIK. I understand why you don't want to allow the following code, but this Array.reduce use case seems more legitimate
If the above is is intentional, please can someone explain what code smell I'm creating here?
If not, I'd like to suggest changing the rule to
except-parens[1] option provided by Eslint or remove it completely.The
except-parensoption would allow for the following style which I like because it clearly signals the author's intent to return an assignment.