@anolilab/oxlint-config

中文文档
2.0.3发布于 2026/11/05MITTypeScriptESM + CJS构建来源已验证近 30 天下载 4734

oxlint shareable config for Anolilab.

原始使用文档
文档目录8 节
  1. oxlint shareable config for Anolilab.
  2. Install
  3. Setup
  4. Overriding
  5. Automatic JSX runtime
  6. What it sets
  7. Not migrated
  8. Related
oxlint-config

oxlint shareable config for Anolilab.


typescript-image mit licence


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

oxlint and oxlint-tsgolint are peer dependencies. Install both alongside this package. The config turns on type-aware linting, and oxlint looks for oxlint-tsgolint in your project. Without it, oxlint stops with Failed 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-config sets for those files
  • plugins: typescript, unicorn, oxc, import, promise, node, jsdoc, react, jsx-a11y
  • jsPlugins: sonarjs, regexp, eslint-comments, no-secrets, react-doctor. ESLint plugins oxlint loads unchanged, with the rules @anolilab/eslint-config enables for them, and the oxlint-plugin-react-doctor rule set.
  • rules: every rule oxlint implements that @anolilab/eslint-config enables for TypeScript files, with ESLint's severity and options. Every other rule oxlint implements is set to off explicitly, so the preset never switches a rule on by category.
  • Type-aware rules. options.typeAware is on, so the typescript/* rules that need type information run through oxlint-tsgolint. That package must be installed next to oxlint. A consumer that sets its own options keeps this setting.
  • Severity parity. Every rule that @anolilab/eslint-config runs at error or warn runs here at the same severity. Rules from the style, restriction and nursery categories 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 are error and turn that ESLint rule off, but only when its plugin is loaded. The rest are warn.

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 report module, process and 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, react and @stylistic rules ESLint enables that oxlint has no rule for, and camelcase, no-restricted-syntax, no-return-await and no-undef-init among 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.

版本与发布记录

@anolilab/oxlint-config 共发布 11 个版本,首次发布于 2026/07/22;过去 12 个月发布了 11 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.0.3latest2026/11/051 天前
2.0.22026/11/032 天前
2.0.12026/10/2214 天前
2.0.02026/10/2215 天前
1.0.52026/10/1720 天前
1.0.42026/10/1324 天前

关于 @anolilab/oxlint-config 的常见问题

@anolilab/oxlint-config 是什么?

oxlint shareable config for Anolilab.

如何安装 @anolilab/oxlint-config?

在项目目录运行 npm install @anolilab/oxlint-config,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:oxlint(1.89.0)、oxlint-tsgolint(7.0.2005)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anolilab/oxlint-config 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anolilab/oxlint-config 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@anolilab/oxlint-config 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.12.0 <=25.*。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@anolilab/oxlint-config 可以商用吗?

@anolilab/oxlint-config 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@anolilab/oxlint-config 的下载量有多少?

根据 npm 官方下载统计,@anolilab/oxlint-config 在 2026/10/06 – 2026/11/04 这 30 天内被下载 4,734 次,日均约 158 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anolilab/oxlint-config 还在维护吗?

最新版本 2.0.3 发布于 2026/11/05(1 天前);至今共发布 11 个版本,其中过去 12 个月发布了 11 个;首次发布于 2026/07/22。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。