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

Fix order of classes starting with digits in tailwindcss class sorter #58

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

enescakir
Copy link

CSS classes cannot begin with digits. For this reason, Tailwind uses \3 to escape them. For instance, 2xl:col-span-10 is transformed into .\32xl\:col-span-10 { grid-column: span 10 / span 10; } in the final CSS file.

tailwindlabs/tailwindcss#3069

The current Tailwind CSS class sorter implementation does not handle this correctly. As it cannot identify suitable classes beginning with digits, it places them at the start of the sorted list.

Expected output:

divide-y divide-gray-200 lg:col-span-8 xl:col-span-9 2xl:col-span-10 pb-10

Current output:

2xl:col-span-10 divide-y divide-gray-200 pb-10 lg:col-span-8 xl:col-span-9

I simply remove the escape characters from the class name.

CSS classes cannot begin with digits. For this reason, Tailwind uses
`\3` to escape them. For instance, `2xl:col-span-10` is transformed into
`.\32xl\:col-span-10 { grid-column: span 10 / span 10; }` in the final
CSS file.

tailwindlabs/tailwindcss#3069

The current Tailwind CSS class sorter implementation does not handle
this correctly. As it cannot identify suitable classes beginning with
digits, it places them at the start of the sorted list.

Expected output:

    divide-y divide-gray-200 lg:col-span-8 xl:col-span-9 2xl:col-span-10 pb-10

Current output:

    2xl:col-span-10 divide-y divide-gray-200 pb-10 lg:col-span-8 xl:col-span-9

I simply remove the escape characters from the class name.
@enescakir
Copy link
Author

Hi @elia, do you have any reviews for this PR?

1 similar comment
@enescakir
Copy link
Author

Hi @elia, do you have any reviews for this PR?

enescakir added a commit to ubicloud/ubicloud that referenced this pull request Nov 7, 2024
We were using a forked version of nebula/erb-formatter due to these two
commits:
- ubicloud/erb-formatter@05b30f6
- ubicloud/erb-formatter@a9ff000

These issues have been fixed upstream, so I initially planned to switch
to the official package. However, I encountered another problem and
created two PRs to address them. Unfortunately, I didn't receive any
response from the maintainer. Thus, I've decided to continue using our
updated forked version.
- nebulab/erb-formatter#58
- nebulab/erb-formatter#59
enescakir added a commit to ubicloud/ubicloud that referenced this pull request Nov 7, 2024
We were using a forked version of nebula/erb-formatter due to these two
commits:
- ubicloud/erb-formatter@05b30f6
- ubicloud/erb-formatter@a9ff000

These issues have been fixed upstream, so I initially planned to switch
to the official package. However, I encountered another problem and
created two PRs to address them. Unfortunately, I didn't receive any
response from the maintainer. Thus, I've decided to continue using our
updated forked version.
- nebulab/erb-formatter#58
- nebulab/erb-formatter#59
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.

1 participant