From 9799f7e6986d953b6de72d5a8cdfa84cdaf071ea Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sat, 23 May 2026 17:53:11 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20ci:=20Check=20Prettier=20Formatt?= =?UTF-8?q?ing=20Drift=20on=20Package=20Changes=20(#13282)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a `Run Prettier --check on changed files` step to the existing `eslint-ci.yml` workflow. Same path filter (api/**, client/**, packages/**), same changed-files detection, runs after the ESLint step. ## Why Today there is no `prettier --check` in CI — only the local `lint-staged` pre-commit hook runs `prettier --write`. When a PR is merged with the hook bypassed (e.g. GitHub UI edit-and-merge, or `git commit --no-verify`), a file can land in a non-prettier-canonical state and nobody notices. The next contributor who stages an unrelated change in that file then ends up with a "drive-by" prettier diff in their PR. `packages/api/src` had 14 such files accumulated; #13281 fixes the existing drift. This PR closes the gap so it doesn't regrow. ## What the step does - Detects changed JS/TS files under `api/**`, `client/**`, or `packages/**` against the PR base. - Runs `npx prettier --check $CHANGED_FILES`. - On failure, prints a `::error::` annotation telling the contributor how to fix it locally (`npx prettier --write `). Same one-step shape as the existing ESLint check — no extra workflow file, no extra `npm ci`, no extra checkout. ## Ordering note #13281 (`chore: prettier --write packages/api/src`) should land first so the existing drift is cleared. After both PRs merge, the pre-commit hook + this CI check together prevent drift from re-accumulating. ## Test plan - [x] `npx js-yaml .github/workflows/eslint-ci.yml` validates. - [ ] CI green on this PR itself (touches only `.github/workflows/`, which the path filter includes, so the workflow runs on itself). - [ ] After merge: a synthetic PR introducing prettier drift should fail the new step with the diagnostic message. --- .github/workflows/eslint-ci.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/eslint-ci.yml b/.github/workflows/eslint-ci.yml index 629f41662e..f03e88a7a7 100644 --- a/.github/workflows/eslint-ci.yml +++ b/.github/workflows/eslint-ci.yml @@ -61,3 +61,30 @@ jobs: --config eslint.config.mjs \ --max-warnings=0 \ $CHANGED_FILES + + # Run Prettier --check on the same set of changed files to catch + # formatting drift in PRs that bypassed the local pre-commit hook + # (e.g. GitHub UI edit-and-merge, `git commit --no-verify`). + - name: Run Prettier --check on changed files + run: | + BASE_SHA=$(jq --raw-output .pull_request.base.sha "$GITHUB_EVENT_PATH") + CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRTUXB "$BASE_SHA" HEAD | grep -E '^(api|client|packages)/.*\.(js|jsx|ts|tsx)$' || true) + + if [[ -z "$CHANGED_FILES" ]]; then + echo "No matching files changed. Skipping Prettier." + exit 0 + fi + + echo "Files to check:" + echo "$CHANGED_FILES" + + # `prettier --check` exits non-zero if any file would be reformatted. + # Suggest the local fix in the failure message so contributors aren't + # left guessing how to resolve. + if ! npx prettier --check --no-error-on-unmatched-pattern $CHANGED_FILES; then + echo "" + echo "::error::Prettier formatting drift detected. Fix locally with:" + echo "::error:: npx prettier --write " + echo "::error::Or rely on the lint-staged pre-commit hook (do not bypass with --no-verify)." + exit 1 + fi