Skip to main content

Core Types

Diagnostic

Represents a single diagnostic issue found in the codebase.
string
Absolute path to the file containing the issue.
string
Source of the diagnostic (e.g., "oxlint", "knip").
string
Specific rule that was violated (e.g., "react-hooks/exhaustive-deps").
'error' | 'warning'
Severity level of the issue.
string
Human-readable description of the issue.
string
Additional context or guidance for fixing the issue.
number
Line number where the issue occurs (1-indexed).
number
Column number where the issue occurs (1-indexed).
string
Categorization of the issue (e.g., "correctness", "style", "performance").
number
Numeric weight for score calculation. Higher weights have more impact on the score.

ProjectInfo

Information about the analyzed React project.
string
Absolute path to the project root directory.
string
Name of the project from package.json.
string | null
Version of React installed, or null if not found.
Framework
Detected framework. See Framework type.
boolean
Whether TypeScript is detected in the project.
boolean
Whether React Compiler (babel-plugin-react-compiler) is detected.
number
Total number of source files in the project.

ScoreResult

Overall health score for the codebase.
number
Numeric score from 0-100, where 100 is perfect health.
string
Human-readable label for the score (e.g., "Excellent", "Good", "Fair", "Poor").

DiffInfo

Information about changed files in a git repository.
string
Name of the current git branch.
string
Name of the base branch for comparison.
string[]
Array of file paths that have changed.
boolean
Whether the changes are uncommitted (working directory changes).

ReactDoctorConfig

Configuration object from react-doctor.config.json.
ReactDoctorIgnoreConfig
Rules and files to ignore. See ReactDoctorIgnoreConfig.
boolean
Enable linting checks.
boolean
Enable dead code detection.
boolean
Show verbose output with file details.
boolean | string
Enable diff mode. If a string, specifies the base branch name.
FailOnLevel
Exit code behavior. See FailOnLevel.

ReactDoctorIgnoreConfig

Configuration for ignoring specific rules or files.
string[]
Array of rule IDs to ignore (e.g., ["react-hooks/exhaustive-deps"]).
string[]
Array of file glob patterns to ignore (e.g., ["**/*.test.tsx"]).

Enums & Unions

Framework

Supported React frameworks.
Framework
Next.js framework
Framework
Vite framework
Framework
Create React App
Framework
Remix framework
Framework
Gatsby framework
Framework
Expo framework
Framework
React Native (non-Expo)
Framework
Framework could not be detected

FailOnLevel

Exit code behavior based on diagnostic severity.
FailOnLevel
Exit with code 1 only if errors are found.
FailOnLevel
Exit with code 1 if any warnings or errors are found.
FailOnLevel
Always exit with code 0 regardless of diagnostics.

Internal Types

These types are used internally by React Doctor but may be useful for advanced use cases.

EstimatedScoreResult

Estimated score improvement after fixing issues.

ScanOptions

Internal options used by the CLI scanner.

ScanResult

Internal result from the scanner.

PackageJson

Structure of a package.json file.

WorkspacePackage

Information about a workspace package in a monorepo.

Utility Functions

getDiffInfo()

Returns information about changed files in a git repository.
string
required
Path to the git repository.
string
Base branch for comparison. If not provided, uses the default base branch (usually main or master).
Returns: DiffInfo | null - Diff information or null if not a git repository or no changes found.

filterSourceFiles()

Filters an array of file paths to include only source files.
string[]
required
Array of file paths to filter.
Returns: string[] - Array containing only source files (JavaScript, TypeScript, JSX, TSX).

Examples

Type-safe diagnostic handling

Custom score display

Working with project info