From b68d84367855413bdb631015a70506c54ed5f13c Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 19 Nov 2026 22:11:18 -0800 Subject: [PATCH 1/2] improvement(hooks): check only changed files and affected workspaces before push --- .husky/pre-push | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.husky/pre-push b/.husky/pre-push index dd0fdf09e2d..f83c90f4533 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,5 +1,24 @@ #!/bin/sh +# Checks only what this push changes against its merge base with origin/staging (the PR base): +# biome format + lint on the changed files, then type-check for the affected workspaces. +# CI runs the full lint, type-check and audit gate on every PR, so it stays the backstop. set -e -bun run lint:check -bun run type-check +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" + bun run lint:check + bun run type-check + exit 0 +fi + +changed=$(git diff --name-only --diff-filter=ACMR "$base" HEAD) +[ -z "$changed" ] && exit 0 + +# Word-splitting the list is deliberate; no path biome checks contains a space. +bunx biome check --no-errors-on-unmatched --files-ignore-unknown=true $changed + +if printf '%s\n' "$changed" | grep -qE '^scripts/'; then + bun run type-check:scripts:esm +fi +TURBO_SCM_BASE="$base" bunx turbo run type-check --affected --output-logs=errors-only From c135b9f4930dcbeaa5f9c08131c4642965838847 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 19 Nov 2026 22:19:12 -0800 Subject: [PATCH 2/2] fix(hooks): check the pushed commit and keep deletions in the type-check decision --- .husky/pre-push | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.husky/pre-push b/.husky/pre-push index f83c90f4533..8d6d1f415fe 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -4,6 +4,21 @@ # CI runs the full lint, type-check and audit gate on every PR, so it stays the backstop. set -e +# git passes one " " line per pushed ref. +zero=0000000000000000000000000000000000000000 +head=$(git rev-parse HEAD) +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 + pushes_head=true +done +[ "$pushes_head" = true ] || exit 0 + 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" @@ -12,11 +27,16 @@ if [ -z "$base" ]; then exit 0 fi -changed=$(git diff --name-only --diff-filter=ACMR "$base" HEAD) +# Deletions still decide the type-check (an import of a deleted module breaks); biome only +# reads files that exist. +changed=$(git diff --name-only "$base" HEAD) [ -z "$changed" ] && exit 0 +existing=$(git diff --name-only --diff-filter=ACMR "$base" HEAD) -# Word-splitting the list is deliberate; no path biome checks contains a space. -bunx biome check --no-errors-on-unmatched --files-ignore-unknown=true $changed +if [ -n "$existing" ]; then + # Word-splitting the list is deliberate; no path biome checks contains a space. + bunx biome check --no-errors-on-unmatched --files-ignore-unknown=true $existing +fi if printf '%s\n' "$changed" | grep -qE '^scripts/'; then bun run type-check:scripts:esm