Skip to content

Commit

Permalink
Don't run linter on pre-push if nothing to lint
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmire committed Feb 2, 2024
1 parent 112cd52 commit 27a7970
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ if echo "$stdin" | grep -q "^(delete)"; then
exit 0
fi

files_to_check=$(git diff --cached "$(git merge-base main HEAD)" --name-only --diff-filter=d)
if [[ -n $files_to_check ]]; then
raw_files_to_check="$(git diff main...HEAD --name-only --diff-filter=d)"
if [[ -n "$raw_files_to_check" ]]; then
echo "*** Checking for lint violations in changed files ***************"
echo

yarn prettier --check --ignore-unknown $files_to_check || exit $?
echo "$raw_files_to_check" | while IFS='\n' read -r line; do
printf '%s\0' "$line"
done | xargs -0 yarn prettier --check --ignore-unknown || exit $?
fi

echo
Expand Down

0 comments on commit 27a7970

Please sign in to comment.