Incorrect no-return-assign report
See original GitHub issueTell 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
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
},
env: {
browser: true
},
extends: [
'standard',
// Uncomment any of the lines below to choose desired strictness,
// but leave only one uncommented!
// See https://eslint.vuejs.org/rules/#available-rules
'plugin:vue/essential' // Priority A: Essential (Error Prevention)
// 'plugin:vue/strongly-recommended' // Priority B: Strongly Recommended (Improving Readability)
// 'plugin:vue/recommended' // Priority C: Recommended (Minimizing Arbitrary Choices and Cognitive Overhead)
],
// required to lint *.vue files
plugins: [
'vue'
],
globals: {
'ga': true, // Google Analytics
'cordova': true,
'__statics': true,
'process': true,
'Capacitor': true,
'chrome': true
},
// add your custom rules here
rules: {
// allow async-await
'generator-star-spacing': 'off',
// allow paren-less arrow functions
'arrow-parens': 'off',
'one-var': 'off',
'import/first': 'off',
'import/named': 'error',
'import/namespace': 'error',
'import/default': 'error',
'import/export': 'error',
'import/extensions': 'off',
'import/no-unresolved': 'off',
'import/no-extraneous-dependencies': 'off',
'prefer-promise-reject-errors': 'off',
// allow debugger during development only
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-sequences': 'off',
}
}
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.
row.reduce((object, value, index) => (object[rs.columns[index]] = value, object), {})
Not sure. ESlint was invoked by quasar/cli
quasar dev
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
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Just to add, correct code without linting errors would be:
This rule by default allows parenthesized assignments (parentheses should be directly around the assignment expression).
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.