-
-
Notifications
You must be signed in to change notification settings - Fork 420
Open
Labels
Description
Description
Enforce or disallow explicit delay argument for setTimeout() and setInterval()
Allow configuring whether setTimeout() and setInterval() must have an explicit delay argument. This provides flexibility for different team preferences.
Examples
{
"unicorn/explicit-timer-delay": ["error", "always" | "never"]
}"always"(default): Require explicit delay argument"never": Disallow explicit delay when it's 0 (prefer implicit default)
With "always":
// ❌ Fail
setTimeout(() => console.log('Hello'));
setInterval(callback);
// ✅ Pass
setTimeout(() => console.log('Hello'), 0);
setInterval(callback, 0);With "never":
// ❌ Fail
setTimeout(() => console.log('Hello'), 0);
// ✅ Pass
setTimeout(() => console.log('Hello'));
setInterval(callback, 1000); // Non-zero is still OKProposed rule name
explicit-timer-delay
Additional Info
No response
fisker and neoantox