feat(core): improved bindings detection#8642
Conversation
f07b3e3 to
19ac66e
Compare
🦋 Changeset detectedLatest commit: a24e7a6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
🦋 Changeset detectedLatest commit: 19ac66e The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #8642 will not alter performanceComparing Summary
Footnotes
|
WalkthroughAdds Svelte destructured binding support and threads embedded-JS bindings through lexer, parser, formatter, service/workspace and analyzer layers. New tokens (DOT3, Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (2)**/*.rs📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
crates/biome_service/src/workspace/server.rs📄 CodeRabbit inference engine (crates/biome_service/CONTRIBUTING.md)
Files:
🧠 Learnings (22)📚 Learning: 2025-11-24T18:06:12.048ZApplied to files:
📚 Learning: 2025-11-24T18:06:12.048ZApplied to files:
📚 Learning: 2025-12-21T21:15:03.796ZApplied to files:
📚 Learning: 2025-11-24T18:05:42.356ZApplied to files:
📚 Learning: 2025-11-24T18:05:42.356ZApplied to files:
📚 Learning: 2025-11-24T18:05:42.356ZApplied to files:
📚 Learning: 2025-11-24T18:06:12.048ZApplied to files:
📚 Learning: 2025-11-24T18:05:20.371ZApplied to files:
📚 Learning: 2025-11-24T18:05:42.356ZApplied to files:
📚 Learning: 2026-01-02T14:58:16.536ZApplied to files:
📚 Learning: 2025-11-24T18:05:20.371ZApplied to files:
📚 Learning: 2025-11-24T18:05:20.371ZApplied to files:
📚 Learning: 2026-01-02T14:58:16.536ZApplied to files:
📚 Learning: 2025-11-24T18:05:20.371ZApplied to files:
📚 Learning: 2025-12-21T21:15:03.796ZApplied to files:
📚 Learning: 2025-11-24T18:06:03.545ZApplied to files:
📚 Learning: 2025-11-24T18:06:03.545ZApplied to files:
📚 Learning: 2025-11-24T18:06:12.048ZApplied to files:
📚 Learning: 2025-11-24T18:06:12.048ZApplied to files:
📚 Learning: 2025-11-24T18:06:12.048ZApplied to files:
📚 Learning: 2025-11-24T18:06:03.545ZApplied to files:
📚 Learning: 2026-01-02T14:58:16.536ZApplied to files:
🧬 Code graph analysis (1)crates/biome_service/src/workspace/server.rs (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
🔇 Additional comments (7)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (10)
crates/biome_html_parser/src/syntax/parse_error.rs (1)
108-115: Inconsistent argument pattern forexpected_node.Other diagnostic helpers in this file pass short noun phrases to
expected_node(e.g., "attribute", "expression", "element name"), whilst this uses a full sentence. Consider using a short phrase like "name or closing block" for consistency.🔎 Suggested refactor for consistency
pub(crate) fn expected_name(p: &HtmlParser, range: TextRange) -> ParseDiagnostic { expected_node( - "Expected a name or a closing block, instead found none.", + "name or closing block", range, p, ) .into_diagnostic(p) }crates/biome_js_syntax/src/file_source.rs (1)
130-136: Clarify the documentation foris_source.The comment "Where the bindings are defined" is ambiguous. Consider: "Whether this embedded code defines bindings (source) or only references them."
.changeset/wide-masks-mix.md (1)
1-5: LGTM!Clear description of the improvement to
noUnusedVariablesfor Svelte files. Optionally, consider "script blocks" instead of "JavaScript blocks" for Svelte-specific terminology, though the current wording is perfectly clear.crates/biome_html_formatter/src/svelte/auxiliary/curly_destructured_name.rs (1)
13-17: Consider reordering the field destructuring for readability.The write order uses
l_curly_token→names→r_curly_token, but the destructuring lists them differently. Matching the order would improve readability—compare withsquare_destructured_name.rswhich already follows this pattern.🔎 Suggested reorder
let SvelteCurlyDestructuredNameFields { - r_curly_token, - names, l_curly_token, + names, + r_curly_token, } = node.as_fields();crates/biome_js_analyze/src/services/embedded_bindings.rs (1)
8-17: Consider the duplication with workspace service.This implementation mirrors
EmbeddedExportedBindings::contains_bindingincrates/biome_service/src/workspace/document/services/embedded_bindings.rs:217-224. Whilst the layering may be intentional (JS analyzer service wrapping workspace service), verify whether both implementations are needed or if one could delegate to the other.crates/biome_service/src/workspace/server.rs (2)
1512-1544: Duplicate embedded‑bindings setup betweenopen_file_internalandchange_fileThe
change_filepath replicates the exported‑bindings builder pattern used inopen_file_internal, which is functionally fine but does introduce duplication and a mild risk of future drift if one path is updated without the other.Consider extracting a small helper (e.g.
compute_embedded_snippets_and_bindings(...)) returning(Vec<AnyEmbeddedSnippet>, EmbeddedExportedBindings, DocumentServices)so both code paths share the same logic.
1663-1698: Clarify embedded bindings passed to snippet lints and avoid repeated cloningTwo related points here:
For embedded snippets you pass
document_services: snippet_servicesbutembedded_exported_bindings: services.embedded_bindings(), i.e. the root document’s bindings. That’s likely what you want so each snippet’sEmbeddedBindingsservice can see the whole exported‑bindings map, but it’s worth double‑checking you don’t actually need snippet‑scoped bindings instead.
services.embedded_bindings()clones the entireEmbeddedExportedBindingson every call (root + each snippet). If bindings ever get large, this could be a mild hotspot. Passing a shared reference (or anArc) into the analyser would avoid repeated cloning.If you’re happy with the root‑level semantics, I’d at least consider exposing a
&EmbeddedExportedBindingsaccessor onDocumentServicesto cut down on allocations.crates/biome_service/src/workspace/document/mod.rs (1)
1-2: Document services refactor is fine; consider exposing embedded bindings by referenceThe move to a
DocumentServicesstruct with aLanguageServicesenum plus optionalEmbeddedExportedBindingsis a sensible way to grow per‑document/per‑snippet services, and the newEmbeddedSnippet::treehelper is a neat convenience for callers that just want the tree.One thing to watch:
DocumentServices::embedded_bindings()currently returns a clonedOption<EmbeddedExportedBindings>. Given this is called in the diagnostics path (and again for each embedded snippet), cloning a vector-of-maps every time could become a small but noticeable cost on large Svelte documents.If feasible, adding a
fn embedded_bindings_ref(&self) -> Option<&EmbeddedExportedBindings>(and threading a reference through the analyser) would avoid extra allocations while keeping the owned accessor for callers that truly need an owned copy.Also applies to: 7-7, 14-14, 140-165, 190-197, 263-317
crates/biome_service/src/workspace/document/services/embedded_bindings.rs (1)
20-23:builderdoesn't use&self; consider making it an associated function.The method ignores the receiver entirely. Converting it to
fn builder() -> EmbeddedBuilder(ornew_builder) makes the intent clearer and avoids the need for an existing instance.🔎 Proposed fix
impl EmbeddedExportedBindings { - pub(crate) fn builder(&self) -> EmbeddedBuilder { + pub(crate) fn builder() -> EmbeddedBuilder { EmbeddedBuilder::new() }crates/biome_html_parser/src/syntax/svelte.rs (1)
1054-1063: Recovery diagnostic may be misleading for binding lists.
expected_svelte_closing_blockseems intended for block-level recovery, but here we're recovering from malformed binding elements within a destructuring pattern. Usingexpected_name(asBindingListdoes on line 911) would produce a more accurate diagnostic for users.🔎 Proposed fix
fn recover( &mut self, p: &mut Self::Parser<'_>, parsed_element: ParsedSyntax, ) -> RecoveryResult { parsed_element.or_recover_with_token_set( p, &ParseRecoveryTokenSet::new(SVELTE_BOGUS_BLOCK, BLOCK_RECOVER), - expected_svelte_closing_block, + expected_name, ) }
eb50041 to
2119510
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (1)
289-291: Service retrieval needs graceful fallback.The
.expect()will panic ifEmbeddedBindingsisn't wired (e.g., in tests or future analyzer paths). Consider defaulting to an empty service when absent:let embedded_bindings = ctx .get_service::<EmbeddedBindings>() .unwrap_or(&EmbeddedBindings(vec![]));This keeps the rule robust across different wiring scenarios.
Based on past review comments.
🧹 Nitpick comments (4)
crates/biome_html_parser/src/token_source.rs (1)
138-138: Nice addition of documentation for the Svelte relex context.The doc comment is a good start, though it could be more specific about what "manages" entails and when to use this context versus
HtmlText. Consider clarifying the specific behaviour (e.g., how it handles commas in Svelte destructuring or expression contexts).crates/biome_js_analyze/src/services/embedded_bindings.rs (1)
9-9: Considerpubvisibility for consistency.Since
EmbeddedBindingsispub, makingcontains_bindingfully public would allow external consumers to use the service more flexibly. Currentlypub(crate)limits usage to within the crate.crates/biome_html_parser/src/syntax/svelte.rs (2)
199-200: Misleading comment: destructuring patterns are not expressions.The comment says "a name is actually an expression", but destructuring patterns like
{a, b}or[x, y]are binding patterns, not expressions. This terminology matters in language implementation.📝 Suggested rewording
- // This is the case where a name is actually an expression e.g. `[id, name]` - // We need to re-lex so we recognize it as expression instead of name + // This is the case where the binding uses a destructuring pattern e.g. `{a, b}` or `[id, name]` + // We need to re-lex to properly recognize the destructuring tokens instead of treating them as a plain name
924-933: Consider clarifying the documentation.The implementation correctly accepts both identifiers and Svelte keywords (line 926), but the doc comment only mentions "Svelte name". Mentioning that keywords are also accepted would improve clarity.
📝 Suggested doc comment
-/// Parses a Svelte name +/// Parses a Svelte name (identifier or keyword) fn parse_name(p: &mut HtmlParser) -> ParsedSyntax {
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (27)
crates/biome_cli/tests/snapshots/main_cases_handle_svelte_files/embedded_bindings_are_tracked_correctly.snapis excluded by!**/*.snapand included by**crates/biome_html_factory/src/generated/node_factory.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_html_factory/src/generated/syntax_factory.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_html_formatter/tests/specs/html/svelte/each_with_destructuring.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/error/svelte/debug-trailing-comma.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/error/svelte/debug.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/error/svelte/each_missing_binding.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/error/svelte/each_missing_closing_paren.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/error/svelte/each_missing_expression.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/error/svelte/each_unclosed.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/await_nested.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/complex_expressions.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/debug.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_as_in_identifier.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_basic.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_complex_combinations.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_complex_expression.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_index_only.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_with_destructuring.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_with_else.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_with_index.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_with_index_and_key.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_parser/tests/html_specs/ok/svelte/each_with_key.svelte.snapis excluded by!**/*.snapand included by**crates/biome_html_syntax/src/generated/kind.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_html_syntax/src/generated/macros.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_html_syntax/src/generated/nodes.rsis excluded by!**/generated/**,!**/generated/**and included by**crates/biome_html_syntax/src/generated/nodes_mut.rsis excluded by!**/generated/**,!**/generated/**and included by**
📒 Files selected for processing (24)
.changeset/wide-masks-mix.mdcrates/biome_cli/tests/cases/handle_svelte_files.rscrates/biome_html_formatter/src/generated.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/any/destructured_name.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/any/mod.rscrates/biome_html_formatter/src/svelte/auxiliary/curly_destructured_name.rscrates/biome_html_formatter/src/svelte/auxiliary/mod.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.rscrates/biome_html_formatter/src/svelte/lists/mod.rscrates/biome_html_parser/src/lexer/mod.rscrates/biome_html_parser/src/syntax/parse_error.rscrates/biome_html_parser/src/syntax/svelte.rscrates/biome_html_parser/src/token_source.rscrates/biome_html_parser/tests/html_specs/ok/svelte/debug.sveltecrates/biome_html_parser/tests/html_specs/ok/svelte/each_with_destructuring.sveltecrates/biome_html_parser/tests/quick_test.rscrates/biome_js_analyze/src/lib.rscrates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_js_analyze/src/services/embedded_bindings.rscrates/biome_js_analyze/src/services/mod.rs
✅ Files skipped from review due to trivial changes (1)
- crates/biome_html_parser/tests/html_specs/ok/svelte/debug.svelte
🚧 Files skipped from review as they are similar to previous changes (8)
- crates/biome_html_formatter/src/svelte/any/mod.rs
- crates/biome_html_formatter/src/svelte/any/destructured_name.rs
- crates/biome_html_formatter/src/svelte/auxiliary/curly_destructured_name.rs
- .changeset/wide-masks-mix.md
- crates/biome_html_parser/tests/html_specs/ok/svelte/each_with_destructuring.svelte
- crates/biome_html_formatter/src/generated.rs
- crates/biome_html_parser/src/syntax/parse_error.rs
- crates/biome_html_formatter/src/svelte/auxiliary/mod.rs
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Use inline rustdoc documentation for rules, assists, and their options
Use thedbg!()macro for debugging output in Rust tests and code
Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests
Files:
crates/biome_html_parser/tests/quick_test.rscrates/biome_html_parser/src/lexer/mod.rscrates/biome_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_js_analyze/src/services/mod.rscrates/biome_html_formatter/src/svelte/lists/mod.rscrates/biome_html_parser/src/token_source.rscrates/biome_cli/tests/cases/handle_svelte_files.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_parser/src/syntax/svelte.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.rscrates/biome_js_analyze/src/lib.rscrates/biome_js_analyze/src/services/embedded_bindings.rs
🧠 Learnings (73)
📚 Learning: 2025-12-04T13:29:49.287Z
Learnt from: dyc3
Repo: biomejs/biome PR: 8291
File: crates/biome_html_formatter/tests/specs/prettier/vue/html-vue/elastic-header.html:10-10
Timestamp: 2025-12-04T13:29:49.287Z
Learning: Files under `crates/biome_html_formatter/tests/specs/prettier` are test fixtures synced from Prettier and should not receive detailed code quality reviews (e.g., HTTP vs HTTPS, formatting suggestions, etc.). These files are test data meant to validate formatter behavior and should be preserved as-is.
Applied to files:
crates/biome_html_parser/tests/quick_test.rscrates/biome_cli/tests/cases/handle_svelte_files.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_html_parser/tests/quick_test.rscrates/biome_cli/tests/cases/handle_svelte_files.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_html_parser/tests/quick_test.rscrates/biome_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_cli/tests/cases/handle_svelte_files.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.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_html_parser/tests/quick_test.rscrates/biome_html_formatter/src/svelte/lists/mod.rscrates/biome_cli/tests/cases/handle_svelte_files.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Invalid code snippets in rule documentation must emit exactly one diagnostic
Applied to files:
crates/biome_html_parser/tests/quick_test.rscrates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2025-12-21T21:15:03.796Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.796Z
Learning: Applies to **/*.rs : Use doc tests (doctest) format with code blocks in rustdoc comments; ensure assertions pass in tests
Applied to files:
crates/biome_html_parser/tests/quick_test.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Code blocks in rule documentation must specify a language identifier and be tagged with `expect_diagnostic` for invalid examples or remain untagged for valid examples
Applied to files:
crates/biome_html_parser/tests/quick_test.rscrates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `Markup!` macro for diagnostic messages and code action descriptions to ensure proper formatting
Applied to files:
crates/biome_html_parser/tests/quick_test.rscrates/biome_js_analyze/src/lint/correctness/no_unused_variables.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_html_parser/tests/quick_test.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_html_parser/tests/quick_test.rs
📚 Learning: 2025-12-21T21:15:03.796Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: CONTRIBUTING.md:0-0
Timestamp: 2025-12-21T21:15:03.796Z
Learning: Applies to **/*.rs : Use the `dbg!()` macro for debugging output in Rust tests and code
Applied to files:
crates/biome_html_parser/tests/quick_test.rscrates/biome_cli/tests/cases/handle_svelte_files.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_html_parser/src/lexer/mod.rscrates/biome_html_parser/src/token_source.rscrates/biome_html_parser/src/syntax/svelte.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/**/lexer/mod.rs : Implement a `Lexer` trait from `biome_parser` crate for the lexer struct that consumes characters from source code and emits tokens
Applied to files:
crates/biome_html_parser/src/lexer/mod.rscrates/biome_html_parser/src/token_source.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_html_parser/src/lexer/mod.rscrates/biome_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_parser/src/token_source.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_parser/src/syntax/svelte.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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_html_parser/src/lexer/mod.rscrates/biome_html_parser/src/token_source.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 `p.eat(token)` for optional tokens, `p.expect(token)` for required tokens, `parse_rule(p).ok(p)` for optional nodes, and `parse_rule(p).or_add_diagnostic(p, error)` for required nodes
Applied to files:
crates/biome_html_parser/src/lexer/mod.rscrates/biome_html_parser/src/token_source.rscrates/biome_html_parser/src/syntax/svelte.rs
📚 Learning: 2025-11-09T12:47:46.298Z
Learnt from: ematipico
Repo: biomejs/biome PR: 8031
File: crates/biome_html_parser/src/syntax/svelte.rs:140-147
Timestamp: 2025-11-09T12:47:46.298Z
Learning: In the Biome HTML parser, `expect` and `expect_with_context` consume the current token and then lex the next token. The context parameter in `expect_with_context` controls how the next token (after the consumed one) is lexed, not the current token being consumed. For example, in Svelte parsing, after `bump_with_context(T!["{:"], HtmlLexContext::Svelte)`, the next token is already lexed in the Svelte context, so `expect(T![else])` is sufficient unless the token after `else` also needs to be lexed in a specific context.
Applied to files:
crates/biome_html_parser/src/lexer/mod.rscrates/biome_html_parser/src/token_source.rscrates/biome_html_parser/src/syntax/svelte.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_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.rscrates/biome_js_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: 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_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_parser/src/token_source.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_parser/src/syntax/svelte.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_formatter/src/svelte/lists/mod.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Apply `#[serde(rename_all = "camelCase")]` to rule option structs to match JSON configuration naming convention
Applied to files:
crates/biome_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Apply `#[serde(deny_unknown_fields)]` to rule option structs to enforce strict configuration validation
Applied to files:
crates/biome_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.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_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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_html_formatter/src/svelte/auxiliary/square_destructured_name.rscrates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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: 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_html_formatter/src/svelte/auxiliary/square_destructured_name.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_js_analyze/src/services/mod.rscrates/biome_html_formatter/src/svelte/lists/mod.rscrates/biome_js_analyze/src/lib.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_js_analyze/src/services/mod.rscrates/biome_html_formatter/src/svelte/lists/mod.rscrates/biome_js_analyze/src/lib.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_js_analyze/src/services/mod.rscrates/biome_js_analyze/src/lib.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_js_analyze/src/services/mod.rscrates/biome_html_formatter/src/svelte/lists/mod.rscrates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_js_analyze/src/lib.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/services/mod.rscrates/biome_html_formatter/src/svelte/lists/mod.rscrates/biome_js_analyze/src/lib.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use the `Semantic<T>` query type to access semantic information about bindings, references, and scope within a rule
Applied to files:
crates/biome_js_analyze/src/services/mod.rscrates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_html_parser/src/syntax/svelte.rscrates/biome_js_analyze/src/lib.rscrates/biome_js_analyze/src/services/embedded_bindings.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_html_formatter/src/svelte/lists/mod.rscrates/biome_html_parser/src/syntax/svelte.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_html_formatter/src/svelte/lists/mod.rscrates/biome_html_parser/src/syntax/svelte.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_html_formatter/src/svelte/lists/mod.rscrates/biome_js_analyze/src/lib.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_html_formatter/src/svelte/lists/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 `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_html_parser/src/token_source.rscrates/biome_html_parser/src/syntax/svelte.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_html_parser/src/token_source.rscrates/biome_html_parser/src/syntax/svelte.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/**/*.ungram : Add a legend comment to `.ungram` files explaining the grammar syntax including comments, non-terminals, tokens, sequences, alternations, repetitions, and optional elements
Applied to files:
crates/biome_html_parser/src/token_source.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_cli/tests/cases/handle_svelte_files.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Rule options must be defined in the `biome_rule_options` crate with a file named after the rule
Applied to files:
crates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Implement the `action` function and add `fix_kind` metadata to the rule macro if the rule provides code actions
Applied to files:
crates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_js_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: Implement the `AsFormat<Context>` trait in `lib.rs` with generic implementations for references, `SyntaxResult`, and `Option` types as provided in the formatter boilerplate code
Applied to files:
crates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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 `IntoFormat<Context>` trait in `lib.rs` with implementations for `SyntaxResult` and `Option` types as part of the formatter infrastructure
Applied to files:
crates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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 `FormatLanguage` trait with `SyntaxLanguage`, `Context`, and `FormatRule` associated types for the language's formatter
Applied to files:
crates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rscrates/biome_html_formatter/src/svelte/any/each_name.rscrates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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 a new formatter crate using the command `just new-crate biome_<language>_formatter` where `<language>` is the target language (e.g., `biome_html_formatter` for HTML)
Applied to files:
crates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Check if a variable is global using the semantic model before reporting diagnostics for rules that ban global functions or variables
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `declare_node_union!` macro to query multiple node types together to avoid redundant traversal passes
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_js_analyze/src/lib.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Rule names should use the `use` prefix when the rule's sole intention is to mandate a single concept
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_js_analyze/src/lib.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Deprecated rules must include a `deprecated` field in the `declare_lint_rule!` macro with an explanation of what rule to use instead
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `ctx.get_service()` to retrieve services by type when a rule requires multiple services beyond those pulled in the Query
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_js_analyze/src/lib.rscrates/biome_js_analyze/src/services/embedded_bindings.rs
📚 Learning: 2025-12-22T09:26:56.943Z
Learnt from: ematipico
Repo: biomejs/biome PR: 8537
File: crates/biome_js_analyze/src/lint/nursery/no_leaked_render.rs:167-210
Timestamp: 2025-12-22T09:26:56.943Z
Learning: When defining lint rules (declare_lint_rule!), only specify fix_kind if the rule implements an action(...) function. Rules that only emit diagnostics without a code fix should omit fix_kind. This applies to all Rust lint rule definitions under crates/.../src/lint (e.g., crates/biome_js_analyze/src/lint/...).
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Implement the `diagnostic` function to provide error messages explaining what the error is, why it is triggered, and what the user should do
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use helper functions like `map`, `filter`, and `and_then` to avoid excessive nested `if let` statements
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_js_analyze/src/lib.rs
📚 Learning: 2025-12-31T15:35:41.261Z
Learnt from: dyc3
Repo: biomejs/biome PR: 8639
File: crates/biome_js_analyze/src/lint/nursery/no_excessive_lines_per_file.rs:101-108
Timestamp: 2025-12-31T15:35:41.261Z
Learning: In crates/biome_analyze/**/*analyze/src/lint/nursery/**/*.rs, the `issue_number` field in `declare_lint_rule!` macro is optional and the vast majority of nursery rules do not need it. Do not recommend adding `issue_number` unless there's a specific reason.
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Mark rules with `issue_number` in the `declare_lint_rule!` macro if they are work-in-progress to indicate missing features
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Rule names should use the `no` prefix when the rule's sole intention is to forbid a single concept
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : When porting rules from other linters, use `sources` metadata with `RuleSource::Eslint().same()` for identical behavior or `.inspired()` for different behavior
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Implement custom `Queryable` and `Visitor` types for rules that require deep inspection of child nodes to avoid inefficient traversals
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_js_analyze/src/lib.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Implement the `run` function to return `Option<Self::State>` or `Vec<Self::State>` (as `Box<[Self::State]>`) depending on whether the rule reports one or multiple signals
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rscrates/biome_js_analyze/src/lib.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : Use `rule_category!()` macro to refer to the diagnostic category instead of dynamically parsing its string name
Applied to files:
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.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_html_parser/src/syntax/svelte.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_html_parser/src/syntax/svelte.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/**/*.ungram : Nodes for enclosing syntax errors must have the `Bogus` word, e.g., `HtmlBogusAttribute`, and must be part of a variant
Applied to files:
crates/biome_html_parser/src/syntax/svelte.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 return `ParsedSyntax::Absent` if the rule can't predict by the next token(s) if they form the expected node, and must not progress the parser in this case
Applied to files:
crates/biome_html_parser/src/syntax/svelte.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/**/*.ungram : All grammar nodes must start with the prefix of the language, e.g., `HtmlSimpleAttribute`
Applied to files:
crates/biome_html_parser/src/syntax/svelte.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 error recovery in list parsing using `or_recover()` to wrap unparseable tokens in a `BOGUS_*` node and consume tokens until a recovery token is found
Applied to files:
crates/biome_html_parser/src/syntax/svelte.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/**/*_analyze/**/src/lint/**/*.rs : The first paragraph of rule documentation must be written in a single line to ensure proper rendering in the rules overview table
Applied to files:
crates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.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/**/scoped_resolver.rs : Implement full inference to resolve `TypeReference::Import` variants across the entire module graph
Applied to files:
crates/biome_js_analyze/src/lib.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_js_analyze/src/lib.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_js_analyze/src/lib.rs
📚 Learning: 2026-01-02T14:58:16.536Z
Learnt from: CR
Repo: biomejs/biome PR: 0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2026-01-02T14:58:16.536Z
Learning: Applies to crates/biome_analyze/biome_rule_options/lib/**/*.rs : Use `Option<_>` wrapper for rule option fields to enable proper merging of configurations
Applied to files:
crates/biome_js_analyze/src/lib.rs
🧬 Code graph analysis (9)
crates/biome_html_formatter/src/svelte/auxiliary/square_destructured_name.rs (5)
crates/biome_html_formatter/src/svelte/auxiliary/curly_destructured_name.rs (1)
fmt_fields(8-29)crates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rs (1)
fmt_fields(7-14)crates/biome_js_syntax/src/expr_ext.rs (2)
l_brack_token(1494-1499)r_brack_token(1515-1520)crates/biome_html_formatter/src/generated.rs (16)
format(28-33)format(66-71)format(104-109)format(142-144)format(174-179)format(212-217)format(250-255)format(288-293)format(326-331)format(364-370)format(404-409)format(442-447)format(480-485)format(512-517)format(550-555)format(588-594)crates/biome_formatter/src/builders.rs (1)
space(606-608)
crates/biome_js_analyze/src/services/mod.rs (1)
crates/biome_service/src/workspace/document/mod.rs (1)
embedded_bindings(298-300)
crates/biome_cli/tests/cases/handle_svelte_files.rs (2)
crates/biome_service/src/workspace/document/services/embedded_bindings.rs (1)
new(30-34)crates/biome_cli/tests/snap_test.rs (1)
assert_cli_snapshot(408-410)
crates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rs (2)
crates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.rs (1)
fmt(10-36)crates/biome_html_formatter/src/generated.rs (15)
fmt(14-20)fmt(52-58)fmt(90-96)fmt(128-134)fmt(160-166)fmt(198-204)fmt(236-242)fmt(274-280)fmt(312-318)fmt(350-356)fmt(390-396)fmt(428-434)fmt(466-472)fmt(502-504)fmt(536-542)
crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (1)
crates/biome_service/src/workspace/document/services/embedded_bindings.rs (1)
new(30-34)
crates/biome_html_parser/src/syntax/svelte.rs (1)
crates/biome_html_parser/src/syntax/parse_error.rs (4)
expected_child_or_block(43-45)expected_expression(125-128)expected_name(108-115)expected_svelte_closing_block(104-106)
crates/biome_html_formatter/src/svelte/lists/binding_assignment_binding_list.rs (2)
crates/biome_formatter/src/formatter.rs (1)
join(73-75)crates/biome_formatter/src/builders.rs (1)
format_with(2304-2312)
crates/biome_js_analyze/src/lib.rs (2)
crates/biome_html_analyze/src/registry.rs (1)
visit_registry(5-7)crates/biome_service/src/workspace/document/mod.rs (2)
embedded_bindings(298-300)set_embedded_bindings(286-288)
crates/biome_js_analyze/src/services/embedded_bindings.rs (1)
crates/biome_service/src/workspace/document/services/embedded_bindings.rs (1)
contains_binding(233-240)
⏰ 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). (5)
- GitHub Check: Documentation
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Bench (biome_js_parser)
- GitHub Check: Bench (biome_js_analyze)
- GitHub Check: Bench (biome_js_formatter)
🔇 Additional comments (18)
crates/biome_html_parser/tests/quick_test.rs (1)
7-7: LGTM!The updated test input exercises Svelte destructuring with rest patterns, which aligns nicely with the PR's binding detection improvements. As an ignored quick test, this is perfectly fine for development.
crates/biome_cli/tests/cases/handle_svelte_files.rs (1)
546-592: LGTM! Test logic is sound.The test correctly verifies that bindings defined in
<script>blocks and used in HTML templates are tracked as "used", preventing false positives fromnoUnusedVariables. All defined variables (hello,array,Component) are referenced in the template, sois_ok()is the expected result.crates/biome_html_parser/src/lexer/mod.rs (2)
807-812: LGTM! Clean helper functions.The
consume_dot3()andis_at_three_dots()helpers correctly implement three-dot token detection and consumption. Theinline(always)attributes are appropriate for these small, frequently-called functions.Also applies to: 882-887
167-168: LGTM! Bracket tokens added to appropriate contexts.Square bracket tokens are now correctly recognised in both Regular and Svelte contexts, enabling destructuring syntax support.
Also applies to: 481-482
crates/biome_js_analyze/src/services/mod.rs (1)
3-3: LGTM!Simple module addition to expose embedded bindings functionality.
crates/biome_html_formatter/src/svelte/lists/mod.rs (1)
4-4: LGTM!Generated module declaration follows the existing pattern.
crates/biome_html_formatter/src/svelte/any/binding_assignment_binding.rs (1)
1-19: LGTM!Generated formatter correctly delegates to
SvelteNameandSvelteRestBindingvariants following the standard pattern.crates/biome_html_formatter/src/svelte/auxiliary/square_destructured_name.rs (1)
1-29: LGTM!The formatter implementation correctly follows the established pattern from
curly_destructured_name.rs, uses AST tokens appropriately, and maintains consistent spacing. Well done.crates/biome_js_analyze/src/lint/correctness/no_unused_variables.rs (1)
313-315: Embedded bindings check correctly integrated.The logic properly suppresses diagnostics for bindings defined in embedded sources. The three-way check (underscore prefix, unused, embedded) makes sense for Svelte prop handling.
crates/biome_js_analyze/src/services/embedded_bindings.rs (1)
19-31: FromServices implementation is sound.Proper error handling with
.ok_or_else()avoids panics, and cloning is appropriate for the trait contract. Good work.crates/biome_html_formatter/src/svelte/auxiliary/rest_binding.rs (1)
1-15: LGTM!Correctly formats rest bindings without spacing (as
...name), matching JavaScript rest syntax conventions. Implementation is clean and consistent.crates/biome_js_analyze/src/lib.rs (2)
53-53: Embedded bindings integration is well-structured.The field addition, default initialization, and setter method provide a clean API for provisioning bindings before analysis. Nice work threading this through the service layer.
Also applies to: 68-68, 73-77
188-188: Service registration completes the wiring.Inserting
EmbeddedBindingsinto the service bag makes it available to lint rules viaFromServices. The integration is complete and follows the established pattern.crates/biome_html_formatter/src/svelte/any/each_name.rs (1)
1-16: LGTM!The generated formatter correctly delegates to the appropriate formatters for each variant. Standard pattern, well-structured.
crates/biome_html_parser/src/syntax/svelte.rs (4)
3-3: LGTM!Import additions correctly support the new destructuring and binding syntax kinds.
Also applies to: 12-20
279-283: LGTM!The updated index parsing and new destructuring parsers follow the correct patterns. The symmetric structure between curly and square destructuring makes the code easy to understand.
Also applies to: 716-743
900-901: LGTM!The rest binding parser and BindingList updates correctly handle the extended syntax. The addition of
]to the end condition properly supports array destructuring contexts.Also applies to: 911-911, 936-947
1034-1104: LGTM!The new list parser is well-structured and follows the established patterns for
ParseSeparatedList. The handling of both rest bindings and regular names inparse_elementis clean, and the recovery logic is appropriate. The region markers improve code navigation.
|
Going to merge this |
Summary
Part of #8590
This PR adds logic to track expoted bindings defined within embedded snippets. The logic has been added to the
biome_servicecrate, as a document service. TheDocumentServicetype has been updated to accommodate the new infra.The visitor inside the new service has been specifically tailored over how bindings are expected to be "exported" when they are defined inside a snippet. There are few tests that shows the logic.
A new concept of
is_sourcehas been added to the file source of those snippets. The reason why we have this now is because inside a document we might have various snippets, but only a few define the bindings, like in the following example:Bindings are a vector of maps because in a document, we can define multiple sources, so these sources might bindings that have the different text range (relative to the root of the snippet).
As a reflection of this update, I added also a new service in the JavaScript analyzer, and updated the
noUnusedVariablerule to use this new service.Svelte update
In this PR, now we parse all the snippets inside a
.sveltefile. With all snippets, I mean allHtmlTextExpressione.g.{hello}As a consequence, I had to update the parsing of the svelte language in some parts, because we incorrectly parsed them as expressions, while they are identifiers instead.
Test Plan
Added various tests
Docs