Skip to content

Oxlint 导入插件阿尔法版

我们很高兴宣布 oxlint --import-plugin 的阿尔法版本发布,这是 eslint-plugin-import 的移植版本。

该移植旨在解决 eslint-plugin-import 所有已知的问题:

发布内容有哪些?

本次阿尔法版本在项目使用 ESM(ECMAScript 模块)的情况下预期可正常工作。

如果需要通过 tsconfig.compilerOptions.paths 使用路径别名(例如 @/foo),可以使用 --tsconfig 选项:

npx oxlint@latest --tsconfig ./tsconfig.json --import-plugin

通过 npx oxlint@latest --import-plugin 默认启用的规则包括:

可以通过 npx oxlint@latest --import-plugin -D rule-name 选择性启用的规则包括:

这些规则也进行了改进;例如,no-cycle 规则的诊断信息已优化:

 ⚠ eslint-plugin-import(no-cycle): 检测到依赖循环
   ╭─[apps/web/playwright/lib/fixtures.ts:13:42]
12 │ import { createPaymentsFixture } from "../fixtures/payments";
13 │ import { createBookingPageFixture } from "../fixtures/regularBookings";
   ·                                          ─────────────────────────────
14 │ import { createRoutingFormsFixture } from "../fixtures/routingForms";
   ╰────
 帮助:以下路径构成一个循环:
       -> ../fixtures/regularBookings - apps/web/playwright/fixtures/regularBookings.ts
       -> ./users - apps/web/playwright/fixtures/users.ts
       -> ../lib/testUtils - apps/web/playwright/lib/testUtils.ts
       -> ./fixtures - apps/web/playwright/lib/fixtures.ts

这并非一个庞大的功能列表,
但由于当前生态系统状态的复杂性,实现这些规则并确保其正确运行仍需大量投入。

在过去六个月中,我们在业余时间持续工作,并成功完成了 --import-plugin 正常运行所需的所有前置条件:

我该如何帮忙?

如果你是项目维护者(即配置工程师),但没有时间或精力持续更新 ESLint 及其所有插件,
你可以参考 @brooooooklyn 的做法,在他所有项目中 用 oxlint 替换 ESLint

如果你是开源爱好者,愿意贡献力量,欢迎加入我们的 discord 社区交流,查看 linter 产品规划与进度问题,或通过 提出新规则建议 来帮助推进被延期的功能。

如果你是工程经理,或有意将你的项目迁移到 oxlint(目前已有 330 条规则且持续增长),以降低基础设施成本,
你可考虑 赞助,以便我们优先支持你的项目。

请记住,oxlint 目前仍由社区驱动。我相信只要有足够的资源,我们将在未来几个月内让 --import-plugin 实现广泛可用。


要开始使用 oxlint,请参阅 安装指南 或了解更多关于 oxc 项目 的信息。