react-doctor 0.5.8-dev.441e6af → 0.5.8-dev.5639b1e
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/README.md +9 -3
- package/dist/cli.js +9263 -1441
- package/dist/index.d.ts +11 -2
- package/dist/index.js +216 -36
- package/dist/lsp.js +159 -37
- package/package.json +9 -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]="1e049c6a-27f7-5c62-8be8-57ce0b987f6f")}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",
|
|
@@ -39234,11 +39345,12 @@ const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
|
39234
39345
|
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
39235
39346
|
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
39236
39347
|
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
39348
|
+
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`.";
|
|
39237
39349
|
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
39238
|
-
const buildReactCompilerMessage = (reasonSummary) => {
|
|
39350
|
+
const buildReactCompilerMessage = (reasonSummary, action = REACT_COMPILER_ACTION) => {
|
|
39239
39351
|
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
39240
|
-
if (!normalizedSummary) return
|
|
39241
|
-
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${
|
|
39352
|
+
if (!normalizedSummary) return `${REACT_COMPILER_IMPACT}. ${action}`;
|
|
39353
|
+
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${action}`;
|
|
39242
39354
|
};
|
|
39243
39355
|
const PLUGIN_CATEGORY_MAP = {
|
|
39244
39356
|
react: "Bugs",
|
|
@@ -39287,7 +39399,7 @@ const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
|
39287
39399
|
const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
|
|
39288
39400
|
const reasonDetail = reasonDetailLines.join("\n").trim();
|
|
39289
39401
|
return {
|
|
39290
|
-
message: buildReactCompilerMessage(reasonSummary.trim()),
|
|
39402
|
+
message: buildReactCompilerMessage(reasonSummary.trim(), rule === "incompatible-library" ? REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION : REACT_COMPILER_ACTION),
|
|
39291
39403
|
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
39292
39404
|
};
|
|
39293
39405
|
}
|
|
@@ -40636,7 +40748,10 @@ const formatLintFailText = (reasonTag, nodeVersion) => {
|
|
|
40636
40748
|
* diagnostics).
|
|
40637
40749
|
* 2. beforeLint hook (e.g. CLI renders the project-detection block)
|
|
40638
40750
|
* 3. environment checks (reduced-motion + pnpm hardening +
|
|
40639
|
-
* expo/react-native
|
|
40751
|
+
* expo/react-native), collected synchronously. The heavier
|
|
40752
|
+
* content-regex security scan is forked instead (like supply-chain
|
|
40753
|
+
* below) and joined before the concat, so its CPU overlaps lint
|
|
40754
|
+
* rather than blocking the event loop before it.
|
|
40640
40755
|
* 4. The supply-chain check (Socket.dev) is forked onto a background
|
|
40641
40756
|
* fiber so its ~100% network-bound time overlaps the ~100%
|
|
40642
40757
|
* CPU/subprocess-bound lint pass below, collapsing two serial
|
|
@@ -40656,7 +40771,7 @@ const formatLintFailText = (reasonTag, nodeVersion) => {
|
|
|
40656
40771
|
* order, so terminal output is identical either way; supply-chain
|
|
40657
40772
|
* rides alongside without a spinner.
|
|
40658
40773
|
* 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
|
|
40774
|
+
* FIXED order (env, security-scan, supply-chain, lint, dead-code) so the output is
|
|
40660
40775
|
* byte-identical regardless of which fiber settled first. The
|
|
40661
40776
|
* viewer-permission fiber is joined later, during score-metadata
|
|
40662
40777
|
* assembly (it feeds score metadata, not diagnostics). The per-element
|
|
@@ -40717,12 +40832,12 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
40717
40832
|
...checkPnpmHardening(scanDirectory),
|
|
40718
40833
|
...checkReactServerComponentsAdvisory(scanDirectory, project),
|
|
40719
40834
|
...checkExpoProject(scanDirectory, project),
|
|
40720
|
-
...checkReactNativeProject(scanDirectory, project)
|
|
40721
|
-
...checkSecurityScan(scanDirectory, {
|
|
40722
|
-
project,
|
|
40723
|
-
ignoredTags: input.ignoredTags
|
|
40724
|
-
})
|
|
40835
|
+
...checkReactNativeProject(scanDirectory, project)
|
|
40725
40836
|
])));
|
|
40837
|
+
const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(promise(() => checkSecurityScanCooperative(scanDirectory, {
|
|
40838
|
+
project,
|
|
40839
|
+
ignoredTags: input.ignoredTags
|
|
40840
|
+
})).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)))))).pipe(withSpan("SecurityScan.run")));
|
|
40726
40841
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
40727
40842
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
40728
40843
|
const supplyChainFiber = yield* forkChild(shouldRunSupplyChain ? runCollect(applyPerElementPipeline(supplyChainService.run({
|
|
@@ -40858,9 +40973,11 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
40858
40973
|
else yield* scanProgress.succeed(`Scanned ${scannedFilesLabel} in ${scanElapsedSeconds}s${workerCountSuffix}`);
|
|
40859
40974
|
const supplyChainResult = yield* join(supplyChainFiber);
|
|
40860
40975
|
const supplyChainCollected = supplyChainResult.diagnostics;
|
|
40976
|
+
const securityScanCollected = yield* join(securityScanFiber);
|
|
40861
40977
|
yield* reporterService.finalize;
|
|
40862
40978
|
const finalDiagnostics = sortDiagnosticsStable(assignFixGroups([
|
|
40863
40979
|
...envCollected,
|
|
40980
|
+
...securityScanCollected,
|
|
40864
40981
|
...supplyChainCollected,
|
|
40865
40982
|
...lintCollected,
|
|
40866
40983
|
...deadCodeCollected
|
|
@@ -41312,6 +41429,61 @@ const clearAutoSuppressionCaches = () => {};
|
|
|
41312
41429
|
* untouched so the loader sees the same plain object either way.
|
|
41313
41430
|
*/
|
|
41314
41431
|
const defineConfig = (config) => config;
|
|
41432
|
+
const AI_TRAINING_ENV_VARS = [
|
|
41433
|
+
["HF_DATASETS_CACHE", "huggingface"],
|
|
41434
|
+
["HF_HOME", "huggingface"],
|
|
41435
|
+
["HUGGINGFACE_HUB_CACHE", "huggingface"],
|
|
41436
|
+
["SPACE_ID", "huggingface-spaces"],
|
|
41437
|
+
["CUDA_VISIBLE_DEVICES", "cuda"],
|
|
41438
|
+
["NVIDIA_VISIBLE_DEVICES", "nvidia"],
|
|
41439
|
+
["ROCR_VISIBLE_DEVICES", "rocm"],
|
|
41440
|
+
["TPU_NAME", "google-tpu"],
|
|
41441
|
+
["WANDB_RUN_ID", "wandb"],
|
|
41442
|
+
["WANDB_SWEEP_ID", "wandb"],
|
|
41443
|
+
["MLFLOW_RUN_ID", "mlflow"],
|
|
41444
|
+
["MLFLOW_TRACKING_URI", "mlflow"],
|
|
41445
|
+
["COMET_EXPERIMENT_KEY", "comet"],
|
|
41446
|
+
["NEPTUNE_RUN_ID", "neptune"],
|
|
41447
|
+
["CLEARML_TASK_ID", "clearml"],
|
|
41448
|
+
["DVC_STAGE", "dvc"],
|
|
41449
|
+
["RAY_WORKER_PROCESS", "ray"],
|
|
41450
|
+
["RAY_ADDRESS", "ray"],
|
|
41451
|
+
["MUJOCO_GL", "mujoco"],
|
|
41452
|
+
["MUJOCO_PATH", "mujoco"],
|
|
41453
|
+
["GYM_DISABLE_ENV_CHECKER", "gymnasium"],
|
|
41454
|
+
["SM_TRAINING_ENV", "sagemaker"],
|
|
41455
|
+
["TRAINING_JOB_ARN", "sagemaker"],
|
|
41456
|
+
["SAGEMAKER_BASE_DIR", "sagemaker"],
|
|
41457
|
+
["AZUREML_RUN_ID", "azure-ml"],
|
|
41458
|
+
["AZURE_ML_MODEL_DIR", "azure-ml"],
|
|
41459
|
+
["CLOUD_ML_PROJECT_ID", "vertex-ai"],
|
|
41460
|
+
["VERTEX_AI_LOG_LEVEL", "vertex-ai"],
|
|
41461
|
+
["DET_MASTER", "determined-ai"],
|
|
41462
|
+
["LIGHTNING_USER_ID", "lightning-ai"],
|
|
41463
|
+
["FLYTE_INTERNAL_EXECUTION_ID", "flyte"],
|
|
41464
|
+
["ARGO_WORKFLOW_NAME", "argo-workflows"],
|
|
41465
|
+
["KFP_POD_NAME", "kubeflow-pipelines"],
|
|
41466
|
+
["KAGGLE_KERNEL_RUN_TYPE", "kaggle"],
|
|
41467
|
+
["COLAB_BACKEND_VERSION", "google-colab"],
|
|
41468
|
+
["DATABRICKS_RUNTIME_VERSION", "databricks"],
|
|
41469
|
+
["DAYTONA_WS_ID", "daytona"],
|
|
41470
|
+
["DAYTONA_WS_NAME", "daytona"],
|
|
41471
|
+
["E2B_SANDBOX_ID", "e2b"],
|
|
41472
|
+
["MODAL_FUNCTION_ID", "modal"],
|
|
41473
|
+
["MODAL_TASK_ID", "modal"],
|
|
41474
|
+
["RUNPOD_POD_ID", "runpod"],
|
|
41475
|
+
["REPLICATE_USERNAME", "replicate"],
|
|
41476
|
+
["VAST_CONTAINERLABEL", "vast-ai"],
|
|
41477
|
+
["HARBOR_URL", "harbor"],
|
|
41478
|
+
["HARBOR_HOSTNAME", "harbor"],
|
|
41479
|
+
["SWE_BENCH_TASK", "swe-bench"],
|
|
41480
|
+
["SWEBENCH_TASK", "swe-bench"],
|
|
41481
|
+
["SWE_AGENT_MODEL", "swe-agent"]
|
|
41482
|
+
];
|
|
41483
|
+
const detectAiTrainingEnvironment = () => {
|
|
41484
|
+
for (const [envVar, label] of AI_TRAINING_ENV_VARS) if (process.env[envVar]) return label;
|
|
41485
|
+
return null;
|
|
41486
|
+
};
|
|
41315
41487
|
const unionValues = (baseValues, overrideValues) => [...new Set([...baseValues, ...overrideValues])];
|
|
41316
41488
|
const mergeIgnores = (baseIgnore, overrideIgnore) => {
|
|
41317
41489
|
const mergedIgnore = {
|
|
@@ -41356,6 +41528,12 @@ const mergeReactDoctorConfigs = (baseConfig, overrideConfig) => {
|
|
|
41356
41528
|
};
|
|
41357
41529
|
//#endregion
|
|
41358
41530
|
//#region ../api/dist/index.js
|
|
41531
|
+
let didWarnAiTraining = false;
|
|
41532
|
+
const warnIfAiTrainingEnvironment = () => {
|
|
41533
|
+
if (didWarnAiTraining || detectAiTrainingEnvironment() === null) return;
|
|
41534
|
+
didWarnAiTraining = true;
|
|
41535
|
+
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.");
|
|
41536
|
+
};
|
|
41359
41537
|
const buildDiagnoseLayer = (config, configOverrideTarget) => {
|
|
41360
41538
|
const configLayer = configOverrideTarget === void 0 ? Config.layerNode : Config.layerOf({
|
|
41361
41539
|
config,
|
|
@@ -41393,6 +41571,7 @@ const outputToDiagnoseResult = (output, elapsedMilliseconds) => {
|
|
|
41393
41571
|
};
|
|
41394
41572
|
};
|
|
41395
41573
|
const diagnoseDirectory = async (directory, options) => {
|
|
41574
|
+
warnIfAiTrainingEnvironment();
|
|
41396
41575
|
const startTime = globalThis.performance.now();
|
|
41397
41576
|
const scanTarget = await resolveScanTarget(directory);
|
|
41398
41577
|
return outputToDiagnoseResult(await runPromise(restoreLegacyThrow(buildInspectProgram(scanTarget, options).pipe(provide(buildDiagnoseLayer(scanTarget.userConfig)), provide(layerOtlp)))), globalThis.performance.now() - startTime);
|
|
@@ -41439,6 +41618,7 @@ const diagnoseProject = async (projectDefinition, baseOptions, batchConfig) => {
|
|
|
41439
41618
|
}
|
|
41440
41619
|
};
|
|
41441
41620
|
const diagnoseProjectBatch = async (input) => {
|
|
41621
|
+
warnIfAiTrainingEnvironment();
|
|
41442
41622
|
const startTime = globalThis.performance.now();
|
|
41443
41623
|
const { projects, concurrency, config: batchConfig, ...baseOptions } = input;
|
|
41444
41624
|
const projectResults = await mapWithConcurrency(projects, concurrency ?? 4, (projectDefinition) => diagnoseProject(projectDefinition, baseOptions, batchConfig));
|
|
@@ -41483,4 +41663,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
41483
41663
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
41484
41664
|
|
|
41485
41665
|
//# sourceMappingURL=index.js.map
|
|
41486
|
-
//# debugId=
|
|
41666
|
+
//# debugId=1e049c6a-27f7-5c62-8be8-57ce0b987f6f
|