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

False positive for consistent-destructuring #2268

Closed
crystalfp opened this issue Feb 4, 2024 · 1 comment
Closed

False positive for consistent-destructuring #2268

crystalfp opened this issue Feb 4, 2024 · 1 comment

Comments

@crystalfp
Copy link

In the code below, the rule suggest to use destructuring but does not suggest a way to fix the problem. In my opinion this is a perfectly valid destructuring and a possible change makes the code unclear. The code is:

const structure = {
    atoms: [{position: [1,2,3]}]
};
const {position} = structure.atoms[0];

The rule complains to the last line. One way to satisfy the rule is to change the last line into:

const {atoms} = structure;
const {position} = atoms[0];

That is much less clear that the first code.

consistent-destructuring

The example is above in the first section.

const code = 'that should be ok';

const structure = {
    atoms: [{position: [1,2,3]}]
};
const {position} = structure.atoms[0];
@fregante
Copy link
Collaborator

That's not a false positive, it works as intended.

However we agree that the rule is not always ideal so it was recently removed from the "recommended" config:

@fregante fregante closed this as not planned Won't fix, can't repro, duplicate, stale Feb 10, 2024
@fregante fregante marked this as a duplicate of #1501 Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants