Uh oh!
There was an error while loading. Please reload this page.
tools,test: provide duration/interval to timers, require it with lint rule - #9472
tools,test: provide duration/interval to timers, require it with lint rule#9472Trott wants to merge 2 commits into
Conversation
not-an-aardvark
left a comment
There was a problem hiding this comment.
I have a slight nitpick with the error message, but otherwise this LGTM.
There was a problem hiding this comment.
This error message seems a bit misleading to me, since setTimeout and setInterval can be called with more than 2 arguments. Maybe it would be better to use must have at least 2 arguments instead.
There was a problem hiding this comment.
Yes, you are right, I updated the rule to accommodate more arguments but did not update the message. Fixed.
There was a problem hiding this comment.
I'm not sure if it matters, but name will be undefined for calls like foo.bar().
There was a problem hiding this comment.
I think that's fine but would be happy to add a check for the situation if others feel differently.
Fishrock123
commented
Nov 4, 2016
I think this is unnecessary and we should probably not bother. |
mscdex
commented
Nov 4, 2016
Unless these are specifically testing |
7830fd5 to
11e40d1Compare4f67aec to
ddea832Compare8e41a18 to
41e6507Compare55ff765 to
3decf69Compareea51fa2 to
4d83722Comparee18c718 to
dfd901dCompareThere are several places in the code base where setTimeout() or setInterval() are called with just a callback and no duration/interval. The timers module will use a value of `1` in that situation. I find an unspecified duration or interval confusing. I always spend a moment wondering if it is a mistake. Did the original author simply forget to provide a value? Did they intend to use setImmediate() or even process.nextTick() instead of setTimeout()? And so on. This change provides a duration or interval of `1` to all calls in the codebase where it is missing. `parallel/test-timers.js` still tests the situation where `setTimeout()` and `setInterval()` are called with `undefined` and other non-numeric values for the duration/interval.
Add a custom ESLint rule to require that setTimeout() and setInterval() get called with at least two arguments. This prevents omitting the duration or interval.
Checklist
make -j8 test(UNIX), orvcbuild test nosign(Windows) passesAffected core subsystem(s)
tools test timers
Description of change
First commit
Second commit