Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Remove duplicate class names and spaces on sort #7559

Closed
jakeprins opened this issue Jan 25, 2022 · 7 comments
Closed

Remove duplicate class names and spaces on sort #7559

jakeprins opened this issue Jan 25, 2022 · 7 comments

Comments

@jakeprins
Copy link

jakeprins commented Jan 25, 2022

Awesome work on this plugin! The only thing Headwind is doing that's currently missing is also removing duplicate class names and extra spaces. Would be a nice addition.

// before
<div className=" text-white bg-slate-900 bg-slate-900   "></div>
// after formatting
<div className=" bg-slate-900 bg-slate-900 text-white   "></div>
// expected behavior
<div className="bg-slate-900 text-white"></div> // <-- trim
@reinink
Copy link
Member

reinink commented Jan 25, 2022

I dig the idea of removing duplicate classes! 👍

However, Prettier should already take care of extra spaces. I just gave this a try:

<!-- Before -->
<header class=" bg-grey-200 md:flex         hidden        ">

<!-- After -->
<header class="hidden bg-grey-200 md:flex">

@reinink
Copy link
Member

reinink commented Jan 25, 2022

Hmm, just realizing that while it does it for the class attribute, it doesn't do it for :class:

<!-- Before -->
<header :class="` bg-grey-200 md:flex         hidden        `">

<!-- After -->
<header :class="` hidden bg-grey-200         md:flex        `">

So, I suspect it probably also won't work with some other variations like className and ngClass (although I haven't tested these).

@Harry2D
Copy link

Harry2D commented Jan 27, 2022

@reinink I can confirm it doesn't remove extra spaces for className

@camiant
Copy link

camiant commented Jan 31, 2022

I did the idea of removing duplicate classes! 👍

will this feature be implemented in next releases?

@zommerberg
Copy link

It doesn't remove the spaces in svelte with class.

@jenstornell
Copy link

:class can include more than just the CSS classes. It can have methods etc, even inside the special kind of ticks. Maybe that's why it does not remove duplicate spaces, because it may have unwanted side effects.

But yes, please remove duplicate classes from class.

@snax4a
Copy link

snax4a commented Feb 7, 2022

Not only spaces but line breaks also should be removed

@tailwindlabs tailwindlabs locked and limited conversation to collaborators Feb 21, 2022
@bradlc bradlc converted this issue into discussion #7560 Feb 21, 2022
@bradlc bradlc transferred this issue from tailwindlabs/prettier-plugin-tailwindcss Feb 21, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants