ultracite

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Ultracite

Ultracite

Zero-config linting and formatting for JS/TS projects. Supports three linter backends: Biome (recommended), ESLint + Prettier, and Oxlint + Oxfmt.
面向JS/TS项目的零配置代码检查与格式化工具。支持三种检查器后端:Biome(推荐)、ESLint + Prettier,以及Oxlint + Oxfmt。

Detecting Ultracite

检测Ultracite

Check if
ultracite
is in
package.json
devDependencies. Detect the active linter by looking for:
  • biome.jsonc
    → Biome
  • eslint.config.mjs
    → ESLint
  • .oxlintrc.json
    → Oxlint
检查
package.json
的devDependencies中是否包含
ultracite
。通过以下文件判断当前使用的检查器:
  • biome.jsonc
    → Biome
  • eslint.config.mjs
    → ESLint
  • .oxlintrc.json
    → Oxlint

CLI Commands

CLI命令

bash
undefined
bash
undefined

Check for issues (read-only)

检查问题(只读模式)

bunx ultracite check
bunx ultracite check

Auto-fix issues

自动修复问题

bunx ultracite fix
bunx ultracite fix

Diagnose setup problems

诊断配置问题

bunx ultracite doctor
bunx ultracite doctor

Initialize in a new project

在新项目中初始化

bunx ultracite init

Replace `bunx` with `npx`, `pnpx`, or `yarn dlx` depending on the package manager.

`check` and `fix` accept optional file paths: `bunx ultracite check src/index.ts`.
bunx ultracite init

可根据包管理器将`bunx`替换为`npx`、`pnpx`或`yarn dlx`。

`check`和`fix`命令支持传入可选文件路径:`bunx ultracite check src/index.ts`。

Initialization

初始化

bunx ultracite init
runs an interactive setup. For non-interactive (CI) use, pass flags:
bash
bunx ultracite init \
  --pm bun \
  --linter biome \
  --editors vscode cursor \
  --agents claude copilot \
  --frameworks react next \
  --integrations husky lint-staged \
  --quiet
Flags:
  • --pm
    npm
    |
    yarn
    |
    pnpm
    |
    bun
  • --linter
    biome
    (recommended) |
    eslint
    |
    oxlint
  • --editors
    vscode
    |
    zed
    |
    cursor
    |
    windsurf
    |
    antigravity
    |
    kiro
    |
    trae
    |
    void
  • --agents
    claude
    |
    codex
    |
    copilot
    |
    cline
    |
    amp
    |
    gemini
    |
    cursor-cli
    + 19 more
  • --frameworks
    react
    |
    next
    |
    solid
    |
    vue
    |
    svelte
    |
    qwik
    |
    remix
    |
    angular
    |
    astro
    |
    nestjs
  • --integrations
    husky
    |
    lefthook
    |
    lint-staged
    |
    pre-commit
  • --hooks
    — Enable auto-fix hooks for supported agents/editors
  • --type-aware
    — Enable type-aware linting (oxlint only)
  • --skip-install
    — Skip dependency installation
  • --quiet
    — Suppress prompts (auto-detected when
    CI=true
    )
Init creates config that extends Ultracite presets:
jsonc
// biome.jsonc
{ "extends": ["ultracite/biome/core", "ultracite/biome/react"] }
Framework presets available per linter:
core
,
react
,
next
,
solid
,
vue
,
svelte
,
qwik
,
remix
,
angular
,
astro
,
nestjs
.
bunx ultracite init
会启动交互式配置流程。对于非交互式(CI环境)使用,可传入参数:
bash
bunx ultracite init \
  --pm bun \
  --linter biome \
  --editors vscode cursor \
  --agents claude copilot \
  --frameworks react next \
  --integrations husky lint-staged \
  --quiet
参数说明:
  • --pm
    npm
    |
    yarn
    |
    pnpx
    |
    bun
  • --linter
    biome
    (推荐) |
    eslint
    |
    oxlint
  • --editors
    vscode
    |
    zed
    |
    cursor
    |
    windsurf
    |
    antigravity
    |
    kiro
    |
    trae
    |
    void
  • --agents
    claude
    |
    codex
    |
    copilot
    |
    cline
    |
    amp
    |
    gemini
    |
    cursor-cli
    及其他19种
  • --frameworks
    react
    |
    next
    |
    solid
    |
    vue
    |
    svelte
    |
    qwik
    |
    remix
    |
    angular
    |
    astro
    |
    nestjs
  • --integrations
    husky
    |
    lefthook
    |
    lint-staged
    |
    pre-commit
  • --hooks
    — 为支持的Agent/编辑器启用自动修复钩子
  • --type-aware
    — 启用类型感知检查(仅Oxlint支持)
  • --skip-install
    — 跳过依赖安装
  • --quiet
    — 抑制提示信息(当
    CI=true
    时自动触发)
初始化会创建继承自Ultracite预设的配置文件:
jsonc
// biome.jsonc
{ "extends": ["ultracite/biome/core", "ultracite/biome/react"] }
各检查器均提供对应框架的预设:
core
react
next
solid
vue
svelte
qwik
remix
angular
astro
nestjs

Code Standards

代码规范

When writing code in a project with Ultracite, follow these standards. For the full rules reference, see references/code-standards.md.
Key rules at a glance:
Formatting: 2-space indent, semicolons, double quotes, 80-char width, ES5 trailing commas, LF line endings.
Style: Arrow functions preferred.
const
by default, never
var
.
for...of
over
.forEach()
. Template literals over concatenation. No enums (use objects with
as const
). No nested ternaries. Kebab-case filenames.
Correctness: No unused imports/variables. No
any
(use
unknown
). Always
await
promises in async functions. No
console.log
/
debugger
/
alert
in production.
React: Function components only. Hooks at top level. Exhaustive deps.
key
on iterables (no array index). No nested component definitions. Semantic HTML + ARIA.
Performance: No accumulating spread in loops. No barrel files. No namespace imports. Top-level regex.
Security:
rel="noopener"
on
target="_blank"
. No
dangerouslySetInnerHTML
. No
eval()
.
在使用Ultracite的项目中编写代码时,请遵循以下规范。完整规则参考请见references/code-standards.md
核心规则概览:
格式化规则: 2空格缩进,使用分号,双引号,80字符行宽,ES5尾逗号,LF换行符。
编码风格: 优先使用箭头函数。默认使用
const
,禁止使用
var
。优先
for...of
而非
.forEach()
。优先模板字符串而非字符串拼接。禁止使用枚举(使用
as const
声明的对象替代)。禁止嵌套三元表达式。文件名使用短横线命名法(Kebab-case)。
正确性规则: 禁止未使用的导入/变量。禁止使用
any
(使用
unknown
替代)。异步函数中必须
await
Promise。生产环境禁止使用
console.log
/
debugger
/
alert
React规则: 仅使用函数式组件。Hooks需置于顶层。依赖项需完整。可迭代元素需添加
key
(禁止使用数组索引)。禁止嵌套组件定义。使用语义化HTML + ARIA。
性能规则: 禁止在循环中累加扩展操作。禁止使用桶文件(Barrel files)。禁止使用命名空间导入。正则表达式需定义在顶层。
安全规则:
target="_blank"
时需添加
rel="noopener"
。禁止使用
dangerouslySetInnerHTML
。禁止使用
eval()

Troubleshooting

问题排查

Run
bunx ultracite doctor
to diagnose. It checks:
  1. Linter installation (biome/eslint/oxlint binary available)
  2. Config validity (extends ultracite presets correctly)
  3. Ultracite in package.json dependencies
  4. Conflicting tools (old
    .eslintrc.*
    ,
    .prettierrc.*
    files)
Common fixes:
  • Conflicting configs: Delete legacy
    .eslintrc.*
    and
    .prettierrc.*
    files after migrating to Ultracite
  • Missing dependency: Run
    bunx ultracite init
    again or manually add
    ultracite
    to devDependencies
  • Rules not applying: Ensure config file extends the correct presets for your framework
运行
bunx ultracite doctor
进行诊断,它会检查以下内容:
  1. 检查器安装情况(biome/eslint/oxlint可执行文件是否存在)
  2. 配置文件有效性(是否正确继承Ultracite预设)
  3. Ultracite是否在package.json依赖中
  4. 是否存在冲突工具(旧的
    .eslintrc.*
    .prettierrc.*
    文件)
常见修复方案:
  • 配置冲突:迁移到Ultracite后,删除旧的
    .eslintrc.*
    .prettierrc.*
    文件
  • 依赖缺失:重新运行
    bunx ultracite init
    或手动将
    ultracite
    添加到devDependencies
  • 规则未生效:确保配置文件继承了对应框架的正确预设