oxlint shareable config for Anolilab.
A shareable oxlint configuration for Anolilab. It
enables the correctness category and lists every other rule it turns on by name, so no rule
switches on by category alone. It leaves the style category to @anolilab/oxfmt-config.
Install
npm install --save-dev @anolilab/oxlint-config oxlint oxlint-tsgolint
pnpm add -D @anolilab/oxlint-config oxlint oxlint-tsgolint
oxlintandoxlint-tsgolintare peer dependencies. Install both alongside this package. The config turns on type-aware linting, and oxlint looks foroxlint-tsgolintin your project. Without it, oxlint stops withFailed to find tsgolint executable.
Setup
Run the installer to scaffold a .oxlintrc.json for you:
npx oxlint-config:install
Or wire it up manually — there are two ways to consume it.
.oxlintrc.json (extends by path)
oxlint's JSON config cannot import npm packages, so extends points at the file inside node_modules:
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"extends": ["./node_modules/@anolilab/oxlint-config/.oxlintrc.json"],
"rules": {}
}
oxlint.config.ts (import the object)
import config from "@anolilab/oxlint-config";
export default config;
Overriding
Relax or tighten individual rules on top of the shared base:
{
"extends": ["./node_modules/@anolilab/oxlint-config/.oxlintrc.json"],
"rules": {
"no-console": "off"
}
}
Top-level rules lose to the preset's per-file-kind overrides (see What it sets).
A rule the preset also sets for **/*.tsx, **/*.jsx or **/*.{cjs,mjs,js} keeps the preset's
value for those files, even when your top-level rules turn it off. To change it there too, set it
in an override of your own. Your overrides apply after the preset's:
{
"extends": ["./node_modules/@anolilab/oxlint-config/.oxlintrc.json"],
"overrides": [
{
"files": ["**/*"],
"rules": {
"no-console": "off"
}
}
]
}
Automatic JSX runtime
The preset turns react/react-in-jsx-scope on for .tsx and .jsx files, as @anolilab/eslint-config
does for the classic runtime. @anolilab/eslint-config turns the rule off when the tsconfig sets
jsx to react-jsx or react-jsxdev, but a JSON config cannot read a tsconfig. To get the same
result, use oxlint.config.ts and jsxRuntimeOverrides. It returns one override for each listed
tsconfig that uses the automatic runtime:
import config, { jsxRuntimeOverrides } from "@anolilab/oxlint-config";
export default {
...config,
overrides: [...config.overrides, ...jsxRuntimeOverrides(["tsconfig.json", "packages/app/tsconfig.json"])],
};
In a .oxlintrc.json, add an override that turns react/react-in-jsx-scope off for those files instead.
What it sets
categories:correctness: "error"overrides: one entry per file kind whose rules differ from the TypeScript rules:**/*.{cjs,mjs,js},**/*.jsx,**/*.tsx. Each uses the values@anolilab/eslint-configsets for those filesplugins:typescript,unicorn,oxc,import,promise,node,jsdoc,react,jsx-a11yjsPlugins:sonarjs,regexp,eslint-comments,no-secrets,react-doctor. ESLint plugins oxlint loads unchanged, with the rules@anolilab/eslint-configenables for them, and theoxlint-plugin-react-doctorrule set.rules: every rule oxlint implements that@anolilab/eslint-configenables for TypeScript files, with ESLint's severity and options. Every other rule oxlint implements is set tooffexplicitly, so the preset never switches a rule on by category.- Type-aware rules.
options.typeAwareis on, so thetypescript/*rules that need type information run throughoxlint-tsgolint. That package must be installed next tooxlint. A consumer that sets its ownoptionskeeps this setting. - Severity parity. Every rule that
@anolilab/eslint-configruns aterrororwarnruns here at the same severity. Rules from thestyle,restrictionandnurserycategories that ESLint enables are listed explicitly. - React Doctor. Its rules are enabled except the 80 that oxlint already runs natively under the
same name (for example
jsx-a11y/alt-text,react/rules-of-hooks,no-eval), so no finding is reported twice. Where React Doctor is stricter than the native rule, the native rule is pinned to React Doctor's severity. The React Doctor rules that match an ESLint rule of the same concept areerrorand turn that ESLint rule off, but only when its plugin is loaded. The rest arewarn.
Not migrated
Every rule @anolilab/eslint-config enables that oxlint implements is enabled here with the same file kinds. These are not:
no-undef: the preset declares no globals, so it would reportmodule,processand browser globals. Keep it in ESLint.- Options oxlint does not accept. The rule runs at ESLint's severity with its default options:
preserve-caught-error,unicorn/escape-case,unicorn/filename-case,unicorn/no-array-callback-reference,unicorn/no-empty-file,unicorn/no-unreadable-array-destructuring,unicorn/prefer-add-event-listener,unicorn/prefer-array-find,unicorn/prefer-array-flat,unicorn/prefer-set-has. - Rules oxlint does not implement, so they stay in ESLint. These are the
unicorn,jsdoc,perfectionist,react-x,n,antfu,e18e,import,reactand@stylisticrules ESLint enables that oxlint has no rule for, andcamelcase,no-restricted-syntax,no-return-awaitandno-undef-initamong the core rules. - Rules for other languages (JSON, YAML, TOML, Markdown, CSS, HTML, Astro) and framework plugins (Storybook, Testing Library, Playwright, TanStack, Tailwind, UnoCSS, Zod, Vitest). Those stay in ESLint.
The style category is left off as a category — formatting is the formatter's job. The rules ESLint runs from it are listed explicitly above. Pair this
with @anolilab/oxfmt-config.
@anolilab/eslint-config reads this file when it is present and turns off the rules it runs, so
no rule is reported twice.