`@unocss/order` does not sort class strings inside `unoVariables` assigned to helpers like `defu`, or inside arrow-function slot values
Author: praburangkiCreated Sep 7, 2026Updated Sep 7, 2026
UnoCSS version
66.10.0
Describe the bug
unocss/order can sort class strings on matching unoVariables when the initializer is a string or a plain object:
const buttonClassNames = { default: 'pr1 pl1' }
// autofix → { default: 'pl1 pr1' }Theme-style code often looks like this instead:
export const themeSelect = defu(
{
slots: {
base: () => 'relative disabled:cursor-not-allowed disabled:(opacity-75)',
},
},
{},
)eslint --fix does not reorder those classes.
Two AST gaps:
- Call initializer. If a matching variable is assigned
defu(...)(or any helper that is not inunoFunctions),VariableDeclaratordoes not walk the call arguments. - Arrow / function slot values. Object walking only looks at string literals and nested objects, so
base: () => '...'andbase: () => { return '...' }are skipped.
Configuring unoFunctions: ['defu'] is not enough on its own, because of (2). Configuring unoVariables: ['^theme'] is not enough on its own, because of (1) and (2).
Reproduction
// eslint.config.js
export default [
{
plugins: { unocss },
rules: {
'unocss/order': ['warn', {
unoVariables: ['^theme'],
// also reproduces with: unoFunctions: ['defu']
}],
},
},
]export const themeSelect = defu(
{
slots: {
base: () => 'mr-1 ml-1',
},
},
{},
)Expected after --fix:
export const themeSelect = defu(
{
slots: {
base: () => 'ml-1 mr-1',
},
},
{},
)Actual: no warning and no fix.
Same skip for a block body:
base: () => { return 'mr-1 ml-1' }Without defu and without the arrow function, a plain matching object is fixed:
const buttonClassNames = { default: 'pr1 pl1' }System Info
@unocss/eslint-plugin66.10.0- Class strings live in theme objects merged with
defu, with slot values as() => '...'
Validations
- Read the Contributing Guidelines.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Source: unocss/unocss