Files
Brandon ThomasandClaude Opus 5.5 e621098b09 Port the UI to TypeScript and ban raw JavaScript
All UI code moves to strict TypeScript in ui/src/, compiled by tsc (no
bundler) to ui/build/, which index.html loads; the app's build.rs runs the
compile so every cargo build ships the current UI. Sources import each
other as ./x.ts so node --test runs them directly, and the data types
mirror crates/craft-core/src/model.rs.

app.ts now exports start(api) and main.ts wires it to Tauri or the browser
preview, so the UI can be tested in happy-dom against a fake host: sorting,
dragging, clicks, the window picker, status, the urgent view and shortcuts.
Sort toggling and drop placement move into model.ts with unit tests. The
inline error-reporting script becomes report.ts.

CLAUDE.md records the rule: no .js/.mjs/.cjs/.jsx files, inline scripts,
inline handlers or javascript: URLs. ui/src/repo.test.ts enforces it in
make test; make check adds a tsc type-check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 23:56:15 -04:00

1.3 KiB

Craft Repo Status App

Rules

  • No raw JavaScript, ever. All frontend code is TypeScript in ui/src/. Never add .js, .mjs, .cjs or .jsx files, inline <script> code, inline on…= handlers or javascript: URLs, and never commit ui/build/ (tsc's output). Scripts and tooling go in Rust, shell or Makefile targets, not JS. ui/src/repo.test.ts enforces this in make test.
  • New UI code gets tests: pure logic in ui/src/model.ts with model.test.ts, DOM behavior in app.test.ts (happy-dom, fake host API).

TypeScript setup

  • tsc only, no bundler. Sources import each other with .ts extensions; node --test runs them directly (type stripping) and tsc rewrites the imports to .js when emitting. Use only erasable syntax (erasableSyntaxOnly): no enums, namespaces or parameter properties.
  • tsconfig.json type-checks everything, tests included; tsconfig.build.json emits the browser code to ui/build/. crates/craft-status-app/build.rs runs npm run build before Tauri embeds ui/.
  • ui/src/model.ts's data types mirror crates/craft-core/src/model.rs: change both together.

Commands

  • make test: Rust tests + npm test (UI tests)
  • make check: clippy, rustfmt, npm run typecheck
  • make preview: the UI in a browser against ui/dev-snapshot.json