Skip to content

fix(webkit): catch malformed token shorthands, and restore the popover header min-height - #887

Open
gabriel-lisboa-azion wants to merge 2 commits into
mainfrom
fix/dead-token-shorthand
Open

fix(webkit): catch malformed token shorthands, and restore the popover header min-height#887
gabriel-lisboa-azion wants to merge 2 commits into
mainfrom
fix/dead-token-shorthand

Conversation

@gabriel-lisboa-azion

Copy link
Copy Markdown
Collaborator

Summary

  • A malformed token shorthand never reaches the element and no gate reported it: a stray space inside the parens makes Tailwind emit nothing, an inverted [--(token)] emits an invalid value the browser discards. dead-token-shorthand joins the token-check engine, so it blocks write-time and in the repo-wide CI ratchet.
  • Landed with zero grandfathered violations, and immediately caught a live one: popover-header's min-height — meant to match the absolute close button — has been inert since the v4 canonicalization sweep. It now names min-h-7, mirroring the button's own size-7; the token it previously pointed at is 16px, not the 1.75rem it is matching, so the syntax and the value were wrong.
  • Same defect class shipped chip's filled kind fully transparent in both themes, with baselines generated from the broken render encoding it as correct — which is why this needs a mechanical gate rather than review.

How to test

  1. cd packages/webkit && node --test test/eslint-plugin/token-checks.test.mjs → 14 pass, including the fires/silent pairs for the new check (ordinary subtraction and var(--a, var(--b)) must stay silent).
  2. cd packages/webkit && node scripts/check-authoring.mjs0 new. Then introduce bg-(--bg-surface ) in any component under src/components/ and re-run → it blocks with the new message.
  3. pnpm storybook:dev, open Components/Overlay/Popover → Default and inspect the header's inner div: computed min-height is 28px (it was auto). With a title and no description the title top-aligns with the close button instead of centering.

Notes

  • The scan runs over raw file text, so a comment that quotes a malformed class also trips the check — describe such a class rather than spelling it out. Noted in the check's own comment.
  • Visual baselines for the popover stories are regenerated in this PR (the restored min-height changes the header's box).
  • No new dependency. No public API change. No related issue.

…r header min-height

A malformed token shorthand never reaches the element, and nothing anywhere
reported it — not lint, not vue-tsc, not the build. Two spellings, failing at
two different stages:

- a stray space inside the parens terminates the Tailwind candidate, so it
  emits nothing at all;
- an inverted bracket/paren form does emit a rule, carrying an invalid value
  that the browser discards at parse time.

The class reads as correct forever either way. chip's `filled` kind was
transparent in both themes from the day it shipped because of the first, and
its visual baselines were generated from the broken render — so they encoded
the bug as correct and no gate ever failed.

So `dead-token-shorthand` joins the token-check engine, which makes it blocking
on both surfaces at once (write-time hook + repo-wide CI ratchet). It landed
with zero grandfathered violations, and immediately found a live one:
popover-header's min-height, meant to match the absolute close button, has been
inert since the v4 canonicalization sweep. It now names `min-h-7`, mirroring
the button's own `size-7` — the token it previously pointed at is 16px, not the
1.75rem it is matching, so both the syntax and the value were wrong.

The regex anchors on a `--` inside the parens via lookahead, which is what
keeps it off ordinary subtraction (`x -(y + z)`) and off a nested var with a
fallback (`var(--a, var(--b))`, where the character before the paren is not a
hyphen). Pinned both ways in the token-checks test.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant