Skip to content

Conversation

minht11
Copy link
Contributor

@minht11 minht11 commented Aug 16, 2025

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.

@minht11 minht11 requested review from a team August 16, 2025 17:40
@minht11 minht11 self-assigned this Aug 16, 2025
@changeset-bot
Copy link

changeset-bot bot commented Aug 16, 2025

🦋 Changeset detected

Latest commit: fd6608a

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

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

Not sure what this means? Click here to learn what changesets are.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 16, 2025

Walkthrough

This 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: .svelte.test.ts, .svelte.test.js, .svelte.spec.ts, and .svelte.spec.js. When these patterns are detected, the analyser treats them like other Svelte inputs and injects Svelte 5 globals ($bindable, $derived, $effect, $host, $inspect, $props, $state). No exported/public API signatures are modified.

Suggested labels

A-Linter, L-JavaScript, A-Tooling

Suggested reviewers

  • siketyan

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
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/svelte-globals-inside-spec-test-files

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the A-Project Area: project label Aug 16, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (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.rs that AnalyzerOptions.globals includes the Svelte runes for .svelte.test.ts/.js and .svelte.spec.ts/.js would 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.

📥 Commits

Reviewing files that changed from the base of the PR and between b7aa111 and 53733ae.

📒 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 with just 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 format

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

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.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.

📥 Commits

Reviewing files that changed from the base of the PR and between 53733ae and fd6608a.

📒 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 with just 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.

@minht11 minht11 merged commit 1d643d8 into main Aug 18, 2025
13 checks passed
@minht11 minht11 deleted the feat/svelte-globals-inside-spec-test-files branch August 18, 2025 15:13
@github-actions github-actions bot mentioned this pull request Aug 18, 2025
SkyBird233 pushed a commit to SkyBird233/biomejs that referenced this pull request Aug 28, 2025
SkyBird233 pushed a commit to SkyBird233/biomejs that referenced this pull request Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants