zq8jlq
Last Updated: February 28, 2016
·
5.746K
· johannesboyne
100 2223

eslint pre-commit hook

eslint pre-commti 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

If you want to store the eslint.json config file at a different path, just change it inside the script ;-)

Say Thanks
Respond
Awesome Job

033a9968 4bcd 11e7 83f5 dbe933838e53
Senior Mobile Developer
·
Logan, UT (Remote or On-Site)
·
Full Time