Linter wants previously declared variable destructured during assignment
See original GitHub issueTell us about your environment Windows 10
- ESLint Version: v4.12.0
- Node Version: v8.9.1
- npm Version: 5.5.
What parser (default, Babel-ESLint, etc.) are you using? eslint
Please show your full configuration:
Configuration
{
"env": {
"es6": true,
"node": true,
"browser": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 8
},
"rules": {
"prefer-destructuring": ["error", {
"VariableDeclarator": {
"array": true,
"object": true
},
"AssignmentExpression": {
"array": true,
"object": true
}
}, {
"enforceForRenamedProperties": false
}]
}
}
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
function potato(b) {
let a;
if(b) {
a = b.a;
}
doThing(a); //Where a being undefined or not affects the downstream.
}
eslint .
What did you expect to happen? No error or warning.
What actually happened? Please include the actual, raw output from ESLint.
..path...\test.js
5:5 error Use object destructuring prefer-destructuring
✖ 1 problem (1 error, 0 warnings)
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Prefer destructuring - already exisiting variable - Stack Overflow
Is there any ways to use destructuration when the variable already exists? Using let again : const data = { status: 'example', }; ......
Read more >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 >Destructuring assignment - JavaScript - MDN Web Docs
Each destructured property is assigned to a target of assignment — which may either be declared beforehand with var or let , or...
Read more >Many ways to use Destructuring in Modern JavaScript - Medium
It's main purpose is to improve your code and simplify it at the ... Before Destructuring if we wanted to create a variable...
Read more >CoffeeScript
In that case, we want to convert modern JavaScript into older JavaScript that will ... Since CoffeeScript takes care of all variable declaration,...
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
Unfortunately, since that’s a parsing error, the lint rules can’t even run at that point. I’m not aware of a good way to catch that and report a user-friendly message explaining the need for parentheses… Sorry.
On Nov 28, 2017 10:08 AM, “Krishna Glick” notifications@github.com wrote:
Ah, that fixed it. Is there a linting rule to yell about that, or more a
don't be dumb
kinda thing? 😃