react-doctor 0.4.0 → 0.4.1-dev.7d4b996

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
@@ -66,6 +66,7 @@ permissions:
66
66
  contents: read
67
67
  pull-requests: write
68
68
  issues: write
69
+ statuses: write # lets the action publish the score as a commit status
69
70
 
70
71
  concurrency:
71
72
  group: react-doctor-${{ github.event.pull_request.number || github.ref }}
@@ -78,15 +79,15 @@ jobs:
78
79
  - uses: actions/checkout@v5
79
80
  with:
80
81
  fetch-depth: 0 # so React Doctor can diff against the merge-base for new-vs-existing
81
- - uses: millionco/react-doctor@v1
82
+ - uses: millionco/react-doctor@v2
82
83
  ```
83
84
 
84
85
  `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
 
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
+ `@v2` always resolves to the latest `v2.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
 
88
89
  ```yaml
89
- - uses: millionco/react-doctor@b612664043a9be414166e3c6a69b355e39a8dcf4 # v1.1.1
90
+ - uses: millionco/react-doctor@75932719d11ef50e110eac01ce04acdc05fde074 # v2.0.1
90
91
  ```
91
92
 
92
93
  [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]="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]="6ef6b306-718a-5ef6-81bb-b6465cd32f04")}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;
@@ -8394,6 +8411,7 @@ const checkReducedMotion = (rootDirectory) => {
8394
8411
  if (!hasMotionLibrary) return [];
8395
8412
  const result = spawnSync("git", [
8396
8413
  "grep",
8414
+ "--untracked",
8397
8415
  "-ql",
8398
8416
  "-E",
8399
8417
  REDUCED_MOTION_GREP_PATTERN,
@@ -9764,6 +9782,7 @@ const buildCapabilities = (project) => {
9764
9782
  capabilities.add(project.framework);
9765
9783
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
9766
9784
  if (project.expoVersion !== null) capabilities.add("expo");
9785
+ if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
9767
9786
  const reactMajor = project.reactMajorVersion;
9768
9787
  if (reactMajor !== null) {
9769
9788
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -10708,7 +10727,12 @@ const SANITIZED_ENV = (() => {
10708
10727
  const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLINT_SPAWN_TIMEOUT_MS, outputMaxBytes = OXLINT_OUTPUT_MAX_BYTES) => new Promise((resolve, reject) => {
10709
10728
  const child = spawn(nodeBinaryPath, args, {
10710
10729
  cwd: rootDirectory,
10711
- env: SANITIZED_ENV
10730
+ env: SANITIZED_ENV,
10731
+ stdio: [
10732
+ "ignore",
10733
+ "pipe",
10734
+ "pipe"
10735
+ ]
10712
10736
  });
10713
10737
  const timeoutHandle = setTimeout(() => {
10714
10738
  child.kill("SIGKILL");
@@ -12191,7 +12215,7 @@ const makeNoopConsole = () => ({
12191
12215
  });
12192
12216
  //#endregion
12193
12217
  //#region src/cli/utils/version.ts
12194
- const VERSION = "0.4.0";
12218
+ const VERSION = "0.4.1-dev.7d4b996";
12195
12219
  //#endregion
12196
12220
  //#region src/cli/utils/json-mode.ts
12197
12221
  let context = null;
@@ -12549,13 +12573,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
12549
12573
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
12550
12574
  * standard `SENTRY_RELEASE` override.
12551
12575
  */
12552
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.0`;
12576
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.4.1-dev.7d4b996`;
12553
12577
  /**
12554
12578
  * Deployment environment shown in Sentry's environment filter. Defaults to
12555
12579
  * `production` for tagged releases and `development` for dev/unbuilt versions,
12556
12580
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
12557
12581
  */
12558
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.0") ? "development" : "production");
12582
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.4.1-dev.7d4b996") ? "development" : "production");
12559
12583
  /**
12560
12584
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
12561
12585
  * (set to `0` to disable tracing) and falls back to
@@ -16752,10 +16776,10 @@ const canAnimateOnboarding = (stream = process.stdout) => {
16752
16776
  };
16753
16777
  //#endregion
16754
16778
  //#region src/cli/utils/onboarding-state.ts
16755
- const GLOBAL_CONFIG_PROJECT_NAME$1 = "react-doctor";
16779
+ const GLOBAL_CONFIG_PROJECT_NAME$2 = "react-doctor";
16756
16780
  const ONBOARDED_AT_KEY = "onboardedAt";
16757
16781
  const getOnboardingStore = (options = {}) => new Conf({
16758
- projectName: GLOBAL_CONFIG_PROJECT_NAME$1,
16782
+ projectName: GLOBAL_CONFIG_PROJECT_NAME$2,
16759
16783
  cwd: options.cwd
16760
16784
  });
16761
16785
  const hasCompletedOnboarding = (options = {}) => {
@@ -17719,9 +17743,9 @@ const buildHandoffPayload = (input) => {
17719
17743
  };
17720
17744
  //#endregion
17721
17745
  //#region src/cli/utils/is-command-available.ts
17722
- const isWindows = process.platform === "win32";
17746
+ const isWindows$1 = process.platform === "win32";
17723
17747
  const candidateFileNames = (command) => {
17724
- if (!isWindows || path$1.extname(command)) return [command];
17748
+ if (!isWindows$1 || path$1.extname(command)) return [command];
17725
17749
  return [command, ...(process.env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").map((extension) => extension.trim()).filter(Boolean).map((extension) => `${command}${extension}`)];
17726
17750
  };
17727
17751
  const isCommandAvailable = (command) => {
@@ -17730,7 +17754,7 @@ const isCommandAvailable = (command) => {
17730
17754
  const binaryPath = path$1.join(directory, fileName);
17731
17755
  try {
17732
17756
  if (!fs$1.statSync(binaryPath).isFile()) continue;
17733
- if (!isWindows) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
17757
+ if (!isWindows$1) fs$1.accessSync(binaryPath, fs$1.constants.X_OK);
17734
17758
  return true;
17735
17759
  } catch {}
17736
17760
  }
@@ -18143,6 +18167,11 @@ permissions:
18143
18167
  # comments (PRs are issues under the hood). Not exercised on \`push\`
18144
18168
  # events, so safe to drop if you only run on \`main\`.
18145
18169
  issues: write
18170
+ # Lets the action publish a commit status with the score + error/warning
18171
+ # counts (links to the run). This is how a \`push\` to \`main\` surfaces its
18172
+ # result, since the PR comment is skipped off pull requests. Drop it to
18173
+ # disable the status (or set \`commit-status: false\` below).
18174
+ statuses: write
18146
18175
 
18147
18176
  # Cancels any in-flight scan for the same PR (or branch, on push) the moment
18148
18177
  # a new commit arrives, so reviewers only ever see the latest run.
@@ -18156,20 +18185,42 @@ jobs:
18156
18185
  steps:
18157
18186
  - uses: actions/checkout@v5
18158
18187
 
18159
- - uses: millionco/react-doctor@v1
18188
+ - uses: millionco/react-doctor@v2
18160
18189
  # Common configuration knobs — uncomment any to override the default.
18161
18190
  # Full reference: https://www.react.doctor/ci
18162
18191
  # 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"
18192
+ # blocking: warning # Gate level: "error" (default) | "warning" | "none" (advisory)
18193
+ # scope: full # On PRs, scan the whole project instead of just changed files
18165
18194
  # 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"
18195
+ # review-comments: false # Disable inline review comments on changed lines
18196
+ # commit-status: false # Disable the commit status (score + counts, links to the run)
18197
+ # version: "0.4.0" # Pin to a specific react-doctor version instead of "latest"
18168
18198
  # directory: apps/web # Scan a sub-directory (default: ".")
18169
18199
  # project: "web,admin" # In a monorepo, scan specific workspace project(s)
18170
18200
  `;
18171
18201
  const getReactDoctorWorkflowPath = (projectRoot) => path$1.join(projectRoot, ".github", "workflows", "react-doctor.yml");
18172
18202
  const isReactDoctorWorkflowInstalled = (projectRoot) => fs$1.existsSync(getReactDoctorWorkflowPath(projectRoot));
18203
+ const V1_FLOATING_ACTION_REF = String.raw`millionco/react-doctor@v1(?![\w.])`;
18204
+ const V2_FLOATING_ACTION_REF = "millionco/react-doctor@v2";
18205
+ const readReactDoctorWorkflow = (projectRoot) => {
18206
+ const workflowPath = getReactDoctorWorkflowPath(projectRoot);
18207
+ try {
18208
+ return {
18209
+ workflowPath,
18210
+ content: fs$1.readFileSync(workflowPath, "utf8")
18211
+ };
18212
+ } catch {
18213
+ return null;
18214
+ }
18215
+ };
18216
+ const workflowUsesV1Action = (content) => new RegExp(V1_FLOATING_ACTION_REF).test(content);
18217
+ const upgradeWorkflowActionToV2 = (content) => {
18218
+ const upgraded = content.replace(new RegExp(V1_FLOATING_ACTION_REF, "g"), V2_FLOATING_ACTION_REF);
18219
+ return {
18220
+ content: upgraded,
18221
+ changed: upgraded !== content
18222
+ };
18223
+ };
18173
18224
  const installReactDoctorWorkflow = (projectRoot) => {
18174
18225
  const workflowPath = getReactDoctorWorkflowPath(projectRoot);
18175
18226
  if (fs$1.existsSync(workflowPath)) return {
@@ -18999,6 +19050,41 @@ const runInstallReactDoctor = async (options = {}) => {
18999
19050
  for (const agent of selectedAgents) recordCount(METRIC.installAgent, 1, { agent });
19000
19051
  };
19001
19052
  //#endregion
19053
+ //#region src/cli/utils/hash-project-root.ts
19054
+ const hashProjectRoot = (projectRoot) => createHash("sha256").update(path$1.resolve(projectRoot)).digest("hex");
19055
+ //#endregion
19056
+ //#region src/cli/utils/action-upgrade-prompt.ts
19057
+ const GLOBAL_CONFIG_PROJECT_NAME$1 = "react-doctor";
19058
+ const getActionUpgradeStore = (options = {}) => new Conf({
19059
+ projectName: GLOBAL_CONFIG_PROJECT_NAME$1,
19060
+ cwd: options.cwd
19061
+ });
19062
+ const hasHandledActionUpgrade = (projectRoot, storeOptions = {}) => {
19063
+ try {
19064
+ const upgrades = getActionUpgradeStore(storeOptions).get("actionUpgrades", {});
19065
+ return Boolean(upgrades[hashProjectRoot(projectRoot)]);
19066
+ } catch {
19067
+ return true;
19068
+ }
19069
+ };
19070
+ const recordActionUpgradeDecision = (projectRoot, outcome, storeOptions = {}) => {
19071
+ try {
19072
+ const store = getActionUpgradeStore(storeOptions);
19073
+ const upgrades = store.get("actionUpgrades", {});
19074
+ store.set("actionUpgrades", {
19075
+ ...upgrades,
19076
+ [hashProjectRoot(projectRoot)]: {
19077
+ rootDirectory: path$1.resolve(projectRoot),
19078
+ outcome,
19079
+ at: (/* @__PURE__ */ new Date()).toISOString()
19080
+ }
19081
+ });
19082
+ return true;
19083
+ } catch {
19084
+ return false;
19085
+ }
19086
+ };
19087
+ //#endregion
19002
19088
  //#region src/cli/utils/install-skill-for-agent.ts
19003
19089
  const installReactDoctorSkillForAgent = async (agent, projectRoot) => {
19004
19090
  const source = getSkillSourceDirectory();
@@ -19049,9 +19135,9 @@ const openUrl = (url) => {
19049
19135
  //#endregion
19050
19136
  //#region src/cli/utils/open-workflow-pull-request.ts
19051
19137
  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.
19138
+ const DEFAULT_COMMIT_MESSAGE = "ci: add React Doctor GitHub Actions workflow";
19139
+ const DEFAULT_PR_TITLE = "Add React Doctor to GitHub Actions";
19140
+ 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
19141
 
19056
19142
  Docs: https://www.react.doctor/ci`;
19057
19143
  const execFileAsync = promisify(execFile);
@@ -19103,6 +19189,9 @@ const findUniqueBranchName = async (cwd) => {
19103
19189
  };
19104
19190
  const openWorkflowPullRequest = async (params) => {
19105
19191
  const workflowPath = path$1.resolve(params.workflowPath);
19192
+ const commitMessage = params.commitMessage ?? DEFAULT_COMMIT_MESSAGE;
19193
+ const prTitle = params.prTitle ?? DEFAULT_PR_TITLE;
19194
+ const prBody = params.prBody ?? DEFAULT_PR_BODY;
19106
19195
  const repoRootProbe = await run("git", ["rev-parse", "--show-toplevel"], path$1.dirname(workflowPath));
19107
19196
  if (!repoRootProbe.success) return {
19108
19197
  status: "not-attempted",
@@ -19169,7 +19258,7 @@ const openWorkflowPullRequest = async (params) => {
19169
19258
  if (!(await run("git", [
19170
19259
  "commit",
19171
19260
  "-m",
19172
- COMMIT_MESSAGE
19261
+ commitMessage
19173
19262
  ], cwd)).success) {
19174
19263
  await restoreToPreviousBranch(true);
19175
19264
  return {
@@ -19193,9 +19282,9 @@ const openWorkflowPullRequest = async (params) => {
19193
19282
  "pr",
19194
19283
  "create",
19195
19284
  "--title",
19196
- PR_TITLE,
19285
+ prTitle,
19197
19286
  "--body",
19198
- PR_BODY,
19287
+ prBody,
19199
19288
  "--base",
19200
19289
  defaultBranch,
19201
19290
  "--head",
@@ -19223,6 +19312,7 @@ const stageWorkflowFile = async (params) => {
19223
19312
  };
19224
19313
  //#endregion
19225
19314
  //#region src/cli/utils/launch-agent.ts
19315
+ const isWindows = process.platform === "win32";
19226
19316
  const CLI_AGENT_BINARIES = {
19227
19317
  "claude-code": "claude",
19228
19318
  codex: "codex",
@@ -19233,14 +19323,47 @@ const CLI_AGENT_AUTO_FLAGS = {
19233
19323
  codex: ["--yolo"],
19234
19324
  cursor: ["--force"]
19235
19325
  };
19236
- const launchCliAgent = (agentId, prompt, cwd) => new Promise((resolve, reject) => {
19237
- const child = spawn(CLI_AGENT_BINARIES[agentId], [...CLI_AGENT_AUTO_FLAGS[agentId], prompt], {
19326
+ const resolveWindowsCmdEntryScript = (command) => {
19327
+ if (!isWindows) return null;
19328
+ const pathDirectories = (process.env.PATH ?? "").split(path$1.delimiter).filter(Boolean);
19329
+ for (const directory of pathDirectories) {
19330
+ const cmdFilePath = path$1.join(directory, `${command}.cmd`);
19331
+ try {
19332
+ if (!fs$1.statSync(cmdFilePath).isFile()) continue;
19333
+ } catch {
19334
+ continue;
19335
+ }
19336
+ try {
19337
+ const entryScriptMatch = fs$1.readFileSync(cmdFilePath, "utf8").match(/"%(?:~dp0|dp0%)\\([^"]+\.(?:m?js|cjs))"/);
19338
+ if (!entryScriptMatch) continue;
19339
+ const resolvedScriptPath = path$1.resolve(directory, entryScriptMatch[1]);
19340
+ if (fs$1.statSync(resolvedScriptPath).isFile()) return resolvedScriptPath;
19341
+ } catch {}
19342
+ }
19343
+ return null;
19344
+ };
19345
+ const spawnAgent = (command, args, cwd, shell = false) => new Promise((resolve, reject) => {
19346
+ const child = spawn(command, [...args], {
19238
19347
  cwd,
19239
- stdio: "inherit"
19348
+ stdio: "inherit",
19349
+ shell
19240
19350
  });
19241
19351
  child.on("error", reject);
19242
19352
  child.on("close", (code) => resolve(code ?? 0));
19243
19353
  });
19354
+ const launchCliAgent = async (agentId, prompt, cwd) => {
19355
+ const binary = CLI_AGENT_BINARIES[agentId];
19356
+ const agentArgs = [...CLI_AGENT_AUTO_FLAGS[agentId], prompt];
19357
+ if (isWindows) {
19358
+ const entryScript = resolveWindowsCmdEntryScript(binary);
19359
+ if (entryScript) return spawnAgent(process.execPath, [entryScript, ...agentArgs], cwd);
19360
+ }
19361
+ try {
19362
+ return await spawnAgent(binary, agentArgs, cwd);
19363
+ } catch {
19364
+ throw new Error(`Failed to launch ${binary}`);
19365
+ }
19366
+ };
19244
19367
  const CLIPBOARD_COMMANDS = [
19245
19368
  {
19246
19369
  binary: "pbcopy",
@@ -19313,6 +19436,77 @@ const setUpGitHubActions = async (rootDirectory) => {
19313
19436
  }
19314
19437
  cliLogger.log(` Learn more: ${highlighter.info(CI_URL)}`);
19315
19438
  };
19439
+ const UPGRADE_YES_CHOICE = "upgrade-yes";
19440
+ const UPGRADE_NO_CHOICE = "upgrade-no";
19441
+ const UPGRADE_COMMIT_MESSAGE = "ci: upgrade React Doctor GitHub Action to v2";
19442
+ const UPGRADE_PR_TITLE = "Upgrade React Doctor Action to v2";
19443
+ const UPGRADE_PR_BODY = `Bumps the React Doctor GitHub Actions workflow to the action's latest major, \`millionco/react-doctor@v2\`.
19444
+
19445
+ Docs: https://www.react.doctor/ci`;
19446
+ const askUpgradeActionVersion = async () => {
19447
+ const { upgradeChoice } = await prompts({
19448
+ type: "select",
19449
+ name: "upgradeChoice",
19450
+ message: "A new major of the React Doctor Action (v2) is out. Upgrade this repo's workflow?",
19451
+ hint: " ",
19452
+ choices: [{
19453
+ title: "Yes (recommended)",
19454
+ description: "Open a PR bumping the workflow to millionco/react-doctor@v2",
19455
+ value: UPGRADE_YES_CHOICE
19456
+ }, {
19457
+ title: "No, thanks",
19458
+ description: "Keep @v1 — won't ask again for this repo",
19459
+ value: UPGRADE_NO_CHOICE
19460
+ }],
19461
+ initial: 0
19462
+ }, { onCancel: () => true });
19463
+ if (upgradeChoice === void 0) return "cancel";
19464
+ return upgradeChoice === UPGRADE_YES_CHOICE ? "yes" : "no";
19465
+ };
19466
+ const upgradeGitHubActionsWorkflow = async (workflow) => {
19467
+ const { content, changed } = upgradeWorkflowActionToV2(workflow.content);
19468
+ if (!changed) return false;
19469
+ const upgradeSpinner = spinner("Opening a pull request to upgrade React Doctor to v2...").start();
19470
+ try {
19471
+ fs$1.writeFileSync(workflow.workflowPath, content);
19472
+ } catch {
19473
+ upgradeSpinner.fail("Couldn't update the workflow file.");
19474
+ return false;
19475
+ }
19476
+ const pullRequestResult = await openWorkflowPullRequest({
19477
+ workflowPath: workflow.workflowPath,
19478
+ commitMessage: UPGRADE_COMMIT_MESSAGE,
19479
+ prTitle: UPGRADE_PR_TITLE,
19480
+ prBody: UPGRADE_PR_BODY
19481
+ });
19482
+ if (pullRequestResult.status === "pr-opened") upgradeSpinner.succeed(`Opened pull request for review: ${highlighter.info(pullRequestResult.url)}`);
19483
+ 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}`);
19484
+ else {
19485
+ upgradeSpinner.stop();
19486
+ try {
19487
+ fs$1.writeFileSync(workflow.workflowPath, content);
19488
+ } catch {
19489
+ cliLogger.log(" Couldn't finish the upgrade. Re-run React Doctor to try again.");
19490
+ return false;
19491
+ }
19492
+ const didStage = await stageWorkflowFile({ workflowPath: workflow.workflowPath });
19493
+ 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.");
19494
+ }
19495
+ return true;
19496
+ };
19497
+ const maybeOfferActionUpgrade = async (projectRoot) => {
19498
+ const workflow = readReactDoctorWorkflow(projectRoot);
19499
+ if (!workflow || !workflowUsesV1Action(workflow.content)) return;
19500
+ if (hasHandledActionUpgrade(projectRoot)) return;
19501
+ const outcome = await askUpgradeActionVersion();
19502
+ if (outcome === "cancel") return;
19503
+ recordCount(METRIC.agentHandoff, 1, { outcome: outcome === "yes" ? "upgrade-accepted" : "upgrade-declined" });
19504
+ if (outcome === "no") {
19505
+ recordActionUpgradeDecision(projectRoot, "declined");
19506
+ return;
19507
+ }
19508
+ if (await upgradeGitHubActionsWorkflow(workflow)) recordActionUpgradeDecision(projectRoot, "accepted");
19509
+ };
19316
19510
  const SGR_BOLD_OFF = "\x1B[22m";
19317
19511
  const ciQuestionMessage = [
19318
19512
  "Add React Doctor to GitHub Actions?",
@@ -19360,7 +19554,8 @@ const detectLaunchableAgents = async () => {
19360
19554
  const handoffToAgent = async (input) => {
19361
19555
  if (!input.interactive || input.diagnostics.length === 0) return;
19362
19556
  cliLogger.break();
19363
- if (!isReactDoctorWorkflowInstalled(findNearestPackageDirectory(input.rootDirectory) ?? input.rootDirectory)) {
19557
+ const projectRootForCi = findNearestPackageDirectory(input.rootDirectory) ?? input.rootDirectory;
19558
+ if (!isReactDoctorWorkflowInstalled(projectRootForCi)) {
19364
19559
  const ciOutcome = await askAddToGitHubActions();
19365
19560
  recordCount(METRIC.agentHandoff, 1, {
19366
19561
  outcome: `ci-${ciOutcome}`,
@@ -19371,7 +19566,7 @@ const handoffToAgent = async (input) => {
19371
19566
  await setUpGitHubActions(input.rootDirectory);
19372
19567
  cliLogger.break();
19373
19568
  }
19374
- }
19569
+ } else await maybeOfferActionUpgrade(projectRootForCi);
19375
19570
  const { handoffTarget } = await prompts({
19376
19571
  type: "select",
19377
19572
  name: "handoffTarget",
@@ -19705,7 +19900,7 @@ const getSetupPromptStore = (options = {}) => new Conf({
19705
19900
  projectName: GLOBAL_CONFIG_PROJECT_NAME,
19706
19901
  cwd: options.cwd
19707
19902
  });
19708
- const getSetupPromptProjectKey = (projectRoot) => createHash("sha256").update(path$1.resolve(projectRoot)).digest("hex");
19903
+ const getSetupPromptProjectKey = (projectRoot) => hashProjectRoot(projectRoot);
19709
19904
  const hasDisabledSetupPrompt = (projectRoot, storeOptions = {}) => {
19710
19905
  try {
19711
19906
  return getSetupPromptStore(storeOptions).get("projects", {})[getSetupPromptProjectKey(projectRoot)]?.setupPrompt === false;
@@ -21277,4 +21472,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
21277
21472
  export {};
21278
21473
 
21279
21474
  //# sourceMappingURL=cli.js.map
21280
- //# debugId=e56fe2ba-b7f4-5b81-942b-685d55761c6b
21475
+ //# debugId=6ef6b306-718a-5ef6-81bb-b6465cd32f04
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`
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]="f737dd06-c590-5a34-8fb0-b8aa0278cc0d")}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;
@@ -5343,6 +5360,7 @@ const checkReducedMotion = (rootDirectory) => {
5343
5360
  if (!hasMotionLibrary) return [];
5344
5361
  const result = spawnSync("git", [
5345
5362
  "grep",
5363
+ "--untracked",
5346
5364
  "-ql",
5347
5365
  "-E",
5348
5366
  REDUCED_MOTION_GREP_PATTERN,
@@ -6697,6 +6715,7 @@ const buildCapabilities = (project) => {
6697
6715
  capabilities.add(project.framework);
6698
6716
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6699
6717
  if (project.expoVersion !== null) capabilities.add("expo");
6718
+ if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
6700
6719
  const reactMajor = project.reactMajorVersion;
6701
6720
  if (reactMajor !== null) {
6702
6721
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -7641,7 +7660,12 @@ const SANITIZED_ENV = (() => {
7641
7660
  const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLINT_SPAWN_TIMEOUT_MS, outputMaxBytes = OXLINT_OUTPUT_MAX_BYTES) => new Promise((resolve, reject) => {
7642
7661
  const child = spawn(nodeBinaryPath, args, {
7643
7662
  cwd: rootDirectory,
7644
- env: SANITIZED_ENV
7663
+ env: SANITIZED_ENV,
7664
+ stdio: [
7665
+ "ignore",
7666
+ "pipe",
7667
+ "pipe"
7668
+ ]
7645
7669
  });
7646
7670
  const timeoutHandle = setTimeout(() => {
7647
7671
  child.kill("SIGKILL");
@@ -8929,4 +8953,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8929
8953
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8930
8954
 
8931
8955
  //# sourceMappingURL=index.js.map
8932
- //# debugId=44e73f8d-b81f-599b-a04e-22497cd72bb2
8956
+ //# debugId=f737dd06-c590-5a34-8fb0-b8aa0278cc0d
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;
@@ -5280,6 +5297,7 @@ const checkReducedMotion = (rootDirectory) => {
5280
5297
  if (!hasMotionLibrary) return [];
5281
5298
  const result = spawnSync("git", [
5282
5299
  "grep",
5300
+ "--untracked",
5283
5301
  "-ql",
5284
5302
  "-E",
5285
5303
  REDUCED_MOTION_GREP_PATTERN,
@@ -6634,6 +6652,7 @@ const buildCapabilities = (project) => {
6634
6652
  capabilities.add(project.framework);
6635
6653
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6636
6654
  if (project.expoVersion !== null) capabilities.add("expo");
6655
+ if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
6637
6656
  const reactMajor = project.reactMajorVersion;
6638
6657
  if (reactMajor !== null) {
6639
6658
  const cappedReactMajor = Math.min(reactMajor, 30);
@@ -7578,7 +7597,12 @@ const SANITIZED_ENV = (() => {
7578
7597
  const spawnOxlint = (args, rootDirectory, nodeBinaryPath, spawnTimeoutMs = OXLINT_SPAWN_TIMEOUT_MS, outputMaxBytes = OXLINT_OUTPUT_MAX_BYTES) => new Promise((resolve, reject) => {
7579
7598
  const child = spawn(nodeBinaryPath, args, {
7580
7599
  cwd: rootDirectory,
7581
- env: SANITIZED_ENV
7600
+ env: SANITIZED_ENV,
7601
+ stdio: [
7602
+ "ignore",
7603
+ "pipe",
7604
+ "pipe"
7605
+ ]
7582
7606
  });
7583
7607
  const timeoutHandle = setTimeout(() => {
7584
7608
  child.kill("SIGKILL");
@@ -8712,7 +8736,7 @@ const getRuleMetadata = (plugin, rule) => {
8712
8736
  /** Display name used in client-facing messages and progress titles. */
8713
8737
  const SERVER_DISPLAY_NAME = "React Doctor";
8714
8738
  /** Server version reported in `serverInfo`; injected at build, `dev` from source. */
8715
- const SERVER_VERSION = "0.2.12";
8739
+ const SERVER_VERSION = "0.2.13";
8716
8740
  /** `Diagnostic.source` shown next to every published diagnostic. */
8717
8741
  const DIAGNOSTIC_SOURCE = "react-doctor";
8718
8742
  /**
@@ -10800,5 +10824,5 @@ const startLanguageServer = () => {
10800
10824
  };
10801
10825
  //#endregion
10802
10826
  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
10827
+ !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]="8723a353-8e8c-5ecc-8264-6fbb48af2b40")}catch(e){}}();
10828
+ //# debugId=8723a353-8e8c-5ecc-8264-6fbb48af2b40
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.7d4b996",
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.7d4b996"
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"