Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oxlint #16

Open
bouquetrender opened this issue Jan 23, 2024 · 0 comments
Open

oxlint #16

bouquetrender opened this issue Jan 23, 2024 · 0 comments
Labels

Comments

@bouquetrender
Copy link
Owner

bouquetrender commented Jan 23, 2024

基于 Rust 开发的 Linter 工具,无需 NodeJS 环境。

文档描述在 oxlint 的当前阶段并非要完全替代 ESLint,而是在 ESLint 速度严重过慢时可以有改进的选择。如果是使用这个工具文档是建议在先于 ESLint 运行 oxlint,考虑到它在大型代码库只需要很短时间就能完成运行,oxlint 安装好后立即可以使用不需要任何配置。

配置可以通过命令行获取
npx oxlint@latest --help 获取配置说明(文档 Linter Useful Options 并不是最新的)

image

根据描述得知默认的规则种类是correctness,correctness包含了目前存在的所有规则:

image

例如可以在项目目录直接运行 npx oxlint@latest -D=no-empty-pattern 指定规则测试就可以得到输出,格式友好:

image

安装 vscode 插件 oxc 后会有告警提示(默认correctness规则集,无法修改,不建议安装):

image

如果在项目中使用 oxlint 需要配合 ESLint 安装 eslint-plugin-oxc 并引入进 ESLint 的配置文件,主要是关闭 oxlint 所有的规则,这样就可以先运行 oxlint 再运行 ESLint:

import oxlint from "eslint-plugin-oxlint";

export default [
  ...// 其他插件
  oxlint, // oxlint 应该放在最后
];

如果项目中使用的规则 oxlint 完全支持,则可以使用 oxlint 替代 ESLint。如果规则不完全支持,但又必须要用 oxlint,则可两个共用(需要写两个配置文件),oxlint 的 vscode 插件的 lint 提示无法自定义关闭某个规则,对开发中不是太友好。

链接:
Oxlint General Availability
Linter (oxlint)
github.com/oxc-project/oxc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant