tailwindlabs/prettier-plugin-tailwindcss

Organize classes in .php files

Finallf opened this issue · 3 comments

What version of prettier-plugin-tailwindcss are you using?
v0.5.9

What version of Tailwind CSS are you using?
v3.3.6

What version of Node.js are you using?
v20.10.0

What package manager are you using?
npm

What operating system are you using?
Windows

Describe your issue

It appears to have been fixed in another plugin:
#shufo/prettier-plugin-blade#161 (comment)
##52

Would there be a way to fix the official one too?

Hey, so we'd almost certainly have the same issues we had before. We stopped supporting PHP because there was no real way for us to pass the partial blocks to Prettier as valid HTML. It would complain or sometimes incorrectly reformat code. And working around this proved to be a pretty sizable task that we didn't want to take on because it would likely mean completely re-implementing the HTML parser — or perhaps the PHP one.

The blade plugin uses the blade-formatter package under the hood which actually implemented Tailwind class sorting itself rather than being able to delegate to any installed Prettier plugins for that. Though, they do appear to use our internal API we introduced in Tailwind CSS for this so the result should be identical between this plugin and their implementation.

So, unfortunately, we're not likely to add PHP support to this plugin unless a prettier plugin for it comes along that gives us the necessary hooks to support this in a way that doesn't break or produce invalid HTML.