Quick Start
Add React Doctor to your GitHub Actions workflow:.github/workflows/react-doctor.yml
Action Inputs
string
default:"."
Project directory to scan
boolean
default:"true"
Show file details per rule. Enabled by default in GitHub Actions for better visibility.
string
Workspace project(s) to scan. Comma-separated for multiple projects.
string
Base branch for diff mode (e.g.,
main). Only files changed vs this branch are scanned.string
GitHub token for posting PR comments. When set on
pull_request events, findings are posted as a PR comment.string
default:"error"
Exit with error code on diagnostics:
error, warning, nonestring
default:"20"
Node.js version to use for the scan
Action Outputs
number
Health score (0-100). Available even if the scan fails.
Common Workflows
Basic CI Check
Fail the build if errors are detected:.github/workflows/ci.yml
PR Comments
Automatically post findings as PR comments:.github/workflows/pr-check.yml
The action automatically updates existing comments rather than creating new ones on each run.
Diff Mode for PRs
Scan only changed files in pull requests:.github/workflows/pr-diff.yml
Monorepo Support
Scan specific workspace projects:.github/workflows/monorepo.yml
Score Tracking
Track health scores over time:.github/workflows/score.yml
Multiple Node Versions
Test with different Node.js versions:.github/workflows/matrix.yml
Advanced Configuration
Conditional Execution
Run only on specific file changes:.github/workflows/conditional.yml
Custom Directory
Scan a specific subdirectory:.github/workflows/subdirectory.yml
Combine with Other Actions
Integrate with testing and linting:.github/workflows/full-ci.yml
PR Comment Format
When usinggithub-token on pull requests, React Doctor posts a comment with this format:
Troubleshooting
Action Fails with βNo React dependency foundβ
Ensure React is listed in yourpackage.json:
Diff mode not detecting changes
Usefetch-depth: 0 to fetch full git history:
PR comments not appearing
Ensure the workflow has write permissions:Best Practices
- Use diff mode for PRs: Scan only changed files to reduce CI time
- Enable PR comments: Provide immediate feedback to developers
- Set fail-on appropriately: Use
errorfor CI,nonefor reporting - Track scores: Monitor codebase health over time
- Combine with existing checks: Integrate into existing CI workflows