Public: anyone can read this; the crew can change it.

Drift gate: a page may not define a one-off class for what a ui.ts part already does (warn with a count) #5893

Parked opened this
Closed without merging

I added a drift gate. It currently reports drift: 1 one-off classes duplicate a part, for .rs-list at src/web/pages/conflicts.ts:133. The new tests and the existing design-lint tests pass.

Notes

opened this

I added a drift gate. It currently reports drift: 1 one-off classes duplicate a part, for .rs-list at src/web/pages/conflicts.ts:133. The new tests and the existing design-lint tests pass. I did not run the full check, and bun x tsc --noEmit failed here with "Cannot find type definition file for 'bun'", so I have no type-check result. The gate is a warning only: it exits 0.

  • What counts: scripts/design-drift.ts reads the CSS templates in src/web page modules. A class counts when one of its words names a part: list or row, btn or button, empty, or picker. Examples are .todo-list, .save-btn and .nothing-here-empty. Each class counts once per file, at its first rule. It prints one file:line .class → use <part> line for each.
  • What it skips: the shared stylesheet (src/web/style/) and ui.ts, where the parts live. A class the shared stylesheet already defines is not a copy.
  • What it reads: /* css */ templates, plus const CSS = \…\` blocks, because pages like conflicts.ts use that form and design-lint` doesn't see them.
  • The count: bun scripts/design-drift.ts --update writes it to the drift key of docs/design/baseline.json. design-lint.ts --update now keeps that key instead of dropping it.
  • In the check: forge.json runs the script in both fast and run.
  • Tests: test/design-drift.test.ts has three. A fixture page with a home-made list class is counted once at its first rule. A clean page counts zero. The tree's count equals baseline.json.

Left out: the word-based match is a heuristic, so a duplicate with an unrelated name isn't seen. Making the gate fail, and bringing the count down area by area, are follow-ups.

Closes #5881

4 earlier comments
commented

I added a drift gate. It currently reports drift: 1 one-off classes duplicate a part, for .rs-list at src/web/pages/conflicts.ts:133. The new tests and the existing design-lint tests pass. I did not run the full check, and bun x tsc --noEmit failed here with "Cannot find type definition file for 'bun'", so I have no type-check result. The gate is a warning only: it exits 0.

  • What counts: scripts/design-drift.ts reads the CSS templates in src/web page modules. A class counts when one of its words names a part: list or row, btn or button, empty, or picker. Examples are .todo-list, .save-btn and .nothing-here-empty. Each class counts once per file, at its first rule. It prints one file:line .class → use <part> line for each.
  • What it skips: the shared stylesheet (src/web/style/) and ui.ts, where the parts live. A class the shared stylesheet already defines is not a copy.
  • What it reads: /* css */ templates, plus const CSS = \…\` blocks, because pages like conflicts.ts use that form and design-lint` doesn't see them.
  • The count: bun scripts/design-drift.ts --update writes it to the drift key of docs/design/baseline.json. design-lint.ts --update now keeps that key instead of dropping it.
  • In the check: forge.json runs the script in both fast and run.
  • Tests: test/design-drift.test.ts has three. A fixture page with a home-made list class is counted once at its first rule. A clean page counts zero. The tree's count equals baseline.json.

Left out: the word-based match is a heuristic, so a duplicate with an unrelated name isn't seen. Making the gate fail, and bringing the count down area by area, are follow-ups.

commented

The gate now warns instead of failing. I changed the drift test, the script's output and the baseline handling in design-lint --update. The drift and design-lint tests pass; I did not run the full check.

  • Test: test/design-drift.test.ts now asserts the tree's count is at most baseline.drift. Adding a home-made class still fails it; removing one needs no baseline update, so concurrent pulls no longer collide on baseline.json.
  • Warning: scripts/design-drift.ts prints warning: N more than the baseline of M when the count is above the baseline, and still exits 0.
  • Plural: the report reads "1 one-off class duplicates a part" for one and "N one-off classes duplicate a part" otherwise. A test covers the singular.
  • Corrupt baseline: design-lint --update no longer swallows a bad baseline.json. It skips the file only when it is missing and throws on a corrupt one. design-drift.ts follows the same rule.

The count is still 1 (.rs-list at src/web/pages/conflicts.ts:133). Moving it onto ui.ts, and then making the gate fail, are the follow-ups you named; I left both out.

commented

I made no code change for this. The triage note is automatic and says the issue has no pillar, so it waits behind the Later gate. Naming a pillar is a planning decision, and I haven't changed the issue or its links. Nothing new was pushed.

The branch already has the drift gate and the changes from @juniper's review (pull #5893). The issue describes itself as a child of #5817, so that umbrella is probably the pillar to name.

commented

I merged main into this branch and pushed it. The only conflict was forge.json. The design-drift and design-lint tests pass (23 of 23). I did not re-run the full suite, because it ran past the 120 s command limit in this sandbox, and the forge's check will run it on this push.

main had added FORGE_REQUIRE_CELLS=1 to the shard-runner step, and this branch had added bun scripts/design-drift.ts to the gate. I kept both, in the fast and run check commands. The merge also touched scripts/design-lint.ts, which merged without conflict.

I pushed before running those tests, so the push went out ahead of its tests.

commented

Parked by the crew: the check stayed red through 2 automatic tries

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs