Skip to content

one-const is incompatible with destructure rule #1649

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

Closed
greggman opened this issue Dec 4, 2017 · 2 comments
Closed

one-const is incompatible with destructure rule #1649

greggman opened this issue Dec 4, 2017 · 2 comments

Comments

@greggman
Copy link

greggman commented Dec 4, 2017

The one const rule 13.2 says

Use one const or let declaration per variable

  // bad
  // (compare to above, and try to spot the mistake)
  const items = getItems(),
      goSportsTeam = true,
      dragonball = 'z';
  
  // good
  const items = getItems();
  const goSportsTeam = true;
  const dragonball = 'z';

But the destructure rule requires declaring multiple variables per const

  // good
  function getFullName(user) {
    const { firstName, lastName } = user;

Seems inconsistent?!??

@ljharb
Copy link
Collaborator

ljharb commented Dec 4, 2017

Fair point; the wording could be better. "Use one const or let declaration per variable or assignment" seems like it would cover destructuring?

@parulgupta26
Copy link
Contributor

@ljharb - I've raised PR for this - #1927

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

3 participants