react-doctor 0.5.8-dev.229ea2e → 0.5.8-dev.2af7322
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 +9635 -1605
- package/dist/index.d.ts +15 -2
- package/dist/index.js +354 -117
- package/dist/lsp.js +299 -118
- package/package.json +10 -8
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
|
/**
|
|
@@ -33731,6 +33731,9 @@ 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
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;
|
|
33734
33737
|
const PER_WORKER_MEM_BUDGET_BYTES = 1024 * 1024 * 1024;
|
|
33735
33738
|
const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
|
|
33736
33739
|
const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
|
|
@@ -33811,6 +33814,7 @@ const DEAD_CODE_PHASE_TIMEOUT_MS = 15e4;
|
|
|
33811
33814
|
const LINT_PHASE_TIMEOUT_MS = 3e5;
|
|
33812
33815
|
const SCAN_TOTAL_DEADLINE_MS = 9e5;
|
|
33813
33816
|
const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
|
|
33817
|
+
const DEAD_CODE_WORKER_MEM_BUDGET_BYTES = 2 * 1024 * 1024 * 1024;
|
|
33814
33818
|
const DEAD_CODE_TIMEOUT_CEILING_MS = 6e5;
|
|
33815
33819
|
const DEAD_CODE_PHASE_TIMEOUT_OVER_WORKER_MS = 3e4;
|
|
33816
33820
|
const DEAD_CODE_OVERLAP_PARSE_SHARE = .4;
|
|
@@ -34577,7 +34581,7 @@ const tokenizeRuleList = (ruleList) => {
|
|
|
34577
34581
|
const FOREIGN_INLINE_DISABLE_PATTERN = /(?:\/\/|\/\*)[ \t]*(eslint|oxlint)-disable-(next-line|line)(?![\w-])([^\r\n]*)/;
|
|
34578
34582
|
const FOREIGN_BLOCK_DISABLE_PATTERN = /\/\*[ \t]*(eslint|oxlint)-disable(?![\w-])([^*\r\n]*)/;
|
|
34579
34583
|
const FOREIGN_BLOCK_ENABLE_PATTERN = /\/\*[ \t]*(?:eslint|oxlint)-enable(?![\w-])([^*\r\n]*)/;
|
|
34580
|
-
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}\` —
|
|
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}\`).`;
|
|
34581
34585
|
const tokenMisnamesRule = (token, ruleId) => token !== ruleId && isSameRuleKey(token, ruleId);
|
|
34582
34586
|
const detectInlineNearMiss = (lines, diagnosticLineIndex, ruleId) => {
|
|
34583
34587
|
const candidates = [{
|
|
@@ -35053,6 +35057,7 @@ const collectStringSet = (values) => {
|
|
|
35053
35057
|
if (!Array.isArray(values)) return /* @__PURE__ */ new Set();
|
|
35054
35058
|
return new Set(values.filter((value) => typeof value === "string"));
|
|
35055
35059
|
};
|
|
35060
|
+
const JSX_NO_UNDEF_IDENTIFIER_PATTERN = /^`([^`]+)`/;
|
|
35056
35061
|
/**
|
|
35057
35062
|
* Pre-compiles every stateful filter and returns a single
|
|
35058
35063
|
* `apply(diagnostic)` closure that runs (in order):
|
|
@@ -35086,11 +35091,28 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
35086
35091
|
const compiledOverrides = compileIgnoreOverrides(userConfig);
|
|
35087
35092
|
const textComponentNames = collectStringSet(userConfig?.textComponents);
|
|
35088
35093
|
const rawTextWrapperComponentNames = collectStringSet(userConfig?.rawTextWrapperComponents);
|
|
35094
|
+
const runtimeGlobalNames = collectStringSet(userConfig?.runtimeGlobals);
|
|
35089
35095
|
const hasTextComponents = textComponentNames.size > 0;
|
|
35090
35096
|
const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
|
|
35097
|
+
const hasRuntimeGlobals = runtimeGlobalNames.size > 0;
|
|
35091
35098
|
const fileLinesCache = /* @__PURE__ */ new Map();
|
|
35092
35099
|
const fileContextCache = /* @__PURE__ */ new Map();
|
|
35093
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
|
+
};
|
|
35094
35116
|
const isLibraryFile = (filePath) => {
|
|
35095
35117
|
let cached = libraryFileCache.get(filePath);
|
|
35096
35118
|
if (cached === void 0) {
|
|
@@ -35139,50 +35161,60 @@ const buildDiagnosticPipeline = (input) => {
|
|
|
35139
35161
|
if (hasRawTextWrappers && isInsideStringOnlyWrapper(lines, diagnostic.line, diagnostic.column, rawTextWrapperComponentNames)) return true;
|
|
35140
35162
|
return false;
|
|
35141
35163
|
};
|
|
35142
|
-
|
|
35143
|
-
if (
|
|
35144
|
-
|
|
35145
|
-
|
|
35146
|
-
|
|
35147
|
-
|
|
35148
|
-
|
|
35149
|
-
|
|
35150
|
-
|
|
35151
|
-
|
|
35152
|
-
|
|
35153
|
-
|
|
35154
|
-
if (
|
|
35155
|
-
|
|
35156
|
-
|
|
35157
|
-
|
|
35158
|
-
|
|
35159
|
-
|
|
35160
|
-
|
|
35161
|
-
|
|
35162
|
-
|
|
35163
|
-
if (isFileIgnoredByPatterns(current.filePath, rootDirectory, ignoredFilePatterns)) return null;
|
|
35164
|
-
if (isDiagnosticIgnoredByOverrides(current, rootDirectory, compiledOverrides)) return null;
|
|
35165
|
-
if (isRnRawTextSuppressedByConfig(current)) return null;
|
|
35166
|
-
}
|
|
35167
|
-
if (respectInlineDisables && current.line > 0) {
|
|
35168
|
-
const lines = getFileLines(current.filePath);
|
|
35169
|
-
if (lines) {
|
|
35170
|
-
const ruleIdentifier = `${current.plugin}/${current.rule}`;
|
|
35171
|
-
const evaluation = evaluateSuppression(lines, current.line - 1, ruleIdentifier);
|
|
35172
|
-
if (evaluation.isSuppressed) return null;
|
|
35173
|
-
if (evaluation.nearMissHint) current = {
|
|
35174
|
-
...current,
|
|
35175
|
-
suppressionHint: evaluation.nearMissHint
|
|
35176
|
-
};
|
|
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);
|
|
35177
35185
|
}
|
|
35178
|
-
|
|
35179
|
-
|
|
35180
|
-
|
|
35181
|
-
|
|
35182
|
-
|
|
35183
|
-
|
|
35184
|
-
|
|
35185
|
-
|
|
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
|
+
};
|
|
35186
35218
|
};
|
|
35187
35219
|
const OxlintUnavailableKind = Literals(["binary-not-found", "native-binding-missing"]);
|
|
35188
35220
|
var OxlintUnavailable = class extends TaggedErrorClass()("OxlintUnavailable", {
|
|
@@ -35402,7 +35434,7 @@ const resolveScanConcurrency = (requested) => {
|
|
|
35402
35434
|
if (!Number.isFinite(requested) || requested < 1) return 1;
|
|
35403
35435
|
return Math.min(Math.floor(requested), 32);
|
|
35404
35436
|
};
|
|
35405
|
-
const readSystemFacts = () => ({
|
|
35437
|
+
const readSystemFacts$1 = () => ({
|
|
35406
35438
|
availableCores: os.availableParallelism(),
|
|
35407
35439
|
totalMemoryBytes: os.totalmem(),
|
|
35408
35440
|
cgroupMemoryLimitBytes: readCgroupMemoryLimitBytes()
|
|
@@ -35423,7 +35455,7 @@ const readSystemFacts = () => ({
|
|
|
35423
35455
|
* `facts` is injectable so tests exercise core-bound, memory-bound, cgroup-
|
|
35424
35456
|
* limited, and ceiling cases without mocking `os` or the filesystem.
|
|
35425
35457
|
*/
|
|
35426
|
-
const resolveAutoScanConcurrency = (facts = readSystemFacts()) => {
|
|
35458
|
+
const resolveAutoScanConcurrency = (facts = readSystemFacts$1()) => {
|
|
35427
35459
|
const availableMemoryBytes = Math.min(facts.totalMemoryBytes, facts.cgroupMemoryLimitBytes ?? Number.POSITIVE_INFINITY);
|
|
35428
35460
|
const memoryBoundedWorkers = Math.floor(availableMemoryBytes / PER_WORKER_MEM_BUDGET_BYTES);
|
|
35429
35461
|
return resolveScanConcurrency(Math.min(facts.availableCores, memoryBoundedWorkers));
|
|
@@ -35464,13 +35496,7 @@ var ScanDeadlineMs = class extends Reference("react-doctor/ScanDeadlineMs", { de
|
|
|
35464
35496
|
* without recompiling react-doctor. Tests override via
|
|
35465
35497
|
* `Layer.succeed(SupplyChainOverlapTimeoutMs, ...)`.
|
|
35466
35498
|
*/
|
|
35467
|
-
var SupplyChainOverlapTimeoutMs = class extends Reference("react-doctor/SupplyChainOverlapTimeoutMs", { defaultValue: () => {
|
|
35468
|
-
const raw = process.env["REACT_DOCTOR_SUPPLY_CHAIN_TIMEOUT_MS"];
|
|
35469
|
-
if (raw === void 0) return SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS;
|
|
35470
|
-
const parsed = Number(raw);
|
|
35471
|
-
if (!Number.isFinite(parsed) || parsed <= 0) return SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS;
|
|
35472
|
-
return parsed;
|
|
35473
|
-
} }) {};
|
|
35499
|
+
var SupplyChainOverlapTimeoutMs = class extends Reference("react-doctor/SupplyChainOverlapTimeoutMs", { defaultValue: () => readPositiveEnvMs("REACT_DOCTOR_SUPPLY_CHAIN_TIMEOUT_MS", SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS) }) {};
|
|
35474
35500
|
/**
|
|
35475
35501
|
* Hard cap on combined stdout+stderr bytes per oxlint batch. The
|
|
35476
35502
|
* subprocess gets SIGKILL'd if it produces more; the recovery path
|
|
@@ -35618,6 +35644,7 @@ const STRING_ARRAY_FIELD_NAMES = [
|
|
|
35618
35644
|
"projects",
|
|
35619
35645
|
"textComponents",
|
|
35620
35646
|
"rawTextWrapperComponents",
|
|
35647
|
+
"runtimeGlobals",
|
|
35621
35648
|
"serverAuthFunctionNames"
|
|
35622
35649
|
];
|
|
35623
35650
|
const SURFACE_CONTROL_FIELD_NAMES = [
|
|
@@ -36908,7 +36935,10 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledBy)
|
|
|
36908
36935
|
}
|
|
36909
36936
|
return true;
|
|
36910
36937
|
};
|
|
36911
|
-
const
|
|
36938
|
+
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
36939
|
+
setImmediate(resolve);
|
|
36940
|
+
});
|
|
36941
|
+
const createSecurityScanSession = (rootDirectory, options) => {
|
|
36912
36942
|
const capabilities = options.project ? buildCapabilities(options.project) : /* @__PURE__ */ new Set();
|
|
36913
36943
|
const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
|
|
36914
36944
|
const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
|
|
@@ -36923,7 +36953,7 @@ const checkSecurityScan = (rootDirectory, options = {}) => {
|
|
|
36923
36953
|
committedFilesOnly: rule.committedFilesOnly === true
|
|
36924
36954
|
}];
|
|
36925
36955
|
});
|
|
36926
|
-
if (enabledScanRules.length === 0) return
|
|
36956
|
+
if (enabledScanRules.length === 0) return null;
|
|
36927
36957
|
const diagnostics = [];
|
|
36928
36958
|
const seen = /* @__PURE__ */ new Set();
|
|
36929
36959
|
const gitIgnoredCache = /* @__PURE__ */ new Map();
|
|
@@ -36935,15 +36965,34 @@ const checkSecurityScan = (rootDirectory, options = {}) => {
|
|
|
36935
36965
|
}
|
|
36936
36966
|
return status === true;
|
|
36937
36967
|
};
|
|
36938
|
-
|
|
36939
|
-
|
|
36940
|
-
|
|
36941
|
-
|
|
36942
|
-
|
|
36943
|
-
|
|
36944
|
-
|
|
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
|
+
}
|
|
36945
36994
|
}
|
|
36946
|
-
return diagnostics;
|
|
36995
|
+
return session.diagnostics;
|
|
36947
36996
|
};
|
|
36948
36997
|
var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
36949
36998
|
let p = process || {}, argv = p.argv || [], env = p.env || {};
|
|
@@ -37160,6 +37209,74 @@ const collectDeadCodeIgnorePatterns = (rootDirectory) => {
|
|
|
37160
37209
|
return [...seen].filter((pattern) => pattern.length > 0);
|
|
37161
37210
|
};
|
|
37162
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
|
+
};
|
|
37163
37280
|
/**
|
|
37164
37281
|
* Resolves a path to its canonical, symlink-free form, falling back to
|
|
37165
37282
|
* the input when it cannot be realpath'd (broken symlink, permission
|
|
@@ -37184,6 +37301,11 @@ const toCanonicalPath = (filePath) => {
|
|
|
37184
37301
|
};
|
|
37185
37302
|
const DEAD_CODE_PLUGIN = "deslop";
|
|
37186
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
|
+
]);
|
|
37187
37309
|
const DEAD_CODE_WORKER_SCRIPT = `
|
|
37188
37310
|
const inputChunks = [];
|
|
37189
37311
|
process.stdin.on("data", (chunk) => inputChunks.push(chunk));
|
|
@@ -37450,14 +37572,17 @@ const checkDeadCode = async (options) => {
|
|
|
37450
37572
|
if (!NFS.existsSync(Path.join(rootDirectory, "package.json"))) return [];
|
|
37451
37573
|
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
37452
37574
|
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
37453
|
-
const
|
|
37454
|
-
|
|
37455
|
-
|
|
37456
|
-
|
|
37457
|
-
|
|
37458
|
-
|
|
37459
|
-
|
|
37460
|
-
|
|
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());
|
|
37461
37586
|
const toRelative = (filePath) => toRelativeFilePath(rootDirectory, filePath);
|
|
37462
37587
|
const diagnostics = [];
|
|
37463
37588
|
for (const unusedFile of result.unusedFiles) diagnostics.push({
|
|
@@ -37486,6 +37611,7 @@ const checkDeadCode = async (options) => {
|
|
|
37486
37611
|
});
|
|
37487
37612
|
}
|
|
37488
37613
|
for (const unusedDependency of result.unusedDependencies) {
|
|
37614
|
+
if (REACT_DOCTOR_TOOLCHAIN_PACKAGES.has(unusedDependency.name)) continue;
|
|
37489
37615
|
const label = unusedDependency.isDevDependency ? "devDependency" : "dependency";
|
|
37490
37616
|
diagnostics.push({
|
|
37491
37617
|
filePath: "package.json",
|
|
@@ -37664,7 +37790,6 @@ var DeadCode = class DeadCode extends Service()("react-doctor/DeadCode") {
|
|
|
37664
37790
|
return yield* tryPromise({
|
|
37665
37791
|
try: (signal) => checkDeadCode({
|
|
37666
37792
|
rootDirectory: input.rootDirectory,
|
|
37667
|
-
userConfig: input.userConfig,
|
|
37668
37793
|
parseConcurrency: input.parseConcurrency,
|
|
37669
37794
|
workerTimeoutMs: input.workerTimeoutMs,
|
|
37670
37795
|
abortSignal: signal
|
|
@@ -37787,6 +37912,11 @@ const isSafeGitRevision = (candidate) => {
|
|
|
37787
37912
|
if (candidate.includes("..") || candidate.includes("@{")) return false;
|
|
37788
37913
|
return SAFE_GIT_REVISION_PATTERN.test(candidate);
|
|
37789
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
|
+
};
|
|
37790
37920
|
/**
|
|
37791
37921
|
* Splits a git revision range into its endpoints: three-dot `A...B`
|
|
37792
37922
|
* (symmetric, merge-base) or two-dot `A..B` (direct). Returns `null`
|
|
@@ -37871,7 +38001,8 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
37871
38001
|
return scoped(gen(function* () {
|
|
37872
38002
|
if (!isDirectory(input.directory)) return yield* foldSpawnFailure(`spawn ENOTDIR (cwd is not a directory: ${input.directory})`);
|
|
37873
38003
|
const argvLengthChars = input.command.length + 1 + input.args.reduce((total, arg) => total + arg.length + 1, 0);
|
|
37874
|
-
|
|
38004
|
+
const spawnArgsLengthCap = resolveSpawnArgsLengthCap();
|
|
38005
|
+
if (argvLengthChars > spawnArgsLengthCap) return yield* foldSpawnFailure(`spawn ENAMETOOLONG (${argvLengthChars} argv chars exceed ${spawnArgsLengthCap})`);
|
|
37875
38006
|
const handle = yield* spawner.spawn(make$1(input.command, [...input.args], {
|
|
37876
38007
|
cwd: input.directory,
|
|
37877
38008
|
env: input.env,
|
|
@@ -38040,6 +38171,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
38040
38171
|
if (resolvedCurrentBranch === null && explicitBaseBranch === void 0) return null;
|
|
38041
38172
|
const baseBranch = explicitBaseBranch ?? (yield* defaultBranch(directory));
|
|
38042
38173
|
if (baseBranch === null) return null;
|
|
38174
|
+
if (!isSafeGitRevision(baseBranch)) return null;
|
|
38043
38175
|
if (explicitBaseBranch !== void 0) {
|
|
38044
38176
|
if (!(yield* branchExists(directory, explicitBaseBranch))) return yield* fail$4(new ReactDoctorError({ reason: new GitBaseBranchMissing({ branch: explicitBaseBranch }) }));
|
|
38045
38177
|
}
|
|
@@ -38390,7 +38522,7 @@ const normalizeConfigForHash = (config) => {
|
|
|
38390
38522
|
if (Array.isArray(clone?.jsPlugins)) clone.jsPlugins = clone.jsPlugins.map((_, index) => `<plugin:${index}>`);
|
|
38391
38523
|
return clone;
|
|
38392
38524
|
};
|
|
38393
|
-
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("
|
|
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");
|
|
38394
38526
|
/**
|
|
38395
38527
|
* Loads a plugin module via the local require resolver and extracts
|
|
38396
38528
|
* `(name, ruleNames)` from either `module.exports.meta + rules` or
|
|
@@ -38561,12 +38693,12 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
38561
38693
|
if (customRulesOnly && registryEntry.originallyExternal) continue;
|
|
38562
38694
|
if (rule.framework !== "global" && !rule.requires) continue;
|
|
38563
38695
|
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledBy)) continue;
|
|
38564
|
-
const
|
|
38696
|
+
const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
|
|
38697
|
+
if (rule.defaultEnabled === false && explicitRuleOverride === void 0) continue;
|
|
38698
|
+
const severity = resolveRuleSeverityOverride({
|
|
38565
38699
|
ruleKey: registryEntry.key,
|
|
38566
38700
|
category: rule.category
|
|
38567
|
-
}, severityControls);
|
|
38568
|
-
if (rule.defaultEnabled === false && explicitSeverity === void 0) continue;
|
|
38569
|
-
const severity = explicitSeverity ?? resolveCompilerCleanupBucketSeverity(registryEntry.key, severityControls) ?? rule.severity;
|
|
38701
|
+
}, severityControls) ?? resolveCompilerCleanupBucketSeverity(registryEntry.key, severityControls) ?? rule.severity;
|
|
38570
38702
|
if (severity === "off") continue;
|
|
38571
38703
|
enabledReactDoctorRules[registryEntry.key] = severity;
|
|
38572
38704
|
}
|
|
@@ -38668,24 +38800,38 @@ const createFileLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
38668
38800
|
updatedAtMs: Date.now(),
|
|
38669
38801
|
files: Object.fromEntries(cappedEntries)
|
|
38670
38802
|
};
|
|
38671
|
-
const keptHashes = Object.entries(rulesets).sort(([, first], [, second]) => second.updatedAtMs - first.updatedAtMs).slice(0, 8).map(([hash]) => hash);
|
|
38672
|
-
const prunedRulesets = {};
|
|
38673
|
-
for (const hash of keptHashes) prunedRulesets[hash] = rulesets[hash];
|
|
38674
38803
|
atomicWriteJson(cacheFilePath, {
|
|
38675
38804
|
version: 1,
|
|
38676
|
-
rulesets:
|
|
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))
|
|
38677
38806
|
});
|
|
38678
38807
|
}
|
|
38679
38808
|
};
|
|
38680
38809
|
};
|
|
38681
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
|
+
};
|
|
38682
38828
|
const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
38683
38829
|
"oxlint/package.json",
|
|
38684
38830
|
"oxlint-plugin-react-doctor/package.json",
|
|
38685
38831
|
"eslint-plugin-react-hooks/package.json"
|
|
38686
38832
|
];
|
|
38687
|
-
const resolveOxlintToolchainVersions = () => {
|
|
38688
|
-
const versions = [`node=${
|
|
38833
|
+
const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
38834
|
+
const versions = [`node=${resolveChildNodeVersion(nodeBinaryPath)}`];
|
|
38689
38835
|
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
38690
38836
|
const packageJson = bundledRequire(specifier);
|
|
38691
38837
|
const version = typeof packageJson.version === "string" ? packageJson.version : "unknown";
|
|
@@ -39219,11 +39365,12 @@ const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
|
|
|
39219
39365
|
const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
|
|
39220
39366
|
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
39221
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`.";
|
|
39222
39369
|
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
39223
|
-
const buildReactCompilerMessage = (reasonSummary) => {
|
|
39370
|
+
const buildReactCompilerMessage = (reasonSummary, action = REACT_COMPILER_ACTION) => {
|
|
39224
39371
|
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
39225
|
-
if (!normalizedSummary) return
|
|
39226
|
-
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${
|
|
39372
|
+
if (!normalizedSummary) return `${REACT_COMPILER_IMPACT}. ${action}`;
|
|
39373
|
+
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${action}`;
|
|
39227
39374
|
};
|
|
39228
39375
|
const PLUGIN_CATEGORY_MAP = {
|
|
39229
39376
|
react: "Bugs",
|
|
@@ -39272,7 +39419,7 @@ const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
|
39272
39419
|
const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
|
|
39273
39420
|
const reasonDetail = reasonDetailLines.join("\n").trim();
|
|
39274
39421
|
return {
|
|
39275
|
-
message: buildReactCompilerMessage(reasonSummary.trim()),
|
|
39422
|
+
message: buildReactCompilerMessage(reasonSummary.trim(), rule === "incompatible-library" ? REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION : REACT_COMPILER_ACTION),
|
|
39276
39423
|
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
39277
39424
|
};
|
|
39278
39425
|
}
|
|
@@ -39540,21 +39687,27 @@ const spawnLintBatches = async (input) => {
|
|
|
39540
39687
|
const allDiagnostics = [];
|
|
39541
39688
|
const droppedFiles = [];
|
|
39542
39689
|
let firstDropReason = null;
|
|
39543
|
-
const
|
|
39544
|
-
const spawnLintBatch = async (batch, depth) => {
|
|
39690
|
+
const spawnLintBatch = async (batch, depth, splitBudget) => {
|
|
39545
39691
|
const batchArgs = [...baseArgs, ...batch];
|
|
39546
39692
|
try {
|
|
39547
39693
|
return parseOxlintOutput(await spawnOxlint(batchArgs, rootDirectory, nodeBinaryPath, spawnTimeoutMs, outputMaxBytes, signal), project, rootDirectory);
|
|
39548
39694
|
} catch (error) {
|
|
39549
39695
|
if (!isSplittableReactDoctorError(error)) throw error;
|
|
39550
|
-
|
|
39551
|
-
|
|
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) {
|
|
39552
39700
|
droppedFiles.push(...batch);
|
|
39553
|
-
if (firstDropReason === null)
|
|
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
|
+
}
|
|
39554
39707
|
return [];
|
|
39555
39708
|
}
|
|
39556
39709
|
const splitIndex = Math.ceil(batch.length / 2);
|
|
39557
|
-
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)];
|
|
39558
39711
|
}
|
|
39559
39712
|
};
|
|
39560
39713
|
let startedFileCount = 0;
|
|
@@ -39571,7 +39724,7 @@ const spawnLintBatches = async (input) => {
|
|
|
39571
39724
|
try {
|
|
39572
39725
|
const batchResults = await mapWithConcurrency(fileBatches, concurrency, async (batch) => {
|
|
39573
39726
|
startedFileCount += batch.length;
|
|
39574
|
-
const batchDiagnostics = await spawnLintBatch(batch, 0);
|
|
39727
|
+
const batchDiagnostics = await spawnLintBatch(batch, 0, { deadlineMs: null });
|
|
39575
39728
|
scannedFileCount += batch.length;
|
|
39576
39729
|
if (onFileProgress) {
|
|
39577
39730
|
displayedFileCount = Math.min(Math.max(displayedFileCount, scannedFileCount), totalFileCount);
|
|
@@ -39645,7 +39798,14 @@ const resolveReactDoctorCacheDir = (projectDirectory) => {
|
|
|
39645
39798
|
if (cacheDirOverride) return Path.join(cacheDirOverride, projectCacheSubdir(projectDirectory));
|
|
39646
39799
|
const nodeModulesDirectory = Path.join(projectDirectory, "node_modules");
|
|
39647
39800
|
if (NFS.existsSync(nodeModulesDirectory)) return Path.join(nodeModulesDirectory, ".cache", "react-doctor");
|
|
39648
|
-
return Path.join(os.tmpdir(),
|
|
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
|
+
}
|
|
39649
39809
|
};
|
|
39650
39810
|
const sortSourceFilesByCost = (entries) => [...entries].sort((left, right) => right.sizeBytes - left.sizeBytes).map((entry) => entry.path);
|
|
39651
39811
|
/**
|
|
@@ -39813,7 +39973,7 @@ const runOxlint = async (options) => {
|
|
|
39813
39973
|
extendsPaths: [],
|
|
39814
39974
|
ruleSelection: "cacheable"
|
|
39815
39975
|
}),
|
|
39816
|
-
toolchainVersions: resolveOxlintToolchainVersions(),
|
|
39976
|
+
toolchainVersions: resolveOxlintToolchainVersions(nodeBinaryPath),
|
|
39817
39977
|
ignorePatterns: combinedPatterns,
|
|
39818
39978
|
tsconfigContent
|
|
39819
39979
|
});
|
|
@@ -39827,7 +39987,7 @@ const runOxlint = async (options) => {
|
|
|
39827
39987
|
missFiles.push(candidateFile);
|
|
39828
39988
|
continue;
|
|
39829
39989
|
}
|
|
39830
|
-
const cacheKey = `${candidateFile.replaceAll("\\", "/")}
|
|
39990
|
+
const cacheKey = `${candidateFile.replaceAll("\\", "/")}\u0000${contentHash}`;
|
|
39831
39991
|
cacheKeyByFile.set(candidateFile, cacheKey);
|
|
39832
39992
|
const cachedDiagnostics = cache.lookup(cacheKey);
|
|
39833
39993
|
if (cachedDiagnostics === null) missFiles.push(candidateFile);
|
|
@@ -40143,7 +40303,7 @@ const ScoreApiResponseSchema = Struct({
|
|
|
40143
40303
|
})))
|
|
40144
40304
|
});
|
|
40145
40305
|
const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
|
|
40146
|
-
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);
|
|
40147
40307
|
const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
40148
40308
|
const describeFailure = (error) => {
|
|
40149
40309
|
if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
|
|
@@ -40447,7 +40607,10 @@ const ALERT_SEVERITY_RANK = {
|
|
|
40447
40607
|
medium: 2,
|
|
40448
40608
|
low: 1
|
|
40449
40609
|
};
|
|
40450
|
-
const severityRank = (severity) =>
|
|
40610
|
+
const severityRank = (severity) => {
|
|
40611
|
+
const normalized = severity.toLowerCase();
|
|
40612
|
+
return Object.hasOwn(ALERT_SEVERITY_RANK, normalized) ? ALERT_SEVERITY_RANK[normalized] : 0;
|
|
40613
|
+
};
|
|
40451
40614
|
const displaySeverity = (severity) => {
|
|
40452
40615
|
const normalized = sanitizeTerminalText(severity.toLowerCase());
|
|
40453
40616
|
return normalized === "middle" ? "medium" : normalized;
|
|
@@ -40464,7 +40627,7 @@ const ALERT_TYPE_LABELS = {
|
|
|
40464
40627
|
typosquat: "possible typosquat"
|
|
40465
40628
|
};
|
|
40466
40629
|
const humanizeAlertType = (type) => type.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").toLowerCase().trim();
|
|
40467
|
-
const friendlyAlertType = (type) => ALERT_TYPE_LABELS[type]
|
|
40630
|
+
const friendlyAlertType = (type) => Object.hasOwn(ALERT_TYPE_LABELS, type) ? ALERT_TYPE_LABELS[type] : sanitizeTerminalText(humanizeAlertType(type));
|
|
40468
40631
|
const summarizeAlertNote = (note) => {
|
|
40469
40632
|
const collapsed = sanitizeTerminalText(note.replace(/\s+/g, " ").trim());
|
|
40470
40633
|
const firstSentence = collapsed.split(/(?<=\.)\s/)[0] || collapsed;
|
|
@@ -40559,7 +40722,10 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
40559
40722
|
* outage.
|
|
40560
40723
|
*/
|
|
40561
40724
|
var SupplyChain = class SupplyChain extends Service()("react-doctor/SupplyChain") {
|
|
40562
|
-
static layerNode = succeed$3(SupplyChain, SupplyChain.of({ run: (input) => unwrap(
|
|
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"))) }));
|
|
40563
40729
|
static layerOf = (diagnostics) => succeed$3(SupplyChain, SupplyChain.of({ run: () => fromIterable$1(diagnostics) }));
|
|
40564
40730
|
};
|
|
40565
40731
|
const getObjectProperty = (value, propertyName) => {
|
|
@@ -40621,7 +40787,10 @@ const formatLintFailText = (reasonTag, nodeVersion) => {
|
|
|
40621
40787
|
* diagnostics).
|
|
40622
40788
|
* 2. beforeLint hook (e.g. CLI renders the project-detection block)
|
|
40623
40789
|
* 3. environment checks (reduced-motion + pnpm hardening +
|
|
40624
|
-
* expo/react-native
|
|
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.
|
|
40625
40794
|
* 4. The supply-chain check (Socket.dev) is forked onto a background
|
|
40626
40795
|
* fiber so its ~100% network-bound time overlaps the ~100%
|
|
40627
40796
|
* CPU/subprocess-bound lint pass below, collapsing two serial
|
|
@@ -40641,7 +40810,7 @@ const formatLintFailText = (reasonTag, nodeVersion) => {
|
|
|
40641
40810
|
* order, so terminal output is identical either way; supply-chain
|
|
40642
40811
|
* rides alongside without a spinner.
|
|
40643
40812
|
* 6. Join the supply-chain fiber, then assemble the diagnostics in a
|
|
40644
|
-
* 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
|
|
40645
40814
|
* byte-identical regardless of which fiber settled first. The
|
|
40646
40815
|
* viewer-permission fiber is joined later, during score-metadata
|
|
40647
40816
|
* assembly (it feeds score metadata, not diagnostics). The per-element
|
|
@@ -40702,12 +40871,13 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
40702
40871
|
...checkPnpmHardening(scanDirectory),
|
|
40703
40872
|
...checkReactServerComponentsAdvisory(scanDirectory, project),
|
|
40704
40873
|
...checkExpoProject(scanDirectory, project),
|
|
40705
|
-
...checkReactNativeProject(scanDirectory, project)
|
|
40706
|
-
...checkSecurityScan(scanDirectory, {
|
|
40707
|
-
project,
|
|
40708
|
-
ignoredTags: input.ignoredTags
|
|
40709
|
-
})
|
|
40874
|
+
...checkReactNativeProject(scanDirectory, project)
|
|
40710
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")));
|
|
40711
40881
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
40712
40882
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
40713
40883
|
const supplyChainFiber = yield* forkChild(shouldRunSupplyChain ? runCollect(applyPerElementPipeline(supplyChainService.run({
|
|
@@ -40745,7 +40915,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
40745
40915
|
const lintConcurrency = deadCodeParseConcurrency === void 0 ? scanConcurrency : Math.max(1, scanConcurrency - deadCodeParseConcurrency);
|
|
40746
40916
|
const buildCollectDeadCode = (deadCodeTimeout) => runCollect(applyPerElementPipeline(deadCodeService.run({
|
|
40747
40917
|
rootDirectory: scanDirectory,
|
|
40748
|
-
userConfig: resolvedConfig.config,
|
|
40749
40918
|
parseConcurrency: deadCodeParseConcurrency,
|
|
40750
40919
|
workerTimeoutMs: deadCodeTimeout.workerTimeoutMs
|
|
40751
40920
|
}).pipe(catchTag("ReactDoctorError", (error) => unwrap(gen(function* () {
|
|
@@ -40843,9 +41012,11 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
40843
41012
|
else yield* scanProgress.succeed(`Scanned ${scannedFilesLabel} in ${scanElapsedSeconds}s${workerCountSuffix}`);
|
|
40844
41013
|
const supplyChainResult = yield* join(supplyChainFiber);
|
|
40845
41014
|
const supplyChainCollected = supplyChainResult.diagnostics;
|
|
41015
|
+
const securityScanCollected = yield* join(securityScanFiber);
|
|
40846
41016
|
yield* reporterService.finalize;
|
|
40847
41017
|
const finalDiagnostics = sortDiagnosticsStable(assignFixGroups([
|
|
40848
41018
|
...envCollected,
|
|
41019
|
+
...securityScanCollected,
|
|
40849
41020
|
...supplyChainCollected,
|
|
40850
41021
|
...lintCollected,
|
|
40851
41022
|
...deadCodeCollected
|
|
@@ -40871,6 +41042,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
40871
41042
|
metadata: scoreMetadata
|
|
40872
41043
|
});
|
|
40873
41044
|
const lintPartialFailures = yield* get$2(partialFailuresRef);
|
|
41045
|
+
const securityScanFailed = yield* get$2(securityScanFailedRef);
|
|
40874
41046
|
return {
|
|
40875
41047
|
project,
|
|
40876
41048
|
userConfig: resolvedConfig.config,
|
|
@@ -40891,8 +41063,10 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
40891
41063
|
scanElapsedMilliseconds,
|
|
40892
41064
|
scanConcurrency,
|
|
40893
41065
|
supplyChainOverlapTimedOut: supplyChainResult.timedOut,
|
|
41066
|
+
securityScanFailed,
|
|
40894
41067
|
lintCacheHitFileCount,
|
|
40895
|
-
lintCacheTotalFileCount
|
|
41068
|
+
lintCacheTotalFileCount,
|
|
41069
|
+
suppressedRuleCounts: transform.summarizeSuppressions()
|
|
40896
41070
|
};
|
|
40897
41071
|
}).pipe(withSpan("runInspect", { attributes: {
|
|
40898
41072
|
"inspect.directory": input.directory,
|
|
@@ -42930,6 +43104,8 @@ const METRIC = {
|
|
|
42930
43104
|
scanCheckSkipped: "scan.check_skipped",
|
|
42931
43105
|
baselineDegraded: "baseline.degraded",
|
|
42932
43106
|
ruleFired: "rule.fired",
|
|
43107
|
+
ruleDisabled: "rule.disabled",
|
|
43108
|
+
ruleSuppressed: "rule.suppressed",
|
|
42933
43109
|
lintFailed: "lint.failed",
|
|
42934
43110
|
deadCodeFailed: "deadcode.failed",
|
|
42935
43111
|
scoreUnavailable: "score.unavailable",
|
|
@@ -42942,12 +43118,17 @@ const METRIC = {
|
|
|
42942
43118
|
installWorkflow: "install.workflow",
|
|
42943
43119
|
installAgentHooks: "install.agent_hooks",
|
|
42944
43120
|
installDependency: "install.dependency",
|
|
43121
|
+
ciScaffolded: "ci.scaffolded",
|
|
43122
|
+
ciUpgraded: "ci.upgraded",
|
|
43123
|
+
ciConfigured: "ci.configured",
|
|
42945
43124
|
rulesChanged: "rules.changed",
|
|
42946
43125
|
rulesQueried: "rules.queried",
|
|
42947
43126
|
lspSessionStarted: "lsp.session.started",
|
|
42948
43127
|
lspScanCompleted: "lsp.scan.completed",
|
|
42949
43128
|
lspScanDuration: "lsp.scan.duration",
|
|
42950
|
-
lspScanDiagnostics: "lsp.scan.diagnostics"
|
|
43129
|
+
lspScanDiagnostics: "lsp.scan.diagnostics",
|
|
43130
|
+
aiTrainingWarningShown: "ai.training.warning_shown",
|
|
43131
|
+
jsonOutUsed: "json.out_used"
|
|
42951
43132
|
};
|
|
42952
43133
|
//#endregion
|
|
42953
43134
|
//#region src/cli/utils/to-category-key.ts
|
|
@@ -43264,5 +43445,5 @@ const startLanguageServer = () => {
|
|
|
43264
43445
|
};
|
|
43265
43446
|
//#endregion
|
|
43266
43447
|
export { startLanguageServer };
|
|
43267
|
-
!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]="
|
|
43268
|
-
//# debugId=
|
|
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]="1d587ca5-e9ff-5de9-a3fc-c3f1781418a6")}catch(e){}}();
|
|
43449
|
+
//# debugId=1d587ca5-e9ff-5de9-a3fc-c3f1781418a6
|