Skip to main content

Programmatic API

Basic Usage

With Options

Diagnostic Structure

Each diagnostic has this shape:

Custom Scripts

Score Tracking Script

Track health score over time:
track-score.ts
Run daily in CI and commit the history file.

Generate Report

Create a formatted markdown report:
generate-report.ts

Combining with Other Tools

With ESLint

Run React Doctor after ESLint:
package.json

With Prettier

package.json

With TypeScript

Run in sequence:
package.json

With Jest

Run after tests:
package.json

Fail-On Levels

Fail on Errors Only

Exit code 1 if any error-level diagnostics are found.

Fail on Warnings

Exit code 1 if any diagnostics (errors or warnings) are found.

Never Fail

Always exit with code 0 (report only mode).

In Configuration

react-doctor.config.json
CLI flag overrides config value:

Advanced Filtering

Filter by Category

filter-by-category.ts

Filter by Plugin

filter-by-plugin.ts

Filter by File Pattern

filter-by-file.ts

Score Thresholds

Enforce Minimum Score

enforce-score.ts

Prevent Score Regression

prevent-regression.ts

Monorepo Workflows

Parallel Project Scans

scan-all-projects.ts

Conditional Project Scanning

Scan only projects with changes:
scan-changed-projects.sh

Notification Integrations

Slack Notification

notify-slack.ts

Discord Notification

notify-discord.ts

Tips

Use --fail-on error in development and --fail-on warning in production branches
Combine React Doctor with other tools in a single validate script for comprehensive checks
Track your score over time to visualize codebase health improvements