Files
Coltura/pre-commit
Matthieu 7045debc66 feat : add ESLint linter to frontend with pre-commit hook
Add ESLint with @nuxt/eslint-config enforcing 4-space indentation.
Add make nuxt-lint and nuxt-lint-fix targets.
Add ESLint check to pre-commit hook (lint only, no auto-fix).
Fix auth.vue indentation from 2 to 4 spaces.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 14:16:25 +02:00

49 lines
1.2 KiB
Bash
Executable File

#!/bin/sh
echo "######### Pre-commit hook start #############"
echo "--- php-cs-fixer pre commit hook start ---"
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.php$')
# Vérifier s'il y a des fichiers PHP modifiés
if [ -n "$FILES" ]; then
echo "Running PHP CS Fixer on staged PHP files..."
# Convertir la liste des fichiers en une chaîne séparée par des espaces
FILES_LIST=""
for FILE in $FILES; do
FILES_LIST="$FILES_LIST $FILE"
done
# Exécuter la cible make pour PHP CS Fixer
make php-cs-fixer-allow-risky FILES="$FILES_LIST"
# Ajouter les fichiers corrigés au commit
git add $FILES
else
echo "No PHP files to fix."
fi
echo "--- php-cs-fixer pre commit hook finish---"
echo "--- eslint pre commit hook start ---"
make nuxt-lint
ESLINT_RESULT=$?
if [ $ESLINT_RESULT -ne 0 ]; then
echo "ESLint failed. Aborting commit."
exit 1
fi
echo "--- eslint pre commit hook finished ---"
echo "--- phpunit pre commit hook start ---"
make test
PHPUNIT_RESULT=$?
if [ $PHPUNIT_RESULT -ne 0 ]; then
echo "PHPUnit tests failed. Aborting commit."
exit 1
fi
echo "--- phpunit pre commit hook finished ---"
echo "All checks passed. Proceeding with commit."
exit 0