{"record":{"id":"66f05a2ba7396c09","repo":"oxc-project/oxc","slug":"label-name-is-defined-but-never-used","errorCode":null,"errorMessage":"'{label_name}:' is defined but never used.","messagePattern":"'(.+?):' is defined but never used\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_unused_labels.rs","lineNumber":9,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{context::LintContext, rule::Rule};\n\nfn no_unused_labels_diagnostic(label_name: &str, span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"'{label_name}:' is defined but never used.\")).with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoUnusedLabels;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow unused labels.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Labels that are declared and not used anywhere in the code are most likely an error due to incomplete refactoring.\n    ///\n    /// ### Examples\n    ///\n    /// Examples of **incorrect** code for this rule:\n    /// ```javascript","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_unused_labels.rs#L1-L27","documentation":"Diagnostic from oxlint's no-unused-labels rule. A label declared on a loop or block is never targeted by any break/continue with that name, so it is dead syntax, typically leftover after the labeled break or the inner loop was removed.","triggerScenarios":"outer: for (...) { for (...) { ... } } with no break outer; or continue outer; anywhere in the function.","commonSituations":"The inner loop or the labeled break was deleted during refactoring; a flag or early return replaced the labeled control flow; generated code emits labels unconditionally.","solutions":["Delete the unused label and its colon.","If a labeled break was intended, restore break label; at the right spot.","Run oxlint --fix; removing an unused label is a purely mechanical, safe fix."],"exampleFix":"// before\nouter: for (const a of xs) {\n  for (const b of ys) { handle(a, b); }\n}\n// after\nfor (const a of xs) {\n  for (const b of ys) { handle(a, b); }\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remove labels whenever you remove or un-nest the loops they named.","Run oxlint --fix before commit; unused label removal is mechanical and safe.","Prefer extracting functions over labeled control flow in new code."],"tags":["eslint","oxlint","labels","dead-code"],"backgroundTag":"unused-label","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}