Skip to content

Conversation

@julienbenac
Copy link
Contributor

Closes #4923

This PR enhances the @unocss/order ESLint rule to support sorting UnoCSS classes inside arrays passed to functions like classnames and custom utilities. Previously, unordered classes in arrays were not detected or auto-fixed, which led to inconsistent styling and missed linting errors.

🐛 Problem

The rule only checked class strings passed directly to functions. When classes appeared inside arrays, unordered classes slipped through without any warning or auto-fix, making it easy for styling inconsistencies to creep into the codebase.

✨ Changes

Now, the ESLint rule inspects and sorts UnoCSS classes within arrays passed to supported functions, so unordered classes are always detected and auto-fixed, whether they appear in strings or arrays. This ensures a consistent developer experience and styling.

Before

classnames(['flex-col flex']) // ❌ Not processed
classnames(['flex-col flex'], className) // ❌ Not processed

After

classnames(['flex flex-col']) // ✅ Correctly processed
classnames(['flex flex-col'], className) // ✅ Correctly processed

@netlify
Copy link

netlify bot commented Sep 17, 2025

Deploy Preview for unocss ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 836aab0
🔍 Latest deploy log https://app.netlify.com/projects/unocss/deploys/68cbb9466ffd9000087a8968
😎 Deploy Preview https://deploy-preview-4925--unocss.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 17, 2025

Open in StackBlitz

commit: 836aab0

@zyyv zyyv added this pull request to the merge queue Sep 18, 2025
Merged via the queue into unocss:main with commit d5e08b2 Sep 18, 2025
11 checks passed
@julienbenac julienbenac deleted the fix/eslint-array-order branch September 18, 2025 09:15
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.

[ESLint plugin] unoFunctions option in unocss/order rule doesn't work correctly with arrays

2 participants