-
-
Save tuliofaria/8d9c0fc70a9c64f7f3c4d985f8c85461 to your computer and use it in GitHub Desktop.
lint
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
#!/bin/sh | |
STAGED_FILES=$(git diff-index HEAD --name-only --cached | grep -E '\.(js|jsx|ts|tsx)$' || true) | |
if [[ -z $STAGED_FILES ]] | |
then | |
echo 'No relevant staged files, no need to run eslint.' | |
exit # no relevant staged files, no need to run eslint | |
fi | |
# Checks if any staged files have unstaged changes | |
# otherwise eslint isn't running on what is actually | |
# going to be committed. | |
WARN_FILES=$(git diff-files --stat -- $STAGED_FILES) | |
if [[ -n $WARN_FILES ]] | |
then | |
echo 'There are unstaged changes to files (git stash --keep-index to commit safely):' | |
echo "$WARN_FILES\n" | |
exit 1 | |
fi | |
echo "Running eslint..." | |
exec git diff --cached --name-only --relative --diff-filter=ACMR | grep -E '\.(js|jsx|ts|tsx)$' | xargs \ | |
docker compose run --no-TTY re-store-tools eslint \ | |
--ext js,ts,tsx \ | |
--fix \ | |
--quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment