Skip to content

Instantly share code, notes, and snippets.

@Ajnasz

Ajnasz/pre-commit

Forked from jhartikainen/commit-msg
Last active Apr 14, 2018
Embed
What would you like to do?
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