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
feat: Treat Class/New Expressions as truthy in no-constant-condition #15326
feat: Treat Class/New Expressions as truthy in no-constant-condition #15326
Conversation
Hi @captbaritone!, thanks for the Pull Request The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.
Read more about contributing to ESLint here |
a7fd1fd
to
92112a9
Compare
Hi @captbaritone!, thanks for the Pull Request The first commit message isn't properly formatted. We ask that you update the message to match this format, as we use it to generate changelogs and automate releases.
Read more about contributing to ESLint here |
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.
Makes sense to me. Can you also update the docs?
92112a9
to
286cf80
Compare
I've added an example of each error to the docs. The class expression seems obscure enough that it might not be worth inclusion. Happy to remove it if others feel the same way. |
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.
286cf80
to
a893fed
Compare
I believe all comments have been addressed. |
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!
In working on #15296 I discovered a few constant expressions that that were not covered in
no-constant-condition
, so I figured I'd propose adding them here.Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[X] Changes an existing rule (template)
What changes did you make? (Give an overview)
In working on #15296 I discovered a few constant expressions that that were not covered in
no-constant-condition
, so I figured I'd propose adding them here. This change add the ability to detectClassExpression
andNewExpression
s as always truthy. I especially like that it catches the unintuitive fact that boxed primitives are always truthy.These will now report errors:
Is there anything you'd like reviewers to focus on?
There's some overlap here with
no-new-wrappers
but I think it's sensible since this detects an actual bug that results from primitive boxing.