one-click-accessibility/.husky/pre-commit
Nirbhay Singh ebe78b65e1 update: husky
2026-02-09 14:31:15 +05:30

19 lines
No EOL
682 B
Text

# Get list of staged files
STAGED_JS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx)$' || true)
STAGED_PHP_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.php$' || true)
STAGED_CSS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(css|scss)' || true)
# Run JS linting if there are staged JS files
if [ -n "$STAGED_JS_FILES" ]; then
npm run lint:js || exit 1
fi
# Run PHP linting if there are staged PHP files
if [ -n "$STAGED_PHP_FILES" ]; then
npm run lint:php:report || exit 1
fi
# Run CSS linting if there are staged CSS files
if [ -n "$STAGED_CSS_FILES" ]; then
npm run lint:css || exit 1
fi