From ea38d3cb13350baa6dcf30f3b37c5841b1327021 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sat, 21 Nov 2026 15:41:06 -0800 Subject: [PATCH 1/2] fix(hooks): skip local lint and type-check when the working tree differs from the pushed commit --- .husky/pre-push | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.husky/pre-push b/.husky/pre-push index 79f15b82eda..f851eae3d38 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -29,7 +29,6 @@ pushes_head=false while read -r _local_ref local_sha _remote_ref _remote_sha; do [ "$local_sha" = "$zero" ] && continue if [ "$local_sha" != "$head" ]; then - # These checks read the working tree, which holds HEAD, not this commit. echo "pre-push: $local_sha is not the checked-out commit; leaving it to CI" continue fi @@ -37,6 +36,15 @@ while read -r _local_ref local_sha _remote_ref _remote_sha; do done [ "$pushes_head" = true ] || exit 0 +# Lint and type-check read the working tree, so they judge the pushed commit only when nothing they +# read differs from it: no uncommitted change to a tracked file and no untracked TypeScript the +# type-check would compile. Otherwise they could fail a sound commit or pass a broken one. +if ! git diff --quiet HEAD || + [ -n "$(git ls-files --others --exclude-standard -- '*.ts' '*.tsx' '*.mts' '*.cts')" ]; then + echo "pre-push: uncommitted changes or untracked TypeScript; leaving lint, type-check and generated artifacts to CI" + exit 0 +fi + base=$(git merge-base HEAD origin/staging 2>/dev/null || true) if [ -z "$base" ]; then echo "pre-push: origin/staging not found, running the full lint and type-check" From fb548d4bebf00c8741cc124e57682e805c43efa6 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sat, 21 Nov 2026 15:51:50 -0800 Subject: [PATCH 2/2] fix(hooks): treat untracked JavaScript and JSON as type-check inputs too --- .husky/pre-push | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.husky/pre-push b/.husky/pre-push index f851eae3d38..cb2635679d2 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -37,11 +37,12 @@ done [ "$pushes_head" = true ] || exit 0 # Lint and type-check read the working tree, so they judge the pushed commit only when nothing they -# read differs from it: no uncommitted change to a tracked file and no untracked TypeScript the -# type-check would compile. Otherwise they could fail a sound commit or pass a broken one. -if ! git diff --quiet HEAD || - [ -n "$(git ls-files --others --exclude-standard -- '*.ts' '*.tsx' '*.mts' '*.cts')" ]; then - echo "pre-push: uncommitted changes or untracked TypeScript; leaving lint, type-check and generated artifacts to CI" +# read differs from it: no uncommitted change to a tracked file and no untracked file the type-check +# could read (TypeScript, JavaScript under `allowJs`, JSON under `resolveJsonModule`). Otherwise +# they could fail a sound commit or pass a broken one. +if ! git diff --quiet HEAD || [ -n "$(git ls-files --others --exclude-standard -- \ + '*.ts' '*.tsx' '*.mts' '*.cts' '*.js' '*.jsx' '*.mjs' '*.cjs' '*.json')" ]; then + echo "pre-push: uncommitted changes or untracked source files; leaving lint, type-check and generated artifacts to CI" exit 0 fi