react-doctor 0.3.0-dev.6130583 → 0.3.0-dev.915745e
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 +13 -1
- package/bin/react-doctor.js +9 -1
- package/dist/cli.js +92 -23
- package/dist/index.d.ts +35 -0
- package/dist/index.js +56 -8
- package/dist/lsp.js +10741 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -37,7 +37,19 @@ npx react-doctor@latest install
|
|
|
37
37
|
|
|
38
38
|
Works with Claude Code, Cursor, Codex, OpenCode, and many more.
|
|
39
39
|
|
|
40
|
-
### 3.
|
|
40
|
+
### 3. Use in your editor (LSP)
|
|
41
|
+
|
|
42
|
+
React Doctor ships an experimental language server, so diagnostics show up live as you type — underlined inline, with rich hovers and quick fixes — in VS Code, Cursor, Zed, Neovim, Sublime, Emacs, Helix, or any LSP client. The universal launch command is:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
react-doctor experimental-lsp --stdio
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
> The editor language server is experimental — its protocol, caching, and diagnostics may change between releases, hence the `experimental-` prefix.
|
|
49
|
+
|
|
50
|
+
Companion extensions for VS Code/Cursor and Zed live under `packages/`; any other LSP client can run the command above directly over stdio.
|
|
51
|
+
|
|
52
|
+
### 4. Run in CI (GitHub Actions) for your team
|
|
41
53
|
|
|
42
54
|
[](https://github.com/marketplace/actions/react-doctor)
|
|
43
55
|
|
package/bin/react-doctor.js
CHANGED
|
@@ -10,4 +10,12 @@ if (module.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
// Fast-path the (experimental) language server so it runs without the CLI's
|
|
14
|
+
// commander / prompts / ora layer, which would touch process.stdin before the
|
|
15
|
+
// LSP connection attaches and break the stdio transport.
|
|
16
|
+
if (process.argv[2] === "experimental-lsp") {
|
|
17
|
+
const { startLanguageServer } = await import("../dist/lsp.js");
|
|
18
|
+
startLanguageServer();
|
|
19
|
+
} else {
|
|
20
|
+
await import("../dist/cli.js");
|
|
21
|
+
}
|
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]="5f1571ca-529b-5db6-ba79-f7bc1c4d6d2d")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
5
5
|
import * as path$1 from "node:path";
|
|
@@ -34,11 +34,11 @@ import * as ChildProcess from "effect/unstable/process/ChildProcess";
|
|
|
34
34
|
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
35
35
|
import * as ts from "typescript";
|
|
36
36
|
import { gzipSync } from "node:zlib";
|
|
37
|
+
import * as Exit from "effect/Exit";
|
|
37
38
|
import * as Sentry from "@sentry/node";
|
|
38
39
|
import { performance } from "node:perf_hooks";
|
|
39
40
|
import { createHash, randomUUID } from "node:crypto";
|
|
40
41
|
import * as Tracer from "effect/Tracer";
|
|
41
|
-
import * as Exit from "effect/Exit";
|
|
42
42
|
import { promisify, stripVTControlCharacters } from "node:util";
|
|
43
43
|
import tty from "node:tty";
|
|
44
44
|
import { codeFrameColumns } from "@babel/code-frame";
|
|
@@ -3085,6 +3085,16 @@ const { program: program$1, createCommand, createArgument, createOption, Command
|
|
|
3085
3085
|
//#endregion
|
|
3086
3086
|
//#region ../core/dist/schemas.js
|
|
3087
3087
|
const Severity = Schema.Literals(["error", "warning"]);
|
|
3088
|
+
var DiagnosticRelatedLocation = class extends Schema.Class("DiagnosticRelatedLocation")({
|
|
3089
|
+
filePath: Schema.String,
|
|
3090
|
+
line: Schema.Number,
|
|
3091
|
+
column: Schema.Number,
|
|
3092
|
+
offset: Schema.optional(Schema.Number),
|
|
3093
|
+
length: Schema.optional(Schema.Number),
|
|
3094
|
+
endLine: Schema.optional(Schema.Number),
|
|
3095
|
+
endColumn: Schema.optional(Schema.Number),
|
|
3096
|
+
message: Schema.String
|
|
3097
|
+
}) {};
|
|
3088
3098
|
var Diagnostic = class extends Schema.Class("Diagnostic")({
|
|
3089
3099
|
filePath: Schema.String,
|
|
3090
3100
|
plugin: Schema.String,
|
|
@@ -3096,8 +3106,13 @@ var Diagnostic = class extends Schema.Class("Diagnostic")({
|
|
|
3096
3106
|
url: Schema.optional(Schema.String),
|
|
3097
3107
|
line: Schema.Number,
|
|
3098
3108
|
column: Schema.Number,
|
|
3109
|
+
offset: Schema.optional(Schema.Number),
|
|
3110
|
+
length: Schema.optional(Schema.Number),
|
|
3111
|
+
endLine: Schema.optional(Schema.Number),
|
|
3112
|
+
endColumn: Schema.optional(Schema.Number),
|
|
3099
3113
|
category: Schema.String,
|
|
3100
|
-
suppressionHint: Schema.optional(Schema.String)
|
|
3114
|
+
suppressionHint: Schema.optional(Schema.String),
|
|
3115
|
+
relatedLocations: Schema.optional(Schema.Array(DiagnosticRelatedLocation))
|
|
3101
3116
|
}) {};
|
|
3102
3117
|
const JsonReportMode = Schema.Literals([
|
|
3103
3118
|
"full",
|
|
@@ -10537,6 +10552,30 @@ const parseRuleCode = (code) => {
|
|
|
10537
10552
|
};
|
|
10538
10553
|
};
|
|
10539
10554
|
const resolveDiagnosticCategory = (plugin, rule) => getRuleCategory(rule) ?? lookupOwnString(PLUGIN_CATEGORY_MAP, plugin) ?? "Bugs";
|
|
10555
|
+
/**
|
|
10556
|
+
* Maps oxlint's non-primary labels (`labels[1..]`) into related source
|
|
10557
|
+
* locations. Editors surface these as a diagnostic's
|
|
10558
|
+
* `relatedInformation`; non-editor consumers ignore the field. Labels
|
|
10559
|
+
* with empty text still carry a useful jump target, so they're kept
|
|
10560
|
+
* with a neutral message.
|
|
10561
|
+
*/
|
|
10562
|
+
const buildRelatedLocations = (labels, filePath) => {
|
|
10563
|
+
if (labels.length <= 1) return [];
|
|
10564
|
+
const related = [];
|
|
10565
|
+
for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
|
|
10566
|
+
const label = labels[labelIndex];
|
|
10567
|
+
if (!label?.span) continue;
|
|
10568
|
+
related.push({
|
|
10569
|
+
filePath,
|
|
10570
|
+
line: label.span.line ?? 0,
|
|
10571
|
+
column: label.span.column ?? 0,
|
|
10572
|
+
offset: label.span.offset,
|
|
10573
|
+
length: label.span.length,
|
|
10574
|
+
message: label.label ?? ""
|
|
10575
|
+
});
|
|
10576
|
+
}
|
|
10577
|
+
return related;
|
|
10578
|
+
};
|
|
10540
10579
|
const isOxlintOutput = (value) => {
|
|
10541
10580
|
if (typeof value !== "object" || value === null) return false;
|
|
10542
10581
|
const candidate = value;
|
|
@@ -10573,8 +10612,11 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
10573
10612
|
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
10574
10613
|
const primaryLabel = diagnostic.labels[0];
|
|
10575
10614
|
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
|
|
10615
|
+
const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
|
|
10616
|
+
const primarySpan = primaryLabel?.span;
|
|
10617
|
+
const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
|
|
10576
10618
|
return {
|
|
10577
|
-
filePath:
|
|
10619
|
+
filePath: normalizedFilePath,
|
|
10578
10620
|
plugin,
|
|
10579
10621
|
rule,
|
|
10580
10622
|
severity: diagnostic.severity,
|
|
@@ -10582,9 +10624,14 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
10582
10624
|
message: cleaned.message,
|
|
10583
10625
|
help: cleaned.help,
|
|
10584
10626
|
url: diagnostic.url,
|
|
10585
|
-
line:
|
|
10586
|
-
column:
|
|
10587
|
-
|
|
10627
|
+
line: primarySpan?.line ?? 0,
|
|
10628
|
+
column: primarySpan?.column ?? 0,
|
|
10629
|
+
...primarySpan ? {
|
|
10630
|
+
offset: primarySpan.offset,
|
|
10631
|
+
length: primarySpan.length
|
|
10632
|
+
} : {},
|
|
10633
|
+
category: resolveDiagnosticCategory(plugin, rule),
|
|
10634
|
+
...relatedLocations.length > 0 ? { relatedLocations } : {}
|
|
10588
10635
|
};
|
|
10589
10636
|
});
|
|
10590
10637
|
};
|
|
@@ -11313,7 +11360,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
11313
11360
|
directory: scanDirectory,
|
|
11314
11361
|
repo
|
|
11315
11362
|
}).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
|
|
11316
|
-
const lintIncludePaths = computeJsxIncludePaths([...input.includePaths]) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
|
|
11363
|
+
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeJsxIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
|
|
11317
11364
|
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
|
|
11318
11365
|
const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
|
|
11319
11366
|
const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
|
|
@@ -11976,7 +12023,11 @@ const METRIC = {
|
|
|
11976
12023
|
installAgentHooks: "install.agent_hooks",
|
|
11977
12024
|
installDependency: "install.dependency",
|
|
11978
12025
|
rulesChanged: "rules.changed",
|
|
11979
|
-
rulesQueried: "rules.queried"
|
|
12026
|
+
rulesQueried: "rules.queried",
|
|
12027
|
+
lspSessionStarted: "lsp.session.started",
|
|
12028
|
+
lspScanCompleted: "lsp.scan.completed",
|
|
12029
|
+
lspScanDuration: "lsp.scan.duration",
|
|
12030
|
+
lspScanDiagnostics: "lsp.scan.diagnostics"
|
|
11980
12031
|
};
|
|
11981
12032
|
//#endregion
|
|
11982
12033
|
//#region src/cli/utils/noop-console.ts
|
|
@@ -12019,7 +12070,7 @@ const makeNoopConsole = () => ({
|
|
|
12019
12070
|
});
|
|
12020
12071
|
//#endregion
|
|
12021
12072
|
//#region src/cli/utils/version.ts
|
|
12022
|
-
const VERSION = "0.3.0-dev.
|
|
12073
|
+
const VERSION = "0.3.0-dev.915745e";
|
|
12023
12074
|
//#endregion
|
|
12024
12075
|
//#region src/cli/utils/json-mode.ts
|
|
12025
12076
|
let context = null;
|
|
@@ -12356,15 +12407,14 @@ const scrubSentryMetric = (metric) => {
|
|
|
12356
12407
|
}
|
|
12357
12408
|
};
|
|
12358
12409
|
//#endregion
|
|
12359
|
-
//#region src/
|
|
12360
|
-
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
|
|
12365
|
-
|
|
12366
|
-
|
|
12367
|
-
const isEnvFlagEnabled = (value) => value === "1" || value?.toLowerCase() === "true";
|
|
12410
|
+
//#region src/cli/utils/sentry-config.ts
|
|
12411
|
+
/**
|
|
12412
|
+
* Shared Sentry configuration resolution — release, environment, and tracing
|
|
12413
|
+
* sample rate — derived from `VERSION` and the standard `SENTRY_*` env
|
|
12414
|
+
* overrides. Lives apart from `instrument.ts` (the CLI's run-context-aware
|
|
12415
|
+
* init) so both the CLI and the editor language server can resolve identical
|
|
12416
|
+
* release/environment values without the LSP pulling in CLI run-context code.
|
|
12417
|
+
*/
|
|
12368
12418
|
/**
|
|
12369
12419
|
* A version is a "dev" build when it's the unbuilt placeholder (`0.0.0`) or
|
|
12370
12420
|
* carries a prerelease suffix (e.g. the `-dev.<sha>` snapshots published from
|
|
@@ -12377,13 +12427,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12377
12427
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12378
12428
|
* standard `SENTRY_RELEASE` override.
|
|
12379
12429
|
*/
|
|
12380
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.3.0-dev.
|
|
12430
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.3.0-dev.915745e`;
|
|
12381
12431
|
/**
|
|
12382
12432
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12383
12433
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12384
12434
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12385
12435
|
*/
|
|
12386
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.3.0-dev.
|
|
12436
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.3.0-dev.915745e") ? "development" : "production");
|
|
12387
12437
|
/**
|
|
12388
12438
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12389
12439
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -12397,6 +12447,16 @@ const resolveTracesSampleRate = () => {
|
|
|
12397
12447
|
if (Number.isNaN(parsed) || parsed < 0 || parsed > 1) return 1;
|
|
12398
12448
|
return parsed;
|
|
12399
12449
|
};
|
|
12450
|
+
//#endregion
|
|
12451
|
+
//#region src/instrument.ts
|
|
12452
|
+
let isInitialized = false;
|
|
12453
|
+
let resolvedTracesSampleRate = 0;
|
|
12454
|
+
const shouldEnableSentry = () => {
|
|
12455
|
+
if (process.argv.includes("--no-score") || process.argv.includes("--no-telemetry")) return false;
|
|
12456
|
+
if (process.env.VITEST || process.env.NODE_ENV === "test") return false;
|
|
12457
|
+
return true;
|
|
12458
|
+
};
|
|
12459
|
+
const isEnvFlagEnabled = (value) => value === "1" || value?.toLowerCase() === "true";
|
|
12400
12460
|
/**
|
|
12401
12461
|
* Whether performance traces will actually be recorded — Sentry is live and the
|
|
12402
12462
|
* resolved sample rate is above zero. Used to gate the per-run root span and
|
|
@@ -15853,6 +15913,15 @@ const shouldFailForDiagnostics = (diagnostics, failOnLevel) => {
|
|
|
15853
15913
|
return diagnostics.some((diagnostic) => diagnostic.severity === "error");
|
|
15854
15914
|
};
|
|
15855
15915
|
//#endregion
|
|
15916
|
+
//#region src/cli/utils/to-category-key.ts
|
|
15917
|
+
/**
|
|
15918
|
+
* Lowercase, key-safe form of a rule category for the `diag.category.*`
|
|
15919
|
+
* telemetry attribute namespace (categories carry spaces / capitals, e.g.
|
|
15920
|
+
* "Performance" → `performance`, "Dead Code" → `dead_code`). Shared by the
|
|
15921
|
+
* CLI run event and the editor LSP wide event so both namespace identically.
|
|
15922
|
+
*/
|
|
15923
|
+
const toCategoryKey = (category) => category.toLowerCase().replace(/[^a-z0-9]+/g, "_");
|
|
15924
|
+
//#endregion
|
|
15856
15925
|
//#region src/cli/utils/build-run-event.ts
|
|
15857
15926
|
const FAIL_ON_LEVELS = new Set([
|
|
15858
15927
|
"error",
|
|
@@ -15875,7 +15944,6 @@ const resolveTelemetryFailOn = (userConfig) => {
|
|
|
15875
15944
|
if (fromAction !== void 0 && FAIL_ON_LEVELS.has(fromAction)) return fromAction;
|
|
15876
15945
|
return userConfig?.failOn ?? "none";
|
|
15877
15946
|
};
|
|
15878
|
-
const toCategoryKey = (category) => category.toLowerCase().replace(/[^a-z0-9]+/g, "_");
|
|
15879
15947
|
const buildOutcomeAttributes = (input) => {
|
|
15880
15948
|
if (input.result === void 0) {
|
|
15881
15949
|
const error = input.error;
|
|
@@ -20857,6 +20925,7 @@ rules.command("disable <rule>").description("Disable a rule so it never runs").o
|
|
|
20857
20925
|
rules.command("category <category> <severity>").description("Set the severity for a whole category (off, warn, error)").option("-c, --cwd <cwd>", "working directory", process.cwd()).action((category, severity, _options, command) => rulesCategoryAction(category, severity, command.optsWithGlobals()));
|
|
20858
20926
|
rules.command("ignore-tag <tag>").description("Skip a whole rule family by tag before linting (e.g. design)").option("-c, --cwd <cwd>", "working directory", process.cwd()).action((tag, _options, command) => rulesIgnoreTagAction(tag, command.optsWithGlobals()));
|
|
20859
20927
|
rules.command("unignore-tag <tag>").description("Stop ignoring a tag previously skipped via ignore-tag").option("-c, --cwd <cwd>", "working directory", process.cwd()).action((tag, _options, command) => rulesUnignoreTagAction(tag, command.optsWithGlobals()));
|
|
20928
|
+
program.command("experimental-lsp", { hidden: false }).description("[experimental] run the React Doctor language server over stdio (for editors)").allowUnknownOption().action(() => {});
|
|
20860
20929
|
process.stdout.on("error", (error) => {
|
|
20861
20930
|
if (error.code === "EPIPE") process.exit(0);
|
|
20862
20931
|
});
|
|
@@ -20885,4 +20954,4 @@ program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
|
|
|
20885
20954
|
export {};
|
|
20886
20955
|
|
|
20887
20956
|
//# sourceMappingURL=cli.js.map
|
|
20888
|
-
//# debugId=
|
|
20957
|
+
//# debugId=5f1571ca-529b-5db6-ba79-f7bc1c4d6d2d
|
package/dist/index.d.ts
CHANGED
|
@@ -334,6 +334,25 @@ interface ReactDoctorConfig {
|
|
|
334
334
|
plugins?: string[];
|
|
335
335
|
} //#endregion
|
|
336
336
|
//#region src/types/diagnostic.d.ts
|
|
337
|
+
/**
|
|
338
|
+
* A secondary source location attached to a diagnostic (oxlint's
|
|
339
|
+
* non-primary labels). Editors render these as
|
|
340
|
+
* `Diagnostic.relatedInformation` so a user can jump from, say, a
|
|
341
|
+
* `no-derived-state` finding to the originating prop declaration.
|
|
342
|
+
* Positions mirror `Diagnostic` semantics: `line` / `column` are
|
|
343
|
+
* 1-indexed, and `offset` / `length` are UTF-8 byte spans from oxlint
|
|
344
|
+
* when available (preferred for precise ranges).
|
|
345
|
+
*/
|
|
346
|
+
interface DiagnosticRelatedLocation {
|
|
347
|
+
filePath: string;
|
|
348
|
+
line: number;
|
|
349
|
+
column: number;
|
|
350
|
+
offset?: number;
|
|
351
|
+
length?: number;
|
|
352
|
+
endLine?: number;
|
|
353
|
+
endColumn?: number;
|
|
354
|
+
message: string;
|
|
355
|
+
}
|
|
337
356
|
interface Diagnostic {
|
|
338
357
|
filePath: string;
|
|
339
358
|
plugin: string;
|
|
@@ -345,8 +364,24 @@ interface Diagnostic {
|
|
|
345
364
|
url?: string;
|
|
346
365
|
line: number;
|
|
347
366
|
column: number;
|
|
367
|
+
/**
|
|
368
|
+
* UTF-8 byte offset of the diagnostic's primary span start, straight
|
|
369
|
+
* from oxlint's label span. Optional because environment / dead-code
|
|
370
|
+
* diagnostics carry no source span. Editors (LSP) convert this into a
|
|
371
|
+
* precise range via the in-memory document; non-editor consumers can
|
|
372
|
+
* ignore it.
|
|
373
|
+
*/
|
|
374
|
+
offset?: number;
|
|
375
|
+
/** UTF-8 byte length of the primary span (pairs with `offset`). */
|
|
376
|
+
length?: number;
|
|
377
|
+
/** 1-indexed end line of the primary span, when derivable. */
|
|
378
|
+
endLine?: number;
|
|
379
|
+
/** 1-indexed end column of the primary span, when derivable. */
|
|
380
|
+
endColumn?: number;
|
|
348
381
|
category: string;
|
|
349
382
|
suppressionHint?: string;
|
|
383
|
+
/** Secondary source locations (oxlint's non-primary labels). */
|
|
384
|
+
relatedLocations?: DiagnosticRelatedLocation[];
|
|
350
385
|
}
|
|
351
386
|
//#endregion
|
|
352
387
|
//#region src/types/project-info.d.ts
|
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]="ac54f8ec-45d1-5b7d-8208-35f50f4c4973")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import * as Schema from "effect/Schema";
|
|
5
5
|
import * as fs$1 from "node:fs";
|
|
@@ -33,6 +33,7 @@ import * as ChildProcess from "effect/unstable/process/ChildProcess";
|
|
|
33
33
|
import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
|
|
34
34
|
import * as ts from "typescript";
|
|
35
35
|
import { gzipSync } from "node:zlib";
|
|
36
|
+
import "effect/Exit";
|
|
36
37
|
//#region \0rolldown/runtime.js
|
|
37
38
|
var __create$1 = Object.create;
|
|
38
39
|
var __defProp$1 = Object.defineProperty;
|
|
@@ -58,6 +59,16 @@ var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(
|
|
|
58
59
|
//#endregion
|
|
59
60
|
//#region ../core/dist/schemas.js
|
|
60
61
|
const Severity = Schema.Literals(["error", "warning"]);
|
|
62
|
+
var DiagnosticRelatedLocation = class extends Schema.Class("DiagnosticRelatedLocation")({
|
|
63
|
+
filePath: Schema.String,
|
|
64
|
+
line: Schema.Number,
|
|
65
|
+
column: Schema.Number,
|
|
66
|
+
offset: Schema.optional(Schema.Number),
|
|
67
|
+
length: Schema.optional(Schema.Number),
|
|
68
|
+
endLine: Schema.optional(Schema.Number),
|
|
69
|
+
endColumn: Schema.optional(Schema.Number),
|
|
70
|
+
message: Schema.String
|
|
71
|
+
}) {};
|
|
61
72
|
var Diagnostic = class extends Schema.Class("Diagnostic")({
|
|
62
73
|
filePath: Schema.String,
|
|
63
74
|
plugin: Schema.String,
|
|
@@ -69,8 +80,13 @@ var Diagnostic = class extends Schema.Class("Diagnostic")({
|
|
|
69
80
|
url: Schema.optional(Schema.String),
|
|
70
81
|
line: Schema.Number,
|
|
71
82
|
column: Schema.Number,
|
|
83
|
+
offset: Schema.optional(Schema.Number),
|
|
84
|
+
length: Schema.optional(Schema.Number),
|
|
85
|
+
endLine: Schema.optional(Schema.Number),
|
|
86
|
+
endColumn: Schema.optional(Schema.Number),
|
|
72
87
|
category: Schema.String,
|
|
73
|
-
suppressionHint: Schema.optional(Schema.String)
|
|
88
|
+
suppressionHint: Schema.optional(Schema.String),
|
|
89
|
+
relatedLocations: Schema.optional(Schema.Array(DiagnosticRelatedLocation))
|
|
74
90
|
}) {};
|
|
75
91
|
const JsonReportMode = Schema.Literals([
|
|
76
92
|
"full",
|
|
@@ -7469,6 +7485,30 @@ const parseRuleCode = (code) => {
|
|
|
7469
7485
|
};
|
|
7470
7486
|
};
|
|
7471
7487
|
const resolveDiagnosticCategory = (plugin, rule) => getRuleCategory(rule) ?? lookupOwnString(PLUGIN_CATEGORY_MAP, plugin) ?? "Bugs";
|
|
7488
|
+
/**
|
|
7489
|
+
* Maps oxlint's non-primary labels (`labels[1..]`) into related source
|
|
7490
|
+
* locations. Editors surface these as a diagnostic's
|
|
7491
|
+
* `relatedInformation`; non-editor consumers ignore the field. Labels
|
|
7492
|
+
* with empty text still carry a useful jump target, so they're kept
|
|
7493
|
+
* with a neutral message.
|
|
7494
|
+
*/
|
|
7495
|
+
const buildRelatedLocations = (labels, filePath) => {
|
|
7496
|
+
if (labels.length <= 1) return [];
|
|
7497
|
+
const related = [];
|
|
7498
|
+
for (let labelIndex = 1; labelIndex < labels.length; labelIndex++) {
|
|
7499
|
+
const label = labels[labelIndex];
|
|
7500
|
+
if (!label?.span) continue;
|
|
7501
|
+
related.push({
|
|
7502
|
+
filePath,
|
|
7503
|
+
line: label.span.line ?? 0,
|
|
7504
|
+
column: label.span.column ?? 0,
|
|
7505
|
+
offset: label.span.offset,
|
|
7506
|
+
length: label.span.length,
|
|
7507
|
+
message: label.label ?? ""
|
|
7508
|
+
});
|
|
7509
|
+
}
|
|
7510
|
+
return related;
|
|
7511
|
+
};
|
|
7472
7512
|
const isOxlintOutput = (value) => {
|
|
7473
7513
|
if (typeof value !== "object" || value === null) return false;
|
|
7474
7514
|
const candidate = value;
|
|
@@ -7505,8 +7545,11 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
7505
7545
|
const { plugin, rule } = parseRuleCode(diagnostic.code);
|
|
7506
7546
|
const primaryLabel = diagnostic.labels[0];
|
|
7507
7547
|
const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
|
|
7548
|
+
const normalizedFilePath = diagnostic.filename.replaceAll("\\", "/");
|
|
7549
|
+
const primarySpan = primaryLabel?.span;
|
|
7550
|
+
const relatedLocations = buildRelatedLocations(diagnostic.labels, normalizedFilePath);
|
|
7508
7551
|
return {
|
|
7509
|
-
filePath:
|
|
7552
|
+
filePath: normalizedFilePath,
|
|
7510
7553
|
plugin,
|
|
7511
7554
|
rule,
|
|
7512
7555
|
severity: diagnostic.severity,
|
|
@@ -7514,9 +7557,14 @@ const parseOxlintOutput = (stdout, project, rootDirectory) => {
|
|
|
7514
7557
|
message: cleaned.message,
|
|
7515
7558
|
help: cleaned.help,
|
|
7516
7559
|
url: diagnostic.url,
|
|
7517
|
-
line:
|
|
7518
|
-
column:
|
|
7519
|
-
|
|
7560
|
+
line: primarySpan?.line ?? 0,
|
|
7561
|
+
column: primarySpan?.column ?? 0,
|
|
7562
|
+
...primarySpan ? {
|
|
7563
|
+
offset: primarySpan.offset,
|
|
7564
|
+
length: primarySpan.length
|
|
7565
|
+
} : {},
|
|
7566
|
+
category: resolveDiagnosticCategory(plugin, rule),
|
|
7567
|
+
...relatedLocations.length > 0 ? { relatedLocations } : {}
|
|
7520
7568
|
};
|
|
7521
7569
|
});
|
|
7522
7570
|
};
|
|
@@ -8245,7 +8293,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8245
8293
|
directory: scanDirectory,
|
|
8246
8294
|
repo
|
|
8247
8295
|
}).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
|
|
8248
|
-
const lintIncludePaths = computeJsxIncludePaths([...input.includePaths]) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
|
|
8296
|
+
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeJsxIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
|
|
8249
8297
|
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
|
|
8250
8298
|
const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
|
|
8251
8299
|
const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
|
|
@@ -8800,4 +8848,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8800
8848
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8801
8849
|
|
|
8802
8850
|
//# sourceMappingURL=index.js.map
|
|
8803
|
-
//# debugId=
|
|
8851
|
+
//# debugId=ac54f8ec-45d1-5b7d-8208-35f50f4c4973
|