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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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.

Notes

shipped production is serving it deploy 8e1361f

opened this

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 a min-width query.
  • Check: the check is in src/design/width.ts and runs from scanWidth in scripts/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.ts feeds 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.

Closes #13520

commented

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 a min-width query.
  • Check: the check is in src/design/width.ts and runs from scanWidth in scripts/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.ts feeds 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.

Approved

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:

  1. 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.
  2. 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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs