oxc-project/oxc · warning · OxcDiagnostic

{pronoun} '{name}' is {verb} but never used.{suffix}

Error message

{pronoun} '{name}' is {verb} but never used.{suffix}

What it means

Core no-unused-vars message: a binding ({pronoun}: Variable, Class, Function...) is declared, or a catch parameter is caught ({verb}), but never referenced anywhere in value or type positions. The label points at the declaration span.

Source

Thrown at crates/oxc_linter/src/rules/eslint/no_unused_vars/diagnostic.rs:82

    pat: &IgnorePattern<R>,
    only_used_as_type: bool,
) -> OxcDiagnostic
where
    R: fmt::Display,
{
    let (verb, help) = if symbol.flags().is_catch_variable() {
        ("caught", "Consider handling this error.")
    } else {
        ("declared", "Consider removing this declaration.")
    };
    let name = symbol.name();
    let (pronoun, pronoun_plural) = pronoun_for_symbol(symbol.flags());
    let suffix = pat.diagnostic_help(pronoun_plural);

    OxcDiagnostic::warn(if only_used_as_type {
        format!("{pronoun} is {verb} but only used as a type.{suffix}")
    } else {
        format!("{pronoun} '{name}' is {verb} but never used.{suffix}")
    })
    .with_label(symbol.span().label(format!("'{name}' is declared here")))
    .with_help(help)
}

/// Variable 'x' is assigned a value but never used.
pub fn assign<R>(
    symbol: &Symbol<'_, '_>,
    assign_span: Span,
    pat: &IgnorePattern<R>,
) -> OxcDiagnostic
where
    R: fmt::Display,
{
    let name = symbol.name();
    let (pronoun, pronoun_plural) = pronoun_for_symbol(symbol.flags());
    let suffix = pat.diagnostic_help(pronoun_plural);

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Delete the declaration if it is truly unnecessary.
  2. Rename to _name or _ to signal intent, matching the default ignore convention.
  3. For unused catch bindings, omit the parameter entirely: catch { /* ... */ }.
  4. For systematic cases set varsIgnorePattern / caughtErrors options on the rule in .oxlintrc.json.

Example fix

// before
const cache = new Map();
function f() { return 1; }
// after
// (unused declarations removed, or rename to _cache if kept deliberately)
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: const x = 1; with no later reads; catch (e) {} where e is unused; a declared helper never called; destructured values never consumed.

Common situations: Refactors that removed call sites; feature flags read elsewhere; leftover scaffolding; catch blocks that intentionally swallow errors.

Related errors


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