How to Automatically Track Newly Supported ESLint Rules in Oxlint
简体中文 | English
In a previous post — How to Gradually Migrate from ESLint to Oxlint (Without Breaking Everything) — I covered the official Oxlint migration tool that converts your ESLint Flat Config into an Oxlint config.
Over the past few months, Oxlint has been steadily implementing rules that were previously unsupported, so the number of unsupported rule warnings you get when running the migration tool has been shrinking.
To make sure I can take advantage of newly supported rules as soon as they land, I put together a simple GitHub Actions workflow that runs the migration tool on a daily schedule and automatically opens a PR whenever .oxlint.json has changes.
Just drop the snippet below into .github/workflows/oxlint-migrate.yml in your project and you're good to go. All the relevant notes are in the comments.
name: Oxlint Migration
on:
schedule:
# Runs daily — feel free to adjust the schedule
- cron: '0 16 * * *'
workflow_dispatch: # Can also be triggered manually
jobs:
migrate:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Run oxlint migration
# Customize this as needed, e.g. pnpm dlx @oxlint/migrate --type-aware
# For more details, see: https://howiehz.top/archives/eslint-to-oxlint-gradual-migration-guide#%E8%87%AA%E5%8A%A8%E8%BF%81%E7%A7%BB-ESLint-%E9%85%8D%E7%BD%AE
run: pnpm dlx @oxlint/migrate --type-aware --with-nursery
# In my own setup, I append a formatter script defined in package.json to avoid
# spurious diffs caused by formatting inconsistencies, e.g. appending "&& pnpm run format"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.PR_WORKFLOW_TOKEN }}
# Create a Fine-grained PAT: https://github.com/settings/personal-access-tokens
# Create a repo secret: https://github.com/<owner>/<repo>/settings/secrets/actions
# Generate a Fine-grained PAT, then create a repo secret named PR_WORKFLOW_TOKEN and paste the token in.
# We use a Fine-grained PAT instead of the default GITHUB_TOKEN so that PRs created
# by this workflow can trigger other workflows (e.g. for CI checks).
# If you don't need that behavior, you can remove the token line above.
# Required Fine-grained PAT permissions:
# - Contents: Read and Write (to create branches and commits)
# - Pull requests: Read and Write (to open PRs)
# - Workflows: Read and Write (to allow the PR to trigger other workflows)
commit-message: 'chore: update oxlint configuration'
title: 'chore: update oxlint configuration'
body: |
This PR updates the oxlint configuration by running the migration tool.
Generated automatically by the oxlint-migrate workflow.
branch: chore/oxlint-migrate
delete-branch: true
labels: dependencies
add-paths: |
.oxlintrc.json
Feel free to drop a comment below if you have any questions or suggestions! 🚀
0