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

Fix edge cases with whitespace in enforces-shorthand #308

Merged
merged 2 commits into from Jan 17, 2024

Conversation

kachkaev
Copy link
Contributor

@kachkaev kachkaev commented Jan 15, 2024

Description

I noticed a small bug when updating a side project to eslint-plugin-tailwindcss@3.14.0 and running pnpm fix:eslint. See commit history in kachkaev/website#311.

Input:

<body className={`relative flex h-full w-full flex-col overflow-y-scroll px-5 pt-4 ${locale}`}>

Ouput:

<body className={`relative flex size-full flex-col overflow-y-scroll px-5 pt-4${locale}`}>

Expected output:

<body className={`relative flex size-full flex-col overflow-y-scroll px-5 pt-4 ${locale}`}>

This PR makes sure that a space is not removed between pt-4 and ${locale} when tailwindcss/enforces-shorthand does an autofix.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

See new unit tests

Test Configuration:

CI

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 N/A
  • 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 N/A
  • I have checked my code and corrected any misspellings

},
{
code: "<div className={ctl(`w-full px-10 py-10 ${live && 'bg-white'}`)}>Trailing space trim issue with fix</div>",
output: "<div className={ctl(`w-full p-10 ${live && 'bg-white'}`)}>Trailing space trim issue with fix</div>",
Copy link
Contributor Author

@kachkaev kachkaev Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Observed output before the fix:

Suggested change
output: "<div className={ctl(`w-full p-10 ${live && 'bg-white'}`)}>Trailing space trim issue with fix</div>",
output: "<div className={ctl(`w-full p-10${live && 'bg-white'}`)}>Trailing space trim issue with fix</div>",

@kachkaev kachkaev marked this pull request as ready for review January 15, 2024 18:44
@francoismassart francoismassart merged commit 7687ecf into francoismassart:master Jan 17, 2024
@kachkaev kachkaev deleted the fix-space-issue branch January 17, 2024 11:26
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.

None yet

2 participants