{"record":{"id":"0243e548ba42a445","repo":"oxc-project/oxc","slug":"label-in-continue-statement-is-not-allowed","errorCode":null,"errorMessage":"Label in continue statement is not allowed","messagePattern":"Label in continue statement is not allowed","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_labels.rs","lineNumber":19,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{LabelIdentifier, Statement},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::NodeId;\nuse oxc_span::Span;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn no_labels_diagnostic(message: &'static str, label_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(message)\n        .with_help(\"Consider refactoring the code to eliminate the need for labels.\")\n        .with_label(label_span)\n}\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoLabels {\n    /// If set to `true`, this rule ignores labels which are sticking to loop statements.\n    /// Examples of **correct** code with this option set to `true`:\n    /// ```js\n    /// label:\n    ///     while (true) {\n    ///         break label;\n    ///     }\n    /// ```\n    allow_loop: bool,\n    /// If set to `true`, this rule ignores labels which are sticking to switch statements.\n    /// Examples of **correct** code with this option set to `true`:","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_labels.rs#L1-L37","documentation":"Diagnostic from oxlint's eslint/no-labels rule (crates/oxc_linter/src/rules/eslint/no_labels.rs:19). It reports 'continue someLabel;' — a form that jumps to the next iteration of an outer labeled loop. Because continue-with-label only targets loops, it is flagged whenever the labeled statement is disallowed by the active no-labels options; it is the control-flow construct style guides most want removed since it behaves like a restricted goto.","triggerScenarios":"'continue label;' inside an inner loop where 'label:' marks an outer loop or if-statement, e.g. 'outer: while (a) { while (b) { continue outer; } }'.","commonSituations":"Simulation/matrix code that skips to the next outer iteration; legacy code written before Array methods (some/every/find) were common; codebases adopting a strict shared lint config that enables no-labels.","solutions":["Restructure so the inner work is a function: use return to skip to the next outer iteration","Replace the pattern with a guard condition on the outer loop body or use array iteration methods with early exit","If intentional, allow loop labels via \"allowLoop\": true in the no-labels options"],"exampleFix":"// before\nouter: for (const user of users) {\n  for (const item of user.items) {\n    if (item.skip) continue outer;\n    handle(item);\n  }\n}\n\n// after\nfor (const user of users) {\n  if (user.items.some((item) => item.skip)) continue;\n  for (const item of user.items) handle(item);\n}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Replace continue label with a guard on the outer loop body or a helper function","Use array iteration methods for skip-to-next-outer semantics","Keep no-labels enabled in CI to prevent regressions during refactors"],"tags":["lint","javascript","labels","continue","control-flow","style"],"backgroundTag":"labeled-statements","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"}