react-review

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

React Review

React代码审查

Operator-invoked review for React code (
.tsx
/
.jsx
/
.ts
containing hooks or JSX). Mechanical fixes land unstaged; the operator stages.
由操作者触发的React代码(包含hooks或JSX的
.tsx
/
.jsx
/
.ts
文件)审查。机械性修复会直接应用但不暂存,由操作者自行决定是否暂存。

Source of Truth

参考标准

Before judging or fixing, read
references/react-rubric.md
. It defines severity, categories, fix policy, checklist, and output format.
在判断或修复代码前,请阅读
references/react-rubric.md
。该文档定义了问题严重程度、分类、修复规则、检查清单及输出格式。

Reviewer Mindset

审查者准则

The bar is clean, minimal, DRY, SOC-respecting React 19+ code.
  • Effects are for synchronizing with external systems. Derived values and user-action work usually do not belong in
    useEffect
    .
  • Render files render; hooks orchestrate; utils compute.
  • Severity follows the render path: a finding on hot-path code (per keystroke, per list row, per frame) outranks the same finding on a rarely-mounted surface.
  • React-specific structural violations block merge unless the operator explicitly accepts an exception.
  • Do not normalize legacy patterns just because the surrounding file already has them.
目标是产出简洁、精简、DRY、符合SOC原则的React 19+代码。
  • useEffect仅用于与外部系统同步。派生值和用户操作逻辑通常不应放在
    useEffect
    中。
  • 渲染文件仅负责渲染;hooks负责协调逻辑;工具函数负责计算。
  • 问题严重程度遵循渲染路径:热路径代码(如按键响应、列表行、每一帧)中的问题,优先级高于极少挂载的页面中的同类问题。
  • React特定的结构违规会阻止代码合并,除非操作者明确接受例外情况。
  • 不要因为当前文件已有遗留模式就妥协,仍需遵循标准。

Workflow

工作流程

  1. Gather scope:
    • operator-supplied file list if provided
    • otherwise
      git diff --name-only HEAD -- '*.tsx' '*.jsx' '*.ts'
    • plus
      git ls-files --others --exclude-standard -- '*.tsx' '*.jsx' '*.ts'
    • for branch scope:
      git diff --name-only <base>..HEAD -- '*.tsx' '*.jsx' '*.ts'
  2. If no React/TS files are in scope, stop and recommend
    pre-commit-review
    for non-React files.
  3. Resolve the target React major:
    .turkit.yaml → review.react.min_version
    if set, else the version from
    package.json
    , else default
    19
    . Then:
    • installed React < the target (default 19): stop unless this is explicitly a migration review
    • review.react.min_version
      set below 19: keep structural/hooks/data-flow checks but do not apply the React-19-only API auto-fixes (see the rubric's Strictness Profiles)
    • unknown version: continue generic review but do not apply React 19-only auto-fixes; report uncertainty
  4. Resolve the React mechanical gate:
    • .turkit.yaml → commands.react_review
    • package script
      react-review
      ,
      react:review
      , or
      react-doctor
    • fallback
      npx -y react-doctor@latest . --diff --verbose
  5. Prefer a project-pinned gate. If using fallback, report that it is unpinned and recommend adding
    commands.react_review
    or a package script.
  6. Run the resolved gate. If unavailable, continue and report "react-doctor unavailable".
  7. Walk the React rubric in order. Do not duplicate gate findings on the same line unless extra context matters.
  8. Apply only the rubric's Auto-fix bucket. Do not stage or commit.
  9. Re-run the project's lint command and the resolved React gate after auto-fixes.
  10. Report using the React rubric output format.
  1. 确定审查范围:
    • 如果操作者提供了文件列表,则使用该列表
    • 否则使用
      git diff --name-only HEAD -- '*.tsx' '*.jsx' '*.ts'
    • 加上
      git ls-files --others --exclude-standard -- '*.tsx' '*.jsx' '*.ts'
    • 分支范围使用:
      git diff --name-only <base>..HEAD -- '*.tsx' '*.jsx' '*.ts'
  2. 如果范围内没有React/TS文件,则停止审查,并建议对非React文件使用
    pre-commit-review
  3. 确定目标React主版本:如果
    .turkit.yaml → review.react.min_version
    已配置则使用该版本,否则从
    package.json
    获取版本,默认使用
    19
    。之后:
    • 已安装的React版本低于目标版本(默认19):除非是明确的迁移审查,否则停止审查
    • review.react.min_version
      设置低于19:保留结构/hooks/数据流检查,但不应用仅React 19支持的API自动修复(参考审查准则中的严格性配置)
    • 版本未知:继续通用审查,但不应用仅React 19的自动修复,并报告版本不确定的情况
  4. 确定React机械检查关卡:
    • .turkit.yaml → commands.react_review
    • 包脚本
      react-review
      react:review
      react-doctor
    • 备选方案:
      npx -y react-doctor@latest . --diff --verbose
  5. 优先使用项目固定版本的检查工具。如果使用备选方案,需报告其未固定版本,并建议添加
    commands.react_review
    或包脚本。
  6. 运行确定的检查关卡。如果工具不可用,则继续审查并报告“react-doctor unavailable”。
  7. 按顺序执行React审查准则。除非需要额外上下文,否则不要重复报告同一行的检查关卡已发现的问题。
  8. 仅应用审查准则中“自动修复”类别的修复,不要暂存或提交。
  9. 自动修复后,重新运行项目的lint命令和确定的React检查关卡。
  10. 按照React审查准则的输出格式生成报告。

Guardrails

约束规则

  • React code only; route non-React diffs to
    pre-commit-review
    .
  • Never edit outside current scope.
  • Never reformat whole files; trust the formatter.
  • Never change public props signatures in auto-fix mode.
  • If unsure between auto-fix and required change, choose required change.
  • Apply
    references/output-preferences.md
    for operator-facing language/style.
  • 仅处理React代码;非React代码差异请转至
    pre-commit-review
  • 永远不要编辑当前范围外的内容。
  • 永远不要格式化整个文件;信任项目的格式化工具。
  • 在自动修复模式下,永远不要修改公共props的签名。
  • 如果不确定应自动修复还是标记为需要手动修改,选择标记为需要手动修改。
  • 面向操作者的语言/风格需遵循
    references/output-preferences.md