react-doctor 0.7.4-dev.7bbb792 → 0.7.4-dev.99ac4ff
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 +0 -8
- package/dist/cli.js +79 -276
- package/dist/index.d.ts +5 -47
- package/dist/index.js +64 -251
- package/dist/lsp.js +33 -174
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +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]="e5be91b0-fb63-5b7d-849e-60c4e4eb96b2")}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
|
-
import reactDoctorPlugin, { 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, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
|
|
6
5
|
import * as NFS from "node:fs";
|
|
7
6
|
import fs from "node:fs";
|
|
8
7
|
import * as Path from "node:path";
|
|
@@ -10,6 +9,7 @@ import path from "node:path";
|
|
|
10
9
|
import * as NodeChildProcess from "node:child_process";
|
|
11
10
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
12
11
|
import ts from "typescript";
|
|
12
|
+
import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
|
|
13
13
|
import * as OS from "node:os";
|
|
14
14
|
import os from "node:os";
|
|
15
15
|
import { parseJSON5 } from "confbox";
|
|
@@ -19310,45 +19310,12 @@ var Diagnostic = class extends Class("Diagnostic")({
|
|
|
19310
19310
|
relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation)),
|
|
19311
19311
|
fixGroupId: optional(String$1)
|
|
19312
19312
|
}) {};
|
|
19313
|
-
var JsonReportDiagnosticV3 = class extends Class("JsonReportDiagnosticV3")({
|
|
19314
|
-
id: String$1,
|
|
19315
|
-
normalizedFilePath: String$1,
|
|
19316
|
-
filePath: String$1,
|
|
19317
|
-
plugin: String$1,
|
|
19318
|
-
rule: String$1,
|
|
19319
|
-
severity: Severity,
|
|
19320
|
-
tags: ArraySchema(String$1),
|
|
19321
|
-
title: optional(String$1),
|
|
19322
|
-
message: String$1,
|
|
19323
|
-
help: String$1,
|
|
19324
|
-
url: optional(String$1),
|
|
19325
|
-
line: Number$1,
|
|
19326
|
-
column: Number$1,
|
|
19327
|
-
offset: optional(Number$1),
|
|
19328
|
-
length: optional(Number$1),
|
|
19329
|
-
endLine: optional(Number$1),
|
|
19330
|
-
endColumn: optional(Number$1),
|
|
19331
|
-
category: String$1,
|
|
19332
|
-
matchByOccurrence: optional(Boolean$1),
|
|
19333
|
-
fileContext: optional(Literals(["test", "story"])),
|
|
19334
|
-
suppressionHint: optional(String$1),
|
|
19335
|
-
relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation)),
|
|
19336
|
-
fixGroupId: optional(String$1)
|
|
19337
|
-
}) {};
|
|
19338
|
-
/**
|
|
19339
|
-
* Deterministic identity string for a diagnostic. Same diagnostic
|
|
19340
|
-
* across two scans yields the same identity; lets baselines,
|
|
19341
|
-
* suppression files, content-hash caches, and IDE "ignore this"
|
|
19342
|
-
* actions all key off one shared shape.
|
|
19343
|
-
*/
|
|
19344
|
-
const buildDiagnosticIdentity = (input) => `${input.filePath}::${input.line}:${input.column}::${input.plugin}/${input.rule}`;
|
|
19345
19313
|
const JsonReportMode = Literals([
|
|
19346
19314
|
"full",
|
|
19347
19315
|
"diff",
|
|
19348
19316
|
"staged",
|
|
19349
19317
|
"baseline"
|
|
19350
19318
|
]);
|
|
19351
|
-
const Framework = Literals(FRAMEWORK_TOKENS);
|
|
19352
19319
|
var JsonReportSummary = class extends Class("JsonReportSummary")({
|
|
19353
19320
|
errorCount: Number$1,
|
|
19354
19321
|
warningCount: Number$1,
|
|
@@ -19386,22 +19353,13 @@ var JsonReportProjectEntry = class extends Class("JsonReportProjectEntry")({
|
|
|
19386
19353
|
scannedFileCount: optional(Number$1),
|
|
19387
19354
|
elapsedMilliseconds: Number$1
|
|
19388
19355
|
}) {};
|
|
19389
|
-
|
|
19390
|
-
|
|
19391
|
-
|
|
19392
|
-
|
|
19393
|
-
|
|
19394
|
-
|
|
19395
|
-
|
|
19396
|
-
skippedChecks: ArraySchema(String$1),
|
|
19397
|
-
skippedCheckReasons: optional(Record$1(String$1, String$1)),
|
|
19398
|
-
analyzedFiles: ArraySchema(String$1),
|
|
19399
|
-
analyzedFileCount: Number$1,
|
|
19400
|
-
complete: Boolean$1,
|
|
19401
|
-
scannedFileCount: optional(Number$1),
|
|
19402
|
-
elapsedMilliseconds: Number$1
|
|
19403
|
-
}) {};
|
|
19404
|
-
/** Original full, diff, and staged report contract. */
|
|
19356
|
+
/**
|
|
19357
|
+
* Versioned JsonReport schema. `JsonReport` is a `Schema.Union` so we
|
|
19358
|
+
* can add `schemaVersion: 2` later as one new union member without
|
|
19359
|
+
* breaking existing v1 consumers (the GitHub Action keys off the
|
|
19360
|
+
* version literal). Today's union is single-arm; the shape is
|
|
19361
|
+
* intentional.
|
|
19362
|
+
*/
|
|
19405
19363
|
var JsonReportV1 = class extends Class("JsonReportV1")({
|
|
19406
19364
|
schemaVersion: Literal(1),
|
|
19407
19365
|
version: String$1,
|
|
@@ -19462,27 +19420,7 @@ var JsonReportV2 = class extends Class("JsonReportV2")({
|
|
|
19462
19420
|
elapsedMilliseconds: Number$1,
|
|
19463
19421
|
error: NullOr(JsonReportError)
|
|
19464
19422
|
}) {};
|
|
19465
|
-
|
|
19466
|
-
schemaVersion: Literal(3),
|
|
19467
|
-
version: String$1,
|
|
19468
|
-
ok: Boolean$1,
|
|
19469
|
-
directory: String$1,
|
|
19470
|
-
mode: JsonReportMode,
|
|
19471
|
-
baselineDegraded: optional(Boolean$1),
|
|
19472
|
-
reactDetected: optional(Boolean$1),
|
|
19473
|
-
diff: NullOr(JsonReportDiffInfo),
|
|
19474
|
-
baseline: optional(JsonReportBaseline),
|
|
19475
|
-
projects: ArraySchema(JsonReportProjectEntryV3),
|
|
19476
|
-
diagnostics: ArraySchema(JsonReportDiagnosticV3),
|
|
19477
|
-
summary: JsonReportSummary,
|
|
19478
|
-
elapsedMilliseconds: Number$1,
|
|
19479
|
-
error: NullOr(JsonReportError)
|
|
19480
|
-
}) {};
|
|
19481
|
-
Union([
|
|
19482
|
-
JsonReportV1,
|
|
19483
|
-
JsonReportV2,
|
|
19484
|
-
JsonReportV3
|
|
19485
|
-
]);
|
|
19423
|
+
Union([JsonReportV1, JsonReportV2]);
|
|
19486
19424
|
//#endregion
|
|
19487
19425
|
//#region ../../node_modules/.pnpm/semver@7.7.4/node_modules/semver/internal/constants.js
|
|
19488
19426
|
var require_constants$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) => {
|
|
@@ -33952,22 +33890,6 @@ const isPackageJsonReanimatedAware = (packageJson) => {
|
|
|
33952
33890
|
};
|
|
33953
33891
|
return Object.hasOwn(allDependencies, REANIMATED_DEPENDENCY_NAME$1);
|
|
33954
33892
|
};
|
|
33955
|
-
const SSR_DEPENDENCY_NAMES = new Set([
|
|
33956
|
-
"@react-router/cloudflare",
|
|
33957
|
-
"@react-router/node",
|
|
33958
|
-
"@react-router/serve",
|
|
33959
|
-
"vike",
|
|
33960
|
-
"vite-plugin-ssr"
|
|
33961
|
-
]);
|
|
33962
|
-
const isPackageJsonSsrAware = (packageJson) => {
|
|
33963
|
-
const allDependencies = {
|
|
33964
|
-
...packageJson.peerDependencies,
|
|
33965
|
-
...packageJson.dependencies,
|
|
33966
|
-
...packageJson.devDependencies,
|
|
33967
|
-
...packageJson.optionalDependencies
|
|
33968
|
-
};
|
|
33969
|
-
return Object.keys(allDependencies).some((packageName) => SSR_DEPENDENCY_NAMES.has(packageName));
|
|
33970
|
-
};
|
|
33971
33893
|
const getWorkspacePatterns = (rootDirectory, packageJson) => {
|
|
33972
33894
|
const pnpmPatterns = parsePnpmWorkspacePatterns(rootDirectory);
|
|
33973
33895
|
if (pnpmPatterns.length > 0) return pnpmPatterns;
|
|
@@ -34108,7 +34030,6 @@ const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
|
34108
34030
|
}
|
|
34109
34031
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34110
34032
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34111
|
-
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34112
34033
|
};
|
|
34113
34034
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34114
34035
|
const facts = {
|
|
@@ -34130,7 +34051,6 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34130
34051
|
},
|
|
34131
34052
|
hasReactNativeAwarePackage: false,
|
|
34132
34053
|
hasReanimatedAwarePackage: false,
|
|
34133
|
-
hasSsrDependency: false,
|
|
34134
34054
|
reanimatedVersion: null
|
|
34135
34055
|
};
|
|
34136
34056
|
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
@@ -34370,7 +34290,6 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34370
34290
|
hasTypeScript: hasOwnTsConfig,
|
|
34371
34291
|
hasReactCompiler: false,
|
|
34372
34292
|
hasTanStackQuery: false,
|
|
34373
|
-
hasSsrDependency: false,
|
|
34374
34293
|
preactVersion: null,
|
|
34375
34294
|
preactMajorVersion: null,
|
|
34376
34295
|
hasReactNativeWorkspace: false,
|
|
@@ -34490,7 +34409,6 @@ const discoverProject = (directory) => {
|
|
|
34490
34409
|
hasTypeScript,
|
|
34491
34410
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34492
34411
|
hasTanStackQuery: hasTanStackQuery(packageJson),
|
|
34493
|
-
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34494
34412
|
preactVersion,
|
|
34495
34413
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
34496
34414
|
hasReactNativeWorkspace,
|
|
@@ -37309,12 +37227,6 @@ const CLIENT_ONLY_FRAMEWORKS = new Set([
|
|
|
37309
37227
|
"react-native",
|
|
37310
37228
|
"expo"
|
|
37311
37229
|
]);
|
|
37312
|
-
const SSR_FRAMEWORKS = new Set([
|
|
37313
|
-
"nextjs",
|
|
37314
|
-
"remix",
|
|
37315
|
-
"gatsby",
|
|
37316
|
-
"tanstack-start"
|
|
37317
|
-
]);
|
|
37318
37230
|
const addMajorLadder = (capabilities, name, major, earliest, latest) => {
|
|
37319
37231
|
if (major === null) return;
|
|
37320
37232
|
const cappedMajor = Math.min(major, latest);
|
|
@@ -37327,7 +37239,6 @@ const buildCapabilities = (project) => {
|
|
|
37327
37239
|
if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
|
|
37328
37240
|
if (project.expoVersion !== null) capabilities.add("expo");
|
|
37329
37241
|
if ((project.framework === "nextjs" || project.framework === "tanstack-start" || project.framework === "remix") && !project.isStaticExport) capabilities.add("server-actions");
|
|
37330
|
-
if (SSR_FRAMEWORKS.has(project.framework) || project.hasSsrDependency) capabilities.add("ssr");
|
|
37331
37242
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
37332
37243
|
if (project.isStaticExport) capabilities.add("nextjs:static-export");
|
|
37333
37244
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
@@ -40732,8 +40643,6 @@ const spawnLintBatches = async (input) => {
|
|
|
40732
40643
|
const reasonHint = firstDropReason ? ` — first failure: ${firstDropReason}` : "";
|
|
40733
40644
|
reportSkippedFiles(droppedFiles, (fileListPreview) => `${droppedFiles.length} file(s) failed to lint and were skipped (${fileListPreview})${reasonHint}`);
|
|
40734
40645
|
reportSkippedFiles(outcome.deadlineSkippedFiles, (fileListPreview) => `${outcome.deadlineSkippedFiles.length} file(s) skipped — max scan duration reached before they were linted (${fileListPreview})`);
|
|
40735
|
-
const unavailableFiles = new Set([...droppedFiles, ...outcome.deadlineSkippedFiles]);
|
|
40736
|
-
input.onAnalyzedFiles?.([...new Set(fileBatches.flat().filter((filePath) => !unavailableFiles.has(filePath)))].sort());
|
|
40737
40646
|
return dedupeDiagnostics(diagnostics);
|
|
40738
40647
|
};
|
|
40739
40648
|
let didValidate = false;
|
|
@@ -40990,18 +40899,12 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
40990
40899
|
* 6. always restore disable directives + clean up the temp dir
|
|
40991
40900
|
*/
|
|
40992
40901
|
const runOxlint = async (options) => {
|
|
40993
|
-
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), userConfig, configSourceDirectory = rootDirectory, onPartialFailure,
|
|
40902
|
+
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), userConfig, configSourceDirectory = rootDirectory, onPartialFailure, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
|
|
40994
40903
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
40995
40904
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
40996
40905
|
validateRuleRegistration();
|
|
40997
40906
|
resetManifestCaches();
|
|
40998
|
-
if (includePaths !== void 0 && includePaths.length === 0)
|
|
40999
|
-
onFileCoverage?.({
|
|
41000
|
-
candidateFiles: [],
|
|
41001
|
-
analyzedFiles: []
|
|
41002
|
-
});
|
|
41003
|
-
return [];
|
|
41004
|
-
}
|
|
40907
|
+
if (includePaths !== void 0 && includePaths.length === 0) return [];
|
|
41005
40908
|
const pluginPath = resolvePluginPath();
|
|
41006
40909
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
41007
40910
|
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
@@ -41062,7 +40965,6 @@ const runOxlint = async (options) => {
|
|
|
41062
40965
|
const runConfigOverFiles = async (buildConfigForPass, configFileName, files, fileProgress) => {
|
|
41063
40966
|
if (files.length === 0) return {
|
|
41064
40967
|
diagnostics: [],
|
|
41065
|
-
analyzedFiles: [],
|
|
41066
40968
|
didDropReactHooksJsPlugin: false,
|
|
41067
40969
|
hadPartialFailure: false
|
|
41068
40970
|
};
|
|
@@ -41074,32 +40976,24 @@ const runOxlint = async (options) => {
|
|
|
41074
40976
|
const passConfigPath = Path.join(configDirectory, configFileName);
|
|
41075
40977
|
const passBaseArgs = makeBaseArgs(passConfigPath);
|
|
41076
40978
|
const passFileBatches = buildFileBatches(passBaseArgs, files);
|
|
41077
|
-
|
|
41078
|
-
|
|
41079
|
-
|
|
41080
|
-
|
|
41081
|
-
|
|
41082
|
-
|
|
41083
|
-
|
|
41084
|
-
|
|
41085
|
-
|
|
41086
|
-
|
|
41087
|
-
|
|
41088
|
-
|
|
41089
|
-
|
|
41090
|
-
|
|
41091
|
-
spawnTimeoutMs,
|
|
41092
|
-
outputMaxBytes,
|
|
41093
|
-
concurrency: options.concurrency,
|
|
41094
|
-
signal: options.signal,
|
|
41095
|
-
deadlineEpochMs: options.deadlineEpochMs
|
|
41096
|
-
});
|
|
41097
|
-
};
|
|
40979
|
+
const spawnPass = () => spawnLintBatches({
|
|
40980
|
+
baseArgs: passBaseArgs,
|
|
40981
|
+
fileBatches: passFileBatches,
|
|
40982
|
+
rootDirectory,
|
|
40983
|
+
nodeBinaryPath,
|
|
40984
|
+
project,
|
|
40985
|
+
onPartialFailure: reportPartialFailure,
|
|
40986
|
+
onFileProgress: fileProgress,
|
|
40987
|
+
spawnTimeoutMs,
|
|
40988
|
+
outputMaxBytes,
|
|
40989
|
+
concurrency: options.concurrency,
|
|
40990
|
+
signal: options.signal,
|
|
40991
|
+
deadlineEpochMs: options.deadlineEpochMs
|
|
40992
|
+
});
|
|
41098
40993
|
writeOxlintConfig(passConfigPath, buildConfigForPass({}));
|
|
41099
40994
|
try {
|
|
41100
40995
|
return {
|
|
41101
40996
|
diagnostics: await spawnPass(),
|
|
41102
|
-
analyzedFiles,
|
|
41103
40997
|
didDropReactHooksJsPlugin: false,
|
|
41104
40998
|
hadPartialFailure
|
|
41105
40999
|
};
|
|
@@ -41111,7 +41005,6 @@ const runOxlint = async (options) => {
|
|
|
41111
41005
|
reportPartialFailure(reactHooksJsDropNote);
|
|
41112
41006
|
return {
|
|
41113
41007
|
diagnostics,
|
|
41114
|
-
analyzedFiles,
|
|
41115
41008
|
didDropReactHooksJsPlugin: true,
|
|
41116
41009
|
hadPartialFailure
|
|
41117
41010
|
};
|
|
@@ -41187,7 +41080,6 @@ const runOxlint = async (options) => {
|
|
|
41187
41080
|
const missFileSet = new Set(missFiles);
|
|
41188
41081
|
const hitFiles = candidateFiles.filter((candidateFile) => !missFileSet.has(candidateFile));
|
|
41189
41082
|
const sidecarReplayedDiagnostics = [];
|
|
41190
|
-
const sidecarReplayedFiles = [];
|
|
41191
41083
|
const sidecarLintFiles = [];
|
|
41192
41084
|
if (sidecarCache === null) sidecarLintFiles.push(...hitFiles);
|
|
41193
41085
|
else {
|
|
@@ -41195,10 +41087,8 @@ const runOxlint = async (options) => {
|
|
|
41195
41087
|
for (const hitFile of hitFiles) {
|
|
41196
41088
|
const cacheKey = cacheKeyByFile.get(hitFile);
|
|
41197
41089
|
const entry = cacheKey === void 0 ? null : sidecarCache.lookup(cacheKey);
|
|
41198
|
-
if (entry !== null && entry.probes.every((probe) => probeAnswers.answerFor(probe.kind, probe.path) === probe.answer))
|
|
41199
|
-
|
|
41200
|
-
sidecarReplayedDiagnostics.push(...entry.diagnostics);
|
|
41201
|
-
} else sidecarLintFiles.push(hitFile);
|
|
41090
|
+
if (entry !== null && entry.probes.every((probe) => probeAnswers.answerFor(probe.kind, probe.path) === probe.answer)) sidecarReplayedDiagnostics.push(...entry.diagnostics);
|
|
41091
|
+
else sidecarLintFiles.push(hitFile);
|
|
41202
41092
|
if (performance.now() - verifySliceStartedAt >= 12) {
|
|
41203
41093
|
await yieldToEventLoop();
|
|
41204
41094
|
verifySliceStartedAt = performance.now();
|
|
@@ -41224,7 +41114,6 @@ const runOxlint = async (options) => {
|
|
|
41224
41114
|
sidecarRuleIdFilter: new Set(unboundedSidecarRuleIds)
|
|
41225
41115
|
}), "oxlintrc.sidecar-unbounded.json", hitFiles, void 0) : {
|
|
41226
41116
|
diagnostics: [],
|
|
41227
|
-
analyzedFiles: [],
|
|
41228
41117
|
didDropReactHooksJsPlugin: false,
|
|
41229
41118
|
hadPartialFailure: false
|
|
41230
41119
|
};
|
|
@@ -41255,15 +41144,6 @@ const runOxlint = async (options) => {
|
|
|
41255
41144
|
probesByFile: await missProbesTask
|
|
41256
41145
|
}]
|
|
41257
41146
|
});
|
|
41258
|
-
const analyzedFileSet = new Set(fullResult.analyzedFiles);
|
|
41259
|
-
const boundedSidecarAnalyzedFileSet = new Set(boundedSidecarResult.analyzedFiles);
|
|
41260
|
-
const unboundedSidecarAnalyzedFileSet = new Set(unboundedSidecarResult.analyzedFiles);
|
|
41261
|
-
const sidecarReplayedFileSet = new Set(sidecarReplayedFiles);
|
|
41262
|
-
for (const hitFile of hitFiles) if (useSidecarCache ? (sidecarReplayedFileSet.has(hitFile) || boundedSidecarAnalyzedFileSet.has(hitFile)) && (unboundedSidecarRuleIds.length === 0 || unboundedSidecarAnalyzedFileSet.has(hitFile)) : boundedSidecarAnalyzedFileSet.has(hitFile)) analyzedFileSet.add(hitFile);
|
|
41263
|
-
onFileCoverage?.({
|
|
41264
|
-
candidateFiles,
|
|
41265
|
-
analyzedFiles: candidateFiles.filter((candidateFile) => analyzedFileSet.has(candidateFile))
|
|
41266
|
-
});
|
|
41267
41147
|
return dedupeDiagnostics([
|
|
41268
41148
|
...replayedDiagnostics,
|
|
41269
41149
|
...fullResult.diagnostics,
|
|
@@ -41274,7 +41154,6 @@ const runOxlint = async (options) => {
|
|
|
41274
41154
|
}
|
|
41275
41155
|
const baseArgs = makeBaseArgs(configPath);
|
|
41276
41156
|
const fileBatches = buildFileBatches(baseArgs, candidateFiles);
|
|
41277
|
-
let analyzedFiles = [];
|
|
41278
41157
|
const runBatches = () => spawnLintBatches({
|
|
41279
41158
|
baseArgs,
|
|
41280
41159
|
fileBatches,
|
|
@@ -41282,9 +41161,6 @@ const runOxlint = async (options) => {
|
|
|
41282
41161
|
nodeBinaryPath,
|
|
41283
41162
|
project,
|
|
41284
41163
|
onPartialFailure,
|
|
41285
|
-
onAnalyzedFiles: (filePaths) => {
|
|
41286
|
-
analyzedFiles = filePaths;
|
|
41287
|
-
},
|
|
41288
41164
|
onFileProgress: options.onFileProgress,
|
|
41289
41165
|
spawnTimeoutMs,
|
|
41290
41166
|
outputMaxBytes,
|
|
@@ -41294,12 +41170,7 @@ const runOxlint = async (options) => {
|
|
|
41294
41170
|
});
|
|
41295
41171
|
writeOxlintConfig(configPath, buildConfig({ extendsPaths }));
|
|
41296
41172
|
try {
|
|
41297
|
-
|
|
41298
|
-
onFileCoverage?.({
|
|
41299
|
-
candidateFiles,
|
|
41300
|
-
analyzedFiles
|
|
41301
|
-
});
|
|
41302
|
-
return diagnostics;
|
|
41173
|
+
return await runBatches();
|
|
41303
41174
|
} catch (error) {
|
|
41304
41175
|
const reactHooksJsDropNote = reactHooksJsPluginDropNote(error);
|
|
41305
41176
|
if (reactHooksJsDropNote !== null) {
|
|
@@ -41309,20 +41180,11 @@ const runOxlint = async (options) => {
|
|
|
41309
41180
|
}));
|
|
41310
41181
|
const diagnostics = await runBatches();
|
|
41311
41182
|
onPartialFailure?.(reactHooksJsDropNote);
|
|
41312
|
-
onFileCoverage?.({
|
|
41313
|
-
candidateFiles,
|
|
41314
|
-
analyzedFiles
|
|
41315
|
-
});
|
|
41316
41183
|
return diagnostics;
|
|
41317
41184
|
}
|
|
41318
41185
|
if (extendsPaths.length === 0) throw error;
|
|
41319
41186
|
writeOxlintConfig(configPath, buildConfig({ extendsPaths: [] }));
|
|
41320
|
-
|
|
41321
|
-
onFileCoverage?.({
|
|
41322
|
-
candidateFiles,
|
|
41323
|
-
analyzedFiles
|
|
41324
|
-
});
|
|
41325
|
-
return diagnostics;
|
|
41187
|
+
return await runBatches();
|
|
41326
41188
|
}
|
|
41327
41189
|
} finally {
|
|
41328
41190
|
restoreDisableDirectives();
|
|
@@ -41402,7 +41264,6 @@ var Linter = class Linter extends Service()("react-doctor/Linter") {
|
|
|
41402
41264
|
onPartialFailure: (reason) => {
|
|
41403
41265
|
collectedFailures.push(reason);
|
|
41404
41266
|
},
|
|
41405
|
-
onFileCoverage: input.onFileCoverage,
|
|
41406
41267
|
onFileProgress: input.onFileProgress,
|
|
41407
41268
|
perFileLintCacheEnabled,
|
|
41408
41269
|
sidecarLintCacheEnabled,
|
|
@@ -42110,7 +41971,6 @@ const resolveGithubActionsScoreMetadata = (environment = process.env) => {
|
|
|
42110
41971
|
...actorAssociation !== void 0 ? { githubActorAssociation: actorAssociation } : {}
|
|
42111
41972
|
};
|
|
42112
41973
|
};
|
|
42113
|
-
const toNormalizedRelativePath = (filePath, rootDirectory) => Path.relative(Path.resolve(rootDirectory), Path.resolve(rootDirectory, filePath)).replaceAll("\\", "/") || ".";
|
|
42114
41974
|
const NO_HOOKS = {
|
|
42115
41975
|
beforeLint: () => void_,
|
|
42116
41976
|
afterLint: () => void_
|
|
@@ -42209,7 +42069,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42209
42069
|
repo
|
|
42210
42070
|
}).pipe(orElseSucceed(() => null)) : succeed$2(null));
|
|
42211
42071
|
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
|
|
42212
|
-
const
|
|
42072
|
+
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => Path.resolve(scanDirectory, relativePath)) : [];
|
|
42213
42073
|
const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
|
|
42214
42074
|
const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
|
|
42215
42075
|
yield* beforeLint(project, lintIncludePaths ?? void 0);
|
|
@@ -42314,7 +42174,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42314
42174
|
let deadCodeCacheHit = null;
|
|
42315
42175
|
let deadCodeSummaryCacheHits = null;
|
|
42316
42176
|
let deadCodeSummaryCacheMisses = null;
|
|
42317
|
-
const lintFileCoverageState = { value: null };
|
|
42318
42177
|
const baseLintStream = linterService.run({
|
|
42319
42178
|
rootDirectory: scanDirectory,
|
|
42320
42179
|
project,
|
|
@@ -42330,9 +42189,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42330
42189
|
lastReportedTotalFileCount = totalFileCount;
|
|
42331
42190
|
runSync(scanProgress.update(`Scanning files (${scannedFileCount}/${totalFileCount})${workerCountSuffix}...`));
|
|
42332
42191
|
},
|
|
42333
|
-
onFileCoverage: (coverage) => {
|
|
42334
|
-
lintFileCoverageState.value = coverage;
|
|
42335
|
-
},
|
|
42336
42192
|
onCacheStats: (cacheHitFileCount, totalConsideredFileCount) => {
|
|
42337
42193
|
lintCacheHitFileCount = cacheHitFileCount;
|
|
42338
42194
|
lintCacheTotalFileCount = totalConsideredFileCount;
|
|
@@ -42363,10 +42219,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42363
42219
|
const lintFailureState = yield* get$2(lintFailure);
|
|
42364
42220
|
yield* afterLint(lintFailureState.didFail);
|
|
42365
42221
|
if (lintFailureState.didFail) yield* scanProgress.fail(formatLintFailText(lintFailureState.reasonTag, process.version));
|
|
42366
|
-
const
|
|
42367
|
-
const analyzedFiles = lintFileCoverageState.value === null ? [] : [...new Set(lintFileCoverageState.value.analyzedFiles.map((filePath) => toNormalizedRelativePath(filePath, scanDirectory)))].sort();
|
|
42368
|
-
const totalFileCount = candidateFiles.length || lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
|
|
42369
|
-
const scannedFilePaths = input.suppressScanSummary ? candidateFiles.length > 0 ? candidateFiles.map((filePath) => Path.resolve(scanDirectory, filePath)) : fallbackScannedFilePaths : [];
|
|
42222
|
+
const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
|
|
42370
42223
|
const scannedFilesLabel = `${totalFileCount} ${totalFileCount === 1 ? "file" : "files"}`;
|
|
42371
42224
|
let deadCodeCollected = [];
|
|
42372
42225
|
if (lintFailureState.didFail) {
|
|
@@ -42448,7 +42301,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42448
42301
|
deadCodeOverlapped: shouldOverlapDeadCode,
|
|
42449
42302
|
scannedFileCount: totalFileCount,
|
|
42450
42303
|
scannedFilePaths,
|
|
42451
|
-
analyzedFiles,
|
|
42452
42304
|
scanElapsedMilliseconds,
|
|
42453
42305
|
scanConcurrency,
|
|
42454
42306
|
supplyChainOverlapTimedOut: supplyChainResult.timedOut,
|
|
@@ -42700,7 +42552,7 @@ const buildJsonReportError = (input) => {
|
|
|
42700
42552
|
sentryEventId
|
|
42701
42553
|
};
|
|
42702
42554
|
return {
|
|
42703
|
-
schemaVersion:
|
|
42555
|
+
schemaVersion: 1,
|
|
42704
42556
|
version: input.version,
|
|
42705
42557
|
ok: false,
|
|
42706
42558
|
directory: input.directory,
|
|
@@ -42745,7 +42597,6 @@ const summarizeDiagnostics = (diagnostics, worstScore = null, worstScoreLabel =
|
|
|
42745
42597
|
* React-runtime rule family was gated off for the project.
|
|
42746
42598
|
*/
|
|
42747
42599
|
const hasReactRuntime = (project) => project.reactVersion !== null || project.preactVersion !== null;
|
|
42748
|
-
const isScanComplete = (input) => input.analyzedFileCount !== void 0 && input.scannedFileCount !== void 0 && input.skippedCheckCount === 0 && input.skippedCheckReasonCount === 0 && input.analyzedFileCount === input.scannedFileCount;
|
|
42749
42600
|
const toJsonDiff = (diff) => {
|
|
42750
42601
|
if (!diff) return null;
|
|
42751
42602
|
return {
|
|
@@ -42768,68 +42619,21 @@ const findWorstScoredProject = (projects) => {
|
|
|
42768
42619
|
}
|
|
42769
42620
|
return worst;
|
|
42770
42621
|
};
|
|
42771
|
-
const toJsonReportDiagnostic = (diagnostic, projectRoot, reportRoot) => {
|
|
42772
|
-
const normalizedFilePath = toNormalizedRelativePath(diagnostic.filePath, projectRoot);
|
|
42773
|
-
const reportRelativeFilePath = toNormalizedRelativePath(Path.resolve(projectRoot, diagnostic.filePath), reportRoot);
|
|
42774
|
-
const ruleIdentity = getDiagnosticRuleIdentity(diagnostic);
|
|
42775
|
-
return {
|
|
42776
|
-
...diagnostic,
|
|
42777
|
-
id: buildDiagnosticIdentity({
|
|
42778
|
-
filePath: reportRelativeFilePath,
|
|
42779
|
-
line: diagnostic.line,
|
|
42780
|
-
column: diagnostic.column,
|
|
42781
|
-
plugin: diagnostic.plugin,
|
|
42782
|
-
rule: diagnostic.rule
|
|
42783
|
-
}),
|
|
42784
|
-
normalizedFilePath,
|
|
42785
|
-
category: ruleIdentity.category,
|
|
42786
|
-
tags: [...new Set(ruleIdentity.tags)].sort()
|
|
42787
|
-
};
|
|
42788
|
-
};
|
|
42789
42622
|
const buildJsonReport = (input) => {
|
|
42790
|
-
const projects = input.scans.map(({ directory, result }) => {
|
|
42791
|
-
|
|
42792
|
-
|
|
42793
|
-
|
|
42794
|
-
|
|
42795
|
-
|
|
42796
|
-
|
|
42797
|
-
|
|
42798
|
-
|
|
42799
|
-
|
|
42800
|
-
score: result.score,
|
|
42801
|
-
skippedChecks,
|
|
42802
|
-
...result.skippedCheckReasons ? { skippedCheckReasons: result.skippedCheckReasons } : {},
|
|
42803
|
-
analyzedFiles,
|
|
42804
|
-
analyzedFileCount: analyzedFiles.length,
|
|
42805
|
-
complete: isScanComplete({
|
|
42806
|
-
analyzedFileCount: result.analyzedFiles === void 0 ? void 0 : analyzedFiles.length,
|
|
42807
|
-
scannedFileCount,
|
|
42808
|
-
skippedCheckCount: skippedChecks.length,
|
|
42809
|
-
skippedCheckReasonCount: Object.keys(result.skippedCheckReasons ?? {}).length
|
|
42810
|
-
}),
|
|
42811
|
-
...typeof result.scannedFileCount === "number" ? { scannedFileCount } : {},
|
|
42812
|
-
elapsedMilliseconds: result.elapsedMilliseconds
|
|
42813
|
-
};
|
|
42814
|
-
});
|
|
42623
|
+
const projects = input.scans.map(({ directory, result }) => ({
|
|
42624
|
+
directory,
|
|
42625
|
+
project: result.project,
|
|
42626
|
+
diagnostics: result.diagnostics,
|
|
42627
|
+
score: result.score,
|
|
42628
|
+
skippedChecks: result.skippedChecks,
|
|
42629
|
+
...result.skippedCheckReasons ? { skippedCheckReasons: result.skippedCheckReasons } : {},
|
|
42630
|
+
...typeof result.scannedFileCount === "number" ? { scannedFileCount: result.scannedFileCount } : {},
|
|
42631
|
+
elapsedMilliseconds: result.elapsedMilliseconds
|
|
42632
|
+
}));
|
|
42815
42633
|
const flattenedDiagnostics = projects.flatMap((entry) => entry.diagnostics);
|
|
42816
42634
|
const worstScoredProject = findWorstScoredProject(projects);
|
|
42817
|
-
const
|
|
42818
|
-
const
|
|
42819
|
-
const summary = {
|
|
42820
|
-
...diagnosticSummary,
|
|
42821
|
-
affectedFileCount
|
|
42822
|
-
};
|
|
42823
|
-
return {
|
|
42824
|
-
schemaVersion: 3,
|
|
42825
|
-
mode: input.baseline !== void 0 ? "baseline" : input.baselineDegraded && input.mode === "baseline" ? "diff" : input.mode,
|
|
42826
|
-
...input.baseline ? { baseline: {
|
|
42827
|
-
baseRef: input.baseline.baseRef,
|
|
42828
|
-
newCount: summary.totalDiagnosticCount,
|
|
42829
|
-
fixedCount: input.baseline.fixedCount,
|
|
42830
|
-
baseTotalCount: input.baseline.baseTotalCount
|
|
42831
|
-
} } : {},
|
|
42832
|
-
...input.baselineDegraded ? { baselineDegraded: true } : {},
|
|
42635
|
+
const summary = summarizeDiagnostics(flattenedDiagnostics, worstScoredProject?.score?.score ?? null, worstScoredProject?.score?.label ?? null);
|
|
42636
|
+
const shared = {
|
|
42833
42637
|
...input.scans.length > 0 ? { reactDetected: input.scans.some((scan) => hasReactRuntime(scan.result.project)) } : {},
|
|
42834
42638
|
version: input.version,
|
|
42835
42639
|
ok: true,
|
|
@@ -42841,26 +42645,39 @@ const buildJsonReport = (input) => {
|
|
|
42841
42645
|
elapsedMilliseconds: input.totalElapsedMilliseconds,
|
|
42842
42646
|
error: null
|
|
42843
42647
|
};
|
|
42648
|
+
if (input.baseline) return {
|
|
42649
|
+
schemaVersion: 2,
|
|
42650
|
+
mode: "baseline",
|
|
42651
|
+
baseline: {
|
|
42652
|
+
baseRef: input.baseline.baseRef,
|
|
42653
|
+
newCount: summary.totalDiagnosticCount,
|
|
42654
|
+
fixedCount: input.baseline.fixedCount,
|
|
42655
|
+
baseTotalCount: input.baseline.baseTotalCount
|
|
42656
|
+
},
|
|
42657
|
+
...shared
|
|
42658
|
+
};
|
|
42659
|
+
return {
|
|
42660
|
+
schemaVersion: 1,
|
|
42661
|
+
mode: input.mode,
|
|
42662
|
+
...input.baselineDegraded ? { baselineDegraded: true } : {},
|
|
42663
|
+
...shared
|
|
42664
|
+
};
|
|
42844
42665
|
};
|
|
42845
42666
|
/**
|
|
42846
42667
|
* Single source of truth for the skipped-check accounting shared by the
|
|
42847
42668
|
* CLI renderer (`react-doctor/src/inspect.ts → finalizeAndRender`) and the
|
|
42848
42669
|
* programmatic shell (`@react-doctor/api → diagnose()`). Both surface a
|
|
42849
|
-
* failed
|
|
42670
|
+
* failed lint / dead-code pass instead of a false "all clear", so the
|
|
42850
42671
|
* branch logic lives here once.
|
|
42851
42672
|
*/
|
|
42852
42673
|
const buildSkippedChecks = (input) => {
|
|
42853
42674
|
const skippedChecks = [];
|
|
42854
42675
|
if (input.didLintFail) skippedChecks.push("lint");
|
|
42855
42676
|
if (input.didDeadCodeFail) skippedChecks.push("dead-code");
|
|
42856
|
-
if (input.supplyChainOverlapTimedOut) skippedChecks.push("supply-chain");
|
|
42857
|
-
if (input.securityScanFailed) skippedChecks.push("security-scan");
|
|
42858
42677
|
const skippedCheckReasons = {};
|
|
42859
42678
|
if (input.didLintFail && input.lintFailureReason !== null) skippedCheckReasons.lint = input.lintFailureReason;
|
|
42860
42679
|
else if (input.lintPartialFailures.length > 0) skippedCheckReasons["lint:partial"] = input.lintPartialFailures.join("; ");
|
|
42861
42680
|
if (input.didDeadCodeFail && input.deadCodeFailureReason !== null) skippedCheckReasons["dead-code"] = input.deadCodeFailureReason;
|
|
42862
|
-
if (input.supplyChainOverlapTimedOut) skippedCheckReasons["supply-chain"] = "Supply-chain analysis timed out and was skipped.";
|
|
42863
|
-
if (input.securityScanFailed) skippedCheckReasons["security-scan"] = "Security scan failed and was skipped.";
|
|
42864
42681
|
return {
|
|
42865
42682
|
skippedChecks,
|
|
42866
42683
|
skippedCheckReasons
|
|
@@ -43049,8 +42866,6 @@ const outputToDiagnoseResult = (output, elapsedMilliseconds) => {
|
|
|
43049
42866
|
score: output.score,
|
|
43050
42867
|
skippedChecks,
|
|
43051
42868
|
...Object.keys(skippedCheckReasons).length > 0 ? { skippedCheckReasons } : {},
|
|
43052
|
-
analyzedFiles: output.analyzedFiles,
|
|
43053
|
-
scannedFileCount: output.scannedFileCount,
|
|
43054
42869
|
project: output.project,
|
|
43055
42870
|
reactDetected: hasReactRuntime(output.project),
|
|
43056
42871
|
elapsedMilliseconds
|
|
@@ -43160,8 +42975,6 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
43160
42975
|
score: result.score,
|
|
43161
42976
|
skippedChecks: result.skippedChecks,
|
|
43162
42977
|
...result.skippedCheckReasons ? { skippedCheckReasons: result.skippedCheckReasons } : {},
|
|
43163
|
-
...result.analyzedFiles ? { analyzedFiles: result.analyzedFiles } : {},
|
|
43164
|
-
...typeof result.scannedFileCount === "number" ? { scannedFileCount: result.scannedFileCount } : {},
|
|
43165
42978
|
project: result.project,
|
|
43166
42979
|
elapsedMilliseconds: result.elapsedMilliseconds
|
|
43167
42980
|
}
|
|
@@ -43172,4 +42985,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
43172
42985
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
43173
42986
|
|
|
43174
42987
|
//# sourceMappingURL=index.js.map
|
|
43175
|
-
//# debugId=
|
|
42988
|
+
//# debugId=e5be91b0-fb63-5b7d-849e-60c4e4eb96b2
|