react-doctor 0.6.3-dev.ced746f → 0.6.3-dev.ea9a775
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +313 -461
- package/dist/index.js +30 -117
- package/dist/lsp.js +35 -120
- package/package.json +4 -4
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]="b55ef8b2-8e9d-512b-81de-a01f6ce3e60e")}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";
|
|
@@ -32936,7 +32936,6 @@ const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
|
32936
32936
|
const SUPPLY_CHAIN_RULE = "low-supply-chain-score";
|
|
32937
32937
|
const SUPPLY_CHAIN_CATEGORY = "Security";
|
|
32938
32938
|
const SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS = 9e4;
|
|
32939
|
-
const SUPPLY_CHAIN_CACHE_TTL_MS = 864e5;
|
|
32940
32939
|
const SUPPLY_CHAIN_CACHE_SUBDIR = "supply-chain";
|
|
32941
32940
|
const SUPPLY_CHAIN_IGNORED_PACKAGES = new Set(["next"]);
|
|
32942
32941
|
const hasIgnoredPathSegment = (relativePath) => relativePath.split(/[/\\]/).slice(0, -1).some((segment) => IGNORED_DIRECTORIES.has(segment));
|
|
@@ -37366,37 +37365,22 @@ const failOpenReadJson = (filePath, fallback) => {
|
|
|
37366
37365
|
return fallback;
|
|
37367
37366
|
}
|
|
37368
37367
|
};
|
|
37369
|
-
const hashFileContents = (filePath) => {
|
|
37370
|
-
try {
|
|
37371
|
-
return crypto.createHash("sha1").update(NFS.readFileSync(filePath)).digest("hex");
|
|
37372
|
-
} catch {
|
|
37373
|
-
return null;
|
|
37374
|
-
}
|
|
37375
|
-
};
|
|
37376
37368
|
const ANALYZED_FILE_EXTENSIONS = new Set(DEFAULT_EXTENSIONS);
|
|
37377
37369
|
const CORE_SIDE_MANIFEST_NAMES = ["knip.json", "deno.lock"];
|
|
37378
37370
|
const ANALYZED_MANIFEST_NAMES = new Set([...ANALYZED_MANIFEST_FILENAMES, ...CORE_SIDE_MANIFEST_NAMES]);
|
|
37379
37371
|
const isTsConfigLikeFile = (fileName) => (fileName.startsWith("tsconfig") || fileName.startsWith("jsconfig")) && fileName.endsWith(".json");
|
|
37380
37372
|
const isFingerprintedFile = (fileName) => ANALYZED_FILE_EXTENSIONS.has(Path.extname(fileName).toLowerCase()) || ANALYZED_MANIFEST_NAMES.has(fileName) || isTsConfigLikeFile(fileName);
|
|
37381
|
-
|
|
37382
|
-
|
|
37383
|
-
* `/`-separated path. Taken BEFORE the (long) analysis so a stored result is
|
|
37384
|
-
* verified against the tree it started from.
|
|
37385
|
-
*/
|
|
37386
|
-
const collectAnalyzedFileStats = (rootDirectory) => {
|
|
37387
|
-
const statByRelativePath = /* @__PURE__ */ new Map();
|
|
37373
|
+
const collectAnalyzedFileFingerprints = (rootDirectory) => {
|
|
37374
|
+
const fingerprints = [];
|
|
37388
37375
|
for (const { absolutePath, name } of walkSourceTreeFiles(rootDirectory)) {
|
|
37389
37376
|
if (!isFingerprintedFile(name)) continue;
|
|
37390
37377
|
try {
|
|
37391
37378
|
const fileStat = NFS.statSync(absolutePath);
|
|
37392
37379
|
const relativePath = Path.relative(rootDirectory, absolutePath).replace(/\\/g, "/");
|
|
37393
|
-
|
|
37394
|
-
mtimeMs: fileStat.mtimeMs,
|
|
37395
|
-
size: fileStat.size
|
|
37396
|
-
});
|
|
37380
|
+
fingerprints.push(`${relativePath}:${fileStat.mtimeMs}:${fileStat.size}`);
|
|
37397
37381
|
} catch {}
|
|
37398
37382
|
}
|
|
37399
|
-
return
|
|
37383
|
+
return fingerprints.sort();
|
|
37400
37384
|
};
|
|
37401
37385
|
const bundledRequire$2 = createRequire(import.meta.url);
|
|
37402
37386
|
const resolveDeslopVersion = () => {
|
|
@@ -37408,13 +37392,14 @@ const resolveDeslopVersion = () => {
|
|
|
37408
37392
|
}
|
|
37409
37393
|
};
|
|
37410
37394
|
const computeDeadCodeCacheKey = (input) => crypto.createHash("sha1").update(JSON.stringify({
|
|
37411
|
-
schemaVersion:
|
|
37395
|
+
schemaVersion: 1,
|
|
37412
37396
|
coreVersion: input.coreVersion,
|
|
37413
37397
|
deslopVersion: resolveDeslopVersion(),
|
|
37414
37398
|
deslopJsModuleSpecifier: input.deslopJsModuleSpecifier,
|
|
37415
37399
|
entryPatterns: input.entryPatterns,
|
|
37416
37400
|
ignorePatterns: input.ignorePatterns,
|
|
37417
|
-
tsConfigFile: input.tsConfigPath === void 0 ? null : Path.relative(input.rootDirectory, input.tsConfigPath).replace(/\\/g, "/")
|
|
37401
|
+
tsConfigFile: input.tsConfigPath === void 0 ? null : Path.relative(input.rootDirectory, input.tsConfigPath).replace(/\\/g, "/"),
|
|
37402
|
+
files: collectAnalyzedFileFingerprints(input.rootDirectory)
|
|
37418
37403
|
})).digest("hex");
|
|
37419
37404
|
const validateDiagnostic$2 = decodeUnknownSync(Diagnostic);
|
|
37420
37405
|
const decodeCachedDiagnostics = (raw) => {
|
|
@@ -37425,68 +37410,16 @@ const decodeCachedDiagnostics = (raw) => {
|
|
|
37425
37410
|
return null;
|
|
37426
37411
|
}
|
|
37427
37412
|
};
|
|
37428
|
-
const
|
|
37429
|
-
const
|
|
37430
|
-
|
|
37431
|
-
|
|
37432
|
-
if (persisted === null || !isRecord(persisted) || persisted.version !== 2 || persisted.key !== input.cacheKey || !isRecord(persisted.files) || !Array.isArray(persisted.diagnostics)) return null;
|
|
37433
|
-
const storedFileEntries = Object.entries(persisted.files);
|
|
37434
|
-
if (storedFileEntries.length !== input.currentFileStats.size) return null;
|
|
37435
|
-
const repairedFiles = {};
|
|
37436
|
-
let repairedCount = 0;
|
|
37437
|
-
for (const [relativePath, storedIdentity] of storedFileEntries) {
|
|
37438
|
-
if (!isPersistedFileIdentity(storedIdentity)) return null;
|
|
37439
|
-
const currentStat = input.currentFileStats.get(relativePath);
|
|
37440
|
-
if (currentStat === void 0) return null;
|
|
37441
|
-
const [storedMtimeMs, storedSize, storedContentHash] = storedIdentity;
|
|
37442
|
-
if (currentStat.mtimeMs === storedMtimeMs && currentStat.size === storedSize) {
|
|
37443
|
-
repairedFiles[relativePath] = storedIdentity;
|
|
37444
|
-
continue;
|
|
37445
|
-
}
|
|
37446
|
-
if (currentStat.size !== storedSize) return null;
|
|
37447
|
-
const currentContentHash = hashFileContents(Path.join(input.rootDirectory, relativePath));
|
|
37448
|
-
if (currentContentHash === null || currentContentHash !== storedContentHash) return null;
|
|
37449
|
-
repairedFiles[relativePath] = [
|
|
37450
|
-
currentStat.mtimeMs,
|
|
37451
|
-
currentStat.size,
|
|
37452
|
-
storedContentHash
|
|
37453
|
-
];
|
|
37454
|
-
repairedCount += 1;
|
|
37455
|
-
}
|
|
37456
|
-
const diagnostics = decodeCachedDiagnostics(persisted.diagnostics);
|
|
37457
|
-
if (diagnostics === null) return null;
|
|
37458
|
-
if (repairedCount > 0) atomicWriteJson(cacheFilePath, {
|
|
37459
|
-
version: 2,
|
|
37460
|
-
key: input.cacheKey,
|
|
37461
|
-
files: repairedFiles,
|
|
37462
|
-
diagnostics: persisted.diagnostics
|
|
37463
|
-
});
|
|
37464
|
-
return diagnostics;
|
|
37413
|
+
const lookupDeadCodeResultCache = (cacheDirectory, cacheKey) => {
|
|
37414
|
+
const persisted = failOpenReadJson(Path.join(cacheDirectory, DEAD_CODE_CACHE_FILENAME), null);
|
|
37415
|
+
if (persisted === null || !isRecord(persisted) || persisted.version !== 1 || persisted.key !== cacheKey || !Array.isArray(persisted.diagnostics)) return null;
|
|
37416
|
+
return decodeCachedDiagnostics(persisted.diagnostics);
|
|
37465
37417
|
};
|
|
37466
|
-
const storeDeadCodeResultCache = (
|
|
37467
|
-
|
|
37468
|
-
|
|
37469
|
-
|
|
37470
|
-
|
|
37471
|
-
if (contentHash === null) return;
|
|
37472
|
-
let currentStat;
|
|
37473
|
-
try {
|
|
37474
|
-
currentStat = NFS.statSync(absolutePath);
|
|
37475
|
-
} catch {
|
|
37476
|
-
return;
|
|
37477
|
-
}
|
|
37478
|
-
if (currentStat.mtimeMs !== snapshotStat.mtimeMs || currentStat.size !== snapshotStat.size) return;
|
|
37479
|
-
persistedFiles[relativePath] = [
|
|
37480
|
-
snapshotStat.mtimeMs,
|
|
37481
|
-
snapshotStat.size,
|
|
37482
|
-
contentHash
|
|
37483
|
-
];
|
|
37484
|
-
}
|
|
37485
|
-
atomicWriteJson(Path.join(input.cacheDirectory, DEAD_CODE_CACHE_FILENAME), {
|
|
37486
|
-
version: 2,
|
|
37487
|
-
key: input.cacheKey,
|
|
37488
|
-
files: persistedFiles,
|
|
37489
|
-
diagnostics: input.diagnostics
|
|
37418
|
+
const storeDeadCodeResultCache = (cacheDirectory, cacheKey, diagnostics) => {
|
|
37419
|
+
atomicWriteJson(Path.join(cacheDirectory, DEAD_CODE_CACHE_FILENAME), {
|
|
37420
|
+
version: 1,
|
|
37421
|
+
key: cacheKey,
|
|
37422
|
+
diagnostics
|
|
37490
37423
|
});
|
|
37491
37424
|
};
|
|
37492
37425
|
const readSystemFacts = () => ({
|
|
@@ -37896,22 +37829,16 @@ const checkDeadCode = async (options) => {
|
|
|
37896
37829
|
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
37897
37830
|
const tsConfigPath = resolveTsConfigPath(rootDirectory);
|
|
37898
37831
|
const deslopJsModuleSpecifier = options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js");
|
|
37899
|
-
const
|
|
37900
|
-
const cacheKey = fileStatsSnapshot === null ? null : computeDeadCodeCacheKey({
|
|
37832
|
+
const cacheKey = options.cacheEnabled ? computeDeadCodeCacheKey({
|
|
37901
37833
|
rootDirectory,
|
|
37902
37834
|
entryPatterns,
|
|
37903
37835
|
ignorePatterns,
|
|
37904
37836
|
tsConfigPath,
|
|
37905
37837
|
deslopJsModuleSpecifier,
|
|
37906
37838
|
coreVersion: CORE_PACKAGE_VERSION
|
|
37907
|
-
});
|
|
37908
|
-
if (cacheKey !== null
|
|
37909
|
-
const cachedDiagnostics = lookupDeadCodeResultCache(
|
|
37910
|
-
cacheDirectory: resolveReactDoctorCacheDir(rootDirectory),
|
|
37911
|
-
cacheKey,
|
|
37912
|
-
rootDirectory,
|
|
37913
|
-
currentFileStats: fileStatsSnapshot
|
|
37914
|
-
});
|
|
37839
|
+
}) : null;
|
|
37840
|
+
if (cacheKey !== null) {
|
|
37841
|
+
const cachedDiagnostics = lookupDeadCodeResultCache(resolveReactDoctorCacheDir(rootDirectory), cacheKey);
|
|
37915
37842
|
options.onCacheOutcome?.(cachedDiagnostics !== null);
|
|
37916
37843
|
if (cachedDiagnostics !== null) return [...cachedDiagnostics];
|
|
37917
37844
|
}
|
|
@@ -37985,13 +37912,7 @@ const checkDeadCode = async (options) => {
|
|
|
37985
37912
|
category: DEAD_CODE_CATEGORY
|
|
37986
37913
|
});
|
|
37987
37914
|
}
|
|
37988
|
-
if (cacheKey !== null
|
|
37989
|
-
cacheDirectory: resolveReactDoctorCacheDir(rootDirectory),
|
|
37990
|
-
cacheKey,
|
|
37991
|
-
rootDirectory,
|
|
37992
|
-
snapshotFileStats: fileStatsSnapshot,
|
|
37993
|
-
diagnostics
|
|
37994
|
-
});
|
|
37915
|
+
if (cacheKey !== null) storeDeadCodeResultCache(resolveReactDoctorCacheDir(rootDirectory), cacheKey, diagnostics);
|
|
37995
37916
|
return diagnostics;
|
|
37996
37917
|
};
|
|
37997
37918
|
const DEAD_CODE_RULE_KEY_PREFIX = `${DEAD_CODE_PLUGIN}/`;
|
|
@@ -39087,6 +39008,13 @@ const createFileLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
39087
39008
|
}
|
|
39088
39009
|
};
|
|
39089
39010
|
};
|
|
39011
|
+
const hashFileContents = (filePath) => {
|
|
39012
|
+
try {
|
|
39013
|
+
return crypto.createHash("sha1").update(NFS.readFileSync(filePath)).digest("hex");
|
|
39014
|
+
} catch {
|
|
39015
|
+
return null;
|
|
39016
|
+
}
|
|
39017
|
+
};
|
|
39090
39018
|
const ABSENT_CONTENT_ANSWER = "absent";
|
|
39091
39019
|
/**
|
|
39092
39020
|
* Answers dependency probes for the sidecar lint cache — used both when
|
|
@@ -41227,20 +41155,6 @@ const writeCachedSocketBody = (cacheFile, body) => {
|
|
|
41227
41155
|
}));
|
|
41228
41156
|
} catch {}
|
|
41229
41157
|
};
|
|
41230
|
-
const pruneExpiredSocketCache = (cacheDirectory) => {
|
|
41231
|
-
try {
|
|
41232
|
-
const supplyChainCacheDirectory = Path.join(cacheDirectory, SUPPLY_CHAIN_CACHE_SUBDIR);
|
|
41233
|
-
const expiryThresholdMs = Date.now() - SUPPLY_CHAIN_CACHE_TTL_MS;
|
|
41234
|
-
for (const entryName of NFS.readdirSync(supplyChainCacheDirectory)) {
|
|
41235
|
-
const entryPath = Path.join(supplyChainCacheDirectory, entryName);
|
|
41236
|
-
try {
|
|
41237
|
-
if (NFS.statSync(entryPath).mtimeMs < expiryThresholdMs) NFS.rmSync(entryPath);
|
|
41238
|
-
} catch {
|
|
41239
|
-
continue;
|
|
41240
|
-
}
|
|
41241
|
-
}
|
|
41242
|
-
} catch {}
|
|
41243
|
-
};
|
|
41244
41158
|
const fetchSocketArtifact = (dependency, cacheDirectory) => tryPromise(async (signal) => {
|
|
41245
41159
|
const cacheFile = cacheDirectory === null ? null : supplyChainCacheFile(cacheDirectory, dependency);
|
|
41246
41160
|
if (cacheFile !== null) {
|
|
@@ -41368,7 +41282,6 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
41368
41282
|
const dependencies = collectDependenciesToScore(readPackageJson(packageJsonPath), readPackageJsonText(packageJsonPath), options.includeDevDependencies);
|
|
41369
41283
|
if (dependencies.length === 0) return [];
|
|
41370
41284
|
const cacheDirectory = isSupplyChainCacheDisabled() ? null : resolveReactDoctorCacheDir(input.rootDirectory);
|
|
41371
|
-
if (cacheDirectory !== null) pruneExpiredSocketCache(cacheDirectory);
|
|
41372
41285
|
const artifacts = yield* forEach$1(dependencies, (dependency) => fetchSocketArtifact(dependency, cacheDirectory), { concurrency: 8 }).pipe(timeoutOption(input.totalTimeoutMs ?? 9e4), map$3((maybeArtifacts) => getOrElse$1(maybeArtifacts, () => [])));
|
|
41373
41286
|
const diagnostics = [];
|
|
41374
41287
|
for (let index = 0; index < dependencies.length; index += 1) {
|
|
@@ -42413,4 +42326,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
42413
42326
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
42414
42327
|
|
|
42415
42328
|
//# sourceMappingURL=index.js.map
|
|
42416
|
-
//# debugId=
|
|
42329
|
+
//# debugId=b55ef8b2-8e9d-512b-81de-a01f6ce3e60e
|
package/dist/lsp.js
CHANGED
|
@@ -32995,7 +32995,6 @@ const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
|
32995
32995
|
const SUPPLY_CHAIN_RULE = "low-supply-chain-score";
|
|
32996
32996
|
const SUPPLY_CHAIN_CATEGORY = "Security";
|
|
32997
32997
|
const SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS = 9e4;
|
|
32998
|
-
const SUPPLY_CHAIN_CACHE_TTL_MS = 864e5;
|
|
32999
32998
|
const SUPPLY_CHAIN_CACHE_SUBDIR = "supply-chain";
|
|
33000
32999
|
const SUPPLY_CHAIN_IGNORED_PACKAGES = new Set(["next"]);
|
|
33001
33000
|
const hasIgnoredPathSegment = (relativePath) => relativePath.split(/[/\\]/).slice(0, -1).some((segment) => IGNORED_DIRECTORIES.has(segment));
|
|
@@ -37351,37 +37350,22 @@ const failOpenReadJson = (filePath, fallback) => {
|
|
|
37351
37350
|
return fallback;
|
|
37352
37351
|
}
|
|
37353
37352
|
};
|
|
37354
|
-
const hashFileContents = (filePath) => {
|
|
37355
|
-
try {
|
|
37356
|
-
return crypto.createHash("sha1").update(NFS.readFileSync(filePath)).digest("hex");
|
|
37357
|
-
} catch {
|
|
37358
|
-
return null;
|
|
37359
|
-
}
|
|
37360
|
-
};
|
|
37361
37353
|
const ANALYZED_FILE_EXTENSIONS = new Set(DEFAULT_EXTENSIONS);
|
|
37362
37354
|
const CORE_SIDE_MANIFEST_NAMES = ["knip.json", "deno.lock"];
|
|
37363
37355
|
const ANALYZED_MANIFEST_NAMES = new Set([...ANALYZED_MANIFEST_FILENAMES, ...CORE_SIDE_MANIFEST_NAMES]);
|
|
37364
37356
|
const isTsConfigLikeFile = (fileName) => (fileName.startsWith("tsconfig") || fileName.startsWith("jsconfig")) && fileName.endsWith(".json");
|
|
37365
37357
|
const isFingerprintedFile = (fileName) => ANALYZED_FILE_EXTENSIONS.has(Path.extname(fileName).toLowerCase()) || ANALYZED_MANIFEST_NAMES.has(fileName) || isTsConfigLikeFile(fileName);
|
|
37366
|
-
|
|
37367
|
-
|
|
37368
|
-
* `/`-separated path. Taken BEFORE the (long) analysis so a stored result is
|
|
37369
|
-
* verified against the tree it started from.
|
|
37370
|
-
*/
|
|
37371
|
-
const collectAnalyzedFileStats = (rootDirectory) => {
|
|
37372
|
-
const statByRelativePath = /* @__PURE__ */ new Map();
|
|
37358
|
+
const collectAnalyzedFileFingerprints = (rootDirectory) => {
|
|
37359
|
+
const fingerprints = [];
|
|
37373
37360
|
for (const { absolutePath, name } of walkSourceTreeFiles(rootDirectory)) {
|
|
37374
37361
|
if (!isFingerprintedFile(name)) continue;
|
|
37375
37362
|
try {
|
|
37376
37363
|
const fileStat = NFS.statSync(absolutePath);
|
|
37377
37364
|
const relativePath = Path.relative(rootDirectory, absolutePath).replace(/\\/g, "/");
|
|
37378
|
-
|
|
37379
|
-
mtimeMs: fileStat.mtimeMs,
|
|
37380
|
-
size: fileStat.size
|
|
37381
|
-
});
|
|
37365
|
+
fingerprints.push(`${relativePath}:${fileStat.mtimeMs}:${fileStat.size}`);
|
|
37382
37366
|
} catch {}
|
|
37383
37367
|
}
|
|
37384
|
-
return
|
|
37368
|
+
return fingerprints.sort();
|
|
37385
37369
|
};
|
|
37386
37370
|
const bundledRequire$2 = createRequire(import.meta.url);
|
|
37387
37371
|
const resolveDeslopVersion = () => {
|
|
@@ -37393,13 +37377,14 @@ const resolveDeslopVersion = () => {
|
|
|
37393
37377
|
}
|
|
37394
37378
|
};
|
|
37395
37379
|
const computeDeadCodeCacheKey = (input) => crypto.createHash("sha1").update(JSON.stringify({
|
|
37396
|
-
schemaVersion:
|
|
37380
|
+
schemaVersion: 1,
|
|
37397
37381
|
coreVersion: input.coreVersion,
|
|
37398
37382
|
deslopVersion: resolveDeslopVersion(),
|
|
37399
37383
|
deslopJsModuleSpecifier: input.deslopJsModuleSpecifier,
|
|
37400
37384
|
entryPatterns: input.entryPatterns,
|
|
37401
37385
|
ignorePatterns: input.ignorePatterns,
|
|
37402
|
-
tsConfigFile: input.tsConfigPath === void 0 ? null : Path.relative(input.rootDirectory, input.tsConfigPath).replace(/\\/g, "/")
|
|
37386
|
+
tsConfigFile: input.tsConfigPath === void 0 ? null : Path.relative(input.rootDirectory, input.tsConfigPath).replace(/\\/g, "/"),
|
|
37387
|
+
files: collectAnalyzedFileFingerprints(input.rootDirectory)
|
|
37403
37388
|
})).digest("hex");
|
|
37404
37389
|
const validateDiagnostic$2 = decodeUnknownSync(Diagnostic);
|
|
37405
37390
|
const decodeCachedDiagnostics = (raw) => {
|
|
@@ -37410,68 +37395,16 @@ const decodeCachedDiagnostics = (raw) => {
|
|
|
37410
37395
|
return null;
|
|
37411
37396
|
}
|
|
37412
37397
|
};
|
|
37413
|
-
const
|
|
37414
|
-
const
|
|
37415
|
-
|
|
37416
|
-
|
|
37417
|
-
if (persisted === null || !isRecord(persisted) || persisted.version !== 2 || persisted.key !== input.cacheKey || !isRecord(persisted.files) || !Array.isArray(persisted.diagnostics)) return null;
|
|
37418
|
-
const storedFileEntries = Object.entries(persisted.files);
|
|
37419
|
-
if (storedFileEntries.length !== input.currentFileStats.size) return null;
|
|
37420
|
-
const repairedFiles = {};
|
|
37421
|
-
let repairedCount = 0;
|
|
37422
|
-
for (const [relativePath, storedIdentity] of storedFileEntries) {
|
|
37423
|
-
if (!isPersistedFileIdentity(storedIdentity)) return null;
|
|
37424
|
-
const currentStat = input.currentFileStats.get(relativePath);
|
|
37425
|
-
if (currentStat === void 0) return null;
|
|
37426
|
-
const [storedMtimeMs, storedSize, storedContentHash] = storedIdentity;
|
|
37427
|
-
if (currentStat.mtimeMs === storedMtimeMs && currentStat.size === storedSize) {
|
|
37428
|
-
repairedFiles[relativePath] = storedIdentity;
|
|
37429
|
-
continue;
|
|
37430
|
-
}
|
|
37431
|
-
if (currentStat.size !== storedSize) return null;
|
|
37432
|
-
const currentContentHash = hashFileContents(Path.join(input.rootDirectory, relativePath));
|
|
37433
|
-
if (currentContentHash === null || currentContentHash !== storedContentHash) return null;
|
|
37434
|
-
repairedFiles[relativePath] = [
|
|
37435
|
-
currentStat.mtimeMs,
|
|
37436
|
-
currentStat.size,
|
|
37437
|
-
storedContentHash
|
|
37438
|
-
];
|
|
37439
|
-
repairedCount += 1;
|
|
37440
|
-
}
|
|
37441
|
-
const diagnostics = decodeCachedDiagnostics(persisted.diagnostics);
|
|
37442
|
-
if (diagnostics === null) return null;
|
|
37443
|
-
if (repairedCount > 0) atomicWriteJson(cacheFilePath, {
|
|
37444
|
-
version: 2,
|
|
37445
|
-
key: input.cacheKey,
|
|
37446
|
-
files: repairedFiles,
|
|
37447
|
-
diagnostics: persisted.diagnostics
|
|
37448
|
-
});
|
|
37449
|
-
return diagnostics;
|
|
37398
|
+
const lookupDeadCodeResultCache = (cacheDirectory, cacheKey) => {
|
|
37399
|
+
const persisted = failOpenReadJson(Path.join(cacheDirectory, DEAD_CODE_CACHE_FILENAME), null);
|
|
37400
|
+
if (persisted === null || !isRecord(persisted) || persisted.version !== 1 || persisted.key !== cacheKey || !Array.isArray(persisted.diagnostics)) return null;
|
|
37401
|
+
return decodeCachedDiagnostics(persisted.diagnostics);
|
|
37450
37402
|
};
|
|
37451
|
-
const storeDeadCodeResultCache = (
|
|
37452
|
-
|
|
37453
|
-
|
|
37454
|
-
|
|
37455
|
-
|
|
37456
|
-
if (contentHash === null) return;
|
|
37457
|
-
let currentStat;
|
|
37458
|
-
try {
|
|
37459
|
-
currentStat = NFS.statSync(absolutePath);
|
|
37460
|
-
} catch {
|
|
37461
|
-
return;
|
|
37462
|
-
}
|
|
37463
|
-
if (currentStat.mtimeMs !== snapshotStat.mtimeMs || currentStat.size !== snapshotStat.size) return;
|
|
37464
|
-
persistedFiles[relativePath] = [
|
|
37465
|
-
snapshotStat.mtimeMs,
|
|
37466
|
-
snapshotStat.size,
|
|
37467
|
-
contentHash
|
|
37468
|
-
];
|
|
37469
|
-
}
|
|
37470
|
-
atomicWriteJson(Path.join(input.cacheDirectory, DEAD_CODE_CACHE_FILENAME), {
|
|
37471
|
-
version: 2,
|
|
37472
|
-
key: input.cacheKey,
|
|
37473
|
-
files: persistedFiles,
|
|
37474
|
-
diagnostics: input.diagnostics
|
|
37403
|
+
const storeDeadCodeResultCache = (cacheDirectory, cacheKey, diagnostics) => {
|
|
37404
|
+
atomicWriteJson(Path.join(cacheDirectory, DEAD_CODE_CACHE_FILENAME), {
|
|
37405
|
+
version: 1,
|
|
37406
|
+
key: cacheKey,
|
|
37407
|
+
diagnostics
|
|
37475
37408
|
});
|
|
37476
37409
|
};
|
|
37477
37410
|
const readSystemFacts = () => ({
|
|
@@ -37881,22 +37814,16 @@ const checkDeadCode = async (options) => {
|
|
|
37881
37814
|
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
37882
37815
|
const tsConfigPath = resolveTsConfigPath(rootDirectory);
|
|
37883
37816
|
const deslopJsModuleSpecifier = options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js");
|
|
37884
|
-
const
|
|
37885
|
-
const cacheKey = fileStatsSnapshot === null ? null : computeDeadCodeCacheKey({
|
|
37817
|
+
const cacheKey = options.cacheEnabled ? computeDeadCodeCacheKey({
|
|
37886
37818
|
rootDirectory,
|
|
37887
37819
|
entryPatterns,
|
|
37888
37820
|
ignorePatterns,
|
|
37889
37821
|
tsConfigPath,
|
|
37890
37822
|
deslopJsModuleSpecifier,
|
|
37891
37823
|
coreVersion: CORE_PACKAGE_VERSION
|
|
37892
|
-
});
|
|
37893
|
-
if (cacheKey !== null
|
|
37894
|
-
const cachedDiagnostics = lookupDeadCodeResultCache(
|
|
37895
|
-
cacheDirectory: resolveReactDoctorCacheDir(rootDirectory),
|
|
37896
|
-
cacheKey,
|
|
37897
|
-
rootDirectory,
|
|
37898
|
-
currentFileStats: fileStatsSnapshot
|
|
37899
|
-
});
|
|
37824
|
+
}) : null;
|
|
37825
|
+
if (cacheKey !== null) {
|
|
37826
|
+
const cachedDiagnostics = lookupDeadCodeResultCache(resolveReactDoctorCacheDir(rootDirectory), cacheKey);
|
|
37900
37827
|
options.onCacheOutcome?.(cachedDiagnostics !== null);
|
|
37901
37828
|
if (cachedDiagnostics !== null) return [...cachedDiagnostics];
|
|
37902
37829
|
}
|
|
@@ -37970,13 +37897,7 @@ const checkDeadCode = async (options) => {
|
|
|
37970
37897
|
category: DEAD_CODE_CATEGORY
|
|
37971
37898
|
});
|
|
37972
37899
|
}
|
|
37973
|
-
if (cacheKey !== null
|
|
37974
|
-
cacheDirectory: resolveReactDoctorCacheDir(rootDirectory),
|
|
37975
|
-
cacheKey,
|
|
37976
|
-
rootDirectory,
|
|
37977
|
-
snapshotFileStats: fileStatsSnapshot,
|
|
37978
|
-
diagnostics
|
|
37979
|
-
});
|
|
37900
|
+
if (cacheKey !== null) storeDeadCodeResultCache(resolveReactDoctorCacheDir(rootDirectory), cacheKey, diagnostics);
|
|
37980
37901
|
return diagnostics;
|
|
37981
37902
|
};
|
|
37982
37903
|
const DEAD_CODE_RULE_KEY_PREFIX = `${DEAD_CODE_PLUGIN}/`;
|
|
@@ -39072,6 +38993,13 @@ const createFileLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
39072
38993
|
}
|
|
39073
38994
|
};
|
|
39074
38995
|
};
|
|
38996
|
+
const hashFileContents = (filePath) => {
|
|
38997
|
+
try {
|
|
38998
|
+
return crypto.createHash("sha1").update(NFS.readFileSync(filePath)).digest("hex");
|
|
38999
|
+
} catch {
|
|
39000
|
+
return null;
|
|
39001
|
+
}
|
|
39002
|
+
};
|
|
39075
39003
|
const ABSENT_CONTENT_ANSWER = "absent";
|
|
39076
39004
|
/**
|
|
39077
39005
|
* Answers dependency probes for the sidecar lint cache — used both when
|
|
@@ -41212,20 +41140,6 @@ const writeCachedSocketBody = (cacheFile, body) => {
|
|
|
41212
41140
|
}));
|
|
41213
41141
|
} catch {}
|
|
41214
41142
|
};
|
|
41215
|
-
const pruneExpiredSocketCache = (cacheDirectory) => {
|
|
41216
|
-
try {
|
|
41217
|
-
const supplyChainCacheDirectory = Path.join(cacheDirectory, SUPPLY_CHAIN_CACHE_SUBDIR);
|
|
41218
|
-
const expiryThresholdMs = Date.now() - SUPPLY_CHAIN_CACHE_TTL_MS;
|
|
41219
|
-
for (const entryName of NFS.readdirSync(supplyChainCacheDirectory)) {
|
|
41220
|
-
const entryPath = Path.join(supplyChainCacheDirectory, entryName);
|
|
41221
|
-
try {
|
|
41222
|
-
if (NFS.statSync(entryPath).mtimeMs < expiryThresholdMs) NFS.rmSync(entryPath);
|
|
41223
|
-
} catch {
|
|
41224
|
-
continue;
|
|
41225
|
-
}
|
|
41226
|
-
}
|
|
41227
|
-
} catch {}
|
|
41228
|
-
};
|
|
41229
41143
|
const fetchSocketArtifact = (dependency, cacheDirectory) => tryPromise(async (signal) => {
|
|
41230
41144
|
const cacheFile = cacheDirectory === null ? null : supplyChainCacheFile(cacheDirectory, dependency);
|
|
41231
41145
|
if (cacheFile !== null) {
|
|
@@ -41353,7 +41267,6 @@ const checkSupplyChain = (input) => gen(function* () {
|
|
|
41353
41267
|
const dependencies = collectDependenciesToScore(readPackageJson(packageJsonPath), readPackageJsonText(packageJsonPath), options.includeDevDependencies);
|
|
41354
41268
|
if (dependencies.length === 0) return [];
|
|
41355
41269
|
const cacheDirectory = isSupplyChainCacheDisabled() ? null : resolveReactDoctorCacheDir(input.rootDirectory);
|
|
41356
|
-
if (cacheDirectory !== null) pruneExpiredSocketCache(cacheDirectory);
|
|
41357
41270
|
const artifacts = yield* forEach$1(dependencies, (dependency) => fetchSocketArtifact(dependency, cacheDirectory), { concurrency: 8 }).pipe(timeoutOption(input.totalTimeoutMs ?? 9e4), map$3((maybeArtifacts) => getOrElse$1(maybeArtifacts, () => [])));
|
|
41358
41271
|
const diagnostics = [];
|
|
41359
41272
|
for (let index = 0; index < dependencies.length; index += 1) {
|
|
@@ -42070,9 +41983,11 @@ const computeConfigFingerprint = (projectDirectory, version) => {
|
|
|
42070
41983
|
const parts = [`v=${version}`];
|
|
42071
41984
|
let directory = projectDirectory;
|
|
42072
41985
|
for (;;) {
|
|
42073
|
-
for (const filename of CONFIG_FINGERPRINT_FILENAMES) {
|
|
42074
|
-
const
|
|
42075
|
-
|
|
41986
|
+
for (const filename of CONFIG_FINGERPRINT_FILENAMES) try {
|
|
41987
|
+
const stat = fs.statSync(path.join(directory, filename));
|
|
41988
|
+
parts.push(`${directory}/${filename}=${stat.mtimeMs}:${stat.size}`);
|
|
41989
|
+
} catch {
|
|
41990
|
+
continue;
|
|
42076
41991
|
}
|
|
42077
41992
|
const parent = path.dirname(directory);
|
|
42078
41993
|
if (parent === directory) break;
|
|
@@ -44135,5 +44050,5 @@ const startLanguageServer = () => {
|
|
|
44135
44050
|
};
|
|
44136
44051
|
//#endregion
|
|
44137
44052
|
export { startLanguageServer };
|
|
44138
|
-
!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]="
|
|
44139
|
-
//# debugId=
|
|
44053
|
+
!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]="17a3f533-8248-511a-859b-584197cefba6")}catch(e){}}();
|
|
44054
|
+
//# debugId=17a3f533-8248-511a-859b-584197cefba6
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.6.3-dev.
|
|
3
|
+
"version": "0.6.3-dev.ea9a775",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
66
66
|
"vscode-uri": "^3.1.0",
|
|
67
67
|
"yaml": "^2.9.0",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
68
|
+
"oxlint-plugin-react-doctor": "0.6.3-dev.ea9a775",
|
|
69
|
+
"deslop-js": "0.6.3"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"@xterm/headless": "^6.0.0",
|
|
75
75
|
"commander": "^14.0.3",
|
|
76
76
|
"ora": "^9.4.0",
|
|
77
|
-
"@react-doctor/core": "0.6.3",
|
|
78
77
|
"@react-doctor/api": "0.6.3",
|
|
78
|
+
"@react-doctor/core": "0.6.3",
|
|
79
79
|
"@react-doctor/language-server": "0.6.3"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|