gc-wing/.githooks/pre-commit
htlee 918b80e06a chore: 팀 프로젝트 워크플로우 세팅
- pnpm → npm 전환 (워크스페이스 유지)
- .claude/ 팀 규칙(5), 스킬(4), 설정, hooks 스크립트(3) 추가
- .githooks/ commit-msg, post-checkout, pre-commit 추가
- Nexus npm 프록시 설정 (.npmrc — URL만, 인증 제외)
- .editorconfig, .prettierrc, .node-version(24) 추가
- CLAUDE.md 프로젝트 설명서 생성
- Map3D.tsx 미사용 함수 제거 (getDeckShipAngle)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-15 22:18:40 +09:00

62 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
#==============================================================================
# pre-commit hook (모노레포 React TypeScript)
# apps/web TypeScript 컴파일 + 린트 검증 — 실패 시 커밋 차단
#==============================================================================
REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
echo "pre-commit: TypeScript 타입 체크 중..."
# npm 확인
if ! command -v npx &>/dev/null; then
echo "경고: npx가 설치되지 않았습니다. 검증을 건너뜁니다."
exit 0
fi
# node_modules 확인
if [ ! -d "${REPO_ROOT}/node_modules" ]; then
echo "경고: node_modules가 없습니다. 'npm install' 실행 후 다시 시도하세요."
exit 1
fi
# apps/web TypeScript 타입 체크
if [ -d "${REPO_ROOT}/apps/web" ]; then
cd "${REPO_ROOT}/apps/web"
npx tsc --noEmit --pretty 2>&1
TSC_RESULT=$?
if [ $TSC_RESULT -ne 0 ]; then
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ TypeScript 타입 에러! 커밋이 차단되었습니다. ║"
echo "║ 타입 에러를 수정한 후 다시 커밋해주세요. ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
exit 1
fi
echo "pre-commit: apps/web 타입 체크 성공"
# ESLint 검증 (설정 파일이 있는 경우만)
if [ -f "eslint.config.js" ] || [ -f "eslint.config.mjs" ] || [ -f ".eslintrc.js" ] || [ -f ".eslintrc.json" ] || [ -f ".eslintrc.cjs" ]; then
echo "pre-commit: ESLint 검증 중..."
npx eslint src/ --quiet 2>&1
LINT_RESULT=$?
if [ $LINT_RESULT -ne 0 ]; then
echo ""
echo "╔══════════════════════════════════════════════════════════╗"
echo "║ ESLint 에러! 커밋이 차단되었습니다. ║"
echo "║ 'npm run lint -- --fix'로 자동 수정을 시도해보세요. ║"
echo "╚══════════════════════════════════════════════════════════╝"
echo ""
exit 1
fi
echo "pre-commit: ESLint 통과"
fi
fi
cd "${REPO_ROOT}"