`prefer-destructuring` flags a property assignment
See original GitHub issue_Edit: read this comment instead https://github.com/eslint/eslint/issues/11584#issuecomment-479892994_
Tell us about your environment
- ESLint Version: 5.16
- Node Version: any, happens on repl
- npm Version: any, happens on repl
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
Configuration
{
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "script",
"ecmaFeatures": {}
},
"rules": {
"prefer-destructuring": 2
},
"env": {}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
const arr = ['value'];
exports.value = arr[0];
What did you expect to happen?
No prefer-destructuring
error should appear
What actually happened? Please include the actual, raw output from ESLint.
Use array destructuring
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
prefer-destructuring - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >What to do when ESLint rule "prefer-destructuring" makes ...
Here is a link to an Issue about that topic prefer-destructuring flags a property assignment #11584 · Share. Share a link to this...
Read more >Destructuring assignment - JavaScript - MDN Web Docs
The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, ...
Read more >JavaScript object destructuring usages you must know
The mechanism is called Destructuring (also known as destructuring assignment). It is more of a new syntax added to the language than a...
Read more >Destructuring Assignment In JavaScript
The destructuring assignment is a unique syntax that helps “to unpack” objects or arrays into a group of variables. Destructuring can also operate ......
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
@bfred-it Thanks for your response. I would say in this case, there is no bug in the rule.
Please feel free to open an enhancement request if you think the rule could be improved.
Closing as ESLint is working as intended here.
Reopening as this is, at very least, not a duplicate.
I did look on MDN and see nothing about destructured assignment into an object property. I don’t know enough about ES2015 to say if this is definitely a bug, but I can’t rule it out at this point.