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

Update: report rename id destructuring in id-blacklist (fixes #12807) #12923

Merged
merged 5 commits into from Feb 19, 2020

Conversation

yeonjuan
Copy link
Member

Prerequisites checklist

  • I have read the contributing guidelines.
  • The team has reached consensus on the changes proposed in this pull request. If not, I understand that the evaluation process will begin with this pull request and won't be merged until the team has reached consensus.

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] 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)

This PR will fix #12807

Is there anything you'd like reviewers to focus on?

It will make a new warning on the below cases. ( about blacklist foo)

  1. renaming identifier in an ObjectPattern destructuring.
/*eslint id-blacklist: ["error", "foo"] */

const { bar : foo} = asd;
  1. the last identifier in an ObjectPattern destructuring.
/*eslint id-blacklist: ["error", "foo"] */

const { bar : obj.a.a.a.foo} = asd;

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Feb 16, 2020
@mdjermanovic mdjermanovic added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly regression Something broke rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Feb 16, 2020
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. renaming identifier in an ObjectPattern destructuring.

This restores correct behavior from v6.8.0.

  1. the last identifier in an ObjectPattern destructuring.

These are new warnings.

Maybe we could in another PR add new warnings similar to 2., but when the parent is AssignmentPattern, ArrayPattern or RestElement

lib/rules/id-blacklist.js Outdated Show resolved Hide resolved
lib/rules/id-blacklist.js Outdated Show resolved Hide resolved
@yeonjuan
Copy link
Member Author

yeonjuan commented Feb 17, 2020

@mdjermanovic
Thanks for the review 👍

Maybe we could in another PR add new warnings similar to 2., but when the parent is AssignmentPattern, ArrayPattern or RestElement

I understand that this rule should check when the parent is ArrayPattern or RestElement, so changed it.

But I'm curious why we should check AssignmentPattern in those cases(2.).

foo.data; // all property names that are not assignments are ignored

By the docs at examples of incorrect, it seems this rule should not warn in the below cases(AssignmentPattern).

function foo( baz = obj.bar ) {}; // Should we allow `bar` because it is not assignments? 

Am I missing something?

@mdjermanovic
Copy link
Member

mdjermanovic commented Feb 17, 2020

I was thinking to cover the remaining cases where obj.bar can be a target in destructuring. In AssignmentPattern it would be when it's left:

({ a: obj.bar = b } = c);
[obj.bar = b] = c;

@kaicataldo
Copy link
Member

That seems worthwhile - mind making an issue so we can track it?

@yeonjuan
Copy link
Member Author

@mdjermanovic

({ a: obj.bar = b } = c);
[obj.bar = b] = c;

wow, actually, I've never seen this syntax before. TIL. Thanks :)

@kaicataldo
I don't mind whether resolving it here or making another issue. :)

Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Copy link
Member

@kaicataldo kaicataldo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@kaicataldo kaicataldo merged commit 7747177 into master Feb 19, 2020
@kaicataldo kaicataldo deleted the issue12807 branch February 19, 2020 20:54
montmanu pushed a commit to montmanu/eslint that referenced this pull request Mar 4, 2020
…12807) (eslint#12923)

* Update: report rename id destructuring in id-blacklist (fixes eslint#12807)

* check RestElement, ArrayPattern, computed

* check assignment pattern, computed property

* add option

* remove dupe condition
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Aug 19, 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 19, 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 regression Something broke rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

id-blacklist doesn't warn when renaming properties to blacklisted identifiers in destructuring assignment.
4 participants