-
-
Notifications
You must be signed in to change notification settings - Fork 728
feat(linter): auto add Svelte globals for .svelte.test/spec files #7239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: fd6608a The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis change adds a changeset for a patch release of @biomejs/biome and updates the JavaScript/Svelte file handler to recognise additional Svelte test/spec file patterns: Suggested labels
Suggested reviewers
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
.changeset/tame-dolls-serve.md (1)
5-5: Spell out patterns and runes for clarity (tiny polish).Listing the exact patterns and Svelte 5 runes makes the note clearer and more searchable. Also adds a present‑tense sentence to describe current behaviour.
Apply this diff:
-Added support for automatically recognizing Svelte globals ($state and so on) inside `.svelte.test.ts/js` `.svelte.spec.ts/js` files. +Added support for automatically recognizing Svelte 5 globals ($bindable, $derived, $effect, $host, $inspect, $props, $state) in files with the following patterns: `.svelte.test.ts`, `.svelte.test.js`, `.svelte.spec.ts`, `.svelte.spec.js`. +These globals are now available in those test files as well.(Optional) You could add a tiny example after the sentence:
```svelte <!-- Button.svelte.test.ts --> <script lang="ts"> let count = $state(0); $effect(() => console.log(count)); </script></blockquote></details> <details> <summary>crates/biome_service/src/file_handlers/javascript.rs (2)</summary><blockquote> `325-333`: **Consolidate suffix checks to reduce repetition.** A single any() over a small slice improves readability and makes future additions simpler. Apply this diff: ```diff - } else if filename.ends_with(".svelte") - || filename.ends_with(".svelte.js") - || filename.ends_with(".svelte.ts") - || filename.ends_with(".svelte.test.ts") - || filename.ends_with(".svelte.test.js") - || filename.ends_with(".svelte.spec.ts") - || filename.ends_with(".svelte.spec.js") - { + } else if [ + ".svelte", + ".svelte.js", + ".svelte.ts", + ".svelte.test.ts", + ".svelte.test.js", + ".svelte.spec.ts", + ".svelte.spec.js", + ] + .iter() + .any(|s| filename.ends_with(s)) + {
325-346: Consider adding tests for these new patterns.A couple of assertions in
javascript.tests.rsthatAnalyzerOptions.globalsincludes the Svelte runes for.svelte.test.ts/.jsand.svelte.spec.ts/.jswould lock this in and prevent regressions.If you’d like, I can sketch the test cases asserting the presence of
$state(and friends) for those filenames.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (2)
.changeset/tame-dolls-serve.md(1 hunks)crates/biome_service/src/file_handlers/javascript.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
.changeset/*.md
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
.changeset/*.md: Create changesets withjust new-changeset; store them in.changeset/with correct frontmatter (package keys and change type).
In changeset descriptions, follow content conventions: user-facing changes only; past tense for what you did; present tense for current behavior; link issues for fixes; link rules/assists; include representative code blocks; end every sentence with a period.
When adding headers in a changeset, only use #### or ##### levels.
Files:
.changeset/tame-dolls-serve.md
**/*.{rs,toml}
📄 CodeRabbit Inference Engine (CLAUDE.md)
Format code (Rust + TOML) using
just formatFormat Rust and TOML files before committing (use
just f/just format).
Files:
crates/biome_service/src/file_handlers/javascript.rs
crates/biome_*/**/*
📄 CodeRabbit Inference Engine (CLAUDE.md)
Core crates must be located in
/crates/biome_*/
Files:
crates/biome_service/src/file_handlers/javascript.rs
🧠 Learnings (1)
📚 Learning: 2025-08-11T11:43:46.619Z
Learnt from: CR
PR: biomejs/biome#0
File: crates/biome_analyze/CONTRIBUTING.md:0-0
Timestamp: 2025-08-11T11:43:46.619Z
Learning: Applies to crates/biome_analyze/**/src/lint/nursery/**/*.rs : Set the language field in declare_lint_rule! to the primary language/dialect (js, jsx, ts, tsx)
Applied to files:
crates/biome_service/src/file_handlers/javascript.rs
⏰ 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). (9)
- GitHub Check: Test Node.js API
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: autofix
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Documentation
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: End-to-end tests
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-windows-2022)
🔇 Additional comments (1)
crates/biome_service/src/file_handlers/javascript.rs (1)
328-332: LGTM: test/spec Svelte variants now get Svelte globals.This matches the PR goal and aligns with the existing suffix checks for
.svelte,.svelte.js,.svelte.ts. The injection set (Svelte 5 runes) is consistent too. Nice and tidy.
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.
The way the changeset was written is more like a feature than a fix. Which means it should be a minor. Instead of you intending to ship it as a patch, you should rewrite the changeset and make it so it looks like we're fixing a bug :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
.changeset/tame-dolls-serve.md (1)
5-6: Tighten wording, expand patterns explicitly, and list the globals.Avoid “and so on”, state the current behaviour in present tense, and spell out the four patterns to remove ambiguity. Adding a tiny representative example also aligns with the changeset guidelines.
Apply this diff:
-Fixed an issue where Svelte globals ($state and so on) were not properly recognized inside `.svelte.test.ts/js` and `.svelte.spec.ts/js` files. +Fixed Svelte globals detection in test and spec files. + +Svelte globals ($bindable, $derived, $effect, $host, $inspect, $props, $state) are now recognised in `.svelte.test.ts`, `.svelte.test.js`, `.svelte.spec.ts`, and `.svelte.spec.js` files. This matches the behaviour for regular `.svelte`, `.svelte.ts`, and `.svelte.js` files. + +Example. + +```svelte +<!-- Example: Counter.svelte.test.ts --> +<script lang="ts"> + const count = $state(0); + $effect(() => console.log(count)); +</script> +```Optional: consider linking to the official Svelte runes documentation and/or the tracking issue for this fix.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.changeset/tame-dolls-serve.md(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
.changeset/*.md
📄 CodeRabbit Inference Engine (CONTRIBUTING.md)
.changeset/*.md: Create changesets withjust new-changeset; store them in.changeset/with correct frontmatter (package keys and change type).
In changeset descriptions, follow content conventions: user-facing changes only; past tense for what you did; present tense for current behavior; link issues for fixes; link rules/assists; include representative code blocks; end every sentence with a period.
When adding headers in a changeset, only use #### or ##### levels.
Files:
.changeset/tame-dolls-serve.md
🪛 LanguageTool
.changeset/tame-dolls-serve.md
[style] ~4-~4: Consider using a different verb for a more formal wording.
Context: --- "@biomejs/biome": patch --- Fixed an issue where Svelte globals ($state a...
(FIX_RESOLVE)
⏰ 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). (9)
- GitHub Check: Test (depot-windows-2022-16)
- GitHub Check: Test Node.js API
- GitHub Check: Test (depot-ubuntu-24.04-arm-16)
- GitHub Check: Documentation
- GitHub Check: End-to-end tests
- GitHub Check: Check Dependencies
- GitHub Check: Lint project (depot-ubuntu-24.04-arm-16)
- GitHub Check: Lint project (depot-windows-2022)
- GitHub Check: autofix
🔇 Additional comments (1)
.changeset/tame-dolls-serve.md (1)
1-3: Frontmatter looks good.Valid package key and patch bump. No headers used, so the header-level constraint is satisfied.
Summary
Svelte allows using runes in test/spec files. Automatically add Svelte globals for those files, like we do for regular files.
Test Plan
n/a
Docs
No doc changes needed.