Skip to content

fix(core): idempotent lint write#9902

Merged
ematipico merged 2 commits intomainfrom
fix/lint-write-html
Apr 10, 2026
Merged

fix(core): idempotent lint write#9902
ematipico merged 2 commits intomainfrom
fix/lint-write-html

Conversation

@ematipico
Copy link
Copy Markdown
Member

Summary

Closes #9901

I used the last agent session to piggyback on the first for it. When lint --write happens, we need to return the snippet as is.

Test Plan

Added a new test

Docs

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 10, 2026

🦋 Changeset detected

Latest commit: 541c64f

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

@ematipico ematipico requested review from a team April 10, 2026 08:41
@github-actions github-actions Bot added A-CLI Area: CLI A-Project Area: project labels Apr 10, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2026

Walkthrough

This PR fixes non-idempotent behaviour in lint --write for HTML files containing embedded scripts and styles. It introduces a needs_reindent boolean field to UpdateSnippetsNodes struct, allowing the update_snippets function to conditionally reindent embedded content. When needs_reindent is false, the code is spliced as-is without modification, preventing cascading indentation changes on repeated executions. The fix is validated with a new CLI integration test confirming idempotency.

Possibly related PRs

Suggested labels

A-CLI, A-Project, A-Formatter

Suggested reviewers

  • dyc3
  • siketyan
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(core): idempotent lint write' clearly identifies the main fix addressing the idempotency issue with lint --write on HTML files.
Description check ✅ Passed The description references issue #9901, explains the root cause (snippets need to be returned as-is during lint --write), and notes a test was added.
Linked Issues check ✅ Passed The PR successfully addresses issue #9901 by conditionally skipping reindentation when needs_reindent is false, making lint --write idempotent for HTML scripts.
Out of Scope Changes check ✅ Passed All changes directly support the idempotency fix: new field for control, conditional logic in html.rs, test coverage, and changeset documentation.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/lint-write-html

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

Copy link
Copy Markdown
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

🤖 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/fair-snails-peel.md:
- Line 5: Update the sentence in the changeset line that reads "the command
`lint --write` is now idempotent when it's run against HTML-ish files that
contains scripts and styles" by replacing the incorrect verb "contains" with the
correct plural verb "contain" so it reads "...files that contain scripts and
styles" (look for the exact phrase containing "contains scripts and styles" in
the changeset text).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 048d8623-efe7-4f69-91f7-702a1df17713

📥 Commits

Reviewing files that changed from the base of the PR and between 362b638 and bab62e2.

⛔ Files ignored due to path filters (1)
  • crates/biome_cli/tests/snapshots/main_cases_html/lint_write_html_with_embedded_script_is_idempotent.snap is excluded by !**/*.snap and included by **
📒 Files selected for processing (5)
  • .changeset/fair-snails-peel.md
  • crates/biome_cli/tests/cases/html.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_service/src/workspace/server.rs

"@biomejs/biome": patch
---

Fixed [#9901](https://github.com/biomejs/biome/issues/9901): the command `lint --write` is now idempotent when it's run against HTML-ish files that contains scripts and styles.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix the subject–verb agreement in the changeset sentence.

Line 5 should read “files that contain scripts and styles” (not “contains”).

Suggested patch
-Fixed [`#9901`](https://github.com/biomejs/biome/issues/9901): the command `lint --write` is now idempotent when it's run against HTML-ish files that contains scripts and styles.
+Fixed [`#9901`](https://github.com/biomejs/biome/issues/9901): the command `lint --write` is now idempotent when it's run against HTML-ish files that contain scripts and styles.
📝 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.

Suggested change
Fixed [#9901](https://github.com/biomejs/biome/issues/9901): the command `lint --write` is now idempotent when it's run against HTML-ish files that contains scripts and styles.
Fixed [`#9901`](https://github.com/biomejs/biome/issues/9901): the command `lint --write` is now idempotent when it's run against HTML-ish files that contain scripts and styles.
🧰 Tools
🪛 LanguageTool

[grammar] ~5-~5: Possible subject-verb agreement error detected.
Context: ...en it's run against HTML-ish files that contains scripts and styles.

(PLURAL_THAT_AGREEMENT)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/fair-snails-peel.md at line 5, Update the sentence in the
changeset line that reads "the command `lint --write` is now idempotent when
it's run against HTML-ish files that contains scripts and styles" by replacing
the incorrect verb "contains" with the correct plural verb "contain" so it reads
"...files that contain scripts and styles" (look for the exact phrase containing
"contains scripts and styles" in the changeset text).

@ematipico ematipico merged commit 3f4d103 into main Apr 10, 2026
14 checks passed
@ematipico ematipico deleted the fix/lint-write-html branch April 10, 2026 16:02
@github-actions github-actions Bot mentioned this pull request Apr 10, 2026
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.

lint --write is not idempotent for HTML inline <script type="module"> content

2 participants