New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorting with external plugins like Svelte, Astro, etc… not working when using Prettier v3 #186
Comments
@GeoGeorgeous I will recommend to stick to I will wait a few more weeks and try to update to v3 again. |
I also have this issue, which surfaced after upgrading everything to Prettier v3. Thanks for all your hard work! |
This is what I did in case someone else wants to give it a try:
Then when I run the |
Hi! When we released v3 Svelte, Astro, and all suppored plugins from v2 (as far as I know) had not yet updated. We temporarily disabled support for external plugins because of this — when using v3 only (because there's no way we would be able to shim v2 -> v3 for external plugins). I'm taking a look at all our previously supported plugins on Monday and will try to get a release out Monday/Tuesday with any that have updated. |
Short update here: I've got a prototype version of the v3 plugin with support Astro, Svelte, and other plugins. We've had to switch to using ESM for v3 because we have to use top-level await to dynamically load plugins that we have compatibility with. This is because some of them have switched to ESM which means dynamic imports return promises (… ESM really should have had a sync dynamic import primitive — at least for node :/). I'm currently running into issues with the vscode prettier extension loading the wrong version of the plugin so it doesn't look like I'll get a release out today — sorry. But it is being worked on! :) |
Is anyone aware if there is a manual work-around for now to be able to select class strings in VsCode and use a command to sort the classes? |
@TristanBrotherton you can use Prettier v2 with v0.4 of this plugin and everything should work fine. Note that you'll need to use an earlier version of prettier-plugin-svelte as well. It's the prettier v3 compatibility including external plugins that's the complication at the moment. |
@thecrypticace thanks so much for the response. Unfortunately I'm locked in with Prettier V3 - its not a big deal though. I can just sort the classes retrospectively. I really appreciate your work on this, thank you from all of us! |
Hey all! I pushed out an insiders build that enables support for plugins! There are two important things to note:
I've done a good bit of testing myself and things appear to work but it would be great if you all could test our insiders build in whatever tooling you're using and report back! Also, if you're using VSCode, be sure to reload VSCode after upgrading any prettier plugins. npm install prettier-plugin-tailwindcss@insiders |
Thank you for your work. It managed to sort Tailwind classes after upgrading to the aforementioned build. By the way, I had the following Prettier config.
|
it's working for me after upgrading to insiders version, vscode restart was needed. i'm using it in .astro files. |
It's working with Svelte. package.json
.prettierrc.mjs/js
|
I can also comfirm that it is working in VSCode after restart with
and
in .prettierrc Also changed the format run script to: |
I also had to change the format script to: I had this previously: |
@delight @baresi687 Prettier autoloading was removed with Prettier v3 meaning that you must specify all plugins explicitly. The |
Thanks a lot for your work. However, not working for me, tried on a clean Astro setup. My route: npx astro add tailwind npm i prettier-plugin-astro npm install prettier-plugin-tailwindcss@insiders .prettierrc Prettier is not working at all, no formatting and no tailwind class sort. Maybe I do something wrong? |
@evgrekov you need to install prettier, not just the plugins |
Works with Svelte, but only when modifying the format run script as mentioned in #186 (comment). |
@Serator Do you have a prettier config file? If so, and you still have to modify the format script, can you provide a repro? This is likely to be an issue with Prettier itself. |
I'll be able to add a repository with an example a little later. |
Hey all I've published v0.5.0 which mirrors the insiders build published yesterday — as such I'm closing this issue given that things seem to be working for everyone in most cases! Thanks for giving it a test — much appreciated! |
@Serator I'll still be looking for the update here — but like I said I suspect this is actually a Prettier problem rather than |
@thecrypticace It looks like my issue is described here along with an example to reproduce and it is indeed a problem with Prettier itself. |
@mvllow thanks it's working now :) |
Adding on to this, make sure "prettier-plugin-tailwindcss" comes last in the plugins list as referenced by this comment in another thread. I had these two reversed and had a rough time figuring out why they weren't being compatible 😅 |
@Vaiterius |
Hi,
VSCode auto format (on save) doesn't apply the "prettier-plugin-tailwindcss" effects. BUT, at least, i found that is working. I tried both : So my workaround will be to have a package.json (npm/yarn) command such as : I thank you for all of your work, past and future ;-) Bye |
That is interesting. I still can not manage to achieve that in my Astro project. With none of the suggested solutions, unfortunately. |
I follow this blog, and it works for me: this is my package.json: "scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro",
"format": "prettier --plugin=prettier-plugin-astro --plugin=prettier-plugin-tailwindcss --write ."
}, |
What version of
prettier-plugin-tailwindcss
are you using?v0.4.1
What version of Tailwind CSS are you using?
v3.3.3
What version of Node.js are you using?
v18.16.1
What package manager are you using?
npm
What operating system are you using?
Windows
package.json:
settings.json:
.prettierrc:
tailwind.config.js:
Hi! I'm encountering an issue while setting up the prettier-plugin-tailwindcss and prettier-plugin-svelte plugins for my Svelte app. The problem is that the tailwind classes are not being sorted, even though the prettier-plugin-svelte is functioning correctly for other formatting aspects like tabs, quotes, and empty lines.
Any guidance or advice on resolving this issue would be greatly appreciated.
The text was updated successfully, but these errors were encountered: