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: add props option to no-self-assign rule (fixes #6718) #6721

Merged
merged 3 commits into from Aug 4, 2016

Conversation

mysticatea
Copy link
Member

Fixes #6718.

This PR fixes no-self-assign rule to warn properties.

Also, there is a few refactoring (those commits are separated.). I added a function to get the property name of a MemberExpression node (e.g. a.b and a["b"]) into ast-utils.js because this logic is used in multiple places.

@mention-bot
Copy link

@mysticatea, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vitorbal, @lo1tuma and @gyandeeps to be potential reviewers

@eslintbot
Copy link

Thanks for the pull request, @mysticatea! I took a look to make sure it's ready for merging and found some changes are needed:

  • Pull requests with code require an issue to be mentioned at the end of the commit summary, such as (fixes #1234). Please update the commit summary with an issue (file a new issue if one doesn't already exist).

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@mysticatea
Copy link
Member Author

Granted, the 1st commit of this PR does not have (fixes #6718), but 2nd commit has it.

"a.b = c.b",
"a.b = a[b]",
"a[b] = a.b",
"a.b().c = a.b().c",
Copy link
Member

Choose a reason for hiding this comment

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

Nice test case. I'm wondering, should a().b.c = a().b.c constitute a self-assignment or not? (b.c is at least a constant member expression, but a() could return a different object on each invocation, so probably not?)

Copy link
Member Author

Choose a reason for hiding this comment

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

If an expression includes call expression(s), this rule ignores the expression.
I added a test to make sure.

@eslintbot
Copy link

Thanks for the pull request, @mysticatea! I took a look to make sure it's ready for merging and found some changes are needed:

  • Pull requests with code require an issue to be mentioned at the end of the commit summary, such as (fixes #1234). Please update the commit summary with an issue (file a new issue if one doesn't already exist).

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@mysticatea mysticatea changed the title Fix: no-self-assign warns for properties (fixes #6718) Update: add props option to no-self-assign rule (fixes #6718) Jul 23, 2016
@mysticatea
Copy link
Member Author

I update this PR by the result of discussion.

This PR adds props option, which checks self-assignments of properties also, to no-self-assign.
This option is off by default.

@gyandeeps
Copy link
Member

LGTM, waiting for others to review.

@nzakas
Copy link
Member

nzakas commented Jul 29, 2016

@mysticatea can you rebase?

@eslintbot
Copy link

Thanks for the pull request, @mysticatea! I took a look to make sure it's ready for merging and found some changes are needed:

  • Pull requests with code require an issue to be mentioned at the end of the commit summary, such as (fixes #1234). Please update the commit summary with an issue (file a new issue if one doesn't already exist).

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@mysticatea
Copy link
Member Author

Done!

(The 2nd commit has (fixes #6718))

@platinumazure
Copy link
Member

LGTM, thanks for the contribution @mysticatea!

@nzakas
Copy link
Member

nzakas commented Aug 2, 2016

Oops, looks like we need another rebase here.

@eslintbot
Copy link

Thanks for the pull request, @mysticatea! I took a look to make sure it's ready for merging and found some changes are needed:

  • Pull requests with code require an issue to be mentioned at the end of the commit summary, such as (fixes #1234). Please update the commit summary with an issue (file a new issue if one doesn't already exist).

Can you please update the pull request to address these?

(More information can be found in our pull request guide.)

@mysticatea
Copy link
Member Author

I rebased it.

@gyandeeps gyandeeps merged commit 90f78f4 into master Aug 4, 2016
@mysticatea mysticatea deleted the issue6718 branch August 4, 2016 23:06
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@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 Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no-self-assign failing for property assignment
7 participants