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
Stop recommending Number.isNaN over isNaN #2153
Comments
That's the whole reason to do it (and the whole reason |
Ok so |
I completely agree with the OP - the fact the rule suggestion says |
@apieceofbart the suggestion doesn't tell you to blindly make a replacement, because the replacement isn't in backticks - and if it were trying to suggest that, it'd just do an autofix. If someone's going to do a naive replacement then they're probably doomed to screw up no matter what the message says. |
All I am saying is I see the message: "Unexpected use of 'isNaN'. Use Number.isNaN instead" with a link that is hardly visible and not clickable. To me "use X instead" means I can replace one with the other. Of course I won't argue with you but I think this issue and other issues on the same topics + a fact that I am now fixing code that was caused exactly because the person interpreted the rule as a replacement, is a proof that the message is misleading. |
If tests weren’t covering it there’s not much to be done. |
@ljharb @apieceofbart I just became that 4 instances of this, easy fix, just prepend with
|
@kevbost I'm happy to improve the message if that would clear it up, but not having tests is the cause of your issue, not the linter. |
I like the idea of
no-restricted-globals
, but I've noticed that this particular recommendation comes with a behavior change:https://github.com/airbnb/javascript/blob/master/packages/eslint-config-airbnb-base/rules/best-practices.js#L231-L234
isNaN(undefined) -> true
isNaN('state') -> true
Number.isNaN(undefined) -> false
Number.isNaN('state') -> false
To me if the behavior is different it should be listed as a recommended alternative and may cause people to introduce bugs.
The text was updated successfully, but these errors were encountered: