-
-
Save Ajnasz/6e38cb113aeeac2ca2d9d16ac29c8594 to your computer and use it in GitHub Desktop.
ESLint git commit hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
files=$(git diff --diff-filter ACMR --cached --name-only | grep '\.js$') | |
FAILED=0 | |
for file in $files; do | |
git show :$file | $(npm bin)/eslint --stdin --stdin-filename $file | |
EXIT_CODE=$? | |
if [ $EXIT_CODE -ne 0 ]; then | |
FAILED=$EXIT_CODE | |
fi | |
done; | |
exit $FAILED |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment