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
use-isnan options for implicit Strict Equality Comparison #12207
use-isnan options for implicit Strict Equality Comparison #12207
Comments
Thank you for this issue. Sounds a good idea. |
I'm definitely I'm less sure about |
it’d be better to make a custom rule forbidding indexOf in favor of includes, for that one. |
The initial idea was one option for both, but exactly because of this user should have a way to disable |
This can be easily done with |
Off topic: |
I'm working on this (indexOf). |
What rule do you want to change?
use-isnan
This rule targets
foo === NaN
(Strict Equality Comparison)(also targets
!==
,==
and!=
)Currently, the rule checks only
BinaryExpression
nodes, i.e. only explicit comparisons.This is a proposal to also check the following:
case NaN
will never match and it's a possible error.foo.indexOf(NaN)
will never match and it's a possible error. The same applies to Array.prototype.lastIndexOf.Does this change cause the rule to produce more or fewer warnings?
More if an option is set to
true
. Defaults arefalse
.How will the change be implemented? (New option, new default behavior, etc.)?
2 options,
enforceForSwitchCase
andenforceForIndexOf
.Please provide some example code that this change will affect:
What does the rule currently do for this code?
Nothing.
What will the rule do after it's changed?
Are you willing to submit a pull request to implement this change?
Yes. (there is PR #12106 for
enforceForSwitchCase
)The text was updated successfully, but these errors were encountered: