-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Update: check renaming identifier in object destructuring (fixes 12827) #12881
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yeonjuan sorry for the confusion, I didn't mean to suggest to fix these 3 issues now.
Since you already fixed that, I think that 2 of those 3 changes are certainly correct at this moment.
var {x} = foo;
might need a discussion as it could be undesirable for some users.
I left comments on tests cases for these 3 changes.
Checked examples from the docs:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@@ -89,8 +91,7 @@ class x { } | |||
class Foo { x() {} } | |||
function foo(...x) { } | |||
var { x } = {}; | |||
var { x: a} = {}; | |||
var { a: [x]} = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a regression in this PR? I see that this is going to be worked on in a separate PR. Do we have an issue outlining our plan for this (just in case someone else needs to pick this work up)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a regression in this PR?
Yes. The case will not be warned after this PR merged because the actual version warns about a
rather than x
.
/*eslint id-length: ["error", { "min": 4 }]*/
/*eslint-env es6*/
var { a: [x]} = {}; // Error: Identifier name `a` ...
And there is a PR working on to fix it (#12839).
Do we have an issue outlining our plan for this (just in case someone else needs to pick this work up)?
I will add an outlining plan for this on #12832. Thanks 👍
Thanks for working on this! |
Thanks for contributing! |
…7) (eslint#12881) * Update: check renaming identifier in object destructuring (fixes 12827) * Fix wrong error type * ignore properties options on object pattern, ignore computed prop * modify docs, add test cases * add test cases * remove wrong test cases * change to ignore destructuring on properties never * update documentation * fix typo * fix documentation * include error loc, data info
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[x] Documentation update
[x] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Changed this rule to warn the length of the renaming identifier rather than a renamed identifier.
Is there anything you'd like reviewers to focus on?
Fixes #12827