-
Notifications
You must be signed in to change notification settings - Fork 138
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
Incompatibility with other Prettier plugins #31
Comments
I originally opened issue #26 about // merged-prettier-plugin.js
const tailwind = require('prettier-plugin-tailwindcss')
const organizeImports = require('prettier-plugin-organize-imports')
const combinedFormatter = {
...tailwind,
parsers: {
...tailwind.parsers,
...Object.keys(organizeImports.parsers).reduce((acc, key) => {
acc[key] = {
...tailwind.parsers[key],
preprocess(code, options) {
return organizeImports.parsers[key].preprocess(code, options)
},
}
return acc
}, {}),
},
}
module.exports = combinedFormatter // .prettierrc.js
module.exports = {
plugins: [require('./merged-prettier-plugin.js')],
...
} This works for now because, from what I can tell, Looking forward to whatever eventual fix removes the need for the patch! |
Might be a bit of an edge case. But I am using Laravel and subsequently Blade template files. So that prettier runs on these files I am using @shufo/prettier-plugin-blade. But as this issue suggests, Tailwind classes are not sorted when run with this plugin. |
Seems this one might be incompatible as well https://github.com/withastro/prettier-plugin-astro |
I'm in a vue 3 project where we use pug and the plugin is not really working with my current setup. I'm also using vetur as a vscode extension that is set to format everything with prettier (html, pug, etc). Something strange is happening because if I add new lines or extra tabs, the formatter will kick in on save and do its job. However it does not format the order of tailwind classes, even in regular html template tags. The only time I got the tailwind order to work was by doing the I tried removing the dependency for the prettier pug plugin and testing it out and it still does not order classes. Is it conflicting with something else?
|
@rwwagner90 It's not that this plugin is incompatible with |
Subscribing to this. Working with Craft CMS, it's disappointing to see this is incompatible with prettier-plugin-twig-melody. |
Would it be possible to add astro support? |
plugin not work when i use @apply on .scss file ? :( |
Seem to be having problems when parsing Angular HTML files too |
I don't know if it is also related to this, but I can't have |
@nunocasteleira this issue is related to prettier plugins conflicting with each other. If your system can't find If you continue to have problems open an issue on the forms repo. |
Yes, but the problem arises when |
@nunocasteleira Can you share your prettier config file with us? |
Did you find a way to get this working? |
@joshmedeski I have a very minimal prettierrc, it's a Vue project:
|
@nunocasteleira I'm stumped. I don't know why |
I can share the repo if you want.
…On 21 Apr 2022, 22:01 +0100, Josh Medeski ***@***.***>, wrote:
@nunocasteleira I'm stumped. I don't know why @tailwindcss/forms has any relationship with prettier-plugin-tailwindcss.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Also appears to be incompatible with prettier-plugin-jsdoc. My prettier config:
|
what's progress of this issue, i run into this issue, it will break plugin |
No one has taken ownership to fix this issue. For now, I suggest everyone expect After reviewing prettier/prettier#10261 it seems like this plugin is highjacking the typescript parser and so any other plugin that also wants to interact with the same parser they are ignored. If someone understands this please feel free to experiment with rewriting this plugin so other plugins continue to work as expected. |
Both |
If you want a workaround, you could use the prettier This solution won't work with your IDE on saving, but it could work with a lint-stage solution. prettier --config ./.prettierrc.tailwind.js --write .
prettier --config ./.prettierrc.other.js --write . It's not a pretty solution, but I think it's possible for those that strongly want multiple plugin support. I, personally, have decided to use the tailwind prettier plugin on its own for now to avoid adding this much complexity to my projects. |
@sameeranand1 Done: #102 🤙 This has been released as |
Hello everyone, another update, we've just released v0.2.0, which includes all these plugin compatibility fixes. You can install it using npm:
We've also updated the readme to list all the Prettier plugins that we've added explicit support for: With all this complete, I am going to close this issue as resolved. Thanks to everyone here for sharing information about incompatible plugins with us! 🙏 |
So with this release already available is it still necessary to edit the // .prettierrc
{
// ..
"plugins": [
"@prettier/plugin-pug",
"prettier-plugin-organize-attributes",
"prettier-plugin-tailwindcss" // It does not work if I put it here
],
"pluginSearchDirs": false
} and if I put |
Looking forward for this to be compatible with @ianvs/prettier-plugin-sort-imports |
Hey @blooddrunk, this workaround worked for me:
Related to this answer. |
Another breaking plugin is |
@ramblehead Hey! So we actually already have support for |
@blooddrunk @bryanbarrios Just a heads up that we've also added support for |
Beautiful thanks! This worked for me (Next 13, pnpm) |
Isn't working with Prettier v3 Adding
|
@itz4rv This issue is 20 months old. The instructions have changed such that we no longer have to bundle Svelte and you include it in your plugins list like you'd do that with any other. This is documented in the readme: https://github.com/tailwindlabs/prettier-plugin-tailwindcss#compatibility-with-other-prettier-plugins |
It is still not working for me: module.exports = {
trailingComma: "all",
tabWidth: 2,
semi: true,
singleQuote: false,
plugins: [
"prettier-plugin-packagejson",
"prettier-plugin-jsdoc",
"@trivago/prettier-plugin-sort-imports",
// Must be loaded last
"prettier-plugin-tailwindcss",
],
// prettier-plugin-tailwindcss
tailwindAttributes: ["classProp"],
// @trivago/prettier-plugin-sort-imports
// https://github.com/trivago/prettier-plugin-sort-imports#usage
importOrder: ["^#styles(.*)$", "<THIRD_PARTY_MODULES>", "^#(.*)$", "^[./]"],
importOrderSeparation: true,
importOrderSortSpecifiers: true,
importOrderGroupNamespaceSpecifiers: true,
};
"devDependencies": {
"@tailwindcss/typography": "^0.5.10",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"prettier": "3.1.0",
"prettier-plugin-jsdoc": "^1.1.1",
"prettier-plugin-packagejson": "^2.4.6",
"prettier-plugin-tailwindcss": "^0.5.7",
"tailwindcss": "^3.3.5",
"typescript": "5.2.2",
"vite": "^5.0.0",
}, 🤔 |
Seems like it's not working when used with "prettier-plugin-organize-attributes" |
The issue was a problem with my VSCode, all worked after restart |
added prettier tailwind to project instead. see tailwindlabs/prettier-plugin-tailwindcss#31
To make this plugin work we had to use private Prettier APIs that can only be used by a single plugin at once. This means this plugin is incompatible with other Prettier plugins that are using the same APIs.
This GitHub issue will serve as a place to keep track of which Prettier plugins are incompatible — and hopefully we'll eventually find some workarounds, or even a proper long term solution. 👍
Known incompatibilities
@trivago/prettier-plugin-sort-imports
prettier-plugin-organize-imports
prettier-plugin-svelte
(see below)prettier-plugin-twig-melody
prettier-plugin-svelte
We've bundled the
prettier-plugin-svelte
directly intoprettier-plugin-tailwindcss
, so if you'd like to use this plugin with Svelte, just uninstallprettier-plugin-svelte
and everything should work as expected.Workarounds
While I have not tested it yet, @Mattinton provided one possible workaround in this comment.
The text was updated successfully, but these errors were encountered: