"格式化太慢?Lint 卡到爆?不,我们全都要。" ------ 尤雨溪
一条推文,前端圈炸锅
10 月 19 日
下午,Vue.js
作者尤雨溪 在 Twitter
甩出一张截图:
- oxfmt 比
Biome
快 2--3 倍 - 比
Prettier
快 45 倍 - 比
Biome
更贴合 Prettier 规范 - 已跑通
Vite
、Vue
、AntDesign
、Supabase
等 亿级代码库 - "即将可用,直接平替 Prettier!"
配图最后一句话,才是核弹:
"还有一些情况我们故意与 Prettier 不同。"
ESLint 也一起被"斩"?
等等,ESLint
呢?
别急,Oxlint
早已埋伏多时:
工具 | 职责 | 替代目标 | 性能倍数 |
---|---|---|---|
oxfmt | 代码格式化 | Prettier | 45× |
oxlint | 代码检查 | ESLint | 50--100× |
Oxlint
规则已覆盖 200+ 条 ESLint 核心与社区推荐规则 ,并支持 --fix
自动修复。
在 Vite
、Rollup
、Vue-core
的 CI 里,ESLint 全程没启动 ,Oxlint 0
秒跑完。
为什么要"弃用"?
-
速度 = 生产力
本地
save
秒级反馈,CI 从 3 min → 5 s,老板都忍不住点赞。 -
兼容 ≈ 零迁移
oxfmt
与Prettier
快照测试 99.7% 一致 ;
oxlint
提供 eslint-compat 插件,老配置直接导入。 -
可扩展 > 老生态
基于
Rust
的WASM
插件,冷启动 <10 ms,不再被 Node 单线程卡死。 -
改进,而不是迁就
对于带注释的
TS
联合类型,Prettier
会"对不齐",oxfmt
主动修正 。尤雨溪直言:"不是固执,是 Prettier 真的错了。"
迁移指南
1. 一键卸载老伙伴
bash
npm uninstall prettier eslint eslint-config-xxx eslint-plugin-xxx
2. 安装 OXC 全家桶
bash
npm i -D oxc-cli
# 或
pnpm add -D oxc-cli
3. 配置 oxc.config.js
js
export default {
formatter: { enable: true, semi: false, tabWidth: 2 },
linter: {
enable: true,
rules: { import: { noCycle: 'error' } }
}
}
4. 脚本替换
json
{
"scripts": {
"fmt": "oxc fmt",
"lint": "oxc lint",
"lint:fix": "oxc lint --fix"
}
}
5. GitHub Actions 示例
yaml
- name: Lint & Format
run: |
npx oxc fmt --check
npx oxc lint
写在最后
十年前,Grunt
→ Gulp
→ Webpack
五年前,Rollup
→ Vite
今天,ESLint + Prettier → OXC
尤雨溪又一次把"不可能"写成 PR 标题:
"feat: retire eslint & prettier"
准备好迎接 0 秒 lint、0 秒 format 的新时代了吗?
OXC 官网/仓库 :https://github.com/oxc-project/oxc