Conversation
🦋 Changeset detectedLatest commit: c43e45d 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 pull request addresses an idempotence issue in the JavaScript formatter where trailing line comments after case clauses were causing unstable output across multiple formatting passes. The fix introduces a conditional guard in the case clause formatter to prevent block statement hugging when a trailing comment follows the case colon. Changes include updates to the case clause formatter logic, new test coverage for switch statements with inline trailing comments, and documentation via a changeset file. Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.changeset/fix-switch-case-comment-idempotence.md:
- Line 5: Update the changeset body in
.changeset/fix-switch-case-comment-idempotence.md to include a before/after
formatter diff code block showing the concrete visible change (use a unified
diff-style snippet); insert a fenced code block (```diff) containing the
original lines (prefixed with -) and the formatted lines (prefixed with +) —
e.g., show the "-case 1337: {", "- // ELITE", "- console.log(\"x is cool\");",
"-}" and the corresponding "+case 1337: // ELITE", "+{", "+ console.log(\"x is
cool\");", "+}" lines — so users can see the exact formatting change.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
crates/biome_js_formatter/tests/specs/js/module/statement/switch_comment.js.snapis excluded by!**/*.snapand included by**
📒 Files selected for processing (4)
.changeset/fix-switch-case-comment-idempotence.mdcrates/biome_js_formatter/src/js/auxiliary/case_clause.rscrates/biome_js_formatter/tests/quick_test.rscrates/biome_js_formatter/tests/specs/js/module/statement/switch_comment.js
| "@biomejs/biome": patch | ||
| --- | ||
|
|
||
| Fixed [#2786](https://github.com/biomejs/biome/issues/2786): The formatter no longer produces different output on subsequent runs when a `case` clause has a trailing line comment followed by a single block statement. |
There was a problem hiding this comment.
Add a tiny before/after formatter diff in the changeset body.
Nice summary, but this formatter fix should include a concrete formatting diff so users can see the visible behaviour change at a glance.
Suggested changeset snippet
Fixed [`#2786`](https://github.com/biomejs/biome/issues/2786): The formatter no longer produces different output on subsequent runs when a `case` clause has a trailing line comment followed by a single block statement.
+```diff
+-case 1337: {
+- // ELITE
++case 1337: // ELITE
++{
+ console.log("x is cool");
+ }
+```As per coding guidelines: for formatter changes in changesets, show formatting changes using diff code blocks.
📝 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.
| Fixed [#2786](https://github.com/biomejs/biome/issues/2786): The formatter no longer produces different output on subsequent runs when a `case` clause has a trailing line comment followed by a single block statement. | |
| --- | |
| package: `@biomejs/biome` | |
| type: patch | |
| --- | |
| Fixed [`#2786`](https://github.com/biomejs/biome/issues/2786): The formatter no longer produces different output on subsequent runs when a `case` clause has a trailing line comment followed by a single block statement. | |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In @.changeset/fix-switch-case-comment-idempotence.md at line 5, Update the
changeset body in .changeset/fix-switch-case-comment-idempotence.md to include a
before/after formatter diff code block showing the concrete visible change (use
a unified diff-style snippet); insert a fenced code block (```diff) containing
the original lines (prefixed with -) and the formatted lines (prefixed with +) —
e.g., show the "-case 1337: {", "- // ELITE", "- console.log(\"x is cool\");",
"-}" and the corresponding "+case 1337: // ELITE", "+{", "+ console.log(\"x is
cool\");", "+}" lines — so users can see the exact formatting change.
Merging this PR will not alter performance
Comparing Footnotes
|
f583ef5 to
c43e45d
Compare
Summary
Closes #2786
Found the fix with AI
Test Plan
Added a test
Docs