Repository navigation
chore: enforce formatting with lint checks and git hooks (#55) - #68
Merged
Merged
Conversation
4 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of #55 (comment 3). Formatting is now enforced, both in CI and locally. Before this,
make lint-*ran onlygo vet,cargo checkandtsc. Onmain,gofmtflagged 3 Go files,cargo fmtreported diffs, and prettier (at width 120) flagged 13 TS files.This PR does not close #55. The remaining items follow in a separate PR.
What changes
gofmt.cargo fmt, withrs/rustfmt.toml=max_width = 120.ts/.prettierrc={ "printWidth": 120 }.style:commit per language, containing formatter output only (see Verification).make lint-gofails whengofmt -llists a file, or when the file doesn't parse, and points tomake fmt-go.lint-rsaddscargo fmt --check.lint-tsaddsnpm run format:check.rustfmtcomponent, andrust-toolchain.tomlalso requests it, so a minimal local rustup works too.make fmt-go,fmt-rs,fmt-tsandfmt-all.fmt-tsand the hook callts/node_modules/.bin/prettierdirectly and refuse to run without it, so they can never format with a different prettier version. Documented in CONTRIBUTING and AGENTS.md.make hookssetscore.hooksPath=.githooks; documented in CONTRIBUTING):pre-commitchecks the formatting of staged Go, Rust and TS files, in about a second.make fmt-*command to run and--no-verifyfor skipping once.cargo fmt --check), because rustfmt followsmoddeclarations.pre-pushrunsmake lint-all.Review notes
main. A simulated default squash message givesbump=patch tag=v0.3.2. The release would contain no behaviour change.git add -pit can disagree with what is committed. Pre-push and CI are the backstop. This is documented in the hook and in CONTRIBUTING.Verification
style:commits are formatter output only. I checked out each commit's parent, re-ran the formatter, and compared the result with the commit's tree. They were identical for5768631(gofmt),694a175(cargo fmtwith the commit'srustfmt.toml) ande17231d(prettier 3.9.9).cargo fmt --checkunderrust:1.85(rustfmt 1.8.0) shows no diff. Local rustfmt is 1.9.0.make lint-<lang>fail (exit 2).a b.goandé.go;"or\;--no-verify.make test-allgives Go 108, Rust 145, and TS 162 with 1 skipped.make lint-allpasses.Type of change
Implementation(s) changed
Testing
make test-all): Go 108, Rust 145, TS 162 (1 skipped)make lint-*format gates and the git hooksChecklist