Skip to content

Instantly share code, notes, and snippets.

@Cheffheid
Cheffheid / commit-msg
Last active March 27, 2017 20:08 — forked from wesbos/commit-msg
ESLint / PHPCS Git Pre Commit Hook
# Ruthlessly stolen from Wes Bos' ESLint pre commit hook, and expanded to also run PHPCS.
#!/bin/bash
jsfiles=$(git diff --cached --name-only | grep '\.jsx\?$')
# Only do something if we have JS files.
if [[ $jsfiles != "" ]] ; then
jsfailed=0
for jsfile in ${jsfiles}; do
git show :$jsfile | eslint $jsfile