Do not split classes by non-ASCII whitespace#166
Merged
thecrypticace merged 3 commits intotailwindlabs:mainfrom May 26, 2023
Merged
Do not split classes by non-ASCII whitespace#166thecrypticace merged 3 commits intotailwindlabs:mainfrom
thecrypticace merged 3 commits intotailwindlabs:mainfrom
Conversation
Contributor
|
Thanks! |
bronisMateusz
pushed a commit
to bronisMateusz/prettier-plugin-tailwindcss-drupal
that referenced
this pull request
Apr 16, 2025
* add failing test * do not separate classes by non-ASCII white space * Update changelog --------- Co-authored-by: Jordan Pittman <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello, recently applying
prettier-plugin-tailwindcssbroke our styling 😭 so here is a fix.Problem
According to the web standard, HTML's
classattribute is split by ASCII whitespace into a set of classes. In other words, non-ASCII whitespace characters are not class separators.For example,
px-1 py-2is one class (notice that the spece in between is a U+3000), not two classes (px-1andpy-2).However, this plugin wrongly treats non-ASCII whitespace as a class separator, which may lead to unintended change of meaning of code.
The concrete scenario is that, when I newly applied
prettier-plugin-tailwindcssto our project there was code like:where
px-1andz-10weren't effective due to the U+3000.After applying this plugin this turned into:
Now
z-10revived andw-fullwent ineffective instead, which led to unwanted styling change.Solution
This PR fixes the problem by treating only ASCII whitespace as separators.
Note
Of course use of
U+3000is a mistake and should have been prevented by some sort of linting. However, eslint-plugin-tailwindcss had the same issue 😢