-
Notifications
You must be signed in to change notification settings - Fork 128
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
Inconsistent sorting between formatting all files and a single file #246
Comments
If I remove export function sortClassList(classList, { env }) {
let classNamesWithOrder = env.context.getClassOrder
? env.context.getClassOrder(classList)
: getClassOrderPolyfill(classList, { env })
return classNamesWithOrder
.sort(([, a], [, z]) => {
if (a === z) return 0
// if (a === null) return options.unknownClassPosition === 'start' ? -1 : 1
// if (z === null) return options.unknownClassPosition === 'start' ? 1 : -1
if (a === null) return -1
if (z === null) return 1
return bigSign(a - z)
})
.map(([className]) => className)
} |
Hey — so this is a problem in Tailwind CSS itself coupled with the fact that we have to do some things in the Prettier plugin for performance reasons. I've merged in a fix in tailwindlabs/tailwindcss#12911 and I'm going to work on back porting to v3.4 and get a patch release out this week. Thanks for pointing this out! |
What version of
prettier-plugin-tailwindcss
are you using?v0.5.11
What version of Tailwind CSS are you using?
v3.4.1
What version of Node.js are you using?
v20.10.0
What package manager are you using?
npm, pnpm
What operating system are you using?
Windows (WSL)
Reproduction URL
https://github.com/lesha1201/tailwind-prettier-plugin-inconsistent-sorting-issue
Describe your issue
button-social-facebook.tsx.-.tailwind-inconsistent-sorting-issue.WSL_.Ubuntu.-.Visual.Studio.Code.2024-02-08.14-33-06.mp4
prettier-plugin-tailwindcss
formats a certain file differently when you format all files and only that file. In the reproduction example, there are two components:ButtonSocialApple
andButtonSocialFacebook
which have similar tailwind classes.When you format all files by running:
npx prettier --write .
It produces one result for
ButtonSocialFacebook
:When you format only
ButtonSocialFacebook
:It produces a different result:
However, when you remove
ButtonSocialApple
component, it formatsButtonSocialFacebook
consistently.The text was updated successfully, but these errors were encountered: