name: setup-oxlint description: Use when setting up native Oxc linting and formatting in a JS/TS project, migrating from ESLint/Prettier, or standardizing a codebase on @zhangyu1818/oxlint-config.
Setup Oxlint
Scope
- Confirm the project and CI can satisfy Node.js
>=24 - Ensure
@zhangyu1818/oxlint-config,oxlint, andoxfmtare in devDependencies - Ensure
oxlint-tsgolintis installed whentypescriptis present - Create or update
oxlint.config.*usingdefineConfig - Create or update
oxfmt.config.*usingdefineOxfmtConfig - Derive presets from project dependencies and structure
- Add lint and format scripts when missing
Workflow
- Inspect project state (
package.json, lockfiles, Node version, existing lint and format configs) - Confirm Node.js compatibility with
>=24; if not, stop and report the blocker - Install or upgrade dependencies:
@zhangyu1818/oxlint-configoxlintoxfmtoxlint-tsgolintwhentypescriptis used
- Create or update
oxlint.config.* - Create or update
oxfmt.config.* - Configure presets based on the detected stack
- Add scripts if missing
- Verify if requested
Inspect project
- Read
package.json - Detect package manager via lockfiles (
pnpm-lock.yaml,yarn.lock,bun.lockb,package-lock.json) - Check the active Node.js version and
package.json.engines.node - Check for existing config files:
oxlint.config.js,oxlint.config.mjs,oxlint.config.cjs,oxlint.config.tsoxfmt.config.js,oxfmt.config.mjs,oxfmt.config.cjs,oxfmt.config.ts- legacy
eslint.config.*,.eslintrc.*,.prettierrc*
Install dependencies
- Use the detected package manager
- Install:
- pnpm:
pnpm add -D @zhangyu1818/oxlint-config oxlint oxfmt - npm:
npm install -D @zhangyu1818/oxlint-config oxlint oxfmt - yarn:
yarn add -D @zhangyu1818/oxlint-config oxlint oxfmt - bun:
bun add -D @zhangyu1818/oxlint-config oxlint oxfmt
- pnpm:
- If
typescriptis present, also installoxlint-tsgolint
Configure Oxlint
- Prefer an existing
oxlint.config.*extension; otherwise createoxlint.config.ts - Use ESM import and
defineConfig
Example base:
import { defineConfig } from '@zhangyu1818/oxlint-config'
export default defineConfig({
presets: {},
})
Configure Oxfmt
- Prefer an existing
oxfmt.config.*extension; otherwise createoxfmt.config.ts - Use ESM import and
defineOxfmtConfig
Example base:
import { defineOxfmtConfig } from '@zhangyu1818/oxlint-config'
export default defineOxfmtConfig({
presets: {},
})
Preset selection
- Enable
nextifnextis present - Enable
reactifreactorreact-domis present - Enable
typescriptiftypescriptis present - Enable
testifvitestis present - Enable
nodefor backend or CLI projects - Enable Oxfmt
tailwindcsssorting if Tailwind class sorting is needed - Enable Oxfmt
packageJsonsorting ifpackage.jsonordering should be normalized
Optional scripts
- Add scripts if missing:
{
"scripts": {
"lint": "oxlint -c oxlint.config.ts",
"lint:fix": "oxlint --fix -c oxlint.config.ts",
"format": "oxfmt -c oxfmt.config.ts .",
"format:check": "oxfmt --check -c oxfmt.config.ts ."
}
}
Verify
- Prefer existing project scripts if present
- Otherwise run:
pnpm exec oxlint -c oxlint.config.tspnpm exec oxfmt --check -c oxfmt.config.ts .