Skip to content

Conversation

@nylexar-sudo
Copy link
Contributor

@nylexar-sudo nylexar-sudo commented Sep 14, 2025

Changes

This PR fixes a formatting loop when using the following prettier options to format a multiline empty element

{
  "bracketSameLine": true,
  "htmlWhitespaceSensitivity": "ignore
}

The loop goes like this:

➜ cat test.astro
<script is:inline src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-123456" crossorigin="anonymous"></script>

➜ pnpm exec prettier test.astro --write
test.astro 236ms

➜ cat test.astro
<script
  is:inline
  src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-123456"
  crossorigin="anonymous">
</script>

➜ pnpm exec prettier test.astro --check
Checking formatting...
[warn] test.astro
[warn] Code style issues found in the above file. Run Prettier with --write to fix.

➜ pnpm exec prettier test.astro --write
test.astro 106ms

➜ cat test.astro
<script
  is:inline
  src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-123456"
  crossorigin="anonymous"
></script>

➜ pnpm exec prettier test.astro --check
Checking formatting...
[warn] test.astro
[warn] Code style issues found in the above file. Run Prettier with --write to fix.

➜ pnpm exec prettier test.astro --write
test.astro 104ms

➜ cat test.astro
<script
  is:inline
  src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-123456"
  crossorigin="anonymous">
</script>

Testing

Automated tests added

Docs

Bug fix. No docs.

@changeset-bot
Copy link

changeset-bot bot commented Sep 14, 2025

🦋 Changeset detected

Latest commit: 5a7ab3e

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

This PR includes changesets to release 1 package
Name Type
prettier-plugin-astro 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

Copy link
Member

@Princesseuh Princesseuh left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@Princesseuh Princesseuh merged commit de79d60 into withastro:main Oct 8, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants