Equals signs can't be used to check if variable is NaN, isNaN() function should be used instead.
Example of incorrect usage:
const maybeNumber = parseInt("a");
if( maybeNumber === NaN || maybeNumber === NaN ) {
// this line is never reached <- UNEXPECTED
}
const maybeNumber = parseInt("a");
if( isNaN(maybeNumber) ) {
// this line is reached, as expected
}
@HamletDRC - has there been any thought to contributing these Microsoft rules back to the main tslint repo?
@HamletDRC, that would be nice :)
I am happy to move any of the rules to tslint. It is up to someone from the tslint team to go through the tslint-microsoft-contrib rulesset and tell me which ones they want. I am not going to create 60 new PR requests for tslint just to have 55 of them closed as "rule is too specific for teslint". So the ball is in Palentir's court. I am happy to do the work of porting the rules, but tslint must state which rules they want and which rules they do not want.
@HamletDRC fair enough :) thanks for the offer. We'll take a look at the tslint-microsoft-contrib rule set. In the meantime, the new extends feature should make sharing configs easier (once the bugs are ironed out this week).
Feel free to send a PR for this one in particular (and any others which have the "Status: Accepting PRs" label)
Most helpful comment
I am happy to move any of the rules to tslint. It is up to someone from the tslint team to go through the tslint-microsoft-contrib rulesset and tell me which ones they want. I am not going to create 60 new PR requests for tslint just to have 55 of them closed as "rule is too specific for teslint". So the ball is in Palentir's court. I am happy to do the work of porting the rules, but tslint must state which rules they want and which rules they do not want.