内置插件
🌐 Built-in Plugins
Oxlint 包含许多流行 ESLint 插件规则集的内置实现。recommended 配置中的大多数规则已经实现,因此你可以在无需额外设置的情况下获得有用的结果。
🌐 Oxlint includes built-in implementations of many popular ESLint plugin rule sets. Most rules in the recommended configs are already implemented, so you can get useful results without extra setup.
Oxlint 还支持使用与 ESLint 兼容的 API 编写的 JavaScript 插件。请参阅 JS 插件。
🌐 Oxlint also supports plugins written in JavaScript with an ESLint-compatible API. See JS Plugins.
在 Oxlint 中插件的含义是什么
🌐 What a plugin means in Oxlint
插件是一组有名称的规则。启用插件会使其规则可用,而类别标志则控制哪些规则被启用以及其严重程度。
🌐 A plugin is a named group of rules. Enabling a plugin makes its rules available, and category flags control which rules are enabled and at what severity.
如果你正在从 ESLint 迁移,插件对应你已经熟悉的生态系统,例如 import、react、jsx-a11y、jest、unicorn 等。
🌐 If you are migrating from ESLint, plugins map to the ecosystems you already know, such as import, react, jsx-a11y, jest, unicorn, and more.
启用插件
🌐 Enable a plugin
强烈建议使用配置文件来启用插件,因为这会大大简化管理和与其他开发者共享。
🌐 It is strongly recommended to use a config file to enable plugins, as it makes it considerably easier to manage and share with other developers on a project.
在配置文件中启用
🌐 Enable in a config file
你也可以使用 plugins 字段在 .oxlintrc.json 中启用插件:
🌐 You can also enable plugins in .oxlintrc.json using the plugins field:
{
"plugins": ["import"]
}设置 plugins 会覆盖默认的插件集。列表中应包含你希望启用的所有插件。
🌐 Setting plugins overwrites the default plugin set. The list should include every plugin you want enabled.
通过 CLI 启用
🌐 Enable with the CLI
你也可以使用 --<plugin-name>-plugin 命令行标志启用插件。
例如,启用导入插件:
🌐 Example, enable the import plugin:
oxlint --import-plugin启用后,类别标志会决定哪些功能被开启。
🌐 Once enabled, category flags determine what is turned on.
例如,在正确性类别中将导入插件规则启用为错误,将可疑情况设置为警告:
🌐 Example, enable import plugin rules in the correctness category as errors and suspicious as warnings:
oxlint --import-plugin -D correctness -W suspicious正确性规则默认启用。
🌐 Correctness rules are enabled by default.
提示:运行 oxlint --help 查看插件标志的完整列表。
🌐 Tip: run oxlint --help to see the full list of plugin flags.
禁用默认插件
🌐 Disable default plugins
在配置文件中禁用默认插件
🌐 Disable default plugins in a config file
要在配置文件中禁用所有默认插件,请将 plugins 设置为空数组:
🌐 To disable all default plugins in a config file, set plugins to an empty array:
{
"plugins": []
}这会禁用所有默认插件,仅使用基本规则集。
🌐 This disables all default plugins and uses only the base rule set.
使用 CLI 禁用默认插件
🌐 Disable default plugins with the CLI
有几个插件默认启用。你可以使用 --disable-<plugin-name>-plugin 来禁用默认插件。
示例,禁用独角兽:
🌐 Example, disable unicorn:
oxlint --disable-unicorn-plugin只有默认插件支持被禁用。非默认插件可以直接省略。
🌐 Only default plugins support being disabled. Non-default plugins can simply be omitted.
支持的插件
🌐 Supported plugins
此表列出了内置插件及其来源。
🌐 This table lists the built-in plugins and where they come from.
| Plugin name | Default | Source |
|---|---|---|
eslint | Yes | ESLint core rules |
typescript | Yes | TypeScript rules from typescript-eslint (aka @typescript-eslint/plugin). Type-aware rules are available in alpha using the type-aware mode. |
unicorn | Yes | eslint-plugin-unicorn |
react | No | eslint-plugin-react and eslint-plugin-react-hooks |
react-perf | No | eslint-plugin-react-perf |
nextjs | No | @next/eslint-plugin-next |
oxc | Yes | Oxc-specific rules and selected rules ported from deepscan |
import | No | eslint-plugin-import (also equivalent to eslint-plugin-import-x) |
jsdoc | No | eslint-plugin-jsdoc |
jsx-a11y | No | eslint-plugin-jsx-a11y |
node | No | eslint-plugin-n |
promise | No | eslint-plugin-promise |
jest | No | eslint-plugin-jest |
vitest | No | @vitest/eslint-plugin aka eslint-plugin-vitest |
vue | No | eslint-plugin-vue rules that work with script tags |
有关规则覆盖的当前状态,请参阅 linter 产品计划问题。
🌐 For the current status of rule coverage, see the linter product plan issue.
添加新插件
🌐 Adding new plugins
Oxlint 通过内置插件和兼容 ESLint 的 JavaScript 插件来支持生态系统。鼓励向现有内置插件添加规则的贡献。
🌐 Oxlint focuses on supporting the ecosystem through built-in plugins and ESLint-compatible JavaScript plugins. Contributions that add rules to existing built-in plugins are encouraged.
如果你认为某个规则集应该作为内置插件实现,请先在 GitHub 上发起讨论。
🌐 If you think a rule set should be implemented as a built-in plugin, please open a GitHub discussion first.
