-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
docs: fix no-unnecessary-boolean-literal-compare example #8981
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
Thanks for the PR, @heitorlisboa! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Good eyes! Thanks for sending this. On the CI failure: There's a gap in our docs right now about how to update the snapshots of the code samples (filed #8997); long story short, would you mind running |
@@ -101,11 +101,11 @@ Examples of code for this rule with `{ allowComparingNullableBooleansToFalse: fa | |||
|
|||
```ts option='{ "allowComparingNullableBooleansToFalse": false }' | |||
declare const someUndefinedCondition: boolean | undefined; | |||
if (someUndefinedCondition === false) { |
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.
(optional)
Question - is there any reason for these to negate the "Incorrect" code rather than the "Correct" code here? It feels weird to me to have !inputExpression
=> !outputExpression
when inputExpression
=> outputExpression
would be much simpler. (This isn't a loaded question; I just genuinely can't think of a reason. I note that the chart below does it that way, too, which you've probably followed for consistency, but... should we just change it there too?)
Either way, though, your change fixes it from incorrect to correct, following the existing pattern, so it's totally optional if you even want to think about this comment or 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.
You're right. I only did it this way for consistency, but I agree that negating the "Incorrect" code makes it harder to understand.
I'm down to update the example and the fixer chart to use simpler expressions. Should I go ahead with it? If you're cool with it, I'll update the snapshots (as you mentioned in your previous comment) once I've made the changes.
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.
Great, go for it! 🚀🚀
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.
Done! 😄
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.
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.
🚀 +1, thanks!
6e1241b
into
typescript-eslint:main
PR Checklist
no-unnecessary-boolean-literal-compare
#8980Overview
Add missing
!( ... )
around comparison cases in example for theallowComparingNullableBooleansToFalse
option of the no-unnecessary-boolean-literal-compare docs.