此迁移指南适用于较旧版本的 Oxlint。 有关最新稳定版本 v1.0 的信息,请参见 Oxlint v1.0 稳定版公告。
Oxlint v0.10.0 发布了!此版本包含几个令人兴奋的新功能,包括对配置文件的多项改进。
🌐 Oxlint v0.10.0 is here! This release includes several exciting features, including many improvements to configuration files.
新功能
🌐 New Features
新规则
🌐 New Rules
此版本包括以下新规则:
🌐 This release includes the following new rules:
promise/no-callback-in-promisereact/iframe-missing-sandboxnode/no-new-require
并为以下内容添加自动修复/建议:
🌐 And adds auto fixes/suggestions for:
eslint/no-plusplus
按类别启用/禁用规则
🌐 Enable/Disable Rules by Category
现在,你可以在配置文件中的 categories 字段启用或禁用整个规则类别。
🌐 You can now enable or disable entire categories of rules with the categories field inside of your configuration file.
现在,不是运行这个命令:
🌐 Now, instead of running this command:
oxlint -D correctness -W suspicious -c oxlint.json你可以在你的 oxlint.json 中添加一个 categories 字段:
🌐 You can add a categories field to your oxlint.json:
{
"categories": {
"correctness": "deny",
"suspicious": "warn",
},
"rules": {
"no-const-assign": "error",
"import/no-cycle": "error",
},
}并去掉 -D 和 -W 标志。
🌐 and drop the -D and -W flags.
plugins 现在支持在配置文件中使用
🌐 plugins Are Now Supported in Configuration Files
配置文件现在支持来自 ESLint v8 配置的 plugins 数组。这使你可以在不使用命令行参数的情况下启用插件,从而可以在 VSCode 中使用插件。
🌐 Configuration files now support the plugins array from ESLint v8 configs. This allows you to enable plugins without CLI arguments, making it possible to use plugins in VSCode.
{
"plugins": ["import"],
"categories": {
"correctness": "deny",
"suspicious": "warn",
},
"rules": {
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
},
}这与 categories 配合得很好,因为启用/禁用的类别也会影响插件。
🌐 This plays nicely with categories, as enabled/disabled categories affect plugins as well.
{
"plugins": ["import"],
// `categories` affects all enabled plugins
"categories": {
"correctness": "allow",
"suspicious": "warn",
},
"rules": {
"no-const-assign": "error",
"import/no-cycle": "error",
},
}重大更改与迁移指南
🌐 Breaking Changes and Migration Guide
CLI 与配置文件规则优先级
🌐 CLI vs Config File Rule Priority
以前,配置文件会覆盖在命令行参数中设置的规则。例如,运行以下命令:
🌐 Before, config files would override rules set in CLI arguments. For example, running this command:
oxlint -A correctness -c oxlintrc.json使用这个配置文件
🌐 With this config file
{
"rules": {
"no-const-assign": "error",
},
}将导致只有一个规则 no-const-assign 在错误级别被启用,而所有其他规则都被禁用(即设置为“允许”)。
🌐 Would result in a single rule, no-const-assign being turned on at an error level with all other rules disabled (i.e. set to "allow").
现在,命令行参数将覆盖配置文件。使用相同配置文件的相同命令将导致所有规则被禁用。如果想要获得之前的行为,请在配置文件中启用或禁用类别,而不是通过命令行参数。
🌐 Now, CLI arguments will override config files. That same command with the same config file will result with all rules being disabled. To get the same behavior as before, enable and disable categories in your config file instead of with CLI arguments.
oxlint -c oxlint.json{
"categories": {
"correctness": "allow",
},
"rules": {
"no-const-assign": "error",
},
}