From afef350fe1d7c9c32662d8366455e5cc057f6b2b Mon Sep 17 00:00:00 2001 From: pseudoyu Date: Thu, 15 Oct 2026 02:46:47 +0800 Subject: [PATCH] fix(ci): keep fixing until the auto format result passes lint oxlint applies fixes in a single pass and reports the problems it saw before fixing, so a fix that creates a new problem still exits 0. In 60dd77d75 the prefer-switch fix left an unbraced `else switch` with braced cases, the bot committed it, and every later Format run failed on code it could no longer fix in one pass. After `npm run format`, repeat oxlint --fix and oxfmt on the changed files until they stop changing, then lint them without --fix so the job fails instead of committing what lint rejects. Pushes without fixes skip the loop. Remove the step once oxlint applies fixes recursively (oxc-project/oxc#16118). --- .github/workflows/format.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index e3edb6fb37..ef6de919ce 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -23,6 +23,24 @@ jobs: - run: pnpm i - run: npm run format:description - run: npm run format + # oxlint applies fixes in a single pass, so a fix can leave problems that only the next pass fixes or reports + # Repeat on the changed files until they stop changing, and fail instead of committing what lint rejects + # https://github.com/oxc-project/oxc/issues/16118 + - name: Apply chained fixes + run: | + files=() + while IFS= read -r file; do files+=("$file"); done < <(git diff --name-only -- '*.js' '*.mjs' '*.ts' '*.tsx') + if [ ${#files[@]} -gt 0 ]; then + for _ in 1 2 3 4 5; do + before=$(git diff | git hash-object --stdin) + pnpm exec oxlint --type-aware --fix "${files[@]}" || true + pnpm exec oxfmt "${files[@]}" + if [ "$(git diff | git hash-object --stdin)" = "$before" ]; then + break + fi + done + pnpm exec oxlint --type-aware "${files[@]}" + fi - name: Commit files run: | git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"