react-doctor 0.2.0-beta.2 → 0.2.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,294 @@
1
- import { buildJsonReport, buildJsonReportError, filterSourceFiles, getDiffInfo, summarizeDiagnostics } from "@react-doctor/core";
2
- import { AmbiguousProjectError, NoReactDependencyError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, isReactDoctorError } from "@react-doctor/project-info";
3
- import { DiagnoseOptions, DiagnoseResult, Diagnostic, DiffInfo, JsonReport, JsonReportDiffInfo, JsonReportError, JsonReportMode, JsonReportProjectEntry, JsonReportSummary, ProjectInfo, ReactDoctorConfig, ScoreResult } from "@react-doctor/types";
4
-
1
+ //#region ../types/dist/index.d.ts
2
+ //#region src/config.d.ts
3
+ type FailOnLevel = "error" | "warning" | "none";
4
+ interface ReactDoctorIgnoreOverride {
5
+ files: string[];
6
+ rules?: string[];
7
+ }
8
+ interface ReactDoctorIgnoreConfig {
9
+ rules?: string[];
10
+ files?: string[];
11
+ overrides?: ReactDoctorIgnoreOverride[];
12
+ tags?: string[];
13
+ }
14
+ interface ReactDoctorConfig {
15
+ ignore?: ReactDoctorIgnoreConfig;
16
+ lint?: boolean;
17
+ verbose?: boolean;
18
+ diff?: boolean | string;
19
+ failOn?: FailOnLevel;
20
+ customRulesOnly?: boolean;
21
+ share?: boolean;
22
+ offline?: boolean;
23
+ /**
24
+ * Redirect react-doctor at a different project directory than the one
25
+ * it was invoked against. Resolved relative to the location of the
26
+ * config file that declared this field (NOT relative to the CWD), so
27
+ * the redirect is stable no matter where the CLI / `diagnose()` is
28
+ * run from. Absolute paths are used as-is.
29
+ *
30
+ * Typical use: a monorepo root holds the only `react-doctor.config.json`
31
+ * (so editor tooling and child commands all find it), but the React
32
+ * app lives in `apps/web`. Setting `"rootDir": "apps/web"` makes
33
+ * every invocation that loads this config scan that subproject
34
+ * without anyone needing to `cd` first or pass an explicit path.
35
+ *
36
+ * Ignored if the resolved path does not exist or is not a directory
37
+ * (a warning is emitted and react-doctor falls back to the originally
38
+ * requested directory).
39
+ */
40
+ rootDir?: string;
41
+ textComponents?: string[];
42
+ /**
43
+ * Names of components that safely route string-only children through a
44
+ * React Native `<Text>` internally (e.g. `heroui-native`'s `Button`,
45
+ * which stringifies its children and renders them through a
46
+ * `ButtonLabel` → `Text`). For listed components, `rn-no-raw-text`
47
+ * is suppressed ONLY when the wrapper's children are entirely
48
+ * stringifiable (no nested JSX elements). A wrapper with mixed
49
+ * children — e.g. `<Button>Save<Icon /></Button>` — still reports,
50
+ * because the wrapper can't safely route raw text alongside a
51
+ * sibling JSX element.
52
+ *
53
+ * Use this instead of `textComponents` when the component is not
54
+ * itself a text element but is known to wrap its string children
55
+ * in one. `textComponents` is the broader escape hatch and
56
+ * suppresses regardless of sibling content.
57
+ */
58
+ rawTextWrapperComponents?: string[];
59
+ /**
60
+ * Whether to respect inline `// eslint-disable*`, `// oxlint-disable*`,
61
+ * and `// react-doctor-disable*` comments in source files. Default: `true`.
62
+ *
63
+ * File-level ignores (`.gitignore`, `.eslintignore`, `.oxlintignore`,
64
+ * `.prettierignore`, `.gitattributes` `linguist-vendored` /
65
+ * `linguist-generated`) are ALWAYS honored regardless of this option
66
+ * — they typically point at vendored or generated code that
67
+ * genuinely shouldn't be linted at all.
68
+ *
69
+ * Set to `false` for "audit mode": every inline suppression is
70
+ * neutralized so react-doctor reports every diagnostic regardless
71
+ * of historical hide-comments.
72
+ */
73
+ respectInlineDisables?: boolean;
74
+ /**
75
+ * Whether to merge the user's existing JSON oxlint / eslint config
76
+ * (`.oxlintrc.json` or `.eslintrc.json`) into the generated scan via
77
+ * oxlint's `extends` field, so diagnostics from those rules count
78
+ * toward the react-doctor score. Default: `true`.
79
+ *
80
+ * Detection runs at the scanned directory and walks up to the
81
+ * nearest project boundary (`.git` directory or monorepo root).
82
+ * The first match wins, with `.oxlintrc.json` preferred over
83
+ * `.eslintrc.json`.
84
+ *
85
+ * Only JSON-format configs are supported because oxlint's `extends`
86
+ * cannot evaluate JS/TS configs. Flat configs (`eslint.config.js`),
87
+ * legacy JS configs (`.eslintrc.js`), and TypeScript oxlint configs
88
+ * (`oxlint.config.ts`) are silently skipped.
89
+ *
90
+ * Category-level enables in the user's config (`"categories": { ... }`)
91
+ * are NOT honored — react-doctor explicitly disables every oxlint
92
+ * category to keep the scan scoped to its curated rule surface, and
93
+ * local config wins over `extends`. Use rule-level severities to
94
+ * fold rules into the score.
95
+ *
96
+ * Set to `false` to scan only react-doctor's curated rule set.
97
+ */
98
+ adoptExistingLintConfig?: boolean;
99
+ } //#endregion
100
+ //#region src/diagnostic.d.ts
101
+ interface Diagnostic {
102
+ filePath: string;
103
+ plugin: string;
104
+ rule: string;
105
+ severity: "error" | "warning";
106
+ message: string;
107
+ help: string;
108
+ url?: string;
109
+ line: number;
110
+ column: number;
111
+ category: string;
112
+ suppressionHint?: string;
113
+ }
114
+ //#endregion
115
+ //#region src/project-info.d.ts
116
+ type Framework = "nextjs" | "vite" | "cra" | "remix" | "gatsby" | "expo" | "react-native" | "tanstack-start" | "unknown";
117
+ interface ProjectInfo {
118
+ rootDirectory: string;
119
+ projectName: string;
120
+ reactVersion: string | null;
121
+ reactMajorVersion: number | null;
122
+ tailwindVersion: string | null;
123
+ framework: Framework;
124
+ hasTypeScript: boolean;
125
+ hasReactCompiler: boolean;
126
+ hasTanStackQuery: boolean;
127
+ sourceFileCount: number;
128
+ }
129
+ //#endregion
130
+ //#region src/score.d.ts
131
+ interface ScoreResult {
132
+ score: number;
133
+ label: string;
134
+ } //#endregion
135
+ //#region src/diagnose.d.ts
136
+ interface DiagnoseOptions {
137
+ lint?: boolean;
138
+ verbose?: boolean;
139
+ includePaths?: string[];
140
+ /**
141
+ * Per-call override for `ReactDoctorConfig.respectInlineDisables`.
142
+ * See that field's docs for the full contract.
143
+ */
144
+ respectInlineDisables?: boolean;
145
+ }
146
+ interface DiagnoseResult {
147
+ diagnostics: Diagnostic[];
148
+ score: ScoreResult | null;
149
+ project: ProjectInfo;
150
+ elapsedMilliseconds: number;
151
+ } //#endregion
152
+ //#region src/handle-error.d.ts
153
+ //#endregion
154
+ //#region src/inspect.d.ts
155
+ interface InspectResult {
156
+ diagnostics: Diagnostic[];
157
+ score: ScoreResult | null;
158
+ skippedChecks: string[];
159
+ /**
160
+ * Human-readable explanation for each entry in `skippedChecks`. Keyed
161
+ * by check name (e.g. `"lint"`). Optional so existing consumers that
162
+ * only read `skippedChecks` keep working unchanged — but JSON output
163
+ * and CI integrations should prefer this for diagnostic clarity
164
+ * (e.g. distinguishing "oxlint native binding missing" from "oxlint
165
+ * spawn timed out on a large project").
166
+ */
167
+ skippedCheckReasons?: Record<string, string>;
168
+ project: ProjectInfo;
169
+ elapsedMilliseconds: number;
170
+ }
171
+ interface DiffInfo {
172
+ currentBranch: string;
173
+ baseBranch: string;
174
+ changedFiles: string[];
175
+ isCurrentChanges?: boolean;
176
+ }
177
+ type JsonReportMode = "full" | "diff" | "staged";
178
+ interface JsonReportDiffInfo {
179
+ baseBranch: string;
180
+ currentBranch: string;
181
+ changedFileCount: number;
182
+ isCurrentChanges: boolean;
183
+ }
184
+ interface JsonReportProjectEntry {
185
+ directory: string;
186
+ project: ProjectInfo;
187
+ diagnostics: Diagnostic[];
188
+ score: ScoreResult | null;
189
+ skippedChecks: string[];
190
+ /** Human-readable explanation per skipped check. See `InspectResult.skippedCheckReasons`. */
191
+ skippedCheckReasons?: Record<string, string>;
192
+ elapsedMilliseconds: number;
193
+ }
194
+ interface JsonReportSummary {
195
+ errorCount: number;
196
+ warningCount: number;
197
+ affectedFileCount: number;
198
+ totalDiagnosticCount: number;
199
+ score: number | null;
200
+ scoreLabel: string | null;
201
+ }
202
+ interface JsonReportError {
203
+ message: string;
204
+ name: string;
205
+ chain: string[];
206
+ }
207
+ interface JsonReport {
208
+ schemaVersion: 1;
209
+ version: string;
210
+ ok: boolean;
211
+ directory: string;
212
+ mode: JsonReportMode;
213
+ diff: JsonReportDiffInfo | null;
214
+ projects: JsonReportProjectEntry[];
215
+ /**
216
+ * Flattened across `projects[].diagnostics` for convenience. Equivalent to
217
+ * `projects.flatMap((project) => project.diagnostics)`.
218
+ */
219
+ diagnostics: Diagnostic[];
220
+ summary: JsonReportSummary;
221
+ elapsedMilliseconds: number;
222
+ error: JsonReportError | null;
223
+ } //#endregion
224
+ //#region src/prompts.d.ts
225
+ //#endregion
226
+ //#region ../project-info/dist/index.d.ts
227
+ //#endregion
228
+ //#region src/errors.d.ts
229
+ declare class ReactDoctorError extends Error {
230
+ readonly name: string;
231
+ constructor(message: string, options?: ErrorOptions);
232
+ }
233
+ declare class ProjectNotFoundError extends ReactDoctorError {
234
+ readonly name = "ProjectNotFoundError";
235
+ readonly directory: string;
236
+ constructor(directory: string, options?: ErrorOptions);
237
+ }
238
+ declare class NoReactDependencyError extends ReactDoctorError {
239
+ readonly name = "NoReactDependencyError";
240
+ readonly directory: string;
241
+ constructor(directory: string, options?: ErrorOptions);
242
+ }
243
+ declare class PackageJsonNotFoundError extends ReactDoctorError {
244
+ readonly name = "PackageJsonNotFoundError";
245
+ readonly directory: string;
246
+ constructor(directory: string, options?: ErrorOptions);
247
+ }
248
+ declare class AmbiguousProjectError extends ReactDoctorError {
249
+ readonly name = "AmbiguousProjectError";
250
+ readonly directory: string;
251
+ readonly candidates: readonly string[];
252
+ constructor(directory: string, candidates: readonly string[], options?: ErrorOptions);
253
+ }
254
+ declare const isReactDoctorError: (value: unknown) => value is ReactDoctorError; //#endregion
255
+ //#region src/utils/is-file.d.ts
256
+ //#endregion
257
+ //#region ../core/dist/index.d.ts
258
+ //#endregion
259
+ //#region src/build-json-report-error.d.ts
260
+ interface BuildJsonReportErrorInput {
261
+ version: string;
262
+ directory: string;
263
+ error: unknown;
264
+ elapsedMilliseconds: number;
265
+ mode?: JsonReportMode;
266
+ }
267
+ declare const buildJsonReportError: (input: BuildJsonReportErrorInput) => JsonReport; //#endregion
268
+ //#region src/build-json-report.d.ts
269
+ interface BuildJsonReportInput {
270
+ version: string;
271
+ directory: string;
272
+ mode: JsonReportMode;
273
+ diff: DiffInfo | null;
274
+ scans: Array<{
275
+ directory: string;
276
+ result: InspectResult;
277
+ }>;
278
+ totalElapsedMilliseconds: number;
279
+ }
280
+ declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#endregion
281
+ //#region src/calculate-score.d.ts
282
+ //#endregion
283
+ //#region src/get-diff-files.d.ts
284
+ declare const getDiffInfo: (directory: string, explicitBaseBranch?: string) => DiffInfo | null;
285
+ declare const filterSourceFiles: (filePaths: string[]) => string[]; //#endregion
286
+ //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/types.d.ts
287
+ //#endregion
288
+ //#region src/summarize-diagnostics.d.ts
289
+ declare const summarizeDiagnostics: (diagnostics: Diagnostic[], worstScore?: number | null, worstScoreLabel?: string | null) => JsonReportSummary; //#endregion
290
+ //#region src/validate-config-types.d.ts
291
+ //#endregion
5
292
  //#region src/index.d.ts
6
293
  declare const clearCaches: () => void;
7
294
  interface ToJsonReportOptions {