-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Enhancement: [strict-boolean-expressions] Change == to ===? #6173
Comments
There is nothing to align with in ESLint core - these are just two optional, stylistic rules that can be used to enforce a certain code style. I'm personally opposed to strict equality checks against
IIRC it was because the rule itself doesn't specifically distinguish between In hindsight, it does also allow for a simpler rule because we also didn't need to write three separate fixers (one for Should we change it? I'm leaning towards no because:
Should we add an option? I'm leaning towards no again because:
Not blocking on this, but without a really killer reason or there is a lot of push from users - I don't think it's worth the maintenance burden. |
In my case, I didn't use the rule because it used to be buggy and too limited. And now, I cannot enable the rule as the auto-fix fixes to the wrong thing (not |
I'm okay if we add an option to control the null/undefined fixer style. interface Options {
nullishFixStyle?: 'double-equals' | 'triple-equals';
}
const defaults: Options = {
nullishFixStyle: 'double-equals',
}; Where |
Love it! Hopefully there are other willing contributors who have more time than I do right now to submit a PR for this. I'll keep an eye on it. |
(cc @sindresorhus) |
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Link to the rule's documentation
https://typescript-eslint.io/rules/strict-boolean-expressions/
Description
Hello! We believe strongly that strict boolean expressions are a good thing, because truthy evaluation opens the door for developer error and bugs to slip into the wild.
For this reason, we very much like the power of the strict-boolean-expressions rule.
The challenge we are facing, is how auto-fix conflicts with some other rules that we believe are very valuable:
The fixes and suggestions (specifically the auto-fix for objects when
allowNullableObject
isfalse
) conflict with the above rules.I am sure that there is good reason and a lot of discussion behind why there was a decision to use
== null
as opposed to=== undefined
, but I thought it would be worth opening a discussion to see if we can get a consensus that it would be preferable to change the behavior to align more with the core eslint rules and the philosophy behind why it is a good idea to enable them.Fail
Pass
Additional Info
There are a couple issues I found with some information on the topic, but it is not explicit about this particular choice so I thought it was worth opening a new thread:
The text was updated successfully, but these errors were encountered: