-
Notifications
You must be signed in to change notification settings - Fork 29.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
tools: add number-isnan eslint rule #17556
Conversation
8ebfc4a
to
3397250
Compare
This might be a bit finicky since it would catch |
No objections, but one question and one observation. Question: What's the reason for avoiding the Observation: I think this can probably be implemented using |
3397250
to
960dd50
Compare
For personal reasons, I think it's more clear to use
Interesting -- refactored down to use no-restricted-syntax |
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.
Unfortunately this won't work as it overrides all the no-restricted-syntax
rules declared within .eslintrc.yaml
in the root directory.
Oh, yeah, I assumed it was a lint rule we'd want for the entire code base... |
Yeah, I think we could do that? I don't see any reason why we would be stricter about this in |
Are we sure we want to necessarily encourage people to change isNaN('a string is not a nubmer'); //true
Number.isNaN('a string is not a number'); // false |
|
960dd50
to
1e94820
Compare
updated @apapirovski @Trott For context, I was initially hesitant to add the rule to |
@maclover7 Sorry to make this tedious, but this is what I'd recommend:
|
(And yeah, had I not said anything, first bullet point would have happened and all of this would have been avoided. Sorry!) |
lib/events.js
Outdated
@@ -75,7 +75,7 @@ EventEmitter.init = function() { | |||
// Obviously not all Emitters should be limited to 10. This function allows | |||
// that to be increased. Set to zero for unlimited. | |||
EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) { | |||
if (typeof n !== 'number' || n < 0 || isNaN(n)) { | |||
if (typeof n !== 'number' || n < 0 || Number.isNaN(n)) { |
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.
I think the typeof n !== 'number'
check is redundant if Number.isNaN
is being used.
lib/readline.js
Outdated
@@ -105,7 +105,7 @@ function Interface(input, output, completer, terminal) { | |||
} | |||
|
|||
if (typeof historySize !== 'number' || | |||
isNaN(historySize) || | |||
Number.isNaN(historySize) || |
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.
I think the typeof historySize !== 'number'
check is redundant if Number.isNaN
is being used.
b57c942
to
301cc7a
Compare
updated @Trott, PTAL |
Will land tomorrow unless any objections |
Landed in e554bc8 |
PR-URL: nodejs#17556 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #17556 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #17556 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #17556 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #17556 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #17556 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
tools, test