tools,test: provide duration/interval to timers, require it with lint rule by Trott · Pull Request #9472 · nodejs/node

Skip to content

Navigation Menu

Sign in

Appearance settings

Conversation

@Trott Trott added timers

Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

test

Issues and PRs related to the tests.

benchmark

Issues and PRs related to the benchmark subsystem.

tools

Issues and PRs related to the tools directory.

labels

Nov 4, 2016

not-an-aardvark

not-an-aardvark

@Trott Trott mentioned this pull request

Nov 11, 2016

2 tasks

Fishrock123 added a commit to Fishrock123/github-bot that referenced this pull request

Nov 16, 2016

@Trott Trott changed the title tools,test,benchmark: provide duration/interval to timers, require it with lint rule tools,test: provide duration/interval to timers, require it with lint rule

Nov 16, 2016
There 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.

This was referenced

Jan 25, 2017

Labels

test

Issues and PRs related to the tests.

timers

Issues and PRs related to the timers subsystem / setImmediate, setInterval, setTimeout.

tools

Issues and PRs related to the tools directory.