setup-react-doctor

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Setup React Doctor

配置React Doctor

What This Sets Up

配置内容

  • react-doctor package for codebase health scoring (0-100)
  • doctor
    package.json script
  • react-doctor.config.json
    disabling biome-overlapping rules
  • Stop hook running doctor on changed files, failing on score drop
  • react-doctor 包:用于代码库健康度评分(分值范围0-100)
  • doctor
    package.json脚本
  • react-doctor.config.json
    配置文件,禁用与biome重叠的规则
  • Stop钩子:文件变更时运行doctor检查,评分下降时直接报错终止

Steps

步骤

1. Install

1. 安装

bash
bun add -D react-doctor --yarn
bash
bun add -D react-doctor --yarn

2. Add package.json script

2. 添加package.json脚本

json
{
  "scripts": {
    "doctor": "react-doctor ."
  }
}
json
{
  "scripts": {
    "doctor": "react-doctor ."
  }
}

3. Create
react-doctor.config.json

3. 创建
react-doctor.config.json

json
{
  "ignore": {
    "rules": [
      "react-hooks/exhaustive-deps",
      "react/no-nested-component"
    ]
  }
}
json
{
  "ignore": {
    "rules": [
      "react-hooks/exhaustive-deps",
      "react/no-nested-component"
    ]
  }
}

4. Create Stop hook script

4. 创建Stop钩子脚本

Copy
scripts/react-doctor-stop.sh
into
.claude/hooks/
. Make executable.
scripts/react-doctor-stop.sh
复制到
.claude/hooks/
目录下,赋予可执行权限。

5. Configure hook in
.claude/settings.json

5. 在
.claude/settings.json
中配置钩子

Add to hooks config: Stop:
.claude/hooks/react-doctor-stop.sh
在钩子配置中添加以下内容:Stop:
.claude/hooks/react-doctor-stop.sh

6. Codex compatibility (optional)

6. Codex兼容(可选)

If the project also uses OpenAI Codex, run
codex-compat
to generate
.codex/hooks.json
from the Claude Code config.
如果项目同时使用OpenAI Codex,运行
codex-compat
命令基于Claude Code配置生成
.codex/hooks.json
文件。

7. Verify & Commit

7. 验证与提交

  • bun run doctor
    works
  • react-doctor.config.json
    exists
  • Stop hook is executable
Commit:
Add react-doctor health scoring with Stop hook
  • bun run doctor
    可正常执行
  • react-doctor.config.json
    文件已存在
  • Stop钩子已具备可执行权限
提交信息:
Add react-doctor health scoring with Stop hook