Skip to content

Fix Svelte class sorting with prettier-plugin-svelte v4#462

Merged
Boshen merged 2 commits into
tailwindlabs:mainfrom
firatciftci:fix-svelte-modern-ast-tailwind-config
May 25, 2026
Merged

Fix Svelte class sorting with prettier-plugin-svelte v4#462
Boshen merged 2 commits into
tailwindlabs:mainfrom
firatciftci:fix-svelte-modern-ast-tailwind-config

Conversation

@firatciftci
Copy link
Copy Markdown
Contributor

@firatciftci firatciftci commented May 24, 2026

Fixes Svelte class sorting with prettier-plugin-svelte@4.

The recently released version 4 of prettier-plugin-svelte now parses with the modern Svelte AST. That changed the template shape from the legacy html.children / MustacheTag structure to fragment.nodes / ExpressionTag, so the Svelte transformer was no longer reaching markup class attributes or dynamic class={...} expressions. This PR updates the Svelte traversal to handle both AST shapes, while preserving the existing legacy path. It also updates the Svelte plugin test dependency to v4 so this regression is covered.

@firatciftci
Copy link
Copy Markdown
Contributor Author

For context, here's the prettier-plugin-svelte's relevant PR that introduced the usage of modern Svelte AST: sveltejs/prettier-plugin-svelte#512

Copy link
Copy Markdown
Contributor

@leaysgur leaysgur left a comment

Choose a reason for hiding this comment

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

The changes look good.

As for the code, while backward compatibility with previous Svelte versions is maintained, it's a bit concerning that we haven't verified this through tests or CI.

For now, I've confirmed that the tests still pass with prettier-plugin-svelte@3.5.2.

@Boshen Boshen merged commit 410eb88 into tailwindlabs:main May 25, 2026
1 check passed
@firatciftci
Copy link
Copy Markdown
Contributor Author

@leaysgur I didn't touch the changelog in this PR; was that necessary? Apologies for missing that if so!

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.

3 participants