react-doctor 0.5.5 → 0.5.6-dev.0053a02
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +74 -29
- package/dist/index.d.ts +4 -3
- package/dist/index.js +65 -20
- package/dist/lsp.js +66 -21
- package/package.json +5 -5
package/dist/cli.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]="d18dc59a-0744-5f52-ae2e-98fddb52ed49")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as NodeChildProcess from "node:child_process";
|
|
5
5
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
@@ -39740,13 +39740,24 @@ const checkSecurityScan = (rootDirectory, options = {}) => {
|
|
|
39740
39740
|
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledBy)) return [];
|
|
39741
39741
|
return [{
|
|
39742
39742
|
entry,
|
|
39743
|
-
scan
|
|
39743
|
+
scan,
|
|
39744
|
+
committedFilesOnly: rule.committedFilesOnly === true
|
|
39744
39745
|
}];
|
|
39745
39746
|
});
|
|
39746
39747
|
if (enabledScanRules.length === 0) return [];
|
|
39747
39748
|
const diagnostics = [];
|
|
39748
39749
|
const seen = /* @__PURE__ */ new Set();
|
|
39749
|
-
|
|
39750
|
+
const gitIgnoredCache = /* @__PURE__ */ new Map();
|
|
39751
|
+
const isFileGitIgnored = (file) => {
|
|
39752
|
+
let status = gitIgnoredCache.get(file.absolutePath);
|
|
39753
|
+
if (status === void 0) {
|
|
39754
|
+
status = isPathGitIgnored(rootDirectory, file.absolutePath);
|
|
39755
|
+
gitIgnoredCache.set(file.absolutePath, status);
|
|
39756
|
+
}
|
|
39757
|
+
return status === true;
|
|
39758
|
+
};
|
|
39759
|
+
for (const file of collectSecurityScanFiles(rootDirectory)) for (const { entry, scan, committedFilesOnly } of enabledScanRules) for (const finding of scan(file)) {
|
|
39760
|
+
if (committedFilesOnly && isFileGitIgnored(file)) continue;
|
|
39750
39761
|
const diagnostic = buildSecurityScanDiagnostic(finding, entry, file.relativePath);
|
|
39751
39762
|
const key = `${diagnostic.rule}:${diagnostic.filePath}:${diagnostic.line}:${diagnostic.column}:${diagnostic.message}`;
|
|
39752
39763
|
if (seen.has(key)) continue;
|
|
@@ -39975,12 +39986,11 @@ const collectKnipPatterns = (rootDirectory, settingName) => {
|
|
|
39975
39986
|
if (!config) return [];
|
|
39976
39987
|
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
39977
39988
|
};
|
|
39978
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory
|
|
39989
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory) => {
|
|
39979
39990
|
const seen = /* @__PURE__ */ new Set();
|
|
39980
39991
|
const sources = [
|
|
39981
39992
|
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
39982
39993
|
collectIgnorePatterns(rootDirectory),
|
|
39983
|
-
userConfig?.ignore?.files ?? [],
|
|
39984
39994
|
collectKnipPatterns(rootDirectory, "ignore")
|
|
39985
39995
|
];
|
|
39986
39996
|
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
@@ -40258,11 +40268,10 @@ const runDeadCodeWorkerWithTimeout = (handle, timeoutMs) => new Promise((resolve
|
|
|
40258
40268
|
});
|
|
40259
40269
|
});
|
|
40260
40270
|
const checkDeadCode = async (options) => {
|
|
40261
|
-
const { userConfig } = options;
|
|
40262
40271
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
40263
40272
|
if (!NFS.existsSync(Path.join(rootDirectory, "package.json"))) return [];
|
|
40264
40273
|
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
40265
|
-
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory
|
|
40274
|
+
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
40266
40275
|
const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
|
|
40267
40276
|
rootDirectory,
|
|
40268
40277
|
entryPatterns,
|
|
@@ -41311,8 +41320,8 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
41311
41320
|
}
|
|
41312
41321
|
return enabled;
|
|
41313
41322
|
};
|
|
41314
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [] }) => {
|
|
41315
|
-
const reactHooksJsPlugin = resolveReactHooksJsPlugin(project.hasReactCompiler, customRulesOnly);
|
|
41323
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false }) => {
|
|
41324
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin ? null : resolveReactHooksJsPlugin(project.hasReactCompiler, customRulesOnly);
|
|
41316
41325
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
41317
41326
|
const jsPlugins = [];
|
|
41318
41327
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -42009,9 +42018,9 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
42009
42018
|
try {
|
|
42010
42019
|
parsed = JSON.parse(sanitizedStdout);
|
|
42011
42020
|
} catch {
|
|
42012
|
-
throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0,
|
|
42021
|
+
throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
|
|
42013
42022
|
}
|
|
42014
|
-
if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0,
|
|
42023
|
+
if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
|
|
42015
42024
|
const minifiedFileCache = /* @__PURE__ */ new Map();
|
|
42016
42025
|
const isMinifiedDiagnosticFile = (filename) => {
|
|
42017
42026
|
const absolutePath = Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
|
|
@@ -42302,6 +42311,28 @@ const writeOxlintConfig = (configPath, configToWrite) => {
|
|
|
42302
42311
|
NFS.closeSync(fileHandle);
|
|
42303
42312
|
}
|
|
42304
42313
|
};
|
|
42314
|
+
const REACT_HOOKS_JS_DROP_PREFIX = "React Compiler rules (react-hooks-js/*) skipped — eslint-plugin-react-hooks failed to load in this environment";
|
|
42315
|
+
/**
|
|
42316
|
+
* Detects an oxlint config-load crash caused by the optional
|
|
42317
|
+
* `react-hooks-js` (eslint-plugin-react-hooks) React Compiler plugin and
|
|
42318
|
+
* builds the partial-failure note for it; returns `null` when the failure
|
|
42319
|
+
* was anything else.
|
|
42320
|
+
*
|
|
42321
|
+
* oxlint prints a framed error to stdout (not stderr) and exits non-zero
|
|
42322
|
+
* when a `jsPlugins` entry can't be imported; that non-JSON stdout
|
|
42323
|
+
* surfaces as `OxlintOutputUnparseable`. Because oxlint fails the WHOLE
|
|
42324
|
+
* config load on it, leaving the plugin in would drop every curated
|
|
42325
|
+
* react-doctor diagnostic too — so the caller retries with the plugin
|
|
42326
|
+
* stripped (issue #833). Both markers sit at the start of oxlint's
|
|
42327
|
+
* message, so they survive the `preview` slice even for deep pnpm paths.
|
|
42328
|
+
*/
|
|
42329
|
+
const reactHooksJsPluginDropNote = (error) => {
|
|
42330
|
+
if (!(error instanceof ReactDoctorError) || error.reason._tag !== "OxlintOutputUnparseable") return null;
|
|
42331
|
+
const { preview } = error.reason;
|
|
42332
|
+
if (!preview.includes("Failed to load JS plugin") || !preview.includes("eslint-plugin-react-hooks")) return null;
|
|
42333
|
+
const underlyingReason = preview.match(/Error:[^\n]*/)?.[0]?.trim();
|
|
42334
|
+
return `${REACT_HOOKS_JS_DROP_PREFIX}${underlyingReason ? `: ${underlyingReason}` : ""}. Other rules ran normally.`;
|
|
42335
|
+
};
|
|
42305
42336
|
/**
|
|
42306
42337
|
* The oxlint runner. Composed of three pieces in `runners/oxlint/`:
|
|
42307
42338
|
*
|
|
@@ -42329,15 +42360,16 @@ const runOxlint = async (options) => {
|
|
|
42329
42360
|
const pluginPath = resolvePluginPath();
|
|
42330
42361
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
42331
42362
|
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
42332
|
-
const buildConfig = (
|
|
42363
|
+
const buildConfig = (overrides) => createOxlintConfig({
|
|
42333
42364
|
pluginPath,
|
|
42334
42365
|
project,
|
|
42335
42366
|
customRulesOnly,
|
|
42336
|
-
extendsPaths:
|
|
42367
|
+
extendsPaths: overrides.extendsPaths,
|
|
42337
42368
|
ignoredTags,
|
|
42338
42369
|
serverAuthFunctionNames,
|
|
42339
42370
|
severityControls,
|
|
42340
|
-
userPlugins
|
|
42371
|
+
userPlugins,
|
|
42372
|
+
disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin
|
|
42341
42373
|
});
|
|
42342
42374
|
const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
|
|
42343
42375
|
const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
@@ -42373,12 +42405,22 @@ const runOxlint = async (options) => {
|
|
|
42373
42405
|
outputMaxBytes,
|
|
42374
42406
|
concurrency: options.concurrency
|
|
42375
42407
|
});
|
|
42376
|
-
writeOxlintConfig(configPath, buildConfig(extendsPaths));
|
|
42408
|
+
writeOxlintConfig(configPath, buildConfig({ extendsPaths }));
|
|
42377
42409
|
try {
|
|
42378
42410
|
return await runBatches();
|
|
42379
42411
|
} catch (error) {
|
|
42412
|
+
const reactHooksJsDropNote = reactHooksJsPluginDropNote(error);
|
|
42413
|
+
if (reactHooksJsDropNote !== null) {
|
|
42414
|
+
writeOxlintConfig(configPath, buildConfig({
|
|
42415
|
+
extendsPaths,
|
|
42416
|
+
disableReactHooksJsPlugin: true
|
|
42417
|
+
}));
|
|
42418
|
+
const diagnostics = await runBatches();
|
|
42419
|
+
onPartialFailure?.(reactHooksJsDropNote);
|
|
42420
|
+
return diagnostics;
|
|
42421
|
+
}
|
|
42380
42422
|
if (extendsPaths.length === 0) throw error;
|
|
42381
|
-
writeOxlintConfig(configPath, buildConfig([]));
|
|
42423
|
+
writeOxlintConfig(configPath, buildConfig({ extendsPaths: [] }));
|
|
42382
42424
|
return await runBatches();
|
|
42383
42425
|
}
|
|
42384
42426
|
} finally {
|
|
@@ -42773,6 +42815,8 @@ const resolveConcreteVersion = (spec) => {
|
|
|
42773
42815
|
const trimmed = spec.trim();
|
|
42774
42816
|
if (trimmed.length === 0) return null;
|
|
42775
42817
|
if (trimmed.includes(":")) return null;
|
|
42818
|
+
const range = import_semver.validRange(trimmed);
|
|
42819
|
+
if (range === null || range === "*") return null;
|
|
42776
42820
|
return import_semver.minVersion(trimmed)?.version ?? null;
|
|
42777
42821
|
};
|
|
42778
42822
|
const locateDependencyKey = (packageJsonText, section, name) => {
|
|
@@ -43159,8 +43203,10 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
43159
43203
|
const lintFailureState = yield* get$2(lintFailure);
|
|
43160
43204
|
yield* afterLint(lintFailureState.didFail);
|
|
43161
43205
|
if (lintFailureState.didFail) yield* scanProgress.fail(formatLintFailText(lintFailureState.reasonTag, process.version));
|
|
43206
|
+
const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
|
|
43207
|
+
const scannedFilesLabel = `${totalFileCount} ${totalFileCount === 1 ? "file" : "files"}`;
|
|
43162
43208
|
const shouldRunDeadCode = input.runDeadCode && !isDiffMode && (showWarnings || deadCodeMaySurfaceWhenWarningsHidden(resolvedConfig.config));
|
|
43163
|
-
const deadCodeCollected = lintFailureState.didFail || !shouldRunDeadCode ? [] : yield* scanProgress.update(
|
|
43209
|
+
const deadCodeCollected = lintFailureState.didFail || !shouldRunDeadCode ? [] : yield* scanProgress.update(`Scanned ${scannedFilesLabel}, analyzing dead code...`).pipe(andThen(runCollect(applyPerElementPipeline(deadCodeService.run({
|
|
43164
43210
|
rootDirectory: scanDirectory,
|
|
43165
43211
|
userConfig: resolvedConfig.config
|
|
43166
43212
|
}).pipe(catchTag("ReactDoctorError", (error) => unwrap(gen(function* () {
|
|
@@ -43173,10 +43219,9 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
43173
43219
|
const deadCodeFailureState = yield* get$2(deadCodeFailure);
|
|
43174
43220
|
const scanElapsedMilliseconds = Date.now() - scanStartTime;
|
|
43175
43221
|
const scanElapsedSeconds = (scanElapsedMilliseconds / 1e3).toFixed(1);
|
|
43176
|
-
const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
|
|
43177
43222
|
if (!lintFailureState.didFail) if (deadCodeFailureState.didFail) yield* scanProgress.fail(DEAD_CODE_FAIL_TEXT);
|
|
43178
43223
|
else if (input.suppressScanSummary) yield* scanProgress.stop();
|
|
43179
|
-
else yield* scanProgress.succeed(`Scanned ${
|
|
43224
|
+
else yield* scanProgress.succeed(`Scanned ${scannedFilesLabel} in ${scanElapsedSeconds}s${workerCountSuffix}`);
|
|
43180
43225
|
yield* reporterService.finalize;
|
|
43181
43226
|
const finalDiagnostics = [
|
|
43182
43227
|
...envCollected,
|
|
@@ -43958,7 +44003,7 @@ const makeNoopConsole = () => ({
|
|
|
43958
44003
|
});
|
|
43959
44004
|
//#endregion
|
|
43960
44005
|
//#region src/cli/utils/version.ts
|
|
43961
|
-
const VERSION = "0.5.
|
|
44006
|
+
const VERSION = "0.5.6-dev.0053a02";
|
|
43962
44007
|
//#endregion
|
|
43963
44008
|
//#region src/cli/utils/json-mode.ts
|
|
43964
44009
|
let context = null;
|
|
@@ -44316,13 +44361,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
44316
44361
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
44317
44362
|
* standard `SENTRY_RELEASE` override.
|
|
44318
44363
|
*/
|
|
44319
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.
|
|
44364
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.6-dev.0053a02`;
|
|
44320
44365
|
/**
|
|
44321
44366
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
44322
44367
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
44323
44368
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
44324
44369
|
*/
|
|
44325
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.
|
|
44370
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.6-dev.0053a02") ? "development" : "production");
|
|
44326
44371
|
/**
|
|
44327
44372
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
44328
44373
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -48104,7 +48149,7 @@ const AGENT_GUIDANCE_LINES = [
|
|
|
48104
48149
|
"Investigate deeply where relevant: race conditions, security-sensitive flows, state propagation, multi-file refactors, and downstream dependency chains.",
|
|
48105
48150
|
"Ignore pure style preferences, theoretical issues without real impact, missing features, and unrelated pre-existing code.",
|
|
48106
48151
|
"Start with high-confidence fixes that preserve behavior. Leave low-confidence or product-dependent changes as notes.",
|
|
48107
|
-
"Run `npx react-doctor@latest --verbose --
|
|
48152
|
+
"Run `npx react-doctor@latest --verbose --scope changed` before and after changes, plus relevant tests after each focused batch.",
|
|
48108
48153
|
"When available, spawn subagents or isolated worktrees for independent rule families, then review and merge only the best safe fixes.",
|
|
48109
48154
|
"Split unrelated, broad, or behavior-changing work into separate PRs/branches instead of one large cleanup.",
|
|
48110
48155
|
"For confirmed issues that cannot be fixed now, create GitHub issues with the rule, file/line, confidence, impact, and proposed fix.",
|
|
@@ -50746,22 +50791,22 @@ const buildAgentHookScript = () => [
|
|
|
50746
50791
|
"",
|
|
50747
50792
|
"run_react_doctor() {",
|
|
50748
50793
|
" if [ -x ./node_modules/.bin/react-doctor ]; then",
|
|
50749
|
-
" ./node_modules/.bin/react-doctor --verbose --
|
|
50794
|
+
" ./node_modules/.bin/react-doctor --verbose --scope changed --blocking warning --no-score",
|
|
50750
50795
|
" return",
|
|
50751
50796
|
" fi",
|
|
50752
50797
|
"",
|
|
50753
50798
|
" if command -v react-doctor >/dev/null 2>&1; then",
|
|
50754
|
-
" react-doctor --verbose --
|
|
50799
|
+
" react-doctor --verbose --scope changed --blocking warning --no-score",
|
|
50755
50800
|
" return",
|
|
50756
50801
|
" fi",
|
|
50757
50802
|
"",
|
|
50758
50803
|
" if command -v pnpm >/dev/null 2>&1; then",
|
|
50759
|
-
" pnpm dlx react-doctor@latest --verbose --
|
|
50804
|
+
" pnpm dlx react-doctor@latest --verbose --scope changed --blocking warning --no-score",
|
|
50760
50805
|
" return",
|
|
50761
50806
|
" fi",
|
|
50762
50807
|
"",
|
|
50763
50808
|
" if command -v npx >/dev/null 2>&1; then",
|
|
50764
|
-
" npx --yes react-doctor@latest --verbose --
|
|
50809
|
+
" npx --yes react-doctor@latest --verbose --scope changed --blocking warning --no-score",
|
|
50765
50810
|
" return",
|
|
50766
50811
|
" fi",
|
|
50767
50812
|
"",
|
|
@@ -53858,7 +53903,7 @@ ${highlighter.dim("Examples:")}
|
|
|
53858
53903
|
${formatExampleLines([
|
|
53859
53904
|
["react-doctor", "scan the current project"],
|
|
53860
53905
|
["react-doctor ./apps/web", "scan a specific directory"],
|
|
53861
|
-
["react-doctor --
|
|
53906
|
+
["react-doctor --scope changed --base main", "scan only new issues vs. main"],
|
|
53862
53907
|
["react-doctor --project modules/a,modules/b", "score each module separately (names or paths)"],
|
|
53863
53908
|
["react-doctor --staged", "scan staged files (pre-commit hook)"],
|
|
53864
53909
|
["react-doctor --category Security", "show only one diagnostic category"],
|
|
@@ -53934,4 +53979,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
|
|
|
53934
53979
|
export {};
|
|
53935
53980
|
|
|
53936
53981
|
//# sourceMappingURL=cli.js.map
|
|
53937
|
-
//# debugId=
|
|
53982
|
+
//# debugId=d18dc59a-0744-5f52-ae2e-98fddb52ed49
|
package/dist/index.d.ts
CHANGED
|
@@ -9280,9 +9280,10 @@ interface ReactDoctorConfig {
|
|
|
9280
9280
|
* list, user-provided names are treated as distinctive and never
|
|
9281
9281
|
* subject to receiver-object disambiguation.
|
|
9282
9282
|
*
|
|
9283
|
-
*
|
|
9284
|
-
*
|
|
9285
|
-
*
|
|
9283
|
+
* Common guard conventions are already recognized automatically
|
|
9284
|
+
* (`requireAdmin`, `ensureSignedIn`, `getCurrentUser`, `hasRole`, …),
|
|
9285
|
+
* so this is only needed for domain-specific guards whose names carry
|
|
9286
|
+
* no auth noun — e.g. a project-local `requireWorkspaceMember`.
|
|
9286
9287
|
*/
|
|
9287
9288
|
serverAuthFunctionNames?: string[];
|
|
9288
9289
|
/**
|
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]="4e83db09-9255-525f-b6fd-405784826e7d")}catch(e){}}();
|
|
3
3
|
import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import * as NFS from "node:fs";
|
|
@@ -36520,13 +36520,24 @@ const checkSecurityScan = (rootDirectory, options = {}) => {
|
|
|
36520
36520
|
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledBy)) return [];
|
|
36521
36521
|
return [{
|
|
36522
36522
|
entry,
|
|
36523
|
-
scan
|
|
36523
|
+
scan,
|
|
36524
|
+
committedFilesOnly: rule.committedFilesOnly === true
|
|
36524
36525
|
}];
|
|
36525
36526
|
});
|
|
36526
36527
|
if (enabledScanRules.length === 0) return [];
|
|
36527
36528
|
const diagnostics = [];
|
|
36528
36529
|
const seen = /* @__PURE__ */ new Set();
|
|
36529
|
-
|
|
36530
|
+
const gitIgnoredCache = /* @__PURE__ */ new Map();
|
|
36531
|
+
const isFileGitIgnored = (file) => {
|
|
36532
|
+
let status = gitIgnoredCache.get(file.absolutePath);
|
|
36533
|
+
if (status === void 0) {
|
|
36534
|
+
status = isPathGitIgnored(rootDirectory, file.absolutePath);
|
|
36535
|
+
gitIgnoredCache.set(file.absolutePath, status);
|
|
36536
|
+
}
|
|
36537
|
+
return status === true;
|
|
36538
|
+
};
|
|
36539
|
+
for (const file of collectSecurityScanFiles(rootDirectory)) for (const { entry, scan, committedFilesOnly } of enabledScanRules) for (const finding of scan(file)) {
|
|
36540
|
+
if (committedFilesOnly && isFileGitIgnored(file)) continue;
|
|
36530
36541
|
const diagnostic = buildSecurityScanDiagnostic(finding, entry, file.relativePath);
|
|
36531
36542
|
const key = `${diagnostic.rule}:${diagnostic.filePath}:${diagnostic.line}:${diagnostic.column}:${diagnostic.message}`;
|
|
36532
36543
|
if (seen.has(key)) continue;
|
|
@@ -36739,12 +36750,11 @@ const collectKnipPatterns = (rootDirectory, settingName) => {
|
|
|
36739
36750
|
if (!config) return [];
|
|
36740
36751
|
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
36741
36752
|
};
|
|
36742
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory
|
|
36753
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory) => {
|
|
36743
36754
|
const seen = /* @__PURE__ */ new Set();
|
|
36744
36755
|
const sources = [
|
|
36745
36756
|
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
36746
36757
|
collectIgnorePatterns(rootDirectory),
|
|
36747
|
-
userConfig?.ignore?.files ?? [],
|
|
36748
36758
|
collectKnipPatterns(rootDirectory, "ignore")
|
|
36749
36759
|
];
|
|
36750
36760
|
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
@@ -37022,11 +37032,10 @@ const runDeadCodeWorkerWithTimeout = (handle, timeoutMs) => new Promise((resolve
|
|
|
37022
37032
|
});
|
|
37023
37033
|
});
|
|
37024
37034
|
const checkDeadCode = async (options) => {
|
|
37025
|
-
const { userConfig } = options;
|
|
37026
37035
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
37027
37036
|
if (!NFS.existsSync(Path.join(rootDirectory, "package.json"))) return [];
|
|
37028
37037
|
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
37029
|
-
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory
|
|
37038
|
+
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
37030
37039
|
const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
|
|
37031
37040
|
rootDirectory,
|
|
37032
37041
|
entryPatterns,
|
|
@@ -38075,8 +38084,8 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
38075
38084
|
}
|
|
38076
38085
|
return enabled;
|
|
38077
38086
|
};
|
|
38078
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [] }) => {
|
|
38079
|
-
const reactHooksJsPlugin = resolveReactHooksJsPlugin(project.hasReactCompiler, customRulesOnly);
|
|
38087
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false }) => {
|
|
38088
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin ? null : resolveReactHooksJsPlugin(project.hasReactCompiler, customRulesOnly);
|
|
38080
38089
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
38081
38090
|
const jsPlugins = [];
|
|
38082
38091
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -38773,9 +38782,9 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
38773
38782
|
try {
|
|
38774
38783
|
parsed = JSON.parse(sanitizedStdout);
|
|
38775
38784
|
} catch {
|
|
38776
|
-
throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0,
|
|
38785
|
+
throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
|
|
38777
38786
|
}
|
|
38778
|
-
if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0,
|
|
38787
|
+
if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
|
|
38779
38788
|
const minifiedFileCache = /* @__PURE__ */ new Map();
|
|
38780
38789
|
const isMinifiedDiagnosticFile = (filename) => {
|
|
38781
38790
|
const absolutePath = Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
|
|
@@ -39066,6 +39075,28 @@ const writeOxlintConfig = (configPath, configToWrite) => {
|
|
|
39066
39075
|
NFS.closeSync(fileHandle);
|
|
39067
39076
|
}
|
|
39068
39077
|
};
|
|
39078
|
+
const REACT_HOOKS_JS_DROP_PREFIX = "React Compiler rules (react-hooks-js/*) skipped — eslint-plugin-react-hooks failed to load in this environment";
|
|
39079
|
+
/**
|
|
39080
|
+
* Detects an oxlint config-load crash caused by the optional
|
|
39081
|
+
* `react-hooks-js` (eslint-plugin-react-hooks) React Compiler plugin and
|
|
39082
|
+
* builds the partial-failure note for it; returns `null` when the failure
|
|
39083
|
+
* was anything else.
|
|
39084
|
+
*
|
|
39085
|
+
* oxlint prints a framed error to stdout (not stderr) and exits non-zero
|
|
39086
|
+
* when a `jsPlugins` entry can't be imported; that non-JSON stdout
|
|
39087
|
+
* surfaces as `OxlintOutputUnparseable`. Because oxlint fails the WHOLE
|
|
39088
|
+
* config load on it, leaving the plugin in would drop every curated
|
|
39089
|
+
* react-doctor diagnostic too — so the caller retries with the plugin
|
|
39090
|
+
* stripped (issue #833). Both markers sit at the start of oxlint's
|
|
39091
|
+
* message, so they survive the `preview` slice even for deep pnpm paths.
|
|
39092
|
+
*/
|
|
39093
|
+
const reactHooksJsPluginDropNote = (error) => {
|
|
39094
|
+
if (!(error instanceof ReactDoctorError) || error.reason._tag !== "OxlintOutputUnparseable") return null;
|
|
39095
|
+
const { preview } = error.reason;
|
|
39096
|
+
if (!preview.includes("Failed to load JS plugin") || !preview.includes("eslint-plugin-react-hooks")) return null;
|
|
39097
|
+
const underlyingReason = preview.match(/Error:[^\n]*/)?.[0]?.trim();
|
|
39098
|
+
return `${REACT_HOOKS_JS_DROP_PREFIX}${underlyingReason ? `: ${underlyingReason}` : ""}. Other rules ran normally.`;
|
|
39099
|
+
};
|
|
39069
39100
|
/**
|
|
39070
39101
|
* The oxlint runner. Composed of three pieces in `runners/oxlint/`:
|
|
39071
39102
|
*
|
|
@@ -39093,15 +39124,16 @@ const runOxlint = async (options) => {
|
|
|
39093
39124
|
const pluginPath = resolvePluginPath();
|
|
39094
39125
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
39095
39126
|
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
39096
|
-
const buildConfig = (
|
|
39127
|
+
const buildConfig = (overrides) => createOxlintConfig({
|
|
39097
39128
|
pluginPath,
|
|
39098
39129
|
project,
|
|
39099
39130
|
customRulesOnly,
|
|
39100
|
-
extendsPaths:
|
|
39131
|
+
extendsPaths: overrides.extendsPaths,
|
|
39101
39132
|
ignoredTags,
|
|
39102
39133
|
serverAuthFunctionNames,
|
|
39103
39134
|
severityControls,
|
|
39104
|
-
userPlugins
|
|
39135
|
+
userPlugins,
|
|
39136
|
+
disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin
|
|
39105
39137
|
});
|
|
39106
39138
|
const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
|
|
39107
39139
|
const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
@@ -39137,12 +39169,22 @@ const runOxlint = async (options) => {
|
|
|
39137
39169
|
outputMaxBytes,
|
|
39138
39170
|
concurrency: options.concurrency
|
|
39139
39171
|
});
|
|
39140
|
-
writeOxlintConfig(configPath, buildConfig(extendsPaths));
|
|
39172
|
+
writeOxlintConfig(configPath, buildConfig({ extendsPaths }));
|
|
39141
39173
|
try {
|
|
39142
39174
|
return await runBatches();
|
|
39143
39175
|
} catch (error) {
|
|
39176
|
+
const reactHooksJsDropNote = reactHooksJsPluginDropNote(error);
|
|
39177
|
+
if (reactHooksJsDropNote !== null) {
|
|
39178
|
+
writeOxlintConfig(configPath, buildConfig({
|
|
39179
|
+
extendsPaths,
|
|
39180
|
+
disableReactHooksJsPlugin: true
|
|
39181
|
+
}));
|
|
39182
|
+
const diagnostics = await runBatches();
|
|
39183
|
+
onPartialFailure?.(reactHooksJsDropNote);
|
|
39184
|
+
return diagnostics;
|
|
39185
|
+
}
|
|
39144
39186
|
if (extendsPaths.length === 0) throw error;
|
|
39145
|
-
writeOxlintConfig(configPath, buildConfig([]));
|
|
39187
|
+
writeOxlintConfig(configPath, buildConfig({ extendsPaths: [] }));
|
|
39146
39188
|
return await runBatches();
|
|
39147
39189
|
}
|
|
39148
39190
|
} finally {
|
|
@@ -39537,6 +39579,8 @@ const resolveConcreteVersion = (spec) => {
|
|
|
39537
39579
|
const trimmed = spec.trim();
|
|
39538
39580
|
if (trimmed.length === 0) return null;
|
|
39539
39581
|
if (trimmed.includes(":")) return null;
|
|
39582
|
+
const range = import_semver.validRange(trimmed);
|
|
39583
|
+
if (range === null || range === "*") return null;
|
|
39540
39584
|
return import_semver.minVersion(trimmed)?.version ?? null;
|
|
39541
39585
|
};
|
|
39542
39586
|
const locateDependencyKey = (packageJsonText, section, name) => {
|
|
@@ -39923,8 +39967,10 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
39923
39967
|
const lintFailureState = yield* get$2(lintFailure);
|
|
39924
39968
|
yield* afterLint(lintFailureState.didFail);
|
|
39925
39969
|
if (lintFailureState.didFail) yield* scanProgress.fail(formatLintFailText(lintFailureState.reasonTag, process.version));
|
|
39970
|
+
const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
|
|
39971
|
+
const scannedFilesLabel = `${totalFileCount} ${totalFileCount === 1 ? "file" : "files"}`;
|
|
39926
39972
|
const shouldRunDeadCode = input.runDeadCode && !isDiffMode && (showWarnings || deadCodeMaySurfaceWhenWarningsHidden(resolvedConfig.config));
|
|
39927
|
-
const deadCodeCollected = lintFailureState.didFail || !shouldRunDeadCode ? [] : yield* scanProgress.update(
|
|
39973
|
+
const deadCodeCollected = lintFailureState.didFail || !shouldRunDeadCode ? [] : yield* scanProgress.update(`Scanned ${scannedFilesLabel}, analyzing dead code...`).pipe(andThen(runCollect(applyPerElementPipeline(deadCodeService.run({
|
|
39928
39974
|
rootDirectory: scanDirectory,
|
|
39929
39975
|
userConfig: resolvedConfig.config
|
|
39930
39976
|
}).pipe(catchTag("ReactDoctorError", (error) => unwrap(gen(function* () {
|
|
@@ -39937,10 +39983,9 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
39937
39983
|
const deadCodeFailureState = yield* get$2(deadCodeFailure);
|
|
39938
39984
|
const scanElapsedMilliseconds = Date.now() - scanStartTime;
|
|
39939
39985
|
const scanElapsedSeconds = (scanElapsedMilliseconds / 1e3).toFixed(1);
|
|
39940
|
-
const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
|
|
39941
39986
|
if (!lintFailureState.didFail) if (deadCodeFailureState.didFail) yield* scanProgress.fail(DEAD_CODE_FAIL_TEXT);
|
|
39942
39987
|
else if (input.suppressScanSummary) yield* scanProgress.stop();
|
|
39943
|
-
else yield* scanProgress.succeed(`Scanned ${
|
|
39988
|
+
else yield* scanProgress.succeed(`Scanned ${scannedFilesLabel} in ${scanElapsedSeconds}s${workerCountSuffix}`);
|
|
39944
39989
|
yield* reporterService.finalize;
|
|
39945
39990
|
const finalDiagnostics = [
|
|
39946
39991
|
...envCollected,
|
|
@@ -40559,4 +40604,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
40559
40604
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
40560
40605
|
|
|
40561
40606
|
//# sourceMappingURL=index.js.map
|
|
40562
|
-
//# debugId=
|
|
40607
|
+
//# debugId=4e83db09-9255-525f-b6fd-405784826e7d
|
package/dist/lsp.js
CHANGED
|
@@ -36506,13 +36506,24 @@ const checkSecurityScan = (rootDirectory, options = {}) => {
|
|
|
36506
36506
|
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledBy)) return [];
|
|
36507
36507
|
return [{
|
|
36508
36508
|
entry,
|
|
36509
|
-
scan
|
|
36509
|
+
scan,
|
|
36510
|
+
committedFilesOnly: rule.committedFilesOnly === true
|
|
36510
36511
|
}];
|
|
36511
36512
|
});
|
|
36512
36513
|
if (enabledScanRules.length === 0) return [];
|
|
36513
36514
|
const diagnostics = [];
|
|
36514
36515
|
const seen = /* @__PURE__ */ new Set();
|
|
36515
|
-
|
|
36516
|
+
const gitIgnoredCache = /* @__PURE__ */ new Map();
|
|
36517
|
+
const isFileGitIgnored = (file) => {
|
|
36518
|
+
let status = gitIgnoredCache.get(file.absolutePath);
|
|
36519
|
+
if (status === void 0) {
|
|
36520
|
+
status = isPathGitIgnored(rootDirectory, file.absolutePath);
|
|
36521
|
+
gitIgnoredCache.set(file.absolutePath, status);
|
|
36522
|
+
}
|
|
36523
|
+
return status === true;
|
|
36524
|
+
};
|
|
36525
|
+
for (const file of collectSecurityScanFiles(rootDirectory)) for (const { entry, scan, committedFilesOnly } of enabledScanRules) for (const finding of scan(file)) {
|
|
36526
|
+
if (committedFilesOnly && isFileGitIgnored(file)) continue;
|
|
36516
36527
|
const diagnostic = buildSecurityScanDiagnostic(finding, entry, file.relativePath);
|
|
36517
36528
|
const key = `${diagnostic.rule}:${diagnostic.filePath}:${diagnostic.line}:${diagnostic.column}:${diagnostic.message}`;
|
|
36518
36529
|
if (seen.has(key)) continue;
|
|
@@ -36725,12 +36736,11 @@ const collectKnipPatterns = (rootDirectory, settingName) => {
|
|
|
36725
36736
|
if (!config) return [];
|
|
36726
36737
|
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
36727
36738
|
};
|
|
36728
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory
|
|
36739
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory) => {
|
|
36729
36740
|
const seen = /* @__PURE__ */ new Set();
|
|
36730
36741
|
const sources = [
|
|
36731
36742
|
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
36732
36743
|
collectIgnorePatterns(rootDirectory),
|
|
36733
|
-
userConfig?.ignore?.files ?? [],
|
|
36734
36744
|
collectKnipPatterns(rootDirectory, "ignore")
|
|
36735
36745
|
];
|
|
36736
36746
|
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
@@ -37008,11 +37018,10 @@ const runDeadCodeWorkerWithTimeout = (handle, timeoutMs) => new Promise((resolve
|
|
|
37008
37018
|
});
|
|
37009
37019
|
});
|
|
37010
37020
|
const checkDeadCode = async (options) => {
|
|
37011
|
-
const { userConfig } = options;
|
|
37012
37021
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
37013
37022
|
if (!NFS.existsSync(Path.join(rootDirectory, "package.json"))) return [];
|
|
37014
37023
|
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
37015
|
-
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory
|
|
37024
|
+
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory);
|
|
37016
37025
|
const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
|
|
37017
37026
|
rootDirectory,
|
|
37018
37027
|
entryPatterns,
|
|
@@ -38061,8 +38070,8 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
38061
38070
|
}
|
|
38062
38071
|
return enabled;
|
|
38063
38072
|
};
|
|
38064
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [] }) => {
|
|
38065
|
-
const reactHooksJsPlugin = resolveReactHooksJsPlugin(project.hasReactCompiler, customRulesOnly);
|
|
38073
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false }) => {
|
|
38074
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin ? null : resolveReactHooksJsPlugin(project.hasReactCompiler, customRulesOnly);
|
|
38066
38075
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
38067
38076
|
const jsPlugins = [];
|
|
38068
38077
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -38759,9 +38768,9 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
38759
38768
|
try {
|
|
38760
38769
|
parsed = JSON.parse(sanitizedStdout);
|
|
38761
38770
|
} catch {
|
|
38762
|
-
throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0,
|
|
38771
|
+
throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
|
|
38763
38772
|
}
|
|
38764
|
-
if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0,
|
|
38773
|
+
if (!isOxlintOutput(parsed)) throw new ReactDoctorError({ reason: new OxlintOutputUnparseable({ preview: stdout.slice(0, 600) }) });
|
|
38765
38774
|
const minifiedFileCache = /* @__PURE__ */ new Map();
|
|
38766
38775
|
const isMinifiedDiagnosticFile = (filename) => {
|
|
38767
38776
|
const absolutePath = Path.isAbsolute(filename) ? filename : Path.resolve(rootDirectory || ".", filename);
|
|
@@ -39052,6 +39061,28 @@ const writeOxlintConfig = (configPath, configToWrite) => {
|
|
|
39052
39061
|
NFS.closeSync(fileHandle);
|
|
39053
39062
|
}
|
|
39054
39063
|
};
|
|
39064
|
+
const REACT_HOOKS_JS_DROP_PREFIX = "React Compiler rules (react-hooks-js/*) skipped — eslint-plugin-react-hooks failed to load in this environment";
|
|
39065
|
+
/**
|
|
39066
|
+
* Detects an oxlint config-load crash caused by the optional
|
|
39067
|
+
* `react-hooks-js` (eslint-plugin-react-hooks) React Compiler plugin and
|
|
39068
|
+
* builds the partial-failure note for it; returns `null` when the failure
|
|
39069
|
+
* was anything else.
|
|
39070
|
+
*
|
|
39071
|
+
* oxlint prints a framed error to stdout (not stderr) and exits non-zero
|
|
39072
|
+
* when a `jsPlugins` entry can't be imported; that non-JSON stdout
|
|
39073
|
+
* surfaces as `OxlintOutputUnparseable`. Because oxlint fails the WHOLE
|
|
39074
|
+
* config load on it, leaving the plugin in would drop every curated
|
|
39075
|
+
* react-doctor diagnostic too — so the caller retries with the plugin
|
|
39076
|
+
* stripped (issue #833). Both markers sit at the start of oxlint's
|
|
39077
|
+
* message, so they survive the `preview` slice even for deep pnpm paths.
|
|
39078
|
+
*/
|
|
39079
|
+
const reactHooksJsPluginDropNote = (error) => {
|
|
39080
|
+
if (!(error instanceof ReactDoctorError) || error.reason._tag !== "OxlintOutputUnparseable") return null;
|
|
39081
|
+
const { preview } = error.reason;
|
|
39082
|
+
if (!preview.includes("Failed to load JS plugin") || !preview.includes("eslint-plugin-react-hooks")) return null;
|
|
39083
|
+
const underlyingReason = preview.match(/Error:[^\n]*/)?.[0]?.trim();
|
|
39084
|
+
return `${REACT_HOOKS_JS_DROP_PREFIX}${underlyingReason ? `: ${underlyingReason}` : ""}. Other rules ran normally.`;
|
|
39085
|
+
};
|
|
39055
39086
|
/**
|
|
39056
39087
|
* The oxlint runner. Composed of three pieces in `runners/oxlint/`:
|
|
39057
39088
|
*
|
|
@@ -39079,15 +39110,16 @@ const runOxlint = async (options) => {
|
|
|
39079
39110
|
const pluginPath = resolvePluginPath();
|
|
39080
39111
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
39081
39112
|
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
39082
|
-
const buildConfig = (
|
|
39113
|
+
const buildConfig = (overrides) => createOxlintConfig({
|
|
39083
39114
|
pluginPath,
|
|
39084
39115
|
project,
|
|
39085
39116
|
customRulesOnly,
|
|
39086
|
-
extendsPaths:
|
|
39117
|
+
extendsPaths: overrides.extendsPaths,
|
|
39087
39118
|
ignoredTags,
|
|
39088
39119
|
serverAuthFunctionNames,
|
|
39089
39120
|
severityControls,
|
|
39090
|
-
userPlugins
|
|
39121
|
+
userPlugins,
|
|
39122
|
+
disableReactHooksJsPlugin: overrides.disableReactHooksJsPlugin
|
|
39091
39123
|
});
|
|
39092
39124
|
const restoreDisableDirectives = respectInlineDisables ? () => {} : await neutralizeDisableDirectives(rootDirectory, includePaths);
|
|
39093
39125
|
const configDirectory = NFS.mkdtempSync(Path.join(os.tmpdir(), "react-doctor-oxlintrc-"));
|
|
@@ -39123,12 +39155,22 @@ const runOxlint = async (options) => {
|
|
|
39123
39155
|
outputMaxBytes,
|
|
39124
39156
|
concurrency: options.concurrency
|
|
39125
39157
|
});
|
|
39126
|
-
writeOxlintConfig(configPath, buildConfig(extendsPaths));
|
|
39158
|
+
writeOxlintConfig(configPath, buildConfig({ extendsPaths }));
|
|
39127
39159
|
try {
|
|
39128
39160
|
return await runBatches();
|
|
39129
39161
|
} catch (error) {
|
|
39162
|
+
const reactHooksJsDropNote = reactHooksJsPluginDropNote(error);
|
|
39163
|
+
if (reactHooksJsDropNote !== null) {
|
|
39164
|
+
writeOxlintConfig(configPath, buildConfig({
|
|
39165
|
+
extendsPaths,
|
|
39166
|
+
disableReactHooksJsPlugin: true
|
|
39167
|
+
}));
|
|
39168
|
+
const diagnostics = await runBatches();
|
|
39169
|
+
onPartialFailure?.(reactHooksJsDropNote);
|
|
39170
|
+
return diagnostics;
|
|
39171
|
+
}
|
|
39130
39172
|
if (extendsPaths.length === 0) throw error;
|
|
39131
|
-
writeOxlintConfig(configPath, buildConfig([]));
|
|
39173
|
+
writeOxlintConfig(configPath, buildConfig({ extendsPaths: [] }));
|
|
39132
39174
|
return await runBatches();
|
|
39133
39175
|
}
|
|
39134
39176
|
} finally {
|
|
@@ -39523,6 +39565,8 @@ const resolveConcreteVersion = (spec) => {
|
|
|
39523
39565
|
const trimmed = spec.trim();
|
|
39524
39566
|
if (trimmed.length === 0) return null;
|
|
39525
39567
|
if (trimmed.includes(":")) return null;
|
|
39568
|
+
const range = import_semver.validRange(trimmed);
|
|
39569
|
+
if (range === null || range === "*") return null;
|
|
39526
39570
|
return import_semver.minVersion(trimmed)?.version ?? null;
|
|
39527
39571
|
};
|
|
39528
39572
|
const locateDependencyKey = (packageJsonText, section, name) => {
|
|
@@ -39909,8 +39953,10 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
39909
39953
|
const lintFailureState = yield* get$2(lintFailure);
|
|
39910
39954
|
yield* afterLint(lintFailureState.didFail);
|
|
39911
39955
|
if (lintFailureState.didFail) yield* scanProgress.fail(formatLintFailText(lintFailureState.reasonTag, process.version));
|
|
39956
|
+
const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
|
|
39957
|
+
const scannedFilesLabel = `${totalFileCount} ${totalFileCount === 1 ? "file" : "files"}`;
|
|
39912
39958
|
const shouldRunDeadCode = input.runDeadCode && !isDiffMode && (showWarnings || deadCodeMaySurfaceWhenWarningsHidden(resolvedConfig.config));
|
|
39913
|
-
const deadCodeCollected = lintFailureState.didFail || !shouldRunDeadCode ? [] : yield* scanProgress.update(
|
|
39959
|
+
const deadCodeCollected = lintFailureState.didFail || !shouldRunDeadCode ? [] : yield* scanProgress.update(`Scanned ${scannedFilesLabel}, analyzing dead code...`).pipe(andThen(runCollect(applyPerElementPipeline(deadCodeService.run({
|
|
39914
39960
|
rootDirectory: scanDirectory,
|
|
39915
39961
|
userConfig: resolvedConfig.config
|
|
39916
39962
|
}).pipe(catchTag("ReactDoctorError", (error) => unwrap(gen(function* () {
|
|
@@ -39923,10 +39969,9 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
39923
39969
|
const deadCodeFailureState = yield* get$2(deadCodeFailure);
|
|
39924
39970
|
const scanElapsedMilliseconds = Date.now() - scanStartTime;
|
|
39925
39971
|
const scanElapsedSeconds = (scanElapsedMilliseconds / 1e3).toFixed(1);
|
|
39926
|
-
const totalFileCount = lastReportedTotalFileCount || (lintIncludePaths?.length ?? project.sourceFileCount);
|
|
39927
39972
|
if (!lintFailureState.didFail) if (deadCodeFailureState.didFail) yield* scanProgress.fail(DEAD_CODE_FAIL_TEXT);
|
|
39928
39973
|
else if (input.suppressScanSummary) yield* scanProgress.stop();
|
|
39929
|
-
else yield* scanProgress.succeed(`Scanned ${
|
|
39974
|
+
else yield* scanProgress.succeed(`Scanned ${scannedFilesLabel} in ${scanElapsedSeconds}s${workerCountSuffix}`);
|
|
39930
39975
|
yield* reporterService.finalize;
|
|
39931
39976
|
const finalDiagnostics = [
|
|
39932
39977
|
...envCollected,
|
|
@@ -40297,7 +40342,7 @@ const computeConfigFingerprint = (projectDirectory, version) => {
|
|
|
40297
40342
|
/** Display name used in client-facing messages and progress titles. */
|
|
40298
40343
|
const SERVER_DISPLAY_NAME = "React Doctor";
|
|
40299
40344
|
/** Server version reported in `serverInfo`; injected at build, `dev` from source. */
|
|
40300
|
-
const SERVER_VERSION = "0.5.
|
|
40345
|
+
const SERVER_VERSION = "0.5.6";
|
|
40301
40346
|
/** `Diagnostic.source` shown next to every published diagnostic. */
|
|
40302
40347
|
const DIAGNOSTIC_SOURCE = "react-doctor";
|
|
40303
40348
|
/**
|
|
@@ -42344,5 +42389,5 @@ const startLanguageServer = () => {
|
|
|
42344
42389
|
};
|
|
42345
42390
|
//#endregion
|
|
42346
42391
|
export { startLanguageServer };
|
|
42347
|
-
!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]="
|
|
42348
|
-
//# debugId=
|
|
42392
|
+
!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]="7deadb2d-94c2-54e2-bd0d-808ee8d4c380")}catch(e){}}();
|
|
42393
|
+
//# debugId=7deadb2d-94c2-54e2-bd0d-808ee8d4c380
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6-dev.0053a02",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"vscode-languageserver": "^9.0.1",
|
|
65
65
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
66
66
|
"vscode-uri": "^3.1.0",
|
|
67
|
-
"oxlint-plugin-react-doctor": "0.5.
|
|
67
|
+
"oxlint-plugin-react-doctor": "0.5.6-dev.0053a02"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"@xterm/headless": "^6.0.0",
|
|
73
73
|
"commander": "^14.0.3",
|
|
74
74
|
"ora": "^9.4.0",
|
|
75
|
-
"@react-doctor/api": "0.5.
|
|
76
|
-
"@react-doctor/
|
|
77
|
-
"@react-doctor/
|
|
75
|
+
"@react-doctor/api": "0.5.6",
|
|
76
|
+
"@react-doctor/language-server": "0.5.6",
|
|
77
|
+
"@react-doctor/core": "0.5.6"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": "^20.19.0 || >=22.13.0"
|