-
-
Save mholtzhausen/0d7bd7e72976fbfa82a4933cf25b3a0d to your computer and use it in GitHub Desktop.
Pre-commit hook for eslint, linting *only* staged changes.
This file contains 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
#!/bin/bash | |
clear | |
fileList=$(git diff --diff-filter=d --cached --name-only | grep -E '\.(js|vue)$') | |
if [ ${#fileList} -lt 1 ]; then | |
echo -e "You have no staged .js or .vue files to test\n" | |
exit | |
fi | |
npx eslint ${fileList[*]} "$@" | |
if [ $? -ne 0 ]; then | |
echo -e "\nPlease fix the above linting issues before committing.\n" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mholtzhausen do you know why when a lot of files are checked it complaints?