Skip to content
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

Fix: prefer-destructuring error with computed properties (fixes #9784) #9817

Merged
merged 1 commit into from Jan 10, 2018

Conversation

not-an-aardvark
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[x] Bug fix (#9784)

What changes did you make? (Give an overview)

This fixes the prefer-destructuring bug described in #9784.

Is there anything you'd like reviewers to focus on?

Nothing in particular

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules labels Jan 7, 2018
@platinumazure
Copy link
Member

Not sure I understand the issue.

One could destructure like ({ [foo] } = bar), right? Or would that assign not to foo but to whatever foo holds? Or will that do an array destructure or something weird?

I'm just trying to figure out if there's ever a use case for allowing prefer-destructuring to enforce for computed properties, that's all.

@not-an-aardvark
Copy link
Member Author

I don't think ({ [foo] } = bar) is valid syntax. It would be possible to use ({ [foo]: foo } = bar) here, but I think the rule should only enforce that when the enforceForRenamedProperties option is used. I think the goal of the enforceForRenamedProperties: false behavior is to enforce destructuring when it would be possible to use object shorthand (e.g. ({ foo } = bar) rather than ({ foo: foo } = bar)), which is never possible when using computed properties.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants