Skip to content

Instantly share code, notes, and snippets.

@Ajnasz
Forked from jhartikainen/commit-msg
Last active April 14, 2018 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ajnasz/6e38cb113aeeac2ca2d9d16ac29c8594 to your computer and use it in GitHub Desktop.
Save Ajnasz/6e38cb113aeeac2ca2d9d16ac29c8594 to your computer and use it in GitHub Desktop.
ESLint git commit hook
#!/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