Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ematipico
Copy link
Member

Summary

This is an attempt to refactor how we use services inside Biome.

At the moment, the analyzer has the infrastructure that allows developers to create new services as they need. This is very useful, and services are created only when needed.

While this is neat, we're reaching a point (actually, we already did) where some services can't be isolated anymore. An example is the semantic model of the JavaScript files i.e. the biome_js_semantic crate. In fact, when we introduced the module graph and the type inference engine, we needed the JS semantic model, which led us to duplicate code (to avoid a major refactor).

The reason why I decided to do this refactor is to solve two main problems:

  • Reduce code duplication between the analyser and the module graph
  • allow languages that have code snippets (HTML-ish languages) to query bindings that belong to them. Notably, it's a stepping stone towards supporting things like noUnusedVariables inside files like .vue, .astro and possibly .svelte too.

This PR attempts to store some services in the Workspace and pass them down to the analyser.

This PR moves the CSS semantic model into the Workspace. I thought it was easier to start with a smaller, younger service, so we can then pass to other services.

Having a service at the workspace level changes the whole architecture and how the APIs should be designed.

Make a service Send and Sync

The main challenge of existing services is that they are designed with typed nodes in mind, i.e. any node that belongs so a specific language. Having these nodes makes those services not sharable across threads.

To make services thread-safe, we need to change how services are designed by using the following two solutions:

AstPtr

We added these new nodes a while back, when we started the work around embedded languages and snippets. These nodes were ported from rust-analyzer/rowan a while back, now we get to use them.

This is an untyped node that:

  • knows its kind
  • knows its position inside the root of the language

That's how we "type" the nodes inside a workspace-level service:

-CssString
+AstPtr<CssString>

The CSS semantic model was updated to use this type to make its nodes thread-safe. However, this requires that its public APIs be reviewed to retrieve its typed counterpart.

APIs must accept the root node

Based on the previous example, if we want to retrieve CssString, we must use AstPtr::to_node, which needs &CssRoot.

This works quite well because every time we use the semantic model, the root is available, so the changes were minimal and made within the lint rules.

Store services

Services are now stored in the Document type, within an enum called DocumentServices. Like DocumentFileSource, it is organised by language.

Document services are created the moment we open and store a file (notably, open_file and change_file). This is probably a drawback of this new design, compared to what we have today.

I tried to make services a Option, so they are created when we most likely need them. For example, if linting or assist are disabled, we don't create them.

However, this is a small price we need to pay to provide more powerful features, which are impossible at the moment.

Test Plan

This is an internal refactor, existing tests should pass.

Docs

@changeset-bot
Copy link

changeset-bot bot commented Dec 1, 2025

⚠️ No Changeset found

Latest commit: 3d6503b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ematipico ematipico changed the title refactor: document services refactor(core): document services Dec 1, 2025
@ematipico ematipico requested review from a team December 1, 2025 09:19
@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter A-Tooling Area: internal tools L-CSS Language: CSS labels Dec 1, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Dec 1, 2025

CodSpeed Performance Report

Merging #8327 will not alter performance

Comparing refactor/document-services (3d6503b) with main (9266677)1

Summary

✅ 58 untouched
⏩ 95 skipped2

Footnotes

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

  2. 95 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.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 52432 52432 0
Passed 51219 51219 0
Failed 1171 1171 0
Panics 42 42 0
Coverage 97.69% 97.69% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6327 6327 0
Passed 2108 2108 0
Failed 4219 4219 0
Panics 0 0 0
Coverage 33.32% 33.32% 0.00%

ts/babel

Test result main count This PR count Difference
Total 835 835 0
Passed 742 742 0
Failed 93 93 0
Panics 0 0 0
Coverage 88.86% 88.86% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18827 18827 0
Passed 14073 14073 0
Failed 4753 4753 0
Panics 1 1 0
Coverage 74.75% 74.75% 0.00%

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

This PR adds a service-driven CSS analysis flow: a new public CssAnalyzerServices (file source + optional SemanticModel) is introduced and threaded into biome_css_analyze::analyze/analyze_with_inspect_matcher. Semantic model ownership shifts to Arc and many AST fields switch to AstPtr with root-aware accessors (methods now accept &CssRoot). Workspace/document embedding now carries DocumentServices/CssDocumentServices and propagates per-document services through lint, code-actions and fix-all paths. Multiple linters were updated to use the root-aware accessors.

Possibly related PRs

Suggested labels

A-Core, A-Parser

Suggested reviewers

  • dyc3
  • arendjr
  • chansuke

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor(core): document services' clearly describes the main change: refactoring how services are used in Biome's core, specifically by storing them at the document/workspace level.
Description check ✅ Passed The description comprehensively covers the refactoring's motivation, implementation strategy (AstPtr usage, root parameter threading), architectural changes (DocumentServices enum), and tradeoffs—all directly related to the changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/document-services

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: 1

🧹 Nitpick comments (2)
crates/biome_css_semantic/src/semantic_model/builder.rs (1)

122-126: Consider documenting the expect() invariant.

The expect("To be a root node") relies on self.root always being a valid root. Since SemanticModelBuilder::new accepts a CssRoot, this invariant should hold. However, a brief doc comment on the struct or method explaining this assumption would help future maintainers.

crates/biome_service/src/file_handlers/css.rs (1)

714-726: Consider hoisting css_services construction outside the loop.

css_services is recreated on each iteration, but neither semantic_model nor file_source changes between iterations. While cloning an Arc is cheap, moving the construction before the loop would be slightly cleaner.

+    let css_services = CssAnalyzerServices {
+        semantic_model: params
+            .document_services
+            .as_css_services()
+            .and_then(|services| services.semantic_model.clone()),
+        file_source,
+    };
+
     loop {
-        let css_services = CssAnalyzerServices {
-            semantic_model: params
-                .document_services
-                .as_css_services()
-                .and_then(|services| services.semantic_model.clone()),
-            file_source,
-        };
-
         let (action, _) = analyze(
             &tree,
             filter,
             &analyzer_options,
-            css_services,
+            css_services.clone(),
             &params.plugins,
             |signal| process_fix_all.process_signal(signal),
         );

This requires CssAnalyzerServices to derive Clone, which it likely already does given the Arc and Copy fields.

📜 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 1da899b and 5c447eb.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock and included by **
📒 Files selected for processing (23)
  • crates/biome_css_analyze/benches/css_analyzer.rs (2 hunks)
  • crates/biome_css_analyze/src/lib.rs (11 hunks)
  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs (3 hunks)
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs (4 hunks)
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs (1 hunks)
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs (1 hunks)
  • crates/biome_css_analyze/src/services/semantic.rs (4 hunks)
  • crates/biome_css_analyze/tests/quick_test.rs (3 hunks)
  • crates/biome_css_analyze/tests/spec_tests.rs (3 hunks)
  • crates/biome_css_semantic/src/format_semantic_model.rs (2 hunks)
  • crates/biome_css_semantic/src/semantic_model/builder.rs (10 hunks)
  • crates/biome_css_semantic/src/semantic_model/model.rs (8 hunks)
  • crates/biome_service/src/file_handlers/css.rs (7 hunks)
  • crates/biome_service/src/file_handlers/graphql.rs (1 hunks)
  • crates/biome_service/src/file_handlers/html.rs (6 hunks)
  • crates/biome_service/src/file_handlers/javascript.rs (2 hunks)
  • crates/biome_service/src/file_handlers/json.rs (1 hunks)
  • crates/biome_service/src/file_handlers/mod.rs (5 hunks)
  • crates/biome_service/src/workspace.rs (2 hunks)
  • crates/biome_service/src/workspace/document.rs (6 hunks)
  • crates/biome_service/src/workspace/server.rs (22 hunks)
  • xtask/rules_check/Cargo.toml (1 hunks)
  • xtask/rules_check/src/lib.rs (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the dbg!() macro for debugging output during testing, and pass the --show-output flag to cargo to view debug output
Use cargo t or cargo test to run tests; for a single test, pass the test name after the test command
Use snapshot testing with the insta crate; run cargo insta accept, cargo insta reject, or cargo insta review to manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Use just f (alias for just format) to format Rust and TOML files before committing

Files:

  • crates/biome_service/src/file_handlers/graphql.rs
  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • xtask/rules_check/src/lib.rs
  • crates/biome_service/src/file_handlers/json.rs
  • crates/biome_service/src/workspace.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_service/src/workspace/server.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
**/*.toml

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use just f (alias for just format) to format TOML files before committing

Files:

  • xtask/rules_check/Cargo.toml
crates/biome_service/src/workspace*.rs

📄 CodeRabbit inference engine (crates/biome_service/CONTRIBUTING.md)

Implement the Workspace trait in the Biome Service to manage internal state of projects, including open documents, project layout instances, and module graph instances

Files:

  • crates/biome_service/src/workspace.rs
crates/biome_service/src/workspace/server.rs

📄 CodeRabbit inference engine (crates/biome_service/CONTRIBUTING.md)

Use WorkspaceServer implementation for maintaining workspace state in daemon mode and CLI daemonless mode

Files:

  • crates/biome_service/src/workspace/server.rs
🧠 Learnings (69)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace*.rs : Implement the Workspace trait in the Biome Service to manage internal state of projects, including open documents, project layout instances, and module graph instances
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `Semantic<T>` query type instead of `Ast<T>` when a rule needs to access the semantic model for binding references and scope information
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : When using multiple services in a rule, use `ctx.get_service::<ServiceType>()` to retrieve services running in the second phase when query runs during that phase
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Code actions must specify a `fix_kind` field in the `declare_lint_rule!` macro as either `FixKind::Safe` or `FixKind::Unsafe` to indicate whether fixes always preserve program behavior

Applied to files:

  • crates/biome_service/src/file_handlers/graphql.rs
  • crates/biome_service/src/file_handlers/json.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_service/src/file_handlers/mod.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Check if a variable is global before banning it to avoid false positives when the variable is redeclared in local scope; use the semantic model to verify global scope

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUndeclared` prefix for rules that report undefined entities (e.g., `noUndeclaredVariables`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `Semantic<T>` query type instead of `Ast<T>` when a rule needs to access the semantic model for binding references and scope information

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • xtask/rules_check/src/lib.rs
  • xtask/rules_check/Cargo.toml
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noRedundant` prefix for rules that report redundant code (e.g., `noRedundantUseStrict`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : When navigating CST nodes that return `Result`, use the try operator `?` to convert to `Option`, or use `let else` pattern for `Vec` return types in rule run functions

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnused` prefix for rules that report unused entities (e.g., `noUnusedVariables`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noEmpty` prefix for rules that report empty code (e.g., `noEmptyBlockStatements`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noConstant` prefix for rules that report computations always evaluated to the same value (e.g., `noConstantMathMinMaxClamp`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `useConsistent` prefix for rules that ensure consistency across the codebase (e.g., `useConsistentArrayType`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnknown` prefix for rules that report mistyped entities in CSS (e.g., `noUnknownUnit`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • xtask/rules_check/src/lib.rs
  • xtask/rules_check/Cargo.toml
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noDuplicate` prefix for rules that report duplication overriding previous occurrences (e.g., `noDuplicateObjectKeys`)

Applied to files:

  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Implement custom `Queryable` types and `Visitor` traits for rules requiring deep AST inspection to avoid redundant traversal passes

Applied to files:

  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_service/src/workspace/server.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noRestricted` prefix for rules that report user-banned entities (e.g., `noRestrictedGlobals`)

Applied to files:

  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : For rules ported from other ecosystems like ESLint or Clippy, add a `sources` field with `RuleSource` metadata using `.same()` for identical behavior or `.inspired()` for different behavior

Applied to files:

  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • xtask/rules_check/src/lib.rs
  • xtask/rules_check/Cargo.toml
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `run` function of a lint rule should return `Option<Self::State>` or an iterable like `Vec<Self::State>` or `Box<[Self::State]>` to signal zero or more diagnostics

Applied to files:

  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Lint rules must be implemented using the `Rule` trait with type parameters: `Query` (node type to analyze), `State` (information for signals), `Signals` (return type from run function), and `Options` (rule configuration)

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Set rule severity to `error` for correctness/security/a11y rules, `warn` for suspicious/performance rules, `info` for style/complexity rules, and `info` for actions

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Framework-specific rules should be named using the `use` or `no` prefix followed by the framework name (e.g., `noVueReservedProps`)

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_service/src/file_handlers/json.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-28T09:08:10.077Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.077Z
Learning: Applies to Cargo.toml : Use workspace dependencies in the root Cargo.toml; internal crates should use `workspace = true` for dependencies and path dependencies for dev-dependencies

Applied to files:

  • xtask/rules_check/Cargo.toml
  • crates/biome_service/src/workspace.rs
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace*.rs : Implement the Workspace trait in the Biome Service to manage internal state of projects, including open documents, project layout instances, and module graph instances

Applied to files:

  • xtask/rules_check/Cargo.toml
  • crates/biome_service/src/file_handlers/json.rs
  • crates/biome_service/src/workspace.rs
  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_service/src/workspace/server.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/Cargo.toml : Include development dependencies in `Cargo.toml` for formatter tests: `biome_formatter_test`, `biome_<language>_factory`, `biome_<language>_parser`, `biome_parser`, `biome_service`, `countme`, `iai`, `quickcheck`, `quickcheck_macros`, and `tests_macros`

Applied to files:

  • xtask/rules_check/Cargo.toml
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : New rules must be placed inside the `nursery` group as an incubation space exempt from semantic versioning, with promotion to appropriate groups done during minor/major releases

Applied to files:

  • xtask/rules_check/Cargo.toml
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Commit rule changes with message format: `feat(biome_<crate>): <ruleName>` to follow Biome's conventional commit style

Applied to files:

  • xtask/rules_check/Cargo.toml
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Implement watcher tests for workspace methods in watcher.tests.rs and end-to-end tests in LSP tests

Applied to files:

  • xtask/rules_check/Cargo.toml
  • crates/biome_service/src/workspace.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/workspace/server.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Wrap optional rule option fields in `Option<_>` to properly track set vs unset options during configuration merging

Applied to files:

  • xtask/rules_check/Cargo.toml
  • crates/biome_service/src/file_handlers/json.rs
  • crates/biome_service/src/workspace.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Debug the WorkspaceWatcher by starting the daemon with cargo run --bin=biome -- start and running commands such as cargo run --bin=biome -- lint --use-server <path>

Applied to files:

  • xtask/rules_check/Cargo.toml
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Rule options struct fields should use `#[serde(rename_all = "camelCase")]`, `#[serde(deny_unknown_fields)]`, and `#[serde(default)]` attributes for proper JSON serialization

Applied to files:

  • crates/biome_service/src/file_handlers/json.rs
  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Document rules with a one-line brief description in the first paragraph of the doc comment, followed by detailed paragraphs, `## Examples` section with `### Invalid` and `### Valid` subsections, and optional `## Options` section

Applied to files:

  • crates/biome_service/src/file_handlers/json.rs
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace/server.rs : Use WorkspaceServer implementation for maintaining workspace state in daemon mode and CLI daemonless mode

Applied to files:

  • crates/biome_service/src/workspace.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced

Applied to files:

  • crates/biome_service/src/workspace.rs
  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace/client.rs : Use WorkspaceClient implementation for creating connections to the daemon and communicating with WorkspaceServer

Applied to files:

  • crates/biome_service/src/workspace.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnsafe` prefix for rules that report code leading to runtime failures (e.g., `noUnsafeOptionalChaining`)

Applied to files:

  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noExcessive` prefix for rules that report code exceeding configurable limits (e.g., `noExcessiveNestedTestSuites`)

Applied to files:

  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Deprecate rules by adding a `deprecated` field to the `declare_lint_rule!` macro with a message explaining the reason for deprecation (e.g., 'Use the rule noAnotherVar')

Applied to files:

  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUseless` prefix for rules that report unnecessary code that could be removed or simplified (e.g., `noUselessConstructor`)

Applied to files:

  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Avoid unnecessary string allocations by comparing against `&str` or `TokenText` instead of calling `to_string()` which allocates heap memory

Applied to files:

  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/tests/quick_test.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `rule_category!()` macro instead of dynamic string parsing to refer to rule diagnostic categories for compile-time validation

Applied to files:

  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : A parser struct must implement the `Parser` trait and save the token source, parser context, and optional parser options

Applied to files:

  • crates/biome_css_analyze/benches/css_analyzer.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Use quick testing via `tests/quick_test.rs` by removing the `#[ignore]` macro and modifying the `SOURCE` variable to rapidly validate rule behavior during development

Applied to files:

  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Rule options must be defined in the `biome_rule_options` crate and implement traits: `Deserializable`, `Merge`, `Serialize`, `Deserialize`, and `JsonSchema`

Applied to files:

  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : When using multiple services in a rule, use `ctx.get_service::<ServiceType>()` to retrieve services running in the second phase when query runs during that phase

Applied to files:

  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_service/src/workspace/server.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `action` function must return a `JsRuleAction` (or equivalent language-specific action type) with category `ctx.action_category(ctx.category(), ctx.group())` and applicability from `ctx.metadata().applicability()`

Applied to files:

  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/html.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Rules should use the `use` prefix naming convention when the sole intention is to mandate a single concept (e.g., `useValidLang` to enforce valid HTML lang attribute values)

Applied to files:

  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Avoid using `unwrap()` or `expect()` on `Result` and `Option` types; instead use helper functions like `map`, `filter`, `and_then` to maintain code clarity and avoid panics

Applied to files:

  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/lib.rs : Expose a public `format_node` function that accepts formatting options and a root syntax node, returning a `FormatResult<Formatted<Context>>` with appropriate documentation

Applied to files:

  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `diagnostic` function must return a `RuleDiagnostic` that defines the message reported to the user using the `markup!` macro

Applied to files:

  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/quick_test.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to 'fix' the code; if a token/node is known to be mandatory but is missing, return `None` instead

Applied to files:

  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:04:57.309Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:57.309Z
Learning: Applies to crates/biome_diagnostics/**/*.rs : Use helper types from the biome_diagnostics::v2 module (CodeFrameAdvice, CommandAdvice, DiffAdvice, LogAdvice) or implement the Advices trait yourself for custom advice handling

Applied to files:

  • crates/biome_service/src/file_handlers/javascript.rs
📚 Learning: 2025-11-28T09:08:10.077Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.077Z
Learning: Internal crate changes that don't affect user-facing behavior do not require changesets; changesets are only for user-facing changes

Applied to files:

  • crates/biome_service/src/file_handlers/javascript.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Store type data in linear vectors instead of using recursive data structures with `Arc` for improved data locality and performance

Applied to files:

  • crates/biome_service/src/file_handlers/javascript.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : In rule documentation code blocks, mark invalid examples with the `expect_diagnostic` property and valid examples without it; each invalid example must emit exactly one diagnostic

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Define `FormatHtmlSyntaxNode` struct in a `cst.rs` file implementing `FormatRule<HtmlSyntaxNode>`, `AsFormat<HtmlFormatContext>`, and `IntoFormat<HtmlFormatContext>` traits using the provided boilerplate code

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/context.rs : Define `<Language>FormatContext` struct in a `context.rs` file containing `comments` and `source_map` fields, implementing `FormatContext` and `CstFormatContext` traits

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Parse rule functions must be prefixed with `parse_` and use the name defined in the grammar file, e.g., `parse_for_statement` or `parse_expression`

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Implement the `FormatNodeRule<N>` trait with `fmt_fields` as the only required method; default implementations of `fmt`, `is_suppressed`, `fmt_leading_comments`, `fmt_dangling_comments`, and `fmt_trailing_comments` are provided

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: The formatter foundation relies on using the generic `Format` trait and `FormatNode` for nodes, with creation of an intermediate IR via a series of helpers

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/lib.rs : Define a type alias `<Language>Formatter<'buf>` as `Formatter<'buf, <Language>FormatContext>` in the main formatter crate

Applied to files:

  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/language.rs : Implement `TestFormatLanguage` trait in `tests/language.rs` for the formatter's test language

Applied to files:

  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `ConditionalParsedSyntax` for syntax that is only valid in specific contexts (e.g., strict mode, file types, language versions) and call `or_invalid_to_bogus()` to convert to a bogus node if not supported

Applied to files:

  • crates/biome_service/src/workspace/document.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/comments.rs : Define `<Language>CommentStyle` as a public type alias for `Comments<<Language>Language>` in a `comments.rs` file

Applied to files:

  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Parse rules must take a mutable reference to the parser as their only parameter and return a `ParsedSyntax`

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Use `Box<[T]>` instead of `Vec<T>` for rule options array fields to save memory (boxed slices and boxed str use 2 words instead of three words)

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Implement the `Merge` trait for rule options to define how options from extended configuration merge with user configuration (usually reset instead of extend)

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `declare_node_union!` macro to query multiple node types at once by joining them into an enum with `Any*Like` naming convention

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/model.rs
🧬 Code graph analysis (12)
crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs (1)
crates/biome_css_semantic/src/semantic_model/model.rs (2)
  • root (34-36)
  • root (35-35)
crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs (1)
crates/biome_css_semantic/src/semantic_model/model.rs (5)
  • root (34-36)
  • root (35-35)
  • node (143-145)
  • node (227-229)
  • declaration (310-312)
xtask/rules_check/src/lib.rs (2)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_css_semantic/src/semantic_model/model.rs (2)
  • root (34-36)
  • root (35-35)
crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs (2)
crates/biome_css_semantic/src/semantic_model/model.rs (4)
  • root (34-36)
  • root (35-35)
  • new (27-32)
  • new (385-389)
crates/biome_css_semantic/src/semantic_model/builder.rs (1)
  • new (29-40)
crates/biome_css_analyze/benches/css_analyzer.rs (1)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_css_analyze/src/lib.rs (3)
crates/biome_css_analyze/src/services/semantic.rs (1)
  • model (15-17)
crates/biome_css_semantic/src/semantic_model/model.rs (5)
  • root (34-36)
  • root (35-35)
  • new (27-32)
  • new (385-389)
  • text (231-233)
crates/biome_css_syntax/src/file_source.rs (1)
  • css (35-39)
crates/biome_service/src/file_handlers/css.rs (1)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_css_analyze/tests/spec_tests.rs (2)
crates/biome_css_semantic/src/semantic_model/model.rs (4)
  • root (34-36)
  • root (35-35)
  • from (345-347)
  • from (351-353)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_css_semantic/src/format_semantic_model.rs (1)
crates/biome_css_semantic/src/semantic_model/model.rs (8)
  • selectors (154-156)
  • root (34-36)
  • root (35-35)
  • range (147-152)
  • range (235-240)
  • text (231-233)
  • specificity (170-172)
  • specificity (242-244)
crates/biome_css_analyze/src/services/semantic.rs (2)
crates/biome_css_semantic/src/semantic_model/builder.rs (1)
  • new (29-40)
crates/biome_css_semantic/src/semantic_model/model.rs (2)
  • new (27-32)
  • new (385-389)
crates/biome_css_semantic/src/semantic_model/builder.rs (1)
crates/biome_css_semantic/src/semantic_model/model.rs (5)
  • new (27-32)
  • new (385-389)
  • node (143-145)
  • node (227-229)
  • property (314-316)
crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs (1)
crates/biome_css_semantic/src/semantic_model/model.rs (5)
  • root (34-36)
  • root (35-35)
  • node (143-145)
  • node (227-229)
  • declaration (310-312)
⏰ 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). (25)
  • GitHub Check: Bench (biome_tailwind_parser)
  • GitHub Check: Parser conformance
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Documentation
  • 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_module_graph)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_package)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Test Node.js API
  • GitHub Check: autofix

@ematipico ematipico force-pushed the refactor/document-services branch from 5c447eb to 65bff06 Compare December 1, 2025 09:45
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/biome_service/src/file_handlers/json.rs (1)

558-586: Fix use-after-move of params in code_actions

The destructuring let CodeActionsParams { .. } = params; moves fields out of params, so later reads of params.path, params.language and params.settings are using a partially-moved value and will not compile.

You already have the necessary locals (path, language, workspace), so just use those instead of params.*.

 fn code_actions(params: CodeActionsParams) -> PullActionsResult {
     let CodeActionsParams {
         parse,
         range,
-        settings: workspace,
-        path,
+        settings: workspace,
+        path,
         module_graph: _,
         project_layout,
         language,
@@
-    let tree: JsonRoot = parse.tree();
-    let analyzer_options = workspace.analyzer_options::<JsonLanguage>(
-        params.path,
-        &params.language,
-        suppression_reason.as_deref(),
-    );
+    let tree: JsonRoot = parse.tree();
+    let analyzer_options = workspace.analyzer_options::<JsonLanguage>(
+        path,
+        &language,
+        suppression_reason.as_deref(),
+    );
@@
-    let (enabled_rules, disabled_rules, analyzer_options) =
-        AnalyzerVisitorBuilder::new(params.settings, analyzer_options)
+    let (enabled_rules, disabled_rules, analyzer_options) =
+        AnalyzerVisitorBuilder::new(workspace, analyzer_options)
🧹 Nitpick comments (4)
xtask/rules_check/src/lib.rs (1)

16-16: CSS semantic services wiring for assert_lint looks good

The new CSS arm correctly builds a SemanticModel, wraps it in CssAnalyzerServices together with the CssFileSource, and passes that into biome_css_analyze::analyze, mirroring the JS/JSON flow.

If you fancy a tiny clean-up later, you could reuse the existing root instead of calling parse.tree() a second time when building the semantic model:

-            let parse = biome_css_parser::parse_css(code, parse_options);
+            let parse = biome_css_parser::parse_css(code, parse_options);
@@
-            } else {
-                let root = parse.tree();
+            } else {
+                let root = parse.tree();
@@
-                let semantic_model = biome_css_semantic::semantic_model(&parse.tree());
+                let semantic_model = biome_css_semantic::semantic_model(&root);

Also applies to: 393-421

crates/biome_service/src/file_handlers/css.rs (1)

714-726: Consider hoisting CssAnalyzerServices construction outside the loop.

Since file_source is immutable and document_services does not change between iterations, reconstructing css_services on each pass appears redundant. Unless the semantic model must reflect tree mutations (which doesn't seem to be the case here), you could create it once before the loop.

+    let css_services = CssAnalyzerServices {
+        semantic_model: params
+            .document_services
+            .as_css_services()
+            .and_then(|services| services.semantic_model.clone()),
+        file_source,
+    };
+
     loop {
-        let css_services = CssAnalyzerServices {
-            semantic_model: params
-                .document_services
-                .as_css_services()
-                .and_then(|services| services.semantic_model.clone()),
-            file_source,
-        };
-
         let (action, _) = analyze(
             &tree,
             filter,
             &analyzer_options,
-            css_services,
+            css_services.clone(),
             &params.plugins,
             |signal| process_fix_all.process_signal(signal),
         );
crates/biome_css_analyze/src/lib.rs (2)

20-25: CssAnalyzerServices shape and defaults

The CssAnalyzerServices container and tiny builder methods look sensible for threading file source + semantic model into the analyser. The Default derive implicitly picks whatever CssFileSource::default() is; if there’s no “obvious” default, consider whether you actually want Default here or prefer forcing callers to set file_source explicitly.

Also applies to: 34-53


179-265: Tests exercise both semantic and non‑semantic paths

The updated tests constructing CssAnalyzerServices with semantic_model: Some(_) and None cover both “semantic available” and “syntax‑only” analysis flows, which is exactly what this refactor needs. The boilerplate struct literals are clear enough; factoring a tiny helper to build CssAnalyzerServices for tests would be purely a nicety.

Also applies to: 286-309, 337-359, 384-407, 428-448

📜 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 5c447eb and 65bff06.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock and included by **
📒 Files selected for processing (23)
  • crates/biome_css_analyze/benches/css_analyzer.rs (2 hunks)
  • crates/biome_css_analyze/src/lib.rs (11 hunks)
  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs (3 hunks)
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs (4 hunks)
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs (1 hunks)
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs (1 hunks)
  • crates/biome_css_analyze/src/services/semantic.rs (4 hunks)
  • crates/biome_css_analyze/tests/quick_test.rs (3 hunks)
  • crates/biome_css_analyze/tests/spec_tests.rs (3 hunks)
  • crates/biome_css_semantic/src/format_semantic_model.rs (2 hunks)
  • crates/biome_css_semantic/src/semantic_model/builder.rs (10 hunks)
  • crates/biome_css_semantic/src/semantic_model/model.rs (8 hunks)
  • crates/biome_service/src/file_handlers/css.rs (7 hunks)
  • crates/biome_service/src/file_handlers/graphql.rs (1 hunks)
  • crates/biome_service/src/file_handlers/html.rs (6 hunks)
  • crates/biome_service/src/file_handlers/javascript.rs (2 hunks)
  • crates/biome_service/src/file_handlers/json.rs (1 hunks)
  • crates/biome_service/src/file_handlers/mod.rs (5 hunks)
  • crates/biome_service/src/workspace.rs (2 hunks)
  • crates/biome_service/src/workspace/document.rs (6 hunks)
  • crates/biome_service/src/workspace/server.rs (22 hunks)
  • xtask/rules_check/Cargo.toml (1 hunks)
  • xtask/rules_check/src/lib.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_service/src/file_handlers/graphql.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_properties.rs
  • crates/biome_css_analyze/src/lint/suspicious/no_duplicate_custom_properties.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
🧰 Additional context used
📓 Path-based instructions (4)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the dbg!() macro for debugging output during testing, and pass the --show-output flag to cargo to view debug output
Use cargo t or cargo test to run tests; for a single test, pass the test name after the test command
Use snapshot testing with the insta crate; run cargo insta accept, cargo insta reject, or cargo insta review to manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Use just f (alias for just format) to format Rust and TOML files before committing

Files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/workspace.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_service/src/workspace/server.rs
  • crates/biome_service/src/file_handlers/json.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
crates/biome_service/src/workspace*.rs

📄 CodeRabbit inference engine (crates/biome_service/CONTRIBUTING.md)

Implement the Workspace trait in the Biome Service to manage internal state of projects, including open documents, project layout instances, and module graph instances

Files:

  • crates/biome_service/src/workspace.rs
**/*.toml

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Use just f (alias for just format) to format TOML files before committing

Files:

  • xtask/rules_check/Cargo.toml
crates/biome_service/src/workspace/server.rs

📄 CodeRabbit inference engine (crates/biome_service/CONTRIBUTING.md)

Use WorkspaceServer implementation for maintaining workspace state in daemon mode and CLI daemonless mode

Files:

  • crates/biome_service/src/workspace/server.rs
🧠 Learnings (62)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace*.rs : Implement the Workspace trait in the Biome Service to manage internal state of projects, including open documents, project layout instances, and module graph instances
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `Semantic<T>` query type instead of `Ast<T>` when a rule needs to access the semantic model for binding references and scope information
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : When using multiple services in a rule, use `ctx.get_service::<ServiceType>()` to retrieve services running in the second phase when query runs during that phase
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `Semantic<T>` query type instead of `Ast<T>` when a rule needs to access the semantic model for binding references and scope information

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lib.rs
  • xtask/rules_check/Cargo.toml
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : For rules ported from other ecosystems like ESLint or Clippy, add a `sources` field with `RuleSource` metadata using `.same()` for identical behavior or `.inspired()` for different behavior

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lib.rs
  • xtask/rules_check/Cargo.toml
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnknown` prefix for rules that report mistyped entities in CSS (e.g., `noUnknownUnit`)

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lib.rs
  • xtask/rules_check/Cargo.toml
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Check if a variable is global before banning it to avoid false positives when the variable is redeclared in local scope; use the semantic model to verify global scope

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_css_analyze/src/lib.rs
  • xtask/rules_check/Cargo.toml
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Set rule severity to `error` for correctness/security/a11y rules, `warn` for suspicious/performance rules, `info` for style/complexity rules, and `info` for actions

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Lint rules must be implemented using the `Rule` trait with type parameters: `Query` (node type to analyze), `State` (information for signals), `Signals` (return type from run function), and `Options` (rule configuration)

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Implement custom `Queryable` types and `Visitor` traits for rules requiring deep AST inspection to avoid redundant traversal passes

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/workspace/server.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `useConsistent` prefix for rules that ensure consistency across the codebase (e.g., `useConsistentArrayType`)

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Framework-specific rules should be named using the `use` or `no` prefix followed by the framework name (e.g., `noVueReservedProps`)

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`

Applied to files:

  • xtask/rules_check/src/lib.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_service/src/file_handlers/json.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUndeclared` prefix for rules that report undefined entities (e.g., `noUndeclaredVariables`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnused` prefix for rules that report unused entities (e.g., `noUnusedVariables`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noInvalid` prefix for rules that report runtime errors from mistyping (e.g., `noInvalidConstructorSuper`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : When navigating CST nodes that return `Result`, use the try operator `?` to convert to `Option`, or use `let else` pattern for `Vec` return types in rule run functions

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noEmpty` prefix for rules that report empty code (e.g., `noEmptyBlockStatements`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnsafe` prefix for rules that report code leading to runtime failures (e.g., `noUnsafeOptionalChaining`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noConstant` prefix for rules that report computations always evaluated to the same value (e.g., `noConstantMathMinMaxClamp`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noRedundant` prefix for rules that report redundant code (e.g., `noRedundantUseStrict`)

Applied to files:

  • crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs
  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noDuplicate` prefix for rules that report duplication overriding previous occurrences (e.g., `noDuplicateObjectKeys`)

Applied to files:

  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noExcessive` prefix for rules that report code exceeding configurable limits (e.g., `noExcessiveNestedTestSuites`)

Applied to files:

  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUseless` prefix for rules that report unnecessary code that could be removed or simplified (e.g., `noUselessConstructor`)

Applied to files:

  • crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Implement watcher tests for workspace methods in watcher.tests.rs and end-to-end tests in LSP tests

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/workspace.rs
  • xtask/rules_check/Cargo.toml
  • crates/biome_service/src/workspace/server.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : When using multiple services in a rule, use `ctx.get_service::<ServiceType>()` to retrieve services running in the second phase when query runs during that phase

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_service/src/workspace/server.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `rule_category!()` macro instead of dynamic string parsing to refer to rule diagnostic categories for compile-time validation

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Avoid using `unwrap()` or `expect()` on `Result` and `Option` types; instead use helper functions like `map`, `filter`, `and_then` to maintain code clarity and avoid panics

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : In rule documentation code blocks, mark invalid examples with the `expect_diagnostic` property and valid examples without it; each invalid example must emit exactly one diagnostic

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `diagnostic` function must return a `RuleDiagnostic` that defines the message reported to the user using the `markup!` macro

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_service/src/file_handlers/mod.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `run` function of a lint rule should return `Option<Self::State>` or an iterable like `Vec<Self::State>` or `Box<[Self::State]>` to signal zero or more diagnostics

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_service/src/file_handlers/mod.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Code actions must specify a `fix_kind` field in the `declare_lint_rule!` macro as either `FixKind::Safe` or `FixKind::Unsafe` to indicate whether fixes always preserve program behavior

Applied to files:

  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/json.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `action` function must return a `JsRuleAction` (or equivalent language-specific action type) with category `ctx.action_category(ctx.category(), ctx.group())` and applicability from `ctx.metadata().applicability()`

Applied to files:

  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/lib.rs : Expose a public `format_node` function that accepts formatting options and a root syntax node, returning a `FormatResult<Formatted<Context>>` with appropriate documentation

Applied to files:

  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace*.rs : Implement the Workspace trait in the Biome Service to manage internal state of projects, including open documents, project layout instances, and module graph instances

Applied to files:

  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/workspace.rs
  • xtask/rules_check/Cargo.toml
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_service/src/workspace/server.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Wrap optional rule option fields in `Option<_>` to properly track set vs unset options during configuration merging

Applied to files:

  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_service/src/file_handlers/html.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Define `FormatHtmlSyntaxNode` struct in a `cst.rs` file implementing `FormatRule<HtmlSyntaxNode>`, `AsFormat<HtmlFormatContext>`, and `IntoFormat<HtmlFormatContext>` traits using the provided boilerplate code

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_service/src/workspace/document.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/context.rs : Define `<Language>FormatContext` struct in a `context.rs` file containing `comments` and `source_map` fields, implementing `FormatContext` and `CstFormatContext` traits

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : When formatting AST nodes, use mandatory tokens from the AST instead of hardcoding token strings (e.g., use `node.l_paren_token().format()` instead of `token("(")`)

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs : New rules must be placed inside the `nursery` group as an incubation space exempt from semantic versioning, with promotion to appropriate groups done during minor/major releases

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • xtask/rules_check/Cargo.toml
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Rule options must be defined in the `biome_rule_options` crate and implement traits: `Deserializable`, `Merge`, `Serialize`, `Deserialize`, and `JsonSchema`

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Rule options struct fields should use `#[serde(rename_all = "camelCase")]`, `#[serde(deny_unknown_fields)]`, and `#[serde(default)]` attributes for proper JSON serialization

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
  • crates/biome_service/src/file_handlers/json.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Parse rule functions must be prefixed with `parse_` and use the name defined in the grammar file, e.g., `parse_for_statement` or `parse_expression`

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Implement the `FormatNodeRule<N>` trait with `fmt_fields` as the only required method; default implementations of `fmt`, `is_suppressed`, `fmt_leading_comments`, `fmt_dangling_comments`, and `fmt_trailing_comments` are provided

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: The formatter foundation relies on using the generic `Format` trait and `FormatNode` for nodes, with creation of an intermediate IR via a series of helpers

Applied to files:

  • crates/biome_css_semantic/src/format_semantic_model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `useShorthand` prefix for rules that report syntax rewritable using equivalent compact syntax (e.g., `useShorthandAssign`)

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Use `Box<[T]>` instead of `Vec<T>` for rule options array fields to save memory (boxed slices and boxed str use 2 words instead of three words)

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : Use `ConditionalParsedSyntax` for syntax that is only valid in specific contexts (e.g., strict mode, file types, language versions) and call `or_invalid_to_bogus()` to convert to a bogus node if not supported

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:05:42.356Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_type_info/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:42.356Z
Learning: Applies to crates/biome_js_type_info/**/*.rs : Use `TypeReference` instead of `Arc` for types that reference other types to avoid stale cache issues when modules are replaced

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/builder.rs
  • crates/biome_css_analyze/src/services/semantic.rs
  • crates/biome_service/src/workspace.rs
  • crates/biome_css_semantic/src/semantic_model/model.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Implement the `Merge` trait for rule options to define how options from extended configuration merge with user configuration (usually reset instead of extend)

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/builder.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Rules should use the `use` prefix naming convention when the sole intention is to mandate a single concept (e.g., `useValidLang` to enforce valid HTML lang attribute values)

Applied to files:

  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Use quick testing via `tests/quick_test.rs` by removing the `#[ignore]` macro and modifying the `SOURCE` variable to rapidly validate rule behavior during development

Applied to files:

  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-28T09:08:10.077Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.077Z
Learning: Applies to Cargo.toml : Use workspace dependencies in the root Cargo.toml; internal crates should use `workspace = true` for dependencies and path dependencies for dev-dependencies

Applied to files:

  • crates/biome_service/src/workspace.rs
  • xtask/rules_check/Cargo.toml
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace/server.rs : Use WorkspaceServer implementation for maintaining workspace state in daemon mode and CLI daemonless mode

Applied to files:

  • crates/biome_service/src/workspace.rs
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace/client.rs : Use WorkspaceClient implementation for creating connections to the daemon and communicating with WorkspaceServer

Applied to files:

  • crates/biome_service/src/workspace.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/Cargo.toml : Include development dependencies in `Cargo.toml` for formatter tests: `biome_formatter_test`, `biome_<language>_factory`, `biome_<language>_parser`, `biome_parser`, `biome_service`, `countme`, `iai`, `quickcheck`, `quickcheck_macros`, and `tests_macros`

Applied to files:

  • xtask/rules_check/Cargo.toml
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Commit rule changes with message format: `feat(biome_<crate>): <ruleName>` to follow Biome's conventional commit style

Applied to files:

  • xtask/rules_check/Cargo.toml
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Debug the WorkspaceWatcher by starting the daemon with cargo run --bin=biome -- start and running commands such as cargo run --bin=biome -- lint --use-server <path>

Applied to files:

  • xtask/rules_check/Cargo.toml
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/lib.rs : Define a type alias `<Language>Formatter<'buf>` as `Formatter<'buf, <Language>FormatContext>` in the main formatter crate

Applied to files:

  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/tests/language.rs : Implement `TestFormatLanguage` trait in `tests/language.rs` for the formatter's test language

Applied to files:

  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/comments.rs : Define `<Language>CommentStyle` as a public type alias for `Comments<<Language>Language>` in a `comments.rs` file

Applied to files:

  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Do not attempt to 'fix' the code; if a token/node is known to be mandatory but is missing, return `None` instead

Applied to files:

  • crates/biome_service/src/workspace/document.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `declare_node_union!` macro to query multiple node types at once by joining them into an enum with `Any*Like` naming convention

Applied to files:

  • crates/biome_css_semantic/src/semantic_model/model.rs
🧬 Code graph analysis (11)
xtask/rules_check/src/lib.rs (2)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_css_semantic/src/semantic_model/model.rs (2)
  • root (34-36)
  • root (35-35)
crates/biome_css_analyze/src/lint/correctness/no_missing_var_function.rs (1)
crates/biome_css_semantic/src/semantic_model/model.rs (2)
  • root (34-36)
  • root (35-35)
crates/biome_css_analyze/src/lint/style/no_descending_specificity.rs (2)
crates/biome_css_semantic/src/semantic_model/model.rs (4)
  • root (34-36)
  • root (35-35)
  • new (27-32)
  • new (385-389)
crates/biome_css_semantic/src/semantic_model/builder.rs (1)
  • new (29-40)
crates/biome_css_analyze/tests/quick_test.rs (1)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_service/src/file_handlers/css.rs (1)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_css_analyze/tests/spec_tests.rs (3)
crates/biome_css_semantic/src/semantic_model/model.rs (4)
  • root (34-36)
  • root (35-35)
  • from (345-347)
  • from (351-353)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_test_utils/src/lib.rs (1)
  • code_fix_to_string (344-355)
crates/biome_css_semantic/src/format_semantic_model.rs (2)
crates/biome_css_semantic/src/semantic_model/mod.rs (5)
  • model (328-328)
  • model (351-351)
  • model (372-372)
  • model (388-388)
  • selector (218-225)
crates/biome_css_semantic/src/semantic_model/model.rs (8)
  • selectors (154-156)
  • root (34-36)
  • root (35-35)
  • range (147-152)
  • range (235-240)
  • text (231-233)
  • specificity (170-172)
  • specificity (242-244)
crates/biome_css_semantic/src/semantic_model/builder.rs (1)
crates/biome_css_semantic/src/semantic_model/model.rs (7)
  • new (27-32)
  • new (385-389)
  • node (143-145)
  • node (227-229)
  • property (314-316)
  • value (318-320)
  • value (328-335)
crates/biome_css_analyze/src/services/semantic.rs (2)
crates/biome_css_semantic/src/semantic_model/builder.rs (1)
  • new (29-40)
crates/biome_css_semantic/src/semantic_model/model.rs (2)
  • new (27-32)
  • new (385-389)
crates/biome_service/src/workspace/document.rs (2)
crates/biome_css_semantic/src/semantic_model/model.rs (4)
  • node (143-145)
  • node (227-229)
  • root (34-36)
  • root (35-35)
crates/biome_parser/src/lib.rs (5)
  • into_serde_diagnostics (738-743)
  • into_serde_diagnostics (913-924)
  • into_serde_diagnostics (958-969)
  • root (884-886)
  • root (950-952)
crates/biome_service/src/workspace/server.rs (2)
crates/biome_service/src/workspace/document.rs (4)
  • none (278-280)
  • parse (88-94)
  • parse (184-184)
  • parse (189-196)
crates/biome_service/src/file_handlers/mod.rs (1)
  • can_parse (373-385)
⏰ 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). (25)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Documentation
  • GitHub Check: Test Node.js API
  • GitHub Check: End-to-end tests
  • GitHub Check: Check Dependencies
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Parser conformance
  • GitHub Check: Bench (biome_tailwind_parser)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_package)

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

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

Phew, that's some heavy lifting! Left some questions, but looks good to me!

root: &LanguageRoot<CssLanguage>,
filter: AnalysisFilter,
options: &'a AnalyzerOptions,
services: CssAnalyzerServices,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we may want to pass the services by reference instead of by value, so we can avoid a lot of cloning. Are there reasons why the analyser needs to mutate services, maybe? If so, we may want to resolve that in a separate PR, but I feel it would be a good idea to do before scaling up to other services.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, there's no reason to pass the service by value at the moment. We can pass references

/// ```
pub struct SemanticServices {
model: SemanticModel,
model: Arc<SemanticModel>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: If we pass the services to the analyser by reference, do you think wrapping these in Arc is still necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably not!

/// stored with [biome_rowan::AstPtr]. The service needs to accept the language root so
/// the pointer can be retrieved with its typed counter part.
#[derive(Clone, Debug)]
pub enum DocumentServices {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not an immediate concern, but do you think we'll have services that are language-agnostic?

Copy link
Member Author

Choose a reason for hiding this comment

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

Theoretically, we already could! For example we have the biome_aria that is used by two analyzer crates already. Are you onto something?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah, I was just thinking whether an enum is appropriate to store the services longer term, but even if it requires a little duplication it’s fine.

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_service/src/file_handlers/css.rs (1)

713-727: Consider hoisting CssAnalyzerServices construction outside the loop.

CssAnalyzerServices is reconstructed on every iteration, but file_source and the semantic model reference don't change between iterations. Moving this construction before the loop would avoid redundant work.

+    let css_services = CssAnalyzerServices {
+        semantic_model: params
+            .document_services
+            .as_css_services()
+            .and_then(|services| services.semantic_model.as_ref()),
+        file_source,
+    };
+
     loop {
-        let css_services = CssAnalyzerServices {
-            semantic_model: params
-                .document_services
-                .as_css_services()
-                .and_then(|services| services.semantic_model.as_ref()),
-            file_source,
-        };
-
         let (action, _) = analyze(
             &tree,
             filter,
             &analyzer_options,
-            css_services,
+            css_services.clone(),
             &params.plugins,
             |signal| process_fix_all.process_signal(signal),
         );
crates/biome_css_analyze/src/lib.rs (1)

34-53: Add documentation for the new public API.

CssAnalyzerServices is a new public type but lacks doc comments. Please document the struct and its methods to explain their purpose and usage, particularly noting when semantic_model should be provided.

📜 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 65bff06 and 3d6503b.

📒 Files selected for processing (7)
  • crates/biome_css_analyze/benches/css_analyzer.rs (2 hunks)
  • crates/biome_css_analyze/src/lib.rs (11 hunks)
  • crates/biome_css_analyze/src/services/semantic.rs (4 hunks)
  • crates/biome_css_analyze/tests/quick_test.rs (3 hunks)
  • crates/biome_css_analyze/tests/spec_tests.rs (3 hunks)
  • crates/biome_service/src/file_handlers/css.rs (7 hunks)
  • xtask/rules_check/src/lib.rs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • xtask/rules_check/src/lib.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.rs: Use the dbg!() macro for debugging output during testing, and pass the --show-output flag to cargo to view debug output
Use cargo t or cargo test to run tests; for a single test, pass the test name after the test command
Use snapshot testing with the insta crate; run cargo insta accept, cargo insta reject, or cargo insta review to manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Use just f (alias for just format) to format Rust and TOML files before committing

Files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/src/services/semantic.rs
🧠 Learnings (32)
📓 Common learnings
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace*.rs : Implement the Workspace trait in the Biome Service to manage internal state of projects, including open documents, project layout instances, and module graph instances
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `Semantic<T>` query type instead of `Ast<T>` when a rule needs to access the semantic model for binding references and scope information
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : When using multiple services in a rule, use `ctx.get_service::<ServiceType>()` to retrieve services running in the second phase when query runs during that phase
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `Semantic<T>` query type instead of `Ast<T>` when a rule needs to access the semantic model for binding references and scope information

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/src/services/semantic.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use language tags in documentation code blocks (js, ts, tsx, json, css) and order properties consistently as: language, then `expect_diagnostic`, then options modifiers, then `ignore`, then `file=path`

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noUnknown` prefix for rules that report mistyped entities in CSS (e.g., `noUnknownUnit`)

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Check if a variable is global before banning it to avoid false positives when the variable is redeclared in local scope; use the semantic model to verify global scope

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/src/services/semantic.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use `rule_category!()` macro instead of dynamic string parsing to refer to rule diagnostic categories for compile-time validation

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Implement custom `Queryable` types and `Visitor` traits for rules requiring deep AST inspection to avoid redundant traversal passes

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/src/services/semantic.rs
📚 Learning: 2025-11-24T18:04:57.309Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_diagnostics/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:04:57.309Z
Learning: Applies to crates/biome_diagnostics/**/*.rs : Use helper types from the biome_diagnostics::v2 module (CodeFrameAdvice, CommandAdvice, DiffAdvice, LogAdvice) or implement the Advices trait yourself for custom advice handling

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : In rule documentation code blocks, mark invalid examples with the `expect_diagnostic` property and valid examples without it; each invalid example must emit exactly one diagnostic

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Set rule severity to `error` for correctness/security/a11y rules, `warn` for suspicious/performance rules, `info` for style/complexity rules, and `info` for actions

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `noExcessive` prefix for rules that report code exceeding configurable limits (e.g., `noExcessiveNestedTestSuites`)

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Framework-specific rules should be named using the `use` or `no` prefix followed by the framework name (e.g., `noVueReservedProps`)

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Use the `useConsistent` prefix for rules that ensure consistency across the codebase (e.g., `useConsistentArrayType`)

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/css.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `action` function must return a `JsRuleAction` (or equivalent language-specific action type) with category `ctx.action_category(ctx.category(), ctx.group())` and applicability from `ctx.metadata().applicability()`

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/css.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : When navigating CST nodes that return `Result`, use the try operator `?` to convert to `Option`, or use `let else` pattern for `Vec` return types in rule run functions

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : For rules ported from other ecosystems like ESLint or Clippy, add a `sources` field with `RuleSource` metadata using `.same()` for identical behavior or `.inspired()` for different behavior

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Code actions must specify a `fix_kind` field in the `declare_lint_rule!` macro as either `FixKind::Safe` or `FixKind::Unsafe` to indicate whether fixes always preserve program behavior

Applied to files:

  • crates/biome_css_analyze/tests/spec_tests.rs
  • crates/biome_service/src/file_handlers/css.rs
📚 Learning: 2025-11-24T18:06:12.048Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_service/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:12.048Z
Learning: Applies to crates/biome_service/src/workspace/watcher.tests.rs : Implement watcher tests for workspace methods in watcher.tests.rs and end-to-end tests in LSP tests

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : When using multiple services in a rule, use `ctx.get_service::<ServiceType>()` to retrieve services running in the second phase when query runs during that phase

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/src/services/semantic.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/Cargo.toml : Include development dependencies in `Cargo.toml` for formatter tests: `biome_formatter_test`, `biome_<language>_factory`, `biome_<language>_parser`, `biome_parser`, `biome_service`, `countme`, `iai`, `quickcheck`, `quickcheck_macros`, and `tests_macros`

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Avoid using `unwrap()` or `expect()` on `Result` and `Option` types; instead use helper functions like `map`, `filter`, `and_then` to maintain code clarity and avoid panics

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `diagnostic` function must return a `RuleDiagnostic` that defines the message reported to the user using the `markup!` macro

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Lint rules must be implemented using the `Rule` trait with type parameters: `Query` (node type to analyze), `State` (information for signals), `Signals` (return type from run function), and `Options` (rule configuration)

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_css_analyze/src/lib.rs
  • crates/biome_css_analyze/src/services/semantic.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : The `run` function of a lint rule should return `Option<Self::State>` or an iterable like `Vec<Self::State>` or `Box<[Self::State]>` to signal zero or more diagnostics

Applied to files:

  • crates/biome_css_analyze/tests/quick_test.rs
  • crates/biome_service/src/file_handlers/css.rs
📚 Learning: 2025-11-24T18:05:27.810Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_js_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:27.810Z
Learning: Applies to crates/biome_js_formatter/**/*.rs : Import the `FormatNode` trait and implement it for your Node when creating formatters in biome_js_formatter

Applied to files:

  • crates/biome_service/src/file_handlers/css.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/lib.rs : Expose a public `format_node` function that accepts formatting options and a root syntax node, returning a `FormatResult<Formatted<Context>>` with appropriate documentation

Applied to files:

  • crates/biome_service/src/file_handlers/css.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Wrap optional rule option fields in `Option<_>` to properly track set vs unset options during configuration merging

Applied to files:

  • crates/biome_css_analyze/benches/css_analyzer.rs
📚 Learning: 2025-11-24T18:06:03.545Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_parser/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:06:03.545Z
Learning: Applies to crates/biome_parser/**/src/**/*.rs : A parser struct must implement the `Parser` trait and save the token source, parser context, and optional parser options

Applied to files:

  • crates/biome_css_analyze/benches/css_analyzer.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Use quick testing via `tests/quick_test.rs` by removing the `#[ignore]` macro and modifying the `SOURCE` variable to rapidly validate rule behavior during development

Applied to files:

  • crates/biome_css_analyze/benches/css_analyzer.rs
  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/biome_rule_options/src/**/*.rs : Rule options must be defined in the `biome_rule_options` crate and implement traits: `Deserializable`, `Merge`, `Serialize`, `Deserialize`, and `JsonSchema`

Applied to files:

  • crates/biome_css_analyze/benches/css_analyzer.rs
📚 Learning: 2025-11-27T23:04:02.022Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-11-27T23:04:02.022Z
Learning: Applies to crates/biome_analyze/**/*analyze/src/lint/**/*.rs : Rules should use the `use` prefix naming convention when the sole intention is to mandate a single concept (e.g., `useValidLang` to enforce valid HTML lang attribute values)

Applied to files:

  • crates/biome_css_analyze/src/lib.rs
📚 Learning: 2025-11-24T18:05:20.371Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_formatter/CONTRIBUTING.md:0-0
Timestamp: 2025-11-24T18:05:20.371Z
Learning: Applies to crates/biome_formatter/**/biome_*_formatter/src/context.rs : Define `<Language>FormatContext` struct in a `context.rs` file containing `comments` and `source_map` fields, implementing `FormatContext` and `CstFormatContext` traits

Applied to files:

  • crates/biome_css_analyze/src/lib.rs
🧬 Code graph analysis (3)
crates/biome_css_analyze/tests/spec_tests.rs (2)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_test_utils/src/lib.rs (2)
  • diagnostic_to_string (270-275)
  • code_fix_to_string (344-355)
crates/biome_css_analyze/tests/quick_test.rs (1)
crates/biome_css_analyze/src/lib.rs (1)
  • analyze (58-79)
crates/biome_css_analyze/src/lib.rs (2)
crates/biome_css_semantic/src/semantic_model/model.rs (2)
  • root (34-36)
  • root (35-35)
crates/biome_css_syntax/src/file_source.rs (1)
  • css (35-39)
⏰ 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). (25)
  • GitHub Check: Bench (biome_module_graph)
  • GitHub Check: Test Node.js API
  • GitHub Check: Bench (biome_css_analyze)
  • GitHub Check: Bench (biome_css_formatter)
  • GitHub Check: Bench (biome_css_parser)
  • GitHub Check: Documentation
  • GitHub Check: End-to-end tests
  • GitHub Check: Test (depot-windows-2022-16)
  • GitHub Check: Test (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Bench (biome_configuration)
  • GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
  • GitHub Check: Check Dependencies
  • GitHub Check: Lint project (depot-windows-2022)
  • GitHub Check: autofix
  • GitHub Check: Bench (biome_graphql_formatter)
  • GitHub Check: Bench (biome_js_formatter)
  • GitHub Check: Bench (biome_graphql_parser)
  • GitHub Check: Bench (biome_js_analyze)
  • GitHub Check: Bench (biome_js_parser)
  • GitHub Check: Parser conformance
  • GitHub Check: Bench (biome_tailwind_parser)
  • GitHub Check: Bench (biome_json_parser)
  • GitHub Check: Bench (biome_json_formatter)
  • GitHub Check: Bench (biome_json_analyze)
  • GitHub Check: Bench (biome_package)
🔇 Additional comments (12)
crates/biome_service/src/file_handlers/css.rs (4)

25-25: LGTM!

Import of CssAnalyzerServices and analyze aligns with the new service-driven analysis flow.


41-41: LGTM!

Cleaned up unused tracing imports—tidy.


540-596: LGTM!

The lint function now correctly:

  1. Exits early when the language cannot yield a CSS file source
  2. Constructs CssAnalyzerServices with the semantic model from document services
  3. Passes services to analyze

The pattern of using as_css_services().and_then(...) for optional semantic model access is appropriately defensive.


598-675: LGTM!

The code_actions function now mirrors the lint flow with proper CssAnalyzerServices construction and passes it through to the analyzer. The mapping of analyzer signals to CodeAction entries is clear.

crates/biome_css_analyze/benches/css_analyzer.rs (1)

60-69: LGTM!

Semantic model is correctly computed once outside the benchmark loop, whilst services.clone() inside the closure ensures each benchmark iteration gets a fresh clone. This is the right approach for accurate benchmarking.

crates/biome_css_analyze/tests/quick_test.rs (1)

23-35: LGTM!

Quick test correctly constructs CssAnalyzerServices using the builder pattern and passes it to analyze. This aligns with the updated API.

crates/biome_css_analyze/tests/spec_tests.rs (2)

133-137: LGTM!

The analyze_and_snap function correctly constructs the semantic model and CssAnalyzerServices using the builder pattern with the appropriate source_type.


137-187: LGTM!

The callback logic properly handles both diagnostic-bearing signals and standalone actions, with appropriate separation of suppression vs. lint action paths. The control flow is clear and well-structured.

crates/biome_css_analyze/src/services/semantic.rs (3)

73-75: LGTM!

The build_visitor simplification aligns with the new architecture where the semantic model is provided externally rather than built during analysis. Only SyntaxVisitor is needed since the semantic model is pre-computed.


35-39: The Phase change from Phases::Semantic to Phases::Syntax is correct. The semantic model is now provided externally via CssAnalyzerServices and injected during analysis setup. Rules using Semantic<N> (such as no_duplicate_properties, no_duplicate_custom_properties, no_missing_var_function, and no_descending_specificity) access the model through the service, not through phase sequencing. This design allows rules to run during the syntax phase while still having access to semantic information via dependency injection.


9-11: No changes needed. The SemanticModel still contains an internal Arc<SemanticModelData> field and a GreenNode (which wraps ThinArc). Cloning SemanticModel is already efficient because the heavy data is behind Arc/ThinArc pointers. The current implementation is correct.

Likely an incorrect or invalid review comment.

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

62-62: This review comment is based on a misunderstanding of the design.

CssAnalyzerServices is a lightweight struct that derives Clone and contains only references (Option<&'a SemanticModel>) and a simple type (CssFileSource). Passing it by value is idiomatic Rust and incurs negligible overhead—cloning only increments reference counts. Similarly, at line 92, semantic_model.clone() clones a reference, which is cheap.

The current design is correct and does not require changes.

@ematipico ematipico merged commit 9266677 into main Dec 4, 2025
30 checks passed
@ematipico ematipico deleted the refactor/document-services branch December 4, 2025 08:19
ematipico added a commit that referenced this pull request Dec 8, 2025
l0ngvh pushed a commit to l0ngvh/biome that referenced this pull request Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter A-Project Area: project A-Tooling Area: internal tools L-CSS Language: CSS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants