-
Notifications
You must be signed in to change notification settings - Fork 0
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
[FAQ] Compatibility with prettier-plugin-tailwindcss
#33
Comments
I think it would be better to leave the issue open so that visitors can be more aware of how to use the plugin. |
Hi @ony3000 Your plugin doesn't work for me. I put the following in my {
"plugins": [
"prettier-plugin-tailwindcss",
"prettier-plugin-classnames",
"prettier-plugin-merge"
]
} I then ran |
@dprkh Have you checked the Ending Position option? When this option is set to default( If class names that are longer than the Since |
I've tried adding
Performance is fine, this is just a formatter after all. I was only pointing out that something is definitely happening there. |
Ah! The name that this plugin considers to be the default attribute for jsx (and tsx) is So, in your case the |
Yep, this worked. Thank you. |
so, it doesn't work with SvelteKit, right? |
@SergiySev For now, yes. In this case, you can still configure Prettier as follows: {
"plugins": [
"prettier-plugin-svelte",
"prettier-plugin-tailwindcss",
"prettier-plugin-classnames",
"prettier-plugin-merge"
]
} However, among the above plugins, only There is logic inside |
I'm using this plugin and the merge plugin with angular with the following config: /** @type {import("prettier").Config} */
const config = {
plugins: [
"prettier-plugin-tailwindcss",
"prettier-plugin-classnames",
"prettier-plugin-merge",
],
customAttributes: ["class", "className", "style"],
endingPosition: "absolute-with-indent",
printWidth: 80,
overrides: [
{
files: "*.html",
options: {
parser: "angular",
},
},
],
};
export default config; and I have the following html snippet: <button
type="submit"
class="w-full rounded-lg bg-blue-700 px-5 py-2.5 text-center text-sm font-medium text-white hover:bg-blue-800 focus:outline-none focus:ring-4 focus:ring-blue-300 sm:w-auto dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
>
Submit
</button> When I run prettier with:
The class name does not get formated |
@lampewebdev As you can see in the first note, angular is also not currently supported. Further development is required. |
Just to double check, are you saying formatting through this plugin doesn't work in SvelteKit, right?! |
@yyijoo Strictly speaking, this plugin can work on components written in But I haven't used SvelteKit, so I don't know if such a use case exists. It's true that it doesn't currently work with |
I see Thank you for your reply! @ony3000 |
Finally, @SergiySev @yyijoo @lampewebdev |
Hi, Can we be compatible with the |
@u3u I looked at The intersection of |
@ony3000 Thank you! That's enough! |
Thanks for this plugin @ony3000. But the biggest pain still exists even with I know we can format with I believe you've been using this. So how did you work around it? |
@udohjeremiah I mainly use VS Code. The Please try cloning the next-tailwind-template repository and check, and if the "pain" is reproduced, please report the issue. |
Put the same settings to your VS Code settings.jsonprettier.config.mjs
VS Code settings.json
Modify to your needs accordingly. Sometimes it's also a good idea to restart VS Code when changing these settings. |
Can I use this plugin with
prettier-plugin-tailwindcss
?Of course! However, there are a few notes.
Languages that can be used with
prettier-plugin-tailwindcss
are limited to:v0.3.0
or higher)v0.6.0
or higher)v0.7.0
or higher)Support for other languages requires further development.
You need to add
prettier-plugin-merge
to your Prettier configuration.This is because if two or more plugins are configured to format a particular language, Prettier will only use the last of those plugins.
So, for example, if you configure it like this, only
prettier-plugin-tailwindcss
will be used.By reordering the two plugins, now only
prettier-plugin-classnames
is used.I created
prettier-plugin-merge
to overcome this limitation of Prettier.prettier-plugin-merge
uses the plugins listed before it sequentially to format and merge them.So, to allow Prettier to use
prettier-plugin-merge
, change the configuration as follows:Now Prettier will only use
prettier-plugin-merge
among the three plugins, butprettier-plugin-merge
will useprettier-plugin-tailwindcss
andprettier-plugin-classnames
sequentially.So the class names will be sorted first and then wrapped.
The text was updated successfully, but these errors were encountered: