Back to list

Git Pre-commit Hook

Lv.3180@mukitaro0 playsJan 2, 2026

Git pre-commit hook for linting staged JavaScript files. Common in Husky setups.

preview.shell
Shell
1STAGED=$(git diff --cached --name-only --diff-filter=ACM)
2for file in $STAGED; do
3 if [[ $file == *.js ]]; then
4 npx eslint "$file" || exit 1
5 fi
6done
7echo "All checks passed"

Custom problems are not included in rankings