Skip to main content

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, none
string
default:"20"
Node.js version to use for the scan

Action Outputs

number
Health score (0-100). Available even if the scan fails.
Example using output:

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 using github-token on pull requests, React Doctor posts a comment with this format:
βœ— useEffect dependencies array is missing dependencies (2) Ensure all dependencies are included in the array src/components/Header.tsx: 45, 67 ⚠ Avoid using array index as key (1) Use a unique identifier instead src/pages/List.tsx: 89 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”Œβ”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β€’ β€’ β”‚ β”‚ β”‚ β”‚ ─ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ React Doctor (www.react.doctor) β”‚ β”‚ β”‚ β”‚ 78 / 100 Needs Improvement β”‚ β”‚ β”‚ β”‚ β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ β”‚ β”‚ β”‚ β”‚ βœ— 5 errors ⚠ 12 warnings across 8/142 β”‚ β”‚ files in 2.3s β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
The comment is automatically updated on subsequent runs rather than creating duplicates.

Troubleshooting

Action Fails with β€œNo React dependency found”

Ensure React is listed in your package.json:

Diff mode not detecting changes

Use fetch-depth: 0 to fetch full git history:

PR comments not appearing

Ensure the workflow has write permissions:

Best Practices

  1. Use diff mode for PRs: Scan only changed files to reduce CI time
  2. Enable PR comments: Provide immediate feedback to developers
  3. Set fail-on appropriately: Use error for CI, none for reporting
  4. Track scores: Monitor codebase health over time
  5. Combine with existing checks: Integrate into existing CI workflows