oxc-project/oxc · warning · OxcDiagnostic

{pronoun_singular} '{name}' is marked as ignored but is used

Error message

{pronoun_singular} '{name}' is marked as ignored but is used.

What it means

Diagnostic of oxlint's no-unused-vars for ignore-pattern drift: a binding matches your varsIgnorePattern/argsIgnorePattern (or the default underscore convention) yet it IS referenced in code. The message tells you the ignore marker on a used symbol is misleading and suggests renaming so it no longer matches.

Source

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

pub fn used_ignored<R>(symbol: &Symbol<'_, '_>, pat: &IgnorePattern<R>) -> OxcDiagnostic
where
    R: fmt::Display,
{
    let (pronoun_singular, _) = pronoun_for_symbol(symbol.flags());
    let name = symbol.name();

    let help_suffix = match pat {
        IgnorePattern::None => ".".into(),
        IgnorePattern::Default | IgnorePattern::PrefixUnderscore => {
            name.strip_prefix('_').map_or(".".into(), |name| format!(" to '{name}'."))
        }
        IgnorePattern::Some(r) => {
            format!(" to match the pattern /{r}/.")
        }
    };

    OxcDiagnostic::warn(format!("{pronoun_singular} '{name}' is marked as ignored but is used."))
        .with_label(symbol.span().label(format!("'{name}' is declared here")))
        .with_help(format!(
            "Consider renaming this {}{help_suffix}",
            pronoun_singular.cow_to_ascii_lowercase()
        ))
}

/// Variable 'x' is declared but never used.
pub fn declared<R>(
    symbol: &Symbol<'_, '_>,
    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.")

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Rename the variable to drop the underscore/ignore marker since it is genuinely used.
  2. Tighten the ignore pattern (e.g. ^_ instead of _ anywhere) so it stops matching this name.
  3. If the ignore is deliberate for tooling reasons, disable the ignored-but-used reporting for the rule.

Example fix

// before (argsIgnorePattern: "^")
function f(_count) { return _count + 1; }
// after
function f(count) { return count + 1; }
Defensive patterns

Strategy: validation

Validate before calling

// sanity-check your pattern against names you actually use:
const argsIgnorePattern = /^_/;
const usedNames = ['_count', 'total'];
for (const n of usedNames) if (argsIgnorePattern.test(n)) console.warn(`${n} is used but ignored`);

Prevention

When it happens

Trigger: Configuration sets argsIgnorePattern "^_" (or enables reporting of ignored-but-used bindings) and code declares function f(_count) { return _count + 1; } where _count is read in the body.

Common situations: Underscore-prefixed params that later gain real uses after a refactor; overly broad ignore patterns that swallow genuine names; copy-pasting ignored names into used positions.

Related errors


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