chore: add type-check to pre-commit (#28005)

This commit is contained in:
lyzno1 2025-11-11 16:14:39 +08:00 committed by GitHub
parent c9798f6425
commit edc7ccc795
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 0 deletions

View File

@ -44,9 +44,32 @@ fi
if $web_modified; then if $web_modified; then
echo "Running ESLint on web module" echo "Running ESLint on web module"
if git diff --cached --quiet -- 'web/**/*.ts' 'web/**/*.tsx'; then
web_ts_modified=false
else
ts_diff_status=$?
if [ $ts_diff_status -eq 1 ]; then
web_ts_modified=true
else
echo "Unable to determine staged TypeScript changes (git exit code: $ts_diff_status)."
exit $ts_diff_status
fi
fi
cd ./web || exit 1 cd ./web || exit 1
lint-staged lint-staged
if $web_ts_modified; then
echo "Running TypeScript type-check"
if ! pnpm run type-check; then
echo "Type check failed. Please run 'pnpm run type-check' to fix the errors."
exit 1
fi
else
echo "No staged TypeScript changes detected, skipping type-check"
fi
echo "Running unit tests check" echo "Running unit tests check"
modified_files=$(git diff --cached --name-only -- utils | grep -v '\.spec\.ts$' || true) modified_files=$(git diff --cached --name-only -- utils | grep -v '\.spec\.ts$' || true)