ultracite
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUltracite
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 is in devDependencies. Detect the active linter by looking for:
ultracitepackage.json- → Biome
biome.jsonc - → ESLint
eslint.config.mjs - → Oxlint
.oxlintrc.json
检查的devDependencies中是否包含。通过以下文件判断当前使用的检查器:
package.jsonultracite- → Biome
biome.jsonc - → ESLint
eslint.config.mjs - → Oxlint
.oxlintrc.json
CLI Commands
CLI命令
bash
undefinedbash
undefinedCheck 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 initbash
bunx ultracite init \
--pm bun \
--linter biome \
--editors vscode cursor \
--agents claude copilot \
--frameworks react next \
--integrations husky lint-staged \
--quietFlags:
- —
--pm|npm|yarn|pnpmbun - —
--linter(recommended) |biome|eslintoxlint - —
--editors|vscode|zed|cursor|windsurf|antigravity|kiro|traevoid - —
--agents|claude|codex|copilot|cline|amp|gemini+ 19 morecursor-cli - —
--frameworks|react|next|solid|vue|svelte|qwik|remix|angular|astronestjs - —
--integrations|husky|lefthook|lint-stagedpre-commit - — Enable auto-fix hooks for supported agents/editors
--hooks - — Enable type-aware linting (oxlint only)
--type-aware - — Skip dependency installation
--skip-install - — Suppress prompts (auto-detected when
--quiet)CI=true
Init creates config that extends Ultracite presets:
jsonc
// biome.jsonc
{ "extends": ["ultracite/biome/core", "ultracite/biome/react"] }Framework presets available per linter: , , , , , , , , , , .
corereactnextsolidvuesvelteqwikremixangularastronestjsbunx ultracite initbash
bunx ultracite init \
--pm bun \
--linter biome \
--editors vscode cursor \
--agents claude copilot \
--frameworks react next \
--integrations husky lint-staged \
--quiet参数说明:
- —
--pm|npm|yarn|pnpxbun - —
--linter(推荐) |biome|eslintoxlint - —
--editors|vscode|zed|cursor|windsurf|antigravity|kiro|traevoid - —
--agents|claude|codex|copilot|cline|amp|gemini及其他19种cursor-cli - —
--frameworks|react|next|solid|vue|svelte|qwik|remix|angular|astronestjs - —
--integrations|husky|lefthook|lint-stagedpre-commit - — 为支持的Agent/编辑器启用自动修复钩子
--hooks - — 启用类型感知检查(仅Oxlint支持)
--type-aware - — 跳过依赖安装
--skip-install - — 抑制提示信息(当
--quiet时自动触发)CI=true
初始化会创建继承自Ultracite预设的配置文件:
jsonc
// biome.jsonc
{ "extends": ["ultracite/biome/core", "ultracite/biome/react"] }各检查器均提供对应框架的预设:、、、、、、、、、、。
corereactnextsolidvuesvelteqwikremixangularastronestjsCode 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. by default, never . over . Template literals over concatenation. No enums (use objects with ). No nested ternaries. Kebab-case filenames.
constvarfor...of.forEach()as constCorrectness: No unused imports/variables. No (use ). Always promises in async functions. No // in production.
anyunknownawaitconsole.logdebuggeralertReact: Function components only. Hooks at top level. Exhaustive deps. on iterables (no array index). No nested component definitions. Semantic HTML + ARIA.
keyPerformance: No accumulating spread in loops. No barrel files. No namespace imports. Top-level regex.
Security: on . No . No .
rel="noopener"target="_blank"dangerouslySetInnerHTMLeval()在使用Ultracite的项目中编写代码时,请遵循以下规范。完整规则参考请见references/code-standards.md。
核心规则概览:
格式化规则: 2空格缩进,使用分号,双引号,80字符行宽,ES5尾逗号,LF换行符。
编码风格: 优先使用箭头函数。默认使用,禁止使用。优先而非。优先模板字符串而非字符串拼接。禁止使用枚举(使用声明的对象替代)。禁止嵌套三元表达式。文件名使用短横线命名法(Kebab-case)。
constvarfor...of.forEach()as const正确性规则: 禁止未使用的导入/变量。禁止使用(使用替代)。异步函数中必须 Promise。生产环境禁止使用//。
anyunknownawaitconsole.logdebuggeralertReact规则: 仅使用函数式组件。Hooks需置于顶层。依赖项需完整。可迭代元素需添加(禁止使用数组索引)。禁止嵌套组件定义。使用语义化HTML + ARIA。
key性能规则: 禁止在循环中累加扩展操作。禁止使用桶文件(Barrel files)。禁止使用命名空间导入。正则表达式需定义在顶层。
安全规则: 时需添加。禁止使用。禁止使用。
target="_blank"rel="noopener"dangerouslySetInnerHTMLeval()Troubleshooting
问题排查
Run to diagnose. It checks:
bunx ultracite doctor- Linter installation (biome/eslint/oxlint binary available)
- Config validity (extends ultracite presets correctly)
- Ultracite in package.json dependencies
- Conflicting tools (old ,
.eslintrc.*files).prettierrc.*
Common fixes:
- Conflicting configs: Delete legacy and
.eslintrc.*files after migrating to Ultracite.prettierrc.* - Missing dependency: Run again or manually add
bunx ultracite initto devDependenciesultracite - Rules not applying: Ensure config file extends the correct presets for your framework
运行进行诊断,它会检查以下内容:
bunx ultracite doctor- 检查器安装情况(biome/eslint/oxlint可执行文件是否存在)
- 配置文件有效性(是否正确继承Ultracite预设)
- Ultracite是否在package.json依赖中
- 是否存在冲突工具(旧的、
.eslintrc.*文件).prettierrc.*
常见修复方案:
- 配置冲突:迁移到Ultracite后,删除旧的和
.eslintrc.*文件.prettierrc.* - 依赖缺失:重新运行或手动将
bunx ultracite init添加到devDependenciesultracite - 规则未生效:确保配置文件继承了对应框架的正确预设