diff --git a/.husky/pre-commit b/.husky/pre-commit index d186ea0fe..a0d49ab65 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1,13 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -yarn prettier src/app --check +# Get staged files to check with prettier. +files=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx|json)$' || true) +# Check if there are any files to format +if [ -n "$files" ]; then + echo "Checking formatting for: $files" + yarn prettier --check $files +else + echo "No matching files to check." +fi