OXC formatter config preset for aplus team.
npm install @aplus-frontend/oxfmt-config🚀 Ultra-fast OXC Formatter config preset for Aplus frontend team
基于 Rust 编写的高性能代码格式化工具配置预设
- ⚡️ 极速格式化 - 基于 Rust 的 OXC 引擎,比 Prettier 快 10-50 倍
- 🎯 零配置 - 开箱即用的团队统一配置
- 📦 轻量级 - 无需安装 Prettier 及其插件
- 🔧 兼容性好 - 支持 JavaScript、TypeScript、Vue、React 等
``bash`只需安装这一个包,无需 prettier
pnpm add @aplus-frontend/oxfmt-config -D
`bash`只需安装这一个包,无需 prettier
pnpm add @aplus-frontend/oxfmt-config -D
在 package.json 中添加:
`json`
{
"scripts": {
"format": "oxfmt",
"format:check": "oxfmt --check"
}
}
> 注意:包内已包含 oxfmt 可执行文件和配置,无需额外安装或配置。
`bash格式化所有文件(默认)
pnpm format
⚙️ 配置选项
此预设包含以下配置:
| 选项 | 值 | 说明 |
|------|-----|------|
|
printWidth | 80 | 每行最大字符数 |
| indentWidth | 2 | 缩进宽度 |
| useTabs | false | 使用空格而非制表符 |
| semicolons | always | 始终使用分号 |
| singleQuote | true | 使用单引号 |
| trailingComma | none | 不使用尾随逗号 |
| bracketSpacing | true | 对象字面量括号内有空格 |
| arrowParens | true | 箭头函数参数总是使用括号 |🔄 从 Prettier 迁移
如果你正在从
@aplus-frontend/prettier-config 迁移:$3
- ✅ 格式化速度提升 10-50 倍
- ✅ 更小的依赖体积
- ✅ 更快的安装速度
- ✅ 配置完全兼容$3
1. 卸载 Prettier 相关依赖:
`bash
pnpm remove prettier @aplus-frontend/prettier-config
`2. 安装 OXC Formatter 配置:
`bash
pnpm add @aplus-frontend/oxfmt-config -D
`3. 更新配置文件(删除
.prettierrc,创建 .oxc.json)4. 更新 package.json 脚本:
`json
{
"scripts": {
"format": "oxc format --write .",
"format:check": "oxc format --check ."
}
}
`📚 更多信息
📄 License
MIT © Aplus Frontend Team
``