oxc-project/oxc · warning · OxcDiagnostic

{pronoun} '{name}' is imported but never used.

Error message

{pronoun} '{name}' is imported but never used.

What it means

no-unused-vars import variant: an imported binding is never referenced, so the import is dead code that obscures real dependencies and can bloat bundles in toolchains that cannot tree-shake. The label points at the import span.

Source

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

    } else {
        pat.diagnostic_help("parameters")
    };

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

/// Identifier 'x' imported but never used.
pub fn imported(symbol: &Symbol<'_, '_>) -> OxcDiagnostic {
    let (pronoun, _) = pronoun_for_symbol(symbol.flags());
    let name = symbol.name();

    OxcDiagnostic::warn(format!("{pronoun} '{name}' is imported but never used."))
        .with_label(symbol.span().label(format!("'{name}' is imported here")))
        .with_help("Consider removing this import.")
}

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Delete the unused specifier (or the whole import statement if no specifiers remain).
  2. If it is only used as a type, convert to import type { X }.
  3. Run an organize-imports fixer (editor action or oxlint --fix where configured) before committing.

Example fix

// before
import { ref, computed } from 'vue';
export const x = 1;
// after
export const x = 1;
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: import { debounce } from 'lodash-es'; with no debounce usage anywhere in the module; type imports kept after switching to inline types; barrel-file imports of unused symbols.

Common situations: Refactors removing call sites; IDE auto-import pulling in unused names; switching values to import type; re-export cleanup.

Related errors


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