oxc-project/oxc · error · OxcDiagnostic

`{name}` should have an explicit delay argument.

Error message

`{name}` should have an explicit delay argument.

What it means

Raised by unicorn/explicit-timer-delay in 'always' mode when setTimeout/setInterval is called without an explicit delay argument, relying on the implicit browser default (0/4ms) and hiding timing intent.

Source

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

use oxc_ast::{
    AstKind,
    ast::{Argument, CallExpression, Expression, UnaryOperator},
};
use oxc_diagnostics::OxcDiagnostic;
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,

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Pass an explicit delay: setTimeout(fn, 0).
  2. Set the rule option to 'never' if implicit delays are acceptable in the codebase.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/explicit_timer_delay.rs:18 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/a782598c3cde87c8. Report an issue: GitHub.