-
-
Notifications
You must be signed in to change notification settings - Fork 781
feat(lint): implement noEmptySource
#7715
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: c152ae4 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 |
CodSpeed Performance ReportMerging #7715 will not alter performanceComparing Summary
Footnotes
|
WalkthroughAdds a new nursery lint rule Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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: 4
🧹 Nitpick comments (6)
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs (2)
113-131: Prefer .any() over .filter().count() > 0 (short‑circuit and clearer)Micro-optimisation and readability win.
- if node - .items() - .iter() - .filter(|i| { - let Some(body) = i.as_any_js_statement() else { - return true; - }; - - return match body { - AnyJsStatement::JsEmptyStatement(_) => false, - AnyJsStatement::JsBlockStatement(block) => block.statements().len() > 0, - _ => true, - }; - }) - .count() - > 0 - { + if node.items().iter().any(|i| { + if let Some(body) = i.as_any_js_statement() { + match body { + AnyJsStatement::JsEmptyStatement(_) => false, + AnyJsStatement::JsBlockStatement(block) => block.statements().len() > 0, + _ => true, + } + } else { + // imports/exports and other non-statements are meaningful + true + } + }) { return None; }
151-152: Polish the diagnostic note (grammar)Small tweak for readability.
- "A higher amount of files can increase the cognitive load, deleting empty files can help reducing this load." + "A higher number of files can increase cognitive load; deleting empty files can help reduce it."crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs (2)
7-33: Document the rule options here as well (or note N/A for JSON)For consistency, add an Options section (even if JSON has no comments and the option is effectively N/A). As per coding guidelines.
61-63: Polish the diagnostic note (grammar)Same tweak as in the JS rule.
- "A higher amount of files can increase the cognitive load, deleting empty files can help reducing this load." + "A higher number of files can increase cognitive load; deleting empty files can help reduce it."crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs (1)
72-72: Simplify to.len().The
.iter()call is unnecessary;AstNodeListprovides.len()directly.Apply this diff:
- if node.rules().iter().len() > 0 { + if node.rules().len() > 0 {crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs (1)
73-73: Simplify to.len().Same as the CSS version: the
.iter()call is unnecessary.Apply this diff:
- if node.definitions().iter().len() > 0 { + if node.definitions().len() > 0 {
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (29)
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_css_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.css.snapis excluded by!**/*.snapand included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**crates/biome_graphql_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphql.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.js.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/invalid.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/valid.json.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 (24)
.changeset/every-states-sort.md(1 hunks)crates/biome_css_analyze/src/lint.rs(1 hunks)crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs(1 hunks)crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.css(1 hunks)crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.css(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs(1 hunks)crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.graphql(1 hunks)crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphql(1 hunks)crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphql(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.js(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/valid.json(1 hunks)crates/biome_rule_options/src/lib.rs(1 hunks)crates/biome_rule_options/src/no_empty_file.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
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_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.graphqlcrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.jscrates/biome_css_analyze/src/lint.rscrates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.csscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.jscrates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.jscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphqlcrates/biome_css_analyze/src/lint/nursery/no_empty_file.rscrates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphqlcrates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.csscrates/biome_json_analyze/tests/specs/nursery/noEmptyFile/valid.jsoncrates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.graphqlcrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.jscrates/biome_rule_options/src/lib.rscrates/biome_css_analyze/src/lint.rscrates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.csscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.jscrates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.jscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphqlcrates/biome_css_analyze/src/lint/nursery/no_empty_file.rscrates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphqlcrates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.csscrates/biome_json_analyze/tests/specs/nursery/noEmptyFile/valid.jsoncrates/biome_rule_options/src/no_empty_file.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js
**/tests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place test files under a tests/ directory in each crate
Files:
crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.graphqlcrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.jscrates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.csscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.jscrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.jscrates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphqlcrates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphqlcrates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.csscrates/biome_json_analyze/tests/specs/nursery/noEmptyFile/valid.jsoncrates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js
.changeset/**/*.md
📄 CodeRabbit inference engine (CONTRIBUTING.md)
.changeset/**/*.md: Create changesets using thejust new-changesetcommand; do not author them manually
In changeset markdown, only use headers #### or #####
Changeset descriptions must end every sentence with a full stop (.)
For bug fixes, start the changeset description with a linked issue reference like “Fixed #1234”
Prefer past tense for what was done and present tense for current behavior in changesets
Files:
.changeset/every-states-sort.md
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_rule_options/src/lib.rscrates/biome_css_analyze/src/lint.rscrates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_css_analyze/src/lint/nursery/no_empty_file.rscrates/biome_rule_options/src/no_empty_file.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_rule_options/src/lib.rscrates/biome_css_analyze/src/lint.rscrates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_css_analyze/src/lint/nursery/no_empty_file.rscrates/biome_rule_options/src/no_empty_file.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs
🧠 Learnings (11)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
.changeset/every-states-sort.mdcrates/biome_css_analyze/src/lint.rscrates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : In declare_lint_rule! blocks, set version: "next" for all rules
Applied to files:
crates/biome_css_analyze/src/lint.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Avoid deep indentation by using combinators like map/filter/and_then instead of unwrap/expect chains
Applied to files:
crates/biome_css_analyze/src/lint.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : If a rule returns a code action, add fix_kind in declare_lint_rule! and ensure action uses ctx.action_category(ctx.category(), ctx.group()) and ctx.metadata().applicability()
Applied to files:
crates/biome_css_analyze/src/lint.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Set the language field in declare_lint_rule! to the primary dialect (js, jsx, ts, tsx) appropriate for the rule
Applied to files:
crates/biome_css_analyze/src/lint.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : In documentation code blocks: specify a language; mark invalid examples with expect_diagnostic (exactly one diagnostic per snippet); valid examples must parse with no diagnostics; order modifiers consistently; use options/full_options/use_options where applicable
Applied to files:
crates/biome_css_analyze/src/lint.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : When banning globals (e.g., console), consult the semantic model to avoid flagging locally shadowed variables
Applied to files:
crates/biome_css_analyze/src/lint.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/tests/specs/nursery/** : Place snapshot tests for new rules under tests/specs/nursery/<ruleName>/ with files prefixed by invalid* and valid*
Applied to files:
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/*.rs : Define per-rule options in biome_rule_options/lib/<rule>.rs with a dedicated options struct/enum (camelCase serde names, deny_unknown_fields, default) and derive Serialize/Deserialize/Deserializable (and schemars JsonSchema when schema feature is on)
Applied to files:
crates/biome_rule_options/src/no_empty_file.rs
🧬 Code graph analysis (9)
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js (2)
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js (1)
x(3-3)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js (1)
x(3-3)
crates/biome_css_analyze/src/lint.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
Nursery(1627-1776)
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js (2)
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js (1)
x(3-3)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js (1)
x(2-2)
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptyFileOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs (2)
run(70-85)diagnostic(87-101)crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs (2)
run(41-49)diagnostic(51-65)
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js (2)
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js (1)
x(3-3)crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js (1)
x(2-2)
crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptyFileOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs (2)
run(70-85)diagnostic(87-101)crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs (2)
run(110-138)diagnostic(140-154)
crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptyFileOptions(8203-8208)crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs (2)
run(70-85)diagnostic(87-101)crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs (2)
run(110-138)diagnostic(140-154)crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs (2)
run(41-49)diagnostic(51-65)
crates/biome_rule_options/src/no_empty_file.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptyFileOptions(8203-8208)
crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptyFileOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs (2)
run(69-81)diagnostic(83-97)crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs (2)
run(110-138)diagnostic(140-154)crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs (2)
run(41-49)diagnostic(51-65)
⏰ 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). (19)
- GitHub Check: Test Node.js API
- GitHub Check: Documentation
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Check Dependencies
- GitHub Check: Check JS Files
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: autofix
🔇 Additional comments (20)
.changeset/every-states-sort.md (1)
1-5: LGTM!The changeset follows the required conventions: ends with a full stop, has appropriate patch-level change, and clearly describes the new nursery rule.
crates/biome_css_analyze/src/lint.rs (1)
8-11: LGTM!Correctly wires the nursery module into the CSS lint category declaration, matching the pattern used in other language analyzers.
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.js (1)
1-1: Verify directive-only files should be flagged as empty.Confirm that a file containing only
'use strict';should trigger the noEmptyFile diagnostic. This seems reasonable (directives alone don't add meaningful code), but ensure it aligns with the rule's design intent and matches ESLint Unicorn's behaviour.crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphql (1)
1-2: LGTM!A fragment definition is meaningful GraphQL content, so this test correctly belongs in the valid/ directory.
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.js (1)
1-2: LGTM!An empty block statement alone is meaningless, so correctly placed in invalid/.
crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.graphql (1)
1-1: LGTM!A comment-only GraphQL file should be flagged as empty (when the
commentsoption is true, which is the default), so this test is correctly placed in invalid/.crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.js (1)
1-3: LGTM!A JSDoc-only file contains no executable code, so correctly belongs in invalid/.
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js (1)
1-1: LGTM!A lone semicolon is an empty statement with no meaningful content, so correctly placed in invalid/.
crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.js (1)
1-1: All good—fixture captures the hashbang edge case. Nicely done.crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js (1)
1-1: Looks right for the comment-only failure case. Thanks for covering it.crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.css (1)
1-1: CSS counterpart checks out. Happy to see the parity.crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js (1)
1-3: Directive-plus-code fixture looks perfect. Exactly the scenario we needed.crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.js (1)
1-2: Happy with this plain var case. Simple and effective.crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js (1)
1-2: Nice touch including the stray empty statement. This will keep the rule honest.crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.css (1)
1-2: Selector fixture fits the bill. Thanks for mirroring the behaviour.crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphql (1)
1-2: GraphQL variant looks spot on. Appreciated the cross-language guard.crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js (1)
1-4: Looks goodCovers a meaningful block so the rule should stay quiet.
crates/biome_rule_options/src/lib.rs (1)
70-70: Module export LGTMPublicly exposing no_empty_file is correct and in the right spot.
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs (1)
133-135: Confirm comment detection when options.comments is falseJS uses has_comments_direct() on the root, while GraphQL checks EOF token comments. Please verify that a file with only comments and options.comments=false is treated as non-empty (no diagnostic). If not, consider aligning with the EOF token approach.
Do you want me to add a small test fixture for this option?
crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs (1)
77-82: Confirm GraphQL comment-detection approach
GraphQL useseof_token.has_leading_comments() || eof_token.has_trailing_comments(), whereas CSS/JS rely onnode.syntax().has_comments_direct(). Ensure the EOF-token check catches comments in all positions (top-of-file, inline) or switch tosyntax().has_comments_direct()for consistency.
0c9a0ba to
843a560
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: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (14)
crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.css.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.graphql.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.js.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/invalid.json.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 (5)
crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs(1 hunks)crates/biome_rule_options/src/no_empty_file.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- crates/biome_rule_options/src/no_empty_file.rs
- crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs
🧰 Additional context used
📓 Path-based instructions (4)
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_empty_file.rscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rscrates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : In declare_lint_rule! blocks, set version: "next" for all rules
Applied to files:
crates/biome_json_analyze/src/lint/nursery/no_empty_file.rscrates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : When deprecating a rule, add deprecated: "<reason>" in declare_lint_rule! with an explanatory message
Applied to files:
crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
🧬 Code graph analysis (3)
crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptyFileOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs (2)
run(70-82)diagnostic(84-98)crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs (2)
run(41-49)diagnostic(51-65)
crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptyFileOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs (2)
run(110-132)diagnostic(134-148)
crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptyFileOptions(8203-8208)crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs (2)
run(110-132)diagnostic(134-148)crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs (2)
run(41-49)diagnostic(51-65)
⏰ 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). (19)
- GitHub Check: Check JS Files
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Check Dependencies
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: autofix
|
I'd prefer |
Makes sense, unless others have objections / remarks :) |
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: 1
🧹 Nitpick comments (1)
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (1)
56-61: Consider adding sources annotation.Whilst there's no direct GraphQL equivalent, you could reference the inspiration using
.inspired()to acknowledge the source rules from other ecosystems.If desired, apply this diff:
+use biome_analyze::{Ast, Rule, RuleDiagnostic, RuleSource, context::RuleContext, declare_lint_rule}; -use biome_analyze::{Ast, Rule, RuleDiagnostic, context::RuleContext, declare_lint_rule};pub NoEmptySource { version: "next", name: "noEmptySource", language: "graphql", + sources: &[RuleSource::Stylelint("no-empty-source").inspired()], recommended: false, }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (29)
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_css_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.css.snapis excluded by!**/*.snapand included by**crates/biome_diagnostics_categories/src/categories.rsis excluded by!**/categories.rsand included by**crates/biome_graphql_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/query.graphql.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/block-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/directive.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/var.js.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/src/lint/nursery.rsis excluded by!**/nursery.rsand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid.json.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 (23)
.changeset/every-states-sort.md(1 hunks)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css(1 hunks)crates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.css(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql(1 hunks)crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphql(1 hunks)crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/query.graphql(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/block-statement.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/directive.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.js(1 hunks)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/var.js(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid.json(1 hunks)crates/biome_rule_options/src/lib.rs(1 hunks)crates/biome_rule_options/src/no_empty_source.rs(1 hunks)
✅ Files skipped from review due to trivial changes (11)
- crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js
- crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css
- crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js
- crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/var.js
- crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js
- crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid.json
- crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js
- crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql
- crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/query.graphql
- crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/directive.js
- crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js
🚧 Files skipped from review as they are similar to previous changes (1)
- .changeset/every-states-sort.md
🧰 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/noEmptySource/valid/block-statement.jscrates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.csscrates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.jscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphqlcrates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.jscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/block-statement.jscrates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.csscrates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.jscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_rule_options/src/no_empty_source.rscrates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphqlcrates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.jscrates/biome_rule_options/src/lib.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.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/noEmptySource/valid/block-statement.jscrates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.csscrates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.jscrates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphqlcrates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.js
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_rule_options/src/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_rule_options/src/lib.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_rule_options/src/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_rule_options/src/lib.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/*.rs : Define per-rule options in biome_rule_options/lib/<rule>.rs with a dedicated options struct/enum (camelCase serde names, deny_unknown_fields, default) and derive Serialize/Deserialize/Deserializable (and schemars JsonSchema when schema feature is on)
Applied to files:
crates/biome_rule_options/src/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (7)
crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/block-statement.js (2)
crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/directive.js (1)
x(3-3)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.js (1)
x(2-2)
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(41-49)diagnostic(51-65)
crates/biome_rule_options/src/no_empty_source.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(41-49)diagnostic(51-65)
crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.js (2)
crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/block-statement.js (1)
x(3-3)crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/directive.js (1)
x(3-3)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (5)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_analyze/src/rule.rs (3)
sources(576-579)same(244-249)recommended(561-564)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(41-49)diagnostic(51-65)
⏰ 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). (19)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: autofix
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Documentation
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: Check JS Files
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_js_parser)
🔇 Additional comments (13)
crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.js (1)
1-2: LGTM!Valid test case: empty statements followed by a real declaration correctly passes the rule.
crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js (1)
1-3: LGTM!Correct invalid test case: JSDoc comment alone should trigger the rule with default options.
crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/block-statement.js (1)
1-4: LGTM!Valid test case: block statement with content correctly passes the rule.
crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphql (1)
1-2: LGTM!Valid GraphQL test case: fragment definition correctly passes the rule.
crates/biome_rule_options/src/lib.rs (1)
72-72: LGTM!Module declaration correctly added in alphabetical order.
crates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.css (1)
1-2: LGTM!Valid CSS test case: class selector (even with empty body) correctly passes the rule.
crates/biome_rule_options/src/no_empty_source.rs (1)
1-15: LGTM!Options type correctly implements best practices: camelCase serde names, deny_unknown_fields, default implementation, and optional schema support. The doc comment on line 7 correctly spells "Whether" (past review comment appears outdated).
Based on learnings.
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (3)
113-123: Directive handling is correct.The past review concern about directives appears invalid. Directives are in
node.directives(), notnode.items(), so a file with only directives would have an emptyitems()iterator, causingany(...)to return false and the rule to correctly fire. The logic is sound.
127-129: LGTM!Comment handling correctly respects the
commentsoption: when false, files with comments are treated as non-empty.
10-102: Well-documented rule.Comprehensive documentation with clear examples of invalid (empty) and valid (non-empty) cases, plus options explanation. Nice work!
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (1)
1-98: LGTM!The CSS implementation correctly references Stylelint's
no-empty-sourceas the source rule, handles the comments option appropriately, and provides clear documentation with examples.crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (1)
41-49: Comments option correctly omitted for JSON.The maintainer clarified that JSON doesn't allow comments before/after the root node, so not checking the comments option here is appropriate.
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (1)
70-82: LGTM!The run logic correctly checks for definitions and honours the comments option appropriately.
noEmptySourcenoEmptySource
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 (2)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
114-114: Consider renamingbodytostatementfor clarity.The variable receives the result of
as_any_js_statement(), sostatementwould more accurately reflect its type.Apply this diff:
- let Some(body) = i.as_any_js_statement() else { + let Some(statement) = i.as_any_js_statement() else { return true; }; - match body { + match statement { AnyJsStatement::JsEmptyStatement(_) => false,
113-125: [done]
- Verified that
invalid/directive.jsandinvalid/hashbang.jsexist in the test suite.- No further verification needed.
No changes required for directive/hashbang handling
Test fixturesinvalid/directive.jsandinvalid/hashbang.jsalready cover these cases, so the lint correctly emits diagnostics.
Optional: renamebodytostatementat line 114 for clarity.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
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_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.209Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.209Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(41-49)diagnostic(51-65)
⏰ 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). (21)
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: autofix
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Documentation
- GitHub Check: Bench (biome_js_parser)
- 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: Bench (biome_js_analyze)
- GitHub Check: Check JS Files
🔇 Additional comments (2)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
127-129: LGTM!The comments option logic correctly handles both cases: when
comments: true(default), files with only comments trigger the diagnostic; whencomments: false, comments mark the file as non-empty.
134-148: LGTM!The diagnostic message is clear and the note helpfully explains the rationale for the rule. Implementation is consistent with the CSS, GraphQL and JSON analysers.
| /// ```json,options | ||
| /// { | ||
| /// "options": { | ||
| /// "comments": true | ||
| /// } | ||
| /// } | ||
| /// ``` |
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.
If the default is true, it means that the previous example already runs with the default value. maybe we should show an example when the value is false too
| }, | ||
| ) | ||
| .note(markup! { | ||
| "Empty files can clutter the codebase & increase cognitive load; deleting empty files can help reduce it." |
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.
| "Empty files can clutter the codebase & increase cognitive load; deleting empty files can help reduce it." | |
| "Empty files can clutter the codebase and increase cognitive load; deleting empty files can help reduce it." |
Please apply this suggestion to all rules
| use biome_rule_options::no_empty_source::NoEmptySourceOptions; | ||
|
|
||
| declare_lint_rule! { | ||
| /// Disallow empty files. |
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.
We should update the docs and diagnostics to say "source" instead of "file", for all rules
| /// ```json | ||
| /// { } | ||
| /// ``` | ||
| /// |
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.
Options are missing
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.
Yeah as I initially thought jsonc didn't allow rootnode comments, I didn't add an options section for json. But added now that you mention it is supported
e850cdd to
da9ce7e
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)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (1)
69-77: Fix ordering: honourcommentsoption for comment‑only JSON/JSONC.Empty roots return before checking options, so files with only comments still get flagged when
comments: false. Check comments inside the empty-root branch.- if node.value().ok().is_none() { - return Some(()); - } - - if !ctx.options().comments && node.syntax().has_comments_direct() { - return None; - } - - None + if node.value().ok().is_none() { + if !ctx.options().comments && node.syntax().has_comments_direct() { + return None; + } + return Some(()); + } + + None
🧹 Nitpick comments (4)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (1)
90-92: Tiny wording nit: plural “sources”.Use “empty sources” for consistency with the opening sentence.
- "Empty sources can clutter the codebase & increase cognitive load; deleting empty source can help reduce it." + "Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it."crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (1)
144-146: Tiny wording nit: plural “sources”.Align phrasing with the rule name.
- "Empty sources can clutter the codebase & increase cognitive load; deleting empty source can help reduce it." + "Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it."crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
50-52: Options example should not expect a diagnostic.With
"comments": false, comment‑only CSS should be valid. Dropexpect_diagnostichere.- /// ```css,expect_diagnostic + /// ```css /// /* Only comments */ /// ```
93-95: Tiny wording nit: plural “sources”.Match the rule’s terminology.
- "Empty sources can clutter the codebase & increase cognitive load; deleting empty source can help reduce it." + "Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it."
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (14)
crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/empty.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (6)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json
- crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
🧰 Additional context used
📓 Path-based instructions (4)
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_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (3)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (5)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_analyze/src/rule.rs (3)
sources(576-579)same(244-249)recommended(561-564)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(66-78)diagnostic(80-94)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (5)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_analyze/src/rule.rs (3)
sources(576-579)same(244-249)recommended(561-564)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(66-78)diagnostic(80-94)
⏰ 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). (19)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check JS Files
- GitHub Check: Documentation
- GitHub Check: Check Dependencies
- GitHub Check: autofix
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_css_parser)
🔇 Additional comments (1)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (1)
110-132: Rule logic LGTM.Accurately classifies empty vs meaningful items; options handling matches other languages.
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: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (17)
crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/empty.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json.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)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
- crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json
- crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
- crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
- crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc
🧰 Additional context used
📓 Path-based instructions (4)
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_json_analyze/src/lint/nursery/no_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (1)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)
⏰ 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). (20)
- GitHub Check: Test Node.js API
- GitHub Check: Documentation
- GitHub Check: Test (depot-windows-2022-16)
- 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: Check Dependencies
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Check JS Files
🔇 Additional comments (3)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (3)
1-5: Imports look good.Standard Biome rule imports are all present and follow the established patterns from other analyzers.
7-58: Documentation is clear and thorough.The inline examples effectively demonstrate both invalid cases (empty file, comments-only file) and valid cases, and the options documentation is helpful.
80-94: Diagnostic message is consistent and clear.The diagnostic matches the other language implementations and provides helpful context about why empty sources should be avoided.
1d7f66f to
b94a3dd
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
🧹 Nitpick comments (3)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (1)
90-92: Tiny wording nit in diagnostic note.Pluralise “source” for consistency/readability.
- "Empty sources can clutter the codebase and increase cognitive load; deleting empty source can help reduce it." + "Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it."crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (1)
144-146: Tiny wording nit in diagnostic note.Pluralise “source”.
- "Empty sources can clutter the codebase and increase cognitive load; deleting empty source can help reduce it." + "Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it."crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (1)
94-96: Tiny wording nit in diagnostic note.Pluralise “source”.
- "Empty sources can clutter the codebase and increase cognitive load; deleting empty source can help reduce it." + "Empty sources can clutter the codebase and increase cognitive load; deleting empty sources can help reduce it."
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (17)
crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/empty.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json.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)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json
- crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc
- crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
🧰 Additional context used
📓 Path-based instructions (4)
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_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (3)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(66-78)diagnostic(80-94)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (5)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_analyze/src/rule.rs (3)
sources(576-579)same(244-249)recommended(561-564)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(66-78)diagnostic(80-94)
⏰ 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). (21)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Check JS Files
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Test Node.js API
- GitHub Check: Check Dependencies
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: autofix
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Documentation
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_json_parser)
🔇 Additional comments (3)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (1)
66-78: LGTM: empty/source and comments handling is correct.Logic mirrors CSS/GraphQL and honours the
commentsoption properly. Nice.crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (1)
70-82: LGTM: matches CSS/JSON behaviour and honours options.Definition and comments checks are spot on.
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (1)
5-5: Remove theJsModuleItemimport suggestion—there is no such enum inbiome_js_syntax.Likely an incorrect or invalid review comment.
b94a3dd to
3929d75
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
🧹 Nitpick comments (1)
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (1)
70-82: Logic correctly detects empty GraphQL sources.The implementation properly checks for definitions and handles the
commentsoption as expected: whencommentsistrue(default), comment-only sources are considered empty; whenfalse, they're valid.The pattern matches the CSS implementation for consistency.
Minor: Line 73 could use
!node.definitions().is_empty()instead oflen() > 0for more idiomatic Rust, though the current pattern matches the CSS implementation.- if node.definitions().len() > 0 { + if !node.definitions().is_empty() { return None; }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (17)
crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snapis excluded by!**/*.snapand included by**crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snapis excluded by!**/*.snapand included by**crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snapis excluded by!**/*.snapand included by**crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/empty.json.snapis excluded by!**/*.snapand included by**crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json.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)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc(1 hunks)crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc
- crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
- crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json
🧰 Additional context used
📓 Path-based instructions (4)
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_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (3)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(66-78)diagnostic(80-94)
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(66-78)diagnostic(80-94)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (1)
run(69-81)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (1)
run(70-82)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (1)
run(110-132)
⏰ 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). (21)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Check JS Files
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Documentation
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: autofix
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_graphql_parser)
🔇 Additional comments (14)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (5)
1-5: LGTM!The imports follow the standard pattern for lint rules and all dependencies are appropriately declared.
7-58: Excellent documentation.The rustdoc comprehensively covers the rule's behaviour, provides clear examples, and documents the
commentsoption with usage examples. Well done.
60-64: LGTM!The type declarations follow the standard pattern for lint rules with options.
66-78: Correct logic for honouring the comments option.The implementation properly checks for content presence before evaluating the comments option, matching the pattern used in the CSS and GraphQL implementations. Previous review concerns have been fully addressed.
80-94: LGTM!The diagnostic message is clear and the note provides helpful context about the rationale for the rule.
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (4)
1-5: Imports look good.All necessary dependencies are present and correctly scoped. The shared
NoEmptySourceOptionsensures consistency across language implementations.
7-62: Documentation is comprehensive and well-structured.The rule declaration follows all guidelines: one-line summary, clear examples (Invalid before Valid), and a detailed Options section. The metadata correctly positions this in the nursery group as non-recommended.
64-68: Type definitions are correct.The use of
Ast<GraphqlRoot>as the query type is appropriate for GraphQL sources, and the sharedNoEmptySourceOptionsmaintains consistency across language implementations.
84-98: Diagnostic message is clear and consistent.The error message and note match those in the CSS, JS, and JSON implementations, providing a uniform experience across all language analysers.
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (5)
9-102: Comprehensive documentation.The rule documentation is thorough with clear examples for both valid and invalid cases, and properly documents the
commentsoption. The use of "source" terminology aligns with the maintainer feedback.
127-129: LGTM!The comments option logic correctly allows comment-only sources when
commentsis set tofalse, matching the documented behaviour.
134-148: LGTM!The diagnostic correctly uses "source" terminology throughout and provides a helpful note explaining the rationale. Consistent with the CSS, GraphQL, and JSON implementations of this rule.
1-7: Directive handling is correct
JsModule::items()excludes directives—they’re accessed viadirectives(), so no extra import or filtering is required.
113-125: Handle directive-only filesNon-statement items (e.g. directives) in
node.items()are treated as meaningful, so a file with only a directive may bypass this rule. Confirm via the biome CLI that a directive-only file still emits the diagnostic; if it doesn’t, filter outJsModuleItem::JsDirective(_)in theitems()check or add an explicitnode.directives()guard.
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 (3)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (1)
40-51: The example doesn't demonstratecomments: falsebehaviour.The example at lines 48-50 shows an empty file with
comments: false, but this doesn't illustrate what the option does. A more informative example would show a file with only comments that passes validation whencomments: false:// Only a commentThis would make it clear that setting
comments: falseallows comment-only files.Apply this diff:
/// ```json,options /// { /// "options": { /// "comments": false /// } /// } /// ``` /// -/// ```jsonc,expect_diagnostic,use_options +/// ```jsonc,use_options +/// // Only a comment +/// ``` /// -/// ```crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (1)
83-93: Example doesn't illustratecomments: falseeffect.An empty file with
comments: falsestill triggers a diagnostic, which doesn't demonstrate what the option actually does. Show a comment-only file that passes whencomments: false:// Only commentsThis makes the option's purpose clear.
Apply this diff:
/// ```json,options /// { /// "options": { /// "comments": false /// } /// } /// ``` /// -/// ```js,expect_diagnostic,use_options +/// ```js,use_options +/// // Only comments +/// ``` /// -/// ```crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (1)
42-52: Example doesn't showcomments: falsein action.Same as the JSON and JS implementations: an empty file doesn't demonstrate what the option does. Show a file with only comments that's valid when
comments: false:/* Only comments */Apply this diff:
/// ```json,options /// { /// "options": { /// "comments": false /// } /// } /// ``` /// -/// ```css,expect_diagnostic,use_options +/// ```css,use_options +/// /* Only comments */ +/// ``` /// -/// ```
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
🧰 Additional context used
📓 Path-based instructions (4)
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_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (3)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(66-78)diagnostic(80-94)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(66-78)diagnostic(80-94)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(69-81)diagnostic(83-97)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(110-132)diagnostic(134-148)
⏰ 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). (21)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Check JS Files
- GitHub Check: Test Node.js API
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Documentation
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: autofix
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Check Dependencies
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_css_parser)
🔇 Additional comments (6)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
66-78: Logic correctly honours the comments option.The run method properly checks content presence first, then respects the comments option. The flow is correct and matches the pattern used in other language implementations.
80-94: Diagnostic message is clear and consistent.The diagnostic follows the established pattern across all implementations, providing a helpful explanation about cognitive load.
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
110-132: Logic correctly treats directives as empty content.The implementation properly checks for meaningful statements in
items()while ignoring directives (which are innode.directives()), aligning with the documented behaviour that directives count as empty.
134-148: Clear and consistent diagnostic.Message matches the pattern across all language implementations.
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
69-81: Straightforward and correct.The emptiness check and comments handling follow the established pattern perfectly.
83-97: Diagnostic message consistent across languages.Clear explanation that applies universally.
| /// ```json,options | ||
| /// { | ||
| /// "options": { | ||
| /// "comments": false |
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 have some thoughts about this configuration. The issue I see is that comments: false without documentation is very difficult to interpret. Even when you read the rule name, what does "comments: false" mean? Does it mean they are allowed or disallowed?
My suggestions are the following, and let me know what you think:
- rename the option to
allowComments/disallowComments - rework the docs, and explicitly say what the behaviour of the rule is when the other value (different from default) is. And the example should show it! In this example, you didn't show a snippet with comments, which fails to show the behaviour of the option
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 thought the example under options should be an invalid one. When comments are considered valid, then the only option is an empty file being an invalid state
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.
It can be valid, invalid or both. It really depends on what you're documenting and what you want to communicate. I just thought that since the option is allowing comments, at least an example should be a snippet where comments are allowed
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.
Should options perhaps also have clear Valid & Invalid headings? Like the examples above?
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.
It's an option! I'm not sure what it will look like. But remember we can't have duplicated headings in a page, because they come HTML IDs
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.
Starlight seems to add a -1 to the second header
9d846d2 to
3fa849c
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: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_rule_options/src/no_empty_source.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
🧰 Additional context used
📓 Path-based instructions (4)
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_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_rule_options/src/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_rule_options/src/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_rule_options/src/no_empty_source.rs
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_rule_options/lib/*.rs : Define per-rule options in biome_rule_options/lib/<rule>.rs with a dedicated options struct/enum (camelCase serde names, deny_unknown_fields, default) and derive Serialize/Deserialize/Deserializable (and schemars JsonSchema when schema feature is on)
Applied to files:
crates/biome_rule_options/src/no_empty_source.rs
🧬 Code graph analysis (4)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (3)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_analyze/src/rule.rs (2)
sources(576-579)same(244-249)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(72-84)diagnostic(86-100)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(111-133)diagnostic(135-149)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(72-84)diagnostic(86-100)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(111-133)diagnostic(135-149)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(67-79)diagnostic(81-95)
crates/biome_rule_options/src/no_empty_source.rs (1)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)
⏰ 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). (19)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Check Dependencies
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Documentation
- GitHub Check: Check JS Files
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: autofix
- GitHub Check: Bench (biome_configuration)
e6662cb to
07d6268
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
🧹 Nitpick comments (4)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (1)
41-51: Consider adding a valid example for theallowCommentsoption.The current example demonstrates that an empty file remains invalid even when
allowCommentsis true, which is correct. However, it would be helpful to also show a valid case: a file containing only comments that's considered valid whenallowCommentsis true.For instance, add after line 51:
/// ### Valid /// /// ```jsonc,use_options /// // Only comments /// ```This would clarify the option's effect more completely.
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (1)
84-94: Consider adding a valid example for theallowCommentsoption.Similar to the other language implementations, adding a valid case would improve clarity. Show a file with only comments being valid when
allowCommentsis true:/// ### Valid /// /// ```js,use_options /// // Only comments /// ```crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (1)
43-53: Consider adding a valid example for theallowCommentsoption.The documentation would benefit from showing a valid case where a comment-only file is permitted:
/// ### Valid /// /// ```css,use_options /// /* Only comments */ /// ```crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (1)
46-56: Consider adding a valid example for theallowCommentsoption.For consistency with the suggestion in other files, show a valid comment-only case:
/// ### Valid /// /// ```graphql,use_options /// # Only comments /// ```
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
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 (5)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_rule_options/src/no_empty_source.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/biome_rule_options/src/no_empty_source.rs
🧰 Additional context used
📓 Path-based instructions (4)
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_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rscrates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (4)
crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (3)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(111-133)diagnostic(135-149)
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(111-133)diagnostic(135-149)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(67-79)diagnostic(81-95)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (5)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_analyze/src/rule.rs (3)
sources(576-579)same(244-249)recommended(561-564)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(70-82)diagnostic(84-98)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(72-84)diagnostic(86-100)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(67-79)diagnostic(81-95)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(72-84)diagnostic(86-100)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(111-133)diagnostic(135-149)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(67-79)diagnostic(81-95)
⏰ 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). (21)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Check JS Files
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
- GitHub Check: Documentation
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test Node.js API
- GitHub Check: autofix
| /// Default `false` | ||
| /// | ||
| /// ```json,options | ||
| /// { | ||
| /// "options": { | ||
| /// "allowComments": true | ||
| /// } | ||
| /// } | ||
| /// ``` | ||
| /// | ||
| /// ```css,expect_diagnostic,use_options | ||
| /// | ||
| /// ``` |
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.
This example should show that comments are allowed more clearly. I would expect to see a valid example with a comment in it.
| /// ```json,options | ||
| /// { | ||
| /// "options": { | ||
| /// "allowComments": true | ||
| /// } | ||
| /// } | ||
| /// ``` | ||
| /// | ||
| /// ```graphql,expect_diagnostic,use_options | ||
| /// | ||
| /// ``` |
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.
same here
| /// ```json,options | ||
| /// { | ||
| /// "options": { | ||
| /// "allowComments": true | ||
| /// } | ||
| /// } | ||
| /// ``` | ||
| /// | ||
| /// ```js,expect_diagnostic,use_options | ||
| /// | ||
| /// ``` |
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.
same here
76ac789 to
dedd722
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: 1
🧹 Nitpick comments (1)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (1)
122-125: Non-statement handling could be more explicit.The
elsebranch treats all items that failas_any_js_statement()as non-empty by returningtrue. Whilst this is likely correct for imports, exports, and type declarations, consider adding a comment explaining this design decision, especially given the earlier confusion about directives.if node.items().iter().any(|i| { let Some(body) = i.as_any_js_statement() else { + // Non-statement items (imports, exports, declarations) make the file non-empty. + // Directives are in node.directives(), not items. return true; };
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
🧰 Additional context used
📓 Path-based instructions (4)
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_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rscrates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rscrates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (3)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(80-92)diagnostic(94-108)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(119-141)diagnostic(143-157)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(75-87)diagnostic(89-103)
crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(78-90)diagnostic(92-106)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (2)
run(119-141)diagnostic(143-157)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(75-87)diagnostic(89-103)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(78-90)diagnostic(92-106)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(80-92)diagnostic(94-108)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(75-87)diagnostic(89-103)
⏰ 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). (21)
- GitHub Check: Check JS Files
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Documentation
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Check Dependencies
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_configuration)
- GitHub Check: autofix
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_json_parser)
🔇 Additional comments (1)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (1)
1-107: LGTM!The CSS implementation is straightforward and correct. The logic properly checks for non-empty rule sets and respects the
allowCommentsoption.
| /// | ||
| /// #### Valid | ||
| /// | ||
| /// ```graphql,expect_diagnostic,use_options |
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.
Remove spurious expect_diagnostic from the valid example.
The valid example shouldn't expect a diagnostic. When allowComments is true, a comment-only source is valid and should not produce a diagnostic.
Apply this diff:
-/// ```graphql,expect_diagnostic,use_options
+/// ```graphql,use_options🤖 Prompt for AI Agents
In crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs around line
62, the valid example's code fence incorrectly includes "expect_diagnostic";
remove that token so the opening fence reads "```graphql,use_options" (and
ensure the corresponding closing ``` is present) so the example no longer
expects a diagnostic when allowComments is true.
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.
Sadly the parser will then throw an "Expected definition but instead found the end of the file."
dedd722 to
fe7ffca
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: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
- crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
- crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
- crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
🧰 Additional context used
📓 Path-based instructions (4)
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_empty_source.rs
crates/biome_*/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place core crates under /crates/biome_*/
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Before committing, format Rust and TOML files (e.g., via
just f/just format)
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Document rules, assists, and options via inline rustdoc in Rust source
Files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/biome_js_analyze/lib/src/lint/nursery/*.rs : Place all new JavaScript lint rules in the nursery group under biome_js_analyze/lib/src/lint/nursery/<rule_name>.rs
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: If porting a rule from another ecosystem, annotate sources in declare_lint_rule! (e.g., sources: &[RuleSource::Eslint("no-debugger").{same|inspired}()])
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
📚 Learning: 2025-10-02T12:57:33.228Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-10-02T12:57:33.228Z
Learning: Applies to crates/biome_analyze/crates/**/src/**/lint/**/*.rs : Document rules in the declare_lint_rule! doc comment with a one-line first paragraph, followed by sections including ## Examples, ### Invalid (first) and ### Valid, and optional ## Options
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
🧬 Code graph analysis (1)
crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs (4)
packages/@biomejs/backend-jsonrpc/src/workspace.ts (1)
NoEmptySourceOptions(8203-8208)crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs (2)
run(78-90)diagnostic(92-106)crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs (2)
run(80-92)diagnostic(94-108)crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs (2)
run(75-87)diagnostic(89-103)
⏰ 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). (22)
- GitHub Check: autofix
- GitHub Check: Check JS Files
- GitHub Check: Bench (biome_js_formatter)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_json_parser)
- GitHub Check: Test Node.js API
- GitHub Check: Bench (biome_json_formatter)
- GitHub Check: Bench (biome_css_parser)
- GitHub Check: Bench (biome_css_analyze)
- GitHub Check: Bench (biome_json_analyze)
- GitHub Check: Bench (biome_css_formatter)
- GitHub Check: Bench (biome_graphql_parser)
- GitHub Check: End-to-end tests
- GitHub Check: Bench (biome_configuration)
- GitHub Check: Bench (biome_graphql_formatter)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Documentation
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Check Dependencies
| match body { | ||
| AnyJsStatement::JsEmptyStatement(_) => false, | ||
| AnyJsStatement::JsBlockStatement(block) => block.statements().len() > 0, | ||
| _ => true, |
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.
Nested empty blocks slip through
Right now a JsBlockStatement counts as meaningful as soon as it contains anything, even another empty block or an empty statement. That means files such as {{}} or { ; } quietly return None, so the lint never fires despite the docs promising that empty block statements and empty statements are considered empty. Please walk nested blocks and only treat them as meaningful once you hit a genuinely non-empty statement.
+fn has_meaningful_statement(statement: &AnyJsStatement) -> bool {
+ match statement {
+ AnyJsStatement::JsEmptyStatement(_) => false,
+ AnyJsStatement::JsBlockStatement(block) => block
+ .statements()
+ .iter()
+ .filter_map(|stmt| AnyJsStatement::cast(stmt.syntax().clone()))
+ .any(|stmt| has_meaningful_statement(&stmt)),
+ _ => true,
+ }
+}
+
if node.items().iter().any(|i| {
let Some(body) = i.as_any_js_statement() else {
return true;
};
- match body {
- AnyJsStatement::JsEmptyStatement(_) => false,
- AnyJsStatement::JsBlockStatement(block) => block.statements().len() > 0,
- _ => true,
- }
+ has_meaningful_statement(&body)
}) {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| match body { | |
| AnyJsStatement::JsEmptyStatement(_) => false, | |
| AnyJsStatement::JsBlockStatement(block) => block.statements().len() > 0, | |
| _ => true, | |
| // Insert this helper (at file scope or above the rule’s run method) | |
| fn has_meaningful_statement(statement: &AnyJsStatement) -> bool { | |
| match statement { | |
| AnyJsStatement::JsEmptyStatement(_) => false, | |
| AnyJsStatement::JsBlockStatement(block) => block | |
| .statements() | |
| .iter() | |
| .filter_map(|stmt| AnyJsStatement::cast(stmt.syntax().clone())) | |
| .any(|stmt| has_meaningful_statement(&stmt)), | |
| _ => true, | |
| } | |
| } | |
| // … inside your run method, replace the inline match with: | |
| if node.items().iter().any(|i| { | |
| let Some(body) = i.as_any_js_statement() else { | |
| return true; | |
| }; | |
| has_meaningful_statement(&body) | |
| }) { | |
| // … | |
| } |
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.
Awesome!
Summary
Implement Eslint Unicon's
no-empty-file/ Stylelint'sno-empty-sourcefor js, css, json & graphql filesCloses #7697
Test Plan
Docs