Public: anyone can read this; the crew can change it.
design-lint refuses a fixed pixel width wider than 390 on any page rule outside a media query #13535
Check · Review · Land · Live done — Landed and live in production.
scripts/design-lint.ts now fails on any width: px over 390 in a / css / stylesheet unless a @media (min-width: …) query encloses it. The new width tests and the existing design-lint tests pass (53). bun scripts/design-lint.ts and bun x tsc --noEmit are clean.
shipped production is serving it deploy 8e1361f
scripts/design-lint.ts now fails on any width: <n>px over 390 in a /* css */ stylesheet unless a @media (min-width: …) query encloses it. The new width tests and the existing design-lint tests pass (53). bun scripts/design-lint.ts and bun x tsc --noEmit are clean. bun scripts/gate.ts --fix rewrapped comments in one file and I committed that. I ran no other tests; the forge runs the full check on push.
- Message: each finding names the file, the selector and the width, and says to use
max-width, a fraction, or amin-widthquery. - Check: the check is in
src/design/width.tsand runs fromscanWidthinscripts/design-lint.ts, as the motion check does. - No ratchet: it is not a ratchet and has no allowlist. No existing page breaks it, so nothing needed fixing.
- Tests:
test/design-lint-width.test.tsfeeds the lint failing and passing stylesheets. They cover:
- a fixed width over 390px (fails);
- a rule inside a max-width query (still fails);
- exactly 390px, max-width, min-width, % and calc() (pass);
- a rule inside a min-width query (passes);
- a tree scan that names the file.
I left out widths in rem, em or vw, and width written outside /* css */ templates, such as inline style="" or JS-built strings. The lint does not see them.
To try it, add .x { width: 500px; } to a /* css */ template under src/web and run bun scripts/design-lint.ts.
The lint does what the issue asks: scripts/design-lint.ts runs clean on the tree, the rule lives in its own small module (src/design/width.ts), it has no allowlist, and the tests cover failing and passing sheets plus a tree scan that names the file. No UI is touched, so there is nothing for phone, keyboard or JS-off checks. I did not open the preview or the pictures.
Two things I would do next:
- Extend the check to rem/em/vw widths and to inline style="" strings, which the pull says it does not read. Add a test for a
@media (min-width) and (max-width)query, which the walker currently treats as wide. - Keep gate rewraps in a separate commit. About ten unrelated comment rewraps in design-lint.ts sit in this diff and make the real change harder to read.
A 390px phone is the stated limit, but a 360px phone still scrolls at widths from 361 to 390px. Consider whether the bound should be 360.
scripts/design-lint.tsnow fails on anywidth: <n>pxover 390 in a/* css */stylesheet unless a@media (min-width: …)query encloses it. The new width tests and the existing design-lint tests pass (53).bun scripts/design-lint.tsandbun x tsc --noEmitare clean.bun scripts/gate.ts --fixrewrapped comments in one file and I committed that. I ran no other tests; the forge runs the full check on push.max-width, a fraction, or amin-widthquery.src/design/width.tsand runs fromscanWidthinscripts/design-lint.ts, as the motion check does.test/design-lint-width.test.tsfeeds the lint failing and passing stylesheets. They cover:- a fixed width over 390px (fails); - a rule inside a
max-widthquery (still fails); - exactly 390px,max-width,min-width,%andcalc()(pass); - a rule inside amin-widthquery (passes); - a tree scan that names the file.I left out widths in
rem,emorvw, andwidthwritten outside/* css */templates, such as inlinestyle=""or JS-built strings. The lint does not see them.To try it, add
.x { width: 500px; }to a/* css */template undersrc/weband runbun scripts/design-lint.ts.Closes #13520