-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Reverts #7865, keeping class names on the same line #11827
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
Conversation
flex-column flex-lg-row | ||
justify-content-start justify-content-lg-between | ||
align-items-start align-items-lg-center | ||
" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this output as a new test input to make sure that existing code with line breaks in the class
attribute continues to be formatted correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR does not implement the behavior where it keeps it if there is already a line break. So they will get collapsed.
I just realized why I never noticed this behavior before: In JSX, we just keep the class name as it exactly. It seems like the JSX and HTML behavior should be exactly the same. We should just keep the class name as is, so that means that all existing users won't be effected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In JSX, we just keep the class name as it exactly. It seems like the JSX and HTML behavior should be exactly the same.
Formatting for class names in html was introduced in #7555 https://prettier.io/blog/2020/03/21/2.0.0.html#format-value-of-html-class-attribute-7555httpsgithubcomprettierprettierpull7555-by-fiskerhttpsgithubcomfisker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will reopen #7863
I can say that this is super weird behavior. Is there any chance to have this available at least behind an option, something similar to proseWrap? Maybe classWrap? |
Someone know how to solve this? |
@alicercedigital I don't think it's possible at the moment, but highly needed in my opinion |
…#11827) * Reverts prettier#7865, keeping class names on the same line * Add changelog * Fix lint * Fix Co-authored-by: fisker Cheung <lionkay@gmail.com>
Description
This reverts #7865 which introduced automatically breaking class names across multiple lines. This has introduced significant community churn, particularly in CSS frameworks like Tailwind where it's typical to have a lot of class names.
I think this was on overstep on Prettier's part. The consequence of breaking this line is large and there's not a strong enough reason for it. While these decisions are somewhat subjective, I still don't see strong arguments to implement this feature. It's too opinionated. It's a "nice" thing for people that want it, but it wreaks havoc on code for people that don't want it. Given that balance, I think we should remove it.
If we merge this PR and someone really wants class names to be formatted, look into suggestions like here: #10918 (comment). I think it'd be fine to simply break the class names across lines if there is newline in there. It's not fully reversable, but we have the same behavior for objects. I don't 100% love it all the time, but it is a clever technique that balances the tradeoffs between users. I think it'd be fine here even if I don't want that behavior for everything.
Checklist
docs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨