react-doctor 0.2.17-dev.5614b32 → 0.2.18-dev.19b39c0

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 CHANGED
@@ -64,7 +64,13 @@ jobs:
64
64
  runs-on: ubuntu-latest
65
65
  steps:
66
66
  - uses: actions/checkout@v5
67
- - uses: millionco/react-doctor@main
67
+ - uses: millionco/react-doctor@v1
68
+ ```
69
+
70
+ `@v1` always resolves to the latest `v1.x` release of the Action. For hardened CI — recommended whenever the workflow is granted `pull-requests: write` — pin to a full commit SHA instead and let Dependabot or Renovate keep it current:
71
+
72
+ ```yaml
73
+ - uses: millionco/react-doctor@b612664043a9be414166e3c6a69b355e39a8dcf4 # v1.1.1
68
74
  ```
69
75
 
70
76
  [Add GitHub Action →](https://github.com/marketplace/actions/react-doctor)
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f83fc141-ff41-5c96-8a8e-f4ea0399b0f2")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="989a10c5-8f69-5f04-a13a-8353aeb4c29a")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import { execFileSync, spawn, spawnSync } from "node:child_process";
5
5
  import * as Path from "node:path";
@@ -5054,33 +5054,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
5054
5054
  value: mod,
5055
5055
  enumerable: true
5056
5056
  }) : target, mod));
5057
- /**
5058
- * Narrow errors raised by the project-discovery helpers
5059
- * (`discoverProject` / `resolveDiagnoseTarget` / `readPackageJson`).
5060
- *
5061
- * These extend `Error` directly — they are NOT the tagged
5062
- * `ReactDoctorError` from `../errors.js` (that one wraps every
5063
- * runtime-pipeline failure as a `Schema.TaggedErrorClass` for
5064
- * `Effect.catchReasons` dispatch). The split is intentional:
5065
- *
5066
- * - Discovery happens BEFORE the Effect runtime takes over — at the
5067
- * `diagnose()` / CLI entry point — and throws plain JS exceptions
5068
- * so callers can `try/catch` without an Effect-layer-aware
5069
- * `instanceof` check.
5070
- * - The Project service (`services/project.ts → translateProjectInfoError`)
5071
- * translates each of these into the equivalent tagged-error
5072
- * `reason` before re-raising inside the Effect pipeline, so the
5073
- * runtime never sees a non-tagged failure.
5074
- *
5075
- * If you're inside the Effect runtime, use the tagged
5076
- * `ReactDoctorError` from `../errors.js` instead.
5077
- */
5078
5057
  var ProjectNotFoundError = class extends Error {
5079
5058
  name = "ProjectNotFoundError";
5080
5059
  directory;
5060
+ kind;
5081
5061
  constructor(directory, options) {
5082
- super(`No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
5062
+ const kind = options?.kind ?? "no-project";
5063
+ super(kind === "missing-path" ? `Scan target "${directory}" does not exist. Check the path and try again.` : `No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
5083
5064
  this.directory = directory;
5065
+ this.kind = kind;
5084
5066
  }
5085
5067
  };
5086
5068
  var NoReactDependencyError = class extends Error {
@@ -5117,6 +5099,7 @@ var AmbiguousProjectError = class extends Error {
5117
5099
  this.candidates = candidates;
5118
5100
  }
5119
5101
  };
5102
+ const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
5120
5103
  const isFile = (filePath) => {
5121
5104
  try {
5122
5105
  return fs.statSync(filePath).isFile();
@@ -5174,7 +5157,10 @@ const IGNORABLE_READDIR_ERROR_CODES = new Set([
5174
5157
  "EACCES",
5175
5158
  "EPERM",
5176
5159
  "ENOENT",
5177
- "ENOTDIR"
5160
+ "ENOTDIR",
5161
+ "EINVAL",
5162
+ "ELOOP",
5163
+ "ENAMETOOLONG"
5178
5164
  ]);
5179
5165
  const isIgnorableReaddirError = (error) => {
5180
5166
  if (typeof error !== "object" || error === null) return false;
@@ -7701,7 +7687,7 @@ const resolveScanTarget = async (requestedDirectory, options = {}) => {
7701
7687
  const redirectedDirectory = resolveConfigRootDir(userConfig, configSourceDirectory);
7702
7688
  const directoryAfterRedirect = redirectedDirectory ?? absoluteRequested;
7703
7689
  const resolvedDirectory = resolveDiagnoseTarget(directoryAfterRedirect, options) ?? directoryAfterRedirect;
7704
- if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory);
7690
+ if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory, { kind: "missing-path" });
7705
7691
  return {
7706
7692
  resolvedDirectory,
7707
7693
  requestedDirectory: absoluteRequested,
@@ -9203,7 +9189,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
9203
9189
  if (result.status !== 0) return null;
9204
9190
  const branch = trimOrNull(result.stdout);
9205
9191
  return branch === "HEAD" ? null : branch;
9206
- }));
9192
+ }), Effect.orElseSucceed(() => null));
9207
9193
  const defaultBranch = (directory) => Effect.gen(function* () {
9208
9194
  const symref = yield* runGit(directory, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
9209
9195
  if (symref.status === 0) {
@@ -11948,7 +11934,7 @@ const makeNoopConsole = () => ({
11948
11934
  });
11949
11935
  //#endregion
11950
11936
  //#region src/cli/utils/version.ts
11951
- const VERSION = "0.2.17-dev.5614b32";
11937
+ const VERSION = "0.2.18-dev.19b39c0";
11952
11938
  //#endregion
11953
11939
  //#region src/cli/utils/json-mode.ts
11954
11940
  let context = null;
@@ -12294,13 +12280,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
12294
12280
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
12295
12281
  * standard `SENTRY_RELEASE` override.
12296
12282
  */
12297
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.17-dev.5614b32`;
12283
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.19b39c0`;
12298
12284
  /**
12299
12285
  * Deployment environment shown in Sentry's environment filter. Defaults to
12300
12286
  * `production` for tagged releases and `development` for dev/unbuilt versions,
12301
12287
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
12302
12288
  */
12303
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.17-dev.5614b32") ? "development" : "production");
12289
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.19b39c0") ? "development" : "production");
12304
12290
  /**
12305
12291
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
12306
12292
  * (set to `0` to disable tracing) and falls back to
@@ -17019,6 +17005,49 @@ const handleUserError = (error, options = {}) => {
17019
17005
  process.exitCode = 1;
17020
17006
  };
17021
17007
  //#endregion
17008
+ //#region src/cli/utils/cli-input-error.ts
17009
+ /**
17010
+ * A mistake in *how the CLI was invoked* — a malformed `<file>:<line>`
17011
+ * argument, mutually exclusive flags, or an unknown `--project` name. This is
17012
+ * user input, not a react-doctor bug, so `isExpectedUserError` routes it
17013
+ * through `handleUserError`: a clean, single-line message with no Sentry
17014
+ * report and no "Something went wrong, open a prefilled issue" block.
17015
+ *
17016
+ * The `message` is rendered verbatim, so it must read as a complete,
17017
+ * human-readable sentence that tells the user how to fix their invocation.
17018
+ */
17019
+ var CliInputError = class extends Error {
17020
+ name = "CliInputError";
17021
+ };
17022
+ //#endregion
17023
+ //#region src/cli/utils/is-expected-user-error.ts
17024
+ /**
17025
+ * Whether `error` is an expected, user-actionable failure — the user's project
17026
+ * or input, not a react-doctor bug. Such failures must be kept out of crash
17027
+ * reporting (Sentry + the alertable error-rate metric) and rendered via
17028
+ * `handleUserError` (a plain message — no "Something went wrong", prefilled
17029
+ * issue, Discord link, or Sentry reference), since there is no bug to report.
17030
+ *
17031
+ * Three distinct shapes reach the CLI's catch blocks:
17032
+ *
17033
+ * - **Project-discovery failures** (`NoReactDependencyError`,
17034
+ * `ProjectNotFoundError`, `PackageJsonNotFoundError`, `NotADirectoryError`,
17035
+ * `AmbiguousProjectError`) arrive as their plain legacy classes (so
17036
+ * `isReactDoctorError` is `false` for them) — narrow with
17037
+ * `isProjectDiscoveryError`. Running react-doctor against a directory that
17038
+ * has no React, or a path that doesn't exist, is the canonical example.
17039
+ * - **CLI invocation mistakes** (`CliInputError`): a malformed
17040
+ * `<file>:<line>` argument, mutually exclusive flags, or an unknown
17041
+ * `--project` name.
17042
+ * - **Bad `--diff` input** (`GitBaseBranchInvalid` / `GitBaseBranchMissing`)
17043
+ * stays the tagged `ReactDoctorError`, so dispatch on the reason `_tag`.
17044
+ *
17045
+ * This composes the existing core narrowers rather than introducing a new
17046
+ * error-shape helper (AGENTS.md): it encodes CLI-layer reporting policy, not
17047
+ * knowledge of the `ReactDoctorError` shape.
17048
+ */
17049
+ const isExpectedUserError = (error) => error instanceof CliInputError || isProjectDiscoveryError(error) || isReactDoctorError(error) && (error.reason._tag === "GitBaseBranchInvalid" || error.reason._tag === "GitBaseBranchMissing");
17050
+ //#endregion
17022
17051
  //#region src/cli/utils/build-handoff-payload.ts
17023
17052
  const buildHandoffPayload = (input) => {
17024
17053
  const topGroups = buildSortedRuleGroups(input.diagnostics).slice(0, 3);
@@ -18543,6 +18572,7 @@ const playWelcomeScene = () => Effect.gen(function* () {
18543
18572
  */
18544
18573
  const reportErrorToSentry = async (error) => {
18545
18574
  if (!Sentry.isInitialized()) return void 0;
18575
+ if (isExpectedUserError(error)) return void 0;
18546
18576
  try {
18547
18577
  const { tags, contexts } = buildSentryScope();
18548
18578
  let reason = "unknown";
@@ -18584,7 +18614,13 @@ const isSafeRelativePath = (filePath) => {
18584
18614
  return normalized === filePath;
18585
18615
  };
18586
18616
  const readChangedFilesFrom = (filePath) => {
18587
- const raw = fs.readFileSync(filePath, "utf8");
18617
+ let raw;
18618
+ try {
18619
+ raw = fs.readFileSync(filePath, "utf8");
18620
+ } catch (error) {
18621
+ const errorCode = error?.code;
18622
+ throw new CliInputError(`Could not read the --changed-files-from file "${filePath}"${errorCode ? ` (${errorCode})` : ""}. Pass a path to a readable text file that lists changed files, one per line.`);
18623
+ }
18588
18624
  const uniqueFiles = /* @__PURE__ */ new Set();
18589
18625
  for (const line of raw.split(/\r?\n/)) {
18590
18626
  const candidate = toForwardSlashes(line.trim());
@@ -18682,7 +18718,11 @@ const getSetupPromptStore = (options = {}) => new Conf({
18682
18718
  });
18683
18719
  const getSetupPromptProjectKey = (projectRoot) => createHash("sha256").update(path.resolve(projectRoot)).digest("hex");
18684
18720
  const hasDisabledSetupPrompt = (projectRoot, storeOptions = {}) => {
18685
- return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
18721
+ try {
18722
+ return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
18723
+ } catch {
18724
+ return false;
18725
+ }
18686
18726
  };
18687
18727
  const resolveInstallSetupProjectRoot = (options) => {
18688
18728
  if (options.scanDirectories.length === 0) return findNearestPackageDirectory(options.scanRoot) ?? options.scanRoot;
@@ -18900,12 +18940,12 @@ const findOwningProjectDirectory = (rootDirectory, filePath) => {
18900
18940
  //#region src/cli/utils/parse-file-line-argument.ts
18901
18941
  const parseFileLineArgument = (rawArgument) => {
18902
18942
  const lastColonIndex = rawArgument.lastIndexOf(":");
18903
- if (lastColonIndex < 0) throw new Error(`Expected "<file>:<line>" (e.g. "src/foo.tsx:42"), got "${rawArgument}".`);
18943
+ if (lastColonIndex < 0) throw new CliInputError(`Expected "<file>:<line>" (e.g. "src/foo.tsx:42"), got "${rawArgument}".`);
18904
18944
  const filePath = rawArgument.slice(0, lastColonIndex);
18905
18945
  const lineText = rawArgument.slice(lastColonIndex + 1);
18906
- if (filePath.length === 0) throw new Error(`Missing file path in "${rawArgument}".`);
18946
+ if (filePath.length === 0) throw new CliInputError(`Missing file path in "${rawArgument}".`);
18907
18947
  const line = Number.parseInt(lineText, 10);
18908
- if (!Number.isFinite(line) || line <= 0 || String(line) !== lineText.trim()) throw new Error(`Expected a positive line number in "${rawArgument}".`);
18948
+ if (!Number.isFinite(line) || line <= 0 || String(line) !== lineText.trim()) throw new CliInputError(`Expected a positive line number in "${rawArgument}".`);
18909
18949
  return {
18910
18950
  filePath,
18911
18951
  line
@@ -18934,10 +18974,7 @@ const resolveProjectFlag = (projectFlag, workspacePackages) => {
18934
18974
  const resolvedDirectories = [];
18935
18975
  for (const requestedName of requestedNames) {
18936
18976
  const matched = workspacePackages.find((workspacePackage) => workspacePackage.name === requestedName || path.basename(workspacePackage.directory) === requestedName);
18937
- if (!matched) {
18938
- const availableNames = workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ");
18939
- throw new Error(`Project "${requestedName}" not found. Available: ${availableNames}`);
18940
- }
18977
+ if (!matched) throw new CliInputError(`Project "${requestedName}" not found. Available: ${workspacePackages.map((workspacePackage) => workspacePackage.name).join(", ")}`);
18941
18978
  resolvedDirectories.push(matched.directory);
18942
18979
  }
18943
18980
  return resolvedDirectories;
@@ -19017,14 +19054,14 @@ const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
19017
19054
  const validateModeFlags = (flags) => {
19018
19055
  const coercedDiff = coerceDiffValue(flags.diff);
19019
19056
  const exclusiveModes = [flags.staged ? "--staged" : null, coercedDiff !== void 0 && coercedDiff !== false ? "--diff" : null].filter((modeName) => modeName !== null);
19020
- if (exclusiveModes.length > 1) throw new Error(`Cannot combine ${exclusiveModes.join(" and ")}; pick one mode.`);
19021
- if (flags.yes && flags.full) throw new Error("Cannot combine --yes and --full; pick one.");
19022
- if (flags.score && flags.json) throw new Error("Cannot combine --score and --json; pick one output mode.");
19023
- if (flags.score && flags.telemetry === false) throw new Error("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
19024
- if (flags.prComment && (flags.json || flags.score)) throw new Error("--pr-comment cannot be combined with --json or --score.");
19025
- if (flags.annotations && flags.score) throw new Error("--annotations cannot be combined with --score.");
19026
- if (flags.explain !== void 0 && flags.why !== void 0) throw new Error("Use --explain or --why, not both — they're aliases of the same flag.");
19027
- if ((flags.explain ?? flags.why) !== void 0 && (flags.json || flags.score || flags.annotations || flags.staged)) throw new Error("--explain cannot be combined with --json, --score, --annotations, or --staged.");
19057
+ if (exclusiveModes.length > 1) throw new CliInputError(`Cannot combine ${exclusiveModes.join(" and ")}; pick one mode.`);
19058
+ if (flags.yes && flags.full) throw new CliInputError("Cannot combine --yes and --full; pick one.");
19059
+ if (flags.score && flags.json) throw new CliInputError("Cannot combine --score and --json; pick one output mode.");
19060
+ if (flags.score && flags.telemetry === false) throw new CliInputError("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
19061
+ if (flags.prComment && (flags.json || flags.score)) throw new CliInputError("--pr-comment cannot be combined with --json or --score.");
19062
+ if (flags.annotations && flags.score) throw new CliInputError("--annotations cannot be combined with --score.");
19063
+ if (flags.explain !== void 0 && flags.why !== void 0) throw new CliInputError("Use --explain or --why, not both — they're aliases of the same flag.");
19064
+ if ((flags.explain ?? flags.why) !== void 0 && (flags.json || flags.score || flags.annotations || flags.staged)) throw new CliInputError("--explain cannot be combined with --json, --score, --annotations, or --staged.");
19028
19065
  };
19029
19066
  //#endregion
19030
19067
  //#region src/cli/commands/inspect.ts
@@ -19272,7 +19309,7 @@ const inspectAction = async (directory, flags) => {
19272
19309
  }
19273
19310
  }
19274
19311
  } catch (error) {
19275
- const isUserError = isReactDoctorError(error) && (error.reason._tag === "GitBaseBranchInvalid" || error.reason._tag === "GitBaseBranchMissing");
19312
+ const isUserError = isExpectedUserError(error);
19276
19313
  const sentryEventId = isUserError ? void 0 : await reportErrorToSentry(error);
19277
19314
  if (isJsonMode) {
19278
19315
  writeJsonErrorReport(error);
@@ -19908,6 +19945,30 @@ const exitGracefully = () => {
19908
19945
  process.exit(130);
19909
19946
  };
19910
19947
  //#endregion
19948
+ //#region src/cli/utils/guard-stdin.ts
19949
+ const TERMINAL_HANGUP_CODES = new Set(["EIO", "ENXIO"]);
19950
+ /**
19951
+ * Handles a `process.stdin` `'error'` event. A terminal hangup mid-read
19952
+ * (`read EIO`) is environmental, not a bug, so exit like an interrupted run
19953
+ * instead of crashing. Re-throws anything else so genuine stdin failures keep
19954
+ * funneling to the crash reporter exactly as they did before this guard.
19955
+ */
19956
+ const handleStdinError = (error) => {
19957
+ if (error.code !== void 0 && TERMINAL_HANGUP_CODES.has(error.code)) process.exit(129);
19958
+ throw error;
19959
+ };
19960
+ /**
19961
+ * Arms a `process.stdin` error guard at startup. The only thing that reads
19962
+ * stdin is the interactive `prompts` UI, which opens the TTY in raw mode and
19963
+ * never attaches an `'error'` listener of its own. Without a listener Node
19964
+ * turns a `read EIO` from a vanished terminal into a fatal uncaught exception
19965
+ * (reported to Sentry as a crash); with one, {@link handleStdinError} exits
19966
+ * cleanly on a hangup. Mirrors the stdout EPIPE guard in `cli/index.ts`.
19967
+ */
19968
+ const guardStdin = () => {
19969
+ process.stdin.on("error", handleStdinError);
19970
+ };
19971
+ //#endregion
19911
19972
  //#region src/cli/utils/normalize-help-command.ts
19912
19973
  /**
19913
19974
  * 12-factor CLI Apps (#1, "Great help is essential"): `mycli help` and
@@ -20102,6 +20163,7 @@ initializeSentry();
20102
20163
  process.on("SIGINT", exitGracefully);
20103
20164
  process.on("SIGTERM", exitGracefully);
20104
20165
  unrefStdin();
20166
+ guardStdin();
20105
20167
  const formatExampleLines = (examples) => {
20106
20168
  const width = Math.max(...examples.map(([command]) => command.length));
20107
20169
  return examples.map(([command, description]) => ` $ ${command.padEnd(width)} ${highlighter.dim(`# ${description}`)}`).join("\n");
@@ -20166,15 +20228,20 @@ if (process.argv.includes("-V") && !strippedArgv.includes("-V")) {
20166
20228
  applyColorPreference(strippedArgv);
20167
20229
  const argv = normalizeHelpInvocation(strippedArgv, knownCommands);
20168
20230
  program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
20169
- const sentryEventId = await reportErrorToSentry(error);
20231
+ const isUserError = isExpectedUserError(error);
20232
+ const sentryEventId = isUserError ? void 0 : await reportErrorToSentry(error);
20170
20233
  if (isJsonModeActive()) {
20171
20234
  writeJsonErrorReport(error);
20172
20235
  process.exit(1);
20173
20236
  }
20237
+ if (isUserError) {
20238
+ handleUserError(error);
20239
+ return;
20240
+ }
20174
20241
  handleError(error, { sentryEventId });
20175
20242
  });
20176
20243
  //#endregion
20177
20244
  export {};
20178
20245
 
20179
20246
  //# sourceMappingURL=cli.js.map
20180
- //# debugId=f83fc141-ff41-5c96-8a8e-f4ea0399b0f2
20247
+ //# debugId=989a10c5-8f69-5f04-a13a-8353aeb4c29a
package/dist/index.d.ts CHANGED
@@ -610,10 +610,25 @@ interface JsonReport {
610
610
  * If you're inside the Effect runtime, use the tagged
611
611
  * `ReactDoctorError` from `../errors.js` instead.
612
612
  */
613
+ /**
614
+ * Distinguishes the two situations that both surface as "no project here", so
615
+ * the rendered message matches reality:
616
+ *
617
+ * - `no-project` (default): the path exists but has no React project — no
618
+ * `package.json` at the root and no discoverable nested React subproject.
619
+ * - `missing-path`: the resolved scan target does not exist on disk at all
620
+ * (a typo, a stale temp path, a monorepo subdir that isn't present). The
621
+ * generic "expected a package.json" guidance is misleading here, so point
622
+ * at the missing path instead.
623
+ */
624
+ interface ProjectNotFoundOptions extends ErrorOptions {
625
+ readonly kind?: "no-project" | "missing-path";
626
+ }
613
627
  declare class ProjectNotFoundError extends Error {
614
628
  readonly name = "ProjectNotFoundError";
615
629
  readonly directory: string;
616
- constructor(directory: string, options?: ErrorOptions);
630
+ readonly kind: "no-project" | "missing-path";
631
+ constructor(directory: string, options?: ProjectNotFoundOptions);
617
632
  }
618
633
  declare class NoReactDependencyError extends Error {
619
634
  readonly name = "NoReactDependencyError";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="de59ec3d-8219-56e6-b16a-5aed5d046e99")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="40acbd32-84e3-59a8-874d-7a23e9b8383e")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as Schema from "effect/Schema";
5
5
  import * as fs$1 from "node:fs";
@@ -2027,33 +2027,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
2027
2027
  value: mod,
2028
2028
  enumerable: true
2029
2029
  }) : target, mod));
2030
- /**
2031
- * Narrow errors raised by the project-discovery helpers
2032
- * (`discoverProject` / `resolveDiagnoseTarget` / `readPackageJson`).
2033
- *
2034
- * These extend `Error` directly — they are NOT the tagged
2035
- * `ReactDoctorError` from `../errors.js` (that one wraps every
2036
- * runtime-pipeline failure as a `Schema.TaggedErrorClass` for
2037
- * `Effect.catchReasons` dispatch). The split is intentional:
2038
- *
2039
- * - Discovery happens BEFORE the Effect runtime takes over — at the
2040
- * `diagnose()` / CLI entry point — and throws plain JS exceptions
2041
- * so callers can `try/catch` without an Effect-layer-aware
2042
- * `instanceof` check.
2043
- * - The Project service (`services/project.ts → translateProjectInfoError`)
2044
- * translates each of these into the equivalent tagged-error
2045
- * `reason` before re-raising inside the Effect pipeline, so the
2046
- * runtime never sees a non-tagged failure.
2047
- *
2048
- * If you're inside the Effect runtime, use the tagged
2049
- * `ReactDoctorError` from `../errors.js` instead.
2050
- */
2051
2030
  var ProjectNotFoundError = class extends Error {
2052
2031
  name = "ProjectNotFoundError";
2053
2032
  directory;
2033
+ kind;
2054
2034
  constructor(directory, options) {
2055
- super(`No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
2035
+ const kind = options?.kind ?? "no-project";
2036
+ super(kind === "missing-path" ? `Scan target "${directory}" does not exist. Check the path and try again.` : `No React project found in ${directory}. Expected a package.json at the directory root or a nested package.json with a React dependency.`, options);
2056
2037
  this.directory = directory;
2038
+ this.kind = kind;
2057
2039
  }
2058
2040
  };
2059
2041
  var NoReactDependencyError = class extends Error {
@@ -2148,7 +2130,10 @@ const IGNORABLE_READDIR_ERROR_CODES = new Set([
2148
2130
  "EACCES",
2149
2131
  "EPERM",
2150
2132
  "ENOENT",
2151
- "ENOTDIR"
2133
+ "ENOTDIR",
2134
+ "EINVAL",
2135
+ "ELOOP",
2136
+ "ENAMETOOLONG"
2152
2137
  ]);
2153
2138
  const isIgnorableReaddirError = (error) => {
2154
2139
  if (typeof error !== "object" || error === null) return false;
@@ -4651,7 +4636,7 @@ const resolveScanTarget = async (requestedDirectory, options = {}) => {
4651
4636
  const redirectedDirectory = resolveConfigRootDir(userConfig, configSourceDirectory);
4652
4637
  const directoryAfterRedirect = redirectedDirectory ?? absoluteRequested;
4653
4638
  const resolvedDirectory = resolveDiagnoseTarget(directoryAfterRedirect, options) ?? directoryAfterRedirect;
4654
- if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory);
4639
+ if (!isDirectory(resolvedDirectory)) throw existsSync(resolvedDirectory) ? new NotADirectoryError(resolvedDirectory) : new ProjectNotFoundError(resolvedDirectory, { kind: "missing-path" });
4655
4640
  return {
4656
4641
  resolvedDirectory,
4657
4642
  requestedDirectory: absoluteRequested,
@@ -6137,7 +6122,7 @@ var Git = class Git extends Context.Service()("react-doctor/Git") {
6137
6122
  if (result.status !== 0) return null;
6138
6123
  const branch = trimOrNull(result.stdout);
6139
6124
  return branch === "HEAD" ? null : branch;
6140
- }));
6125
+ }), Effect.orElseSucceed(() => null));
6141
6126
  const defaultBranch = (directory) => Effect.gen(function* () {
6142
6127
  const symref = yield* runGit(directory, ["symbolic-ref", "refs/remotes/origin/HEAD"]);
6143
6128
  if (symref.status === 0) {
@@ -8742,4 +8727,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8742
8727
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8743
8728
 
8744
8729
  //# sourceMappingURL=index.js.map
8745
- //# debugId=de59ec3d-8219-56e6-b16a-5aed5d046e99
8730
+ //# debugId=40acbd32-84e3-59a8-874d-7a23e9b8383e
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.2.17-dev.5614b32",
3
+ "version": "0.2.18-dev.19b39c0",
4
4
  "description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -55,7 +55,7 @@
55
55
  "agent-install": "0.0.5",
56
56
  "conf": "^15.1.0",
57
57
  "confbox": "^0.2.4",
58
- "deslop-js": "^0.0.14",
58
+ "deslop-js": "^0.0.15",
59
59
  "effect": "4.0.0-beta.70",
60
60
  "eslint-plugin-react-hooks": "^7.1.1",
61
61
  "jiti": "^2.7.0",
@@ -63,7 +63,7 @@
63
63
  "oxlint": "^1.66.0",
64
64
  "prompts": "^2.4.2",
65
65
  "typescript": ">=5.0.4 <7",
66
- "oxlint-plugin-react-doctor": "0.2.17-dev.5614b32"
66
+ "oxlint-plugin-react-doctor": "0.2.18-dev.19b39c0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/babel__code-frame": "^7.27.0",
@@ -71,8 +71,8 @@
71
71
  "@xterm/headless": "^6.0.0",
72
72
  "commander": "^14.0.3",
73
73
  "ora": "^9.4.0",
74
- "@react-doctor/api": "0.2.17",
75
- "@react-doctor/core": "0.2.17"
74
+ "@react-doctor/api": "0.2.18",
75
+ "@react-doctor/core": "0.2.18"
76
76
  },
77
77
  "engines": {
78
78
  "node": "^20.19.0 || >=22.12.0"