oxc-project/oxc · warning · OxcDiagnostic
Parameter '{name}' is declared but never used.{suffix}
Error message
Parameter '{name}' is declared but never used.{suffix} What it means
Fires when the no_unused_vars rule finds a function parameter binding that is never referenced in the function body (or only inside type positions when only_used_as_type is true). The suffix carries ignore-pattern help text, or is empty for the default '_' parameter under the default ignore pattern.
Source
Thrown at crates/oxc_linter/src/rules/eslint/no_unused_vars/diagnostic.rs:128
pub fn param<R>(
symbol: &Symbol<'_, '_>,
pat: &IgnorePattern<R>,
only_used_as_type: bool,
) -> OxcDiagnostic
where
R: fmt::Display,
{
let name = symbol.name();
let suffix = if name == "_" && pat.is_default() {
std::borrow::Cow::Borrowed("")
} 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
- Rename to _index / _ to match the default underscore ignore convention.
- Remove the parameter entirely when it is trailing and unneeded: items.map((item) => ...).
- Tune rule options (args, argsIgnorePattern) in .oxlintrc.json to your team's strictness.
- Use rest parameters to absorb ignored positionals when arity must be preserved.
Example fix
// before items.map((item, index) => item * 2); // after items.map((item, _index) => item * 2); // or: items.map((item) => item * 2);
Defensive patterns
Strategy: validation
Prevention
- Name ignored positional parameters with a leading underscore (_index).
- Drop trailing unused parameters outright: (item) => ... instead of (item, _index) => ... when arity allows.
- Set args/argsIgnorePattern options once in .oxlintrc.json to encode team convention.
When it happens
Trigger: items.map((item, index) => item * 2) with index unused; function f(a, b) { return a; }; interface method implementations with unused parameters.
Common situations: Framework callbacks with fixed signatures (express handlers, React props, test runners); unused arguments positioned before used ones; refactors that dropped the last use of a parameter.
Related errors
- Parameter '{name}' is declared but only used as a type.{suff
- Default parameters should be last
- Function '{}' has too many parameters ({}). Maximum allowed
- Function has too many parameters ({}). Maximum allowed is {}
- Arrow function has too many parameters ({}). Maximum allowed
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/8460e6db286bf27a.
Report an issue: GitHub.