The diagnose() function is the primary programmatic API for React Doctor. It analyzes a React codebase and returns diagnostics, score, and project information.
Enable dead code detection using Knip. Defaults to true unless overridden by config file.Note: Dead code analysis is automatically skipped when includePaths is provided (diff mode).
Array of file paths to scan. When provided, enables “diff mode” and only scans the specified files.Note: Dead code detection is automatically disabled in diff mode.
import { diagnose } from 'react-doctor/api';const result = await diagnose('./my-app');console.log(`Found ${result.diagnostics.length} issues`);console.log(`Score: ${result.score?.score}`);console.log(`Completed in ${result.elapsedMilliseconds}ms`);
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.