Skip to content

fix: organizeImports adding newlines in HTML-ish templating languages when :BLANK_LINE: was involved#9592

Draft
dyc3 wants to merge 3 commits intomainfrom
dyc3/fix-9097
Draft

fix: organizeImports adding newlines in HTML-ish templating languages when :BLANK_LINE: was involved#9592
dyc3 wants to merge 3 commits intomainfrom
dyc3/fix-9097

Conversation

@dyc3
Copy link
Contributor

@dyc3 dyc3 commented Mar 23, 2026

Summary

generated by gpt 5.4

This one was a bit weird because the bug happened across both with and without full html support, but only on astro. vue and svelte was bugged only with full html support enabled.

Essentially, this was an interaction between how we extract embedded snippets vs how the rule deals with the :BLANK_LINE: group.

fixes #9097

Test Plan

Docs

@changeset-bot
Copy link

changeset-bot bot commented Mar 23, 2026

🦋 Changeset detected

Latest commit: 53db612

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

@dyc3 dyc3 marked this pull request as draft March 23, 2026 00:55
@github-actions github-actions bot added A-Project Area: project A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Mar 23, 2026
@github-actions github-actions bot added the A-CLI Area: CLI label Mar 23, 2026
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 fix isn't entirely correct. There's an evident regression in the snapshots

Comment on lines +42 to +45
1 │ - import·{·getLocale·}·from·"astro:i18n";
2 │ - import·{·Code·}·from·"astro:components";
1 │ + import·{·Code·}·from·"astro:components";
2 │ + import·{·getLocale·}·from·"astro:i18n";
Copy link
Member

Choose a reason for hiding this comment

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

Do you see the bug? The first import now is at line 1, which is wrong. It should be at line 2, like before

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I did. I'm still mulling over whether or not this is the right fix. I'll mark it ready to review when its ready to review.

Comment on lines +83 to +95
/// Returns the byte range of the actual frontmatter code inside the `---` fences.
///
/// Astro frontmatter commonly includes a newline immediately after the opening
/// fence and before the closing fence. Those wrapper-adjacent bytes are part of
/// the host document layout, but they should not be treated as part of the
/// embedded JavaScript/TypeScript snippet itself.
///
/// Keeping them in the embedded slice makes snippet-based assists like
/// `organizeImports` observe a different input than standalone JS/TS, which can
/// lead to incorrect blank-line edits at the snippet boundary. By trimming only
/// the fence-adjacent whitespace, we keep parser offsets and fix application
/// aligned to the meaningful frontmatter content while still preserving the host
/// document's surrounding layout.
Copy link
Member

Choose a reason for hiding this comment

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

Here's the problem of the agents: they write the comments as a "story" of things they're fixing, with the given context:

  • it talks about import sorting, when it's not necessarily the cause of the bug
  • it talks about Astro when in reality we are fixing a more general problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Linter Area: linter A-Project Area: project L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Astro - Assist organizeImports with :BLANK_LINE: group breaks

2 participants