react-doctor 0.5.8-dev.734c564 → 0.5.8-dev.7ef9f0e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lsp.js CHANGED
@@ -6,7 +6,7 @@ import os from "node:os";
6
6
  import * as Path from "node:path";
7
7
  import path from "node:path";
8
8
  import * as NodeChildProcess from "node:child_process";
9
- import { spawn, spawnSync } from "node:child_process";
9
+ import { execFileSync, spawn, spawnSync } from "node:child_process";
10
10
  import * as ts from "typescript";
11
11
  import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
12
12
  import { parseJSON5 } from "confbox";
@@ -6021,7 +6021,7 @@ const composePassthrough = /* @__PURE__ */ dual(2, (left, right) => (input) => {
6021
6021
  * @since 2.0.0
6022
6022
  */
6023
6023
  const Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", { defaultValue: () => new MixedScheduler() });
6024
- const setImmediate = "setImmediate" in globalThis ? (f) => {
6024
+ const setImmediate$1 = "setImmediate" in globalThis ? (f) => {
6025
6025
  const timer = globalThis.setImmediate(f);
6026
6026
  return () => globalThis.clearImmediate(timer);
6027
6027
  } : (f) => {
@@ -6065,7 +6065,7 @@ var PriorityBuckets = class {
6065
6065
  var MixedScheduler = class {
6066
6066
  executionMode;
6067
6067
  setImmediate;
6068
- constructor(executionMode = "async", setImmediateFn = setImmediate) {
6068
+ constructor(executionMode = "async", setImmediateFn = setImmediate$1) {
6069
6069
  this.executionMode = executionMode;
6070
6070
  this.setImmediate = setImmediateFn;
6071
6071
  }
@@ -6090,7 +6090,7 @@ var MixedSchedulerDispatcher = class {
6090
6090
  tasks = /* @__PURE__ */ new PriorityBuckets();
6091
6091
  running = void 0;
6092
6092
  setImmediate;
6093
- constructor(setImmediateFn = setImmediate) {
6093
+ constructor(setImmediateFn = setImmediate$1) {
6094
6094
  this.setImmediate = setImmediateFn;
6095
6095
  }
6096
6096
  /**
@@ -33730,6 +33730,10 @@ const MILLISECONDS_PER_SECOND = 1e3;
33730
33730
  const SCORE_API_URL = "https://www.react.doctor/api/score";
33731
33731
  const FETCH_TIMEOUT_MS = 1e4;
33732
33732
  const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
33733
+ const SPAWN_ARGS_MAX_LENGTH_CHARS = 24e3;
33734
+ const SPAWN_ARGS_MAX_LENGTH_CHARS_POSIX = 15e5;
33735
+ const SPAWN_ARGS_MAX_LENGTH_CHARS_DARWIN = 8e5;
33736
+ const NODE_VERSION_PROBE_TIMEOUT_MS = 5e3;
33733
33737
  const PER_WORKER_MEM_BUDGET_BYTES = 1024 * 1024 * 1024;
33734
33738
  const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
33735
33739
  const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
@@ -33810,6 +33814,7 @@ const DEAD_CODE_PHASE_TIMEOUT_MS = 15e4;
33810
33814
  const LINT_PHASE_TIMEOUT_MS = 3e5;
33811
33815
  const SCAN_TOTAL_DEADLINE_MS = 9e5;
33812
33816
  const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
33817
+ const DEAD_CODE_WORKER_MEM_BUDGET_BYTES = 2 * 1024 * 1024 * 1024;
33813
33818
  const DEAD_CODE_TIMEOUT_CEILING_MS = 6e5;
33814
33819
  const DEAD_CODE_PHASE_TIMEOUT_OVER_WORKER_MS = 3e4;
33815
33820
  const DEAD_CODE_OVERLAP_PARSE_SHARE = .4;
@@ -34576,7 +34581,7 @@ const tokenizeRuleList = (ruleList) => {
34576
34581
  const FOREIGN_INLINE_DISABLE_PATTERN = /(?:\/\/|\/\*)[ \t]*(eslint|oxlint)-disable-(next-line|line)(?![\w-])([^\r\n]*)/;
34577
34582
  const FOREIGN_BLOCK_DISABLE_PATTERN = /\/\*[ \t]*(eslint|oxlint)-disable(?![\w-])([^*\r\n]*)/;
34578
34583
  const FOREIGN_BLOCK_ENABLE_PATTERN = /\/\*[ \t]*(?:eslint|oxlint)-enable(?![\w-])([^*\r\n]*)/;
34579
- const buildHint = (tool, token, ruleId) => `oxlint matches plugin rules only by their full name, so \`${token}\` in your ${tool}-disable comment does not silence \`${ruleId}\` — change it to \`${ruleId}\`.`;
34584
+ const buildHint = (tool, token, ruleId) => `oxlint matches plugin rules only by their full name, so \`${token}\` in your ${tool}-disable comment does not silence \`${ruleId}\` — add \`${ruleId}\` to the comment (e.g. \`${token}, ${ruleId}\`).`;
34580
34585
  const tokenMisnamesRule = (token, ruleId) => token !== ruleId && isSameRuleKey(token, ruleId);
34581
34586
  const detectInlineNearMiss = (lines, diagnosticLineIndex, ruleId) => {
34582
34587
  const candidates = [{
@@ -35052,6 +35057,7 @@ const collectStringSet = (values) => {
35052
35057
  if (!Array.isArray(values)) return /* @__PURE__ */ new Set();
35053
35058
  return new Set(values.filter((value) => typeof value === "string"));
35054
35059
  };
35060
+ const JSX_NO_UNDEF_IDENTIFIER_PATTERN = /^`([^`]+)`/;
35055
35061
  /**
35056
35062
  * Pre-compiles every stateful filter and returns a single
35057
35063
  * `apply(diagnostic)` closure that runs (in order):
@@ -35085,11 +35091,28 @@ const buildDiagnosticPipeline = (input) => {
35085
35091
  const compiledOverrides = compileIgnoreOverrides(userConfig);
35086
35092
  const textComponentNames = collectStringSet(userConfig?.textComponents);
35087
35093
  const rawTextWrapperComponentNames = collectStringSet(userConfig?.rawTextWrapperComponents);
35094
+ const runtimeGlobalNames = collectStringSet(userConfig?.runtimeGlobals);
35088
35095
  const hasTextComponents = textComponentNames.size > 0;
35089
35096
  const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
35097
+ const hasRuntimeGlobals = runtimeGlobalNames.size > 0;
35090
35098
  const fileLinesCache = /* @__PURE__ */ new Map();
35091
35099
  const fileContextCache = /* @__PURE__ */ new Map();
35092
35100
  const libraryFileCache = /* @__PURE__ */ new Map();
35101
+ const suppressions = /* @__PURE__ */ new Map();
35102
+ const suppress = (diagnostic, source) => {
35103
+ const { ruleKey } = getDiagnosticRuleIdentity(diagnostic);
35104
+ const suppressionKey = `${ruleKey}\u0000${source}`;
35105
+ const existing = suppressions.get(suppressionKey);
35106
+ suppressions.set(suppressionKey, existing ? {
35107
+ ...existing,
35108
+ count: existing.count + 1
35109
+ } : {
35110
+ rule: ruleKey,
35111
+ source,
35112
+ count: 1
35113
+ });
35114
+ return null;
35115
+ };
35093
35116
  const isLibraryFile = (filePath) => {
35094
35117
  let cached = libraryFileCache.get(filePath);
35095
35118
  if (cached === void 0) {
@@ -35138,50 +35161,60 @@ const buildDiagnosticPipeline = (input) => {
35138
35161
  if (hasRawTextWrappers && isInsideStringOnlyWrapper(lines, diagnostic.line, diagnostic.column, rawTextWrapperComponentNames)) return true;
35139
35162
  return false;
35140
35163
  };
35141
- return { apply: (diagnostic) => {
35142
- if (shouldAutoSuppress(diagnostic)) return null;
35143
- let current = diagnostic;
35144
- let explicitSeverityOverride;
35145
- let explicitRuleOverride;
35146
- if (severityControls) {
35147
- const { ruleKey, category } = getDiagnosticRuleIdentity(current);
35148
- explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey }, severityControls);
35149
- explicitSeverityOverride = resolveRuleSeverityOverride({
35150
- ruleKey,
35151
- category
35152
- }, severityControls);
35153
- if (explicitSeverityOverride === "off") return null;
35154
- if (explicitSeverityOverride !== void 0) current = restampSeverity(current, explicitSeverityOverride);
35155
- }
35156
- if (explicitRuleOverride === void 0) {
35157
- if (isAppOnlyRule(`${current.plugin}/${current.rule}`) && isLibraryFile(current.filePath)) return null;
35158
- }
35159
- if (!showWarnings && current.severity === "warning" && explicitSeverityOverride !== "warn") return null;
35160
- if (userConfig) {
35161
- if (isRuleIgnored(`${current.plugin}/${current.rule}`)) return null;
35162
- if (isFileIgnoredByPatterns(current.filePath, rootDirectory, ignoredFilePatterns)) return null;
35163
- if (isDiagnosticIgnoredByOverrides(current, rootDirectory, compiledOverrides)) return null;
35164
- if (isRnRawTextSuppressedByConfig(current)) return null;
35165
- }
35166
- if (respectInlineDisables && current.line > 0) {
35167
- const lines = getFileLines(current.filePath);
35168
- if (lines) {
35169
- const ruleIdentifier = `${current.plugin}/${current.rule}`;
35170
- const evaluation = evaluateSuppression(lines, current.line - 1, ruleIdentifier);
35171
- if (evaluation.isSuppressed) return null;
35172
- if (evaluation.nearMissHint) current = {
35173
- ...current,
35174
- suppressionHint: evaluation.nearMissHint
35175
- };
35164
+ const isJsxNoUndefSuppressedByConfig = (diagnostic) => {
35165
+ if (!hasRuntimeGlobals) return false;
35166
+ if (diagnostic.rule !== "jsx-no-undef") return false;
35167
+ const identifierMatch = JSX_NO_UNDEF_IDENTIFIER_PATTERN.exec(diagnostic.message);
35168
+ return identifierMatch !== null && runtimeGlobalNames.has(identifierMatch[1]);
35169
+ };
35170
+ return {
35171
+ apply: (diagnostic) => {
35172
+ if (shouldAutoSuppress(diagnostic)) return null;
35173
+ let current = diagnostic;
35174
+ let explicitSeverityOverride;
35175
+ let explicitRuleOverride;
35176
+ if (severityControls) {
35177
+ const { ruleKey, category } = getDiagnosticRuleIdentity(current);
35178
+ explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey }, severityControls);
35179
+ explicitSeverityOverride = resolveRuleSeverityOverride({
35180
+ ruleKey,
35181
+ category
35182
+ }, severityControls);
35183
+ if (explicitSeverityOverride === "off") return suppress(current, "config");
35184
+ if (explicitSeverityOverride !== void 0) current = restampSeverity(current, explicitSeverityOverride);
35176
35185
  }
35177
- }
35178
- const fileContext = getFileContext(current.filePath);
35179
- if (fileContext !== "production") current = {
35180
- ...current,
35181
- fileContext
35182
- };
35183
- return current;
35184
- } };
35186
+ if (explicitRuleOverride === void 0) {
35187
+ if (isAppOnlyRule(`${current.plugin}/${current.rule}`) && isLibraryFile(current.filePath)) return null;
35188
+ }
35189
+ if (!showWarnings && current.severity === "warning" && explicitSeverityOverride !== "warn") return null;
35190
+ if (userConfig) {
35191
+ if (isRuleIgnored(`${current.plugin}/${current.rule}`)) return suppress(current, "config");
35192
+ if (isFileIgnoredByPatterns(current.filePath, rootDirectory, ignoredFilePatterns)) return null;
35193
+ if (isDiagnosticIgnoredByOverrides(current, rootDirectory, compiledOverrides)) return suppress(current, "override");
35194
+ if (isRnRawTextSuppressedByConfig(current)) return null;
35195
+ if (isJsxNoUndefSuppressedByConfig(current)) return null;
35196
+ }
35197
+ if (respectInlineDisables && current.line > 0) {
35198
+ const lines = getFileLines(current.filePath);
35199
+ if (lines) {
35200
+ const ruleIdentifier = `${current.plugin}/${current.rule}`;
35201
+ const evaluation = evaluateSuppression(lines, current.line - 1, ruleIdentifier);
35202
+ if (evaluation.isSuppressed) return suppress(current, "inline");
35203
+ if (evaluation.nearMissHint) current = {
35204
+ ...current,
35205
+ suppressionHint: evaluation.nearMissHint
35206
+ };
35207
+ }
35208
+ }
35209
+ const fileContext = getFileContext(current.filePath);
35210
+ if (fileContext !== "production") current = {
35211
+ ...current,
35212
+ fileContext
35213
+ };
35214
+ return current;
35215
+ },
35216
+ summarizeSuppressions: () => [...suppressions.values()]
35217
+ };
35185
35218
  };
35186
35219
  const OxlintUnavailableKind = Literals(["binary-not-found", "native-binding-missing"]);
35187
35220
  var OxlintUnavailable = class extends TaggedErrorClass()("OxlintUnavailable", {
@@ -35401,7 +35434,7 @@ const resolveScanConcurrency = (requested) => {
35401
35434
  if (!Number.isFinite(requested) || requested < 1) return 1;
35402
35435
  return Math.min(Math.floor(requested), 32);
35403
35436
  };
35404
- const readSystemFacts = () => ({
35437
+ const readSystemFacts$1 = () => ({
35405
35438
  availableCores: os.availableParallelism(),
35406
35439
  totalMemoryBytes: os.totalmem(),
35407
35440
  cgroupMemoryLimitBytes: readCgroupMemoryLimitBytes()
@@ -35422,7 +35455,7 @@ const readSystemFacts = () => ({
35422
35455
  * `facts` is injectable so tests exercise core-bound, memory-bound, cgroup-
35423
35456
  * limited, and ceiling cases without mocking `os` or the filesystem.
35424
35457
  */
35425
- const resolveAutoScanConcurrency = (facts = readSystemFacts()) => {
35458
+ const resolveAutoScanConcurrency = (facts = readSystemFacts$1()) => {
35426
35459
  const availableMemoryBytes = Math.min(facts.totalMemoryBytes, facts.cgroupMemoryLimitBytes ?? Number.POSITIVE_INFINITY);
35427
35460
  const memoryBoundedWorkers = Math.floor(availableMemoryBytes / PER_WORKER_MEM_BUDGET_BYTES);
35428
35461
  return resolveScanConcurrency(Math.min(facts.availableCores, memoryBoundedWorkers));
@@ -35463,13 +35496,7 @@ var ScanDeadlineMs = class extends Reference("react-doctor/ScanDeadlineMs", { de
35463
35496
  * without recompiling react-doctor. Tests override via
35464
35497
  * `Layer.succeed(SupplyChainOverlapTimeoutMs, ...)`.
35465
35498
  */
35466
- var SupplyChainOverlapTimeoutMs = class extends Reference("react-doctor/SupplyChainOverlapTimeoutMs", { defaultValue: () => {
35467
- const raw = process.env["REACT_DOCTOR_SUPPLY_CHAIN_TIMEOUT_MS"];
35468
- if (raw === void 0) return SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS;
35469
- const parsed = Number(raw);
35470
- if (!Number.isFinite(parsed) || parsed <= 0) return SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS;
35471
- return parsed;
35472
- } }) {};
35499
+ var SupplyChainOverlapTimeoutMs = class extends Reference("react-doctor/SupplyChainOverlapTimeoutMs", { defaultValue: () => readPositiveEnvMs("REACT_DOCTOR_SUPPLY_CHAIN_TIMEOUT_MS", SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS) }) {};
35473
35500
  /**
35474
35501
  * Hard cap on combined stdout+stderr bytes per oxlint batch. The
35475
35502
  * subprocess gets SIGKILL'd if it produces more; the recovery path
@@ -35617,6 +35644,7 @@ const STRING_ARRAY_FIELD_NAMES = [
35617
35644
  "projects",
35618
35645
  "textComponents",
35619
35646
  "rawTextWrapperComponents",
35647
+ "runtimeGlobals",
35620
35648
  "serverAuthFunctionNames"
35621
35649
  ];
35622
35650
  const SURFACE_CONTROL_FIELD_NAMES = [
@@ -36907,7 +36935,10 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledBy)
36907
36935
  }
36908
36936
  return true;
36909
36937
  };
36910
- const checkSecurityScan = (rootDirectory, options = {}) => {
36938
+ const yieldToEventLoop = () => new Promise((resolve) => {
36939
+ setImmediate(resolve);
36940
+ });
36941
+ const createSecurityScanSession = (rootDirectory, options) => {
36911
36942
  const capabilities = options.project ? buildCapabilities(options.project) : /* @__PURE__ */ new Set();
36912
36943
  const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
36913
36944
  const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
@@ -36922,7 +36953,7 @@ const checkSecurityScan = (rootDirectory, options = {}) => {
36922
36953
  committedFilesOnly: rule.committedFilesOnly === true
36923
36954
  }];
36924
36955
  });
36925
- if (enabledScanRules.length === 0) return [];
36956
+ if (enabledScanRules.length === 0) return null;
36926
36957
  const diagnostics = [];
36927
36958
  const seen = /* @__PURE__ */ new Set();
36928
36959
  const gitIgnoredCache = /* @__PURE__ */ new Map();
@@ -36934,15 +36965,34 @@ const checkSecurityScan = (rootDirectory, options = {}) => {
36934
36965
  }
36935
36966
  return status === true;
36936
36967
  };
36937
- for (const file of collectSecurityScanFiles(rootDirectory)) for (const { entry, scan, committedFilesOnly } of enabledScanRules) for (const finding of scan(file)) {
36938
- if (committedFilesOnly && isFileGitIgnored(file)) continue;
36939
- const diagnostic = buildSecurityScanDiagnostic(finding, entry, file.relativePath);
36940
- const key = `${diagnostic.rule}:${diagnostic.filePath}:${diagnostic.line}:${diagnostic.column}:${diagnostic.message}`;
36941
- if (seen.has(key)) continue;
36942
- seen.add(key);
36943
- diagnostics.push(diagnostic);
36968
+ const scanFile = (file) => {
36969
+ for (const { entry, scan, committedFilesOnly } of enabledScanRules) for (const finding of scan(file)) {
36970
+ if (committedFilesOnly && isFileGitIgnored(file)) continue;
36971
+ const diagnostic = buildSecurityScanDiagnostic(finding, entry, file.relativePath);
36972
+ const key = `${diagnostic.rule}:${diagnostic.filePath}:${diagnostic.line}:${diagnostic.column}:${diagnostic.message}`;
36973
+ if (seen.has(key)) continue;
36974
+ seen.add(key);
36975
+ diagnostics.push(diagnostic);
36976
+ }
36977
+ };
36978
+ return {
36979
+ scanFile,
36980
+ diagnostics
36981
+ };
36982
+ };
36983
+ const checkSecurityScanCooperative = async (rootDirectory, options = {}) => {
36984
+ const session = createSecurityScanSession(rootDirectory, options);
36985
+ if (session === null) return [];
36986
+ let filesSinceYield = 0;
36987
+ for (const file of collectSecurityScanFiles(rootDirectory)) {
36988
+ session.scanFile(file);
36989
+ filesSinceYield += 1;
36990
+ if (filesSinceYield >= 16) {
36991
+ filesSinceYield = 0;
36992
+ await yieldToEventLoop();
36993
+ }
36944
36994
  }
36945
- return diagnostics;
36995
+ return session.diagnostics;
36946
36996
  };
36947
36997
  var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
36948
36998
  let p = process || {}, argv = p.argv || [], env = p.env || {};
@@ -37159,6 +37209,74 @@ const collectDeadCodeIgnorePatterns = (rootDirectory) => {
37159
37209
  return [...seen].filter((pattern) => pattern.length > 0);
37160
37210
  };
37161
37211
  const collectDeadCodeEntryPatterns = (rootDirectory) => [...new Set(collectKnipPatterns(rootDirectory, "entry"))].filter((pattern) => pattern.length > 0);
37212
+ const readSystemFacts = () => ({
37213
+ availableCores: os.availableParallelism(),
37214
+ totalMemoryBytes: os.totalmem(),
37215
+ cgroupMemoryLimitBytes: readCgroupMemoryLimitBytes()
37216
+ });
37217
+ /**
37218
+ * How many real deslop dead-code child processes may run at once, across the
37219
+ * concurrent per-project `runInspect` fibers of one CLI run. The cap is the
37220
+ * smaller of the core count and the number of `DEAD_CODE_WORKER_MEM_BUDGET_BYTES`
37221
+ * workers that fit in available memory, floored at 1.
37222
+ *
37223
+ * On a roomy dev box / CI runner this resolves high enough that every
37224
+ * concurrently-scanned project still spawns its own worker (no serialization vs
37225
+ * the prior uncapped behavior); on a memory-constrained runner it collapses
37226
+ * toward 1, so the `withDeadCodeWorkerSlot` semaphore serializes the spawns
37227
+ * instead of oversubscribing memory with N simultaneous children — the global
37228
+ * cap the per-project spawn path lacked.
37229
+ *
37230
+ * Mirrors `resolveAutoScanConcurrency` (lint), but budgets memory per the
37231
+ * heavier dead-code worker. `facts` is injectable for tests.
37232
+ */
37233
+ const resolveDeadCodeConcurrency = (facts = readSystemFacts()) => {
37234
+ const availableMemoryBytes = Math.min(facts.totalMemoryBytes, facts.cgroupMemoryLimitBytes ?? Number.POSITIVE_INFINITY);
37235
+ const memoryBoundedWorkers = Math.floor(availableMemoryBytes / DEAD_CODE_WORKER_MEM_BUDGET_BYTES);
37236
+ return Math.max(1, Math.min(facts.availableCores, memoryBoundedWorkers));
37237
+ };
37238
+ let availableSlots = -1;
37239
+ const waiters = [];
37240
+ const releaseSlot = () => {
37241
+ const nextWaiter = waiters.shift();
37242
+ if (nextWaiter !== void 0) nextWaiter();
37243
+ else availableSlots += 1;
37244
+ };
37245
+ /**
37246
+ * Runs `task` once a dead-code worker slot is free, releasing the slot when the
37247
+ * task settles (success or failure). With a high cap (roomy machine) every
37248
+ * caller proceeds immediately; with a low cap (constrained runner) callers
37249
+ * queue and run as slots free.
37250
+ *
37251
+ * `abortSignal` short-circuits the WAIT: if it's already aborted, or fires while
37252
+ * this caller is queued, the call rejects without acquiring a slot or running
37253
+ * `task` — so a cancelled scan (e.g. lint failed) doesn't sit in the queue and
37254
+ * then spawn a child only to tear it down. A queued caller that aborts removes
37255
+ * its own waiter so a later release never hands a slot to a dead request.
37256
+ */
37257
+ const withDeadCodeWorkerSlot = async (task, abortSignal) => {
37258
+ if (abortSignal?.aborted) throw new Error("Dead-code worker aborted.");
37259
+ if (availableSlots < 0) availableSlots = resolveDeadCodeConcurrency();
37260
+ if (availableSlots > 0) availableSlots -= 1;
37261
+ else await new Promise((resolve, reject) => {
37262
+ const waiter = () => {
37263
+ abortSignal?.removeEventListener("abort", onAbort);
37264
+ resolve();
37265
+ };
37266
+ const onAbort = () => {
37267
+ const queuedIndex = waiters.indexOf(waiter);
37268
+ if (queuedIndex !== -1) waiters.splice(queuedIndex, 1);
37269
+ reject(/* @__PURE__ */ new Error("Dead-code worker aborted."));
37270
+ };
37271
+ waiters.push(waiter);
37272
+ abortSignal?.addEventListener("abort", onAbort, { once: true });
37273
+ });
37274
+ try {
37275
+ return await task();
37276
+ } finally {
37277
+ releaseSlot();
37278
+ }
37279
+ };
37162
37280
  /**
37163
37281
  * Resolves a path to its canonical, symlink-free form, falling back to
37164
37282
  * the input when it cannot be realpath'd (broken symlink, permission
@@ -37183,6 +37301,11 @@ const toCanonicalPath = (filePath) => {
37183
37301
  };
37184
37302
  const DEAD_CODE_PLUGIN = "deslop";
37185
37303
  const DEAD_CODE_CATEGORY = "Maintainability";
37304
+ const REACT_DOCTOR_TOOLCHAIN_PACKAGES = new Set([
37305
+ "react-doctor",
37306
+ "eslint-plugin-react-doctor",
37307
+ "oxlint-plugin-react-doctor"
37308
+ ]);
37186
37309
  const DEAD_CODE_WORKER_SCRIPT = `
37187
37310
  const inputChunks = [];
37188
37311
  process.stdin.on("data", (chunk) => inputChunks.push(chunk));
@@ -37449,14 +37572,17 @@ const checkDeadCode = async (options) => {
37449
37572
  if (!NFS.existsSync(Path.join(rootDirectory, "package.json"))) return [];
37450
37573
  const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
37451
37574
  const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
37452
- const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
37453
- rootDirectory,
37454
- entryPatterns,
37455
- tsConfigPath: resolveTsConfigPath(rootDirectory),
37456
- ignorePatterns,
37457
- deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js"),
37458
- parseConcurrency: options.parseConcurrency
37459
- }), options.workerTimeoutMs ?? 12e4, options.abortSignal));
37575
+ const spawnAndRun = () => {
37576
+ return runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
37577
+ rootDirectory,
37578
+ entryPatterns,
37579
+ tsConfigPath: resolveTsConfigPath(rootDirectory),
37580
+ ignorePatterns,
37581
+ deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js"),
37582
+ parseConcurrency: options.parseConcurrency
37583
+ }), options.workerTimeoutMs ?? 12e4, options.abortSignal);
37584
+ };
37585
+ const result = parseDeadCodeWorkerResult(options.createWorker === void 0 ? await withDeadCodeWorkerSlot(spawnAndRun, options.abortSignal) : await spawnAndRun());
37460
37586
  const toRelative = (filePath) => toRelativeFilePath(rootDirectory, filePath);
37461
37587
  const diagnostics = [];
37462
37588
  for (const unusedFile of result.unusedFiles) diagnostics.push({
@@ -37485,6 +37611,7 @@ const checkDeadCode = async (options) => {
37485
37611
  });
37486
37612
  }
37487
37613
  for (const unusedDependency of result.unusedDependencies) {
37614
+ if (REACT_DOCTOR_TOOLCHAIN_PACKAGES.has(unusedDependency.name)) continue;
37488
37615
  const label = unusedDependency.isDevDependency ? "devDependency" : "dependency";
37489
37616
  diagnostics.push({
37490
37617
  filePath: "package.json",
@@ -37663,7 +37790,6 @@ var DeadCode = class DeadCode extends Service()("react-doctor/DeadCode") {
37663
37790
  return yield* tryPromise({
37664
37791
  try: (signal) => checkDeadCode({
37665
37792
  rootDirectory: input.rootDirectory,
37666
- userConfig: input.userConfig,
37667
37793
  parseConcurrency: input.parseConcurrency,
37668
37794
  workerTimeoutMs: input.workerTimeoutMs,
37669
37795
  abortSignal: signal
@@ -37786,6 +37912,11 @@ const isSafeGitRevision = (candidate) => {
37786
37912
  if (candidate.includes("..") || candidate.includes("@{")) return false;
37787
37913
  return SAFE_GIT_REVISION_PATTERN.test(candidate);
37788
37914
  };
37915
+ const resolveSpawnArgsLengthCap = () => {
37916
+ if (process.platform === "win32") return SPAWN_ARGS_MAX_LENGTH_CHARS;
37917
+ if (process.platform === "darwin") return SPAWN_ARGS_MAX_LENGTH_CHARS_DARWIN;
37918
+ return SPAWN_ARGS_MAX_LENGTH_CHARS_POSIX;
37919
+ };
37789
37920
  /**
37790
37921
  * Splits a git revision range into its endpoints: three-dot `A...B`
37791
37922
  * (symmetric, merge-base) or two-dot `A..B` (direct). Returns `null`
@@ -37857,43 +37988,47 @@ var Git = class Git extends Service()("react-doctor/Git") {
37857
37988
  * reason: GitInvocationFailed })` so the rest of the codebase
37858
37989
  * sees a single failure channel.
37859
37990
  */
37860
- const runCommand = (input) => scoped(gen(function* () {
37861
- const handle = yield* spawner.spawn(make$1(input.command, [...input.args], {
37862
- cwd: input.directory,
37863
- env: input.env,
37864
- extendEnv: true
37865
- }));
37866
- const maxStdoutBytes = input.maxStdoutBytes;
37867
- const stdoutByteCount = yield* make$13(0);
37868
- const [stdout, stderr, status] = yield* all([
37869
- mkString(decodeText(maxStdoutBytes === void 0 ? handle.stdout : handle.stdout.pipe(tap((chunk) => updateAndGet(stdoutByteCount, (total) => total + chunk.length).pipe(flatMap$2((total) => total > maxStdoutBytes ? fail$4(new ReactDoctorError({ reason: new GitInvocationFailed({
37870
- args: [...input.args],
37871
- directory: input.directory,
37872
- cause: /* @__PURE__ */ new Error(`git stdout exceeded ${maxStdoutBytes} bytes`)
37873
- }) })) : void_)))))),
37874
- mkString(decodeText(handle.stderr)),
37875
- handle.exitCode
37876
- ], { concurrency: 3 });
37877
- return {
37878
- status,
37879
- stdout,
37880
- stderr
37881
- };
37882
- })).pipe(catchTag$1("PlatformError", (cause) => {
37883
- if (input.command !== "git") return succeed$2({
37991
+ const runCommand = (input) => {
37992
+ const foldSpawnFailure = (cause) => input.command !== "git" ? succeed$2({
37884
37993
  status: 127,
37885
37994
  stdout: "",
37886
37995
  stderr: String(cause)
37887
- });
37888
- return new ReactDoctorError({ reason: new GitInvocationFailed({
37996
+ }) : fail$4(new ReactDoctorError({ reason: new GitInvocationFailed({
37889
37997
  args: [...input.args],
37890
37998
  directory: input.directory,
37891
37999
  cause
37892
- }) });
37893
- }), withSpan("git.exec", { attributes: {
37894
- "git.command": input.command,
37895
- "git.subcommand": input.args[0] ?? ""
37896
- } }));
38000
+ }) }));
38001
+ return scoped(gen(function* () {
38002
+ if (!isDirectory(input.directory)) return yield* foldSpawnFailure(`spawn ENOTDIR (cwd is not a directory: ${input.directory})`);
38003
+ const argvLengthChars = input.command.length + 1 + input.args.reduce((total, arg) => total + arg.length + 1, 0);
38004
+ const spawnArgsLengthCap = resolveSpawnArgsLengthCap();
38005
+ if (argvLengthChars > spawnArgsLengthCap) return yield* foldSpawnFailure(`spawn ENAMETOOLONG (${argvLengthChars} argv chars exceed ${spawnArgsLengthCap})`);
38006
+ const handle = yield* spawner.spawn(make$1(input.command, [...input.args], {
38007
+ cwd: input.directory,
38008
+ env: input.env,
38009
+ extendEnv: true
38010
+ }));
38011
+ const maxStdoutBytes = input.maxStdoutBytes;
38012
+ const stdoutByteCount = yield* make$13(0);
38013
+ const [stdout, stderr, status] = yield* all([
38014
+ mkString(decodeText(maxStdoutBytes === void 0 ? handle.stdout : handle.stdout.pipe(tap((chunk) => updateAndGet(stdoutByteCount, (total) => total + chunk.length).pipe(flatMap$2((total) => total > maxStdoutBytes ? fail$4(new ReactDoctorError({ reason: new GitInvocationFailed({
38015
+ args: [...input.args],
38016
+ directory: input.directory,
38017
+ cause: /* @__PURE__ */ new Error(`git stdout exceeded ${maxStdoutBytes} bytes`)
38018
+ }) })) : void_)))))),
38019
+ mkString(decodeText(handle.stderr)),
38020
+ handle.exitCode
38021
+ ], { concurrency: 3 });
38022
+ return {
38023
+ status,
38024
+ stdout,
38025
+ stderr
38026
+ };
38027
+ })).pipe(catchTag$1("PlatformError", foldSpawnFailure), withSpan("git.exec", { attributes: {
38028
+ "git.command": input.command,
38029
+ "git.subcommand": input.args[0] ?? ""
38030
+ } }));
38031
+ };
37897
38032
  const runGit = (directory, args) => runCommand({
37898
38033
  command: "git",
37899
38034
  args,
@@ -38036,6 +38171,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38036
38171
  if (resolvedCurrentBranch === null && explicitBaseBranch === void 0) return null;
38037
38172
  const baseBranch = explicitBaseBranch ?? (yield* defaultBranch(directory));
38038
38173
  if (baseBranch === null) return null;
38174
+ if (!isSafeGitRevision(baseBranch)) return null;
38039
38175
  if (explicitBaseBranch !== void 0) {
38040
38176
  if (!(yield* branchExists(directory, explicitBaseBranch))) return yield* fail$4(new ReactDoctorError({ reason: new GitBaseBranchMissing({ branch: explicitBaseBranch }) }));
38041
38177
  }
@@ -38140,7 +38276,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
38140
38276
  ]);
38141
38277
  if (result.status !== 0) return null;
38142
38278
  return parseChangedLineRanges(result.stdout);
38143
- }).pipe(withSpan("Git.changedLineRanges"))
38279
+ }).pipe(catch_$1((error) => error.reason._tag === "GitInvocationFailed" ? succeed$2(null) : fail$4(error)), withSpan("Git.changedLineRanges"))
38144
38280
  });
38145
38281
  })).pipe(provide$2(layer$2.pipe(provide$2(mergeAll$1(layer$1, layer)))));
38146
38282
  /**
@@ -38386,7 +38522,7 @@ const normalizeConfigForHash = (config) => {
38386
38522
  if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
38387
38523
  return clone;
38388
38524
  };
38389
- const computeRulesetHash = (input) => crypto.createHash("sha1").update(JSON.stringify(normalizeConfigForHash(input.config))).update("\0").update([...input.toolchainVersions].join("\0")).update("\0").update([...input.ignorePatterns].join("\n")).update(" ").update(input.tsconfigContent ?? "").digest("hex");
38525
+ const computeRulesetHash = (input) => crypto.createHash("sha1").update(JSON.stringify(normalizeConfigForHash(input.config))).update("\0").update([...input.toolchainVersions].join("\0")).update("\0").update([...input.ignorePatterns].join("\n")).update("\0").update(input.tsconfigContent ?? "").digest("hex");
38390
38526
  /**
38391
38527
  * Loads a plugin module via the local require resolver and extracts
38392
38528
  * `(name, ruleNames)` from either `module.exports.meta + rules` or
@@ -38664,24 +38800,38 @@ const createFileLintCache = (cacheDirectory, rulesetHash) => {
38664
38800
  updatedAtMs: Date.now(),
38665
38801
  files: Object.fromEntries(cappedEntries)
38666
38802
  };
38667
- const keptHashes = Object.entries(rulesets).sort(([, first], [, second]) => second.updatedAtMs - first.updatedAtMs).slice(0, 8).map(([hash]) => hash);
38668
- const prunedRulesets = {};
38669
- for (const hash of keptHashes) prunedRulesets[hash] = rulesets[hash];
38670
38803
  atomicWriteJson(cacheFilePath, {
38671
38804
  version: 1,
38672
- rulesets: prunedRulesets
38805
+ rulesets: Object.fromEntries(Object.entries(rulesets).filter(([, bucket]) => isRecord(bucket) && typeof bucket.updatedAtMs === "number").sort(([, first], [, second]) => second.updatedAtMs - first.updatedAtMs).slice(0, 8))
38673
38806
  });
38674
38807
  }
38675
38808
  };
38676
38809
  };
38677
38810
  const bundledRequire = createRequire(import.meta.url);
38811
+ const childNodeVersionByBinaryPath = /* @__PURE__ */ new Map();
38812
+ const resolveChildNodeVersion = (nodeBinaryPath) => {
38813
+ if (nodeBinaryPath === process.execPath) return process.version;
38814
+ const cachedVersion = childNodeVersionByBinaryPath.get(nodeBinaryPath);
38815
+ if (cachedVersion !== void 0) return cachedVersion;
38816
+ let version;
38817
+ try {
38818
+ version = execFileSync(nodeBinaryPath, ["--version"], {
38819
+ encoding: "utf8",
38820
+ timeout: NODE_VERSION_PROBE_TIMEOUT_MS
38821
+ }).trim();
38822
+ } catch {
38823
+ version = `unknown:${nodeBinaryPath}`;
38824
+ }
38825
+ childNodeVersionByBinaryPath.set(nodeBinaryPath, version);
38826
+ return version;
38827
+ };
38678
38828
  const TOOLCHAIN_PACKAGE_SPECIFIERS = [
38679
38829
  "oxlint/package.json",
38680
38830
  "oxlint-plugin-react-doctor/package.json",
38681
38831
  "eslint-plugin-react-hooks/package.json"
38682
38832
  ];
38683
- const resolveOxlintToolchainVersions = () => {
38684
- const versions = [`node=${process.version}`];
38833
+ const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
38834
+ const versions = [`node=${resolveChildNodeVersion(nodeBinaryPath)}`];
38685
38835
  for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
38686
38836
  const packageJson = bundledRequire(specifier);
38687
38837
  const version = typeof packageJson.version === "string" ? packageJson.version : "unknown";
@@ -39215,11 +39365,12 @@ const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
39215
39365
  const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
39216
39366
  const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
39217
39367
  const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
39368
+ const REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION = "It's how the library works, not a bug in your code. Memoize values you pass from it into other memoized components, or suppress it with `// react-doctor-disable-next-line react-hooks-js/incompatible-library`.";
39218
39369
  const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
39219
- const buildReactCompilerMessage = (reasonSummary) => {
39370
+ const buildReactCompilerMessage = (reasonSummary, action = REACT_COMPILER_ACTION) => {
39220
39371
  const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
39221
- if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
39222
- return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
39372
+ if (!normalizedSummary) return `${REACT_COMPILER_IMPACT}. ${action}`;
39373
+ return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${action}`;
39223
39374
  };
39224
39375
  const PLUGIN_CATEGORY_MAP = {
39225
39376
  react: "Bugs",
@@ -39268,7 +39419,7 @@ const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
39268
39419
  const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
39269
39420
  const reasonDetail = reasonDetailLines.join("\n").trim();
39270
39421
  return {
39271
- message: buildReactCompilerMessage(reasonSummary.trim()),
39422
+ message: buildReactCompilerMessage(reasonSummary.trim(), rule === "incompatible-library" ? REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION : REACT_COMPILER_ACTION),
39272
39423
  help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
39273
39424
  };
39274
39425
  }
@@ -39536,21 +39687,27 @@ const spawnLintBatches = async (input) => {
39536
39687
  const allDiagnostics = [];
39537
39688
  const droppedFiles = [];
39538
39689
  let firstDropReason = null;
39539
- const splitDeadlineMs = Date.now() + splitTotalBudgetMs;
39540
- const spawnLintBatch = async (batch, depth) => {
39690
+ const spawnLintBatch = async (batch, depth, splitBudget) => {
39541
39691
  const batchArgs = [...baseArgs, ...batch];
39542
39692
  try {
39543
39693
  return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory);
39544
39694
  } catch (error) {
39545
39695
  if (!isSplittableReactDoctorError(error)) throw error;
39546
- const splitBudgetExhausted = Date.now() >= splitDeadlineMs || depth >= splitMaxDepth;
39547
- if (batch.length <= 1 || splitBudgetExhausted) {
39696
+ splitBudget.deadlineMs ??= Date.now() + splitTotalBudgetMs;
39697
+ const isBudgetElapsed = Date.now() >= splitBudget.deadlineMs;
39698
+ const isDepthCapReached = depth >= splitMaxDepth;
39699
+ if (batch.length <= 1 || isBudgetElapsed || isDepthCapReached) {
39548
39700
  droppedFiles.push(...batch);
39549
- if (firstDropReason === null) firstDropReason = splitBudgetExhausted && batch.length > 1 ? `${error.message} (split budget exhausted after ${splitMaxDepth} levels / ${splitTotalBudgetMs / MILLISECONDS_PER_SECOND}s)` : error.message;
39701
+ if (firstDropReason === null) {
39702
+ let limitHint = "";
39703
+ if (isDepthCapReached) limitHint = ` (split depth cap of ${splitMaxDepth} levels reached)`;
39704
+ else if (isBudgetElapsed) limitHint = ` (split budget of ${splitTotalBudgetMs / MILLISECONDS_PER_SECOND}s exhausted at depth ${depth})`;
39705
+ firstDropReason = batch.length > 1 ? `${error.message}${limitHint}` : error.message;
39706
+ }
39550
39707
  return [];
39551
39708
  }
39552
39709
  const splitIndex = Math.ceil(batch.length / 2);
39553
- return [...await spawnLintBatch(batch.slice(0, splitIndex), depth + 1), ...await spawnLintBatch(batch.slice(splitIndex), depth + 1)];
39710
+ return [...await spawnLintBatch(batch.slice(0, splitIndex), depth + 1, splitBudget), ...await spawnLintBatch(batch.slice(splitIndex), depth + 1, splitBudget)];
39554
39711
  }
39555
39712
  };
39556
39713
  let startedFileCount = 0;
@@ -39567,7 +39724,7 @@ const spawnLintBatches = async (input) => {
39567
39724
  try {
39568
39725
  const batchResults = await mapWithConcurrency(fileBatches, concurrency, async (batch) => {
39569
39726
  startedFileCount += batch.length;
39570
- const batchDiagnostics = await spawnLintBatch(batch, 0);
39727
+ const batchDiagnostics = await spawnLintBatch(batch, 0, { deadlineMs: null });
39571
39728
  scannedFileCount += batch.length;
39572
39729
  if (onFileProgress) {
39573
39730
  displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
@@ -39641,7 +39798,14 @@ const resolveReactDoctorCacheDir = (projectDirectory) => {
39641
39798
  if (cacheDirOverride) return Path.join(cacheDirOverride, projectCacheSubdir(projectDirectory));
39642
39799
  const nodeModulesDirectory = Path.join(projectDirectory, "node_modules");
39643
39800
  if (NFS.existsSync(nodeModulesDirectory)) return Path.join(nodeModulesDirectory, ".cache", "react-doctor");
39644
- return Path.join(os.tmpdir(), "react-doctor-cache", projectCacheSubdir(projectDirectory));
39801
+ return Path.join(os.tmpdir(), `react-doctor-cache-${resolveUserCacheScope()}`, projectCacheSubdir(projectDirectory));
39802
+ };
39803
+ const resolveUserCacheScope = () => {
39804
+ try {
39805
+ return String(process.getuid?.() ?? os.userInfo().username);
39806
+ } catch {
39807
+ return "shared";
39808
+ }
39645
39809
  };
39646
39810
  const sortSourceFilesByCost = (entries) => [...entries].sort((left, right) => right.sizeBytes - left.sizeBytes).map((entry) => entry.path);
39647
39811
  /**
@@ -39809,7 +39973,7 @@ const runOxlint = async (options) => {
39809
39973
  extendsPaths: [],
39810
39974
  ruleSelection: "cacheable"
39811
39975
  }),
39812
- toolchainVersions: resolveOxlintToolchainVersions(),
39976
+ toolchainVersions: resolveOxlintToolchainVersions(nodeBinaryPath),
39813
39977
  ignorePatterns: combinedPatterns,
39814
39978
  tsconfigContent
39815
39979
  });
@@ -39823,7 +39987,7 @@ const runOxlint = async (options) => {
39823
39987
  missFiles.push(candidateFile);
39824
39988
  continue;
39825
39989
  }
39826
- const cacheKey = `${candidateFile.replaceAll("\\", "/")}${contentHash}`;
39990
+ const cacheKey = `${candidateFile.replaceAll("\\", "/")}\u0000${contentHash}`;
39827
39991
  cacheKeyByFile.set(candidateFile, cacheKey);
39828
39992
  const cachedDiagnostics = cache.lookup(cacheKey);
39829
39993
  if (cachedDiagnostics === null) missFiles.push(candidateFile);
@@ -40139,7 +40303,7 @@ const ScoreApiResponseSchema = Struct({
40139
40303
  })))
40140
40304
  });
40141
40305
  const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
40142
- const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, ...rest }) => rest);
40306
+ const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, fixGroupId: _fixGroupId, ...rest }) => rest);
40143
40307
  const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
40144
40308
  const describeFailure = (error) => {
40145
40309
  if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
@@ -40443,7 +40607,10 @@ const ALERT_SEVERITY_RANK = {
40443
40607
  medium: 2,
40444
40608
  low: 1
40445
40609
  };
40446
- const severityRank = (severity) => ALERT_SEVERITY_RANK[severity.toLowerCase()] ?? 0;
40610
+ const severityRank = (severity) => {
40611
+ const normalized = severity.toLowerCase();
40612
+ return Object.hasOwn(ALERT_SEVERITY_RANK, normalized) ? ALERT_SEVERITY_RANK[normalized] : 0;
40613
+ };
40447
40614
  const displaySeverity = (severity) => {
40448
40615
  const normalized = sanitizeTerminalText(severity.toLowerCase());
40449
40616
  return normalized === "middle" ? "medium" : normalized;
@@ -40460,7 +40627,7 @@ const ALERT_TYPE_LABELS = {
40460
40627
  typosquat: "possible typosquat"
40461
40628
  };
40462
40629
  const humanizeAlertType = (type) => type.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase().trim();
40463
- const friendlyAlertType = (type) => ALERT_TYPE_LABELS[type] ?? sanitizeTerminalText(humanizeAlertType(type));
40630
+ const friendlyAlertType = (type) => Object.hasOwn(ALERT_TYPE_LABELS, type) ? ALERT_TYPE_LABELS[type] : sanitizeTerminalText(humanizeAlertType(type));
40464
40631
  const summarizeAlertNote = (note) => {
40465
40632
  const collapsed = sanitizeTerminalText(note.replace(/\s+/g, " ").trim());
40466
40633
  const firstSentence = collapsed.split(/(?<=\.)\s/)[0] || collapsed;
@@ -40555,7 +40722,10 @@ const checkSupplyChain = (input) => gen(function* () {
40555
40722
  * outage.
40556
40723
  */
40557
40724
  var SupplyChain = class SupplyChain extends Service()("react-doctor/SupplyChain") {
40558
- static layerNode = succeed$3(SupplyChain, SupplyChain.of({ run: (input) => unwrap(checkSupplyChain(input).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), withSpan("SupplyChain.run"))) }));
40725
+ static layerNode = succeed$3(SupplyChain, SupplyChain.of({ run: (input) => unwrap(flatMap$2(SupplyChainOverlapTimeoutMs, (totalTimeoutMs) => checkSupplyChain({
40726
+ ...input,
40727
+ totalTimeoutMs
40728
+ })).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), withSpan("SupplyChain.run"))) }));
40559
40729
  static layerOf = (diagnostics) => succeed$3(SupplyChain, SupplyChain.of({ run: () => fromIterable$1(diagnostics) }));
40560
40730
  };
40561
40731
  const getObjectProperty = (value, propertyName) => {
@@ -40617,7 +40787,10 @@ const formatLintFailText = (reasonTag, nodeVersion) => {
40617
40787
  * diagnostics).
40618
40788
  * 2. beforeLint hook (e.g. CLI renders the project-detection block)
40619
40789
  * 3. environment checks (reduced-motion + pnpm hardening +
40620
- * expo/react-native + security scan), collected synchronously
40790
+ * expo/react-native), collected synchronously. The heavier
40791
+ * content-regex security scan is forked instead (like supply-chain
40792
+ * below) and joined before the concat, so its CPU overlaps lint
40793
+ * rather than blocking the event loop before it.
40621
40794
  * 4. The supply-chain check (Socket.dev) is forked onto a background
40622
40795
  * fiber so its ~100% network-bound time overlaps the ~100%
40623
40796
  * CPU/subprocess-bound lint pass below, collapsing two serial
@@ -40637,7 +40810,7 @@ const formatLintFailText = (reasonTag, nodeVersion) => {
40637
40810
  * order, so terminal output is identical either way; supply-chain
40638
40811
  * rides alongside without a spinner.
40639
40812
  * 6. Join the supply-chain fiber, then assemble the diagnostics in a
40640
- * FIXED order (env, supply-chain, lint, dead-code) so the output is
40813
+ * FIXED order (env, security-scan, supply-chain, lint, dead-code) so the output is
40641
40814
  * byte-identical regardless of which fiber settled first. The
40642
40815
  * viewer-permission fiber is joined later, during score-metadata
40643
40816
  * assembly (it feeds score metadata, not diagnostics). The per-element
@@ -40698,12 +40871,13 @@ const runInspect = (input, hooks = {}) => gen(function* () {
40698
40871
  ...checkPnpmHardening(scanDirectory),
40699
40872
  ...checkReactServerComponentsAdvisory(scanDirectory, project),
40700
40873
  ...checkExpoProject(scanDirectory, project),
40701
- ...checkReactNativeProject(scanDirectory, project),
40702
- ...checkSecurityScan(scanDirectory, {
40703
- project,
40704
- ignoredTags: input.ignoredTags
40705
- })
40874
+ ...checkReactNativeProject(scanDirectory, project)
40706
40875
  ])));
40876
+ const securityScanFailedRef = yield* make$13(false);
40877
+ const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(tryPromise(() => checkSecurityScanCooperative(scanDirectory, {
40878
+ project,
40879
+ ignoredTags: input.ignoredTags
40880
+ })).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), catch_$1(() => set(securityScanFailedRef, true).pipe(as(empty$4))))))).pipe(withSpan("SecurityScan.run")));
40707
40881
  const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
40708
40882
  const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
40709
40883
  const supplyChainFiber = yield* forkChild(shouldRunSupplyChain ? runCollect(applyPerElementPipeline(supplyChainService.run({
@@ -40741,7 +40915,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
40741
40915
  const lintConcurrency = deadCodeParseConcurrency === void 0 ? scanConcurrency : Math.max(1, scanConcurrency - deadCodeParseConcurrency);
40742
40916
  const buildCollectDeadCode = (deadCodeTimeout) => runCollect(applyPerElementPipeline(deadCodeService.run({
40743
40917
  rootDirectory: scanDirectory,
40744
- userConfig: resolvedConfig.config,
40745
40918
  parseConcurrency: deadCodeParseConcurrency,
40746
40919
  workerTimeoutMs: deadCodeTimeout.workerTimeoutMs
40747
40920
  }).pipe(catchTag("ReactDoctorError", (error) => unwrap(gen(function* () {
@@ -40839,9 +41012,11 @@ const runInspect = (input, hooks = {}) => gen(function* () {
40839
41012
  else yield* scanProgress.succeed(`Scanned ${scannedFilesLabel} in ${scanElapsedSeconds}s${workerCountSuffix}`);
40840
41013
  const supplyChainResult = yield* join(supplyChainFiber);
40841
41014
  const supplyChainCollected = supplyChainResult.diagnostics;
41015
+ const securityScanCollected = yield* join(securityScanFiber);
40842
41016
  yield* reporterService.finalize;
40843
41017
  const finalDiagnostics = sortDiagnosticsStable(assignFixGroups([
40844
41018
  ...envCollected,
41019
+ ...securityScanCollected,
40845
41020
  ...supplyChainCollected,
40846
41021
  ...lintCollected,
40847
41022
  ...deadCodeCollected
@@ -40867,6 +41042,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
40867
41042
  metadata: scoreMetadata
40868
41043
  });
40869
41044
  const lintPartialFailures = yield* get$2(partialFailuresRef);
41045
+ const securityScanFailed = yield* get$2(securityScanFailedRef);
40870
41046
  return {
40871
41047
  project,
40872
41048
  userConfig: resolvedConfig.config,
@@ -40887,8 +41063,10 @@ const runInspect = (input, hooks = {}) => gen(function* () {
40887
41063
  scanElapsedMilliseconds,
40888
41064
  scanConcurrency,
40889
41065
  supplyChainOverlapTimedOut: supplyChainResult.timedOut,
41066
+ securityScanFailed,
40890
41067
  lintCacheHitFileCount,
40891
- lintCacheTotalFileCount
41068
+ lintCacheTotalFileCount,
41069
+ suppressedRuleCounts: transform.summarizeSuppressions()
40892
41070
  };
40893
41071
  }).pipe(withSpan("runInspect", { attributes: {
40894
41072
  "inspect.directory": input.directory,
@@ -42926,6 +43104,8 @@ const METRIC = {
42926
43104
  scanCheckSkipped: "scan.check_skipped",
42927
43105
  baselineDegraded: "baseline.degraded",
42928
43106
  ruleFired: "rule.fired",
43107
+ ruleDisabled: "rule.disabled",
43108
+ ruleSuppressed: "rule.suppressed",
42929
43109
  lintFailed: "lint.failed",
42930
43110
  deadCodeFailed: "deadcode.failed",
42931
43111
  scoreUnavailable: "score.unavailable",
@@ -42938,12 +43118,17 @@ const METRIC = {
42938
43118
  installWorkflow: "install.workflow",
42939
43119
  installAgentHooks: "install.agent_hooks",
42940
43120
  installDependency: "install.dependency",
43121
+ ciScaffolded: "ci.scaffolded",
43122
+ ciUpgraded: "ci.upgraded",
43123
+ ciConfigured: "ci.configured",
42941
43124
  rulesChanged: "rules.changed",
42942
43125
  rulesQueried: "rules.queried",
42943
43126
  lspSessionStarted: "lsp.session.started",
42944
43127
  lspScanCompleted: "lsp.scan.completed",
42945
43128
  lspScanDuration: "lsp.scan.duration",
42946
- lspScanDiagnostics: "lsp.scan.diagnostics"
43129
+ lspScanDiagnostics: "lsp.scan.diagnostics",
43130
+ aiTrainingWarningShown: "ai.training.warning_shown",
43131
+ jsonOutUsed: "json.out_used"
42947
43132
  };
42948
43133
  //#endregion
42949
43134
  //#region src/cli/utils/to-category-key.ts
@@ -43260,5 +43445,5 @@ const startLanguageServer = () => {
43260
43445
  };
43261
43446
  //#endregion
43262
43447
  export { startLanguageServer };
43263
- !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]="1b85b637-9e6d-554c-a429-3652a14706b0")}catch(e){}}();
43264
- //# debugId=1b85b637-9e6d-554c-a429-3652a14706b0
43448
+ !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]="349b2e37-65e9-5f86-8168-70334a95aeec")}catch(e){}}();
43449
+ //# debugId=349b2e37-65e9-5f86-8168-70334a95aeec