oxc-project/oxc · error · OxcDiagnostic
Unused {} directive (no matching {} directives were found fo
Error message
Unused {} directive (no matching {} directives were found for {rule_name}). What it means
Diagnostic from create_unused_directives_diagnostics: an enable comment naming a specific rule found no matching disable for that rule (the rule was either never disabled or already re-enabled), so the per-rule enable is redundant.
Source
Thrown at crates/oxc_linter/src/disable_directives.rs:1404
diagnostics.push(
OxcDiagnostic::warn(rule_message)
.with_label(rule.name_span)
.with_severity(severity),
);
}
}
}
}
// Report unused enable comments
let unused_enable = directives.unused_enable_comments();
for (directive_prefix, rule_name, span) in unused_enable {
let message = if let Some(rule_name) = rule_name {
directive_prefix.unused_enable_rule_message(rule_name)
} else {
directive_prefix.unused_enable_message()
};
diagnostics.push(OxcDiagnostic::warn(message).with_label(*span).with_severity(severity));
}
diagnostics
}
#[cfg(test)]
mod tests {
use oxc_allocator::Allocator;
use oxc_ast::Comment;
use oxc_parser::Parser;
use oxc_semantic::{Semantic, SemanticBuilder};
use oxc_span::{SourceType, Span};
use crate::disable_directives::{
DirectivePrefix, DisabledRule, RuleCommentRule, RuleCommentType,
};
use super::{DisableDirectives, DisableDirectivesBuilder};View on GitHub (pinned to e1e7af627c)
Solutions
- Remove the redundant rule-specific enable comment
- Add or keep the matching disable directive if pairs were intended
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/disable_directives.rs:1404 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/e2ab85902e3804c5.
Report an issue: GitHub.