Skip to content

Instantly share code, notes, and snippets.

@constgen
Last active June 24, 2017 15:51
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 constgen/383fbfa6ed8460b4da21d8c178e3f468 to your computer and use it in GitHub Desktop.
Save constgen/383fbfa6ed8460b4da21d8c178e3f468 to your computer and use it in GitHub Desktop.
Git ESLint precommit hook
#!/bin/zsh
function lintit () {
OUTPUT=$(git diff --name-only | grep -E '(.js)$')
a=("${(f)OUTPUT}")
e=$(eslint -c eslint.json $a)
echo $e
if [[ "$e" != *"0 problems"* ]]; then
echo "ERROR: Check eslint hints."
exit 1 # reject
fi
}
lintit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment