Last active
February 18, 2018 16:37
-
-
Save wwwebman/54fc234df55fe588d9ea8cd37b8a5417 to your computer and use it in GitHub Desktop.
Revisions
-
wwwebman renamed this gist
Feb 18, 2018 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
wwwebman created this gist
Feb 18, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ #!/bin/sh # 1. # Code Quality Check # @scope ./react # STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM "src/react/*.js" "react/*.jsx" | tr '\n' ' ') ESLINT="$(git rev-parse --show-toplevel)/react/node_modules/.bin/eslint" [ -z "$STAGED_FILES" ] && exit 0 # Check if Eslint installed [ ! -x "$ESLINT" ] && echo "\033[41m Please install ESlint \033[0m (cd react && npm i -D eslint)" && exit 1 # Start validation VALIDATION_PASSED=true echo "$STAGED_FILES \n Validating Javascript:" for FILE in $STAGED_FILES do "$ESLINT" "$FILE" if [ -n "$?" ]; then VALIDATION_PASSED=false fi done if ! $VALIDATION_PASSED; then echo "\033[41m COMMIT FAILED: \033[0m Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again." exit 1 fi exit $?