react-doctor 0.5.8-dev.970babc → 0.5.8-dev.99f2417
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/LICENSE +14 -1
- package/dist/cli.js +487 -187
- package/dist/index.d.ts +11 -2
- package/dist/index.js +211 -32
- package/dist/lsp.js +151 -33
- package/package.json +8 -7
package/dist/index.d.ts
CHANGED
|
@@ -9271,6 +9271,15 @@ interface ReactDoctorConfig {
|
|
|
9271
9271
|
* suppresses regardless of sibling content.
|
|
9272
9272
|
*/
|
|
9273
9273
|
rawTextWrapperComponents?: string[];
|
|
9274
|
+
/**
|
|
9275
|
+
* Capitalized identifiers that exist at runtime but aren't imported in
|
|
9276
|
+
* the file that uses them — react-live's `<LiveProvider scope={...}>`,
|
|
9277
|
+
* Storybook globals, MDX live blocks, or an ambient `declare global` in a
|
|
9278
|
+
* separate `.d.ts`. The single-file `jsx-no-undef` rule can't see those
|
|
9279
|
+
* bindings and would report `<DatePicker />` as an undefined JSX component.
|
|
9280
|
+
* List the injected names here and `jsx-no-undef` treats them as known.
|
|
9281
|
+
*/
|
|
9282
|
+
runtimeGlobals?: string[];
|
|
9274
9283
|
/**
|
|
9275
9284
|
* Project-level allowlist of function names that the
|
|
9276
9285
|
* `server-auth-actions` rule treats as an auth check at the top of
|
|
@@ -9726,7 +9735,7 @@ interface InspectResult {
|
|
|
9726
9735
|
* Per-file lint cache outcome: files served from cache, and total files
|
|
9727
9736
|
* considered. Both absent when the cache was off or bypassed (audit mode,
|
|
9728
9737
|
* adopted `extends`, user plugins). The CLI projects these onto the Sentry
|
|
9729
|
-
* wide event as `
|
|
9738
|
+
* wide event as `lint.cacheHitRatio`.
|
|
9730
9739
|
*/
|
|
9731
9740
|
lintCacheHitFileCount?: number | null;
|
|
9732
9741
|
lintCacheTotalFileCount?: number | null;
|
|
@@ -10123,7 +10132,7 @@ declare const summarizeDiagnostics: (diagnostics: Diagnostic[], worstScore?: num
|
|
|
10123
10132
|
* untouched so the loader sees the same plain object either way.
|
|
10124
10133
|
*/
|
|
10125
10134
|
declare const defineConfig: (config: ReactDoctorConfig) => ReactDoctorConfig; //#endregion
|
|
10126
|
-
//#region src/utils/
|
|
10135
|
+
//#region src/utils/detect-ai-training-environment.d.ts
|
|
10127
10136
|
//#endregion
|
|
10128
10137
|
//#region ../api/dist/index.d.ts
|
|
10129
10138
|
//#region src/diagnose.d.ts
|
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]="
|
|
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]="0bd202f9-5e22-5625-86dc-458270afbcca")}catch(e){}}();
|
|
3
3
|
import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as NFS from "node:fs";
|
|
@@ -5996,7 +5996,7 @@ const composePassthrough = /* @__PURE__ */ dual(2, (left, right) => (input) => {
|
|
|
5996
5996
|
* @since 2.0.0
|
|
5997
5997
|
*/
|
|
5998
5998
|
const Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", { defaultValue: () => new MixedScheduler() });
|
|
5999
|
-
const setImmediate = "setImmediate" in globalThis ? (f) => {
|
|
5999
|
+
const setImmediate$1 = "setImmediate" in globalThis ? (f) => {
|
|
6000
6000
|
const timer = globalThis.setImmediate(f);
|
|
6001
6001
|
return () => globalThis.clearImmediate(timer);
|
|
6002
6002
|
} : (f) => {
|
|
@@ -6040,7 +6040,7 @@ var PriorityBuckets = class {
|
|
|
6040
6040
|
var MixedScheduler = class {
|
|
6041
6041
|
executionMode;
|
|
6042
6042
|
setImmediate;
|
|
6043
|
-
constructor(executionMode = "async", setImmediateFn = setImmediate) {
|
|
6043
|
+
constructor(executionMode = "async", setImmediateFn = setImmediate$1) {
|
|
6044
6044
|
this.executionMode = executionMode;
|
|
6045
6045
|
this.setImmediate = setImmediateFn;
|
|
6046
6046
|
}
|
|
@@ -6065,7 +6065,7 @@ var MixedSchedulerDispatcher = class {
|
|
|
6065
6065
|
tasks = /* @__PURE__ */ new PriorityBuckets();
|
|
6066
6066
|
running = void 0;
|
|
6067
6067
|
setImmediate;
|
|
6068
|
-
constructor(setImmediateFn = setImmediate) {
|
|
6068
|
+
constructor(setImmediateFn = setImmediate$1) {
|
|
6069
6069
|
this.setImmediate = setImmediateFn;
|
|
6070
6070
|
}
|
|
6071
6071
|
/**
|
|
@@ -33752,6 +33752,7 @@ const DEAD_CODE_PHASE_TIMEOUT_MS = 15e4;
|
|
|
33752
33752
|
const LINT_PHASE_TIMEOUT_MS = 3e5;
|
|
33753
33753
|
const SCAN_TOTAL_DEADLINE_MS = 9e5;
|
|
33754
33754
|
const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
|
|
33755
|
+
const DEAD_CODE_WORKER_MEM_BUDGET_BYTES = 2 * 1024 * 1024 * 1024;
|
|
33755
33756
|
const DEAD_CODE_TIMEOUT_CEILING_MS = 6e5;
|
|
33756
33757
|
const DEAD_CODE_PHASE_TIMEOUT_OVER_WORKER_MS = 3e4;
|
|
33757
33758
|
const DEAD_CODE_OVERLAP_PARSE_SHARE = .4;
|
|
@@ -34998,6 +34999,7 @@ const collectStringSet = (values) => {
|
|
|
34998
34999
|
if (!Array.isArray(values)) return /* @__PURE__ */ new Set();
|
|
34999
35000
|
return new Set(values.filter((value) => typeof value === "string"));
|
|
35000
35001
|
};
|
|
35002
|
+
const JSX_NO_UNDEF_IDENTIFIER_PATTERN = /^`([^`]+)`/;
|
|
35001
35003
|
/**
|
|
35002
35004
|
* Pre-compiles every stateful filter and returns a single
|
|
35003
35005
|
* `apply(diagnostic)` closure that runs (in order):
|
|
@@ -35031,8 +35033,10 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
35031
35033
|
const compiledOverrides = compileIgnoreOverrides(userConfig);
|
|
35032
35034
|
const textComponentNames = collectStringSet(userConfig?.textComponents);
|
|
35033
35035
|
const rawTextWrapperComponentNames = collectStringSet(userConfig?.rawTextWrapperComponents);
|
|
35036
|
+
const runtimeGlobalNames = collectStringSet(userConfig?.runtimeGlobals);
|
|
35034
35037
|
const hasTextComponents = textComponentNames.size > 0;
|
|
35035
35038
|
const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
|
|
35039
|
+
const hasRuntimeGlobals = runtimeGlobalNames.size > 0;
|
|
35036
35040
|
const fileLinesCache = /* @__PURE__ */ new Map();
|
|
35037
35041
|
const fileContextCache = /* @__PURE__ */ new Map();
|
|
35038
35042
|
const libraryFileCache = /* @__PURE__ */ new Map();
|
|
@@ -35084,6 +35088,12 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
35084
35088
|
if (hasRawTextWrappers && isInsideStringOnlyWrapper(lines, diagnostic.line, diagnostic.column, rawTextWrapperComponentNames)) return true;
|
|
35085
35089
|
return false;
|
|
35086
35090
|
};
|
|
35091
|
+
const isJsxNoUndefSuppressedByConfig = (diagnostic) => {
|
|
35092
|
+
if (!hasRuntimeGlobals) return false;
|
|
35093
|
+
if (diagnostic.rule !== "jsx-no-undef") return false;
|
|
35094
|
+
const identifierMatch = JSX_NO_UNDEF_IDENTIFIER_PATTERN.exec(diagnostic.message);
|
|
35095
|
+
return identifierMatch !== null && runtimeGlobalNames.has(identifierMatch[1]);
|
|
35096
|
+
};
|
|
35087
35097
|
return { apply: (diagnostic) => {
|
|
35088
35098
|
if (shouldAutoSuppress(diagnostic)) return null;
|
|
35089
35099
|
let current = diagnostic;
|
|
@@ -35108,6 +35118,7 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
35108
35118
|
if (isFileIgnoredByPatterns(current.filePath, rootDirectory, ignoredFilePatterns)) return null;
|
|
35109
35119
|
if (isDiagnosticIgnoredByOverrides(current, rootDirectory, compiledOverrides)) return null;
|
|
35110
35120
|
if (isRnRawTextSuppressedByConfig(current)) return null;
|
|
35121
|
+
if (isJsxNoUndefSuppressedByConfig(current)) return null;
|
|
35111
35122
|
}
|
|
35112
35123
|
if (respectInlineDisables && current.line > 0) {
|
|
35113
35124
|
const lines = getFileLines(current.filePath);
|
|
@@ -35369,7 +35380,7 @@ const resolveScanConcurrency = (requested) => {
|
|
|
35369
35380
|
if (!Number.isFinite(requested) || requested < 1) return 1;
|
|
35370
35381
|
return Math.min(Math.floor(requested), 32);
|
|
35371
35382
|
};
|
|
35372
|
-
const readSystemFacts = () => ({
|
|
35383
|
+
const readSystemFacts$1 = () => ({
|
|
35373
35384
|
availableCores: os.availableParallelism(),
|
|
35374
35385
|
totalMemoryBytes: os.totalmem(),
|
|
35375
35386
|
cgroupMemoryLimitBytes: readCgroupMemoryLimitBytes()
|
|
@@ -35390,7 +35401,7 @@ const readSystemFacts = () => ({
|
|
|
35390
35401
|
* `facts` is injectable so tests exercise core-bound, memory-bound, cgroup-
|
|
35391
35402
|
* limited, and ceiling cases without mocking `os` or the filesystem.
|
|
35392
35403
|
*/
|
|
35393
|
-
const resolveAutoScanConcurrency = (facts = readSystemFacts()) => {
|
|
35404
|
+
const resolveAutoScanConcurrency = (facts = readSystemFacts$1()) => {
|
|
35394
35405
|
const availableMemoryBytes = Math.min(facts.totalMemoryBytes, facts.cgroupMemoryLimitBytes ?? Number.POSITIVE_INFINITY);
|
|
35395
35406
|
const memoryBoundedWorkers = Math.floor(availableMemoryBytes / PER_WORKER_MEM_BUDGET_BYTES);
|
|
35396
35407
|
return resolveScanConcurrency(Math.min(facts.availableCores, memoryBoundedWorkers));
|
|
@@ -35585,6 +35596,7 @@ const STRING_ARRAY_FIELD_NAMES = [
|
|
|
35585
35596
|
"projects",
|
|
35586
35597
|
"textComponents",
|
|
35587
35598
|
"rawTextWrapperComponents",
|
|
35599
|
+
"runtimeGlobals",
|
|
35588
35600
|
"serverAuthFunctionNames"
|
|
35589
35601
|
];
|
|
35590
35602
|
const SURFACE_CONTROL_FIELD_NAMES = [
|
|
@@ -36923,7 +36935,10 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledBy)
|
|
|
36923
36935
|
}
|
|
36924
36936
|
return true;
|
|
36925
36937
|
};
|
|
36926
|
-
const
|
|
36938
|
+
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
36939
|
+
setImmediate(resolve);
|
|
36940
|
+
});
|
|
36941
|
+
const createSecurityScanSession = (rootDirectory, options) => {
|
|
36927
36942
|
const capabilities = options.project ? buildCapabilities(options.project) : /* @__PURE__ */ new Set();
|
|
36928
36943
|
const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
|
|
36929
36944
|
const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
|
|
@@ -36938,7 +36953,7 @@ const checkSecurityScan = (rootDirectory, options = {}) => {
|
|
|
36938
36953
|
committedFilesOnly: rule.committedFilesOnly === true
|
|
36939
36954
|
}];
|
|
36940
36955
|
});
|
|
36941
|
-
if (enabledScanRules.length === 0) return
|
|
36956
|
+
if (enabledScanRules.length === 0) return null;
|
|
36942
36957
|
const diagnostics = [];
|
|
36943
36958
|
const seen = /* @__PURE__ */ new Set();
|
|
36944
36959
|
const gitIgnoredCache = /* @__PURE__ */ new Map();
|
|
@@ -36950,15 +36965,34 @@ const checkSecurityScan = (rootDirectory, options = {}) => {
|
|
|
36950
36965
|
}
|
|
36951
36966
|
return status === true;
|
|
36952
36967
|
};
|
|
36953
|
-
|
|
36954
|
-
|
|
36955
|
-
|
|
36956
|
-
|
|
36957
|
-
|
|
36958
|
-
|
|
36959
|
-
|
|
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
|
+
}
|
|
36960
36994
|
}
|
|
36961
|
-
return diagnostics;
|
|
36995
|
+
return session.diagnostics;
|
|
36962
36996
|
};
|
|
36963
36997
|
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
36964
36998
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
@@ -37175,6 +37209,74 @@ const collectDeadCodeIgnorePatterns = (rootDirectory) => {
|
|
|
37175
37209
|
return [...seen].filter((pattern) => pattern.length > 0);
|
|
37176
37210
|
};
|
|
37177
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
|
+
};
|
|
37178
37280
|
/**
|
|
37179
37281
|
* Resolves a path to its canonical, symlink-free form, falling back to
|
|
37180
37282
|
* the input when it cannot be realpath'd (broken symlink, permission
|
|
@@ -37199,6 +37301,11 @@ const toCanonicalPath = (filePath) => {
|
|
|
37199
37301
|
};
|
|
37200
37302
|
const DEAD_CODE_PLUGIN = "deslop";
|
|
37201
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
|
+
]);
|
|
37202
37309
|
const DEAD_CODE_WORKER_SCRIPT = `
|
|
37203
37310
|
const inputChunks = [];
|
|
37204
37311
|
process.stdin.on("data", (chunk) => inputChunks.push(chunk));
|
|
@@ -37465,14 +37572,17 @@ const checkDeadCode = async (options) => {
|
|
|
37465
37572
|
if (!NFS.existsSync(Path.join(rootDirectory, "package.json"))) return [];
|
|
37466
37573
|
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
37467
37574
|
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
37468
|
-
const
|
|
37469
|
-
|
|
37470
|
-
|
|
37471
|
-
|
|
37472
|
-
|
|
37473
|
-
|
|
37474
|
-
|
|
37475
|
-
|
|
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());
|
|
37476
37586
|
const toRelative = (filePath) => toRelativeFilePath(rootDirectory, filePath);
|
|
37477
37587
|
const diagnostics = [];
|
|
37478
37588
|
for (const unusedFile of result.unusedFiles) diagnostics.push({
|
|
@@ -37501,6 +37611,7 @@ const checkDeadCode = async (options) => {
|
|
|
37501
37611
|
});
|
|
37502
37612
|
}
|
|
37503
37613
|
for (const unusedDependency of result.unusedDependencies) {
|
|
37614
|
+
if (REACT_DOCTOR_TOOLCHAIN_PACKAGES.has(unusedDependency.name)) continue;
|
|
37504
37615
|
const label = unusedDependency.isDevDependency ? "devDependency" : "dependency";
|
|
37505
37616
|
diagnostics.push({
|
|
37506
37617
|
filePath: "package.json",
|
|
@@ -40636,7 +40747,10 @@ const formatLintFailText = (reasonTag, nodeVersion) => {
|
|
|
40636
40747
|
* diagnostics).
|
|
40637
40748
|
* 2. beforeLint hook (e.g. CLI renders the project-detection block)
|
|
40638
40749
|
* 3. environment checks (reduced-motion + pnpm hardening +
|
|
40639
|
-
* expo/react-native
|
|
40750
|
+
* expo/react-native), collected synchronously. The heavier
|
|
40751
|
+
* content-regex security scan is forked instead (like supply-chain
|
|
40752
|
+
* below) and joined before the concat, so its CPU overlaps lint
|
|
40753
|
+
* rather than blocking the event loop before it.
|
|
40640
40754
|
* 4. The supply-chain check (Socket.dev) is forked onto a background
|
|
40641
40755
|
* fiber so its ~100% network-bound time overlaps the ~100%
|
|
40642
40756
|
* CPU/subprocess-bound lint pass below, collapsing two serial
|
|
@@ -40656,7 +40770,7 @@ const formatLintFailText = (reasonTag, nodeVersion) => {
|
|
|
40656
40770
|
* order, so terminal output is identical either way; supply-chain
|
|
40657
40771
|
* rides alongside without a spinner.
|
|
40658
40772
|
* 6. Join the supply-chain fiber, then assemble the diagnostics in a
|
|
40659
|
-
* FIXED order (env, supply-chain, lint, dead-code) so the output is
|
|
40773
|
+
* FIXED order (env, security-scan, supply-chain, lint, dead-code) so the output is
|
|
40660
40774
|
* byte-identical regardless of which fiber settled first. The
|
|
40661
40775
|
* viewer-permission fiber is joined later, during score-metadata
|
|
40662
40776
|
* assembly (it feeds score metadata, not diagnostics). The per-element
|
|
@@ -40717,12 +40831,12 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
40717
40831
|
...checkPnpmHardening(scanDirectory),
|
|
40718
40832
|
...checkReactServerComponentsAdvisory(scanDirectory, project),
|
|
40719
40833
|
...checkExpoProject(scanDirectory, project),
|
|
40720
|
-
...checkReactNativeProject(scanDirectory, project)
|
|
40721
|
-
...checkSecurityScan(scanDirectory, {
|
|
40722
|
-
project,
|
|
40723
|
-
ignoredTags: input.ignoredTags
|
|
40724
|
-
})
|
|
40834
|
+
...checkReactNativeProject(scanDirectory, project)
|
|
40725
40835
|
])));
|
|
40836
|
+
const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(promise(() => checkSecurityScanCooperative(scanDirectory, {
|
|
40837
|
+
project,
|
|
40838
|
+
ignoredTags: input.ignoredTags
|
|
40839
|
+
})).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)))))).pipe(withSpan("SecurityScan.run")));
|
|
40726
40840
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
40727
40841
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
40728
40842
|
const supplyChainFiber = yield* forkChild(shouldRunSupplyChain ? runCollect(applyPerElementPipeline(supplyChainService.run({
|
|
@@ -40858,9 +40972,11 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
40858
40972
|
else yield* scanProgress.succeed(`Scanned ${scannedFilesLabel} in ${scanElapsedSeconds}s${workerCountSuffix}`);
|
|
40859
40973
|
const supplyChainResult = yield* join(supplyChainFiber);
|
|
40860
40974
|
const supplyChainCollected = supplyChainResult.diagnostics;
|
|
40975
|
+
const securityScanCollected = yield* join(securityScanFiber);
|
|
40861
40976
|
yield* reporterService.finalize;
|
|
40862
40977
|
const finalDiagnostics = sortDiagnosticsStable(assignFixGroups([
|
|
40863
40978
|
...envCollected,
|
|
40979
|
+
...securityScanCollected,
|
|
40864
40980
|
...supplyChainCollected,
|
|
40865
40981
|
...lintCollected,
|
|
40866
40982
|
...deadCodeCollected
|
|
@@ -41312,6 +41428,61 @@ const clearAutoSuppressionCaches = () => {};
|
|
|
41312
41428
|
* untouched so the loader sees the same plain object either way.
|
|
41313
41429
|
*/
|
|
41314
41430
|
const defineConfig = (config) => config;
|
|
41431
|
+
const AI_TRAINING_ENV_VARS = [
|
|
41432
|
+
["HF_DATASETS_CACHE", "huggingface"],
|
|
41433
|
+
["HF_HOME", "huggingface"],
|
|
41434
|
+
["HUGGINGFACE_HUB_CACHE", "huggingface"],
|
|
41435
|
+
["SPACE_ID", "huggingface-spaces"],
|
|
41436
|
+
["CUDA_VISIBLE_DEVICES", "cuda"],
|
|
41437
|
+
["NVIDIA_VISIBLE_DEVICES", "nvidia"],
|
|
41438
|
+
["ROCR_VISIBLE_DEVICES", "rocm"],
|
|
41439
|
+
["TPU_NAME", "google-tpu"],
|
|
41440
|
+
["WANDB_RUN_ID", "wandb"],
|
|
41441
|
+
["WANDB_SWEEP_ID", "wandb"],
|
|
41442
|
+
["MLFLOW_RUN_ID", "mlflow"],
|
|
41443
|
+
["MLFLOW_TRACKING_URI", "mlflow"],
|
|
41444
|
+
["COMET_EXPERIMENT_KEY", "comet"],
|
|
41445
|
+
["NEPTUNE_RUN_ID", "neptune"],
|
|
41446
|
+
["CLEARML_TASK_ID", "clearml"],
|
|
41447
|
+
["DVC_STAGE", "dvc"],
|
|
41448
|
+
["RAY_WORKER_PROCESS", "ray"],
|
|
41449
|
+
["RAY_ADDRESS", "ray"],
|
|
41450
|
+
["MUJOCO_GL", "mujoco"],
|
|
41451
|
+
["MUJOCO_PATH", "mujoco"],
|
|
41452
|
+
["GYM_DISABLE_ENV_CHECKER", "gymnasium"],
|
|
41453
|
+
["SM_TRAINING_ENV", "sagemaker"],
|
|
41454
|
+
["TRAINING_JOB_ARN", "sagemaker"],
|
|
41455
|
+
["SAGEMAKER_BASE_DIR", "sagemaker"],
|
|
41456
|
+
["AZUREML_RUN_ID", "azure-ml"],
|
|
41457
|
+
["AZURE_ML_MODEL_DIR", "azure-ml"],
|
|
41458
|
+
["CLOUD_ML_PROJECT_ID", "vertex-ai"],
|
|
41459
|
+
["VERTEX_AI_LOG_LEVEL", "vertex-ai"],
|
|
41460
|
+
["DET_MASTER", "determined-ai"],
|
|
41461
|
+
["LIGHTNING_USER_ID", "lightning-ai"],
|
|
41462
|
+
["FLYTE_INTERNAL_EXECUTION_ID", "flyte"],
|
|
41463
|
+
["ARGO_WORKFLOW_NAME", "argo-workflows"],
|
|
41464
|
+
["KFP_POD_NAME", "kubeflow-pipelines"],
|
|
41465
|
+
["KAGGLE_KERNEL_RUN_TYPE", "kaggle"],
|
|
41466
|
+
["COLAB_BACKEND_VERSION", "google-colab"],
|
|
41467
|
+
["DATABRICKS_RUNTIME_VERSION", "databricks"],
|
|
41468
|
+
["DAYTONA_WS_ID", "daytona"],
|
|
41469
|
+
["DAYTONA_WS_NAME", "daytona"],
|
|
41470
|
+
["E2B_SANDBOX_ID", "e2b"],
|
|
41471
|
+
["MODAL_FUNCTION_ID", "modal"],
|
|
41472
|
+
["MODAL_TASK_ID", "modal"],
|
|
41473
|
+
["RUNPOD_POD_ID", "runpod"],
|
|
41474
|
+
["REPLICATE_USERNAME", "replicate"],
|
|
41475
|
+
["VAST_CONTAINERLABEL", "vast-ai"],
|
|
41476
|
+
["HARBOR_URL", "harbor"],
|
|
41477
|
+
["HARBOR_HOSTNAME", "harbor"],
|
|
41478
|
+
["SWE_BENCH_TASK", "swe-bench"],
|
|
41479
|
+
["SWEBENCH_TASK", "swe-bench"],
|
|
41480
|
+
["SWE_AGENT_MODEL", "swe-agent"]
|
|
41481
|
+
];
|
|
41482
|
+
const detectAiTrainingEnvironment = () => {
|
|
41483
|
+
for (const [envVar, label] of AI_TRAINING_ENV_VARS) if (process.env[envVar]) return label;
|
|
41484
|
+
return null;
|
|
41485
|
+
};
|
|
41315
41486
|
const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
|
|
41316
41487
|
const mergeIgnores = (baseIgnore, overrideIgnore) => {
|
|
41317
41488
|
const mergedIgnore = {
|
|
@@ -41356,6 +41527,12 @@ const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
|
|
|
41356
41527
|
};
|
|
41357
41528
|
//#endregion
|
|
41358
41529
|
//#region ../api/dist/index.js
|
|
41530
|
+
let didWarnAiTraining = false;
|
|
41531
|
+
const warnIfAiTrainingEnvironment = () => {
|
|
41532
|
+
if (didWarnAiTraining || detectAiTrainingEnvironment() === null) return;
|
|
41533
|
+
didWarnAiTraining = true;
|
|
41534
|
+
console.warn("[react-doctor] Use in an AI or ML pipeline requires written permission under the react-doctor license. Contact founders@million.dev to request access.");
|
|
41535
|
+
};
|
|
41359
41536
|
const buildDiagnoseLayer = (config, configOverrideTarget) => {
|
|
41360
41537
|
const configLayer = configOverrideTarget === void 0 ? Config.layerNode : Config.layerOf({
|
|
41361
41538
|
config,
|
|
@@ -41393,6 +41570,7 @@ const outputToDiagnoseResult = (output, elapsedMilliseconds) => {
|
|
|
41393
41570
|
};
|
|
41394
41571
|
};
|
|
41395
41572
|
const diagnoseDirectory = async (directory, options) => {
|
|
41573
|
+
warnIfAiTrainingEnvironment();
|
|
41396
41574
|
const startTime = globalThis.performance.now();
|
|
41397
41575
|
const scanTarget = await resolveScanTarget(directory);
|
|
41398
41576
|
return outputToDiagnoseResult(await runPromise(restoreLegacyThrow(buildInspectProgram(scanTarget, options).pipe(provide(buildDiagnoseLayer(scanTarget.userConfig)), provide(layerOtlp)))), globalThis.performance.now() - startTime);
|
|
@@ -41439,6 +41617,7 @@ const diagnoseProject = async (projectDefinition, baseOptions, batchConfig) => {
|
|
|
41439
41617
|
}
|
|
41440
41618
|
};
|
|
41441
41619
|
const diagnoseProjectBatch = async (input) => {
|
|
41620
|
+
warnIfAiTrainingEnvironment();
|
|
41442
41621
|
const startTime = globalThis.performance.now();
|
|
41443
41622
|
const { projects, concurrency, config: batchConfig, ...baseOptions } = input;
|
|
41444
41623
|
const projectResults = await mapWithConcurrency(projects, concurrency ?? 4, (projectDefinition) => diagnoseProject(projectDefinition, baseOptions, batchConfig));
|
|
@@ -41483,4 +41662,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
41483
41662
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
41484
41663
|
|
|
41485
41664
|
//# sourceMappingURL=index.js.map
|
|
41486
|
-
//# debugId=
|
|
41665
|
+
//# debugId=0bd202f9-5e22-5625-86dc-458270afbcca
|