Function Signature
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
Thediagnose() 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.
Related
- Types Reference - TypeScript type definitions
- Utility Functions -
getDiffInfo()andfilterSourceFiles() - Configuration - Config file format