Skip to content

Instantly share code, notes, and snippets.

@femontanha
Created August 5, 2017 19:38
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 femontanha/3683125ca2964719db4d47d4836f6138 to your computer and use it in GitHub Desktop.
Save femontanha/3683125ca2964719db4d47d4836f6138 to your computer and use it in GitHub Desktop.
pre-commit esw
#!/bin/sh
# ESLint Pre Commit Check
# put to `.git/hooks/pre-commit`
eslint_check() {
files=$(git diff --cached --name-only --diff-filter=AM | grep '\.jsx\?$')
if [[ $files = "" ]] ; then
return
fi
failed=0
for file in ${files}; do
git show :$file | esw --color $file
if [[ $? != 0 ]] ; then
failed=1
fi
done;
if [[ $failed != 0 ]] ; then
echo "🚫 ESLint failed, git commit denied!"
exit $failed
fi
}
eslint_check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment