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

feat: add no-multiple-whitespace rule #370

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Ericlm
Copy link
Contributor

@Ericlm Ericlm commented Oct 26, 2024

Whitespace automatic removal

Description

This PR implements a new rule called no-multiple-whitespace which removes unnecessary whitespaces between classes.

Closes #263

Type of change

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) -> maybe, if added to the default configuration
  • This change requires a documentation update

How Has This Been Tested?

I added a corresponding no-multiple-whitespace test file.

Test Configuration:

  • OS + version: macOS 15.0.1 (24A348)
  • NPM version: 10.8.3
  • Node version: 22.6.0

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@xGooddevilx
Copy link

Hello @Ericlm, thanks for this patch. It seems working; any plans to release it?

@Ericlm Ericlm marked this pull request as ready for review December 13, 2024 17:35
@forfalsket
Copy link

Any updates on this? would be nice to have 😄

@Ericlm
Copy link
Contributor Author

Ericlm commented Jan 7, 2025

@francoismassart What do you think of this rule?

@YoussefNassar
Copy link

This rule is needed. can't wait :)

@Omar-Elmassry
Copy link

very needed rule thanks for your efforts @Ericlm
any plans on merging this pr ? @francoismassart

@francoismassart
Copy link
Owner

Hi,
there is one issue with this feature: it will return false positive on multines usages such as with ctl calls...

e.g.

ctl(`
  sm:w-6
  w-8
  container
  w-12
  flex
  lg:w-4
`);

Maybe you should detect if the current classlist contains new lines or carriages return and handle theses cases.

@Ericlm
Copy link
Contributor Author

Ericlm commented Jan 18, 2025

Maybe you should detect if the current classlist contains new lines or carriages return and handle theses cases.

I handled the case by returning if the classNames contains any line break/carriage return. It won't remove spaces around classes in this syntax, as it may contains leading whitespaces. At best, it could remove trailing whitespaces I think. 🤔

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 this pull request may close these issues.

[Feature request] Automatic whitespace removal
6 participants