Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[ci] Merge ESLint and Prettier workflows with auto-fix
- Combines separate eslint.yaml and format.yaml into unified lint-and-format.yaml
- Automatically fixes ESLint and Prettier issues on PRs and commits changes
- Adds GitHub Action permissions for content write to enable auto-commits
- Includes PR commenting to notify when auto-fixes are applied
- Enables faster iteration by eliminating manual fix cycles
  • Loading branch information
snomiao committed Aug 1, 2025
commit ed3ec8c0e6cd513e8f39d08609eda07bafcee690
17 changes: 0 additions & 17 deletions .github/workflows/eslint.yaml

This file was deleted.

23 changes: 0 additions & 23 deletions .github/workflows/format.yaml

This file was deleted.

71 changes: 71 additions & 0 deletions .github/workflows/lint-and-format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Lint and Format

on:
pull_request:
branches-ignore: [ wip/*, draft/*, temp/* ]

permissions:
contents: write
pull-requests: write

jobs:
lint-and-format:
runs-on: ubuntu-latest
steps:
- name: Checkout PR
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: ${{ github.head_ref }}
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run ESLint with auto-fix
run: npm run lint:fix

- name: Run Prettier with auto-format
run: npm run format

- name: Check for changes
id: verify-changed-files
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi

- name: Commit changes
if: steps.verify-changed-files.outputs.changed == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git commit -m "[auto-fix] Apply ESLint and Prettier fixes"
git push

- name: Comment on PR
if: steps.verify-changed-files.outputs.changed == 'true'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '✅ **Auto-fix Applied**\n\nESLint and Prettier have automatically fixed formatting and linting issues in this PR. The changes have been committed to this branch.'
})

- name: Run final lint check
run: npm run lint

- name: Run final format check
run: npm run format:check