name: Format on: push: branches: - master jobs: format: permissions: contents: write # for Git to git push name: Auto format runs-on: ubuntu-latest timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: lts/* cache: 'pnpm' - 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" git config --local user.name "github-actions[bot]" git status git diff-index --quiet HEAD || (git commit -m "style: auto format" -a --no-verify && git push "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" HEAD:master)