#5317·unocss

`@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:

typescript
const buttonClassNames = { default: 'pr1 pl1' }
// autofix → { default: 'pl1 pr1' }

Theme-style code often looks like this instead:

typescript
export const themeSelect = defu(
  {
    slots: {
      base: () => 'relative disabled:cursor-not-allowed disabled:(opacity-75)',
    },
  },
  {},
)

eslint --fix does not reorder those classes.

Two AST gaps:

  1. Call initializer. If a matching variable is assigned defu(...) (or any helper that is not in unoFunctions), VariableDeclarator does not walk the call arguments.
  2. Arrow / function slot values. Object walking only looks at string literals and nested objects, so base: () => '...' and base: () => { 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

javascript
// eslint.config.js
export default [
  {
    plugins: { unocss },
    rules: {
      'unocss/order': ['warn', {
        unoVariables: ['^theme'],
        // also reproduces with: unoFunctions: ['defu']
      }],
    },
  },
]
typescript
export const themeSelect = defu(
  {
    slots: {
      base: () => 'mr-1 ml-1',
    },
  },
  {},
)

Expected after --fix:

typescript
export const themeSelect = defu(
  {
    slots: {
      base: () => 'ml-1 mr-1',
    },
  },
  {},
)

Actual: no warning and no fix.

Same skip for a block body:

typescript
base: () => { return 'mr-1 ml-1' }

Without defu and without the arrow function, a plain matching object is fixed:

typescript
const buttonClassNames = { default: 'pr1 pl1' }

System Info

  • @unocss/eslint-plugin 66.10.0
  • Class strings live in theme objects merged with defu, with slot values as () => '...'

Validations