prettier-plugin-tailwindcss: Plugin is incompatible with Prettier v3.0
What version of prettier-plugin-tailwindcss
are you using?
v0.3.0
What version of Tailwind CSS are you using? v3.3.2
What version of Node.js are you using? v18.16.0
What package manager are you using? npm
What operating system are you using? macOS
Describe your issue
I’ve installed tailwindcss, prettier and prettier-plugin-tailwindcss in my new next js app. But the class is not sorting when I save the file.
I found this error on the vs code logs output
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 58
- Comments: 43 (5 by maintainers)
Links to this issue
Commits related to this issue
- downgrade prettier to 2.8.8 https://github.com/tailwindlabs/prettier-plugin-tailwindcss/issues/176#issuecomment-1621926950 — committed to nanxiaobei/hugo-paper by nanxiaobei a year ago
- Disable prettier-plugin-tailwindcss https://github.com/tailwindlabs/prettier-plugin-tailwindcss/issues/176 — committed to evoluhq/evolu by steida a year ago
- chore: downgrade prettier to 2.8.8 prettier-plugin-tailwindcss is not working for prettier 3.0.0 https://github.com/tailwindlabs/prettier-plugin-tailwindcss/issues/176 — committed to JeremyLoh/window by JeremyLoh a year ago
- fix(deps): downgrade prettier to v2.8.8 Related issues: * https://github.com/prettier/eslint-plugin-prettier/issues/562 * https://github.com/tailwindlabs/prettier-plugin-tailwindcss/issues/176 — committed to mateusfg7/mateusf.com by mateusfg7 a year ago
- https://github.com/tailwindlabs/prettier-plugin-tailwindcss/issues/176 — committed to mthierman/Airglow by mthierman a year ago
Hey! For now we’d recommend downgrading to v2.8. Prettier v3.0 has some API changes that’ll require a good bit of work and testing for our plugin. But it’s on our radar! I’m going to be looking into this later this week or early next week.
Hey all! We’ve just released v0.4.0 with support for both Prettier v2.x and v3.0.
Please note that many plugins have yet to be updated for Prettier v3 so the third-party plugin compatibility has been temporarily disabled when using Prettier v3. Once plugins start migrating we will test them and do another release that implements compatibility with working third-party plugins where possible.
So, for example, Svelte, Twig (Melody), Pug, Astro, etc… are not currently supported. We’ll be keeping an eye on the plugins once they’ve updated and work toward another release which re-enables support.
Please give the new version a test and open a new issue if you see any problems. Thanks for your patience! ✨
You dont need to downgrade, just add this line “plugins”: [“prettier-plugin-tailwindcss”] to .prettierrc.json
Node.js Version: v18.16.0 Package Manager: npm Operating System: macOS
Here to confirm that rolling back to prettier v2.8 resolved the issue. Commands used:
npm uninstall prettier prettier-plugin-tailwindcss
npm install -D prettier@2.8 prettier-plugin-tailwindcss
@RnbWd, they did warn about the breaking changes about 8 month ago in https://github.com/prettier/prettier/issues/13616 and even left a message about it in tailwindcss repo https://github.com/tailwindlabs/tailwindcss/discussions/9602 that was ignored
Same issue here after upgrading to prettier 3.0
Just to be clear here we didn’t ignore it, we simply didn’t see it. The discussion area is for the community, it’s not an inbox for the team where we read every message. I see maybe 5% of messages posted there.
reading the prettier 3.0 docs was a headache for me, I had no idea they were going to completely break almost all plugins overnight with no warning. It’s not a small change at all. I’ll be sticking with v2 for the next 6 months.
It seems that you are currently utilizing prettier version
3.0.0
. Please consider a temporary downgrade to version2.8.8
.For folks using vs code that are still having issues with version 2.8.8, you could try installing the specific Prettier extension version 9.13.0. I’ve found some backwards compatibility issues with the latest extension version. https://marketplace.visualstudio.com/items/esbenp.prettier-vscode/changelog
@mutheusalmeida
I don’t know if this will work for you but after downgrading I had to reload my vscode for it to start working for me. I’m not using a
.prettierrc
file though. I’m just using the prettier extension.While we’re at it, I also noticed that prettier recently removed plugin autoloading (https://github.com/prettier/prettier/pull/14759) in version 3.0.0, breaking configurations that rely on autoloading as the docs for this plugin recommend.
In a JS file also works
.prettierrc.js
Took me way too long to get this to work, getting confused by the comments above… It was actually very simple and straight forward to get it to work with the 3.x branch of prettier. This is what worked for me:
npm install -D prettier prettier-plugin-tailwindcss
At the moment of writing.prettierrc.json
@martinharyanto Without the
require()
It is not a workaround, it it the new way to implement. Cause is the removed plugin autoloading in prettier v3 because of problems with package managers except npm.
Works for me!
Spent 3 hours on this (first time installation and first time prettier config). Works after downgrade. Thought I was losing my mind
After downgrade, it`s works fine for me
The plugin search feature has been removed.
Because it’s fixed!
It just works with a
.json
file. Anyone know whats the matter?@vighnesh153 I’m pretty sure this is a change in Prettier itself rather than with our plugin. It may be related to the removal of plugin autoloading in Prettier v3 which means that you may need to specify the full path to the plugin.
@debashisbiswas The docs for this plugin explicitly recommended against autoloading and gave instructions for disabling it (when using it in conjunction with any other “compatible” plugin).
We’ll update the docs to remove any mention of autoloading once we’ve updated for v3.0.