Rule-change (`no-return-assign`) - allow assignment in side effect position of comma operator
See original GitHub issueUpdate: @platinumazure suggested I filled out the change-rule template:
What rule do you want to change?
no-return-assign
Does this change cause the rule to produce more or fewer warnings? Fewer
How will the change be implemented? (New option, new default behavior, etc.)?
Change current default behavior (except-parens
)
Please provide some example code that this change will affect:
1. return (x = y, x)
2. return ((x = y), x)
3. return (x = y)
4. return x = y
5. return (x, x = y)
6. return (x, (x = y))
What does the rule currently do for this code?
- Reports error
- Does not report error
- Does not report error
- Reports error
- Reports error
- Does not report error
What will the rule do after it’s changed?
Only 1. will change, 1. will no longer report an error because the assignment is in a position of a sequence (comma operator) that is designed for side effects (see MDN example).
Original issue: no-return-assign
- false positive in combination with comma operator
The assignment in the code below is not in ‘return’ position:
[].map(result => (result['x'] = 'y', result))
What did you expect to happen?
To have no lint error.
What actually happened? Please include the actual, raw output from ESLint.
It said: Arrow function should not return assignment. (no-return-assign)
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (6 by maintainers)
Top GitHub Comments
I’m mildly opposed to changing the rule for this case, but I’m not going to stand in the way if others on the team believe this is a worthwhile change.
Would you mind editing your original post to reflect this rule change proposal template? And in exchange, I’ll relabel this issue as a rule change proposal. Thanks!
@platinumazure I don’t think there is a need to apologize. It might have been my prejudice (coming from other interactions about software) that mistakenly took the “However, this is still a case of an assignment in a return statement (the return statement is implicit due to being a concise arrow body)” as closing the door on the subject.