Skip to content
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

Sort class lists deterministically for Prettier plugin #10672

Merged
merged 2 commits into from
Feb 23, 2023

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Feb 23, 2023

Something we noticed in testing. With the latest release we made sure to sort generated rules deterministically rather than based on content-scanning order which can (and does) differ across environments. However, in testing, we noticed that the Prettier plugin didn't take this into account when ordering class names.

This PR enables that behavior in the API used by our prettier plugin so the next release of Tailwind will ensure prettier sorts the classes correctly.

@thecrypticace thecrypticace changed the title Ensure class sorting is deterministic for Prettier Ensure class sorting is deterministic for Prettier plugin Feb 23, 2023
@thecrypticace thecrypticace changed the title Ensure class sorting is deterministic for Prettier plugin Sort class lists deterministically for Prettier plugin Feb 23, 2023
@thecrypticace thecrypticace force-pushed the fix/get-class-order-deterministic branch from 5d22c17 to e44eafa Compare February 23, 2023 18:17
@thecrypticace thecrypticace merged commit d2a95a0 into master Feb 23, 2023
@thecrypticace thecrypticace deleted the fix/get-class-order-deterministic branch February 23, 2023 18:32
@earthboundkid
Copy link

This change results in a lot of churn on my site, and in particular it changes the order of margins. Before margins were trlb but now they aren't. Are we sure this didn't have a bug?

@reinink
Copy link
Member

reinink commented Mar 30, 2023

@carlmjohnson So yeah, this is intended behavior, although you're totally right it does result in a bunch of new classes being sorted by our Prettier plugin that previously weren't. I actually just tweeted about this yesterday: https://twitter.com/reinink/status/1641222722179985408

When we added deterministic sorting to Tailwind CSS back in January (see #10382) we forgot to update the Prettier plugin to match this, so in v3.3 we've corrected this (#10672).

My recommendation is to run Prettier against your whole project to make all these changes at once.

I'm a fan of this change personally the Prettier plugin sorting is even more thorough now — meaning even less for us developers to have to think about 👍

kevinansfield added a commit to TryGhost/Koenig that referenced this pull request Aug 10, 2023
refs #676

- required for the `eslint-plugin-tailwindcss` bump to work correctly
- ran `yarn lint:js --fix`
  - CSS ordering changed to be more deterministic, see tailwindlabs/tailwindcss#10672
kevinansfield added a commit to TryGhost/Koenig that referenced this pull request Aug 10, 2023
refs #676

- required for the `eslint-plugin-tailwindcss` bump to work correctly
- ran `yarn lint:js --fix`
  - CSS ordering changed to be more deterministic, see tailwindlabs/tailwindcss#10672
kevinansfield added a commit to TryGhost/Koenig that referenced this pull request Aug 10, 2023
refs #676

- required for the `eslint-plugin-tailwindcss` bump to work correctly
- ran `yarn lint:js --fix`
  - CSS ordering changed to be more deterministic, see tailwindlabs/tailwindcss#10672
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants