#4388·unocss

`transformerVariantGroup` incorrectly parses minified ternary operator

Author: fozarix0Created Jan 15, 2025Updated Aug 28, 2026
Labelstransformer-variant-group

UnoCSS version

65.4.0

Describe the bug

When using @unocss/transformer-variant-group in a codebase:

typescript
// uno.config.ts

import transformerVariantGroup from '@unocss/transformer-variant-group'
import { defineConfig } from 'unocss'

export default defineConfig({
  // ...
  transformers: [
    transformerVariantGroup(),
  ],
})

Minified code (or unformatted code) that uses ternary operator, while having the : (colon) enclosed between a word, and an opening parenthesis, would cause it to be incorrectly treated as a variant group. Example:

typescript
const result = cond ? successMsg:(errorMsg)
//                    ^^^^^^^^^^^^^^^^^^^^^
//                    | Treated as variant group

// Or a more concrete example:
time=time?time:(new Date).getTime()

Reproduction

image

StackBlitz

System Info

No response

Validations