Radarr/scripts/pre-commit
admin 66264b7301 chore: add pre-commit hooks and CI coverage reporting
- Add pre-commit hook for JS/TS and CSS lint checks
- Add setup script to install hooks
- Add coverage reporting to CI workflow
- Add coverage threshold warning (60%)
- Update CONTRIBUTING.md with hooks setup instructions
2025-12-18 11:13:21 -06:00

37 lines
1 KiB
Bash
Executable file

#!/bin/bash
# Pre-commit hook for Aletheia
set -e
echo "Running pre-commit checks..."
# Check if there are any staged frontend files
STAGED_JS=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx)$' | grep '^frontend/' || true)
if [ -n "$STAGED_JS" ]; then
echo "Checking JavaScript/TypeScript lint..."
yarn lint --quiet 2>/dev/null || {
echo "ESLint errors found. Run 'yarn lint-fix' to auto-fix."
exit 1
}
fi
# Check if there are any staged CSS files
STAGED_CSS=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.css$' | grep '^frontend/' || true)
if [ -n "$STAGED_CSS" ]; then
echo "Checking CSS lint..."
if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
yarn stylelint-windows --quiet 2>/dev/null || {
echo "Stylelint errors found."
exit 1
}
else
yarn stylelint-linux --quiet 2>/dev/null || {
echo "Stylelint errors found."
exit 1
}
fi
fi
echo "Pre-commit checks passed."