oxc-project/oxc · error · OxcDiagnostic

`{name}` should not have an explicit delay of `0`.

Error message

`{name}` should not have an explicit delay of `0`.

What it means

Raised by unicorn/explicit_timer_delay (in its `never` mode) when `setTimeout` or `setInterval` is passed an explicit delay of `0` as its second argument. At the throw site the `0` is redundant — omitting the delay argument behaves identically (immediate async scheduling) — so the project style forbids spelling it out. redundant_delay_diagnostic fires from check_never for timer calls whose delay argument is the literal 0, naming the timer function in the message.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/explicit_timer_delay.rs:24

use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};
use schemars::JsonSchema;
use serde::Deserialize;

use crate::{
    AstNode,
    context::LintContext,
    rule::{DefaultRuleConfig, Rule},
};

fn missing_delay_diagnostic(span: Span, name: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("`{name}` should have an explicit delay argument."))
        .with_help("Add an explicit delay argument.")
        .with_label(span)
}

fn redundant_delay_diagnostic(span: Span, name: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("`{name}` should not have an explicit delay of `0`."))
        .with_help("Remove the explicit `0` delay argument.")
        .with_label(span)
}

#[derive(Debug, Default, Clone, Copy, Deserialize, JsonSchema)]
#[serde(rename_all = "kebab-case")]
pub enum ExplicitTimerDelayMode {
    #[default]
    /// Require explicit `delay` argument for clarity.
    Always,
    /// Disallow explicit `0` delay, prefer implicit default.
    Never,
}

#[derive(Debug, Default, Clone, Deserialize)]
pub struct ExplicitTimerDelay(ExplicitTimerDelayMode);

declare_oxc_lint!(

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the 0 delay argument from the timer call.
  2. Set the rule option to 'always' if explicit delays are required.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/explicit_timer_delay.rs:24 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/4ab90296c41d50a4. Report an issue: GitHub.