Skip to content

build(fmt): format Odin and C/C++ to one style — tabs, 120 columns - #504

Merged
x-ror merged 2 commits into
masterfrom
build/format
Nov 18, 2026
Merged

x-ror merged 2 commits into
masterfrom
build/format

Conversation

@x-ror

@x-ror x-ror commented Nov 18, 2026

Copy link
Copy Markdown
Owner

What changed

  • odinfmt.json: tabs (width 4), 120 columns, sorted imports. Applied to cmd/lava, pkg/jsc, pkg/runtime and pkg/std/sqlite: 62 files, mostly short calls and signatures joined onto one line and struct fields re-aligned.
  • .clang-format: the owner's C/C++ style with tabs (width 4) and 120 columns. Applied to pkg/jsc/jsc_init_windows.cpp; vendored picohttpparser opts out with its own .clang-format.
  • make fmt runs odinfmt (when ODINFMT points at it; it ships with the OLS editor extension and is not on PATH by default), then odin strip-semicolon, then clang-format.
  • CLAUDE.md §4 names the formatters and the declaration order: imports, constants, types, procedures. No formatter reorders declarations, so that part is a convention.

The same configuration Larva adopted in x-ror/larva#71.

Not formatted

100 Odin lines are still longer than 120 columns. odinfmt does not break string literals, comments or foreign declarations; they are left as they are.

Checked

  • make check (linux, windows and darwin front-ends) and make build.
  • A lava eval touching timers, microtasks, URL and require.
  • Every find in tests/mutation-manifest.json still matches exactly once, so no recorded mutation went stale.

No tests and no gates were run, on the owner's instruction for this phase. Formatting only: no behavior change intended, but 62 files changed without a test run.

🤖 Generated with Claude Code

x-ror and others added 2 commits November 18, 2026 22:50
- odinfmt.json: tabs (width 4), 120 columns, sorted imports. Applied to
  cmd/lava, pkg/jsc, pkg/runtime and pkg/std/sqlite.
- .clang-format: the owner's C/C++ style with tabs (width 4) and 120 columns.
  Applied to pkg/jsc/jsc_init_windows.cpp; vendored picohttpparser opts out.
- `make fmt` runs odinfmt (when ODINFMT points at it — it ships with the OLS
  extension), strip-semicolon, then clang-format.
- CLAUDE.md §4: the formatters, and the declaration order (imports, constants,
  types, procedures), which no formatter enforces.

The same configuration Larva adopted in x-ror/larva#71.

Formatting only. Checked: `make check` (all three targets), `make build`, a
`lava eval` touching timers, microtasks, URL and require; every
mutation-manifest `find` still matches exactly once. No tests run: paused for
this phase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The owner's rules, now in CLAUDE.md §4 and applied by `make fmt`:

- `if` always has braces, on their own lines: no `if x do y`, no `if x {y}`.
  odinfmt's convert_do (odinfmt.json) and clang-format's InsertBraces
  (.clang-format) add the braces; scripts/fmt-if.mjs spreads the one-line
  blocks odinfmt leaves behind.
- A blank line before and after every `if` statement, unless it opens or
  closes a block or a case; a comment directly above belongs to the if. No
  formatter does this, so scripts/fmt-if.mjs does. It tracks strings, comments
  and Odin's multi-line raw strings, so embedded JS in the tests is untouched.

Applied to cmd/lava, pkg/jsc, pkg/runtime and pkg/std/sqlite; `make fmt` is
stable on the result (a second run changes nothing). Nine mutation-manifest
entries pointed at `if … do` lines and were retargeted to the same code in its
new form; every find matches exactly once.

Formatting only. Checked: `make check` (all three targets), `make build`, and a
`lava eval` touching nextTick, microtasks, timers, URL, Buffer and require. No
tests run: paused for this phase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@x-ror

x-ror commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Pushed 854ca75: two more of the owner's rules, in CLAUDE.md §4 and applied by make fmt.

  • if always has braces, on their own lines. No if x do y, no if x {y}. odinfmt convert_do and clang-format InsertBraces add the braces; scripts/fmt-if.mjs spreads the one-line blocks odinfmt leaves.
  • A blank line before and after every if, unless it opens or closes a block or a case; a comment directly above belongs to the if. No formatter does this, so scripts/fmt-if.mjs does. It tracks strings, comments and Odin's multi-line raw strings, so the embedded JS in tests is untouched.

The diff is large (about 6,000 added lines), almost all of it braces and blank lines. make fmt is stable on the result: a second run changes nothing.

Nine mutation-manifest entries pointed at if … do lines. They are retargeted to the same code in its new form, and every find matches exactly once.

Checked: make check (all three targets), make build, and a lava eval touching nextTick, microtasks, timers, URL, Buffer and require. No tests run.

@x-ror
x-ror merged commit f9455bf into master Nov 18, 2026
5 of 6 checks passed
@x-ror
x-ror deleted the build/format branch November 18, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant