Skip to content

Conform the codebase to the contributing guidelines - #128

Merged
philpax merged 5 commits into
mainfrom
contributing-update
Aug 10, 2026
Merged

Conform the codebase to the contributing guidelines#128
philpax merged 5 commits into
mainfrom
contributing-update

Conversation

@philpax

@philpax philpax commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

This branch brings the workspace into conformance with the contributing guidelines imported in commit 2dbc613. It does not change the language, the emitted code shapes, or any runtime behavior. It tightens existing lint and test gates and removes panic-prone code.

The Rust workspace gains clippy restriction lints (unwrap_used, expect_used, panic, unreachable) as warnings, with each crate opting in via [lints] workspace = true. The pass removes every production panic-family site. In-memory formatting routes through infallible_write! and infallible_writeln!. LSP serialization failures propagate as error responses. Genuinely reachable panics become structured compiler errors. Provably unreachable sites carry a documented #[expect] with the invariant stated. The src/util.rs module is renamed to src/math.rs.

The test suite gains an in-memory Fs seam (build_sources and check_sources). Filesystem-touching tests route through it, or stage under target/test-artifacts where the behavior under test is the real filesystem. The suite gains the first property tests: parser round-trip, cfg-predicate evaluation, and StripLocations idempotence. The driver, which had no tests, gains smoke tests for its build and check decisions.

The viewer enables eslint-plugin-better-tailwindcss with the correctness rules at error severity, and promotes the react-hooks rules to error. All className template-fragment interpolations become cn() calls (clsx plus tailwind-merge). All interface declarations become type aliases. Non-null assertions and unchecked casts are removed. Untrusted JSON passes through a zod schema before entering typed state, with vitest unit tests at the boundary. ItemView and Sidebar split into cohesive files under the line threshold. The types package joins the tsc -b graph, and typecheck, format:check, and test scripts are added.

Generated code in codegen_tests/output/rust is exempt from the restriction lints at the crate boundary, through a per-crate allow with the rationale stated in the crate's Cargo.toml. The JSON wire round-trip property test gap is deliberate: a versioned, corpus-covered wire format does not justify a second oracle implementation. The gap is recorded in the JSON backend docs.

Two constraints shape the viewer lint config. Prettier owns line wrapping, so the Tailwind line-wrapping rule is disabled; the correctness rules stay at error. The CodeBlock language class is dynamic by its nature and carries a documented exemption.

Verification: python test.py passes, including clippy with -D warnings for both feature configurations, the full test suite, the codegen corpus, fmt, cargo doc, and the viewer unit tests. Viewer lint, typecheck, format:check, build, and vitest all pass. Review by nat-code-reviewer found no critical or major findings.

Rebuild CONTRIBUTING.md on the philpax/contributing-templates baseline:
a new opening, a sync marker pinned to upstream commit 57e7c55, and the
five applicable templates (general, rust, typescript, react, tailwind)
appended verbatim.

Port the existing project-specific sections (backends, file-size limits,
building emitted C++ on Linux, the language-change surface checklist,
tests, editor tooling) into the new file without dropping content.

Add AGENTS.md as a symlink to CONTRIBUTING.md so both agent entry points
read the guide. CLAUDE.md already includes it via @CONTRIBUTING.md.
@philpax
philpax force-pushed the contributing-update branch from bb527a8 to dfbcb79 Compare August 10, 2026 11:59
Enable the clippy restriction lints (unwrap_used, expect_used, panic,
unreachable) as warnings with per-crate opt-in, and remove every
production panic-family site: in-memory writes route through
infallible_write!/infallible_writeln!, LSP serialization failures push
up as error responses, and genuinely-reachable panics become structured
errors (function body, unresolved types, stalled resolution). Provably
unreachable ICEs carry a documented #[expect] with the proof.

Rename src/util.rs to src/math.rs. Add an in-memory Fs seam
(build_sources/check_sources) and route the filesystem-touching tests
through it, staging the inherently-filesystem ones under
target/test-artifacts. Add the first property tests (parser round-trip,
cfg evaluation, StripLocations idempotence) and driver smoke tests.
Emitted code in codegen_tests/output/rust is exempted at the crate
boundary per the generated-code policy.
Wire eslint-plugin-better-tailwindcss with the correctness rules at
error (line wrapping stays with prettier), and promote the react-hooks
rules to error after restructuring every set-state-in-effect site.
Convert all className template-fragment interpolations to the cn()
helper (clsx + tailwind-merge), all interface declarations to type, and
remove non-null assertions and unchecked casts.

Add a zod schema mirroring the JsonDocumentation wire shape and route
every untrusted JSON input through the parseJsonDocumentation boundary
helper, with vitest unit tests. Split ItemView and Sidebar into
cohesive sub-files under the line threshold. Add typecheck,
format:check, and test scripts, and a types/tsconfig.json so the
generated json.ts joins the tsc -b graph.
Property round-trip tests over the full JsonDocumentation shape are
deliberately not implemented: the schema is versioned and the codegen
corpus round-trips it end to end, so a second oracle implementation of
the schema is disproportionate. Record the gap in the JSON backend
docs.
test.py lints the viewer but does not run its unit tests. Add npm test
(vitest) after the lint step so the JSON boundary validator is covered
by CI, not only by local runs.
@philpax
philpax force-pushed the contributing-update branch from dfbcb79 to 57825a5 Compare August 10, 2026 13:16
@philpax
philpax merged commit 39db8a9 into main Aug 10, 2026
4 checks passed
@philpax
philpax deleted the contributing-update branch August 10, 2026 13:23
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