-
Notifications
You must be signed in to change notification settings - Fork 4
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
Doesn't work when coupled with prettier-plugin-tailwindcss
#2
Comments
prettier-plugin-tailwindcss
Wow this is an interesting case. I did some investigating and it looks like this is a general issue with the way prettier plugins are written. Basically, when a new plugin is registered, it is registered as follows:
As you can imagine, once this same code is ran twice in different plugins, I tried out a different prettier plugin |
Nice, thanks a lot! |
@SanderRonde Any luck with this? |
No response yet to my issue unfortunately. |
Fix: const pluginSortImports = require("prettier-plugin-sort-imports");
const pluginTailwindcss = require("prettier-plugin-tailwindcss");
/** @type {import("prettier").Parser} */
const myParser = {
...pluginSortImports.parsers.typescript,
parse: pluginTailwindcss.parsers.typescript.parse,
};
/** @type {import("prettier").Plugin} */
const myPlugin = {
parsers: {
typescript: myParser,
},
};
module.exports = {
plugins: [myPlugin],
// REST OF YOUR CUSTOM PRETTIER CONFIG GOES BELOW
arrowParens: "always",
bracketSpacing: true,
endOfLine: "lf",
htmlWhitespaceSensitivity: "css",
jsxSingleQuote: false,
printWidth: 80,
proseWrap: "preserve",
quoteProps: "as-needed",
semi: true,
tabWidth: 2,
trailingComma: "es5",
}; |
This is a strange one. I'm trying to get both
prettier-plugin-tailwindcss
andprettier-plugin-sort-imports
to work but when one works, the other doesn't.So far I've tried adding a configuration, restarting and reinstalling but maybe I'm doing something wrong?
When using this configuration, If I remove the tailwindcss plugin, sorting works but if I keep the sorting plugin with tailwindcss, import sorting doesn't work.
The text was updated successfully, but these errors were encountered: