mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-16 21:02:57 +08:00
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).
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user