Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions .claude/hooks/format-hook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ if [ -z "$FILE_PATH" ]; then
exit 0
fi

# Check if file is a TypeScript/JavaScript file
if [[ ! "$FILE_PATH" =~ \.(ts|tsx|js|jsx|mjs|cjs)$ ]]; then
# Check if file is a TypeScript/JavaScript or Python file
if [[ ! "$FILE_PATH" =~ \.(ts|tsx|js|jsx|mjs|cjs|py)$ ]]; then
exit 0
fi

Expand All @@ -32,21 +32,32 @@ fi
echo "🔧 Auto-formatting: $FILE_PATH"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

# Step 1: Run ESLint with auto-fix
echo "📋 Running ESLint..."
if npx eslint --fix "$FILE_PATH" 2>&1; then
echo "✓ ESLint completed"
# Check if it's a Python file
if [[ "$FILE_PATH" =~ \.py$ ]]; then
echo "🐍 Running ruff format for Python..."
if ruff format "$FILE_PATH" 2>&1; then
echo "✓ Ruff format completed"
else
echo "⚠️ Ruff format encountered issues"
fi
else
echo "⚠️ ESLint reported issues (may have auto-fixed some)"
fi
# Handle TypeScript/JavaScript files
# Step 1: Run ESLint with auto-fix
echo "📋 Running ESLint..."
if npx eslint --fix "$FILE_PATH" 2>&1; then
echo "✓ ESLint completed"
else
echo "⚠️ ESLint reported issues (may have auto-fixed some)"
fi

# Step 2: Run TypeScript formatter
echo ""
echo "📐 Running TypeScript formatter..."
if node scripts/format.js "$FILE_PATH" 2>&1; then
echo "✓ TypeScript formatter completed"
else
echo "⚠️ TypeScript formatter encountered issues"
# Step 2: Run TypeScript formatter
echo ""
echo "📐 Running TypeScript formatter..."
if node scripts/format.js "$FILE_PATH" 2>&1; then
echo "✓ TypeScript formatter completed"
else
echo "⚠️ TypeScript formatter encountered issues"
fi
fi

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
Expand Down
Loading