개요
React Doctor 是一款 CLI 工具,可扫描 React 代码库并生成 0-100 的健康评分与可操作诊断。它检查状态、性能、可访问性、安全性和死代码,支持 Next.js、Vite 和 React Native。它可集成到 CI/CD 管道和编程代理中,以强制实施最佳实践。
README 미리보기
\n \n \n \n\n\n[](https://npmjs.com/package/react-doctor)\n[](https://npmjs.com/package/react-doctor)\n\nYour agent writes bad React, this catches it.\n\nOne command scans your codebase and outputs a **0 to 100 health score** with actionable diagnostics.\n\nWorks with Next.js, Vite, and React Native.\n\n### [See it in action →](https://react.doctor)\n\n## Install\n\nRun this at your project root:\n\n```bash\nnpx -y react-doctor@latest .\n```\n\nYou'll get a score (75+ Great, 50 to 74 Needs work, under 50 Critical) and a list of issues across state & effects, performance, architecture, security, accessibility, and dead code. Rules toggle automatically based on your framework and React version.\n\nhttps://github.com/user-attachments/assets/07cc88d9-9589-44c3-aa73-5d603cb1c570\n\n## Install for your coding agent\n\nTeach your coding agent React best practices so it stops writing the bad code in the first place.\n\n```bash\nnpx -y react-doctor@latest install\n```\n\nYou'll be prompted to pick which detected agents to install for. Pass `--yes` to skip prompts.\n\nWorks with Claude Code, Cursor, Codex, OpenCode, and 50+ other agents.\n\n## GitHub Actions\n\nA composite action ships with this repository. Drop it into `.github/workflows/react-doctor.yml`:\n\n```yaml\nname: React Doctor\n\non:\n pull_request:\n push:\n branches: [main]\n\npermissions:\n contents: read\n pull-requests: write # required to post PR comments\n\njobs:\n react-doctor:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v5\n with:\n fetch-depth: 0 # required for `diff`\n - uses: millionco/react-doctor@main\n with:\n diff: main\n github-token: ${{ secrets.GITHUB_TOKEN }}\n```\n\nWhen `github-token` is set on `pull_request` events, findings are posted (and updated) as a PR comment. The action also exposes a `score` output (0–100) you can use in subsequent steps.\n\n**Inputs:** `directory`, `verbose`, `project`, `diff`, `githFAQ (4)
문제 해결왜 react-doctor의 unused-file 규칙이 Windows에서 거의 모든 파일을 사용되지 않는 것으로 표시하나요?
이는 deslop-js가 Windows에서 경로 구분자 불일치로 인해 발생하는 알려진 버그입니다 (백슬래시 대신 슬래시를 사용하여 import 그래프 간선이 누락됨). 해당 수정 사항은 deslop-js main 브랜치에 병합되었으며(PR #16), 다음 react-doctor 릴리스에 포함될 예정입니다. 그때까지 임시 해결책으로 WSL 또는 Unix 환경에서 react-doctor를 실행하거나, millionco/deslop-js#16에서 패치를 수동으로 적용하십시오.
문제 해결대화형 CLI 체크리스트에서 모든 항목을 선택하는 방법은?
'a' 키를 눌러 현재 목록의 모든 옵션을 선택하거나 선택 해제합니다. 이 키보드 단축키는 대화형 인터페이스에서 작동합니다.
securityGitHub Actions 워크플로우에서 @main 브랜치를 사용하는 것이 보안 위험인가요? 그리고 액션을 안전하게 pin하는 방법은 무엇인가요?
네, @main과 같은 변경 가능한 브랜치로 액션을 참조하면 상위 리포지토리가 손상되었을 때 공급망 공격이 가능합니다. 대신 특정 릴리스 태그(예: @v1.2.3)나 전체 커밋 SHA로 고정하세요. react-doctor의 경우 @main 대신 uses: millionco/react-doctor@<tag-or-sha>를 사용하세요.
문제 해결npx react-doctor@latest를 실행할 때 'Cannot find package 'oxc-parser'' 오류를 수정하는 방법?
이 버그는 react-doctor@0.2.14에 영향을 미치며, oxc-parser가 dependencies 대신 devDependencies에 잘못 나열되어 있습니다. 해결 방법: react-doctor를 실행하기 전에 프로젝트에 oxc-parser를 수동으로 설치합니다(npm install oxc-parser 또는 pnpm add oxc-parser). 또는 react-doctor@0.2.3 이하로 다운그레이드하세요. 영구 수정을 위해 issue #629를 추적하세요.