New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect no-return-assign report #13135
Comments
Oof. why isn't this |
Hi @brianwhu, thanks for the bug report! I can confirm this is the intended behavior of this rule (introduced in #6041, issue #5913). On the other hand, we really don't have any incorrect examples with a nested assignment, and there are also no examples with arrow functions, so I'm marking this as an accepted issue to improve the documentation for this rule. |
As for the provided example, you can wrap /*eslint no-return-assign: error*/
row.reduce((object, value, index) => ((object[rs.columns[index]] = value), object), {}) |
Hi @mdjermanovic, thanks for the suggestion. But this make the case even more puzzling. Now ESlint would accept
But not
? |
this is because, as per the rule ,
in this, the parenthesis is around assignment expression. so it's ok
in this, parenthesis is around returned expression not around assignment expression, so its an error |
Just to add, correct code without linting errors would be: /*eslint no-return-assign: "error"*/
() => ((a = b), c) This rule by default allows parenthesized assignments (parentheses should be directly around the assignment expression). |
Tell us about your environment
Windows 10
Node version: v10.16.0
npm version: v6.9.0
Local ESLint version: v6.8.0
Global ESLint version: Not found
What parser (default, Babel-ESLint, etc.) are you using?
babel-eslint
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
I have an arrow function that returns a comma expression (i.e. sequence). After I changed the rule to allow comma operator, eslint reported "no-return-assign" error while in fact it is the comma expression that is being returned.
Not sure. ESlint was invoked by quasar/cli
What did you expect to happen?
The code is NOT returning an assignment, but a comma expression where the second operand is a single object. This should be accepted by ESlint
What actually happened? Please include the actual, raw output from ESLint.
ESlint reported no-return-assign error:
error Arrow function should not return assignment no-return-assign
Are you willing to submit a pull request to fix this bug?
No
The text was updated successfully, but these errors were encountered: