-
-
Notifications
You must be signed in to change notification settings - Fork 780
feat(graph): support CSS files #8329
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
5c447eb to
65bff06
Compare
6cc0fdb to
e743ec3
Compare
CodSpeed Performance ReportMerging #8329 will not alter performanceComparing Summary
Footnotes
|
Parser conformance results onjs/262
jsx/babel
symbols/microsoft
ts/babel
ts/microsoft
|
e743ec3 to
15916d5
Compare
WalkthroughThis change introduces CSS module import support to Biome's module graph infrastructure. The refactoring adds a ModuleInfo enum to distinguish between JavaScript and CSS modules, replacing the previous JavaScript-only storage model. New CSS-specific types (CssModuleInfo, CssImports, CssImport) and a visitor implementation enable parsing of CSS imports. The module graph now stores and resolves both JS and CSS modules, with corresponding updates to public APIs for module lookup and symbol resolution. Test fixtures and utilities are added to validate CSS import resolution. Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
♻️ Duplicate comments (1)
crates/biome_service/src/scanner/workspace_watcher_bridge.tests.rs (1)
115-119: SameModuleInfoaccess pattern as aboveThis block mirrors the earlier assertion; comments about
as_js_module_info().unwrap()and the expected JS-only path apply here too.
🧹 Nitpick comments (11)
crates/biome_ruledoc_utils/src/lib.rs (1)
82-85: Call updated to newupdate_graph_for_js_pathssignatureAdjusting to
module_graph.update_graph_for_js_paths(&fs, &layout, &added_paths);matches the new API and keeps the ruledoc builder JS-focused. When/if you start documenting CSS rules via this path, you can mirror this withupdate_graph_for_css_pathsas well, but that’s strictly a future enhancement.crates/biome_js_analyze/src/services/module_graph.rs (1)
19-21: Service now uses JS-specific graph accessor
module_info_for_pathdelegating tojs_module_info_for_pathis consistent with this being a JS-only service wrapper around the shared graph. You might eventually consider renaming the method tojs_module_info_for_pathfor clarity, but that’s purely cosmetic.crates/biome_module_graph/src/js_module_info.rs (1)
60-66: API rename clarifies JS scope; consider a deprecated aliasRenaming to
find_js_exported_symbolmatches the JS-only nature of this API and the surrounding naming, while keeping the behaviour identical. If you expect external crates to depend onbiome_module_graph, a thin#[deprecated]alias under the old name could smooth over any semver bumps.crates/biome_test_utils/src/lib.rs (1)
236-256: Newget_css_added_pathshelper mirrors the JS versionThe CSS helper cleanly parallels
get_added_paths: it reads from the abstractFileSystem, parses CSS, asserts no diagnostics, and returns(BiomePath, CssRoot)pairs, which is exactly what the new CSS graph tests need. If duplication with the JS helper ever gets annoying, a tiny generic “parse with diagnostics assert” helper could deduplicate the pattern, but it’s fine as-is.crates/biome_lsp/src/server.tests.rs (1)
3841-3845: Consider adding an assertion before the unwrap.Whilst panics are acceptable in tests, you could make failures clearer:
.map(|module_info| { let js_info = module_info.as_js_module_info() .expect("Expected JS module info for .js file"); js_info.static_import_paths.clone() })This provides better context if the test fails unexpectedly.
Also applies to: 3872-3876
crates/biome_css_syntax/src/import_ext.rs (1)
5-12: Complete the documentation example.The doc comment includes an empty example block. Either provide a meaningful example or remove the section:
/// Returns the inner text of the import specifier. /// /// # Examples /// /// ``` /// use biome_css_parser::parse_css; /// use biome_css_syntax::CssFileSource; /// // Example: "@import 'style.css';" -> "style.css" /// ```Or simply remove the empty
## Examplessection if examples aren't needed yet.crates/biome_service/src/workspace/server.rs (1)
544-564: New helperget_parse_and_serviceslooks good.Clean extraction of parse and services from the document. One minor note: on line 560, you're cloning
syntaxandserviceseven though you already have ownership after the.cloned()on line 554. The second.clone()calls are redundant.Ok(syntax) => match syntax { None => Err(WorkspaceError::not_found()), - Some(syntax) => Ok((syntax.clone(), services.clone())), + Some(syntax) => Ok((syntax, services)), },crates/biome_module_graph/src/css_module_info/visitor.rs (2)
7-7: Unused import.
std::ops::DerefMutis imported but not directly used. TheDerefMuttrait is auto-imported when you call.deref_mut()on a type that implements it.-use std::ops::DerefMut;
54-61: Simplify insertion.Since
CssImportsimplementsDerefMut, you can callinsertdirectly without the explicit.deref_mut().- imports.deref_mut().insert( + imports.insert( text.clone(), CssImport { specifier: text, resolved_path, }, );crates/biome_module_graph/src/module_graph.rs (2)
163-176: Consider adding an accessor method for CSS imports.Accessing
module.0.importsdirectly exposes the internal structure. Adding animports()accessor toCssModuleInfo(similar to howJsModuleInfoexposes its data) would improve encapsulation.- for (_, path) in module.0.imports.deref() { + for (_, path) in module.imports() {This would require adding an
imports()method toCssModuleInfo:pub fn imports(&self) -> &CssImports { &self.0.imports }
281-295: Consider explicit pattern matching for future-proofing.Using
_ => Noneworks but explicit matching would catch any future enum variants at compile time.pub fn as_js_module_info(&self) -> Option<&SerializedJsModuleInfo> { match self { Self::Js(module) => Some(module), - _ => None, + Self::Css(_) => None, } } pub fn as_css_module_info(&self) -> Option<&SerializedCssModuleInfo> { match self { Self::Css(module) => Some(module), - _ => None, + Self::Js(_) => None, } }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (3)
Cargo.lockis excluded by!**/*.lockand included by**crates/biome_service/src/snapshots/biome_service__workspace__tests__debug_module_graph.snapis excluded by!**/*.snapand included by**packages/@biomejs/backend-jsonrpc/src/workspace.tsis excluded by!**/backend-jsonrpc/src/workspace.tsand included by**
📒 Files selected for processing (28)
crates/biome_css_syntax/src/import_ext.rs(1 hunks)crates/biome_css_syntax/src/lib.rs(1 hunks)crates/biome_js_analyze/src/lib.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_deprecated_imports.rs(1 hunks)crates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rs(1 hunks)crates/biome_js_analyze/src/services/module_graph.rs(1 hunks)crates/biome_lsp/src/server.tests.rs(2 hunks)crates/biome_module_graph/Cargo.toml(1 hunks)crates/biome_module_graph/benches/module_graph.rs(0 hunks)crates/biome_module_graph/src/css_module_info.rs(1 hunks)crates/biome_module_graph/src/css_module_info/visitor.rs(1 hunks)crates/biome_module_graph/src/js_module_info.rs(1 hunks)crates/biome_module_graph/src/js_module_info/module_resolver.rs(1 hunks)crates/biome_module_graph/src/lib.rs(2 hunks)crates/biome_module_graph/src/module_graph.rs(7 hunks)crates/biome_module_graph/tests/fixtures/css/index.css(1 hunks)crates/biome_module_graph/tests/fixtures/css/package.json(1 hunks)crates/biome_module_graph/tests/snap/mod.rs(2 hunks)crates/biome_module_graph/tests/spec_tests.rs(41 hunks)crates/biome_rowan/src/syntax/node.rs(1 hunks)crates/biome_ruledoc_utils/src/lib.rs(1 hunks)crates/biome_service/src/file_handlers/javascript.rs(1 hunks)crates/biome_service/src/scanner/workspace_watcher_bridge.tests.rs(2 hunks)crates/biome_service/src/workspace.rs(2 hunks)crates/biome_service/src/workspace.tests.rs(1 hunks)crates/biome_service/src/workspace/server.rs(12 hunks)crates/biome_test_utils/Cargo.toml(1 hunks)crates/biome_test_utils/src/lib.rs(3 hunks)
💤 Files with no reviewable changes (1)
- crates/biome_module_graph/benches/module_graph.rs
🧰 Additional context used
📓 Path-based instructions (4)
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Use thedbg!()macro for debugging output during testing, and pass the--show-outputflag tocargoto view debug output
Usecargo torcargo testto run tests; for a single test, pass the test name after thetestcommand
Use snapshot testing with theinstacrate; runcargo insta accept,cargo insta reject, orcargo insta reviewto manage snapshot changes
Write doctests as doc comments with code blocks; the code inside code blocks will be run during the testing phase
Usejust f(alias forjust format) to format Rust and TOML files before committing
Files:
crates/biome_css_syntax/src/lib.rscrates/biome_js_analyze/src/lint/nursery/no_deprecated_imports.rscrates/biome_service/src/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/workspace.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_ruledoc_utils/src/lib.rscrates/biome_module_graph/src/js_module_info.rscrates/biome_css_syntax/src/import_ext.rscrates/biome_js_analyze/src/services/module_graph.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rscrates/biome_rowan/src/syntax/node.rscrates/biome_lsp/src/server.tests.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/css_module_info.rscrates/biome_service/src/workspace/server.rscrates/biome_module_graph/src/css_module_info/visitor.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_test_utils/src/lib.rscrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/tests/spec_tests.rscrates/biome_module_graph/src/module_graph.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.rscrates/biome_service/src/workspace.tests.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
**/*.toml
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use
just f(alias forjust format) to format TOML files before committing
Files:
crates/biome_test_utils/Cargo.tomlcrates/biome_module_graph/Cargo.toml
🧠 Learnings (59)
📓 Common learnings
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/**/scoped_resolver.rs : Implement full inference to resolve `TypeReference::Import` variants across the entire module graph
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/**/js_module_info/collector.rs : Implement module-level (thin) inference to resolve `TypeReference::Qualifier` variants by looking up declarations in module scopes and handling import statements
📚 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_syntax/src/lib.rscrates/biome_test_utils/Cargo.tomlcrates/biome_test_utils/src/lib.rscrates/biome_module_graph/Cargo.tomlcrates/biome_module_graph/tests/spec_tests.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: Create two new crates `biome_{language}_syntax` and `biome_{language}_factory` using `cargo new --lib` for new language parsers
Applied to files:
crates/biome_css_syntax/src/lib.rscrates/biome_test_utils/Cargo.tomlcrates/biome_module_graph/Cargo.toml
📚 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/**/scoped_resolver.rs : Implement full inference to resolve `TypeReference::Import` variants across the entire module graph
Applied to files:
crates/biome_css_syntax/src/lib.rscrates/biome_js_analyze/src/lint/nursery/no_deprecated_imports.rscrates/biome_service/src/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/workspace.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_ruledoc_utils/src/lib.rscrates/biome_css_syntax/src/import_ext.rscrates/biome_js_analyze/src/services/module_graph.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rscrates/biome_lsp/src/server.tests.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/css_module_info.rscrates/biome_module_graph/src/css_module_info/visitor.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/tests/spec_tests.rscrates/biome_module_graph/src/module_graph.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 : No module may copy or clone data from another module in the module graph, not even behind an `Arc`
Applied to files:
crates/biome_css_syntax/src/lib.rscrates/biome_js_analyze/src/lint/nursery/no_deprecated_imports.rscrates/biome_service/src/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/workspace.rscrates/biome_ruledoc_utils/src/lib.rscrates/biome_js_analyze/src/services/module_graph.rscrates/biome_lsp/src/server.tests.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/css_module_info.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/Cargo.tomlcrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/tests/spec_tests.rscrates/biome_module_graph/src/module_graph.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/**/local_inference.rs : Implement local inference in dedicated modules to derive type definitions from expressions without context of surrounding scopes
Applied to files:
crates/biome_css_syntax/src/lib.rscrates/biome_service/src/workspace.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_ruledoc_utils/src/lib.rscrates/biome_js_analyze/src/services/module_graph.rscrates/biome_lsp/src/server.tests.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/css_module_info.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/src/module_graph.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/**/language_kind.rs : Add a new language prefix to the `LANGUAGE_PREFIXES` constant in `language_kind.rs` file
Applied to files:
crates/biome_css_syntax/src/lib.rscrates/biome_service/src/workspace/server.rscrates/biome_test_utils/Cargo.toml
📚 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_syntax/src/lib.rscrates/biome_js_analyze/src/lint/nursery/no_deprecated_imports.rscrates/biome_service/src/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/workspace.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_ruledoc_utils/src/lib.rscrates/biome_module_graph/src/js_module_info.rscrates/biome_js_analyze/src/services/module_graph.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rscrates/biome_lsp/src/server.tests.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/css_module_info.rscrates/biome_test_utils/Cargo.tomlcrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/Cargo.tomlcrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/tests/spec_tests.rscrates/biome_module_graph/src/module_graph.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_syntax/src/lib.rscrates/biome_test_utils/Cargo.toml
📚 Learning: 2025-11-28T09:08:10.091Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.091Z
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_css_syntax/src/lib.rscrates/biome_service/src/scanner/workspace_watcher_bridge.tests.rscrates/biome_ruledoc_utils/src/lib.rscrates/biome_module_graph/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/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_syntax/src/lib.rscrates/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 : 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_js_analyze/src/lint/nursery/no_deprecated_imports.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/**/js_module_info/collector.rs : Implement module-level (thin) inference to resolve `TypeReference::Qualifier` variants by looking up declarations in module scopes and handling import statements
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_deprecated_imports.rscrates/biome_service/src/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/workspace.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_ruledoc_utils/src/lib.rscrates/biome_module_graph/src/js_module_info.rscrates/biome_js_analyze/src/services/module_graph.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rscrates/biome_lsp/src/server.tests.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/css_module_info.rscrates/biome_module_graph/src/css_module_info/visitor.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/tests/spec_tests.rscrates/biome_module_graph/src/module_graph.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_js_analyze/src/lint/nursery/no_deprecated_imports.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.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_js_analyze/src/lint/nursery/no_deprecated_imports.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rscrates/biome_lsp/src/server.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 : Use the `noUndeclared` prefix for rules that report undefined entities (e.g., `noUndeclaredVariables`)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_deprecated_imports.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.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_js_analyze/src/lint/nursery/no_deprecated_imports.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_js_analyze/src/lint/nursery/no_deprecated_imports.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rscrates/biome_module_graph/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:
crates/biome_service/src/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/workspace.rscrates/biome_lsp/src/server.tests.rscrates/biome_service/src/workspace/server.rscrates/biome_test_utils/Cargo.tomlcrates/biome_test_utils/src/lib.rscrates/biome_module_graph/Cargo.tomlcrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/tests/spec_tests.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/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/workspace.rscrates/biome_js_analyze/src/services/module_graph.rscrates/biome_service/src/workspace/server.rscrates/biome_test_utils/Cargo.tomlcrates/biome_test_utils/src/lib.rscrates/biome_module_graph/Cargo.tomlcrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/src/module_graph.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/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/workspace.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_ruledoc_utils/src/lib.rscrates/biome_js_analyze/src/services/module_graph.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/css_module_info.rscrates/biome_test_utils/Cargo.tomlcrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/Cargo.tomlcrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/src/module_graph.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 : Distinguish between `TypeData::Unknown` and `TypeData::UnknownKeyword` to measure inference effectiveness versus explicit user-provided unknown types
Applied to files:
crates/biome_service/src/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rscrates/biome_lsp/src/server.tests.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/module_graph.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 : Always apply the correct `ResolverId` when retrieving raw type data from `ResolvedTypeData.as_raw_data()` to prevent panics during subsequent resolution calls
Applied to files:
crates/biome_service/src/scanner/workspace_watcher_bridge.tests.rscrates/biome_service/src/workspace.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_lsp/src/server.tests.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_service/src/workspace.tests.rs
📚 Learning: 2025-08-20T16:24:59.781Z
Learnt from: arendjr
Repo: biomejs/biome PR: 7266
File: crates/biome_js_type_info/src/type.rs:94-102
Timestamp: 2025-08-20T16:24:59.781Z
Learning: In crates/biome_js_type_info/src/type.rs, the flattened_union_variants() method returns TypeReference instances that already have the correct module IDs applied to them. These references should be used directly with resolver.resolve_reference() without applying additional module ID transformations, as variant references may originate from nested unions in different modules.
Applied to files:
crates/biome_service/src/workspace.rscrates/biome_js_analyze/src/services/module_graph.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/css_module_info.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_service/src/workspace.tests.rscrates/biome_module_graph/src/module_graph.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/workspace.rscrates/biome_service/src/workspace/server.rscrates/biome_test_utils/Cargo.tomlcrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/Cargo.toml
📚 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/workspace.rscrates/biome_service/src/workspace/server.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/Cargo.tomlcrates/biome_module_graph/tests/spec_tests.rscrates/biome_module_graph/src/module_graph.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` variants (`Qualifier`, `Resolved`, `Import`, `Unknown`) to represent different phases of type resolution
Applied to files:
crates/biome_service/src/workspace.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/css_module_info.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/src/lib.rscrates/biome_module_graph/src/js_module_info/module_resolver.rscrates/biome_module_graph/src/module_graph.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 `TypeData::Unknown` to indicate when type inference falls short or is not implemented
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 : When using `ResolvedTypeData`, track the `ResolverId` to ensure subsequent resolver calls use the correct context
Applied to files:
crates/biome_service/src/file_handlers/javascript.rscrates/biome_js_analyze/src/lib.rscrates/biome_module_graph/src/js_module_info/module_resolver.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/**/tests/specs/**/*.jsonc : Use `.jsonc` files in test specs with code snippets as array of strings to test rules in script environment (no import/export syntax)
Applied to files:
crates/biome_module_graph/tests/fixtures/css/index.csscrates/biome_module_graph/tests/fixtures/css/package.json
📚 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/**/tests/specs/**/*.{js,ts,tsx,jsx,json,css} : Test rules using snapshot tests via the `insta` library with test cases in `tests/specs/<group>/<rule_name>/` directories prefixed by `invalid` or `valid`
Applied to files:
crates/biome_module_graph/tests/fixtures/css/index.css
📚 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_ruledoc_utils/src/lib.rscrates/biome_module_graph/tests/snap/mod.rscrates/biome_module_graph/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/**/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_ruledoc_utils/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 : Wrap optional rule option fields in `Option<_>` to properly track set vs unset options during configuration merging
Applied to files:
crates/biome_ruledoc_utils/src/lib.rscrates/biome_service/src/workspace/server.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 : Implement a token source struct that wraps the lexer and implements `TokenSourceWithBufferedLexer` and `LexerWithCheckpoint` for lookahead and re-lexing capabilities
Applied to files:
crates/biome_css_syntax/src/import_ext.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_syntax/src/import_ext.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/**/language_kind.rs : Add a new variant to `LanguageKind` enum in `language_kind.rs` file and implement all methods for the new language variant
Applied to files:
crates/biome_css_syntax/src/import_ext.rscrates/biome_rowan/src/syntax/node.rscrates/biome_service/src/workspace/server.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_syntax/src/import_ext.rscrates/biome_module_graph/tests/snap/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 : Use the `noUnknown` prefix for rules that report mistyped entities in CSS (e.g., `noUnknownUnit`)
Applied to files:
crates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rscrates/biome_module_graph/src/css_module_info/visitor.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_rowan/src/syntax/node.rscrates/biome_module_graph/tests/snap/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 : 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_lsp/src/server.tests.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/specs/**/options.json : Create an `options.json` file (formatted as `biome.json`) in test specification folders to apply non-default formatting options to all test files in that folder
Applied to files:
crates/biome_module_graph/tests/fixtures/css/package.json
📚 Learning: 2025-08-05T14:43:29.581Z
Learnt from: dyc3
Repo: biomejs/biome PR: 7081
File: packages/@biomejs/biome/configuration_schema.json:7765-7781
Timestamp: 2025-08-05T14:43:29.581Z
Learning: The file `packages/biomejs/biome/configuration_schema.json` is auto-generated and should not be manually edited or reviewed for schema issues; any changes should be made at the code generation source.
Applied to files:
crates/biome_module_graph/tests/fixtures/css/package.jsoncrates/biome_test_utils/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:
crates/biome_module_graph/tests/fixtures/css/package.json
📚 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 #[derive(Diagnostic)] on enums when every variant contains a type that is itself a diagnostic
Applied to files:
crates/biome_service/src/workspace/server.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 : Implement the Diagnostic trait on types, or use the #[derive(Diagnostic)] procedural macro to implement the trait. Configure category, severity, description, message, location, and tags using the #[diagnostic] attribute
Applied to files:
crates/biome_service/src/workspace/server.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 : Ensure the type implementing Diagnostic derives Debug
Applied to files:
crates/biome_service/src/workspace/server.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/crates/biome_diagnostics_categories/src/categories.rs : Register all new diagnostic categories in crates/biome_diagnostics_categories/src/categories.rs
Applied to files:
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 : Implement custom `Queryable` types and `Visitor` traits for rules requiring deep AST inspection to avoid redundant traversal passes
Applied to files:
crates/biome_module_graph/src/css_module_info/visitor.rs
📚 Learning: 2025-11-28T09:08:10.091Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-11-28T09:08:10.091Z
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_test_utils/Cargo.tomlcrates/biome_module_graph/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:
crates/biome_test_utils/Cargo.tomlcrates/biome_test_utils/src/lib.rscrates/biome_module_graph/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: Use the `just gen-formatter` command to generate initial formatter implementations from the grammar, which will use `format_verbatim_node` that must be replaced with proper `biome_formatter` utilities
Applied to files:
crates/biome_module_graph/tests/snap/mod.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 `ParseSeparatedList` and `ParseNodeList` for parsing lists with error recovery to avoid infinite loops
Applied to files:
crates/biome_test_utils/src/lib.rscrates/biome_module_graph/tests/spec_tests.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/spec_tests.rs : Use the `tests_macros::gen_tests!` macro in `spec_tests.rs` to generate test functions for each specification file matching the pattern `tests/specs/<language>/**/*.<ext>`
Applied to files:
crates/biome_module_graph/tests/spec_tests.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_module_graph/tests/spec_tests.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 : For tokens that are not mandatory, use helper functions instead of hardcoding
Applied to files:
crates/biome_module_graph/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/**/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_module_graph/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/**/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_module_graph/tests/spec_tests.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: Create test infrastructure with `tests/specs` folder structure and `spec_test.rs`, `spec_tests.rs`, and `language.rs` files in test directories
Applied to files:
crates/biome_module_graph/tests/spec_tests.rs
🧬 Code graph analysis (11)
crates/biome_service/src/scanner/workspace_watcher_bridge.tests.rs (1)
crates/biome_module_graph/src/module_graph.rs (2)
as_js_module_info(282-287)as_js_module_info(305-310)
crates/biome_css_syntax/src/import_ext.rs (1)
crates/biome_css_syntax/src/lib.rs (1)
inner_string_text(189-198)
crates/biome_rowan/src/syntax/node.rs (2)
crates/biome_service/src/workspace/document.rs (1)
node(183-185)crates/biome_rowan/src/ast/mod.rs (1)
unwrap_cast(200-212)
crates/biome_lsp/src/server.tests.rs (1)
crates/biome_module_graph/src/module_graph.rs (2)
as_js_module_info(282-287)as_js_module_info(305-310)
crates/biome_js_analyze/src/lib.rs (1)
crates/biome_service/src/configuration.rs (1)
file_path(113-115)
crates/biome_module_graph/src/css_module_info.rs (3)
crates/biome_module_graph/src/js_module_info.rs (4)
deref(38-40)deref(218-220)deref(229-231)dump(96-131)crates/biome_module_graph/src/module_graph.rs (2)
deref(387-389)dump(298-303)crates/biome_module_graph/src/css_module_info/visitor.rs (1)
new(18-28)
crates/biome_service/src/workspace/server.rs (2)
crates/biome_css_semantic/src/semantic_model/model.rs (2)
root(34-36)root(35-35)crates/biome_rowan/src/syntax/node.rs (1)
into_language_root(863-869)
crates/biome_module_graph/src/css_module_info/visitor.rs (1)
crates/biome_module_graph/src/css_module_info.rs (1)
new(25-28)
crates/biome_test_utils/src/lib.rs (2)
packages/@biomejs/js-api/src/wasm.ts (1)
BiomePath(1-1)crates/biome_css_parser/src/lib.rs (1)
parse_css(27-30)
crates/biome_service/src/workspace.tests.rs (1)
crates/biome_module_graph/src/module_graph.rs (2)
as_js_module_info(282-287)as_js_module_info(305-310)
crates/biome_module_graph/src/module_graph.rs (4)
crates/biome_module_graph/src/js_module_info.rs (2)
diagnostics(53-55)dump(96-131)crates/biome_module_graph/src/css_module_info.rs (2)
new(25-28)dump(30-39)crates/biome_module_graph/src/css_module_info/visitor.rs (1)
new(18-28)crates/biome_module_graph/src/js_module_info/collector.rs (1)
new(1117-1133)
🔇 Additional comments (30)
crates/biome_rowan/src/syntax/node.rs (1)
863-869: Consider the panic behaviour or add documentation.This method returns
Option<N>, suggesting it handles failure gracefully. However,N::unwrap_castwill panic if the language matches but the node kind doesn't match the expected root typeN.If this panic is intentional (indicating a programming error), please document it in the method's documentation, similar to
to_language_rootbelow. Alternatively, consider whether this should returnResultor use a fallible cast method.crates/biome_module_graph/Cargo.toml (1)
19-20: CSS workspace dependencies wired correctlyAdding
biome_css_semanticandbiome_css_syntaxas workspace dependencies here is consistent with the new CSS-aware module graph and follows the workspace dependency pattern. No issues from this file.crates/biome_module_graph/tests/fixtures/css/package.json (1)
1-4: Minimal CSS fixture manifest looks fineThe minimal
package.json(name + version) is perfectly adequate for the CSS module graph tests and keeps the fixture simple.crates/biome_module_graph/tests/fixtures/css/index.css (1)
1-2: Good coverage of CSS import formsUsing both
@import "foo.css";and@import "./bar.css";gives nice coverage for bare vs relative CSS imports in the module graph tests. Looks good.crates/biome_test_utils/Cargo.toml (1)
21-22: CSS parser dependencies correctly added to test utilsBringing in
biome_css_parserandbiome_css_syntaxas workspace dependencies is consistent with how other language tooling is wired inbiome_test_utils. No concerns here.crates/biome_css_syntax/src/lib.rs (1)
3-10: import_ext module is cleanly integratedAdding
mod import_ext;alongside the other internal modules keeps the new import helpers encapsulated and does not alter the public API surface. Integration here looks tidy.crates/biome_js_analyze/src/lint/nursery/no_unresolved_imports.rs (1)
260-264: Use offind_js_exported_symbolmatches JS-only rule semanticsSwitching to
target_info.find_js_exported_symbolis the right move now that the module graph can host non-JS modules: this rule is JS-only and should ignore CSS (or other) exports. The lookup remains constrained by the samemodule_graphcontext, so behaviour is preserved for JS while avoiding cross-language confusion.crates/biome_js_analyze/src/lib.rs (1)
161-164: Resolver now correctly targets JS module infoUsing
js_module_info_for_pathhere makes the type resolver explicitly JS-centric, which is whatJsAnalyzerServicesexpects now that the module graph can host multiple module kinds. The surrounding logic is unchanged, so this is a safe and more precise lookup.crates/biome_service/src/scanner/workspace_watcher_bridge.tests.rs (1)
79-83: Static import assertion correctly adapted toModuleInfoUsing
as_js_module_info().unwrap().static_import_paths.clone()keeps the test aligned with the newModuleInfoenum; theunwrapis fine here because the fixture is a.jsfile and a panic would indicate a genuine bug in the graph.crates/biome_service/src/file_handlers/javascript.rs (1)
627-638:debug_type_infonow correctly uses JS-specific module infoSwapping to
graph.js_module_info_for_path(path)makes the no-parse-path branch explicitly JS-only and consistent with the updated graph API, without changing the observable behaviour ofdebug_type_info.crates/biome_js_analyze/src/lint/nursery/no_deprecated_imports.rs (1)
128-140: Deprecation lookup correctly narrowed to JS modulesUsing
module_graph.js_module_info_for_path(target_path)keeps this rule’s resolution strictly JS-focused; unresolved or non-JS targets just bail out as before, which matches the rule’slanguage: "js"scope.crates/biome_service/src/workspace.tests.rs (1)
348-352: Module graph assertion updated to useas_js_module_infoThe assertion now correctly unwraps the JS variant from
ModuleInfobefore readingstatic_import_paths, which matches the new graph representation and is appropriate for this.ts-only test.crates/biome_module_graph/src/js_module_info/module_resolver.rs (1)
167-178: Registering imported modules viajs_module_info_for_pathSwitching to
self.module_graph.js_module_info_for_path(path)?keepsModuleResolverfirmly in JS territory and lines up with the new graph APIs, without altering the import-resolution flow.crates/biome_test_utils/src/lib.rs (2)
33-35: CSS parser types wired into test utilitiesImporting
CssParserOptionsandCssRoothere makes sense given the new CSS graph tests and keeps the CSS helpers nicely local tobiome_test_utils.
207-208: JS test module graph updated to new JS-path APICalling
update_graph_for_js_paths(&fs, project_layout, &paths)matches the updated signature and keeps this helper focused on JS/TS inputs; CSS fixtures can now go through the separate CSS-specific path.crates/biome_module_graph/tests/snap/mod.rs (1)
89-121: LGTM! Clean pattern matching for the new ModuleInfo variants.The empty CSS branch is appropriate for snapshot testing at this stage.
crates/biome_service/src/workspace.rs (1)
66-66: Straightforward migration to SerializedModuleInfo.The type rename cleanly extends support to both JS and CSS modules whilst maintaining API compatibility.
Also applies to: 1353-1353
crates/biome_css_syntax/src/import_ext.rs (1)
13-26: Implementation looks solid.The pattern matching is exhaustive and error handling is appropriate. The method cleanly extracts inner text from both CSS string literals and url() function values.
crates/biome_service/src/workspace/server.rs (2)
898-925: CSS module graph update looks solid.The branching logic correctly handles JS vs CSS roots, and the CSS path appropriately requires both the CSS root and CSS services (semantic model) to be available. The fallback to
Default::default()for unrecognised roots is sensible.
2486-2498: Debug implementation updated correctly.The tuple now reflects the three-field variant, though it still only displays
reasonfor brevity. That's a reasonable choice.crates/biome_module_graph/src/lib.rs (1)
1-20: Clean module structure expansion for CSS support.The new
css_module_infomodule and its public re-exports follow the established pattern fromjs_module_info. The expanded exports frommodule_graphalign well with the new multi-language module info design.crates/biome_module_graph/tests/spec_tests.rs (1)
2205-2284: Good test coverage for CSS imports.The new
resolves_css_imports_correctlytest properly exercises CSS import resolution with both relative (./bar.css) and non-prefixed (foo.css) specifiers. Nice use of the newget_css_added_pathsutility.crates/biome_module_graph/src/css_module_info/visitor.rs (1)
30-45: Clean visitor implementation.The preorder traversal correctly captures CSS import URLs. The pattern matches the established approach in the JS module visitor.
crates/biome_module_graph/src/css_module_info.rs (1)
12-40: Solid CSS module info structure.The
CssModuleInfowrapper withArcfollows the established pattern fromJsModuleInfo. TheDerefimplementation and serialisation logic look correct.crates/biome_module_graph/src/module_graph.rs (6)
13-28: LGTM!Imports are well-organised and align with the new CSS module support.
43-70: LGTM!The data structure generalisation and the new accessor method are correctly implemented. The clone is necessary due to the hashmap guard semantics.
125-129: LGTM!Clean use of the
Fromtrait for convertingJsModuleInfointoModuleInfo.
254-270: LGTM!Clean enum design with idiomatic
Fromimplementations.
297-318: LGTM!The
dump()method and accessors are correctly implemented. The same wildcard pattern suggestion from theSerializedModuleInforeview applies here.
320-365: LGTM!The function correctly handles the new
ModuleInfoenum by only descending into JS modules when resolving re-exports. CSS modules are appropriately skipped since they don't participate in JS-style export resolution.
| /// Map of all static imports found in the module. | ||
| /// | ||
| /// Maps from the local imported name to a [JsImport] with the absolute path | ||
| /// it resolves to. The resolved path may be looked up as key in the | ||
| /// [ModuleGraph::data] map, although it is not required to exist | ||
| /// (for instance, if the path is outside the project's scope). | ||
| /// | ||
| /// Note that re-exports may introduce additional dependencies, because they | ||
| /// import another module and immediately re-export from that module. | ||
| /// Re-exports are tracked as part of [Self::exports] and | ||
| /// [Self::blanket_reexports]. | ||
| pub imports: CssImports, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Doc comments reference JS-specific concepts.
The documentation mentions JsImport, Self::exports, and Self::blanket_reexports which don't exist for CSS modules. These appear to be copy-pasted from the JS module info.
/// Map of all static imports found in the module.
///
- /// Maps from the local imported name to a [JsImport] with the absolute path
+ /// Maps from the import specifier to a [CssImport] with the absolute path
/// it resolves to. The resolved path may be looked up as key in the
/// [ModuleGraph::data] map, although it is not required to exist
/// (for instance, if the path is outside the project's scope).
- ///
- /// Note that re-exports may introduce additional dependencies, because they
- /// import another module and immediately re-export from that module.
- /// Re-exports are tracked as part of [Self::exports] and
- /// [Self::blanket_reexports].
pub imports: CssImports,📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| /// Map of all static imports found in the module. | |
| /// | |
| /// Maps from the local imported name to a [JsImport] with the absolute path | |
| /// it resolves to. The resolved path may be looked up as key in the | |
| /// [ModuleGraph::data] map, although it is not required to exist | |
| /// (for instance, if the path is outside the project's scope). | |
| /// | |
| /// Note that re-exports may introduce additional dependencies, because they | |
| /// import another module and immediately re-export from that module. | |
| /// Re-exports are tracked as part of [Self::exports] and | |
| /// [Self::blanket_reexports]. | |
| pub imports: CssImports, | |
| /// Map of all static imports found in the module. | |
| /// | |
| /// Maps from the import specifier to a [CssImport] with the absolute path | |
| /// it resolves to. The resolved path may be looked up as key in the | |
| /// [ModuleGraph::data] map, although it is not required to exist | |
| /// (for instance, if the path is outside the project's scope). | |
| pub imports: CssImports, |
| pub fn update_graph_for_removed_paths(&self, removed_paths: &[&BiomePath]) { | ||
| let modules = self.data.pin(); | ||
| // Make sure all directories are registered for the added/updated paths. | ||
| let path_info = self.path_info.pin(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Misleading comment.
The comment references "added/updated paths" but this function handles removed paths.
pub fn update_graph_for_removed_paths(&self, removed_paths: &[&BiomePath]) {
let modules = self.data.pin();
- // Make sure all directories are registered for the added/updated paths.
+ // Clean up removed paths from the module graph and path info cache.
let path_info = self.path_info.pin();📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| pub fn update_graph_for_removed_paths(&self, removed_paths: &[&BiomePath]) { | |
| let modules = self.data.pin(); | |
| // Make sure all directories are registered for the added/updated paths. | |
| let path_info = self.path_info.pin(); | |
| pub fn update_graph_for_removed_paths(&self, removed_paths: &[&BiomePath]) { | |
| let modules = self.data.pin(); | |
| // Clean up removed paths from the module graph and path info cache. | |
| let path_info = self.path_info.pin(); |
🤖 Prompt for AI Agents
In crates/biome_module_graph/src/module_graph.rs around lines 181 to 185, the
inline comment incorrectly mentions "added/updated paths" even though this
function deals with removed paths; update the comment to accurately describe
handling of removed paths (e.g., "Ensure directories are accounted for when
processing removed paths" or "Make sure all directories are handled/unregistered
for the removed paths") so it matches the function's purpose.
| // project_layout.insert_node_manifest(format!("{fixtures_path}/shared").into(), { | ||
| // let path = Utf8PathBuf::from(format!("{fixtures_path}/shared/package.json")); | ||
| // deserialize_from_json_str::<PackageJson>( | ||
| // &fs.read_file_from_path(&path) | ||
| // .expect("package.json must be readable"), | ||
| // JsonParserOptions::default(), | ||
| // "package.json", | ||
| // ) | ||
| // .into_deserialized() | ||
| // .expect("package.json must parse") | ||
| // }); | ||
|
|
||
| // project_layout.insert_node_manifest( | ||
| // format!("{fixtures_path}/frontend/node_modules/shared").into(), | ||
| // { | ||
| // let path = Utf8PathBuf::from(format!( | ||
| // "{fixtures_path}/frontend/node_modules/shared/package.json" | ||
| // )); | ||
| // deserialize_from_json_str::<PackageJson>( | ||
| // &fs.read_file_from_path(&path) | ||
| // .expect("package.json must be readable"), | ||
| // JsonParserOptions::default(), | ||
| // "package.json", | ||
| // ) | ||
| // .into_deserialized() | ||
| // .expect("package.json must parse") | ||
| // }, | ||
| // ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Remove commented-out code.
This appears to be leftover from copy-pasting the JS test setup. Either implement the shared package handling for CSS or remove this dead code to keep the test clean.
- // project_layout.insert_node_manifest(format!("{fixtures_path}/shared").into(), {
- // let path = Utf8PathBuf::from(format!("{fixtures_path}/shared/package.json"));
- // deserialize_from_json_str::<PackageJson>(
- // &fs.read_file_from_path(&path)
- // .expect("package.json must be readable"),
- // JsonParserOptions::default(),
- // "package.json",
- // )
- // .into_deserialized()
- // .expect("package.json must parse")
- // });
-
- // project_layout.insert_node_manifest(
- // format!("{fixtures_path}/frontend/node_modules/shared").into(),
- // {
- // let path = Utf8PathBuf::from(format!(
- // "{fixtures_path}/frontend/node_modules/shared/package.json"
- // ));
- // deserialize_from_json_str::<PackageJson>(
- // &fs.read_file_from_path(&path)
- // .expect("package.json must be readable"),
- // JsonParserOptions::default(),
- // "package.json",
- // )
- // .into_deserialized()
- // .expect("package.json must parse")
- // },
- // );📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // project_layout.insert_node_manifest(format!("{fixtures_path}/shared").into(), { | |
| // let path = Utf8PathBuf::from(format!("{fixtures_path}/shared/package.json")); | |
| // deserialize_from_json_str::<PackageJson>( | |
| // &fs.read_file_from_path(&path) | |
| // .expect("package.json must be readable"), | |
| // JsonParserOptions::default(), | |
| // "package.json", | |
| // ) | |
| // .into_deserialized() | |
| // .expect("package.json must parse") | |
| // }); | |
| // project_layout.insert_node_manifest( | |
| // format!("{fixtures_path}/frontend/node_modules/shared").into(), | |
| // { | |
| // let path = Utf8PathBuf::from(format!( | |
| // "{fixtures_path}/frontend/node_modules/shared/package.json" | |
| // )); | |
| // deserialize_from_json_str::<PackageJson>( | |
| // &fs.read_file_from_path(&path) | |
| // .expect("package.json must be readable"), | |
| // JsonParserOptions::default(), | |
| // "package.json", | |
| // ) | |
| // .into_deserialized() | |
| // .expect("package.json must parse") | |
| // }, | |
| // ); |
🤖 Prompt for AI Agents
crates/biome_module_graph/tests/spec_tests.rs around lines 2224 to 2251: the
block of commented-out code (the two insert_node_manifest sections copying JS
test setup for a shared package) is dead/commented code leftover; remove these
commented lines entirely from the test file to keep the test clean (or if
shared-package behavior is required, replace the comments by implementing the
proper shared package handling — otherwise just delete the commented block).
| N: AstNode, | ||
| N::Language: 'static, | ||
| { | ||
| self.clone().into_node().map(|node| N::unwrap_cast(node)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Remove the unnecessary clone.
Since self is already consumed by the method signature, there's no need to clone it before calling into_node().
Apply this diff:
- self.clone().into_node().map(|node| N::unwrap_cast(node))
+ self.into_node().map(|node| N::unwrap_cast(node))📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| self.clone().into_node().map(|node| N::unwrap_cast(node)) | |
| self.into_node().map(|node| N::unwrap_cast(node)) |
🤖 Prompt for AI Agents
In crates/biome_rowan/src/syntax/node.rs around line 868, remove the unnecessary
clone call on self (the method consumes self) so that you call into_node()
directly on self; optionally simplify the map closure to pass N::unwrap_cast as
the function argument.
Summary
Follow up of #8327
This PR piggy-backs the new document service refactor, and adds CSS to the module graph.
I refactored the module graph this way:
update_graph_for_css_pathshow accepts a service that is pulled from the document services (see related PR)Test Plan
Added a new test, updated the existing tests.
Docs
No changeset needed, the new functionality isn't exposed yet to the users.