Skip to content

本文宣布 Oxlint 的首次正式版(General Availability)发布。 如需了解功能更多、改进显著的最新稳定版本,请参见 Oxlint v1.0 稳定版发布公告

我们非常高兴地宣布,oxlint 现已正式发布!这一里程碑标志着我们的团队能够迅速处理和分类问题。

🌐 We are thrilled to announce that oxlint is now generally available! This milestone signifies our team's ability to promptly address and triage issues.

Oxlint 是一个 JavaScript 代码检查工具,旨在在默认情况下无需任何配置就能捕捉错误或无用的代码。

🌐 Oxlint is a JavaScript linter designed to catch erroneous or useless code without requiring any configurations by default.

如何使用

🌐 How to Use

在这个阶段,oxlint 并不打算完全替代 ESLint;它在 ESLint 速度成为工作流程瓶颈时,作为一种增强工具使用。

🌐 At this stage, oxlint is not intended to fully replace ESLint; it serves as an enhancement when ESLint's slowness becomes a bottleneck in your workflow.

为了更快地获得反馈,我们建议在 lint-staged 或 CI 设置中先运行 oxlint 再运行 ESLint,因为即使在大型代码库上,它运行也只需几秒钟。

🌐 For faster feedback loops, we recommend running oxlint before ESLint in your lint-staged or CI setup, considering it only takes a few seconds to run on large codebases.

要在你的 JavaScript / TypeScript 代码库中测试 oxlint,只需在仓库的根目录执行以下命令:

🌐 To test oxlint in your JavaScript / TypeScript codebase, simply execute the following command at the root directory of your repository:

sh
$ npx oxlint@latest
sh
$ pnpm dlx oxlint@latest
sh
$ yarn dlx oxlint@latest
sh
$ bunx oxlint@latest
sh
$ deno run npm:oxlint@latest

或者,请参考安装指南获取详细说明。

🌐 Alternatively, refer to the installation guide for detailed instructions.

设计

🌐 Design

比 ESLint 快 50-100 倍

🌐 50-100 Times Faster than ESLint

在现实世界的场景中,Shopify 报告称,他们的 75 分钟 CI ESLint 运行现在只需 10 秒。

🌐 In real-world scenarios, Shopify reported that their 75 CI minutes ESLint run is now only 10 seconds.

来自 Jason Miller,Shopify DX 和 Preact 创始人:

🌐 From Jason Miller, Shopify DX and creator of Preact:

oxlint 对我们在 Shopify 来说是一个巨大的胜利。我们之前的 lint 配置需要 75 分钟才能运行完,因此我们在 CI 中将其分发到 40 多个工作节点上。

相比之下,oxlint 在单个工作节点上对相同代码库进行 lint 只需大约 10 秒,并且输出更易于理解。

当我们迁移时,我们甚至发现了一些之前的配置隐藏或跳过的错误!

大部分性能提升源于 Oxlint 的性能设计目的性,采用 Rust 和并行处理作为关键因素。

🌐 The majority of the performance gains stem from Oxlint being purposefully designed for performance, utilizing Rust and parallel processing as key factors.

检查正确性

🌐 Lint for Correctness

Oxlint 默认会识别错误的、多余的或令人困惑的代码——优先保证正确性,而不是过度挑剔的规则(归类为 perfsuspiciouspedanticstyle),这些规则默认是禁用的。

🌐 Oxlint defaults to identifying erroneous, redundant, or confusing code — prioritizing correctness over unnecessary nitpicking rules (categorized as perf, suspicious, pedantic, or style), which are disabled by default.

易用性

🌐 Ease of Use

建立新的 JavaScript / TypeScript 代码库变得越来越复杂。你的工具之间很可能会出现兼容性问题,这可能导致浪费数小时的时间。

🌐 Setting up new JavaScript / TypeScript codebases is becoming increasingly complex. There's a high likelihood of encountering compatibility issues among your tools, potentially resulting in hours of wasted time.

这就是为什么我们设计 Oxlint 时开箱即用,无需任何配置;甚至连 Node.js 都不是必需的。大多数调整可以通过命令行进行,目前正在开发从 ESLint 配置文件读取的功能。

🌐 That's why we designed oxlint to be zero-config out of the box; even Node.js is not a requirement. Most adjustments can be made through the command-line, and reading from an ESLint configuration file is currently in progress.

增强型诊断

🌐 Enhanced Diagnostics

理解 linter 消息可能很有挑战性。Oxlint 旨在通过找出根本原因并提供有用的消息来简化这一过程——无需阅读冗长的规则文档,从而节省宝贵的时间。

🌐 Understanding linter messages can be challenging. Oxlint aims to simplify this by pinpointing root causes and providing helpful messages — eliminating the need for lengthy rule documentation reading, saving valuable time.

vscode 仓库 中运行 oxlint -D perf

🌐 Running oxlint -D perf in the vscode repository:

合并规则

🌐 Consolidated Rules

Oxlint 目前还没有提供插件系统,但我们正在积极整合来自流行插件的规则,例如 TypeScript、React、Jest、Unicorn、JSX-a11y 和 Import。

🌐 Oxlint does not provide a plugin system yet, but we are actively consolidating rules from popular plugins like TypeScript, React, Jest, Unicorn, JSX-a11y and Import.

我们认识到插件在 JavaScript 生态系统中的重要性,并且也在研究基于 DSL 的插件系统。

🌐 We recognize the importance of plugins in the JavaScript ecosystem and are also investigating a DSL-based plugin system.

然而,你可能会喜欢独立的代码检查工具——无需管理插件依赖列表,处理兼容性问题,或由于版本限制而求助于分支插件

🌐 However, you might appreciate a standalone linter — no need to manage a list of plugin dependencies, navigate through compatibility issues, or resort to forked plugins due to version constraints.


祝你代码检查顺利,节日快乐!

🌐 Happy linting and have a joyful holiday season!

要开始,请遵循 安装指南,了解更多关于 oxc 项目 的信息,或在 Hacker News 上讨论。

🌐 To get started, follow the installation guide, learn more about the oxc project, or discuss on Hacker News.