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

Make consistent-destructuring configurable #2469

Open
geoffswift opened this issue Oct 5, 2024 · 0 comments
Open

Make consistent-destructuring configurable #2469

geoffswift opened this issue Oct 5, 2024 · 0 comments

Comments

@geoffswift
Copy link

unicorn/consistent-destructuring seems to trigger in multiple scenarios. We would ideally be able to control which specific cases are active.

For example this seems to always be good

function example(o) {
  const { a } = o;
  console.log(a);
  // Please do complain that I've already got a const for a 👍 
  console.log(o.a); 
}

This scenario in particular I don't like, and would want to turn off:

class Example {
  example() {
    const { a } = this; // rule wants me to write const { a, expensive } = this
    if (a) {
        // this.expensive is not being consistently destructured
        // but i don't want to call the expensive getter unnecessarily in the const above
        console.log(this.expensive); 
    }
  }
    
  get expensive() {
    // Something that requires significant compute
  }
}
@geoffswift geoffswift added the bug label Oct 5, 2024
@fregante fregante changed the title Make unicorn/consistent-destructuring configurable Make consistent-destructuring configurable Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants