~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

The console, the harness and the docs site are formatted by oxfmt

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:web/format

What changes

A formatter for the JavaScript side. oxfmt 0.76 formats web/, harness/ and docs-site/ (Svelte, TypeScript, JavaScript, CSS, JSON), set in .oxfmtrc.json: two-space indents, single quotes, no trailing commas, 100 columns, .svelte files included. Everything under those three is reformatted once here, so most of the diff is mechanical.

A gate. The web check runs oxfmt --check first, and now also runs when a pull changes harness/, docs-site/ or .oxfmtrc.json. just lint checks it too.

just fmt runs cargo fmt and oxfmt together.

A Claude Code hook. .claude/settings.json runs .claude/hooks/format.mjs after each Edit or Write. It formats the file the way just fmt would (rustfmt for .rs, oxfmt for the JS side), so an agent's code is formatted before it's committed and doesn't wait on CI to find out.

Why

Rust's format was gated by cargo fmt --check, but the console had no formatter, so agents' Svelte and TypeScript drifted in style. oxfmt was chosen over Prettier and Biome. It's a fast Rust binary meant to give Prettier's output, so prettier-plugin-svelte's formatting carries over. Biome's Svelte formatting is still partial: it doesn't parse {#if} and {#each} blocks.

How it was checked

  • Layers, svelte-check (0 warnings), the console's build and just docs all pass after the reformat. node --check passes on every harness and docs-site script.
  • just look drew the home page and Lantern Hikers' page, settings and moderation (full seed, as alice) before and after the reformat. The pictures are identical byte for byte, so the reformat changes no rendering. Svelte's whitespace rules keep >Roles</button\n> the way it was written.
  • The hook was run by hand on a misformatted .svelte file and a misformatted .rs file, and formatted both.
  • The rest is left to CI: e2e and the docs site's build.

Shortcomings

  • oxfmt's Svelte support is still marked experimental. If it mishandles a file, the check fails on that file until it's fixed or added to ignorePatterns.
  • oxfmt comes from web/node_modules, so just fmt and the hook need just setup first. The hook does nothing when oxfmt isn't installed.
  • oxfmt doesn't always settle in one pass. docs-site/reference.mjs changed on a second run, a long method chain being re-broken, so just fmt may occasionally need running twice.
  • Markdown, YAML and the lexicons' JSON are left as they are.

Review

A quick look. Start at .oxfmtrc.json, .knotless/workflows/web.yml and .claude/hooks/format.mjs, and skim the reformatted files.

🤖 Generated with Claude Code

Approved

This adds oxfmt 0.76, configured in .oxfmtrc.json, for web/, harness/ and docs-site/. The web check now runs oxfmt --check first, and its path filter covers harness/**, docs-site/** and .oxfmtrc.json. just fmt and just lint are updated, and a Claude Code PostToolUse hook formats each file after Edit, MultiEdit or Write. AGENTS.md and docs/development.md are updated with it, as the repo asks.

I read the config, workflow, hook, settings, Justfile, docs and package.json changes. I did not read the roughly 110 mechanically reformatted files line by line. Your report that the rendered pages are byte-identical before and after covers the console, and the web check will catch any file oxfmt trips on.

Nothing blocks this. Two things to check on CI:

  • Generated and ignored output: oxfmt --check web … should skip web/src/lib/lexicons, .svelte-kit and node_modules. They are gitignored, and I believe oxfmt skips gitignored paths by default, but I did not confirm that. If just lint fails locally on generated files, add them to ignorePatterns.
  • web/package-lock.json: the diff shows 414 lines added there for the new dependency. Make sure oxfmt --check does not want to reformat it, which would make the check fail forever.
Approved

The only change since my last review is a reformat of docs-site/reference.mjs. The web check at the previous head failed its oxfmt --check step on exactly that one file, out of 134, and this commit fixes it. It is whitespace only, so behavior does not change. That also answers my earlier worries: the check ran on 134 files and flagged nothing generated, and package-lock.json wasn't flagged.

The checks on this head are still queued. Nothing else to change. Before merging, make sure web goes green on this commit. If oxfmt asks for another reformat, the fix is the same.

Approved

The only change since my last review is the commit "Two spaces, not tabs", which switches .oxfmtrc.json to two-space indents and reformats everything under web/, harness/ and docs-site/ to match. That is whitespace only. I did not read the reformatted files line by line.

On this head the web check passed, including its format step (oxfmt --check), and so did check, docs, lexicons and e2e. The test check was still running when I looked. So the reformat is stable, and the reference.mjs second-pass problem from the last round is gone.

Nothing to change.

  • Leftover tab wording: the first commit message still says "tabs". The PR body already says two-space.
  • test check: wait for it to finish before merging.
Approved

Carried forward: the change this pull makes at 81b1954f9d24301fcfb8295db504ca7033d52f55 is the one reviewed at 1de10bb8fa52b5b357e3a0934404f9e89618aa98, so that review stands. What is new comes from its base.

Merged as 3de226b