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

[Feature request] Automatic whitespace removal #263

Open
kachkaev opened this issue Jul 21, 2023 · 9 comments
Open

[Feature request] Automatic whitespace removal #263

kachkaev opened this issue Jul 21, 2023 · 9 comments
Labels
enhancement New feature or request

Comments

@kachkaev
Copy link
Contributor

kachkaev commented Jul 21, 2023

Is your feature request related to a problem? Please describe.

When using TailwindCSS, my teammates and I often end up with multiple spaces in the list of classes:

<div className="    flex   w-full space-x-4      items-center ">...</div>

When we apply autofix (tailwindcss/classnames-order), class names are reordered but extra spaces between them are not removed:

<div className="    flex   w-full items-center      space-x-4 ">...</div>

Describe the solution you'd like

I understand that certain teams might want to keep the original spacing, e.g. when someone wants to align class names of different width. However, it’d be great to have an option to auto-remove them:

<div className="flex w-full items-center space-x-4">...</div>

How about a new rule, say, tailwind/whitespace?

Describe alternatives you've considered
I looked around for potential ESLint rules in other plugins but could not find anything that would cover this case. Even if there exists something for className="..." outside eslint-plugin-tailwindcss, that solution would not be ideal. Spaces should be removed from all TailwindCSS-related strings, e.g. inside cn() and other configured functions. So it feels like this rule does belong to this plugin.

Additional context
See #1, which is the original feature request for this behavior. The issue was fixed in 46717c8 but was then discontinued in #126. You can tell this by the removal of a relevant test case.

@kachkaev kachkaev added the enhancement New feature or request label Jul 21, 2023
@kachkaev
Copy link
Contributor Author

👋 @francoismassart! Would you be willing to a accept a PR for this?

@AndonMitev
Copy link

Hey please can we have this PR approved looks like common issue to put extra spaces in classNames

@manyuemeiquqi
Copy link

I think it's a good suggestion,i need it.

@stefanofa
Copy link

Any update on this?

@kachkaev
Copy link
Contributor Author

kachkaev commented Nov 27, 2023

Happy to try a PR if it has chances to get released. The latest commit on master was on Jun 27. I just want to make sure that the repo is actively maintained before investing time in a new rule. WDYT @francoismassart?

@ziyafenn
Copy link

Is there no progress on this? Would be a killer feature as tailwind intellisense extension stopped supporting this too.

@kachkaev
Copy link
Contributor Author

kachkaev commented Jan 18, 2024

👋 @francoismassart, congrats on a new release and thanks for merging #308! Glad that you’re still looking after this plugin.

WDYT of tailwind/whitespace as a new rule? I can try to create a PR if it has chances of getting released. This issue is the top-voted one at the moment:

Screenshot 2024-01-18 at 14 19 39

@thenbe
Copy link

thenbe commented Feb 23, 2024

eslint-plugin-unocss has a similar rule (no-excessive-whitespaces) that can be used for inspiration.

@JacobZyy
Copy link

Is there no progress on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants