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

deno fmt should keep line breaks for the html class attribute. #75

Closed
MohammadSu1 opened this issue Nov 4, 2024 · 3 comments
Closed

Comments

@MohammadSu1
Copy link

I use tailwindcss and often end up sometimes with lots of classes in my either .svelte files or .html files.
To make them more readable and compact I structure them with linebreaks. However, currently deno fmt will rearrange them in one long line that needs horizontal scrolling in VScode to review.

<div
  class="aclass aclass aclass aclass aclass 
aclass aclass aclass aclass aclass aclass aclass 
aclass aclass aclass aclass aclass aclass aclass 
aclass aclass aclass aclass aclass aclass aclass 
aclass aclass aclass aclass aclass aclass aclass 
aclass aclass aclass aclass aclass aclass"
>
  div with lost of tailwindcss classes
</div>

expected:

<div
  class="aclass aclass aclass aclass aclass 
    aclass aclass aclass aclass aclass aclass aclass 
    aclass aclass aclass aclass aclass aclass aclass 
    aclass aclass aclass aclass aclass aclass aclass 
    aclass aclass aclass aclass aclass aclass aclass 
    aclass aclass aclass aclass aclass aclass"
>
  div with lost of tailwindcss classes
</div>

actual (deno 2.0.4 (stable, release, x86_64-pc-windows-msvc)

<div
  class="aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass aclass"
>
  div with lost of tailwindcss classes
</div>

Originally reported in denoland/deno#26690

@g-plane
Copy link
Owner

g-plane commented Nov 5, 2024

@UnknownPlatypus How do you think? Should we keep classes on the same line or add line breaks? Or, add an option to allow users to control this?

@UnknownPlatypus
Copy link
Contributor

@g-plane I feel like if we try to add line break we will never get it right because some users will want:

In my opinion, the best and most flexible way to handle this would be to follow adam wishlist he explained with many details here prettier/prettier#10918 (comment)

We could have a flag to choose between current behavior (always put everything on one line) and the new behavior (format on one line if there are no pre-existing newlines, otherwise format on multiple lines)

To me it's the best of both worlds

@g-plane
Copy link
Owner

g-plane commented Nov 5, 2024

That solution sounds great, at least better than simply choosing adding line breaks or not.

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 a pull request may close this issue.

3 participants