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: Fix handling of property names in no-self-assign #12105
Update: Fix handling of property names in no-self-assign #12105
Conversation
I think the question is, should the rule definitely be reporting those issues (could there be a good reason we weren't reporting those cases)? If the current behavior is not according to design, then this is acceptable as a semver-minor fix. I lean toward that interpretation, but please let me know if I missed something. |
I've edited the post to add As for As for why 'simple' computed keys were not compared, the code is very explicit and it was certainly by design, probably before they were treated as statically known in other rules as well. |
Most of the rules use Was there a precedent of this particular change in a minor version? The safest thing here would be to revert that part and ignore all computed keys, it would be similar to how On the other hand, that rule does match |
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, thank you!
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!
Are all new warnings acceptable for semver-minor? (I didn't change anything after the initial commit) |
@mdjermanovic No, but I thought about this case and I can't see any reason why the rule would want to distinguish between property assignments vs literals as a matter of design. In this case, I evaluated the probability that people were depending on the current, specific behavior with differences between literals and property names, and decided that the probability was very low. But again, that's just my own evaluation. We do have precedent about adding warnings in semver-minor where the enhancement just seems natural. (E.g., a stylistic rule about var declarations could be naturally expanded to let and const declarations.) If other team members feel differently, I certainly have no problem with adding an option. |
@platinumazure I agree, this is a too 'small' change in behavior to be an option. |
I'm fine with semver-minor (A bug fix in a rule that results in ESLint reporting more errors). If the rest of the team have no objection, I will merge this PR within the next release. |
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!
What is the purpose of this pull request? (put an "X" next to item)
[X] Bug fix
This is a bug fix to remove false positives, but it's fixed in a way that can produce a few more warnings.
Please see is it ok, the details are below.
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
Configuration
What did you do? Please include the actual source code causing the issue.
An example:
Demo link
What did you expect to happen?
No warnings.
What actually happened? Please include the actual, raw output from ESLint.
What changes did you make? (Give an overview)
The code was assuming that all non-computed keys are identifiers and matched them by
undefined === undefined
.It's fixed to compare keys by their
getStaticPropertyName
values.Is there anything you'd like reviewers to focus on?
These would be new warnings:
Is it okay for a semver-minor fix? I can modify the code to just remove false positives.