-
-
Notifications
You must be signed in to change notification settings - Fork 760
feat(lint): implement noContinue
#7856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 40bfcfe The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughAdds a changeset entry for the package @biomejs/biome. Introduces a new JavaScript lint rule Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (3)
crates/biome_rule_options/src/no_continue.rs (1)
1-6: Looks solid; please add inline rustdoc for options.Derives and serde attributes are spot‑on. Add a brief rustdoc explaining the rule and that there are currently no options.
Apply:
+/// Options for the `noContinue` rule. +/// +/// This rule disallows the `continue` statement in iteration constructs. +/// Currently, this rule has no configuration options. pub struct NoContinueOptions {}As per coding guidelines.
crates/biome_js_analyze/tests/specs/nursery/noContinue/invalid.js (1)
1-4: Broaden invalid coverage to tricky control‑flow corners.Nice spread. Add a few gotchas to harden the rule:
do…whilewithcontinue.for…ofandfor…in.continueinside aswitchnested within a loop.- Nested loops with an outer label target.
Example additions:
do { if (cond) { continue; } } while (cond2); for (const x of xs) { if (x) { continue; } } for (const k in obj) { if (k === 'x') { continue; } } outer: for (let i = 0; i < 3; i++) { for (let j = 0; j < 3; j++) { if (j === 1) { continue outer; } } } while (true) { switch (state) { case 0: if (ok) { continue; } // continues the loop break; } break; }crates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js (1)
1-3: Add positive examples mirroring edge cases withoutcontinue.To mirror the new invalids, add structured alternatives:
let i = 0; do { if (!cond) { /* work */ } i++; } while (i < n); for (const x of xs) { if (!x) { /* work */ } } for (const k in obj) { if (k !== 'x') { /* work */ } } outer: for (let i = 0; i < 3; i++) { for (let j = 0; j < 3; j++) { if (j !== 1) { /* work */ } } }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**crates/biome_js_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_js_analyze/tests/specs/nursery/noContinue/invalid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (6)
.changeset/yellow-crews-guess.md(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_continue.rs(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noContinue/invalid.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js(1 hunks)crates/biome_rule_options/src/lib.rs(1 hunks)crates/biome_rule_options/src/no_continue.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_rule_options/src/lib.rscrates/biome_js_analyze/src/lint/nursery/no_continue.rscrates/biome_rule_options/src/no_continue.rscrates/biome_js_analyze/tests/specs/nursery/noContinue/invalid.jscrates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Format Rust files before committing (e.g., viajust fwhich formats Rust)
Document rules, assists, and options with inline rustdoc in source
Files:
crates/biome_rule_options/src/lib.rscrates/biome_js_analyze/src/lint/nursery/no_continue.rscrates/biome_rule_options/src/no_continue.rs
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rscrates/biome_js_analyze/tests/specs/nursery/noContinue/invalid.jscrates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js
.changeset/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/*.md: In changesets, only use #### or ##### headers; other header levels are not allowed
Changesets should cover user-facing changes only; internal changes do not need changesets
Use past tense for what you did and present tense for current Biome behavior in changesets
When fixing a bug in a changeset, start with an issue link (e.g., “Fixed #1234: …”)
When referencing a rule or assist in a changeset, include a link to its page on the website
Include code blocks in changesets when applicable to illustrate changes
End every sentence in a changeset with a period
Files:
.changeset/yellow-crews-guess.md
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_js_analyze/tests/specs/nursery/noContinue/invalid.jscrates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js
🧠 Learnings (6)
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Place per-rule options types in biome_rule_options crate under lib/, one file per rule
Applied to files:
crates/biome_rule_options/src/lib.rscrates/biome_rule_options/src/no_continue.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : In declare_lint_rule! macros, set version: "next"
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/lint/nursery/**/*.rs : Place all new rules in the nursery group
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : Set the language field in declare_lint_rule! to the most appropriate dialect (js/jsx/ts/tsx)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : Derive Serialize, Deserialize, and Deserializable for rule options; add #[serde(rename_all = "camelCase", deny_unknown_fields, default)]
Applied to files:
crates/biome_rule_options/src/no_continue.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/**/*.rs : When schema feature is enabled, derive schemars::JsonSchema for options and related enums
Applied to files:
crates/biome_rule_options/src/no_continue.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/no_continue.rs (1)
crates/biome_analyze/src/rule.rs (3)
recommended(595-598)sources(610-613)same(246-251)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Documentation
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Validate rules documentation
- GitHub Check: autofix
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Test Node.js API
🔇 Additional comments (1)
crates/biome_js_analyze/src/lint/nursery/no_continue.rs (1)
59-63: No issues found—implementation is correct.
NoContinueOptionsis an empty struct with no fields, so therunmethod correctly returnsSome(())unconditionally. The rule should flag allcontinuestatements, which matches ESLint's no-continue behaviour. No configuration checks are needed.Likely an incorrect or invalid review comment.
CodSpeed Performance ReportMerging #7856 will not alter performanceComparing Summary
Footnotes
|
4241018 to
e519896
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
.changeset/yellow-crews-guess.md (1)
5-5: URL slug and tense issues already flagged.The past review comment comprehensively covers the required corrections (camelCase URL and tense consistency).
🧹 Nitpick comments (1)
crates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js (1)
1-3: Consider expanding test coverage with additional valid scenarios.The current test cases correctly demonstrate valid patterns without
continue. Consider optionally adding:
- Code with
breakstatements (to confirm they're allowed)- Nested loops
- Other loop types (for-of, for-in, do-while)
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (8)
crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rsis excluded by!**/migrate/eslint_any_rule_to_biome.rsand included by**crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**crates/biome_js_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_js_analyze/tests/specs/nursery/noContinue/invalid.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js.snapis excluded by!**/*.snapand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**packages/@biomejs/biome/configuration_schema.jsonis excluded by!**/configuration_schema.jsonand included by**
📒 Files selected for processing (6)
.changeset/yellow-crews-guess.md(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_continue.rs(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noContinue/invalid.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js(1 hunks)crates/biome_rule_options/src/lib.rs(1 hunks)crates/biome_rule_options/src/no_continue.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- crates/biome_rule_options/src/lib.rs
- crates/biome_js_analyze/tests/specs/nursery/noContinue/invalid.js
- crates/biome_rule_options/src/no_continue.rs
🧰 Additional context used
📓 Path-based instructions (5)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_js_analyze/tests/specs/nursery/noContinue/valid.jscrates/biome_js_analyze/src/lint/nursery/no_continue.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/tests/specs/nursery/noContinue/valid.jscrates/biome_js_analyze/src/lint/nursery/no_continue.rs
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_js_analyze/tests/specs/nursery/noContinue/valid.js
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Format Rust files before committing (e.g., viajust fwhich formats Rust)
Document rules, assists, and options with inline rustdoc in source
Files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
.changeset/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/*.md: In changesets, only use #### or ##### headers; other header levels are not allowed
Changesets should cover user-facing changes only; internal changes do not need changesets
Use past tense for what you did and present tense for current Biome behavior in changesets
When fixing a bug in a changeset, start with an issue link (e.g., “Fixed #1234: …”)
When referencing a rule or assist in a changeset, include a link to its page on the website
Include code blocks in changesets when applicable to illustrate changes
End every sentence in a changeset with a period
Files:
.changeset/yellow-crews-guess.md
🧠 Learnings (1)
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : In declare_lint_rule! macros, set version: "next"
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/no_continue.rs (2)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoContinueOptions(8248-8248)crates/biome_analyze/src/rule.rs (3)
recommended(595-598)sources(610-613)same(246-251)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: Documentation
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: End-to-end tests
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Check JS Files
- GitHub Check: Test Node.js API
- GitHub Check: autofix
- GitHub Check: Bench (biome_configuration)
🔇 Additional comments (3)
crates/biome_js_analyze/src/lint/nursery/no_continue.rs (3)
1-8: LGTM!Imports are appropriate and correctly scoped for the rule implementation.
9-53: Well-documented rule with correct configuration.The rule declaration follows all guidelines. Version "next", ESLint source attribution, and comprehensive rustdoc examples are all correct. Based on learnings.
55-80: LGTM!The
Ruleimplementation correctly flags allcontinuestatements. The diagnostic message is clear, and the explanatory note provides appropriate rationale.
ematipico
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't believe there's a lint rule like this one. continue is so useful!
Left some comments to address
| type Options = NoContinueOptions; | ||
|
|
||
| fn run(_ctx: &RuleContext<Self>) -> Self::Signals { | ||
| Some(()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we check if this is inside a loop? That's what the docs say
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhm, the source code of Eslint doesn't either 🤔.
Could also be confusing to use in switch statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, the docs and the rule must match. Docs are usually in higher order, and the code follows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add a mention of switch statements in the docs :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, what am I saying lol. Switch statements don't use continue 🤦, confused with break for a sec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The continue statement is only valid syntax in a loop to begin with
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/no_continue.rs (1)
75-77: Consider shortening the diagnostic note.The note addresses the previous feedback about fix guidance, but it's quite verbose. Since the explanation is already in the rule docs, you could simplify to just the actionable bit:
-.note(markup! { - "The continue statement terminates execution of the statements in the current 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." -}) +.note(markup! { + "Use structured control flow statements such as if instead." +})
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.changeset/yellow-crews-guess.md(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_continue.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- .changeset/yellow-crews-guess.md
🧰 Additional context used
📓 Path-based instructions (3)
crates/biome_*_{syntax,parser,formatter,analyze,factory,semantic}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Maintain the per-language crate structure: biome_{lang}_{syntax,parser,formatter,analyze,factory,semantic}
Files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Format Rust files before committing (e.g., viajust fwhich formats Rust)
Document rules, assists, and options with inline rustdoc in source
Files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
🧠 Learnings (3)
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : In declare_lint_rule! macros, set version: "next"
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/lint/nursery/**/*.rs : Place all new rules in the nursery group
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
📚 Learning: 2025-10-24T21:24:58.631Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-24T21:24:58.631Z
Learning: Applies to crates/biome_analyze/crates/*_analyze/**/src/**/lint/**/*.rs : Rule names should use no<Concept> when forbidding a single concept (e.g., noDebugger)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_continue.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/no_continue.rs (2)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoContinueOptions(8248-8248)crates/biome_analyze/src/rule.rs (3)
recommended(595-598)sources(610-613)same(246-251)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Test Node.js API
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Documentation
- GitHub Check: Check Dependencies
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Check JS Files
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: autofix
🔇 Additional comments (3)
crates/biome_js_analyze/src/lint/nursery/no_continue.rs (3)
1-7: Imports look good.All imports are properly used in the implementation.
9-53: Excellent documentation and metadata.The rule documentation is clear and comprehensive. Metadata follows all conventions:
version: "next",noContinuenaming pattern, and correct source attribution. The examples effectively demonstrate the rule's intent.
61-63: No loop check needed—parser handles this.Your response to the previous review is spot-on. The JavaScript parser only produces
JsContinueStatementnodes when they're syntactically valid (i.e., inside loops). Any misplacedcontinuewould be a parse error, not an analysis concern.
.changeset/yellow-crews-guess.md
Outdated
| "@biomejs/biome": patch | ||
| --- | ||
|
|
||
| Added the nursery rule [`noContinue`](https://biomejs.dev/linter/rules/no-continue/). It disallows the use of the `continue` statement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approved it, but it would be nice to reword the changeset to explain better the rule, maybe with a snippet that triggers the rule
Summary
Port Eslint's
no-continueTest Plan
Docs