react-doctor 0.2.2 → 0.2.4
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/README.md +16 -500
- package/dist/cli.js +5584 -3571
- package/dist/index.d.ts +199 -28
- package/dist/index.js +5706 -4620
- package/package.json +7 -5
- package/dist/chunk-q7NCDQ7-.js +0 -26
- package/dist/dist-2B-kn9PW.js +0 -17940
- package/dist/dist-BPzE37C6.js +0 -17940
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
1
2
|
import fs from "node:fs";
|
|
2
|
-
|
|
3
|
-
//#region
|
|
3
|
+
import * as Cause from "effect/Cause";
|
|
4
|
+
//#region ../core/dist/index.d.ts
|
|
5
|
+
//#region src/types/config.d.ts
|
|
4
6
|
type FailOnLevel = "error" | "warning" | "none";
|
|
5
7
|
interface ReactDoctorIgnoreOverride {
|
|
6
8
|
files: string[];
|
|
@@ -92,7 +94,7 @@ interface ReactDoctorConfig {
|
|
|
92
94
|
failOn?: FailOnLevel;
|
|
93
95
|
customRulesOnly?: boolean;
|
|
94
96
|
share?: boolean;
|
|
95
|
-
|
|
97
|
+
noScore?: boolean;
|
|
96
98
|
/**
|
|
97
99
|
* Redirect react-doctor at a different project directory than the one
|
|
98
100
|
* it was invoked against. Resolved relative to the location of the
|
|
@@ -240,8 +242,44 @@ interface ReactDoctorConfig {
|
|
|
240
242
|
* single category, use `ignore.tags` instead.
|
|
241
243
|
*/
|
|
242
244
|
categories?: Record<string, RuleSeverityOverride>;
|
|
245
|
+
/**
|
|
246
|
+
* User-defined oxlint plugins to load alongside the built-in
|
|
247
|
+
* `react-doctor` plugin. Each entry is either:
|
|
248
|
+
*
|
|
249
|
+
* - A **relative path** to a JS / TS file (resolved relative to
|
|
250
|
+
* the directory of the config file that declared it — NOT the
|
|
251
|
+
* CWD), e.g. `"./lint/my-rules.js"`.
|
|
252
|
+
* - An **npm package name**, e.g. `"react-doctor-plugin-team-conventions"`.
|
|
253
|
+
*
|
|
254
|
+
* The module must default-export an oxlint-shaped plugin:
|
|
255
|
+
* `{ meta: { name: string }, rules: Record<string, HostRule> }`.
|
|
256
|
+
* Use `defineRule` from `oxlint-plugin-react-doctor` for the
|
|
257
|
+
* cleanest authoring shape — see CONTRIBUTING.md → "Writing a
|
|
258
|
+
* custom plugin" for the full template.
|
|
259
|
+
*
|
|
260
|
+
* Rules from a user plugin are **opt-in by default**: a rule
|
|
261
|
+
* doesn't run unless `rules: { "<plugin-name>/<rule>": "warn" | "error" }`
|
|
262
|
+
* explicitly enables it. (Mirrors how `defaultEnabled: false`
|
|
263
|
+
* rules behave in the built-in plugin.) Once enabled, the rule
|
|
264
|
+
* flows through every react-doctor surface (CLI / PR comment /
|
|
265
|
+
* score / CI gate) the same as a built-in rule.
|
|
266
|
+
*
|
|
267
|
+
* ```json
|
|
268
|
+
* {
|
|
269
|
+
* "plugins": [
|
|
270
|
+
* "./lint/my-team-rules.js",
|
|
271
|
+
* "react-doctor-plugin-shopify-conventions"
|
|
272
|
+
* ],
|
|
273
|
+
* "rules": {
|
|
274
|
+
* "my-team-rules/no-bare-fetch": "error",
|
|
275
|
+
* "shopify-conventions/use-polaris-tokens": "warn"
|
|
276
|
+
* }
|
|
277
|
+
* }
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
plugins?: string[];
|
|
243
281
|
} //#endregion
|
|
244
|
-
//#region src/diagnostic.d.ts
|
|
282
|
+
//#region src/types/diagnostic.d.ts
|
|
245
283
|
interface Diagnostic {
|
|
246
284
|
filePath: string;
|
|
247
285
|
plugin: string;
|
|
@@ -256,7 +294,7 @@ interface Diagnostic {
|
|
|
256
294
|
suppressionHint?: string;
|
|
257
295
|
}
|
|
258
296
|
//#endregion
|
|
259
|
-
//#region src/project-info.d.ts
|
|
297
|
+
//#region src/types/project-info.d.ts
|
|
260
298
|
type Framework = "nextjs" | "vite" | "cra" | "remix" | "gatsby" | "expo" | "react-native" | "tanstack-start" | "unknown";
|
|
261
299
|
interface ProjectInfo {
|
|
262
300
|
rootDirectory: string;
|
|
@@ -285,12 +323,12 @@ interface ProjectInfo {
|
|
|
285
323
|
sourceFileCount: number;
|
|
286
324
|
}
|
|
287
325
|
//#endregion
|
|
288
|
-
//#region src/score.d.ts
|
|
326
|
+
//#region src/types/score.d.ts
|
|
289
327
|
interface ScoreResult {
|
|
290
328
|
score: number;
|
|
291
329
|
label: string;
|
|
292
330
|
} //#endregion
|
|
293
|
-
//#region src/diagnose.d.ts
|
|
331
|
+
//#region src/types/diagnose.d.ts
|
|
294
332
|
interface DiagnoseOptions {
|
|
295
333
|
lint?: boolean;
|
|
296
334
|
/** See `ReactDoctorConfig.deadCode`. Ignored in diff mode. */
|
|
@@ -317,9 +355,9 @@ interface DiagnoseResult {
|
|
|
317
355
|
project: ProjectInfo;
|
|
318
356
|
elapsedMilliseconds: number;
|
|
319
357
|
} //#endregion
|
|
320
|
-
//#region src/handle-error.d.ts
|
|
358
|
+
//#region src/types/handle-error.d.ts
|
|
321
359
|
//#endregion
|
|
322
|
-
//#region src/inspect.d.ts
|
|
360
|
+
//#region src/types/inspect.d.ts
|
|
323
361
|
interface InspectResult {
|
|
324
362
|
diagnostics: Diagnostic[];
|
|
325
363
|
score: ScoreResult | null;
|
|
@@ -396,40 +434,158 @@ interface JsonReport {
|
|
|
396
434
|
elapsedMilliseconds: number;
|
|
397
435
|
error: JsonReportError | null;
|
|
398
436
|
} //#endregion
|
|
399
|
-
//#region src/prompts.d.ts
|
|
400
|
-
//#endregion
|
|
401
|
-
//#region ../project-info/dist/index.d.ts
|
|
437
|
+
//#region src/types/prompts.d.ts
|
|
402
438
|
//#endregion
|
|
403
|
-
//#region src/errors.d.ts
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
439
|
+
//#region src/project-info/errors.d.ts
|
|
440
|
+
/**
|
|
441
|
+
* Narrow errors raised by the project-discovery helpers
|
|
442
|
+
* (`discoverProject` / `resolveDiagnoseTarget` / `readPackageJson`).
|
|
443
|
+
*
|
|
444
|
+
* These extend `Error` directly — they are NOT the tagged
|
|
445
|
+
* `ReactDoctorError` from `../errors.js` (that one wraps every
|
|
446
|
+
* runtime-pipeline failure as a `Schema.TaggedErrorClass` for
|
|
447
|
+
* `Effect.catchReasons` dispatch). The split is intentional:
|
|
448
|
+
*
|
|
449
|
+
* - Discovery happens BEFORE the Effect runtime takes over — at the
|
|
450
|
+
* `diagnose()` / CLI entry point — and throws plain JS exceptions
|
|
451
|
+
* so callers can `try/catch` without an Effect-layer-aware
|
|
452
|
+
* `instanceof` check.
|
|
453
|
+
* - The Project service (`services/project.ts → translateProjectInfoError`)
|
|
454
|
+
* translates each of these into the equivalent tagged-error
|
|
455
|
+
* `reason` before re-raising inside the Effect pipeline, so the
|
|
456
|
+
* runtime never sees a non-tagged failure.
|
|
457
|
+
*
|
|
458
|
+
* If you're inside the Effect runtime, use the tagged
|
|
459
|
+
* `ReactDoctorError` from `../errors.js` instead.
|
|
460
|
+
*/
|
|
461
|
+
declare class ProjectNotFoundError extends Error {
|
|
409
462
|
readonly name = "ProjectNotFoundError";
|
|
410
463
|
readonly directory: string;
|
|
411
464
|
constructor(directory: string, options?: ErrorOptions);
|
|
412
465
|
}
|
|
413
|
-
declare class NoReactDependencyError extends
|
|
466
|
+
declare class NoReactDependencyError extends Error {
|
|
414
467
|
readonly name = "NoReactDependencyError";
|
|
415
468
|
readonly directory: string;
|
|
416
469
|
constructor(directory: string, options?: ErrorOptions);
|
|
417
470
|
}
|
|
418
|
-
declare class PackageJsonNotFoundError extends
|
|
471
|
+
declare class PackageJsonNotFoundError extends Error {
|
|
419
472
|
readonly name = "PackageJsonNotFoundError";
|
|
420
473
|
readonly directory: string;
|
|
421
474
|
constructor(directory: string, options?: ErrorOptions);
|
|
422
475
|
}
|
|
423
|
-
declare class AmbiguousProjectError extends
|
|
476
|
+
declare class AmbiguousProjectError extends Error {
|
|
424
477
|
readonly name = "AmbiguousProjectError";
|
|
425
478
|
readonly directory: string;
|
|
426
479
|
readonly candidates: readonly string[];
|
|
427
480
|
constructor(directory: string, candidates: readonly string[], options?: ErrorOptions);
|
|
428
481
|
}
|
|
429
|
-
declare const
|
|
430
|
-
//#region src/utils/is-directory.d.ts
|
|
482
|
+
declare const isProjectDiscoveryError: (value: unknown) => value is ProjectNotFoundError | NoReactDependencyError | PackageJsonNotFoundError | AmbiguousProjectError; //#endregion
|
|
483
|
+
//#region src/project-info/utils/is-directory.d.ts
|
|
431
484
|
//#endregion
|
|
432
|
-
//#region
|
|
485
|
+
//#region src/errors.d.ts
|
|
486
|
+
declare const OxlintUnavailable_base: Schema.Class<OxlintUnavailable, Schema.TaggedStruct<"OxlintUnavailable", {
|
|
487
|
+
readonly kind: Schema.Literals<readonly ["binary-not-found", "native-binding-missing"]>;
|
|
488
|
+
readonly detail: Schema.String;
|
|
489
|
+
}>, Cause.YieldableError>;
|
|
490
|
+
declare class OxlintUnavailable extends OxlintUnavailable_base {
|
|
491
|
+
get message(): string;
|
|
492
|
+
}
|
|
493
|
+
declare const OxlintBatchExceeded_base: Schema.Class<OxlintBatchExceeded, Schema.TaggedStruct<"OxlintBatchExceeded", {
|
|
494
|
+
readonly kind: Schema.Literals<readonly ["timeout", "output-too-large", "oom", "killed"]>;
|
|
495
|
+
readonly detail: Schema.String;
|
|
496
|
+
}>, Cause.YieldableError>;
|
|
497
|
+
declare class OxlintBatchExceeded extends OxlintBatchExceeded_base {
|
|
498
|
+
get message(): string;
|
|
499
|
+
}
|
|
500
|
+
declare const OxlintSpawnFailed_base: Schema.Class<OxlintSpawnFailed, Schema.TaggedStruct<"OxlintSpawnFailed", {
|
|
501
|
+
readonly cause: Schema.Unknown;
|
|
502
|
+
}>, Cause.YieldableError>;
|
|
503
|
+
declare class OxlintSpawnFailed extends OxlintSpawnFailed_base {
|
|
504
|
+
get message(): string;
|
|
505
|
+
}
|
|
506
|
+
declare const OxlintOutputUnparseable_base: Schema.Class<OxlintOutputUnparseable, Schema.TaggedStruct<"OxlintOutputUnparseable", {
|
|
507
|
+
readonly preview: Schema.String;
|
|
508
|
+
}>, Cause.YieldableError>;
|
|
509
|
+
declare class OxlintOutputUnparseable extends OxlintOutputUnparseable_base {
|
|
510
|
+
get message(): string;
|
|
511
|
+
}
|
|
512
|
+
declare const ConfigParseFailed_base: Schema.Class<ConfigParseFailed, Schema.TaggedStruct<"ConfigParseFailed", {
|
|
513
|
+
readonly path: Schema.String;
|
|
514
|
+
readonly cause: Schema.Unknown;
|
|
515
|
+
}>, Cause.YieldableError>;
|
|
516
|
+
declare class ConfigParseFailed extends ConfigParseFailed_base {
|
|
517
|
+
get message(): string;
|
|
518
|
+
}
|
|
519
|
+
declare const ProjectNotFound_base: Schema.Class<ProjectNotFound, Schema.TaggedStruct<"ProjectNotFound", {
|
|
520
|
+
readonly directory: Schema.String;
|
|
521
|
+
}>, Cause.YieldableError>;
|
|
522
|
+
declare class ProjectNotFound extends ProjectNotFound_base {
|
|
523
|
+
get message(): string;
|
|
524
|
+
}
|
|
525
|
+
declare const NoReactDependency_base: Schema.Class<NoReactDependency, Schema.TaggedStruct<"NoReactDependency", {
|
|
526
|
+
readonly directory: Schema.String;
|
|
527
|
+
}>, Cause.YieldableError>;
|
|
528
|
+
declare class NoReactDependency extends NoReactDependency_base {
|
|
529
|
+
get message(): string;
|
|
530
|
+
}
|
|
531
|
+
declare const AmbiguousProject_base: Schema.Class<AmbiguousProject, Schema.TaggedStruct<"AmbiguousProject", {
|
|
532
|
+
readonly directory: Schema.String;
|
|
533
|
+
readonly candidates: Schema.$Array<Schema.String>;
|
|
534
|
+
}>, Cause.YieldableError>;
|
|
535
|
+
declare class AmbiguousProject extends AmbiguousProject_base {
|
|
536
|
+
get message(): string;
|
|
537
|
+
}
|
|
538
|
+
declare const DeadCodeAnalysisFailed_base: Schema.Class<DeadCodeAnalysisFailed, Schema.TaggedStruct<"DeadCodeAnalysisFailed", {
|
|
539
|
+
readonly cause: Schema.Unknown;
|
|
540
|
+
}>, Cause.YieldableError>;
|
|
541
|
+
declare class DeadCodeAnalysisFailed extends DeadCodeAnalysisFailed_base {
|
|
542
|
+
get message(): string;
|
|
543
|
+
}
|
|
544
|
+
declare const GitInvocationFailed_base: Schema.Class<GitInvocationFailed, Schema.TaggedStruct<"GitInvocationFailed", {
|
|
545
|
+
readonly args: Schema.$Array<Schema.String>;
|
|
546
|
+
readonly directory: Schema.String;
|
|
547
|
+
readonly cause: Schema.Unknown;
|
|
548
|
+
}>, Cause.YieldableError>;
|
|
549
|
+
declare class GitInvocationFailed extends GitInvocationFailed_base {
|
|
550
|
+
get message(): string;
|
|
551
|
+
}
|
|
552
|
+
declare const GitBaseBranchMissing_base: Schema.Class<GitBaseBranchMissing, Schema.TaggedStruct<"GitBaseBranchMissing", {
|
|
553
|
+
readonly branch: Schema.String;
|
|
554
|
+
}>, Cause.YieldableError>;
|
|
555
|
+
declare class GitBaseBranchMissing extends GitBaseBranchMissing_base {
|
|
556
|
+
get message(): string;
|
|
557
|
+
}
|
|
558
|
+
declare const GitBaseBranchInvalid_base: Schema.Class<GitBaseBranchInvalid, Schema.TaggedStruct<"GitBaseBranchInvalid", {
|
|
559
|
+
readonly detail: Schema.String;
|
|
560
|
+
}>, Cause.YieldableError>;
|
|
561
|
+
declare class GitBaseBranchInvalid extends GitBaseBranchInvalid_base {
|
|
562
|
+
get message(): string;
|
|
563
|
+
}
|
|
564
|
+
declare const ReactDoctorError_base: Schema.Class<ReactDoctorError, Schema.TaggedStruct<"ReactDoctorError", {
|
|
565
|
+
readonly reason: Schema.Union<readonly [typeof OxlintUnavailable, typeof OxlintBatchExceeded, typeof OxlintSpawnFailed, typeof OxlintOutputUnparseable, typeof ConfigParseFailed, typeof ProjectNotFound, typeof NoReactDependency, typeof AmbiguousProject, typeof DeadCodeAnalysisFailed, typeof GitInvocationFailed, typeof GitBaseBranchMissing, typeof GitBaseBranchInvalid]>;
|
|
566
|
+
}>, Cause.YieldableError>;
|
|
567
|
+
declare class ReactDoctorError extends ReactDoctorError_base {
|
|
568
|
+
get message(): string;
|
|
569
|
+
}
|
|
570
|
+
declare const isReactDoctorError: (error: unknown) => error is ReactDoctorError; //#endregion
|
|
571
|
+
//#region src/observability.d.ts
|
|
572
|
+
/**
|
|
573
|
+
* Opt-in OpenTelemetry layer. The default `Effect.fn(...)` spans
|
|
574
|
+
* already populate the in-process tracer; this layer plugs an OTLP
|
|
575
|
+
* HTTP exporter into the runtime when the user opts in via:
|
|
576
|
+
*
|
|
577
|
+
* REACT_DOCTOR_OTLP_ENDPOINT e.g. https://api.axiom.co
|
|
578
|
+
* REACT_DOCTOR_OTLP_AUTH_HEADER e.g. "Bearer <token>"
|
|
579
|
+
*
|
|
580
|
+
* Both env vars are required to enable export — if either is
|
|
581
|
+
* missing, the layer is a no-op (matches the pattern from
|
|
582
|
+
* `react-doctor-evals/src/Observability.ts`, where the equivalent
|
|
583
|
+
* absent-env path returns `Layer.empty`).
|
|
584
|
+
*
|
|
585
|
+
* No setup is required for users who don't care about tracing — the
|
|
586
|
+
* inspect / diagnose orchestrators always run, this layer just
|
|
587
|
+
* dictates whether the spans they emit get shipped to a backend.
|
|
588
|
+
*/
|
|
433
589
|
//#endregion
|
|
434
590
|
//#region src/build-json-report-error.d.ts
|
|
435
591
|
interface BuildJsonReportErrorInput {
|
|
@@ -453,10 +609,22 @@ interface BuildJsonReportInput {
|
|
|
453
609
|
totalElapsedMilliseconds: number;
|
|
454
610
|
}
|
|
455
611
|
declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReport; //#endregion
|
|
456
|
-
//#region src/
|
|
612
|
+
//#region src/can-oxlint-extend-config.d.ts
|
|
457
613
|
//#endregion
|
|
458
614
|
//#region src/get-diff-files.d.ts
|
|
459
|
-
|
|
615
|
+
/**
|
|
616
|
+
* Programmatic façade over `Git.diffSelection`. Async because the
|
|
617
|
+
* Git service runs through Effect's `ChildProcess` (true subprocess
|
|
618
|
+
* spawn, not `spawnSync`).
|
|
619
|
+
*
|
|
620
|
+
* Tagged-reason errors are dispatched via `Effect.catchReasons`
|
|
621
|
+
* (a v4-native API for narrowing inside a `Schema.TaggedErrorClass`
|
|
622
|
+
* union without manual `instanceof` checks). The recovered branches
|
|
623
|
+
* raise plain `Error`s so existing thrown-class consumers continue
|
|
624
|
+
* to work — anything else (real `GitInvocationFailed`, etc.)
|
|
625
|
+
* propagates as the tagged `ReactDoctorError` through `Effect.runPromise`.
|
|
626
|
+
*/
|
|
627
|
+
declare const getDiffInfo: (directory: string, explicitBaseBranch?: string) => Promise<DiffInfo | null>;
|
|
460
628
|
declare const filterSourceFiles: (filePaths: string[]) => string[]; //#endregion
|
|
461
629
|
//#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/types.d.ts
|
|
462
630
|
//#endregion
|
|
@@ -464,6 +632,10 @@ declare const filterSourceFiles: (filePaths: string[]) => string[]; //#endregion
|
|
|
464
632
|
declare const summarizeDiagnostics: (diagnostics: Diagnostic[], worstScore?: number | null, worstScoreLabel?: string | null) => JsonReportSummary; //#endregion
|
|
465
633
|
//#region src/validate-config-types.d.ts
|
|
466
634
|
//#endregion
|
|
635
|
+
//#region ../api/dist/index.d.ts
|
|
636
|
+
//#region src/diagnose.d.ts
|
|
637
|
+
declare const diagnose: (directory: string, options?: DiagnoseOptions) => Promise<DiagnoseResult>; //#endregion
|
|
638
|
+
//#endregion
|
|
467
639
|
//#region src/index.d.ts
|
|
468
640
|
declare const clearCaches: () => void;
|
|
469
641
|
interface ToJsonReportOptions {
|
|
@@ -472,7 +644,6 @@ interface ToJsonReportOptions {
|
|
|
472
644
|
mode?: JsonReportMode;
|
|
473
645
|
}
|
|
474
646
|
declare const toJsonReport: (result: DiagnoseResult, options: ToJsonReportOptions) => JsonReport;
|
|
475
|
-
declare const diagnose: (directory: string, options?: DiagnoseOptions) => Promise<DiagnoseResult>;
|
|
476
647
|
//#endregion
|
|
477
|
-
export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, PackageJsonNotFoundError, type ProjectInfo, ProjectNotFoundError, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
648
|
+
export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, PackageJsonNotFoundError, type ProjectInfo, ProjectNotFoundError, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
478
649
|
//# sourceMappingURL=index.d.ts.map
|