Created
January 4, 2019 14:11
-
-
Save mertkahyaoglu/4919cd58b6aecaac7052c49abaf9542d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# allow being run from somewhere other than the git rootdir | |
gitroot=$(git rev-parse --show-cdup) | |
# default gitroot to . if we're already at the rootdir | |
gitroot=${gitroot:-.}; | |
nm_bin=$gitroot/node_modules/.bin | |
files=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$") || files="" | |
# Prevent ESLint help message if no files matched | |
if [[ $files = "" ]] ; then | |
echo "There is no file to lint" | |
exit 0 | |
fi | |
$nm_bin/eslint $files | |
echo "Changed files are linted, commit correct!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment