Files
fete/.claude/hooks/frontend-check.sh
nitrix fd9175925e
All checks were successful
CI / backend-test (push) Successful in 57s
CI / frontend-test (push) Successful in 21s
CI / frontend-e2e (push) Successful in 52s
CI / build-and-publish (push) Has been skipped
Use vue-tsc --build in frontend hook to match CI
The hook used --noEmit which is less strict than CI's --build,
causing type errors to slip through.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 22:54:41 +01:00

38 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Read hook input from stdin (JSON with tool_input.file_path)
INPUT=$(cat)
FILE_PATH=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('tool_input',{}).get('file_path',''))" 2>/dev/null || echo "")
# Only run for TS/Vue files under frontend/
case "$FILE_PATH" in
*/frontend/src/*.ts|*/frontend/src/*.vue|frontend/src/*.ts|frontend/src/*.vue) ;;
*) exit 0 ;;
esac
cd "$CLAUDE_PROJECT_DIR/frontend"
ERRORS=""
# Type-check
if OUTPUT=$(npm run type-check 2>&1); then
:
else
ERRORS+="Type-check failed:\n$OUTPUT\n\n"
fi
# Lint (without --fix — agent must self-correct)
if OUTPUT=$(npx oxlint . 2>&1 && npx eslint . --cache 2>&1); then
:
else
ERRORS+="Lint failed:\n$OUTPUT\n\n"
fi
if [[ -n "$ERRORS" ]]; then
ESCAPED=$(printf '%s' "$ERRORS" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))")
echo "{\"hookSpecificOutput\":{\"hookEventName\":\"PostToolUse\",\"additionalContext\":$ESCAPED}}"
else
echo '{"hookSpecificOutput":{"hookEventName":"PostToolUse","additionalContext":"✓ Frontend type-check + lint passed."}}'
fi