react-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseReact Review
React代码审查
Operator-invoked review for React code ( / / containing hooks or JSX). Mechanical fixes land unstaged; the operator stages.
.tsx.jsx.ts由操作者触发的React代码(包含hooks或JSX的 / / 文件)审查。机械性修复会直接应用但不暂存,由操作者自行决定是否暂存。
.tsx.jsx.tsSource of Truth
参考标准
Before judging or fixing, read . It defines severity, categories, fix policy, checklist, and output format.
references/react-rubric.md在判断或修复代码前,请阅读。该文档定义了问题严重程度、分类、修复规则、检查清单及输出格式。
references/react-rubric.mdReviewer 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
工作流程
- 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'
- If no React/TS files are in scope, stop and recommend for non-React files.
pre-commit-review - Resolve the target React major: if set, else the version from
.turkit.yaml → review.react.min_version, else defaultpackage.json. Then:19- installed React < the target (default 19): stop unless this is explicitly a migration review
- 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)
review.react.min_version - unknown version: continue generic review but do not apply React 19-only auto-fixes; report uncertainty
- Resolve the React mechanical gate:
.turkit.yaml → commands.react_review- package script ,
react-review, orreact:reviewreact-doctor - fallback
npx -y react-doctor@latest . --diff --verbose
- Prefer a project-pinned gate. If using fallback, report that it is unpinned and recommend adding or a package script.
commands.react_review - Run the resolved gate. If unavailable, continue and report "react-doctor unavailable".
- Walk the React rubric in order. Do not duplicate gate findings on the same line unless extra context matters.
- Apply only the rubric's Auto-fix bucket. Do not stage or commit.
- Re-run the project's lint command and the resolved React gate after auto-fixes.
- Report using the React rubric output format.
- 确定审查范围:
- 如果操作者提供了文件列表,则使用该列表
- 否则使用
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'
- 如果范围内没有React/TS文件,则停止审查,并建议对非React文件使用。
pre-commit-review - 确定目标React主版本:如果已配置则使用该版本,否则从
.turkit.yaml → review.react.min_version获取版本,默认使用package.json。之后:19- 已安装的React版本低于目标版本(默认19):除非是明确的迁移审查,否则停止审查
- 设置低于19:保留结构/hooks/数据流检查,但不应用仅React 19支持的API自动修复(参考审查准则中的严格性配置)
review.react.min_version - 版本未知:继续通用审查,但不应用仅React 19的自动修复,并报告版本不确定的情况
- 确定React机械检查关卡:
.turkit.yaml → commands.react_review- 包脚本、
react-review或react:reviewreact-doctor - 备选方案:
npx -y react-doctor@latest . --diff --verbose
- 优先使用项目固定版本的检查工具。如果使用备选方案,需报告其未固定版本,并建议添加或包脚本。
commands.react_review - 运行确定的检查关卡。如果工具不可用,则继续审查并报告“react-doctor unavailable”。
- 按顺序执行React审查准则。除非需要额外上下文,否则不要重复报告同一行的检查关卡已发现的问题。
- 仅应用审查准则中“自动修复”类别的修复,不要暂存或提交。
- 自动修复后,重新运行项目的lint命令和确定的React检查关卡。
- 按照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 for operator-facing language/style.
references/output-preferences.md
- 仅处理React代码;非React代码差异请转至。
pre-commit-review - 永远不要编辑当前范围外的内容。
- 永远不要格式化整个文件;信任项目的格式化工具。
- 在自动修复模式下,永远不要修改公共props的签名。
- 如果不确定应自动修复还是标记为需要手动修改,选择标记为需要手动修改。
- 面向操作者的语言/风格需遵循。
references/output-preferences.md