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

id-length does not check identifier in array pattern #12832

Closed
yeonjuan opened this issue Jan 27, 2020 · 2 comments · Fixed by #12839
Closed

id-length does not check identifier in array pattern #12832

yeonjuan opened this issue Jan 27, 2020 · 2 comments · Fixed by #12839
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

Comments

@yeonjuan
Copy link
Member

Tell us about your environment

  • ESLint Version: 6.8.0
  • Node Version: 12.13.0
  • npm Version: 6.12.0

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

Online demo

/*eslint id-length: "error"*/     // default is minimum 2-chars ({ "min": 2 })
/*eslint-env es6*/
const [a] = foo;

What did you expect to happen?

Warn about short named identifier a;

What actually happened? Please include the actual, raw output from ESLint.

No error.

Are you willing to submit a pull request to fix this bug?

Yes. I already finished the implementation.(locally)

But, I have a question before pull request.

Examples of correct code for this rule with the default options:
...
var { prop: [x] } = {};
...

By the docs in id-length, there is an example in the correct example section showing the array pattern with the short identifier x.
In my understanding, the x is an identifier created by array destructuring so it should be checked by this rule.

Am I missing something? Is it intended behavior?

@yeonjuan yeonjuan added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Jan 27, 2020
@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jan 27, 2020
@kaicataldo
Copy link
Member

kaicataldo commented Jan 27, 2020

Thanks for reporting this! Agreed that this is a bug. The rule already warns for this alternative equivalent:

const a = foo[0];

See demo here.

@yeonjuan yeonjuan changed the title id-length does not check identifier in array destructuring. id-length does not check identifier in array pattern Jan 28, 2020
@yeonjuan
Copy link
Member Author

To note

After #12881 merged, there are false negative examples in the id-length.md:

At Examples of correct code...

/*eslint id-length: "error"*/     // default is minimum 2-chars ({ "min": 2 })
/*eslint-env es6*/
// ...
var { prop: [x] } = {}; // false negative, It should be placed in an incorrect example
// ...

This will be fixed in #12839.

kaicataldo pushed a commit that referenced this issue Feb 28, 2020
…#12839)

* Update: check identifier in array pattern in id-length (fixes #12832)

* fix wrong test case

* Update documentation
montmanu pushed a commit to montmanu/eslint that referenced this issue Mar 4, 2020
…12832) (eslint#12839)

* Update: check identifier in array pattern in id-length (fixes eslint#12832)

* fix wrong test case

* Update documentation
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Aug 28, 2020
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Aug 28, 2020
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 a pull request may close this issue.

2 participants