Skip to main content

Function Signature

The diagnose() function is the primary programmatic API for React Doctor. It analyzes a React codebase and returns diagnostics, score, and project information.

Parameters

string
required
Absolute or relative path to the project directory to scan.
DiagnoseOptions
default:"{}"
Configuration options for the diagnosis.

Return Value

object
The result of the diagnosis operation.

Errors

The function throws an error if:
  • No React dependency is found in package.json
  • The directory path is invalid or inaccessible

Examples

Basic usage

With options

Diff mode (scan specific files)

Error handling

CI integration

Configuration File

The diagnose() function automatically loads configuration from react-doctor.config.json in the project directory. Options passed to the function take precedence over config file settings. See Configuration for more details.