react-doctor 0.4.0 → 0.4.1-dev.d17dc87

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
@@ -37,59 +37,11 @@ npx react-doctor@latest install
37
37
 
38
38
  Works with Claude Code, Cursor, Codex, OpenCode, and many more.
39
39
 
40
- ### 3. Use in your editor (LSP)
40
+ ### 3. Run in CI
41
41
 
42
- React Doctor ships an experimental language server, so diagnostics show up live as you type — underlined inline, with rich hovers and quick fixes — in VS Code, Cursor, Zed, Neovim, Sublime, Emacs, Helix, or any LSP client. The universal launch command is:
42
+ React Doctor CI (GitHub Actions) reviews every pull request automatically and reports only the issues your change introduced, not your existing backlog.
43
43
 
44
- ```bash
45
- react-doctor experimental-lsp --stdio
46
- ```
47
-
48
- > The editor language server is experimental — its protocol, caching, and diagnostics may change between releases, hence the `experimental-` prefix.
49
-
50
- Companion extensions for VS Code/Cursor and Zed live under `packages/`; any other LSP client can run the command above directly over stdio.
51
-
52
- ### 4. Run in CI (GitHub Actions) for your team
53
-
54
- [![GitHub Action](https://img.shields.io/badge/GitHub%20Action-React%20Doctor-000000?style=flat&labelColor=000000&logo=githubactions&logoColor=white)](https://github.com/marketplace/actions/react-doctor)
55
-
56
- On a pull request the Action reports only the issues your change **introduced** — it scans the PR and the merge-base and reports the difference (like Codecov for coverage), leaving pre-existing findings alone. It posts inline review comments on the changed lines and a sticky summary with the new / fixed delta.
57
-
58
- ```yaml
59
- name: React Doctor
60
-
61
- on:
62
- pull_request:
63
- types: [opened, synchronize, reopened, ready_for_review]
64
-
65
- permissions:
66
- contents: read
67
- pull-requests: write
68
- issues: write
69
-
70
- concurrency:
71
- group: react-doctor-${{ github.event.pull_request.number || github.ref }}
72
- cancel-in-progress: true
73
-
74
- jobs:
75
- react-doctor:
76
- runs-on: ubuntu-latest
77
- steps:
78
- - uses: actions/checkout@v5
79
- with:
80
- fetch-depth: 0 # so React Doctor can diff against the merge-base for new-vs-existing
81
- - uses: millionco/react-doctor@v1
82
- ```
83
-
84
- `fetch-depth: 0` is recommended so the baseline comparison can read the base commit; without enough history the Action falls back to reporting every finding in the changed files.
85
-
86
- `@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:
87
-
88
- ```yaml
89
- - uses: millionco/react-doctor@b612664043a9be414166e3c6a69b355e39a8dcf4 # v1.1.1
90
- ```
91
-
92
- [Add GitHub Action →](https://github.com/marketplace/actions/react-doctor)
44
+ [Add GitHub Action →](https://react.doctor/ci)
93
45
 
94
46
  ### 4. Configure rules in `doctor.config.ts`
95
47
 
@@ -97,14 +49,14 @@ Configure with a `doctor.config.ts` (or `.js`, `.mjs`, `.cjs`, `.json`, `.jsonc`
97
49
 
98
50
  ```ts
99
51
  // doctor.config.ts
100
- import type { ReactDoctorConfig } from "react-doctor/api";
52
+ import { defineConfig } from "react-doctor/api";
101
53
 
102
- export default {
54
+ export default defineConfig({
103
55
  lint: true,
104
56
  rules: {
105
57
  "react-doctor/no-array-index-as-key": "off",
106
58
  },
107
- } satisfies ReactDoctorConfig;
59
+ });
108
60
  ```
109
61
 
110
62
  Prefer JSON? Use `doctor.config.json`:
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]="e56fe2ba-b7f4-5b81-942b-685d55761c6b")}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]="1486eaee-ed07-5eef-a9d7-51293140e237")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
5
5
  import * as path$1 from "node:path";
@@ -6004,6 +6004,11 @@ const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson,
6004
6004
  if (!isFile(monorepoPackageJsonPath)) return version;
6005
6005
  return resolveCatalogVersion(readPackageJson$1(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
6006
6006
  };
6007
+ const getNextjsDependencySpec = (packageJson) => {
6008
+ const spec = packageJson.dependencies?.next ?? packageJson.devDependencies?.next ?? packageJson.peerDependencies?.next ?? packageJson.optionalDependencies?.next;
6009
+ return typeof spec === "string" ? spec : null;
6010
+ };
6011
+ const findNextjsVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getNextjsDependencySpec);
6007
6012
  const getPreactVersion = (packageJson) => {
6008
6013
  return {
6009
6014
  ...packageJson.peerDependencies,
@@ -6253,6 +6258,12 @@ const discoverProject = (directory) => {
6253
6258
  version: findShopifyFlashListVersion(directory, packageJson)
6254
6259
  }) : null;
6255
6260
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
6261
+ const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
6262
+ rootDirectory: directory,
6263
+ rootPackageJson: packageJson,
6264
+ packageName: "next",
6265
+ version: findNextjsVersion(directory, packageJson)
6266
+ }) : null;
6256
6267
  const preactVersion = getPreactVersion(packageJson);
6257
6268
  const projectInfo = {
6258
6269
  rootDirectory: directory,
@@ -6269,6 +6280,8 @@ const discoverProject = (directory) => {
6269
6280
  preactVersion,
6270
6281
  preactMajorVersion: parseReactMajor(preactVersion),
6271
6282
  hasReactNativeWorkspace,
6283
+ nextjsVersion,
6284
+ nextjsMajorVersion: nextjsVersion === null ? null : getLowestDependencyMajor(nextjsVersion),
6272
6285
  expoVersion,
6273
6286
  shopifyFlashListVersion,
6274
6287
  shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
@@ -6392,7 +6405,11 @@ const DIAGNOSTIC_CATEGORY_BUCKETS = [
6392
6405
  "Accessibility",
6393
6406
  "Maintainability"
6394
6407
  ];
6395
- const APP_ONLY_RULE_KEYS = new Set(["react-hooks-js/static-components", "react-doctor/no-render-prop-children"]);
6408
+ const APP_ONLY_RULE_KEYS = new Set([
6409
+ "react-hooks-js/static-components",
6410
+ "react-doctor/no-render-prop-children",
6411
+ "react-doctor/prefer-explicit-variants"
6412
+ ]);
6396
6413
  const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
6397
6414
  const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
6398
6415
  const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
@@ -7612,6 +7629,35 @@ const loadPackageJsonConfig = (directory) => {
7612
7629
  format: "package-json"
7613
7630
  };
7614
7631
  };
7632
+ const loadLegacyConfig = (directory) => {
7633
+ const legacyFilePath = path$1.join(directory, LEGACY_CONFIG_FILENAME);
7634
+ if (!isFile(legacyFilePath)) return {
7635
+ status: "absent",
7636
+ loaded: null
7637
+ };
7638
+ try {
7639
+ const parsed = readDataConfig(legacyFilePath);
7640
+ if (isPlainObject(parsed)) {
7641
+ warn(`${LEGACY_CONFIG_FILENAME} is deprecated — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts). It is still read for now.`);
7642
+ return {
7643
+ status: "found",
7644
+ loaded: {
7645
+ config: validateConfigTypes(parsed),
7646
+ sourceDirectory: directory,
7647
+ configFilePath: legacyFilePath,
7648
+ format: "json"
7649
+ }
7650
+ };
7651
+ }
7652
+ warn(`${LEGACY_CONFIG_FILENAME} must contain an object, ignoring.`);
7653
+ } catch (error) {
7654
+ warn(`Failed to load ${LEGACY_CONFIG_FILENAME}: ${formatError(error)}`);
7655
+ }
7656
+ return {
7657
+ status: "invalid",
7658
+ loaded: null
7659
+ };
7660
+ };
7615
7661
  const loadConfigFromDirectory = async (directory) => {
7616
7662
  let sawBrokenConfigFile = false;
7617
7663
  for (const extension of CONFIG_EXTENSIONS) {
@@ -7641,7 +7687,8 @@ const loadConfigFromDirectory = async (directory) => {
7641
7687
  status: "found",
7642
7688
  loaded: packageJsonConfig
7643
7689
  };
7644
- if (isFile(path$1.join(directory, LEGACY_CONFIG_FILENAME))) warn(`${LEGACY_CONFIG_FILENAME} is no longer read — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts).`);
7690
+ const legacyResult = loadLegacyConfig(directory);
7691
+ if (legacyResult.status !== "absent") return legacyResult;
7645
7692
  return {
7646
7693
  status: sawBrokenConfigFile ? "invalid" : "absent",
7647
7694
  loaded: null
@@ -7678,7 +7725,9 @@ const directoryHasCurrentConfig = (directory) => {
7678
7725
  /**
7679
7726
  * Walks up from `rootDirectory` (same boundary semantics as
7680
7727
  * `loadConfigWithSource`) looking for a pre-migration
7681
- * `react-doctor.config.json` that is no longer read. Returns the first one
7728
+ * `react-doctor.config.json`. The loader still reads this file as a deprecated
7729
+ * fallback (see `loadLegacyConfig`); this detector is what lets the interactive
7730
+ * CLI offer to rename it to a current-format config. Returns the first one
7682
7731
  * found, or `null` when a current-format config supersedes it or none exists
7683
7732
  * before a project boundary. Detection only — the CLI performs the rename.
7684
7733
  */
@@ -8394,6 +8443,7 @@ const checkReducedMotion = (rootDirectory) => {
8394
8443
  if (!hasMotionLibrary) return [];
8395
8444
  const result = spawnSync("git", [
8396
8445
  "grep",
8446
+ "--untracked",
8397
8447
  "-ql",
8398
8448
  "-E",
8399
8449
  REDUCED_MOTION_GREP_PATTERN,
@@ -9764,6 +9814,7 @@ const buildCapabilities = (project) => {
9764
9814
  capabilities.add(project.framework);
9765
9815
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
9766
9816
  if (project.expoVersion !== null) capabilities.add("expo");
9817
+ if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
9767
9818
  const reactMajor = project.reactMajorVersion;
9768
9819
  if (reactMajor !== null) {
9769
9820
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -10708,7 +10759,12 @@ const SANITIZED_ENV = (() => {
10708
10759
  const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLINT_SPAWN_TIMEOUT_MS, outputMaxBytes = OXLINT_OUTPUT_MAX_BYTES) => new Promise((resolve, reject) => {
10709
10760
  const child = spawn(nodeBinaryPath, args, {
10710
10761
  cwd: rootDirectory,
10711
- env: SANITIZED_ENV
10762
+ env: SANITIZED_ENV,
10763
+ stdio: [
10764
+ "ignore",
10765
+ "pipe",
10766
+ "pipe"
10767
+ ]
10712
10768
  });
10713
10769
  const timeoutHandle = setTimeout(() => {
10714
10770
  child.kill("SIGKILL");
@@ -12191,7 +12247,7 @@ const makeNoopConsole = () => ({
12191
12247
  });
12192
12248
  //#endregion
12193
12249
  //#region src/cli/utils/version.ts
12194
- const VERSION = "0.4.0";
12250
+ const VERSION = "0.4.1-dev.d17dc87";
12195
12251
  //#endregion
12196
12252
  //#region src/cli/utils/json-mode.ts
12197
12253
  let context = null;
@@ -12549,13 +12605,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
12549
12605
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
12550
12606
  * standard `SENTRY_RELEASE` override.
12551
12607
  */
12552
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.0`;
12608
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.1-dev.d17dc87`;
12553
12609
  /**
12554
12610
  * Deployment environment shown in Sentry's environment filter. Defaults to
12555
12611
  * `production` for tagged releases and `development` for dev/unbuilt versions,
12556
12612
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
12557
12613
  */
12558
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.0") ? "development" : "production");
12614
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.1-dev.d17dc87") ? "development" : "production");
12559
12615
  /**
12560
12616
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
12561
12617
  * (set to `0` to disable tracing) and falls back to
@@ -16752,10 +16808,10 @@ const canAnimateOnboarding = (stream = process.stdout) => {
16752
16808
  };
16753
16809
  //#endregion
16754
16810
  //#region src/cli/utils/onboarding-state.ts
16755
- const GLOBAL_CONFIG_PROJECT_NAME$1 = "react-doctor";
16811
+ const GLOBAL_CONFIG_PROJECT_NAME$2 = "react-doctor";
16756
16812
  const ONBOARDED_AT_KEY = "onboardedAt";
16757
16813
  const getOnboardingStore = (options = {}) => new Conf({
16758
- projectName: GLOBAL_CONFIG_PROJECT_NAME$1,
16814
+ projectName: GLOBAL_CONFIG_PROJECT_NAME$2,
16759
16815
  cwd: options.cwd
16760
16816
  });
16761
16817
  const hasCompletedOnboarding = (options = {}) => {
@@ -17719,9 +17775,9 @@ const buildHandoffPayload = (input) => {
17719
17775
  };
17720
17776
  //#endregion
17721
17777
  //#region src/cli/utils/is-command-available.ts
17722
- const isWindows = process.platform === "win32";
17778
+ const isWindows$1 = process.platform === "win32";
17723
17779
  const candidateFileNames = (command) => {
17724
- if (!isWindows || path$1.extname(command)) return [command];
17780
+ if (!isWindows$1 || path$1.extname(command)) return [command];
17725
17781
  return [command, ...(process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean).map((extension) => `${command}${extension}`)];
17726
17782
  };
17727
17783
  const isCommandAvailable = (command) => {
@@ -17730,7 +17786,7 @@ const isCommandAvailable = (command) => {
17730
17786
  const binaryPath = path$1.join(directory, fileName);
17731
17787
  try {
17732
17788
  if (!fs$1.statSync(binaryPath).isFile()) continue;
17733
- if (!isWindows) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
17789
+ if (!isWindows$1) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
17734
17790
  return true;
17735
17791
  } catch {}
17736
17792
  }
@@ -18143,6 +18199,11 @@ permissions:
18143
18199
  # comments (PRs are issues under the hood). Not exercised on \`push\`
18144
18200
  # events, so safe to drop if you only run on \`main\`.
18145
18201
  issues: write
18202
+ # Lets the action publish a commit status with the score + error/warning
18203
+ # counts (links to the run). This is how a \`push\` to \`main\` surfaces its
18204
+ # result, since the PR comment is skipped off pull requests. Drop it to
18205
+ # disable the status (or set \`commit-status: false\` below).
18206
+ statuses: write
18146
18207
 
18147
18208
  # Cancels any in-flight scan for the same PR (or branch, on push) the moment
18148
18209
  # a new commit arrives, so reviewers only ever see the latest run.
@@ -18156,20 +18217,42 @@ jobs:
18156
18217
  steps:
18157
18218
  - uses: actions/checkout@v5
18158
18219
 
18159
- - uses: millionco/react-doctor@v1
18220
+ - uses: millionco/react-doctor@v2
18160
18221
  # Common configuration knobs — uncomment any to override the default.
18161
18222
  # Full reference: https://www.react.doctor/ci
18162
18223
  # with:
18163
- # non-blocking: true # Report findings but always exit 0 (won't fail the PR check)
18164
- # fail-on: warning # Gate level: "error" (default) | "warning" | "none"
18224
+ # blocking: warning # Gate level: "error" (default) | "warning" | "none" (advisory)
18225
+ # scope: full # On PRs, scan the whole project instead of just changed files
18165
18226
  # comment: false # Disable the sticky PR summary comment
18166
- # annotations: false # Disable inline GitHub Actions annotations on changed files
18167
- # version: "0.2.18" # Pin to a specific react-doctor version instead of "latest"
18227
+ # review-comments: false # Disable inline review comments on changed lines
18228
+ # commit-status: false # Disable the commit status (score + counts, links to the run)
18229
+ # version: "0.4.0" # Pin to a specific react-doctor version instead of "latest"
18168
18230
  # directory: apps/web # Scan a sub-directory (default: ".")
18169
18231
  # project: "web,admin" # In a monorepo, scan specific workspace project(s)
18170
18232
  `;
18171
18233
  const getReactDoctorWorkflowPath = (projectRoot) => path$1.join(projectRoot, ".github", "workflows", "react-doctor.yml");
18172
18234
  const isReactDoctorWorkflowInstalled = (projectRoot) => fs$1.existsSync(getReactDoctorWorkflowPath(projectRoot));
18235
+ const V1_FLOATING_ACTION_REF = String.raw`millionco/react-doctor@v1(?![\w.])`;
18236
+ const V2_FLOATING_ACTION_REF = "millionco/react-doctor@v2";
18237
+ const readReactDoctorWorkflow = (projectRoot) => {
18238
+ const workflowPath = getReactDoctorWorkflowPath(projectRoot);
18239
+ try {
18240
+ return {
18241
+ workflowPath,
18242
+ content: fs$1.readFileSync(workflowPath, "utf8")
18243
+ };
18244
+ } catch {
18245
+ return null;
18246
+ }
18247
+ };
18248
+ const workflowUsesV1Action = (content) => new RegExp(V1_FLOATING_ACTION_REF).test(content);
18249
+ const upgradeWorkflowActionToV2 = (content) => {
18250
+ const upgraded = content.replace(new RegExp(V1_FLOATING_ACTION_REF, "g"), V2_FLOATING_ACTION_REF);
18251
+ return {
18252
+ content: upgraded,
18253
+ changed: upgraded !== content
18254
+ };
18255
+ };
18173
18256
  const installReactDoctorWorkflow = (projectRoot) => {
18174
18257
  const workflowPath = getReactDoctorWorkflowPath(projectRoot);
18175
18258
  if (fs$1.existsSync(workflowPath)) return {
@@ -18999,6 +19082,41 @@ const runInstallReactDoctor = async (options = {}) => {
18999
19082
  for (const agent of selectedAgents) recordCount(METRIC.installAgent, 1, { agent });
19000
19083
  };
19001
19084
  //#endregion
19085
+ //#region src/cli/utils/hash-project-root.ts
19086
+ const hashProjectRoot = (projectRoot) => createHash("sha256").update(path$1.resolve(projectRoot)).digest("hex");
19087
+ //#endregion
19088
+ //#region src/cli/utils/action-upgrade-prompt.ts
19089
+ const GLOBAL_CONFIG_PROJECT_NAME$1 = "react-doctor";
19090
+ const getActionUpgradeStore = (options = {}) => new Conf({
19091
+ projectName: GLOBAL_CONFIG_PROJECT_NAME$1,
19092
+ cwd: options.cwd
19093
+ });
19094
+ const hasHandledActionUpgrade = (projectRoot, storeOptions = {}) => {
19095
+ try {
19096
+ const upgrades = getActionUpgradeStore(storeOptions).get("actionUpgrades", {});
19097
+ return Boolean(upgrades[hashProjectRoot(projectRoot)]);
19098
+ } catch {
19099
+ return true;
19100
+ }
19101
+ };
19102
+ const recordActionUpgradeDecision = (projectRoot, outcome, storeOptions = {}) => {
19103
+ try {
19104
+ const store = getActionUpgradeStore(storeOptions);
19105
+ const upgrades = store.get("actionUpgrades", {});
19106
+ store.set("actionUpgrades", {
19107
+ ...upgrades,
19108
+ [hashProjectRoot(projectRoot)]: {
19109
+ rootDirectory: path$1.resolve(projectRoot),
19110
+ outcome,
19111
+ at: (/* @__PURE__ */ new Date()).toISOString()
19112
+ }
19113
+ });
19114
+ return true;
19115
+ } catch {
19116
+ return false;
19117
+ }
19118
+ };
19119
+ //#endregion
19002
19120
  //#region src/cli/utils/install-skill-for-agent.ts
19003
19121
  const installReactDoctorSkillForAgent = async (agent, projectRoot) => {
19004
19122
  const source = getSkillSourceDirectory();
@@ -19049,9 +19167,9 @@ const openUrl = (url) => {
19049
19167
  //#endregion
19050
19168
  //#region src/cli/utils/open-workflow-pull-request.ts
19051
19169
  const NEW_BRANCH_PREFIX = "react-doctor/add-github-actions";
19052
- const COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
19053
- const PR_TITLE = "Add React Doctor to GitHub Actions";
19054
- const PR_BODY = `Adds a [React Doctor](https://www.react.doctor) scan to every pull request and every push to the default branch. The workflow file is documented inline.
19170
+ const DEFAULT_COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
19171
+ const DEFAULT_PR_TITLE = "Add React Doctor to GitHub Actions";
19172
+ const DEFAULT_PR_BODY = `Adds a [React Doctor](https://www.react.doctor) scan to every pull request and every push to the default branch. The workflow file is documented inline.
19055
19173
 
19056
19174
  Docs: https://www.react.doctor/ci`;
19057
19175
  const execFileAsync = promisify(execFile);
@@ -19103,6 +19221,9 @@ const findUniqueBranchName = async (cwd) => {
19103
19221
  };
19104
19222
  const openWorkflowPullRequest = async (params) => {
19105
19223
  const workflowPath = path$1.resolve(params.workflowPath);
19224
+ const commitMessage = params.commitMessage ?? DEFAULT_COMMIT_MESSAGE;
19225
+ const prTitle = params.prTitle ?? DEFAULT_PR_TITLE;
19226
+ const prBody = params.prBody ?? DEFAULT_PR_BODY;
19106
19227
  const repoRootProbe = await run("git", ["rev-parse", "--show-toplevel"], path$1.dirname(workflowPath));
19107
19228
  if (!repoRootProbe.success) return {
19108
19229
  status: "not-attempted",
@@ -19169,7 +19290,7 @@ const openWorkflowPullRequest = async (params) => {
19169
19290
  if (!(await run("git", [
19170
19291
  "commit",
19171
19292
  "-m",
19172
- COMMIT_MESSAGE
19293
+ commitMessage
19173
19294
  ], cwd)).success) {
19174
19295
  await restoreToPreviousBranch(true);
19175
19296
  return {
@@ -19193,9 +19314,9 @@ const openWorkflowPullRequest = async (params) => {
19193
19314
  "pr",
19194
19315
  "create",
19195
19316
  "--title",
19196
- PR_TITLE,
19317
+ prTitle,
19197
19318
  "--body",
19198
- PR_BODY,
19319
+ prBody,
19199
19320
  "--base",
19200
19321
  defaultBranch,
19201
19322
  "--head",
@@ -19223,6 +19344,7 @@ const stageWorkflowFile = async (params) => {
19223
19344
  };
19224
19345
  //#endregion
19225
19346
  //#region src/cli/utils/launch-agent.ts
19347
+ const isWindows = process.platform === "win32";
19226
19348
  const CLI_AGENT_BINARIES = {
19227
19349
  "claude-code": "claude",
19228
19350
  codex: "codex",
@@ -19233,14 +19355,47 @@ const CLI_AGENT_AUTO_FLAGS = {
19233
19355
  codex: ["--yolo"],
19234
19356
  cursor: ["--force"]
19235
19357
  };
19236
- const launchCliAgent = (agentId, prompt, cwd) => new Promise((resolve, reject) => {
19237
- const child = spawn(CLI_AGENT_BINARIES[agentId], [...CLI_AGENT_AUTO_FLAGS[agentId], prompt], {
19358
+ const resolveWindowsCmdEntryScript = (command) => {
19359
+ if (!isWindows) return null;
19360
+ const pathDirectories = (process.env.PATH ?? "").split(path$1.delimiter).filter(Boolean);
19361
+ for (const directory of pathDirectories) {
19362
+ const cmdFilePath = path$1.join(directory, `${command}.cmd`);
19363
+ try {
19364
+ if (!fs$1.statSync(cmdFilePath).isFile()) continue;
19365
+ } catch {
19366
+ continue;
19367
+ }
19368
+ try {
19369
+ const entryScriptMatch = fs$1.readFileSync(cmdFilePath, "utf8").match(/"%(?:~dp0|dp0%)\\([^"]+\.(?:m?js|cjs))"/);
19370
+ if (!entryScriptMatch) continue;
19371
+ const resolvedScriptPath = path$1.resolve(directory, entryScriptMatch[1]);
19372
+ if (fs$1.statSync(resolvedScriptPath).isFile()) return resolvedScriptPath;
19373
+ } catch {}
19374
+ }
19375
+ return null;
19376
+ };
19377
+ const spawnAgent = (command, args, cwd, shell = false) => new Promise((resolve, reject) => {
19378
+ const child = spawn(command, [...args], {
19238
19379
  cwd,
19239
- stdio: "inherit"
19380
+ stdio: "inherit",
19381
+ shell
19240
19382
  });
19241
19383
  child.on("error", reject);
19242
19384
  child.on("close", (code) => resolve(code ?? 0));
19243
19385
  });
19386
+ const launchCliAgent = async (agentId, prompt, cwd) => {
19387
+ const binary = CLI_AGENT_BINARIES[agentId];
19388
+ const agentArgs = [...CLI_AGENT_AUTO_FLAGS[agentId], prompt];
19389
+ if (isWindows) {
19390
+ const entryScript = resolveWindowsCmdEntryScript(binary);
19391
+ if (entryScript) return spawnAgent(process.execPath, [entryScript, ...agentArgs], cwd);
19392
+ }
19393
+ try {
19394
+ return await spawnAgent(binary, agentArgs, cwd);
19395
+ } catch {
19396
+ throw new Error(`Failed to launch ${binary}`);
19397
+ }
19398
+ };
19244
19399
  const CLIPBOARD_COMMANDS = [
19245
19400
  {
19246
19401
  binary: "pbcopy",
@@ -19313,6 +19468,77 @@ const setUpGitHubActions = async (rootDirectory) => {
19313
19468
  }
19314
19469
  cliLogger.log(` Learn more: ${highlighter.info(CI_URL)}`);
19315
19470
  };
19471
+ const UPGRADE_YES_CHOICE = "upgrade-yes";
19472
+ const UPGRADE_NO_CHOICE = "upgrade-no";
19473
+ const UPGRADE_COMMIT_MESSAGE = "ci: upgrade React Doctor GitHub Action to v2";
19474
+ const UPGRADE_PR_TITLE = "Upgrade React Doctor Action to v2";
19475
+ const UPGRADE_PR_BODY = `Bumps the React Doctor GitHub Actions workflow to the action's latest major, \`millionco/react-doctor@v2\`.
19476
+
19477
+ Docs: https://www.react.doctor/ci`;
19478
+ const askUpgradeActionVersion = async () => {
19479
+ const { upgradeChoice } = await prompts({
19480
+ type: "select",
19481
+ name: "upgradeChoice",
19482
+ message: "A new major of the React Doctor Action (v2) is out. Upgrade this repo's workflow?",
19483
+ hint: " ",
19484
+ choices: [{
19485
+ title: "Yes (recommended)",
19486
+ description: "Open a PR bumping the workflow to millionco/react-doctor@v2",
19487
+ value: UPGRADE_YES_CHOICE
19488
+ }, {
19489
+ title: "No, thanks",
19490
+ description: "Keep @v1 — won't ask again for this repo",
19491
+ value: UPGRADE_NO_CHOICE
19492
+ }],
19493
+ initial: 0
19494
+ }, { onCancel: () => true });
19495
+ if (upgradeChoice === void 0) return "cancel";
19496
+ return upgradeChoice === UPGRADE_YES_CHOICE ? "yes" : "no";
19497
+ };
19498
+ const upgradeGitHubActionsWorkflow = async (workflow) => {
19499
+ const { content, changed } = upgradeWorkflowActionToV2(workflow.content);
19500
+ if (!changed) return false;
19501
+ const upgradeSpinner = spinner("Opening a pull request to upgrade React Doctor to v2...").start();
19502
+ try {
19503
+ fs$1.writeFileSync(workflow.workflowPath, content);
19504
+ } catch {
19505
+ upgradeSpinner.fail("Couldn't update the workflow file.");
19506
+ return false;
19507
+ }
19508
+ const pullRequestResult = await openWorkflowPullRequest({
19509
+ workflowPath: workflow.workflowPath,
19510
+ commitMessage: UPGRADE_COMMIT_MESSAGE,
19511
+ prTitle: UPGRADE_PR_TITLE,
19512
+ prBody: UPGRADE_PR_BODY
19513
+ });
19514
+ if (pullRequestResult.status === "pr-opened") upgradeSpinner.succeed(`Opened pull request for review: ${highlighter.info(pullRequestResult.url)}`);
19515
+ else if (pullRequestResult.status === "branch-pushed") upgradeSpinner.warn(`Pushed branch ${highlighter.bold(pullRequestResult.branch)} but couldn't open a PR. Open one with: gh pr create --head ${pullRequestResult.branch}`);
19516
+ else {
19517
+ upgradeSpinner.stop();
19518
+ try {
19519
+ fs$1.writeFileSync(workflow.workflowPath, content);
19520
+ } catch {
19521
+ cliLogger.log(" Couldn't finish the upgrade. Re-run React Doctor to try again.");
19522
+ return false;
19523
+ }
19524
+ const didStage = await stageWorkflowFile({ workflowPath: workflow.workflowPath });
19525
+ cliLogger.log(didStage ? " Updated the workflow to @v2 and staged it. Commit it to finish the upgrade." : " Updated the workflow to @v2. Commit the change to finish the upgrade.");
19526
+ }
19527
+ return true;
19528
+ };
19529
+ const maybeOfferActionUpgrade = async (projectRoot) => {
19530
+ const workflow = readReactDoctorWorkflow(projectRoot);
19531
+ if (!workflow || !workflowUsesV1Action(workflow.content)) return;
19532
+ if (hasHandledActionUpgrade(projectRoot)) return;
19533
+ const outcome = await askUpgradeActionVersion();
19534
+ if (outcome === "cancel") return;
19535
+ recordCount(METRIC.agentHandoff, 1, { outcome: outcome === "yes" ? "upgrade-accepted" : "upgrade-declined" });
19536
+ if (outcome === "no") {
19537
+ recordActionUpgradeDecision(projectRoot, "declined");
19538
+ return;
19539
+ }
19540
+ if (await upgradeGitHubActionsWorkflow(workflow)) recordActionUpgradeDecision(projectRoot, "accepted");
19541
+ };
19316
19542
  const SGR_BOLD_OFF = "\x1B[22m";
19317
19543
  const ciQuestionMessage = [
19318
19544
  "Add React Doctor to GitHub Actions?",
@@ -19360,7 +19586,8 @@ const detectLaunchableAgents = async () => {
19360
19586
  const handoffToAgent = async (input) => {
19361
19587
  if (!input.interactive || input.diagnostics.length === 0) return;
19362
19588
  cliLogger.break();
19363
- if (!isReactDoctorWorkflowInstalled(findNearestPackageDirectory(input.rootDirectory) ?? input.rootDirectory)) {
19589
+ const projectRootForCi = findNearestPackageDirectory(input.rootDirectory) ?? input.rootDirectory;
19590
+ if (!isReactDoctorWorkflowInstalled(projectRootForCi)) {
19364
19591
  const ciOutcome = await askAddToGitHubActions();
19365
19592
  recordCount(METRIC.agentHandoff, 1, {
19366
19593
  outcome: `ci-${ciOutcome}`,
@@ -19371,7 +19598,7 @@ const handoffToAgent = async (input) => {
19371
19598
  await setUpGitHubActions(input.rootDirectory);
19372
19599
  cliLogger.break();
19373
19600
  }
19374
- }
19601
+ } else await maybeOfferActionUpgrade(projectRootForCi);
19375
19602
  const { handoffTarget } = await prompts({
19376
19603
  type: "select",
19377
19604
  name: "handoffTarget",
@@ -19705,7 +19932,7 @@ const getSetupPromptStore = (options = {}) => new Conf({
19705
19932
  projectName: GLOBAL_CONFIG_PROJECT_NAME,
19706
19933
  cwd: options.cwd
19707
19934
  });
19708
- const getSetupPromptProjectKey = (projectRoot) => createHash("sha256").update(path$1.resolve(projectRoot)).digest("hex");
19935
+ const getSetupPromptProjectKey = (projectRoot) => hashProjectRoot(projectRoot);
19709
19936
  const hasDisabledSetupPrompt = (projectRoot, storeOptions = {}) => {
19710
19937
  try {
19711
19938
  return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
@@ -20078,8 +20305,8 @@ const buildChangedFilesDiffInfo = (changedFiles) => ({
20078
20305
  * `react-doctor.config.json` to `doctor.config.ts` before config is loaded,
20079
20306
  * so the scan reads the renamed file and the user is told once. CI, coding
20080
20307
  * agents, JSON/score output, pre-commit (`--staged`) hooks, and non-TTY runs
20081
- * are left untouched — the loader's warning still nudges them — so a scan
20082
- * never mutates the repo unattended.
20308
+ * are left untouched — the loader still reads the legacy file as a deprecated
20309
+ * fallback and warns — so a scan never mutates the repo unattended.
20083
20310
  */
20084
20311
  const maybeMigrateLegacyConfig = (requestedDirectory, { isQuiet, isStaged }) => {
20085
20312
  if (!(!isQuiet && !isStaged && process.stdout.isTTY === true && !isCiOrCodingAgentEnvironment())) return;
@@ -20441,13 +20668,27 @@ const resolveRuleConfigTarget = async (projectRoot) => {
20441
20668
  config: isPlainObject(embedded) ? embedded : {}
20442
20669
  };
20443
20670
  }
20444
- if (loaded.format === "json") return {
20445
- format: "json",
20446
- filePath: loaded.configFilePath,
20447
- directory: loaded.sourceDirectory,
20448
- exists: true,
20449
- config: readObjectFile(loaded.configFilePath) ?? {}
20450
- };
20671
+ if (loaded.format === "json") {
20672
+ if (path$1.basename(loaded.configFilePath) === "react-doctor.config.json") {
20673
+ const legacyConfig = readObjectFile(loaded.configFilePath) ?? {};
20674
+ delete legacyConfig.$schema;
20675
+ return {
20676
+ format: "json",
20677
+ filePath: path$1.join(loaded.sourceDirectory, NEW_CONFIG_FILENAME),
20678
+ directory: loaded.sourceDirectory,
20679
+ exists: false,
20680
+ config: legacyConfig,
20681
+ migratedFromFilePath: loaded.configFilePath
20682
+ };
20683
+ }
20684
+ return {
20685
+ format: "json",
20686
+ filePath: loaded.configFilePath,
20687
+ directory: loaded.sourceDirectory,
20688
+ exists: true,
20689
+ config: readObjectFile(loaded.configFilePath) ?? {}
20690
+ };
20691
+ }
20451
20692
  return {
20452
20693
  format: "module",
20453
20694
  filePath: loaded.configFilePath,
@@ -20526,7 +20767,10 @@ const writeRuleConfig = async (target, nextConfig) => {
20526
20767
  return { written };
20527
20768
  }
20528
20769
  if (target.format === "package-json") writePackageJsonConfig(target.filePath, nextConfig);
20529
- else writeJsonConfig(target.filePath, nextConfig);
20770
+ else {
20771
+ writeJsonConfig(target.filePath, nextConfig);
20772
+ if (target.migratedFromFilePath) fs$1.rmSync(target.migratedFromFilePath, { force: true });
20773
+ }
20530
20774
  clearConfigCache();
20531
20775
  return { written: true };
20532
20776
  };
@@ -21277,4 +21521,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
21277
21521
  export {};
21278
21522
 
21279
21523
  //# sourceMappingURL=cli.js.map
21280
- //# debugId=e56fe2ba-b7f4-5b81-942b-685d55761c6b
21524
+ //# debugId=1486eaee-ed07-5eef-a9d7-51293140e237
package/dist/index.d.ts CHANGED
@@ -453,6 +453,8 @@ interface ProjectInfo {
453
453
  * — no `rn-*` rules load for the project at all.
454
454
  */
455
455
  hasReactNativeWorkspace: boolean;
456
+ nextjsVersion: string | null;
457
+ nextjsMajorVersion: number | null;
456
458
  /**
457
459
  * The declared `expo` package version spec (e.g. `"~51.0.0"`), looked up
458
460
  * in the project or any of its workspace packages, or `null` when `expo`
@@ -940,6 +942,16 @@ declare const filterSourceFiles: (filePaths: string[]) => string[]; //#endregion
940
942
  declare const summarizeDiagnostics: (diagnostics: Diagnostic[], worstScore?: number | null, worstScoreLabel?: string | null) => JsonReportSummary; //#endregion
941
943
  //#region src/validate-config-types.d.ts
942
944
  //#endregion
945
+ //#region src/utils/define-config.d.ts
946
+ /**
947
+ * Identity helper for authoring a typed `doctor.config.{ts,js,mjs,cjs}`.
948
+ * Gives editor autocomplete and type-checking for the config object without
949
+ * an explicit `satisfies ReactDoctorConfig` annotation; returns the config
950
+ * untouched so the loader sees the same plain object either way.
951
+ */
952
+ declare const defineConfig: (config: ReactDoctorConfig) => ReactDoctorConfig; //#endregion
953
+ //#region src/utils/group-by.d.ts
954
+ //#endregion
943
955
  //#region ../api/dist/index.d.ts
944
956
  //#region src/diagnose.d.ts
945
957
  declare const diagnose: (directory: string, options?: DiagnoseOptions) => Promise<DiagnoseResult>;
@@ -987,5 +999,5 @@ interface ToJsonReportOptions {
987
999
  }
988
1000
  declare const toJsonReport: (result: DiagnoseResult, options: ToJsonReportOptions) => JsonReport;
989
1001
  //#endregion
990
- export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectInfo, ProjectNotFoundError, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
1002
+ export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, type ProjectInfo, ProjectNotFoundError, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
991
1003
  //# sourceMappingURL=index.d.ts.map
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]="44e73f8d-b81f-599b-a04e-22497cd72bb2")}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]="03c21420-4548-560c-9a26-8c22558218d8")}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";
@@ -2981,6 +2981,11 @@ const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson,
2981
2981
  if (!isFile(monorepoPackageJsonPath)) return version;
2982
2982
  return resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
2983
2983
  };
2984
+ const getNextjsDependencySpec = (packageJson) => {
2985
+ const spec = packageJson.dependencies?.next ?? packageJson.devDependencies?.next ?? packageJson.peerDependencies?.next ?? packageJson.optionalDependencies?.next;
2986
+ return typeof spec === "string" ? spec : null;
2987
+ };
2988
+ const findNextjsVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getNextjsDependencySpec);
2984
2989
  const getPreactVersion = (packageJson) => {
2985
2990
  return {
2986
2991
  ...packageJson.peerDependencies,
@@ -3233,6 +3238,12 @@ const discoverProject = (directory) => {
3233
3238
  version: findShopifyFlashListVersion(directory, packageJson)
3234
3239
  }) : null;
3235
3240
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
3241
+ const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
3242
+ rootDirectory: directory,
3243
+ rootPackageJson: packageJson,
3244
+ packageName: "next",
3245
+ version: findNextjsVersion(directory, packageJson)
3246
+ }) : null;
3236
3247
  const preactVersion = getPreactVersion(packageJson);
3237
3248
  const projectInfo = {
3238
3249
  rootDirectory: directory,
@@ -3249,6 +3260,8 @@ const discoverProject = (directory) => {
3249
3260
  preactVersion,
3250
3261
  preactMajorVersion: parseReactMajor(preactVersion),
3251
3262
  hasReactNativeWorkspace,
3263
+ nextjsVersion,
3264
+ nextjsMajorVersion: nextjsVersion === null ? null : getLowestDependencyMajor(nextjsVersion),
3252
3265
  expoVersion,
3253
3266
  shopifyFlashListVersion,
3254
3267
  shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
@@ -3363,7 +3376,11 @@ const DIAGNOSTIC_CATEGORY_BUCKETS = [
3363
3376
  "Accessibility",
3364
3377
  "Maintainability"
3365
3378
  ];
3366
- const APP_ONLY_RULE_KEYS = new Set(["react-hooks-js/static-components", "react-doctor/no-render-prop-children"]);
3379
+ const APP_ONLY_RULE_KEYS = new Set([
3380
+ "react-hooks-js/static-components",
3381
+ "react-doctor/no-render-prop-children",
3382
+ "react-doctor/prefer-explicit-variants"
3383
+ ]);
3367
3384
  const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
3368
3385
  const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
3369
3386
  const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
@@ -4587,6 +4604,35 @@ const loadPackageJsonConfig = (directory) => {
4587
4604
  format: "package-json"
4588
4605
  };
4589
4606
  };
4607
+ const loadLegacyConfig = (directory) => {
4608
+ const legacyFilePath = path$1.join(directory, LEGACY_CONFIG_FILENAME);
4609
+ if (!isFile(legacyFilePath)) return {
4610
+ status: "absent",
4611
+ loaded: null
4612
+ };
4613
+ try {
4614
+ const parsed = readDataConfig(legacyFilePath);
4615
+ if (isPlainObject(parsed)) {
4616
+ warn(`${LEGACY_CONFIG_FILENAME} is deprecated — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts). It is still read for now.`);
4617
+ return {
4618
+ status: "found",
4619
+ loaded: {
4620
+ config: validateConfigTypes(parsed),
4621
+ sourceDirectory: directory,
4622
+ configFilePath: legacyFilePath,
4623
+ format: "json"
4624
+ }
4625
+ };
4626
+ }
4627
+ warn(`${LEGACY_CONFIG_FILENAME} must contain an object, ignoring.`);
4628
+ } catch (error) {
4629
+ warn(`Failed to load ${LEGACY_CONFIG_FILENAME}: ${formatError(error)}`);
4630
+ }
4631
+ return {
4632
+ status: "invalid",
4633
+ loaded: null
4634
+ };
4635
+ };
4590
4636
  const loadConfigFromDirectory = async (directory) => {
4591
4637
  let sawBrokenConfigFile = false;
4592
4638
  for (const extension of CONFIG_EXTENSIONS) {
@@ -4616,7 +4662,8 @@ const loadConfigFromDirectory = async (directory) => {
4616
4662
  status: "found",
4617
4663
  loaded: packageJsonConfig
4618
4664
  };
4619
- if (isFile(path$1.join(directory, LEGACY_CONFIG_FILENAME))) warn(`${LEGACY_CONFIG_FILENAME} is no longer read — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts).`);
4665
+ const legacyResult = loadLegacyConfig(directory);
4666
+ if (legacyResult.status !== "absent") return legacyResult;
4620
4667
  return {
4621
4668
  status: sawBrokenConfigFile ? "invalid" : "absent",
4622
4669
  loaded: null
@@ -5343,6 +5390,7 @@ const checkReducedMotion = (rootDirectory) => {
5343
5390
  if (!hasMotionLibrary) return [];
5344
5391
  const result = spawnSync("git", [
5345
5392
  "grep",
5393
+ "--untracked",
5346
5394
  "-ql",
5347
5395
  "-E",
5348
5396
  REDUCED_MOTION_GREP_PATTERN,
@@ -6697,6 +6745,7 @@ const buildCapabilities = (project) => {
6697
6745
  capabilities.add(project.framework);
6698
6746
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6699
6747
  if (project.expoVersion !== null) capabilities.add("expo");
6748
+ if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
6700
6749
  const reactMajor = project.reactMajorVersion;
6701
6750
  if (reactMajor !== null) {
6702
6751
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -7641,7 +7690,12 @@ const SANITIZED_ENV = (() => {
7641
7690
  const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLINT_SPAWN_TIMEOUT_MS, outputMaxBytes = OXLINT_OUTPUT_MAX_BYTES) => new Promise((resolve, reject) => {
7642
7691
  const child = spawn(nodeBinaryPath, args, {
7643
7692
  cwd: rootDirectory,
7644
- env: SANITIZED_ENV
7693
+ env: SANITIZED_ENV,
7694
+ stdio: [
7695
+ "ignore",
7696
+ "pipe",
7697
+ "pipe"
7698
+ ]
7645
7699
  });
7646
7700
  const timeoutHandle = setTimeout(() => {
7647
7701
  child.kill("SIGKILL");
@@ -8861,6 +8915,13 @@ const filterSourceFiles = (filePaths) => filePaths.filter(isLintableSourceFile);
8861
8915
  * other `clear*` helpers.
8862
8916
  */
8863
8917
  const clearAutoSuppressionCaches = () => {};
8918
+ /**
8919
+ * Identity helper for authoring a typed `doctor.config.{ts,js,mjs,cjs}`.
8920
+ * Gives editor autocomplete and type-checking for the config object without
8921
+ * an explicit `satisfies ReactDoctorConfig` annotation; returns the config
8922
+ * untouched so the loader sees the same plain object either way.
8923
+ */
8924
+ const defineConfig = (config) => config;
8864
8925
  //#endregion
8865
8926
  //#region ../api/dist/index.js
8866
8927
  const buildDiagnoseLayer = (configLayer = Config.layerNode) => Layer.mergeAll(Project.layerNode, configLayer, DeadCode.layerNode, Files.layerNode, Git.layerNode, Linter.layerOxlint, LintPartialFailures.layerLive, Progress.layerNoop, Reporter.layerNoop, Score.layerHttp);
@@ -8926,7 +8987,7 @@ const toJsonReport = (result, options) => buildJsonReport({
8926
8987
  totalElapsedMilliseconds: result.elapsedMilliseconds
8927
8988
  });
8928
8989
  //#endregion
8929
- export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8990
+ export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8930
8991
 
8931
8992
  //# sourceMappingURL=index.js.map
8932
- //# debugId=44e73f8d-b81f-599b-a04e-22497cd72bb2
8993
+ //# debugId=03c21420-4548-560c-9a26-8c22558218d8
package/dist/lsp.js CHANGED
@@ -2992,6 +2992,11 @@ const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson,
2992
2992
  if (!isFile(monorepoPackageJsonPath)) return version;
2993
2993
  return resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
2994
2994
  };
2995
+ const getNextjsDependencySpec = (packageJson) => {
2996
+ const spec = packageJson.dependencies?.next ?? packageJson.devDependencies?.next ?? packageJson.peerDependencies?.next ?? packageJson.optionalDependencies?.next;
2997
+ return typeof spec === "string" ? spec : null;
2998
+ };
2999
+ const findNextjsVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getNextjsDependencySpec);
2995
3000
  const getPreactVersion = (packageJson) => {
2996
3001
  return {
2997
3002
  ...packageJson.peerDependencies,
@@ -3244,6 +3249,12 @@ const discoverProject = (directory) => {
3244
3249
  version: findShopifyFlashListVersion(directory, packageJson)
3245
3250
  }) : null;
3246
3251
  const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
3252
+ const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
3253
+ rootDirectory: directory,
3254
+ rootPackageJson: packageJson,
3255
+ packageName: "next",
3256
+ version: findNextjsVersion(directory, packageJson)
3257
+ }) : null;
3247
3258
  const preactVersion = getPreactVersion(packageJson);
3248
3259
  const projectInfo = {
3249
3260
  rootDirectory: directory,
@@ -3260,6 +3271,8 @@ const discoverProject = (directory) => {
3260
3271
  preactVersion,
3261
3272
  preactMajorVersion: parseReactMajor(preactVersion),
3262
3273
  hasReactNativeWorkspace,
3274
+ nextjsVersion,
3275
+ nextjsMajorVersion: nextjsVersion === null ? null : getLowestDependencyMajor(nextjsVersion),
3263
3276
  expoVersion,
3264
3277
  shopifyFlashListVersion,
3265
3278
  shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
@@ -3374,7 +3387,11 @@ const DIAGNOSTIC_CATEGORY_BUCKETS = [
3374
3387
  "Accessibility",
3375
3388
  "Maintainability"
3376
3389
  ];
3377
- const APP_ONLY_RULE_KEYS = new Set(["react-hooks-js/static-components", "react-doctor/no-render-prop-children"]);
3390
+ const APP_ONLY_RULE_KEYS = new Set([
3391
+ "react-hooks-js/static-components",
3392
+ "react-doctor/no-render-prop-children",
3393
+ "react-doctor/prefer-explicit-variants"
3394
+ ]);
3378
3395
  const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
3379
3396
  const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
3380
3397
  const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
@@ -4572,6 +4589,35 @@ const loadPackageJsonConfig = (directory) => {
4572
4589
  format: "package-json"
4573
4590
  };
4574
4591
  };
4592
+ const loadLegacyConfig = (directory) => {
4593
+ const legacyFilePath = path$1.join(directory, LEGACY_CONFIG_FILENAME);
4594
+ if (!isFile(legacyFilePath)) return {
4595
+ status: "absent",
4596
+ loaded: null
4597
+ };
4598
+ try {
4599
+ const parsed = readDataConfig(legacyFilePath);
4600
+ if (isPlainObject(parsed)) {
4601
+ warn(`${LEGACY_CONFIG_FILENAME} is deprecated — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts). It is still read for now.`);
4602
+ return {
4603
+ status: "found",
4604
+ loaded: {
4605
+ config: validateConfigTypes(parsed),
4606
+ sourceDirectory: directory,
4607
+ configFilePath: legacyFilePath,
4608
+ format: "json"
4609
+ }
4610
+ };
4611
+ }
4612
+ warn(`${LEGACY_CONFIG_FILENAME} must contain an object, ignoring.`);
4613
+ } catch (error) {
4614
+ warn(`Failed to load ${LEGACY_CONFIG_FILENAME}: ${formatError(error)}`);
4615
+ }
4616
+ return {
4617
+ status: "invalid",
4618
+ loaded: null
4619
+ };
4620
+ };
4575
4621
  const loadConfigFromDirectory = async (directory) => {
4576
4622
  let sawBrokenConfigFile = false;
4577
4623
  for (const extension of CONFIG_EXTENSIONS) {
@@ -4601,7 +4647,8 @@ const loadConfigFromDirectory = async (directory) => {
4601
4647
  status: "found",
4602
4648
  loaded: packageJsonConfig
4603
4649
  };
4604
- if (isFile(path$1.join(directory, LEGACY_CONFIG_FILENAME))) warn(`${LEGACY_CONFIG_FILENAME} is no longer read — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts).`);
4650
+ const legacyResult = loadLegacyConfig(directory);
4651
+ if (legacyResult.status !== "absent") return legacyResult;
4605
4652
  return {
4606
4653
  status: sawBrokenConfigFile ? "invalid" : "absent",
4607
4654
  loaded: null
@@ -5280,6 +5327,7 @@ const checkReducedMotion = (rootDirectory) => {
5280
5327
  if (!hasMotionLibrary) return [];
5281
5328
  const result = spawnSync("git", [
5282
5329
  "grep",
5330
+ "--untracked",
5283
5331
  "-ql",
5284
5332
  "-E",
5285
5333
  REDUCED_MOTION_GREP_PATTERN,
@@ -6634,6 +6682,7 @@ const buildCapabilities = (project) => {
6634
6682
  capabilities.add(project.framework);
6635
6683
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6636
6684
  if (project.expoVersion !== null) capabilities.add("expo");
6685
+ if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
6637
6686
  const reactMajor = project.reactMajorVersion;
6638
6687
  if (reactMajor !== null) {
6639
6688
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -7578,7 +7627,12 @@ const SANITIZED_ENV = (() => {
7578
7627
  const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLINT_SPAWN_TIMEOUT_MS, outputMaxBytes = OXLINT_OUTPUT_MAX_BYTES) => new Promise((resolve, reject) => {
7579
7628
  const child = spawn(nodeBinaryPath, args, {
7580
7629
  cwd: rootDirectory,
7581
- env: SANITIZED_ENV
7630
+ env: SANITIZED_ENV,
7631
+ stdio: [
7632
+ "ignore",
7633
+ "pipe",
7634
+ "pipe"
7635
+ ]
7582
7636
  });
7583
7637
  const timeoutHandle = setTimeout(() => {
7584
7638
  child.kill("SIGKILL");
@@ -8712,7 +8766,7 @@ const getRuleMetadata = (plugin, rule) => {
8712
8766
  /** Display name used in client-facing messages and progress titles. */
8713
8767
  const SERVER_DISPLAY_NAME = "React Doctor";
8714
8768
  /** Server version reported in `serverInfo`; injected at build, `dev` from source. */
8715
- const SERVER_VERSION = "0.2.12";
8769
+ const SERVER_VERSION = "0.2.13";
8716
8770
  /** `Diagnostic.source` shown next to every published diagnostic. */
8717
8771
  const DIAGNOSTIC_SOURCE = "react-doctor";
8718
8772
  /**
@@ -10800,5 +10854,5 @@ const startLanguageServer = () => {
10800
10854
  };
10801
10855
  //#endregion
10802
10856
  export { startLanguageServer };
10803
- !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]="367f0c6f-8633-512f-b006-f1bb7ab5a35a")}catch(e){}}();
10804
- //# debugId=367f0c6f-8633-512f-b006-f1bb7ab5a35a
10857
+ !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]="8c84897d-6e79-562b-a26b-06e2ce6de99e")}catch(e){}}();
10858
+ //# debugId=8c84897d-6e79-562b-a26b-06e2ce6de99e
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.4.0",
3
+ "version": "0.4.1-dev.d17dc87",
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.19",
58
+ "deslop-js": "^0.0.21",
59
59
  "effect": "4.0.0-beta.70",
60
60
  "eslint-plugin-react-hooks": "^7.1.1",
61
61
  "jiti": "^2.7.0",
@@ -66,7 +66,7 @@
66
66
  "vscode-languageserver": "^9.0.1",
67
67
  "vscode-languageserver-textdocument": "^1.0.12",
68
68
  "vscode-uri": "^3.1.0",
69
- "oxlint-plugin-react-doctor": "0.4.0"
69
+ "oxlint-plugin-react-doctor": "0.4.1-dev.d17dc87"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/babel__code-frame": "^7.27.0",
@@ -74,9 +74,9 @@
74
74
  "@xterm/headless": "^6.0.0",
75
75
  "commander": "^14.0.3",
76
76
  "ora": "^9.4.0",
77
- "@react-doctor/core": "0.3.0",
78
- "@react-doctor/api": "0.2.20",
79
- "@react-doctor/language-server": "0.2.12"
77
+ "@react-doctor/api": "0.2.21",
78
+ "@react-doctor/core": "0.3.1",
79
+ "@react-doctor/language-server": "0.2.13"
80
80
  },
81
81
  "engines": {
82
82
  "node": "^20.19.0 || >=22.12.0"