{"record":{"id":"625a45495ff4b1fc","repo":"oxc-project/oxc","slug":"unexpected-use-of-continue-statement","errorCode":null,"errorMessage":"Unexpected use of `continue` statement.","messagePattern":"Unexpected use of `continue` statement\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"info","filePath":"crates/oxc_linter/src/rules/eslint/no_continue.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::{AstNode, context::LintContext, rule::Rule};\n\nfn no_continue_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected use of `continue` statement.\")\n        .with_help(\"Do not use the `continue` statement.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoContinue;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow `continue` statements.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// The continue statement terminates execution of the statements in the current iteration of the current or labeled loop, and continues execution of the loop with the next iteration. When used incorrectly it makes code less testable, less readable and less maintainable. Structured control flow statements such as if should be used instead.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_continue.rs#L1-L27","documentation":"Diagnostic from the oxlint rule `no-continue` (crates/oxc_linter/src/rules/eslint/no_continue.rs). It is a stylistic restriction rule that fires on every `continue` statement, per the ESLint original: `continue` jumps control flow and some teams ban it to keep loops readable and force restructured conditions.","triggerScenarios":"Any ContinueStatement in the scanned source — `for (...) { if (skip(i)) continue; work(i); }` — regardless of loop type or label.","commonSituations":"Adopting oxlint with the eslint `restriction` category or porting an ESLint config that included `no-continue`; existing loops using guard-clause `continue` patterns suddenly reported; mixed teams arguing over loop style.","solutions":["Restructure the loop body so the guard becomes an `if` around the work: `if (!skip(i)) { work(i); }`.","Filter the iterable before looping: `for (const i of items.filter(notSkipped)) {...}`.","If `continue` is the clearest form and the team accepts it, disable the rule in .oxlintrc.json (`\"no-continue\": \"off\"`).","For isolated cases keep the code and suppress inline with `// oxlint-disable-next-line no-continue`."],"exampleFix":"// before\nfor (const item of items) {\n  if (!item.active) continue;\n  process(item);\n}\n\n// after\nfor (const item of items) {\n  if (item.active) {\n    process(item);\n  }\n}","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["If the team bans continue, configure `\"no-continue\": \"error\"` and restructure guards into if-wrapped bodies.","If continue is accepted style, turn the rule off in .oxlintrc.json rather than littering suppressions.","Prefer filtering iterables before the loop to avoid guard-clause jumps."],"tags":["lint","continue","control-flow","stylistic","oxlint"],"backgroundTag":"continue-statement","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}