From 5cddc889fa355422278b2f525750608beb8e5f2d Mon Sep 17 00:00:00 2001 From: Oliver Blanthorn Date: Sat, 6 Jun 2026 13:42:52 +0200 Subject: [PATCH] Move prettier to linter rather than pre-commit --- ci/lint.sh | 15 +++++++++++++++ hooks/pre-commit | 22 ++++++++++++---------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ci/lint.sh b/ci/lint.sh index bd3d76e7..6e77fdea 100755 --- a/ci/lint.sh +++ b/ci/lint.sh @@ -12,3 +12,18 @@ if [ "$incompatible_sed" ]; then fi yarn run lint "$(yarn bin)/eslint" --rulesdir custom-eslint-rules --ext .ts . + +if [ "$(git rev-parse --abbrev-ref HEAD)" = "master" ]; then + if ! yarn prettier --check '**/*.ts' ; then + echo "Warning: the files above have prettier formatting issues. Run 'yarn run prettier -w [files]' to fix them." + fi +else + git fetch origin master 2>/dev/null || true + changed=$(git diff --name-only origin/master...HEAD -- '*.ts' 2>/dev/null || true) + if [ -n "$changed" ]; then + if ! yarn prettier --check $changed; then + echo "The files above have prettier formatting issues. Run 'yarn run prettier -w [files]' to fix them." + exit 1 + fi + fi +fi diff --git a/hooks/pre-commit b/hooks/pre-commit index 1f2b69a5..d43781db 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -30,17 +30,19 @@ if [ -n "$consoleFiles" ]; then echo fi -if [ -n "$jsfiles" ]; then - yarn git-format-staged \ - --formatter "yarn --silent prettier --stdin-filepath \"{}\"" \ - "*.ts" "*.tsx" -fi +# # disabled because it was too noisy +# +# if [ -n "$jsfiles" ]; then +# yarn git-format-staged \ +# --formatter "yarn --silent prettier --stdin-filepath \"{}\"" \ +# "*.ts" "*.tsx" +# fi -if [ -n "$otherfiles" ]; then - yarn git-format-staged \ - --formatter "yarn --silent prettier --stdin-filepath \"{}\"" \ - "*.md" "*.css" -fi +# if [ -n "$otherfiles" ]; then +# yarn git-format-staged \ +# --formatter "yarn --silent prettier --stdin-filepath \"{}\"" \ +# "*.md" "*.css" +# fi if [ -n "$jsfiles" ]; then echo "Linting staged files..."