Skip to content

fix(core): workspace formatting#8841

Closed
ematipico wants to merge 3 commits intomainfrom
fix/formatting-workspace
Closed

fix(core): workspace formatting#8841
ematipico wants to merge 3 commits intomainfrom
fix/formatting-workspace

Conversation

@ematipico
Copy link
Member

Summary

This PR fixes two bugs.

Fixes #7912, where embedded formatting was incorrectly applied. I left a comment explaining the change.

The second bug is the CLI, which didn't apply formatting to the code actions when using Workspace::fix_all. This works as expected in the LSP. As you can see, there are many changes because... well, we never caught it 😅

Test Plan

Added a new test for the first bug. Updated the snapshots and tests for the second bug.

Docs

N/A

@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

🦋 Changeset detected

Latest commit: 589736c

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

This PR includes changesets to release 14 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
@biomejs/prettier-compare 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

@github-actions github-actions bot added A-CLI Area: CLI A-Project Area: project labels Jan 23, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

Gates formatter invocation on feature support and stops reformatting embedded content at the root printing stage. Adjusts a formatter flag in lint-and-assist flow, changes root formatting for embedded nodes to print verbatim, and updates tests/expectations for several cases (including Astro frontmatter) to reflect added semicolons/newlines. Adds two changeset entries for patch releases. Fixes the non‑idempotent newline insertion in Astro frontmatter reported in issue 7912.

Possibly related PRs

Suggested labels

A-Core, A-Formatter, L-HTML

Suggested reviewers

  • siketyan
  • dyc3
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(core): workspace formatting' is concise and directly relates to the main changes—fixing workspace formatting bugs in the core CLI and service modules.
Description check ✅ Passed The description clearly explains two bugs being fixed: Astro frontmatter embedded formatting issue (#7912) and CLI code actions not applying formatting via Workspace::fix_all, with test updates documented.
Linked Issues check ✅ Passed The PR addresses issue #7912 by fixing embedded formatting in HTML (preventing spurious newlines in Astro frontmatter) and fixes the CLI bug where formatting wasn't applied during fix_all operations, making lint --write idempotent.
Out of Scope Changes check ✅ Passed All changes are tightly scoped to fixing the two identified bugs: HTML embedded formatting logic, CLI fix_all formatting application, and corresponding test snapshot updates. No unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

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

🤖 Fix all issues with AI agents
In @.changeset/petite-mice-say.md:
- Line 5: Replace the typo "unincorrectly" with "incorrectly" in the changeset
sentence starting with "Fixed [`#7912`]...", updating the line to read "...where
Biome incorrectly added a leading newline to the code contained inside the Astro
frontmatter." to correct the grammar while keeping the existing issue reference
and wording intact.

In `@crates/biome_service/src/file_handlers/html.rs`:
- Around line 693-696: Remove the leftover dbg!() call inside the iterator
closure that finds a node by range: locate the iter.find(|node| {
dbg!(node.range, range); node.range == range }) expression and delete the
dbg!(node.range, range) invocation so the closure simply compares node.range ==
range; ensure no other dbg!() calls remain in the surrounding function (the
closure used to assign let node = iter.find(...)?).

@ematipico ematipico force-pushed the fix/formatting-workspace branch from e593154 to 3f2de8f Compare January 23, 2026 10:19
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: 1

🤖 Fix all issues with AI agents
In @.changeset/tricky-masks-cry.md:
- Line 5: Update the release note sentence "Fixed a regression where formatting
wasn't correctly applied when apply safe/unsafe fixes via Biome linter." to
correct the grammar by changing "when apply" to "when applying" and clarify
phrasing to "when applying safe or unsafe fixes via the Biome linter" so the
final sentence reads: "Fixed a regression where formatting wasn't correctly
applied when applying safe or unsafe fixes via the Biome linter."
♻️ Duplicate comments (1)
.changeset/petite-mice-say.md (1)

5-5: Typo: “unincorrectly” → “incorrectly”.
Already flagged earlier; keeping it brief.

✏️ Proposed fix
-Fixed [`#7912`](https://github.com/biomejs/biome/issues/7912), where Biome unincorrectly added a leading newline to the code contained inside the Astro frontmatter.
+Fixed [`#7912`](https://github.com/biomejs/biome/issues/7912), where Biome incorrectly added a leading newline to the code contained inside the Astro frontmatter.
🧹 Nitpick comments (1)
crates/biome_cli/tests/cases/handle_astro_files.rs (1)

752-803: Consider an explicit idempotence check.
Given issue #7912 is about repeat runs, it would be sturdier to run lint --write twice and assert the file content is unchanged on the second pass (e.g., compare contents after run one vs run two).

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Just a couple of typos that the bot picked up

ematipico and others added 2 commits January 23, 2026 14:05
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@ematipico ematipico changed the base branch from main to next January 24, 2026 10:38
@ematipico ematipico changed the base branch from next to main January 24, 2026 10:43
@ematipico ematipico closed this Jan 24, 2026
@ematipico ematipico deleted the fix/formatting-workspace branch January 24, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 Linter: lint --write is not idempotent on Astro frontmatter, while lint reports no issues

2 participants