Skip to content

v1.13.0

Choose a tag to compare

@github-actions github-actions released this 23 Sep 02:00
065d498

Wrapping cva/tv/classed behind a shared design-system package — re-exporting them under your
own names — is a common monorepo pattern, but a wrapper registered in callees was extracted with
the generic cn-style walk, so the classes nested in its slots/variants config went unseen and no
rule fired. This release adds settings.tailwindcss.calleeExtractors, which maps a custom callee to
the structured extractor it follows so it gets the same deep extraction as the built-in helper —
without renaming imports at every call site
(#155, reported by @azu).

It also fixes enforce-canonical under variants: the autofix that turned bg-white/[.08] into
bg-white/8 never applied to dark:bg-white/[.08] or hover:z-[10], and arbitrary variants like
data-[open]: were never canonicalized at all
(#156, reported by @Nayeem-XTREME).

Features

  • settings.tailwindcss.calleeExtractors routes a custom callee through a known structured
    extractor.
    Map a wrapper name to tv, cva, classed, or flat (e.g.
    { "defineStyles": "tv" }) and it is extracted like the helper it wraps, across all 24 rules.
    Mapped names are auto-registered as callees (no need to list them in callees too); an
    unrecognized value is skipped rather than throwing, exclude.callees still wins, and the reserved
    names tv/cva/classed always use their built-in extractor and can't be remapped.

Bug fixes

  • enforce-canonical now rewrites arbitrary values under a variant. bg-white/[.08] →
    bg-white/8 was reported, but dark:bg-white/[.08], hover:z-[10] or sm:dark:bg-white/[.08]
    were silently left alone. The value-preserving check (#78) compared the emitted CSS after cutting
    it between the first { and the last }, which drops the selector only when it comes first; a
    variant wraps the rule in an at-rule (@media (hover: hover) { .hover\:z-\[10\]:hover { … } }),
    so the escaped class name — different by construction — stayed in the comparison and every
    variant-prefixed rewrite read as unsafe. The check now neutralizes only the class's own name and
    compares everything else, so #78's guarantee is unchanged: dark:text-[#fff] is still not
    rewritten to dark:text-white, which reads a theme variable
    (#156, reported by @Nayeem-XTREME).
  • enforce-canonical canonicalizes arbitrary variants. Tailwind rewrites data-[open]: →
    data-open:, aria-[checked=true]: → aria-checked: and min-[40rem]: → sm:, but these
    classes never reached the design system: only the utility was checked for brackets, and the
    precomputed map knows utilities, not variants. They are now asked too, under the same
    value-preserving check — a variant rewrite that changes the selector (has-[:checked]: →
    has-checked:, [&>*]: → *:) is left as written.

Documentation

  • rootFontSize no longer claims enforce-canonical rewrites p-[2px] → p-0.5. It hasn't
    since #78 (the CSS isn't byte-identical); the README and the settings page now say what the
    setting actually feeds: prefer-scale-token's px-to-scale comparison and Tailwind's
    canonicalizer.