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

no-self-assign failing for property assignment #6718

Closed
Zzzen opened this issue Jul 20, 2016 · 12 comments · Fixed by #6721
Closed

no-self-assign failing for property assignment #6718

Zzzen opened this issue Jul 20, 2016 · 12 comments · Fixed by #6721
Assignees
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 enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@Zzzen
Copy link
Contributor

Zzzen commented Jul 20, 2016

What version of ESLint are you using?
3.1.1
What parser (default, Babel-ESLint, etc.) are you using?
Default
Please show your full configuration:
{ "env": { "browser": true }, "parserOptions": { "ecmaVersion": 6 }, "rules": { "no-self-assign": "error" } }
What did you do? Please include the actual source code causing the issue.

var a = 123;
a = a;

var b = { a };
b.a = b.a; 

What did you expect to happen?
I would expect b.a = b.a to be a error;
What actually happened? Please include the actual, raw output from ESLint.
Only a.a is an error.

2:5 error 'a' is assigned to itself no-self-assign

✖ 1 problem (1 error, 0 warnings)

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jul 20, 2016
@platinumazure platinumazure added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 20, 2016
@platinumazure
Copy link
Member

Hmm... Seems like MemberExpressions just aren't being checked, even though a lot of other kinds of self-assignments are.

@mysticatea Is there a reason MemberExpressions aren't checked in this rule, or was it maybe just an oversight?

@mysticatea
Copy link
Member

mysticatea commented Jul 20, 2016

Thank you for this issue.
I think simply I had forgotten MemberExpressions.

Granted, property accesses can trigger side-effects, but I think that a use of self-assignments in order to trigger side-effects is a corner case.

@mysticatea mysticatea self-assigned this Jul 20, 2016
@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 20, 2016
@nzakas
Copy link
Member

nzakas commented Jul 20, 2016

Are we sure that this should be a default behavior? As mentioned, properties can have getters/setters, so we need to be certain that this makes sense as a default.

And since this is flagging something that wasn't flagged before, this should be an enhancement "Update".

@nzakas nzakas added the enhancement This change enhances an existing feature of ESLint label Jul 20, 2016
@ilyavolodin ilyavolodin removed the bug ESLint is working incorrectly label Jul 20, 2016
@mysticatea mysticatea added evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed accepted There is consensus among the team that this change meets the criteria for inclusion labels Jul 21, 2016
@mysticatea
Copy link
Member

I removed accepted label by this is an enhancement. I will move forward my PR after this issue is accepted.

I think it's good for default behavior since it does not expect that self-assignments have side-effects, normally.

@nzakas
Copy link
Member

nzakas commented Jul 21, 2016

I think it's good for default behavior since it does not expect that self-assignments have side-effects, normally.

My question is, can we assume that? I'm not sure we can.

@platinumazure
Copy link
Member

Can we put it behind a rule option so users can make that call?

On Jul 21, 2016 11:12 AM, "Nicholas C. Zakas" notifications@github.com
wrote:

I think it's good for default behavior since it does not expect that
self-assignments have side-effects, normally.

My question is, can we assume that? I'm not sure we can.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#6718 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AARWemfF03LpMmHU-ynqSqglzbW_cmdtks5qX5phgaJpZM4JQXbi
.

@ilyavolodin
Copy link
Member

I think I would prefer this behind an option as well. Just to be on a safe side. Maybe the option can be on by default, but at least that way users will have a way to turn it off.

@nzakas
Copy link
Member

nzakas commented Jul 21, 2016

For best backwards compatibility, I'd suggest having the option off by default and allow people to opt-in.

@platinumazure
Copy link
Member

👍 to @nzakas' proposal.

@mysticatea
Copy link
Member

Hmm, OK.
I agreed we need an option (maybe {props: true}), false by default.

@nzakas
Copy link
Member

nzakas commented Jul 22, 2016

That sounds good. Since this is an enhancement now, we need one more 👍

@ilyavolodin
Copy link
Member

👍

@ilyavolodin ilyavolodin added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 22, 2016
gyandeeps pushed a commit that referenced this issue Aug 4, 2016
)

* Chore: add `getStaticPropertyName` to ast-utils

* Update: add `props` option to `no-self-assign` rule (fixes #6718)

* Chore: use `astUtils.getStaticProperty` for some places.
@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
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 enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants