-
Notifications
You must be signed in to change notification settings - Fork 0
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
Object destructuring on variable reassignment #6
Comments
Hi @hiimjako, I think this change it's ok. For sure, it is better the assignment. |
I think that linter is suggesting the following: const { foo } = await apiCall(); You don't need the |
Yes, sure this could be done. In this case where you want to set in a variable, you should have another variable name instead. |
It is not either possible, for this reasons:
({ foo } = await apiCall()) But if you have a previous statement, you have to use a semicolumn; As said by @davidebianchi you should have another variable name to do that, but to me, it appears a workaround changing variables names to satisfy linter. |
Hi, I have encountered unreadable behavior, in my opinion, when reassigning a variable from an object that contains a key with the same name as the variable, for example:
This behavior is managed by
prefer-destructuring
ESLint rule. The way it is currently set up, it forces you to adjust the code like this:I was wondering if it wouldn't be more readable to adjust the rule to allow the reassignment as shown in the first example.
It could be modified by updating the rule like this:
This would not be a breaking change, because both syntaxes will work without throwing ESLint errors.
The text was updated successfully, but these errors were encountered: