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
- Delete the declaration if it is truly unnecessary.
- Rename to _name or _ to signal intent, matching the default ignore convention.
- For unused catch bindings, omit the parameter entirely: catch { /* ... */ }.
- 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
- Run oxlint --deny-warnings in CI so unused bindings never reach main.
- Adopt the underscore convention (_ or _name) for intentionally unused bindings.
- Omit catch bindings you do not use: catch { ... }.
- Remove declarations in the same commit that removes their last consumer.
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
- {pronoun} '{name}' is imported but never used.
- Redundant Boolean call
- This label '{label_name}' is unnecessary
- Unreachable code.
- Invalid loop. Its body allows only one iteration.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/aa91767a8bd6522d.
Report an issue: GitHub.