react-doctor 0.9.5 → 0.9.6-dev.3299454
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/README.md
CHANGED
|
@@ -13,7 +13,6 @@ React Doctor deterministically scans your codebase and finds issues across state
|
|
|
13
13
|
|
|
14
14
|
Works across React frameworks and React-enabled sites - Next.js, Vite, Astro, TanStack, React Native, Expo, you name it.
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
[Website →](https://react.doctor/docs)
|
|
18
17
|
|
|
19
18
|
## Install
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
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]="ee33417e-c94f-5f10-ac59-9d4e202b7c9f")}catch(e){}}();
|
|
3
3
|
import { n as __require, r as __toESM, t as __commonJSMin } from "./chunk-q7NCDQ7-.js";
|
|
4
|
-
import { $ as filterDiagnosticsByCategories, $n as GITHUB_ACTIONS_SETUP_URL, $t as PRE_COMMIT_CONFIG_FILE, A as HANDOFF_TARGET_PREFERENCE_ID, An as VERSION, Ar as loadConfigWithSource, At as openWorkflowPullRequest, B as buildHandoffPayload, Bn as isNonInteractiveEnvironment, Br as log, Bt as spinner, C as isGatePending, Cn as buildSentryScope, Cr as highlighter, Ct as upgradeReactDoctorWorkflowInPlace, D as writePreference, Dn as setJsonReportMode, Dr as isReactDoctorError, Dt as recordDistribution, E as runMigrations, En as setJsonReportDirectory, Er as isPlainObject, Et as recordCount, F as CLI_AGENT_BINARIES, Fn as STAGED_FILES_TEMP_DIR_PREFIX, Fr as setColorEnabled, Ft as hasDoctorDependency, G as inspect, Gn as isCodingAgentEnvironment, H as collectProjectSourceFileCounts, Hn as isDebugFlagEnabled, Hr as provide$1, I as copyToClipboard, In as STAGED_SNAPSHOT_ADDITIONAL_CONFIG_FILENAMES, Ir as toRelativePath, It as hasDoctorScript, Jn as CI_URL, Jt as HUSKY_HOOKS_PATH, K as printHeadlessReport, Kn as CANONICAL_DISCORD_URL, Kt as HOOK_FILE_NAME, L as launchCliAgent, Lr as validateConfigTypes, Lt as installReactDoctorScriptStep, Mn as METRIC, Mr as messageFromUnknown, Mt as toForwardSlashes, N as SETUP_HINT_EVENT, Nr as remainingDeadlineBudgetMs, Nt as DOCTOR_PACKAGE_NAME, O as ACTION_UPGRADE_EVENT, On as writeJsonErrorReport, Or as isSameRuleKey, Ot as prompts, P as detectLaunchableAgents, Pn as SENTRY_FLUSH_TIMEOUT_MS, Pr as resolveScanTarget, Pt as findNearestPackageDirectory, Qt as OVERCOMMIT_CONFIG_FILE, R as computeDefaultSelectedAgents, Rt as isSpinnerSilent, S as openUrl, Sn as isEnvironmentError, Sr as hasReactRuntime, St as readReactDoctorWorkflow, T as recordGate, Tn as isJsonModeActive, Tr as isPathInsideDirectory, Tt as workflowUsesV1Action, U as deduplicateProjectScans, Ur as runPromise, V as formatSkippedProjectsMessage, Vr as gen, W as createInvocationInspect, Wn as isCiOrCodingAgentEnvironment, Wr as runSync, X as indentMultilineText, Xn as COMPILER_CLEANUP_RULE_KEYS, Xt as LEGACY_HOOK_RUNNER_RELATIVE_PATH, Yn as COMPILER_CLEANUP_BUCKET, Yt as LEFTHOOK_CONFIG_FILES, Z as printDiagnosticsDump, Zt as NON_BLOCKING_REACT_DOCTOR_COMMAND, _ as resolveCliInspectOptions, _n as cliLogger, _t as resolveBlockingLevel, a as shouldFailScanGate, an as getPackageJsonPath, ar as STAGED_FILES_PROJECT_CONFIG_FILENAMES, b as setUpGitHubActions, bn as isExpectedUserError, br as getEquivalentRuleKeys, bt as installReactDoctorWorkflow, c as selectProjects, cn as packageHasNestedRecordKey, cr as buildRuleDocsUrl, d as resolveProjectChangedLineRanges, dn as resolveGitPath, dr as detectAiTrainingEnvironment, dt as recordRunTraceId, en as REACT_DOCTOR_COMMAND, er as Git, et as buildEmptyReportMessage, f as resolveProjectDiffIncludePaths, fn as runGit, fr as discoverReactSubprojects, ft as finalizeScope, g as resolveWorkspaceDeadCodeOwner, gn as runCommand, gr as getBaselineDiffPlan, gt as isValidBlockingLevel, h as retryMissingProjectScores, hn as detectDefaultBranch, hr as formatReactDoctorError, ht as warnDeprecatedDiff, i as validateModeFlags, in as ensureTrailingNewline, ir as SKILL_NAME, j as INSTALL_AGENTS_PREFERENCE_ID, jn as CI_TRUST_COMPANIES, jr as mapWithConcurrency, jt as stageWorkflowFile, k as CI_PITCH_EVENT, kn as writeJsonReport, kr as listWorkspacePackages, kt as unrefStdin, l as buildCodeFrame, ln as packageHasRecordKey, lt as getActiveRunTrace, m as resolveProjectRelativeDirectory, mn as writeJsonFile, mr as formatErrorChain, mt as resolveScope, o as projectManifestChanged, on as isRecord, or as StagedFiles, p as resolveProjectSourceFilePaths, pn as runGitRaw, pr as findLegacyConfig, pt as isScopeValue, qn as CANONICAL_GITHUB_URL, qr as provide, qt as HOOK_RELATIVE_PATH, r as validateIncludeUntrackedScope, rn as VITE_PLUS_HOOKS_PATH, rt as resolveMergeBaseRef, sn as packageHasDependency, sr as buildJsonReport, t as exitGracefully, u as resolveProjectScan, un as readPackageJson, ur as clearConfigCache, ut as getLastRunTraceId, v as filterScansForSurface, vn as flushSentry, vr as getChangedLineRanges, vt as buildWorkflowContent, w as readPreference, wn as enableJsonMode, wr as isErrnoException, wt as upgradeWorkflowActionToV2, x as reportWorkflowResult, xn as formatEnvironmentError, xt as isReactDoctorWorkflowInstalled, y as countUniqueScannedFiles, yn as initializeSentry, yr as getDiffInfo, yt as getReactDoctorWorkflowPath, z as detectAvailableAgents, zn as CliInputError, zr as error, zt as setSpinnerSilent } from "./exit-gracefully-
|
|
4
|
+
import { $ as filterDiagnosticsByCategories, $n as GITHUB_ACTIONS_SETUP_URL, $t as PRE_COMMIT_CONFIG_FILE, A as HANDOFF_TARGET_PREFERENCE_ID, An as VERSION, Ar as loadConfigWithSource, At as openWorkflowPullRequest, B as buildHandoffPayload, Bn as isNonInteractiveEnvironment, Br as log, Bt as spinner, C as isGatePending, Cn as buildSentryScope, Cr as highlighter, Ct as upgradeReactDoctorWorkflowInPlace, D as writePreference, Dn as setJsonReportMode, Dr as isReactDoctorError, Dt as recordDistribution, E as runMigrations, En as setJsonReportDirectory, Er as isPlainObject, Et as recordCount, F as CLI_AGENT_BINARIES, Fn as STAGED_FILES_TEMP_DIR_PREFIX, Fr as setColorEnabled, Ft as hasDoctorDependency, G as inspect, Gn as isCodingAgentEnvironment, H as collectProjectSourceFileCounts, Hn as isDebugFlagEnabled, Hr as provide$1, I as copyToClipboard, In as STAGED_SNAPSHOT_ADDITIONAL_CONFIG_FILENAMES, Ir as toRelativePath, It as hasDoctorScript, Jn as CI_URL, Jt as HUSKY_HOOKS_PATH, K as printHeadlessReport, Kn as CANONICAL_DISCORD_URL, Kt as HOOK_FILE_NAME, L as launchCliAgent, Lr as validateConfigTypes, Lt as installReactDoctorScriptStep, Mn as METRIC, Mr as messageFromUnknown, Mt as toForwardSlashes, N as SETUP_HINT_EVENT, Nr as remainingDeadlineBudgetMs, Nt as DOCTOR_PACKAGE_NAME, O as ACTION_UPGRADE_EVENT, On as writeJsonErrorReport, Or as isSameRuleKey, Ot as prompts, P as detectLaunchableAgents, Pn as SENTRY_FLUSH_TIMEOUT_MS, Pr as resolveScanTarget, Pt as findNearestPackageDirectory, Qt as OVERCOMMIT_CONFIG_FILE, R as computeDefaultSelectedAgents, Rt as isSpinnerSilent, S as openUrl, Sn as isEnvironmentError, Sr as hasReactRuntime, St as readReactDoctorWorkflow, T as recordGate, Tn as isJsonModeActive, Tr as isPathInsideDirectory, Tt as workflowUsesV1Action, U as deduplicateProjectScans, Ur as runPromise, V as formatSkippedProjectsMessage, Vr as gen, W as createInvocationInspect, Wn as isCiOrCodingAgentEnvironment, Wr as runSync, X as indentMultilineText, Xn as COMPILER_CLEANUP_RULE_KEYS, Xt as LEGACY_HOOK_RUNNER_RELATIVE_PATH, Yn as COMPILER_CLEANUP_BUCKET, Yt as LEFTHOOK_CONFIG_FILES, Z as printDiagnosticsDump, Zt as NON_BLOCKING_REACT_DOCTOR_COMMAND, _ as resolveCliInspectOptions, _n as cliLogger, _t as resolveBlockingLevel, a as shouldFailScanGate, an as getPackageJsonPath, ar as STAGED_FILES_PROJECT_CONFIG_FILENAMES, b as setUpGitHubActions, bn as isExpectedUserError, br as getEquivalentRuleKeys, bt as installReactDoctorWorkflow, c as selectProjects, cn as packageHasNestedRecordKey, cr as buildRuleDocsUrl, d as resolveProjectChangedLineRanges, dn as resolveGitPath, dr as detectAiTrainingEnvironment, dt as recordRunTraceId, en as REACT_DOCTOR_COMMAND, er as Git, et as buildEmptyReportMessage, f as resolveProjectDiffIncludePaths, fn as runGit, fr as discoverReactSubprojects, ft as finalizeScope, g as resolveWorkspaceDeadCodeOwner, gn as runCommand, gr as getBaselineDiffPlan, gt as isValidBlockingLevel, h as retryMissingProjectScores, hn as detectDefaultBranch, hr as formatReactDoctorError, ht as warnDeprecatedDiff, i as validateModeFlags, in as ensureTrailingNewline, ir as SKILL_NAME, j as INSTALL_AGENTS_PREFERENCE_ID, jn as CI_TRUST_COMPANIES, jr as mapWithConcurrency, jt as stageWorkflowFile, k as CI_PITCH_EVENT, kn as writeJsonReport, kr as listWorkspacePackages, kt as unrefStdin, l as buildCodeFrame, ln as packageHasRecordKey, lt as getActiveRunTrace, m as resolveProjectRelativeDirectory, mn as writeJsonFile, mr as formatErrorChain, mt as resolveScope, o as projectManifestChanged, on as isRecord, or as StagedFiles, p as resolveProjectSourceFilePaths, pn as runGitRaw, pr as findLegacyConfig, pt as isScopeValue, qn as CANONICAL_GITHUB_URL, qr as provide, qt as HOOK_RELATIVE_PATH, r as validateIncludeUntrackedScope, rn as VITE_PLUS_HOOKS_PATH, rt as resolveMergeBaseRef, sn as packageHasDependency, sr as buildJsonReport, t as exitGracefully, u as resolveProjectScan, un as readPackageJson, ur as clearConfigCache, ut as getLastRunTraceId, v as filterScansForSurface, vn as flushSentry, vr as getChangedLineRanges, vt as buildWorkflowContent, w as readPreference, wn as enableJsonMode, wr as isErrnoException, wt as upgradeWorkflowActionToV2, x as reportWorkflowResult, xn as formatEnvironmentError, xt as isReactDoctorWorkflowInstalled, y as countUniqueScannedFiles, yn as initializeSentry, yr as getDiffInfo, yt as getReactDoctorWorkflowPath, z as detectAvailableAgents, zn as CliInputError, zr as error, zt as setSpinnerSilent } from "./exit-gracefully-BhiXFgxI.js";
|
|
5
5
|
import { execFile, execFileSync } from "node:child_process";
|
|
6
6
|
import * as path$1 from "node:path";
|
|
7
7
|
import path from "node:path";
|
|
@@ -13146,7 +13146,7 @@ const runScanCommand = async (input) => {
|
|
|
13146
13146
|
warnDeprecatedFailOn(input.flags, scanTarget.userConfig);
|
|
13147
13147
|
warnDeprecatedDiff(input.flags, scanTarget.userConfig);
|
|
13148
13148
|
recordCount(METRIC.cliInvoked, 1, { command: input.invocationCommand });
|
|
13149
|
-
const { runScanApp } = await import("./run-scan-app-
|
|
13149
|
+
const { runScanApp } = await import("./run-scan-app-D2IA_mzQ.js");
|
|
13150
13150
|
const { shouldFail } = await runScanApp({
|
|
13151
13151
|
directory: input.directory,
|
|
13152
13152
|
scanTarget,
|
|
@@ -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]="2e922580-e45b-5cc6-b022-56a84d587b56")}catch(e){}}();
|
|
3
3
|
import { n as __require, r as __toESM$1, t as __commonJSMin$1 } from "./chunk-q7NCDQ7-.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as NodeChildProcess from "node:child_process";
|
|
@@ -18,8 +18,8 @@ import * as NodeUrl from "node:url";
|
|
|
18
18
|
import { fileURLToPath } from "node:url";
|
|
19
19
|
import * as OS from "node:os";
|
|
20
20
|
import os, { tmpdir } from "node:os";
|
|
21
|
-
import { parseJSON5 } from "confbox";
|
|
22
21
|
import { createJiti } from "jiti";
|
|
22
|
+
import { parseJSON5 } from "confbox";
|
|
23
23
|
import { ANALYZED_MANIFEST_FILENAMES, DEFAULT_EXTENSIONS } from "deslop-js/analyzed-inputs";
|
|
24
24
|
import { convertToTSX } from "@astrojs/compiler/sync";
|
|
25
25
|
import { gzipSync } from "node:zlib";
|
|
@@ -62453,7 +62453,7 @@ const SOCKET_FREE_USER_AGENT = "react-doctor-supply-chain";
|
|
|
62453
62453
|
const FILE_LINT_CACHE_FILENAME = "file-lint-cache.json";
|
|
62454
62454
|
const FILE_LINT_CACHE_MAX_FILE_COUNT = 5e4;
|
|
62455
62455
|
const SIDECAR_LINT_CACHE_FILENAME = "sidecar-lint-cache.json";
|
|
62456
|
-
const CORE_PACKAGE_VERSION = "0.9.
|
|
62456
|
+
const CORE_PACKAGE_VERSION = "0.9.6";
|
|
62457
62457
|
const DEAD_CODE_CACHE_FILENAME = "dead-code-cache.json";
|
|
62458
62458
|
const DEAD_CODE_SUMMARY_CACHE_FILENAME = "dead-code-summaries.json";
|
|
62459
62459
|
const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
@@ -63766,6 +63766,7 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
63766
63766
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
63767
63767
|
if (importBinding) {
|
|
63768
63768
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
63769
|
+
if (allowCompilerTransform && importBinding.moduleSpecifier === "@rolldown/plugin-babel" && importBinding.exportName === "default" && node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false))) return true;
|
|
63769
63770
|
const hasCompilerTransform = analyzeImportedConfig({
|
|
63770
63771
|
analysis,
|
|
63771
63772
|
moduleSpecifier: importBinding.moduleSpecifier,
|
|
@@ -66965,6 +66966,11 @@ var DeadCodeResultCacheEnabled = class extends Reference("react-doctor/DeadCodeR
|
|
|
66965
66966
|
if (CACHE_DISABLED_VALUES$1.has(noDeadCodeCache)) return false;
|
|
66966
66967
|
return true;
|
|
66967
66968
|
} }) {};
|
|
66969
|
+
const importDefaultExport = async (jitiInstance, filePath) => {
|
|
66970
|
+
const imported = await jitiInstance.import(filePath);
|
|
66971
|
+
return imported?.default ?? imported;
|
|
66972
|
+
};
|
|
66973
|
+
const readJson5File = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
|
|
66968
66974
|
const DIAGNOSTIC_SURFACES = [
|
|
66969
66975
|
"cli",
|
|
66970
66976
|
"prComment",
|
|
@@ -67195,11 +67201,7 @@ const DATA_CONFIG_EXTENSIONS = new Set(["json", "jsonc"]);
|
|
|
67195
67201
|
const PACKAGE_JSON_FILENAME = "package.json";
|
|
67196
67202
|
const PACKAGE_JSON_CONFIG_KEY = "reactDoctor";
|
|
67197
67203
|
const LEGACY_CONFIG_FILENAME = "react-doctor.config.json";
|
|
67198
|
-
const jiti = createJiti(import.meta.url);
|
|
67199
|
-
const importDefaultExport = async (jitiInstance, filePath) => {
|
|
67200
|
-
const imported = await jitiInstance.import(filePath);
|
|
67201
|
-
return imported?.default ?? imported;
|
|
67202
|
-
};
|
|
67204
|
+
const jiti$1 = createJiti(import.meta.url);
|
|
67203
67205
|
const SELF_PACKAGE_IMPORT_SPECIFIER = "react-doctor/api";
|
|
67204
67206
|
const SELF_PACKAGE_RESOLVE_TARGETS = ["react-doctor/api", "@react-doctor/core"];
|
|
67205
67207
|
const MODULE_NOT_FOUND_ERROR_CODES = new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
|
|
@@ -67207,7 +67209,7 @@ let selfAliasJiti;
|
|
|
67207
67209
|
const getSelfAliasJiti = () => {
|
|
67208
67210
|
if (selfAliasJiti !== void 0) return selfAliasJiti;
|
|
67209
67211
|
for (const resolveTarget of SELF_PACKAGE_RESOLVE_TARGETS) try {
|
|
67210
|
-
const aliasTargetPath = fileURLToPath(jiti.esmResolve(resolveTarget));
|
|
67212
|
+
const aliasTargetPath = fileURLToPath(jiti$1.esmResolve(resolveTarget));
|
|
67211
67213
|
selfAliasJiti = createJiti(import.meta.url, { alias: { [SELF_PACKAGE_IMPORT_SPECIFIER]: aliasTargetPath } });
|
|
67212
67214
|
return selfAliasJiti;
|
|
67213
67215
|
} catch {
|
|
@@ -67219,7 +67221,7 @@ const getSelfAliasJiti = () => {
|
|
|
67219
67221
|
const isSelfPackageResolutionError = (error) => error instanceof Error && "code" in error && typeof error.code === "string" && MODULE_NOT_FOUND_ERROR_CODES.has(error.code) && error.message.includes(SELF_PACKAGE_IMPORT_SPECIFIER);
|
|
67220
67222
|
const loadModuleConfig = async (filePath) => {
|
|
67221
67223
|
try {
|
|
67222
|
-
return await importDefaultExport(jiti, filePath);
|
|
67224
|
+
return await importDefaultExport(jiti$1, filePath);
|
|
67223
67225
|
} catch (error) {
|
|
67224
67226
|
if (!isSelfPackageResolutionError(error)) throw error;
|
|
67225
67227
|
const aliasJiti = getSelfAliasJiti();
|
|
@@ -67231,12 +67233,11 @@ const loadModuleConfig = async (filePath) => {
|
|
|
67231
67233
|
}
|
|
67232
67234
|
}
|
|
67233
67235
|
};
|
|
67234
|
-
const readDataConfig = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
|
|
67235
67236
|
const readEmbeddedPackageJsonConfig = (directory) => {
|
|
67236
67237
|
const packageJsonPath = Path.join(directory, PACKAGE_JSON_FILENAME);
|
|
67237
67238
|
if (!isFile(packageJsonPath)) return null;
|
|
67238
67239
|
try {
|
|
67239
|
-
const packageJson =
|
|
67240
|
+
const packageJson = readJson5File(packageJsonPath);
|
|
67240
67241
|
if (isPlainObject(packageJson)) {
|
|
67241
67242
|
const embeddedConfig = packageJson[PACKAGE_JSON_CONFIG_KEY];
|
|
67242
67243
|
if (isPlainObject(embeddedConfig)) return embeddedConfig;
|
|
@@ -67261,7 +67262,7 @@ const loadLegacyConfig = (directory) => {
|
|
|
67261
67262
|
loaded: null
|
|
67262
67263
|
};
|
|
67263
67264
|
try {
|
|
67264
|
-
const parsed =
|
|
67265
|
+
const parsed = readJson5File(legacyFilePath);
|
|
67265
67266
|
if (isPlainObject(parsed)) {
|
|
67266
67267
|
warn(`${LEGACY_CONFIG_FILENAME} is deprecated — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts). It is still read for now.`);
|
|
67267
67268
|
return {
|
|
@@ -67290,7 +67291,7 @@ const loadConfigFromDirectory = async (directory) => {
|
|
|
67290
67291
|
if (!isFile(filePath)) continue;
|
|
67291
67292
|
const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
|
|
67292
67293
|
try {
|
|
67293
|
-
const parsed = isDataFile ?
|
|
67294
|
+
const parsed = isDataFile ? readJson5File(filePath) : await loadModuleConfig(filePath);
|
|
67294
67295
|
if (isPlainObject(parsed)) return {
|
|
67295
67296
|
status: "found",
|
|
67296
67297
|
loaded: {
|
|
@@ -69536,20 +69537,45 @@ const collectIgnorePatterns = (rootDirectory) => {
|
|
|
69536
69537
|
cachedPatternsByRoot.set(rootDirectory, patterns);
|
|
69537
69538
|
return patterns;
|
|
69538
69539
|
};
|
|
69539
|
-
const
|
|
69540
|
+
const KNIP_DATA_CONFIG_FILENAMES = new Set([
|
|
69541
|
+
"knip.json",
|
|
69542
|
+
"knip.jsonc",
|
|
69543
|
+
".knip.json",
|
|
69544
|
+
".knip.jsonc"
|
|
69545
|
+
]);
|
|
69546
|
+
const KNIP_CONFIG_FILENAMES = [
|
|
69547
|
+
...KNIP_DATA_CONFIG_FILENAMES,
|
|
69548
|
+
"knip.ts",
|
|
69549
|
+
"knip.js",
|
|
69550
|
+
"knip.config.ts",
|
|
69551
|
+
"knip.config.js"
|
|
69552
|
+
];
|
|
69553
|
+
const jiti = createJiti(import.meta.url, { moduleCache: false });
|
|
69554
|
+
const resolveKnipConfigExport = async (configExport) => {
|
|
69555
|
+
const config = typeof configExport === "function" ? await configExport() : await configExport;
|
|
69556
|
+
return isRecord$1(config) ? config : null;
|
|
69557
|
+
};
|
|
69558
|
+
const loadKnipConfigFile = async (configFilename, filePath) => {
|
|
69540
69559
|
try {
|
|
69541
|
-
return
|
|
69560
|
+
return await resolveKnipConfigExport(KNIP_DATA_CONFIG_FILENAMES.has(configFilename) ? readJson5File(filePath) : await importDefaultExport(jiti, filePath));
|
|
69542
69561
|
} catch {
|
|
69543
|
-
return
|
|
69562
|
+
return null;
|
|
69544
69563
|
}
|
|
69545
69564
|
};
|
|
69546
|
-
const
|
|
69547
|
-
const
|
|
69548
|
-
|
|
69549
|
-
|
|
69550
|
-
|
|
69551
|
-
|
|
69552
|
-
|
|
69565
|
+
const loadKnipConfig = async (rootDirectory) => {
|
|
69566
|
+
for (const configFilename of KNIP_CONFIG_FILENAMES) {
|
|
69567
|
+
const filePath = path.join(rootDirectory, configFilename);
|
|
69568
|
+
if (!isFile(filePath)) continue;
|
|
69569
|
+
const config = await loadKnipConfigFile(configFilename, filePath);
|
|
69570
|
+
if (config) return config;
|
|
69571
|
+
}
|
|
69572
|
+
try {
|
|
69573
|
+
const packageJson = readJson5File(path.join(rootDirectory, "package.json"));
|
|
69574
|
+
const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
|
|
69575
|
+
return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
|
|
69576
|
+
} catch {
|
|
69577
|
+
return null;
|
|
69578
|
+
}
|
|
69553
69579
|
};
|
|
69554
69580
|
const normalizePatternList = (value) => {
|
|
69555
69581
|
if (typeof value === "string" && value.length > 0) return [value];
|
|
@@ -69569,22 +69595,28 @@ const collectKnipWorkspacePatterns = (workspaces, settingName) => {
|
|
|
69569
69595
|
}
|
|
69570
69596
|
return patterns;
|
|
69571
69597
|
};
|
|
69572
|
-
const collectKnipPatterns = (
|
|
69573
|
-
const config = readKnipConfig(rootDirectory);
|
|
69598
|
+
const collectKnipPatterns = (config, settingName) => {
|
|
69574
69599
|
if (!config) return [];
|
|
69575
69600
|
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
69576
69601
|
};
|
|
69577
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory) => {
|
|
69602
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory, config) => {
|
|
69578
69603
|
const seen = /* @__PURE__ */ new Set();
|
|
69579
69604
|
const sources = [
|
|
69580
69605
|
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
69581
69606
|
collectIgnorePatterns(rootDirectory),
|
|
69582
|
-
collectKnipPatterns(
|
|
69607
|
+
collectKnipPatterns(config, "ignore")
|
|
69583
69608
|
];
|
|
69584
69609
|
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
69585
69610
|
return [...seen].filter((pattern) => pattern.length > 0);
|
|
69586
69611
|
};
|
|
69587
|
-
const collectDeadCodeEntryPatterns = (
|
|
69612
|
+
const collectDeadCodeEntryPatterns = (config) => [...new Set(collectKnipPatterns(config, "entry"))].filter((pattern) => pattern.length > 0);
|
|
69613
|
+
const collectDeadCodePatterns = async (rootDirectory) => {
|
|
69614
|
+
const config = await loadKnipConfig(rootDirectory);
|
|
69615
|
+
return {
|
|
69616
|
+
entryPatterns: collectDeadCodeEntryPatterns(config),
|
|
69617
|
+
ignorePatterns: collectDeadCodeIgnorePatterns(rootDirectory, config)
|
|
69618
|
+
};
|
|
69619
|
+
};
|
|
69588
69620
|
const atomicWriteJson = (filePath, value) => {
|
|
69589
69621
|
try {
|
|
69590
69622
|
NFS.mkdirSync(Path.dirname(filePath), { recursive: true });
|
|
@@ -69595,6 +69627,13 @@ const atomicWriteJson = (filePath, value) => {
|
|
|
69595
69627
|
return;
|
|
69596
69628
|
}
|
|
69597
69629
|
};
|
|
69630
|
+
const failOpenReadJson = (filePath, fallback) => {
|
|
69631
|
+
try {
|
|
69632
|
+
return JSON.parse(NFS.readFileSync(filePath, "utf8"));
|
|
69633
|
+
} catch {
|
|
69634
|
+
return fallback;
|
|
69635
|
+
}
|
|
69636
|
+
};
|
|
69598
69637
|
const hashFileContents = (filePath) => {
|
|
69599
69638
|
try {
|
|
69600
69639
|
return crypto.createHash("sha1").update(NFS.readFileSync(filePath)).digest("hex");
|
|
@@ -69603,7 +69642,7 @@ const hashFileContents = (filePath) => {
|
|
|
69603
69642
|
}
|
|
69604
69643
|
};
|
|
69605
69644
|
const ANALYZED_FILE_EXTENSIONS = new Set(DEFAULT_EXTENSIONS);
|
|
69606
|
-
const CORE_SIDE_MANIFEST_NAMES = [
|
|
69645
|
+
const CORE_SIDE_MANIFEST_NAMES = [...KNIP_CONFIG_FILENAMES, "deno.lock"];
|
|
69607
69646
|
const ANALYZED_MANIFEST_NAMES = new Set([...ANALYZED_MANIFEST_FILENAMES, ...CORE_SIDE_MANIFEST_NAMES]);
|
|
69608
69647
|
const isTsConfigLikeFile = (fileName) => (fileName.startsWith("tsconfig") || fileName.startsWith("jsconfig")) && fileName.endsWith(".json");
|
|
69609
69648
|
const isFingerprintedFile = (fileName) => ANALYZED_FILE_EXTENSIONS.has(Path.extname(fileName).toLowerCase()) || ANALYZED_MANIFEST_NAMES.has(fileName) || isTsConfigLikeFile(fileName);
|
|
@@ -70129,8 +70168,7 @@ const runDeadCodeWorkerWithTimeout = (handle, timeoutMs, abortSignal) => new Pro
|
|
|
70129
70168
|
const checkDeadCode = async (options) => {
|
|
70130
70169
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
70131
70170
|
if (!NFS.existsSync(Path.join(rootDirectory, "package.json"))) return [];
|
|
70132
|
-
const entryPatterns =
|
|
70133
|
-
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
70171
|
+
const { entryPatterns, ignorePatterns } = await collectDeadCodePatterns(rootDirectory);
|
|
70134
70172
|
const tsConfigPath = resolveTsConfigPath(rootDirectory);
|
|
70135
70173
|
const deslopJsModuleSpecifier = options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js");
|
|
70136
70174
|
const fileStatsSnapshot = options.cacheEnabled ? collectAnalyzedFileStats(rootDirectory) : null;
|
|
@@ -76460,7 +76498,7 @@ const makeNoopConsole = () => ({
|
|
|
76460
76498
|
});
|
|
76461
76499
|
//#endregion
|
|
76462
76500
|
//#region src/cli/utils/version.ts
|
|
76463
|
-
const VERSION = "0.9.
|
|
76501
|
+
const VERSION = "0.9.6-dev.3299454";
|
|
76464
76502
|
//#endregion
|
|
76465
76503
|
//#region src/cli/utils/json-mode.ts
|
|
76466
76504
|
let context = null;
|
|
@@ -76921,13 +76959,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
76921
76959
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
76922
76960
|
* standard `SENTRY_RELEASE` override.
|
|
76923
76961
|
*/
|
|
76924
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.9.
|
|
76962
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.9.6-dev.3299454`;
|
|
76925
76963
|
/**
|
|
76926
76964
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
76927
76965
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
76928
76966
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
76929
76967
|
*/
|
|
76930
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.9.
|
|
76968
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.9.6-dev.3299454") ? "development" : "production");
|
|
76931
76969
|
/**
|
|
76932
76970
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
76933
76971
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -84136,5 +84174,5 @@ const exitGracefully = () => {
|
|
|
84136
84174
|
//#endregion
|
|
84137
84175
|
export { filterDiagnosticsByCategories as $, GITHUB_ACTIONS_SETUP_URL as $n, PRE_COMMIT_CONFIG_FILE as $t, HANDOFF_TARGET_PREFERENCE_ID as A, VERSION as An, loadConfigWithSource as Ar, openWorkflowPullRequest as At, buildHandoffPayload as B, isNonInteractiveEnvironment as Bn, log as Br, spinner as Bt, isGatePending as C, buildSentryScope as Cn, highlighter as Cr, upgradeReactDoctorWorkflowInPlace as Ct, writePreference as D, setJsonReportMode as Dn, isReactDoctorError as Dr, recordDistribution as Dt, runMigrations as E, setJsonReportDirectory as En, isPlainObject as Er, recordCount as Et, CLI_AGENT_BINARIES as F, STAGED_FILES_TEMP_DIR_PREFIX as Fn, setColorEnabled as Fr, hasDoctorDependency as Ft, inspect as G, isCodingAgentEnvironment as Gn, sync as Gr, chalk as Gt, collectProjectSourceFileCounts as H, isDebugFlagEnabled as Hn, provide as Hr, isWide as Ht, copyToClipboard as I, STAGED_SNAPSHOT_ADDITIONAL_CONFIG_FILENAMES as In, toRelativePath as Ir, hasDoctorScript as It, formatElapsedTime as J, CI_URL as Jn, succeed$3 as Jr, HUSKY_HOOKS_PATH as Jt, printHeadlessReport as K, CANONICAL_DISCORD_URL as Kn, void_ as Kr, HOOK_FILE_NAME as Kt, launchCliAgent as L, TUI_REPORT_COMPACT_MAX_ROWS as Ln, validateConfigTypes as Lr, installReactDoctorScriptStep as Lt, ONBOARDING_EVENT as M, METRIC as Mn, messageFromUnknown as Mr, toForwardSlashes as Mt, SETUP_HINT_EVENT as N, MINIMUM_VTE_VERSION_FOR_HYPERLINKS as Nn, remainingDeadlineBudgetMs as Nr, DOCTOR_PACKAGE_NAME as Nt, ACTION_UPGRADE_EVENT as O, writeJsonErrorReport as On, isSameRuleKey as Or, prompts as Ot, detectLaunchableAgents as P, SENTRY_FLUSH_TIMEOUT_MS as Pn, resolveScanTarget as Pr, findNearestPackageDirectory as Pt, formatDiagnosticSite as Q, DIAGNOSTIC_CATEGORY_BUCKETS as Qn, OVERCOMMIT_CONFIG_FILE as Qt, computeDefaultSelectedAgents as R, TUI_REPORT_DETAIL_WIDTH_FRACTION as Rn, yieldToEventLoop as Rr, isSpinnerSilent as Rt, openUrl as S, isEnvironmentError as Sn, hasReactRuntime as Sr, readReactDoctorWorkflow as St, recordGate as T, isJsonModeActive as Tn, isPathInsideDirectory as Tr, workflowUsesV1Action as Tt, deduplicateProjectScans as U, isCiEnvironment as Un, runPromise as Ur, stripAnsi as Ut, formatSkippedProjectsMessage as V, isGitHookEnvironment as Vn, gen as Vr, isFullWidth as Vt, createInvocationInspect as W, isCiOrCodingAgentEnvironment as Wn, runSync as Wr, isUnicodeSupported as Wt, indentMultilineText as X, COMPILER_CLEANUP_RULE_KEYS as Xn, LEGACY_HOOK_RUNNER_RELATIVE_PATH as Xt, printFooter as Y, COMPILER_CLEANUP_BUCKET as Yn, LEFTHOOK_CONFIG_FILES as Yt, printDiagnosticsDump as Z, CONFIG_SCHEMA_URL as Zn, NON_BLOCKING_REACT_DOCTOR_COMMAND as Zt, resolveCliInspectOptions as _, cliLogger as _n, getCategoryImpact as _r, resolveBlockingLevel as _t, shouldFailScanGate as a, getPackageJsonPath as an, STAGED_FILES_PROJECT_CONFIG_FILENAMES as ar, buildRulePriorityMap as at, setUpGitHubActions as b, isExpectedUserError as bn, getEquivalentRuleKeys as br, installReactDoctorWorkflow as bt, selectProjects as c, packageHasNestedRecordKey as cn, buildRuleDocsUrl as cr, formatLearnMoreLine as ct, resolveProjectChangedLineRanges as d, resolveGitPath as dn, detectAiTrainingEnvironment as dr, recordRunTraceId as dt, REACT_DOCTOR_COMMAND as en, Git as er, buildEmptyReportMessage as et, resolveProjectDiffIncludePaths as f, runGit as fn, discoverReactSubprojects as fr, finalizeScope as ft, resolveWorkspaceDeadCodeOwner as g, runCommand as gn, getBaselineDiffPlan as gr, isValidBlockingLevel as gt, retryMissingProjectScores as h, detectDefaultBranch as hn, formatReactDoctorError as hr, warnDeprecatedDiff as ht, validateModeFlags as i, ensureTrailingNewline as in, SKILL_NAME as ir, hasLintHardFailure as it, INSTALL_AGENTS_PREFERENCE_ID as j, CI_TRUST_COMPANIES as jn, mapWithConcurrency as jr, stageWorkflowFile as jt, CI_PITCH_EVENT as k, writeJsonReport as kn, listWorkspacePackages as kr, unrefStdin as kt, buildCodeFrame as l, packageHasRecordKey as ln, calculateScore as lr, getActiveRunTrace as lt, resolveProjectRelativeDirectory as m, writeJsonFile as mn, formatErrorChain as mr, resolveScope as mt, registerActiveTuiRenderer as n, SIMPLE_GIT_HOOKS_PACKAGE_JSON_KEY as nn, Progress as nr, buildNoScoreMessage as nt, projectManifestChanged as o, isRecord as on, StagedFiles as or, buildSortedRuleGroups as ot, resolveProjectSourceFilePaths as p, runGitRaw as pn, findLegacyConfig as pr, isScopeValue as pt, pluralize as q, CANONICAL_GITHUB_URL as qn, provide$2 as qr, HOOK_RELATIVE_PATH as qt, validateIncludeUntrackedScope as r, VITE_PLUS_HOOKS_PATH as rn, Reporter as rr, resolveMergeBaseRef as rt, discoverWorkspacePackages as s, packageHasDependency as sn, buildJsonReport as sr, formatFixRecipeLine as st, exitGracefully as t, SIMPLE_GIT_HOOKS_CONFIG_FILE as tn, LEGACY_CONFIG_FILENAME as tr, hasIncompleteScoreAnalysis as tt, resolveProjectScan as u, readPackageJson as un, clearConfigCache as ur, getLastRunTraceId as ut, filterScansForSurface as v, flushSentry as vn, getChangedLineRanges as vr, buildWorkflowContent as vt, readPreference as w, enableJsonMode as wn, isErrnoException as wr, upgradeWorkflowActionToV2 as wt, reportWorkflowResult as x, formatEnvironmentError as xn, hasPublishedFixRecipe as xr, isReactDoctorWorkflowInstalled as xt, countUniqueScannedFiles as y, initializeSentry as yn, getDiffInfo as yr, getReactDoctorWorkflowPath as yt, detectAvailableAgents as z, CliInputError as zn, error$1 as zr, setSpinnerSilent as zt };
|
|
84138
84176
|
|
|
84139
|
-
//# sourceMappingURL=exit-gracefully-
|
|
84140
|
-
//# debugId=
|
|
84177
|
+
//# sourceMappingURL=exit-gracefully-BhiXFgxI.js.map
|
|
84178
|
+
//# debugId=2e922580-e45b-5cc6-b022-56a84d587b56
|
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]="f9f92ea3-7f8e-5ab4-ba81-494560aa4278")}catch(e){}}();
|
|
3
3
|
import { i as __toESM$1, r as __require, t as __commonJSMin$1 } from "./chunk-ChKA3wi6.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, REACT_DOCTOR_RULE_REGISTRY, REACT_DOCTOR_SCAN_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor/core";
|
|
@@ -17,8 +17,8 @@ import * as NodeUrl from "node:url";
|
|
|
17
17
|
import { fileURLToPath } from "node:url";
|
|
18
18
|
import * as OS from "node:os";
|
|
19
19
|
import os from "node:os";
|
|
20
|
-
import { parseJSON5 } from "confbox";
|
|
21
20
|
import { createJiti } from "jiti";
|
|
21
|
+
import { parseJSON5 } from "confbox";
|
|
22
22
|
import { ANALYZED_MANIFEST_FILENAMES, DEFAULT_EXTENSIONS } from "deslop-js/analyzed-inputs";
|
|
23
23
|
import { convertToTSX } from "@astrojs/compiler/sync";
|
|
24
24
|
import { gzipSync } from "node:zlib";
|
|
@@ -62285,7 +62285,7 @@ const SOCKET_FREE_USER_AGENT = "react-doctor-supply-chain";
|
|
|
62285
62285
|
const FILE_LINT_CACHE_FILENAME = "file-lint-cache.json";
|
|
62286
62286
|
const FILE_LINT_CACHE_MAX_FILE_COUNT = 5e4;
|
|
62287
62287
|
const SIDECAR_LINT_CACHE_FILENAME = "sidecar-lint-cache.json";
|
|
62288
|
-
const CORE_PACKAGE_VERSION = "0.9.
|
|
62288
|
+
const CORE_PACKAGE_VERSION = "0.9.6";
|
|
62289
62289
|
const DEAD_CODE_CACHE_FILENAME = "dead-code-cache.json";
|
|
62290
62290
|
const DEAD_CODE_SUMMARY_CACHE_FILENAME = "dead-code-summaries.json";
|
|
62291
62291
|
const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
@@ -63604,6 +63604,7 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
63604
63604
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
63605
63605
|
if (importBinding) {
|
|
63606
63606
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
63607
|
+
if (allowCompilerTransform && importBinding.moduleSpecifier === "@rolldown/plugin-babel" && importBinding.exportName === "default" && node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false))) return true;
|
|
63607
63608
|
const hasCompilerTransform = analyzeImportedConfig({
|
|
63608
63609
|
analysis,
|
|
63609
63610
|
moduleSpecifier: importBinding.moduleSpecifier,
|
|
@@ -66803,6 +66804,11 @@ var DeadCodeResultCacheEnabled = class extends Reference("react-doctor/DeadCodeR
|
|
|
66803
66804
|
if (CACHE_DISABLED_VALUES.has(noDeadCodeCache)) return false;
|
|
66804
66805
|
return true;
|
|
66805
66806
|
} }) {};
|
|
66807
|
+
const importDefaultExport = async (jitiInstance, filePath) => {
|
|
66808
|
+
const imported = await jitiInstance.import(filePath);
|
|
66809
|
+
return imported?.default ?? imported;
|
|
66810
|
+
};
|
|
66811
|
+
const readJson5File = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
|
|
66806
66812
|
const DIAGNOSTIC_SURFACES = [
|
|
66807
66813
|
"cli",
|
|
66808
66814
|
"prComment",
|
|
@@ -67033,11 +67039,7 @@ const DATA_CONFIG_EXTENSIONS = new Set(["json", "jsonc"]);
|
|
|
67033
67039
|
const PACKAGE_JSON_FILENAME = "package.json";
|
|
67034
67040
|
const PACKAGE_JSON_CONFIG_KEY = "reactDoctor";
|
|
67035
67041
|
const LEGACY_CONFIG_FILENAME = "react-doctor.config.json";
|
|
67036
|
-
const jiti = createJiti(import.meta.url);
|
|
67037
|
-
const importDefaultExport = async (jitiInstance, filePath) => {
|
|
67038
|
-
const imported = await jitiInstance.import(filePath);
|
|
67039
|
-
return imported?.default ?? imported;
|
|
67040
|
-
};
|
|
67042
|
+
const jiti$1 = createJiti(import.meta.url);
|
|
67041
67043
|
const SELF_PACKAGE_IMPORT_SPECIFIER = "react-doctor/api";
|
|
67042
67044
|
const SELF_PACKAGE_RESOLVE_TARGETS = ["react-doctor/api", "@react-doctor/core"];
|
|
67043
67045
|
const MODULE_NOT_FOUND_ERROR_CODES = new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
|
|
@@ -67045,7 +67047,7 @@ let selfAliasJiti;
|
|
|
67045
67047
|
const getSelfAliasJiti = () => {
|
|
67046
67048
|
if (selfAliasJiti !== void 0) return selfAliasJiti;
|
|
67047
67049
|
for (const resolveTarget of SELF_PACKAGE_RESOLVE_TARGETS) try {
|
|
67048
|
-
const aliasTargetPath = fileURLToPath(jiti.esmResolve(resolveTarget));
|
|
67050
|
+
const aliasTargetPath = fileURLToPath(jiti$1.esmResolve(resolveTarget));
|
|
67049
67051
|
selfAliasJiti = createJiti(import.meta.url, { alias: { [SELF_PACKAGE_IMPORT_SPECIFIER]: aliasTargetPath } });
|
|
67050
67052
|
return selfAliasJiti;
|
|
67051
67053
|
} catch {
|
|
@@ -67057,7 +67059,7 @@ const getSelfAliasJiti = () => {
|
|
|
67057
67059
|
const isSelfPackageResolutionError = (error) => error instanceof Error && "code" in error && typeof error.code === "string" && MODULE_NOT_FOUND_ERROR_CODES.has(error.code) && error.message.includes(SELF_PACKAGE_IMPORT_SPECIFIER);
|
|
67058
67060
|
const loadModuleConfig = async (filePath) => {
|
|
67059
67061
|
try {
|
|
67060
|
-
return await importDefaultExport(jiti, filePath);
|
|
67062
|
+
return await importDefaultExport(jiti$1, filePath);
|
|
67061
67063
|
} catch (error) {
|
|
67062
67064
|
if (!isSelfPackageResolutionError(error)) throw error;
|
|
67063
67065
|
const aliasJiti = getSelfAliasJiti();
|
|
@@ -67069,12 +67071,11 @@ const loadModuleConfig = async (filePath) => {
|
|
|
67069
67071
|
}
|
|
67070
67072
|
}
|
|
67071
67073
|
};
|
|
67072
|
-
const readDataConfig = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
|
|
67073
67074
|
const readEmbeddedPackageJsonConfig = (directory) => {
|
|
67074
67075
|
const packageJsonPath = Path.join(directory, PACKAGE_JSON_FILENAME);
|
|
67075
67076
|
if (!isFile(packageJsonPath)) return null;
|
|
67076
67077
|
try {
|
|
67077
|
-
const packageJson =
|
|
67078
|
+
const packageJson = readJson5File(packageJsonPath);
|
|
67078
67079
|
if (isPlainObject(packageJson)) {
|
|
67079
67080
|
const embeddedConfig = packageJson[PACKAGE_JSON_CONFIG_KEY];
|
|
67080
67081
|
if (isPlainObject(embeddedConfig)) return embeddedConfig;
|
|
@@ -67099,7 +67100,7 @@ const loadLegacyConfig = (directory) => {
|
|
|
67099
67100
|
loaded: null
|
|
67100
67101
|
};
|
|
67101
67102
|
try {
|
|
67102
|
-
const parsed =
|
|
67103
|
+
const parsed = readJson5File(legacyFilePath);
|
|
67103
67104
|
if (isPlainObject(parsed)) {
|
|
67104
67105
|
warn(`${LEGACY_CONFIG_FILENAME} is deprecated — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts). It is still read for now.`);
|
|
67105
67106
|
return {
|
|
@@ -67128,7 +67129,7 @@ const loadConfigFromDirectory = async (directory) => {
|
|
|
67128
67129
|
if (!isFile(filePath)) continue;
|
|
67129
67130
|
const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
|
|
67130
67131
|
try {
|
|
67131
|
-
const parsed = isDataFile ?
|
|
67132
|
+
const parsed = isDataFile ? readJson5File(filePath) : await loadModuleConfig(filePath);
|
|
67132
67133
|
if (isPlainObject(parsed)) return {
|
|
67133
67134
|
status: "found",
|
|
67134
67135
|
loaded: {
|
|
@@ -69330,20 +69331,45 @@ const collectIgnorePatterns = (rootDirectory) => {
|
|
|
69330
69331
|
cachedPatternsByRoot.set(rootDirectory, patterns);
|
|
69331
69332
|
return patterns;
|
|
69332
69333
|
};
|
|
69333
|
-
const
|
|
69334
|
+
const KNIP_DATA_CONFIG_FILENAMES = new Set([
|
|
69335
|
+
"knip.json",
|
|
69336
|
+
"knip.jsonc",
|
|
69337
|
+
".knip.json",
|
|
69338
|
+
".knip.jsonc"
|
|
69339
|
+
]);
|
|
69340
|
+
const KNIP_CONFIG_FILENAMES = [
|
|
69341
|
+
...KNIP_DATA_CONFIG_FILENAMES,
|
|
69342
|
+
"knip.ts",
|
|
69343
|
+
"knip.js",
|
|
69344
|
+
"knip.config.ts",
|
|
69345
|
+
"knip.config.js"
|
|
69346
|
+
];
|
|
69347
|
+
const jiti = createJiti(import.meta.url, { moduleCache: false });
|
|
69348
|
+
const resolveKnipConfigExport = async (configExport) => {
|
|
69349
|
+
const config = typeof configExport === "function" ? await configExport() : await configExport;
|
|
69350
|
+
return isRecord(config) ? config : null;
|
|
69351
|
+
};
|
|
69352
|
+
const loadKnipConfigFile = async (configFilename, filePath) => {
|
|
69334
69353
|
try {
|
|
69335
|
-
return
|
|
69354
|
+
return await resolveKnipConfigExport(KNIP_DATA_CONFIG_FILENAMES.has(configFilename) ? readJson5File(filePath) : await importDefaultExport(jiti, filePath));
|
|
69336
69355
|
} catch {
|
|
69337
|
-
return
|
|
69356
|
+
return null;
|
|
69338
69357
|
}
|
|
69339
69358
|
};
|
|
69340
|
-
const
|
|
69341
|
-
const
|
|
69342
|
-
|
|
69343
|
-
|
|
69344
|
-
|
|
69345
|
-
|
|
69346
|
-
|
|
69359
|
+
const loadKnipConfig = async (rootDirectory) => {
|
|
69360
|
+
for (const configFilename of KNIP_CONFIG_FILENAMES) {
|
|
69361
|
+
const filePath = path.join(rootDirectory, configFilename);
|
|
69362
|
+
if (!isFile(filePath)) continue;
|
|
69363
|
+
const config = await loadKnipConfigFile(configFilename, filePath);
|
|
69364
|
+
if (config) return config;
|
|
69365
|
+
}
|
|
69366
|
+
try {
|
|
69367
|
+
const packageJson = readJson5File(path.join(rootDirectory, "package.json"));
|
|
69368
|
+
const packageKnipConfig = isRecord(packageJson) ? packageJson.knip : null;
|
|
69369
|
+
return isRecord(packageKnipConfig) ? packageKnipConfig : null;
|
|
69370
|
+
} catch {
|
|
69371
|
+
return null;
|
|
69372
|
+
}
|
|
69347
69373
|
};
|
|
69348
69374
|
const normalizePatternList = (value) => {
|
|
69349
69375
|
if (typeof value === "string" && value.length > 0) return [value];
|
|
@@ -69363,22 +69389,28 @@ const collectKnipWorkspacePatterns = (workspaces, settingName) => {
|
|
|
69363
69389
|
}
|
|
69364
69390
|
return patterns;
|
|
69365
69391
|
};
|
|
69366
|
-
const collectKnipPatterns = (
|
|
69367
|
-
const config = readKnipConfig(rootDirectory);
|
|
69392
|
+
const collectKnipPatterns = (config, settingName) => {
|
|
69368
69393
|
if (!config) return [];
|
|
69369
69394
|
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
69370
69395
|
};
|
|
69371
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory) => {
|
|
69396
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory, config) => {
|
|
69372
69397
|
const seen = /* @__PURE__ */ new Set();
|
|
69373
69398
|
const sources = [
|
|
69374
69399
|
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
69375
69400
|
collectIgnorePatterns(rootDirectory),
|
|
69376
|
-
collectKnipPatterns(
|
|
69401
|
+
collectKnipPatterns(config, "ignore")
|
|
69377
69402
|
];
|
|
69378
69403
|
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
69379
69404
|
return [...seen].filter((pattern) => pattern.length > 0);
|
|
69380
69405
|
};
|
|
69381
|
-
const collectDeadCodeEntryPatterns = (
|
|
69406
|
+
const collectDeadCodeEntryPatterns = (config) => [...new Set(collectKnipPatterns(config, "entry"))].filter((pattern) => pattern.length > 0);
|
|
69407
|
+
const collectDeadCodePatterns = async (rootDirectory) => {
|
|
69408
|
+
const config = await loadKnipConfig(rootDirectory);
|
|
69409
|
+
return {
|
|
69410
|
+
entryPatterns: collectDeadCodeEntryPatterns(config),
|
|
69411
|
+
ignorePatterns: collectDeadCodeIgnorePatterns(rootDirectory, config)
|
|
69412
|
+
};
|
|
69413
|
+
};
|
|
69382
69414
|
const atomicWriteJson = (filePath, value) => {
|
|
69383
69415
|
try {
|
|
69384
69416
|
NFS.mkdirSync(Path.dirname(filePath), { recursive: true });
|
|
@@ -69389,6 +69421,13 @@ const atomicWriteJson = (filePath, value) => {
|
|
|
69389
69421
|
return;
|
|
69390
69422
|
}
|
|
69391
69423
|
};
|
|
69424
|
+
const failOpenReadJson = (filePath, fallback) => {
|
|
69425
|
+
try {
|
|
69426
|
+
return JSON.parse(NFS.readFileSync(filePath, "utf8"));
|
|
69427
|
+
} catch {
|
|
69428
|
+
return fallback;
|
|
69429
|
+
}
|
|
69430
|
+
};
|
|
69392
69431
|
const hashFileContents = (filePath) => {
|
|
69393
69432
|
try {
|
|
69394
69433
|
return crypto.createHash("sha1").update(NFS.readFileSync(filePath)).digest("hex");
|
|
@@ -69397,7 +69436,7 @@ const hashFileContents = (filePath) => {
|
|
|
69397
69436
|
}
|
|
69398
69437
|
};
|
|
69399
69438
|
const ANALYZED_FILE_EXTENSIONS = new Set(DEFAULT_EXTENSIONS);
|
|
69400
|
-
const CORE_SIDE_MANIFEST_NAMES = [
|
|
69439
|
+
const CORE_SIDE_MANIFEST_NAMES = [...KNIP_CONFIG_FILENAMES, "deno.lock"];
|
|
69401
69440
|
const ANALYZED_MANIFEST_NAMES = new Set([...ANALYZED_MANIFEST_FILENAMES, ...CORE_SIDE_MANIFEST_NAMES]);
|
|
69402
69441
|
const isTsConfigLikeFile = (fileName) => (fileName.startsWith("tsconfig") || fileName.startsWith("jsconfig")) && fileName.endsWith(".json");
|
|
69403
69442
|
const isFingerprintedFile = (fileName) => ANALYZED_FILE_EXTENSIONS.has(Path.extname(fileName).toLowerCase()) || ANALYZED_MANIFEST_NAMES.has(fileName) || isTsConfigLikeFile(fileName);
|
|
@@ -69923,8 +69962,7 @@ const runDeadCodeWorkerWithTimeout = (handle, timeoutMs, abortSignal) => new Pro
|
|
|
69923
69962
|
const checkDeadCode = async (options) => {
|
|
69924
69963
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
69925
69964
|
if (!NFS.existsSync(Path.join(rootDirectory, "package.json"))) return [];
|
|
69926
|
-
const entryPatterns =
|
|
69927
|
-
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
69965
|
+
const { entryPatterns, ignorePatterns } = await collectDeadCodePatterns(rootDirectory);
|
|
69928
69966
|
const tsConfigPath = resolveTsConfigPath(rootDirectory);
|
|
69929
69967
|
const deslopJsModuleSpecifier = options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js");
|
|
69930
69968
|
const fileStatsSnapshot = options.cacheEnabled ? collectAnalyzedFileStats(rootDirectory) : null;
|
|
@@ -75914,4 +75952,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
75914
75952
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
75915
75953
|
|
|
75916
75954
|
//# sourceMappingURL=index.js.map
|
|
75917
|
-
//# debugId=
|
|
75955
|
+
//# debugId=f9f92ea3-7f8e-5ab4-ba81-494560aa4278
|
package/dist/lsp.js
CHANGED
|
@@ -14,8 +14,8 @@ import { ResolverFactory } from "oxc-resolver";
|
|
|
14
14
|
import ts from "typescript";
|
|
15
15
|
import * as NodeUrl from "node:url";
|
|
16
16
|
import { fileURLToPath } from "node:url";
|
|
17
|
-
import { parseJSON5 } from "confbox";
|
|
18
17
|
import { createJiti } from "jiti";
|
|
18
|
+
import { parseJSON5 } from "confbox";
|
|
19
19
|
import { ANALYZED_MANIFEST_FILENAMES, DEFAULT_EXTENSIONS } from "deslop-js/analyzed-inputs";
|
|
20
20
|
import { convertToTSX } from "@astrojs/compiler/sync";
|
|
21
21
|
import { gzipSync } from "node:zlib";
|
|
@@ -62384,7 +62384,7 @@ const SOCKET_FREE_USER_AGENT = "react-doctor-supply-chain";
|
|
|
62384
62384
|
const FILE_LINT_CACHE_FILENAME = "file-lint-cache.json";
|
|
62385
62385
|
const FILE_LINT_CACHE_MAX_FILE_COUNT = 5e4;
|
|
62386
62386
|
const SIDECAR_LINT_CACHE_FILENAME = "sidecar-lint-cache.json";
|
|
62387
|
-
const CORE_PACKAGE_VERSION = "0.9.
|
|
62387
|
+
const CORE_PACKAGE_VERSION = "0.9.6";
|
|
62388
62388
|
const DEAD_CODE_CACHE_FILENAME = "dead-code-cache.json";
|
|
62389
62389
|
const DEAD_CODE_SUMMARY_CACHE_FILENAME = "dead-code-summaries.json";
|
|
62390
62390
|
const SUPPLY_CHAIN_PLUGIN = "socket";
|
|
@@ -63703,6 +63703,7 @@ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTra
|
|
|
63703
63703
|
const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
|
|
63704
63704
|
if (importBinding) {
|
|
63705
63705
|
if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
|
|
63706
|
+
if (allowCompilerTransform && importBinding.moduleSpecifier === "@rolldown/plugin-babel" && importBinding.exportName === "default" && node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false))) return true;
|
|
63706
63707
|
const hasCompilerTransform = analyzeImportedConfig({
|
|
63707
63708
|
analysis,
|
|
63708
63709
|
moduleSpecifier: importBinding.moduleSpecifier,
|
|
@@ -66880,6 +66881,11 @@ var DeadCodeResultCacheEnabled = class extends Reference("react-doctor/DeadCodeR
|
|
|
66880
66881
|
if (CACHE_DISABLED_VALUES.has(noDeadCodeCache)) return false;
|
|
66881
66882
|
return true;
|
|
66882
66883
|
} }) {};
|
|
66884
|
+
const importDefaultExport = async (jitiInstance, filePath) => {
|
|
66885
|
+
const imported = await jitiInstance.import(filePath);
|
|
66886
|
+
return imported?.default ?? imported;
|
|
66887
|
+
};
|
|
66888
|
+
const readJson5File = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
|
|
66883
66889
|
const DIAGNOSTIC_SURFACES = [
|
|
66884
66890
|
"cli",
|
|
66885
66891
|
"prComment",
|
|
@@ -67110,11 +67116,7 @@ const DATA_CONFIG_EXTENSIONS = new Set(["json", "jsonc"]);
|
|
|
67110
67116
|
const PACKAGE_JSON_FILENAME = "package.json";
|
|
67111
67117
|
const PACKAGE_JSON_CONFIG_KEY = "reactDoctor";
|
|
67112
67118
|
const LEGACY_CONFIG_FILENAME = "react-doctor.config.json";
|
|
67113
|
-
const jiti = createJiti(import.meta.url);
|
|
67114
|
-
const importDefaultExport = async (jitiInstance, filePath) => {
|
|
67115
|
-
const imported = await jitiInstance.import(filePath);
|
|
67116
|
-
return imported?.default ?? imported;
|
|
67117
|
-
};
|
|
67119
|
+
const jiti$1 = createJiti(import.meta.url);
|
|
67118
67120
|
const SELF_PACKAGE_IMPORT_SPECIFIER = "react-doctor/api";
|
|
67119
67121
|
const SELF_PACKAGE_RESOLVE_TARGETS = ["react-doctor/api", "@react-doctor/core"];
|
|
67120
67122
|
const MODULE_NOT_FOUND_ERROR_CODES = new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
|
|
@@ -67122,7 +67124,7 @@ let selfAliasJiti;
|
|
|
67122
67124
|
const getSelfAliasJiti = () => {
|
|
67123
67125
|
if (selfAliasJiti !== void 0) return selfAliasJiti;
|
|
67124
67126
|
for (const resolveTarget of SELF_PACKAGE_RESOLVE_TARGETS) try {
|
|
67125
|
-
const aliasTargetPath = fileURLToPath(jiti.esmResolve(resolveTarget));
|
|
67127
|
+
const aliasTargetPath = fileURLToPath(jiti$1.esmResolve(resolveTarget));
|
|
67126
67128
|
selfAliasJiti = createJiti(import.meta.url, { alias: { [SELF_PACKAGE_IMPORT_SPECIFIER]: aliasTargetPath } });
|
|
67127
67129
|
return selfAliasJiti;
|
|
67128
67130
|
} catch {
|
|
@@ -67134,7 +67136,7 @@ const getSelfAliasJiti = () => {
|
|
|
67134
67136
|
const isSelfPackageResolutionError = (error) => error instanceof Error && "code" in error && typeof error.code === "string" && MODULE_NOT_FOUND_ERROR_CODES.has(error.code) && error.message.includes(SELF_PACKAGE_IMPORT_SPECIFIER);
|
|
67135
67137
|
const loadModuleConfig = async (filePath) => {
|
|
67136
67138
|
try {
|
|
67137
|
-
return await importDefaultExport(jiti, filePath);
|
|
67139
|
+
return await importDefaultExport(jiti$1, filePath);
|
|
67138
67140
|
} catch (error) {
|
|
67139
67141
|
if (!isSelfPackageResolutionError(error)) throw error;
|
|
67140
67142
|
const aliasJiti = getSelfAliasJiti();
|
|
@@ -67146,12 +67148,11 @@ const loadModuleConfig = async (filePath) => {
|
|
|
67146
67148
|
}
|
|
67147
67149
|
}
|
|
67148
67150
|
};
|
|
67149
|
-
const readDataConfig = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
|
|
67150
67151
|
const readEmbeddedPackageJsonConfig = (directory) => {
|
|
67151
67152
|
const packageJsonPath = Path.join(directory, PACKAGE_JSON_FILENAME);
|
|
67152
67153
|
if (!isFile(packageJsonPath)) return null;
|
|
67153
67154
|
try {
|
|
67154
|
-
const packageJson =
|
|
67155
|
+
const packageJson = readJson5File(packageJsonPath);
|
|
67155
67156
|
if (isPlainObject(packageJson)) {
|
|
67156
67157
|
const embeddedConfig = packageJson[PACKAGE_JSON_CONFIG_KEY];
|
|
67157
67158
|
if (isPlainObject(embeddedConfig)) return embeddedConfig;
|
|
@@ -67176,7 +67177,7 @@ const loadLegacyConfig = (directory) => {
|
|
|
67176
67177
|
loaded: null
|
|
67177
67178
|
};
|
|
67178
67179
|
try {
|
|
67179
|
-
const parsed =
|
|
67180
|
+
const parsed = readJson5File(legacyFilePath);
|
|
67180
67181
|
if (isPlainObject(parsed)) {
|
|
67181
67182
|
warn(`${LEGACY_CONFIG_FILENAME} is deprecated — rename it to ${CONFIG_BASENAME}.json (or author a ${CONFIG_BASENAME}.ts). It is still read for now.`);
|
|
67182
67183
|
return {
|
|
@@ -67205,7 +67206,7 @@ const loadConfigFromDirectory = async (directory) => {
|
|
|
67205
67206
|
if (!isFile(filePath)) continue;
|
|
67206
67207
|
const isDataFile = DATA_CONFIG_EXTENSIONS.has(extension);
|
|
67207
67208
|
try {
|
|
67208
|
-
const parsed = isDataFile ?
|
|
67209
|
+
const parsed = isDataFile ? readJson5File(filePath) : await loadModuleConfig(filePath);
|
|
67209
67210
|
if (isPlainObject(parsed)) return {
|
|
67210
67211
|
status: "found",
|
|
67211
67212
|
loaded: {
|
|
@@ -69359,20 +69360,45 @@ const collectIgnorePatterns = (rootDirectory) => {
|
|
|
69359
69360
|
cachedPatternsByRoot.set(rootDirectory, patterns);
|
|
69360
69361
|
return patterns;
|
|
69361
69362
|
};
|
|
69362
|
-
const
|
|
69363
|
+
const KNIP_DATA_CONFIG_FILENAMES = new Set([
|
|
69364
|
+
"knip.json",
|
|
69365
|
+
"knip.jsonc",
|
|
69366
|
+
".knip.json",
|
|
69367
|
+
".knip.jsonc"
|
|
69368
|
+
]);
|
|
69369
|
+
const KNIP_CONFIG_FILENAMES = [
|
|
69370
|
+
...KNIP_DATA_CONFIG_FILENAMES,
|
|
69371
|
+
"knip.ts",
|
|
69372
|
+
"knip.js",
|
|
69373
|
+
"knip.config.ts",
|
|
69374
|
+
"knip.config.js"
|
|
69375
|
+
];
|
|
69376
|
+
const jiti = createJiti(import.meta.url, { moduleCache: false });
|
|
69377
|
+
const resolveKnipConfigExport = async (configExport) => {
|
|
69378
|
+
const config = typeof configExport === "function" ? await configExport() : await configExport;
|
|
69379
|
+
return isRecord(config) ? config : null;
|
|
69380
|
+
};
|
|
69381
|
+
const loadKnipConfigFile = async (configFilename, filePath) => {
|
|
69363
69382
|
try {
|
|
69364
|
-
return
|
|
69383
|
+
return await resolveKnipConfigExport(KNIP_DATA_CONFIG_FILENAMES.has(configFilename) ? readJson5File(filePath) : await importDefaultExport(jiti, filePath));
|
|
69365
69384
|
} catch {
|
|
69366
|
-
return
|
|
69385
|
+
return null;
|
|
69367
69386
|
}
|
|
69368
69387
|
};
|
|
69369
|
-
const
|
|
69370
|
-
const
|
|
69371
|
-
|
|
69372
|
-
|
|
69373
|
-
|
|
69374
|
-
|
|
69375
|
-
|
|
69388
|
+
const loadKnipConfig = async (rootDirectory) => {
|
|
69389
|
+
for (const configFilename of KNIP_CONFIG_FILENAMES) {
|
|
69390
|
+
const filePath = path.join(rootDirectory, configFilename);
|
|
69391
|
+
if (!isFile(filePath)) continue;
|
|
69392
|
+
const config = await loadKnipConfigFile(configFilename, filePath);
|
|
69393
|
+
if (config) return config;
|
|
69394
|
+
}
|
|
69395
|
+
try {
|
|
69396
|
+
const packageJson = readJson5File(path.join(rootDirectory, "package.json"));
|
|
69397
|
+
const packageKnipConfig = isRecord(packageJson) ? packageJson.knip : null;
|
|
69398
|
+
return isRecord(packageKnipConfig) ? packageKnipConfig : null;
|
|
69399
|
+
} catch {
|
|
69400
|
+
return null;
|
|
69401
|
+
}
|
|
69376
69402
|
};
|
|
69377
69403
|
const normalizePatternList = (value) => {
|
|
69378
69404
|
if (typeof value === "string" && value.length > 0) return [value];
|
|
@@ -69392,22 +69418,28 @@ const collectKnipWorkspacePatterns = (workspaces, settingName) => {
|
|
|
69392
69418
|
}
|
|
69393
69419
|
return patterns;
|
|
69394
69420
|
};
|
|
69395
|
-
const collectKnipPatterns = (
|
|
69396
|
-
const config = readKnipConfig(rootDirectory);
|
|
69421
|
+
const collectKnipPatterns = (config, settingName) => {
|
|
69397
69422
|
if (!config) return [];
|
|
69398
69423
|
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
69399
69424
|
};
|
|
69400
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory) => {
|
|
69425
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory, config) => {
|
|
69401
69426
|
const seen = /* @__PURE__ */ new Set();
|
|
69402
69427
|
const sources = [
|
|
69403
69428
|
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
69404
69429
|
collectIgnorePatterns(rootDirectory),
|
|
69405
|
-
collectKnipPatterns(
|
|
69430
|
+
collectKnipPatterns(config, "ignore")
|
|
69406
69431
|
];
|
|
69407
69432
|
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
69408
69433
|
return [...seen].filter((pattern) => pattern.length > 0);
|
|
69409
69434
|
};
|
|
69410
|
-
const collectDeadCodeEntryPatterns = (
|
|
69435
|
+
const collectDeadCodeEntryPatterns = (config) => [...new Set(collectKnipPatterns(config, "entry"))].filter((pattern) => pattern.length > 0);
|
|
69436
|
+
const collectDeadCodePatterns = async (rootDirectory) => {
|
|
69437
|
+
const config = await loadKnipConfig(rootDirectory);
|
|
69438
|
+
return {
|
|
69439
|
+
entryPatterns: collectDeadCodeEntryPatterns(config),
|
|
69440
|
+
ignorePatterns: collectDeadCodeIgnorePatterns(rootDirectory, config)
|
|
69441
|
+
};
|
|
69442
|
+
};
|
|
69411
69443
|
const atomicWriteJson = (filePath, value) => {
|
|
69412
69444
|
try {
|
|
69413
69445
|
NFS.mkdirSync(Path.dirname(filePath), { recursive: true });
|
|
@@ -69418,6 +69450,13 @@ const atomicWriteJson = (filePath, value) => {
|
|
|
69418
69450
|
return;
|
|
69419
69451
|
}
|
|
69420
69452
|
};
|
|
69453
|
+
const failOpenReadJson = (filePath, fallback) => {
|
|
69454
|
+
try {
|
|
69455
|
+
return JSON.parse(NFS.readFileSync(filePath, "utf8"));
|
|
69456
|
+
} catch {
|
|
69457
|
+
return fallback;
|
|
69458
|
+
}
|
|
69459
|
+
};
|
|
69421
69460
|
const hashFileContents = (filePath) => {
|
|
69422
69461
|
try {
|
|
69423
69462
|
return crypto.createHash("sha1").update(NFS.readFileSync(filePath)).digest("hex");
|
|
@@ -69426,7 +69465,7 @@ const hashFileContents = (filePath) => {
|
|
|
69426
69465
|
}
|
|
69427
69466
|
};
|
|
69428
69467
|
const ANALYZED_FILE_EXTENSIONS = new Set(DEFAULT_EXTENSIONS);
|
|
69429
|
-
const CORE_SIDE_MANIFEST_NAMES = [
|
|
69468
|
+
const CORE_SIDE_MANIFEST_NAMES = [...KNIP_CONFIG_FILENAMES, "deno.lock"];
|
|
69430
69469
|
const ANALYZED_MANIFEST_NAMES = new Set([...ANALYZED_MANIFEST_FILENAMES, ...CORE_SIDE_MANIFEST_NAMES]);
|
|
69431
69470
|
const isTsConfigLikeFile = (fileName) => (fileName.startsWith("tsconfig") || fileName.startsWith("jsconfig")) && fileName.endsWith(".json");
|
|
69432
69471
|
const isFingerprintedFile = (fileName) => ANALYZED_FILE_EXTENSIONS.has(Path.extname(fileName).toLowerCase()) || ANALYZED_MANIFEST_NAMES.has(fileName) || isTsConfigLikeFile(fileName);
|
|
@@ -69952,8 +69991,7 @@ const runDeadCodeWorkerWithTimeout = (handle, timeoutMs, abortSignal) => new Pro
|
|
|
69952
69991
|
const checkDeadCode = async (options) => {
|
|
69953
69992
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
69954
69993
|
if (!NFS.existsSync(Path.join(rootDirectory, "package.json"))) return [];
|
|
69955
|
-
const entryPatterns =
|
|
69956
|
-
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
69994
|
+
const { entryPatterns, ignorePatterns } = await collectDeadCodePatterns(rootDirectory);
|
|
69957
69995
|
const tsConfigPath = resolveTsConfigPath(rootDirectory);
|
|
69958
69996
|
const deslopJsModuleSpecifier = options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js");
|
|
69959
69997
|
const fileStatsSnapshot = options.cacheEnabled ? collectAnalyzedFileStats(rootDirectory) : null;
|
|
@@ -75564,7 +75602,7 @@ const computeConfigFingerprint = (projectDirectory, version) => {
|
|
|
75564
75602
|
/** Display name used in client-facing messages and progress titles. */
|
|
75565
75603
|
const SERVER_DISPLAY_NAME = "React Doctor";
|
|
75566
75604
|
/** Server version reported in `serverInfo`; injected at build, `dev` from source. */
|
|
75567
|
-
const SERVER_VERSION = "0.9.
|
|
75605
|
+
const SERVER_VERSION = "0.9.6";
|
|
75568
75606
|
/** `Diagnostic.source` shown next to every published diagnostic. */
|
|
75569
75607
|
const DIAGNOSTIC_SOURCE = "react-doctor";
|
|
75570
75608
|
/**
|
|
@@ -77606,5 +77644,5 @@ const startLanguageServer = () => {
|
|
|
77606
77644
|
};
|
|
77607
77645
|
//#endregion
|
|
77608
77646
|
export { startLanguageServer };
|
|
77609
|
-
!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]="
|
|
77610
|
-
//# debugId=
|
|
77647
|
+
!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]="07103829-3f2b-5c9a-9d50-4a067a103ca1")}catch(e){}}();
|
|
77648
|
+
//# debugId=07103829-3f2b-5c9a-9d50-4a067a103ca1
|
|
@@ -1,7 +1,7 @@
|
|
|
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]="3138c140-1d25-5472-8e81-61c5cafdf53e")}catch(e){}}();
|
|
3
3
|
import { n as __require, r as __toESM, t as __commonJSMin } from "./chunk-q7NCDQ7-.js";
|
|
4
|
-
import { $ as filterDiagnosticsByCategories, $n as GITHUB_ACTIONS_SETUP_URL, B as buildHandoffPayload, C as isGatePending, Cr as highlighter, Dt as recordDistribution, Et as recordCount, F as CLI_AGENT_BINARIES, Gr as sync, Gt as chalk, H as collectProjectSourceFileCounts, Ht as isWide$1, I as copyToClipboard, J as formatElapsedTime, Jr as succeed, Kr as void_, L as launchCliAgent, Ln as TUI_REPORT_COMPACT_MAX_ROWS, M as ONBOARDING_EVENT, Mn as METRIC, Mt as toForwardSlashes, Nr as remainingDeadlineBudgetMs, P as detectLaunchableAgents, Pr as resolveScanTarget, Pt as findNearestPackageDirectory, Q as formatDiagnosticSite, Qn as DIAGNOSTIC_CATEGORY_BUCKETS, Rn as TUI_REPORT_DETAIL_WIDTH_FRACTION, Rr as yieldToEventLoop, S as openUrl, T as recordGate, Tr as isPathInsideDirectory, U as deduplicateProjectScans, Un as isCiEnvironment, Ur as runPromise, Ut as stripAnsi, V as formatSkippedProjectsMessage, Vn as isGitHookEnvironment, Vt as isFullWidth$1, W as createInvocationInspect, Wt as isUnicodeSupported, Y as printFooter, Z as printDiagnosticsDump, _ as resolveCliInspectOptions, _n as cliLogger, _r as getCategoryImpact, _t as resolveBlockingLevel, a as shouldFailScanGate, at as buildRulePriorityMap, b as setUpGitHubActions, c as selectProjects, cr as buildRuleDocsUrl, ct as formatLearnMoreLine, d as resolveProjectChangedLineRanges, et as buildEmptyReportMessage, f as resolveProjectDiffIncludePaths, ft as finalizeScope, g as resolveWorkspaceDeadCodeOwner, gr as getBaselineDiffPlan, h as retryMissingProjectScores, it as hasLintHardFailure, jn as CI_TRUST_COMPANIES, jr as mapWithConcurrency, l as buildCodeFrame, lr as calculateScore, mt as resolveScope, n as registerActiveTuiRenderer, nr as Progress, nt as buildNoScoreMessage, o as projectManifestChanged, ot as buildSortedRuleGroups, p as resolveProjectSourceFilePaths, q as pluralize, r as validateIncludeUntrackedScope, rr as Reporter, rt as resolveMergeBaseRef, s as discoverWorkspacePackages, st as formatFixRecipeLine, t as exitGracefully, tt as hasIncompleteScoreAnalysis, u as resolveProjectScan, v as filterScansForSurface, vr as getChangedLineRanges, xr as hasPublishedFixRecipe, xt as isReactDoctorWorkflowInstalled, y as countUniqueScannedFiles, yr as getDiffInfo } from "./exit-gracefully-
|
|
4
|
+
import { $ as filterDiagnosticsByCategories, $n as GITHUB_ACTIONS_SETUP_URL, B as buildHandoffPayload, C as isGatePending, Cr as highlighter, Dt as recordDistribution, Et as recordCount, F as CLI_AGENT_BINARIES, Gr as sync, Gt as chalk, H as collectProjectSourceFileCounts, Ht as isWide$1, I as copyToClipboard, J as formatElapsedTime, Jr as succeed, Kr as void_, L as launchCliAgent, Ln as TUI_REPORT_COMPACT_MAX_ROWS, M as ONBOARDING_EVENT, Mn as METRIC, Mt as toForwardSlashes, Nr as remainingDeadlineBudgetMs, P as detectLaunchableAgents, Pr as resolveScanTarget, Pt as findNearestPackageDirectory, Q as formatDiagnosticSite, Qn as DIAGNOSTIC_CATEGORY_BUCKETS, Rn as TUI_REPORT_DETAIL_WIDTH_FRACTION, Rr as yieldToEventLoop, S as openUrl, T as recordGate, Tr as isPathInsideDirectory, U as deduplicateProjectScans, Un as isCiEnvironment, Ur as runPromise, Ut as stripAnsi, V as formatSkippedProjectsMessage, Vn as isGitHookEnvironment, Vt as isFullWidth$1, W as createInvocationInspect, Wt as isUnicodeSupported, Y as printFooter, Z as printDiagnosticsDump, _ as resolveCliInspectOptions, _n as cliLogger, _r as getCategoryImpact, _t as resolveBlockingLevel, a as shouldFailScanGate, at as buildRulePriorityMap, b as setUpGitHubActions, c as selectProjects, cr as buildRuleDocsUrl, ct as formatLearnMoreLine, d as resolveProjectChangedLineRanges, et as buildEmptyReportMessage, f as resolveProjectDiffIncludePaths, ft as finalizeScope, g as resolveWorkspaceDeadCodeOwner, gr as getBaselineDiffPlan, h as retryMissingProjectScores, it as hasLintHardFailure, jn as CI_TRUST_COMPANIES, jr as mapWithConcurrency, l as buildCodeFrame, lr as calculateScore, mt as resolveScope, n as registerActiveTuiRenderer, nr as Progress, nt as buildNoScoreMessage, o as projectManifestChanged, ot as buildSortedRuleGroups, p as resolveProjectSourceFilePaths, q as pluralize, r as validateIncludeUntrackedScope, rr as Reporter, rt as resolveMergeBaseRef, s as discoverWorkspacePackages, st as formatFixRecipeLine, t as exitGracefully, tt as hasIncompleteScoreAnalysis, u as resolveProjectScan, v as filterScansForSurface, vr as getChangedLineRanges, xr as hasPublishedFixRecipe, xt as isReactDoctorWorkflowInstalled, y as countUniqueScannedFiles, yr as getDiffInfo } from "./exit-gracefully-BhiXFgxI.js";
|
|
5
5
|
import { EventEmitter } from "node:events";
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
7
7
|
import path from "node:path";
|
|
@@ -28307,5 +28307,5 @@ const runScanApp = async (input) => {
|
|
|
28307
28307
|
//#endregion
|
|
28308
28308
|
export { runScanApp };
|
|
28309
28309
|
|
|
28310
|
-
//# sourceMappingURL=run-scan-app-
|
|
28311
|
-
//# debugId=
|
|
28310
|
+
//# sourceMappingURL=run-scan-app-D2IA_mzQ.js.map
|
|
28311
|
+
//# debugId=3138c140-1d25-5472-8e81-61c5cafdf53e
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6-dev.3299454",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"vscode-uri": "^3.1.0",
|
|
70
70
|
"yaml": "^2.9.0",
|
|
71
71
|
"yoga-layout": "~3.2.1",
|
|
72
|
-
"deslop-js": "0.9.
|
|
73
|
-
"oxlint-plugin-react-doctor": "0.9.
|
|
72
|
+
"deslop-js": "0.9.6",
|
|
73
|
+
"oxlint-plugin-react-doctor": "0.9.6-dev.3299454"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"ora": "^9.4.0",
|
|
85
85
|
"react": "19.2.5",
|
|
86
86
|
"react-devtools-core": "^7.0.1",
|
|
87
|
-
"@react-doctor/
|
|
88
|
-
"@react-doctor/
|
|
89
|
-
"@react-doctor/
|
|
87
|
+
"@react-doctor/language-server": "0.9.6",
|
|
88
|
+
"@react-doctor/api": "0.9.6",
|
|
89
|
+
"@react-doctor/core": "0.9.6"
|
|
90
90
|
},
|
|
91
91
|
"engines": {
|
|
92
92
|
"node": "^20.19.0 || >=22.13.0"
|