`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:
// 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:
const result = cond ? successMsg:(errorMsg)
// ^^^^^^^^^^^^^^^^^^^^^
// | Treated as variant group
// Or a more concrete example:
time=time?time:(new Date).getTime()Reproduction
System Info
No response
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