code-standards

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Code Standards

代码规范

Write code that is accessible, performant, type-safe, and maintainable.
编写具备可访问性、高性能、类型安全且可维护的代码。

Activation Conditions

适用场景

  • Linting errors need fixing
  • Code formatting issues
  • Code review feedback
  • Questions about style guidelines
  • 需要修复Linting错误
  • 存在代码格式问题
  • 收到代码评审反馈
  • 对风格指南存在疑问

Quick Reference

快速参考

ActionRule
Write components
react-functional-only.md
Async code
async-await-promises.md
Avoid legacy libs
no-legacy.md
any
types and top-level regex are enforced by Biome (
noExplicitAny
,
useTopLevelRegex
).
操作对应规则
编写组件
react-functional-only.md
异步代码
async-await-promises.md
避免使用遗留库
no-legacy.md
any
类型和顶层正则表达式由Biome强制校验(对应规则为
noExplicitAny
useTopLevelRegex
)。

Commands

命令

bash
bun x ultracite fix     # Format and fix
bun x ultracite check   # Check for issues
bun x ultracite doctor  # Diagnose setup
bash
bun x ultracite fix     # Format and fix
bun x ultracite check   # Check for issues
bun x ultracite doctor  # Diagnose setup

Quick Fix

快速修复

Most issues are auto-fixed:
bash
bun x ultracite fix
大部分问题都支持自动修复:
bash
bun x ultracite fix

Console Logging

控制台日志规则

  • Never use
    console.log
    ,
    console.debug
    , or
    console.info
    in production code
  • Only use
    console.error
    and
    console.warn
    for actionable errors
  • For debug logging, wrap in
    if (IsDev) { ... }
  • Don't use
    biome-ignore
    to suppress console warnings - remove the logs instead
  • 严禁在生产代码中使用
    console.log
    console.debug
    console.info
  • 仅可使用
    console.error
    console.warn
    记录可处理的错误
  • 调试日志需要包裹在
    if (IsDev) { ... }
    代码块中
  • 不要使用
    biome-ignore
    抑制控制台警告,应当直接移除相关日志

Rules

详细规则

See
rules/
directory for detailed guidance.
查看
rules/
目录获取详细指引。