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
Conversation
@mysticatea, thanks for your PR! By analyzing the annotation information on this pull request, we identified @vitorbal, @lo1tuma and @gyandeeps to be potential reviewers |
Thanks for the pull request, @mysticatea! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
Granted, the 1st commit of this PR does not have |
"a.b = c.b", | ||
"a.b = a[b]", | ||
"a[b] = a.b", | ||
"a.b().c = a.b().c", |
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.
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?)
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.
If an expression includes call expression(s), this rule ignores the expression.
I added a test to make sure.
Thanks for the pull request, @mysticatea! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
no-self-assign
warns for properties (fixes #6718)props
option to no-self-assign
rule (fixes #6718)
I update this PR by the result of discussion. This PR adds |
LGTM, waiting for others to review. |
@mysticatea can you rebase? |
Thanks for the pull request, @mysticatea! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
Done! (The 2nd commit has |
LGTM, thanks for the contribution @mysticatea! |
Oops, looks like we need another rebase here. |
Thanks for the pull request, @mysticatea! I took a look to make sure it's ready for merging and found some changes are needed:
Can you please update the pull request to address these? (More information can be found in our pull request guide.) |
I rebased it. |
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
anda["b"]
) intoast-utils.js
because this logic is used in multiple places.