react-doctor README

项目的 README,来自 github.com/millionco/react-doctor。合并为一个 markdown 文件:README.md。

React Doctor

version downloads

React Doctor runs deterministic checks on your code. It reports issues in state and effects, performance, architecture, security, accessibility, and maintainability.

Supports React projects built with Next.js, Vite, Astro, TanStack, React Native, and Expo.

Documentation →

Install

1. Run a scan

Run this command from your project root:

npx react-doctor@latest

https://github.com/user-attachments/assets/07cc88d9-9589-44c3-aa73-5d603cb1c570

2. Install for agents

Install the skill to help your coding agent find and fix React issues:

npx react-doctor@latest install

Supports coding agents including Claude Code, Cursor, Codex, and OpenCode.

3. Run in CI

Scan each pull request and report the issues it introduces:

npx react-doctor@latest ci install

When a Git comparison cannot verify Stencil JSX compiler settings, it skips baseline attribution for uncertain class findings. The CLI names the affected paths on stderr in JSON mode. Other findings still count toward the CI gate.

CI docs →

4. Configure rules

Choose rules and scan settings in doctor.config.ts.

With customRulesOnly: true, explicit rules settings of "warn" or "error" enable selected ported rules. Legacy rule names also work. Other ported rules and the React Compiler plugin stay off.

Mixed classic and automatic JSX projects can use automaticJsxRuntimeFiles to tell the opt-in JSX scope rule which exact project-relative paths use the automatic transform.

For a component that renders a fixed list supplied by its caller, you can declare a specific prop path in fixedIndexKeyLists. React Doctor checks the exact file, component export, and prop path and still reports index keys on other lists. Use this only when the length and the item at each position stay fixed for each mounted component instance.

{
  "fixedIndexKeyLists": [
    { "file": "src/Banner.tsx", "componentExport": "default", "propPath": ["banner", "labels"] }
  ]
}

The rule recognizes direct maps to text-only span elements whose position depends on the index.

Configuration docs →

Runtime performance traces

Record a Chrome DevTools performance trace while you interact with a running React app:

npx react-doctor@latest scan http://localhost:3000

Runtime trace docs →

Telemetry

The CLI collects crash reports and anonymous usage data. See Data use for details.

To opt out, run: npx react-doctor@latest --no-telemetry

Contributing

Report an issue

MIT-licensed

react-doctor (millionco/react-doctor)

正在搜索数据库…

这是什么?React Doctor 是一个代码审查工具,用来扫描 React 代码中 AI 编程代理容易引入的那类错误,让不良写法在上线前就被发现。
这是 linter,还是更大的东西?它更像一个专门的诊断型 linter(即“doctor”式检查),专注于 React 特有的反模式,而不是通用框架或完整的代码格式化工具。
怎么把它跑起来?克隆这个单体仓库,用 'pnpm install' 安装依赖,再用 'pnpm build' 构建;该包自身的开发循环通过 Turborepo 运行,命令是 'turbo run dev --filter=react-doctor'。
开始之前需要先装什么?需要 Node.js 20.19+(或 22.13+)和 pnpm 8+,这些要求写在项目的 engines 字段里。
CI 里会自动运行它吗?仓库里有一个专门的 react-doctor.yml GitHub Actions 工作流,看起来是打算接入 CI 流水线,在每次改动时标记问题。
为什么叫“doctor”?和 flutter doctor 之类的“doctor”工具一样,它是诊断代码库中的问题,而不只是重新格式化代码。
它是单独一个包,还是更大整体的一部分?它是一个包(packages/react-doctor),位于一个更大的 pnpm/Turborepo 单体仓库中,该仓库还包含性能基准测试脚本。
作者
millionco
大小
128.7 MB
星标
15.2K
时长
9个月
提交 · 90 天