Repository navigation
v1.17.0
Two opt-ins from a design system with its own px tokens: prefer-scale-token's sameUnit, and the
lookupTablePatterns setting for class lookup tables. With the same config, classes in an object or
array indexed where it's used are now checked, and prefer-scale-token finds theme tokens whose
name has a dash.
Before you upgrade
- Reports that can appear with the same config: any rule on the classes of a literal indexed in
place ({ ok: "…", error: "…" }[status],["…", "…"][i]) and on the left side of??/||;
prefer-scale-tokenon values equal to a theme token whose name has a dash (p-[16px]→
p-brand-md), and that token in place of the scale step it used to suggest. - Reports that go away:
prefer-scale-tokenno longer matches anemvalue against aremor
pxtoken (p-[1em]→p-4). - Messages that change:
no-arbitrary-value's "Closest in your theme" for a negative value
names the negative utility. On shadcn/ui'sapps/v4that is 8 messages; nothing else moves.
Features
prefer-scale-tokentakessameUnit(#238). WithsameUnit: true, a value only matches a
token or scale step written in its own unit, sow-[512px]is no longer suggested asw-lg
(--container-lg: 32rem): the two differ once the root font size changes. Off by default.lookupTablePatternssetting: the class values of a lookup table (#237). A variable whose
name matches one of its regexes and whose initializer is an object literal has its values read as
classes, nested tables included, throughas constandsatisfies:
const TONE_CLASSES = { warning: "text-amber-700" }.variablePatternsreads an object's keys,
so it can't check these. It is what eslint-plugin-better-tailwindcss'svariableselector with an
objectValuesmatch does. Empty by default.
Bug fixes
- Classes in a literal indexed where it's used are checked (#239, #241).
cn("size-2", { ok: "bg-green-500", error: "bg-red-50O" }[status])and
className={{ … }[status]}hid their classes from every rule; the object's values are read now,
never its keys, throughas const, and so are an indexed array's elements. The left side of??
and||is read too ({ … }[status] ?? "bg-gray-500");&&still reads only its right. prefer-scale-tokenmatches theme tokens whose name contains a dash (#236). The precompute
filed a token class under the class cut at its last dash, sop-brand-md(reading
--spacing-brand-md) sat underp-brandandp-[16px]never matched it; it now sits underp.
The scale steps that read the bare--spacing(mt-1) are no longer filed as named tokens
either, so a project token of the same value wins over them, as the rule documents.
no-arbitrary-value's nearest-token message reads the same table and names these tokens too.prefer-scale-tokenno longer equatesemwithremorpx(#238).p-[1em]was reported
asp-4, but anemfollows the element's font size, so the two are equal only in 16px text. An
emvalue now only matches anemtoken.no-arbitrary-valuenames a negative utility for a negative value (#236).bottom-[-5px]
said "Closest in your theme: bottom-1 (4px)", a class that moves the other way; it now says
-bottom-1.5 (-6px) or -bottom-1 (-4px), and nothing for a prefix with no negative form.
Dependencies
- Development only (#240): oxlint 1.89, oxfmt 0.74, vitest 5.0.5, pnpm 12.15.0; tsdown stays at
0.23.1 (rolldown/tsdown#1106). The runtime dependencies are unchanged.