vibetunnel/web/scripts/pre-commit-check.sh
Mario Zechner c04cb26f4e Fix linter formatting issues
🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-17 01:52:52 +02:00

50 lines
No EOL
1.2 KiB
Bash
Executable file

#!/bin/bash
# VibeTunnel Pre-commit Check Script
# Can be run manually: npm run pre-commit
set -e
echo "🔍 Running pre-commit checks..."
# Check if we're in a git repository
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "❌ Not in a git repository"
exit 1
fi
# Get staged files or all TypeScript files if not in a commit
if git diff --cached --quiet; then
echo "📁 No staged files, checking all TypeScript files..."
TS_FILES=$(find src -name "*.ts" -o -name "*.tsx" | tr '\n' ' ')
else
echo "📁 Checking staged TypeScript files..."
TS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|tsx)$' | tr '\n' ' ')
fi
if [ -z "$TS_FILES" ]; then
echo "✅ No TypeScript files to check"
exit 0
fi
echo "Files to check: $TS_FILES"
# Run ESLint
echo "🔧 Running ESLint..."
npm run lint
if [ $? -ne 0 ]; then
echo "❌ ESLint failed. Run 'npm run lint:fix' to auto-fix issues."
exit 1
fi
# Run Prettier check
echo "✨ Checking Prettier formatting..."
npm run format:check
if [ $? -ne 0 ]; then
echo "❌ Prettier formatting issues found. Run 'npm run format' to fix."
exit 1
fi
echo "✅ All checks passed!"