Skip to content

Conversation

@Netail
Copy link
Member

@Netail Netail commented Oct 8, 2025

Summary

Implement Eslint Unicon's no-empty-file / Stylelint's no-empty-source for js, css, json & graphql files

Closes #7697

Test Plan

Docs

@changeset-bot
Copy link

changeset-bot bot commented Oct 8, 2025

🦋 Changeset detected

Latest commit: c152ae4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

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

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages L-CSS Language: CSS L-JSON Language: JSON and super languages A-Diagnostic Area: diagnostocis labels Oct 8, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Oct 8, 2025

CodSpeed Performance Report

Merging #7715 will not alter performance

Comparing Netail:feat/no-empty-file (c152ae4) with main (e5b8058)1

Summary

✅ 53 untouched
⏩ 85 skipped2

Footnotes

  1. No successful run was found on main (c7f9085) during the generation of this report, so e5b8058 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 85 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 8, 2025

Walkthrough

Adds a new nursery lint rule noEmptySource implemented for JS, CSS, JSON and GraphQL analyzers with Rule implementations, diagnostics, and tests. Adds NoEmptySourceOptions (field allow_comments: bool, serde/schemars support, Default) in crates/biome_rule_options and exposes no_empty_source module. Wires the Nursery group into lint category declarations. Adds a changelog entry for a patch release. No existing exported/public declarations were removed.

Possibly related PRs

  • feat: promote rules #7137 — Modifies lint grouping and nursery-related rule modules; strongly related due to changes in crates/*/src/lint.rs and nursery rule wiring.

Suggested reviewers

  • ematipico
  • dyc3
  • arendjr

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and concisely summarises the primary change, specifying the addition of the noEmptySource lint rule, which aligns precisely with the implemented feature in the changeset.
Linked Issues Check ✅ Passed The pull request fulfils the objectives of issue #7697 by porting the no-empty-source rule from Stylelint to Biome, implementing it across CSS, JavaScript, JSON, and GraphQL, and providing the expected rule options and diagnostics for empty sources.
Out of Scope Changes Check ✅ Passed All modifications—including rule implementations, tests, options, and the changelog—directly support the noEmptySource feature and there are no unrelated or out-of-scope changes in the pull request.
Description Check ✅ Passed The description directly relates to the changeset by outlining the implementation of the no-empty-source rule for multiple file types and references the linked issue, making it sufficiently on-topic despite the empty Test Plan section.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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; AstNodeList provides .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

📥 Commits

Reviewing files that changed from the base of the PR and between 3eeb4df and f822112.

⛔ Files ignored due to path filters (29)
  • crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs is excluded by !**/migrate/eslint_any_rule_to_biome.rs and included by **
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_css_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_graphql_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/invalid.json.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/valid.json.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and 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.graphql
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js
  • crates/biome_css_analyze/src/lint.rs
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.css
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.js
  • crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js
  • crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphql
  • crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphql
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.css
  • crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/valid.json
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs
  • crates/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.graphql
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_css_analyze/src/lint.rs
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.css
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.js
  • crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js
  • crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphql
  • crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphql
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.css
  • crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/valid.json
  • crates/biome_rule_options/src/no_empty_file.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_file.rs
  • crates/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.graphql
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/statement.js
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.css
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/var.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/block-statement.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.js
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/valid/directive.js
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/query.graphql
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/valid/fragment.graphql
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/valid/selector.css
  • crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/valid.json
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js
.changeset/**/*.md

📄 CodeRabbit inference engine (CONTRIBUTING.md)

.changeset/**/*.md: Create changesets using the just new-changeset command; 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.rs
  • crates/biome_css_analyze/src/lint.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_rule_options/src/no_empty_file.rs
  • crates/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.rs
  • crates/biome_css_analyze/src/lint.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_file.rs
  • crates/biome_rule_options/src/no_empty_file.rs
  • crates/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.md
  • crates/biome_css_analyze/src/lint.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_file.rs
  • crates/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 comments option 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 good

Covers a meaningful block so the rule should stay quiet.

crates/biome_rule_options/src/lib.rs (1)

70-70: Module export LGTM

Publicly 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 false

JS 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 uses eof_token.has_leading_comments() || eof_token.has_trailing_comments(), whereas CSS/JS rely on node.syntax().has_comments_direct(). Ensure the EOF-token check catches comments in all positions (top-of-file, inline) or switch to syntax().has_comments_direct() for consistency.

@Netail Netail force-pushed the feat/no-empty-file branch from 0c9a0ba to 843a560 Compare October 8, 2025 09:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 0c9a0ba and 843a560.

⛔ Files ignored due to path filters (14)
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/comment.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/directive.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-block-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/empty.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/hashbang.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptyFile/invalid/jsdoc.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptyFile/invalid.json.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and 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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_file.rs
  • crates/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.rs
  • crates/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.rs
  • crates/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

@siketyan
Copy link
Member

siketyan commented Oct 8, 2025

I'd prefer noEmptySource because the target can be an embedded part in another file (e.g. CSS-in-JS)

@Netail
Copy link
Member Author

Netail commented Oct 8, 2025

I'd prefer noEmptySource because the target can be an embedded part in another file (e.g. CSS-in-JS)

Makes sense, unless others have objections / remarks :)

@Netail Netail changed the title feat: implement noEmptyFile feat: implement noEmptySource Oct 8, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 843a560 and 7481e70.

⛔ Files ignored due to path filters (29)
  • crates/biome_cli/src/execute/migrate/eslint_any_rule_to_biome.rs is excluded by !**/migrate/eslint_any_rule_to_biome.rs and included by **
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_css_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_graphql_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/query.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/block-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/directive.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/var.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/src/lint/nursery.rs is excluded by !**/nursery.rs and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid.json.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid.json.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and 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.js
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.css
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphql
  • crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.js
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.js
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.css
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_rule_options/src/no_empty_source.rs
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphql
  • crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/valid/statement.js
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.js
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/valid/selector.css
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/valid/fragment.graphql
  • crates/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.rs
  • crates/biome_rule_options/src/no_empty_source.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_rule_options/src/no_empty_source.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_rule_options/src/lib.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/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(), not node.items(), so a file with only directives would have an empty items() iterator, causing any(...) to return false and the rule to correctly fire. The logic is sound.


127-129: LGTM!

Comment handling correctly respects the comments option: 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-source as 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.

@Netail Netail changed the title feat: implement noEmptySource feat(lint): implement noEmptySource Oct 8, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 renaming body to statement for clarity.

The variable receives the result of as_any_js_statement(), so statement would 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.js and invalid/hashbang.js exist in the test suite.
  • No further verification needed.

No changes required for directive/hashbang handling
Test fixtures invalid/directive.js and invalid/hashbang.js already cover these cases, so the lint correctly emits diagnostics.
Optional: rename body to statement at line 114 for clarity.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7481e70 and 54036e6.

📒 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; when comments: 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.

Comment on lines 42 to 48
/// ```json,options
/// {
/// "options": {
/// "comments": true
/// }
/// }
/// ```
Copy link
Member

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."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"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.
Copy link
Member

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
/// { }
/// ```
///
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Options are missing

Copy link
Member Author

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

@Netail Netail force-pushed the feat/no-empty-file branch from e850cdd to da9ce7e Compare October 9, 2025 08:04
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: honour comments option 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. Drop expect_diagnostic here.

-    /// ```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

📥 Commits

Reviewing files that changed from the base of the PR and between 54036e6 and e850cdd.

⛔ Files ignored due to path filters (14)
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/empty.json.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json.snap is excluded by !**/*.snap and 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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between e850cdd and 1d7f66f.

⛔ Files ignored due to path filters (17)
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/empty.json.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and 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.

@Netail Netail force-pushed the feat/no-empty-file branch from 1d7f66f to b94a3dd Compare October 9, 2025 08:31
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 1d7f66f and b94a3dd.

⛔ Files ignored due to path filters (17)
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/empty.json.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and 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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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: 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
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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/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 comments option 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 the JsModuleItem import suggestion—there is no such enum in biome_js_syntax.

Likely an incorrect or invalid review comment.

@Netail Netail force-pushed the feat/no-empty-file branch from b94a3dd to 3929d75 Compare October 9, 2025 08:49
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 comments option as expected: when comments is true (default), comment-only sources are considered empty; when false, they're valid.

The pattern matches the CSS implementation for consistency.

Minor: Line 73 could use !node.definitions().is_empty() instead of len() > 0 for 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

📥 Commits

Reviewing files that changed from the base of the PR and between b94a3dd and 3929d75.

⛔ Files ignored due to path filters (17)
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/comment.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_css_analyze/tests/specs/nursery/noEmptySource/invalid/empty.css.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/comment.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/nursery/noEmptySource/invalid/empty.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/comment.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/directive.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-block-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty-statement.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/empty.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/hashbang.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_js_analyze/tests/specs/nursery/noEmptySource/invalid/jsdoc.js.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/comment.jsonc.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/invalid/empty.json.snap is excluded by !**/*.snap and included by **
  • crates/biome_json_analyze/tests/specs/nursery/noEmptySource/valid/object.json.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and 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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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
  • crates/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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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 comments option 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 NoEmptySourceOptions ensures 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 shared NoEmptySourceOptions maintains 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 comments option. The use of "source" terminology aligns with the maintainer feedback.


127-129: LGTM!

The comments option logic correctly allows comment-only sources when comments is set to false, 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 via directives(), so no extra import or filtering is required.


113-125: Handle directive-only files

Non-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 out JsModuleItem::JsDirective(_) in the items() check or add an explicit node.directives() guard.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 demonstrate comments: false behaviour.

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 when comments: false:

// Only a comment

This would make it clear that setting comments: false allows 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 illustrate comments: false effect.

An empty file with comments: false still triggers a diagnostic, which doesn't demonstrate what the option actually does. Show a comment-only file that passes when comments: false:

// Only comments

This 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 show comments: false in 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3929d75 and 49dca41.

📒 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.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
  • 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_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
  • 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_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
  • 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_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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 in node.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
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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

Copy link
Member Author

@Netail Netail Oct 10, 2025

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?

Copy link
Member

@ematipico ematipico Oct 10, 2025

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

Copy link
Member Author

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

@Netail Netail force-pushed the feat/no-empty-file branch from 9d846d2 to 3fa849c Compare October 10, 2025 08:50
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 49dca41 and 3fa849c.

📒 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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_css_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_json_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/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)

@Netail Netail force-pushed the feat/no-empty-file branch from e6662cb to 07d6268 Compare October 10, 2025 09:06
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 the allowComments option.

The current example demonstrates that an empty file remains invalid even when allowComments is true, which is correct. However, it would be helpful to also show a valid case: a file containing only comments that's considered valid when allowComments is 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 the allowComments option.

Similar to the other language implementations, adding a valid case would improve clarity. Show a file with only comments being valid when allowComments is 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 the allowComments option.

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 the allowComments option.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3fa849c and 07d6268.

⛔ Files ignored due to path filters (2)
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and 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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_js_analyze/src/lint/nursery/no_empty_source.rs
  • crates/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

Comment on lines 41 to 53
/// Default `false`
///
/// ```json,options
/// {
/// "options": {
/// "allowComments": true
/// }
/// }
/// ```
///
/// ```css,expect_diagnostic,use_options
///
/// ```
Copy link
Contributor

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.

Comment on lines 46 to 56
/// ```json,options
/// {
/// "options": {
/// "allowComments": true
/// }
/// }
/// ```
///
/// ```graphql,expect_diagnostic,use_options
///
/// ```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment on lines 84 to 94
/// ```json,options
/// {
/// "options": {
/// "allowComments": true
/// }
/// }
/// ```
///
/// ```js,expect_diagnostic,use_options
///
/// ```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@Netail Netail force-pushed the feat/no-empty-file branch from 76ac789 to dedd722 Compare October 10, 2025 15:55
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 else branch treats all items that fail as_any_js_statement() as non-empty by returning true. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 07d6268 and dedd722.

📒 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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_css_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_css_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_css_analyze/src/lint/nursery/no_empty_source.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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: 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.rs
  • crates/biome_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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_graphql_analyze/src/lint/nursery/no_empty_source.rs
  • 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/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 allowComments option.

///
/// #### Valid
///
/// ```graphql,expect_diagnostic,use_options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Copy link
Member Author

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."

@Netail Netail force-pushed the feat/no-empty-file branch from dedd722 to fe7ffca Compare October 10, 2025 18:39
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between dedd722 and fe7ffca.

📒 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

Comment on lines +127 to +130
match body {
AnyJsStatement::JsEmptyStatement(_) => false,
AnyJsStatement::JsBlockStatement(block) => block.statements().len() > 0,
_ => true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

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.

Suggested change
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)
}) {
// …
}

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@ematipico ematipico merged commit b622425 into biomejs:main Oct 14, 2025
25 of 27 checks passed
@github-actions github-actions bot mentioned this pull request Oct 14, 2025
@Netail Netail deleted the feat/no-empty-file branch October 28, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project L-CSS Language: CSS L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📎 Port no-empty-source from Stylelint

4 participants