chore(hooks): run typecheck in pre-commit, drop deprecated husky bootstrap - #521
Conversation
…ootstrap - the husky v9 bootstrap lines (#!/usr/bin/env sh + husky.sh sourcing) print a deprecation warning on every commit and will hard-fail in husky v10 - pre-commit only ran lint-staged (eslint), so type errors reached CI before anyone noticed; tsc --noEmit takes ~5s here, cheap enough to gate commits https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
📝 WalkthroughWalkthroughpre-commit hook adds explicit typecheck after lint-staged and removes the Husky shell wrapper initialization. the change simplifies the hook script and ensures TypeScript validation runs before commit. ChangesPre-commit hook typecheck
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes note: this is a minimal change to the git hook, but several edge cases matter: (1) ensure 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review follow-up: plain sh runs sequential lines unconditionally and exits with the last command's status, so a lint-staged failure followed by a clean typecheck would let the commit through. Chain with && so the first failure short-circuits. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.husky/pre-commit:
- Around line 1-2: Add a regression guard that asserts the .husky/pre-commit
hook preserves fail-fast behavior when multiple commands are present: implement
a CI check (e.g., a lightweight script run in CI) that reads .husky/pre-commit
and fails if the file contains multiple commands like "npx lint-staged" and "npm
run typecheck" but does not include either "&&" or "set -e"; update CI config to
run this check (name it e.g. husky-precommit-guard) so future edits that drop
the "&&" or "set -e" will cause the pipeline to fail.
- Around line 1-2: Make the pre-commit hook fail-fast: update the
.husky/pre-commit file to start with a POSIX shebang (#!/usr/bin/env sh), ensure
the file is executable (chmod +x), and make the two commands run atomically by
either adding "set -e" at top or joining them with "&&" (e.g., npx lint-staged
&& npm run typecheck) so a failure stops the commit; then add a regression test
(e.g., a new test named assertPreCommitHookIsFailFast) that reads the hook and
asserts it contains either "set -e" or "&&" to prevent future drift.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 6027e6c9-152b-4d97-8f76-31d770350781
📒 Files selected for processing (1)
.husky/pre-commit
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Greptile Review
Review follow-up: lock the hook contract with a small regression test — multi-line hooks must set -e, single-line hooks must not chain with ';', and the deprecated husky v9 bootstrap must not return. https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
…audit Snapshot audit against v2.3.0-beta.1 (HEAD 98d9819) covering architecture, security, correctness/concurrency, testing/CI, packaging, and docs/DX: - verified findings table (4 HIGH, 13 MEDIUM, 5 LOW) with file:line evidence - index of the five companion fix PRs (ndycode#517-ndycode#521) - prioritized refactor roadmap with concrete seams for codex-manager.ts, fetch-helpers.ts, runtime-rotation-proxy.ts, retry consolidation, error-contract adoption, CI consolidation, and packaging trims - rejected-findings section recording disproven automated claims so future audits do not re-litigate them https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Summary
Part 5 of the repo-wide audit (#517, #518, #519, #520). Two small dev-tooling fixes to
.husky/pre-commit:Remove the deprecated husky v9 bootstrap lines (
#!/bin/sh+. "$(dirname "$0")/_/husky.sh"). Husky prints a deprecation warning on every commit today and these lines will hard-fail in husky v10.Add
npm run typecheckto the pre-commit gate. The hook previously ran onlylint-staged(eslint), while CI requires typecheck — so type errors silently reached the PR stage.tsc --noEmitcompletes in ~5s on this codebase, cheap enough to gate every commit. (--no-verifyremains available for emergencies, as before.)Testing
The hook exercised itself on this branch's own commit: lint-staged + typecheck both ran, no deprecation warning, commit succeeded.
https://claude.ai/code/session_01XNtnkLbBiXZxfQQYLMpucB
Generated by Claude Code
note: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
drops the deprecated husky v9 bootstrap shim and adds
npm run typecheck(tsc --noEmit) to the pre-commit gate, chained with&&so a lint failure correctly blocks the commit. a new vitest contract test locks in the fail-fast invariant and the removal of the deprecated bootstrap..husky/pre-commit: single-linenpx lint-staged && npm run typecheckreplaces the multi-line husky-v9 form;&&chaining propagates non-zero exit codes to git as required.test/precommit-hook.test.ts: contract test verifies no;chaining, no deprecatedhusky.shshim, and that multi-line hooks carryset -e— adds regression coverage for both changes in this PR.Confidence Score: 5/5
safe to merge — the hook change is correct and the test adds meaningful regression coverage
the two-file change is narrowly scoped: the hook now correctly uses
&&so lint failures block the commit, the deprecated bootstrap is gone, and the new contract test locks both invariants in. no runtime code paths, no token handling, no windows filesystem operations are touched.no files require special attention
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[git commit] --> B[pre-commit hook] B --> C[npx lint-staged] C -->|exit non-zero| D[hook exits non-zero\ngit blocks commit] C -->|exit 0| E[npm run typecheck\ntsc --noEmit] E -->|exit non-zero| D E -->|exit 0| F[hook exits 0\ngit proceeds with commit]Prompt To Fix All With AI
Reviews (3): Last reviewed commit: "test(hooks): guard pre-commit fail-fast ..." | Re-trigger Greptile