Installation
Install React Doctor as a dependency:Basic Usage
API Reference
diagnose()
The main function for scanning a React codebase.
string
required
Absolute or relative path to the project directory to scan
DiagnoseOptions
Optional configuration for the scan
Promise<DiagnoseResult>
Types
DiagnoseOptions
boolean
default:"true"
Enable or disable linting checks using oxlint
boolean
default:"true"
Enable or disable dead code detection using Knip
string[]
default:"[]"
Array of file paths to scan. When provided, enables diff mode and scans only the specified files. Dead code detection is automatically disabled in diff mode.
DiagnoseResult
Diagnostic[]
Array of all detected issues, each containing file path, rule, severity, message, and location information
ScoreResult | null
Health score object with score (0-100) and label.
null when telemetry is unavailable.ProjectInfo
Project metadata including React version, framework, TypeScript status, and file count
number
Total time taken for the scan in milliseconds
Diagnostic
ScoreResult
ProjectInfo
Framework
ReactDoctorConfig
Examples
Basic Scan
Lint Only
Disable dead code detection:Diff Mode
Scan only specific files (useful for pre-commit hooks):Process Diagnostics
Group and analyze diagnostics:Custom Reporting
Generate custom reports:CI Integration
Use in a Node.js CI script:Pre-commit Hook
Create a pre-commit hook using Husky:pre-commit.ts