-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Update: check logical assignment in no-constant-condition #13946
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
Conversation
It's interesting that this rule doesn't currently check non-logical assignment expressions. For example, Should this instead add a |
It does check the direct For example, this is nearly the same as /* eslint no-constant-condition: "error" */
if (a = a || true); // error It indeed doesn't account for Maybe we could remove this, but leave the rest? |
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.
Can you also update the examples in the documentation?
Added examples for |
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
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
To resolve my question above, we decided in yesterday's TSC meeting to update our semantic versioning policy to allow adding new rule checks for new language features in semver-minor features. That's being done in #13970, and this is semver-minor per that policy. We're not including operators like |
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[X] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What rule do you want to change?
no-constant-condition
Does this change cause the rule to produce more or fewer warnings?
more
How will the change be implemented? (New option, new default behavior, etc.)?
new default behavior
Please provide some example code that this change will affect:
What does the rule currently do for this code?
no errors
What will the rule do after it's changed?
all conditions will be reported
What changes did you make? (Give an overview)
Added logic for logical assignments.
Is there anything you'd like reviewers to focus on?
This wasn't included in #13618 as it was waiting for refactoring and bug fixes from #13245. Can we treat this as a semver-minor bug fix?