Skip to content

Commit 3d43eb9

Browse files
committed
feat: enhance pre-push hook with automatic issue fixing
- Add auto-fixing of linting issues with 'npm run lint:fix' - Add automatic code formatting with 'npm run format' - Auto-stage fixes before validation to ensure they're included - Only fail after attempting auto-fixes if manual intervention required - Improves developer experience by fixing common issues locally before push Process: 1. 🔧 Auto-fix linting issues 2. 🎨 Auto-format code 3. 📋 Stage auto-fixes 4. 🔍 Validate final quality 5. 🚀 Push only if everything passes Benefits: ✅ Reduces failed pushes due to fixable formatting/linting issues ✅ Maintains code quality standards automatically ✅ Saves developer time by fixing issues before they cause pipeline failures
1 parent fa727d7 commit 3d43eb9

1 file changed

Lines changed: 33 additions & 4 deletions

File tree

.githooks/pre-push

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,42 @@ if ! command -v npm &> /dev/null; then
1010
exit 1
1111
fi
1212

13-
# Full quality check (linting, formatting, type checking)
14-
echo "🔍 Running complete quality validation..."
13+
# Auto-fix common issues before validation
14+
echo "🔧 Auto-fixing common code quality issues..."
15+
16+
# Step 1: Auto-fix linting issues
17+
echo " 🔧 Running lint auto-fix..."
18+
npm run lint:fix
19+
LINT_FIX_EXIT_CODE=$?
20+
if [ $LINT_FIX_EXIT_CODE -eq 0 ]; then
21+
echo " ✅ Linting auto-fixes applied successfully"
22+
else
23+
echo " ⚠️ Some linting issues detected (exit code: $LINT_FIX_EXIT_CODE)"
24+
fi
25+
26+
# Step 2: Auto-format code
27+
echo " 🎨 Auto-formatting code..."
28+
npm run format
29+
FORMAT_EXIT_CODE=$?
30+
if [ $FORMAT_EXIT_CODE -eq 0 ]; then
31+
echo " ✅ Code formatting applied successfully"
32+
else
33+
echo " ⚠️ Code formatting encountered issues (exit code: $FORMAT_EXIT_CODE)"
34+
fi
35+
36+
# Step 3: Stage any auto-fixes that were applied
37+
echo " 📋 Staging any auto-fixes..."
38+
git add -A
39+
echo " ✅ Auto-fixes staged for commit"
40+
41+
# Final quality validation after auto-fixes
42+
echo "🔍 Running complete quality validation after auto-fixes..."
1543
npm run quality
1644
QUALITY_EXIT_CODE=$?
1745
if [ $QUALITY_EXIT_CODE -ne 0 ]; then
18-
echo "❌ Quality checks failed (exit code: $QUALITY_EXIT_CODE)"
19-
echo "💡 Fix issues with: npm run lint:fix && npm run format"
46+
echo "❌ Quality checks still failing after auto-fixes (exit code: $QUALITY_EXIT_CODE)"
47+
echo "💡 Manual intervention required - some issues cannot be auto-fixed"
48+
echo "🔍 Review the output above and fix remaining issues manually"
2049
exit 1
2150
fi
2251
echo "✅ Code quality validation passed"

0 commit comments

Comments
 (0)