-
Notifications
You must be signed in to change notification settings - Fork 57
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
Add tailwind class sorting #552
Comments
Maybe it could be done via Eslint? I'm using unocss eslint rule to sort it. |
Pinging this issue in light of Fresh 1.6, a headline of which is "First class Tailwind CSS plugin." |
Some questions regarding the optimal solution: Should it trim leading/trailing/in-between whitespace? For instance... - <div className=" h-2" />
+ <div className="h-2" /> - <div className="h-2 " />
+ <div className="h-2" /> - <div className="h-2 w-2" />
+ <div className="h-2 w-2" /> Should it remove surrounding curlies? - <div className={"h-2"} />
+ <div className="h-2" /> How would we want to tackled non-className-placed tw strings? For instance, using a cn merge utility is a common pattern. function MyComponent({ className }: { className: string }) {
return <div className={cn("h-2", className)} />
} |
Seems the sort order may depend on the tailwind config. This is likely out of scope for the TypeScript plugin. May require a dedicated |
Instead of a dedicated plugin, would a shared crate that other plugins depend on work? Or a plugin that other plugins depend on? I'm thinking that way tailwind classes can be formatted consistently across ts,jsx,html,vue,svelte etc. |
There should be an option to sort class names similar to the prettier plugin.
https://tailwindcss.com/blog/automatic-class-sorting-with-prettier#how-classes-are-sorted
Probably
"jsx.sortClassNames": "tailwind"
or something.The text was updated successfully, but these errors were encountered: