Disabling "smart formatting" of HTML class attribute
Problem
_"We get a lot of requests for adding options, but Prettier is built on the principle of being opinionated about code formatting."_ I totally understand this, and so I apologize beforehand for opening this issue. The reason I think this is a valid issue is because the opinion about this seems to have _changed_ from the perspective of Prettier, even though it was mentioned that there's no community interest for this change (and a lot of pushback) in the introducing pull request. The issue When using frameworks like Tailwind, readability has lowered drastically since this feature: <img width="320" src="https://user-images.githubusercontent.com/1065835/117627441-13b4c680-b170-11eb-824b-d22f07456e84.png" /> References - #836345253 - #836536543 - #836652940 - #839911172 - #841662012 I'd love to still be able to use Prettier, but this is a blocking issue for me and many others. The solution Respecting the `class` attribute to stay on a single line, and only applying formatting it when a user already has a multi-line approach for `class`. Alternatively, an option to disable this feature. Thanks in advance for considering this!
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Disabling "smart formatting" of HTML class attribute
> I found it more readable @alexander-akait I guess it's a matter of preference then. For me, if I consider the following: [code block] I'd see what's going on HTML-wise at a glance. With the new approach, it's less readable, especially since there's even more of these blocks above and below: [code block] > Could you please replace the image in your post with a code block, so that it would be
Trust Score
6 verifications
- 1
@alexander-akait I guess it's a matter of preference then. For me, if I consider
@alexander-akait I guess it's a matter of preference then. For me, if I consider the following:
- 2
I'd see what's going on HTML-wise at a glance. With the new approach, it's less
I'd see what's going on HTML-wise at a glance. With the new approach, it's less readable, especially since there's even more of these blocks above and below:
- 3
> Could you please replace the image in your post with a code block, so that it
> Could you please replace the image in your post with a code block, so that it would be easier to experiment with reformatting that code?
Validation
Resolved in prettier/prettier GitHub issue #10918. Community reactions: 22 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep