Skip to content

Instantly share code, notes, and snippets.

@pristinenoise
Last active October 23, 2017 18:20
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 pristinenoise/910dbd6a73e20d4646962fc272540f5c to your computer and use it in GitHub Desktop.
Save pristinenoise/910dbd6a73e20d4646962fc272540f5c to your computer and use it in GitHub Desktop.
Precommit hook for eslint and rubocop
#!/bin/sh
FILE_COUNT=$(git status | grep 'modified:' | wc -l)
if [ $FILE_COUNT -gt 100 ] ; then
echo "File count is 100+, skipping pre-commit validation"
exit 0
fi
# Check modified Javascript files with ESLint
FAILED=0
bundle exec rake lint
if [[ $? != 0 ]] ; then
FAILED=1
fi
matches=$(git diff --cached | grep -E '\+.*?FIXME')
if [ "$matches" != "" ]
then
echo "'FIXME' tag is detected."
echo "Please fix it before committing."
echo " ${matches}"
FAILED=1
fi
if [[ $FAILED != 0 ]] ; then
echo "Pre-commit test failed, git commit denied!"
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment