react-doctor 0.9.17 → 0.9.18-dev.9a79847

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.
Files changed (43) hide show
  1. package/README.md +16 -72
  2. package/dist/{build-section-divider-BpE5NDDX.js → build-section-divider-F18iXtxb.js} +5 -5
  3. package/dist/{ci-DNtt9X6S.js → ci-CgtjUZEp.js} +24 -14
  4. package/dist/cli.js +41 -32
  5. package/dist/constants-DNh19qg9.js +2 -2
  6. package/dist/{constants-DHn5rUeg.js → constants-_b1h6lxa.js} +7 -5
  7. package/dist/{design-u2afuNir.js → design-CtHsB1nr.js} +4 -4
  8. package/dist/duplicate-jsx-worker.js +3 -3
  9. package/dist/{exit-gracefully-DlI5QxjC.js → exit-gracefully-D1DuwwPU.js} +6 -6
  10. package/dist/{handle-error-ChH7NTTt.js → handle-error-B3AmBrIU.js} +6 -6
  11. package/dist/index.d.ts +14 -6
  12. package/dist/index.js +332 -58
  13. package/dist/{inspect-BEMrqB0D.js → inspect-BhFj2qyJ.js} +31 -23
  14. package/dist/{install-rmw4kZuQ.js → install-3nDOB3hj.js} +10 -10
  15. package/dist/{install-doctor-script-D5XbyGON.js → install-doctor-script-DHJd_h8L.js} +10 -6
  16. package/dist/{install-github-workflow-bsR3MAJ4.js → install-github-workflow-BPUJzESV.js} +22 -8
  17. package/dist/{install-react-doctor-CEZd9boZ.js → install-react-doctor-IU3RmjJs.js} +9 -9
  18. package/dist/{is-cache-globally-disabled-DDlh_f1u.js → is-cache-globally-disabled-BTTLvugj.js} +4 -4
  19. package/dist/{jsx-runtime-RhgTgCyJ.js → jsx-runtime-BpqeSsvv.js} +6 -6
  20. package/dist/{print-branded-header-DUpSxfB1.js → print-branded-header-Cabdds8M.js} +4 -4
  21. package/dist/{prompt-runtime-scan-url-ClnyA-kD.js → prompt-runtime-scan-url-DqGtnZaE.js} +5 -5
  22. package/dist/{read-object-file-BmbbCthv.js → read-object-file-OstnyYB2.js} +4 -4
  23. package/dist/{record-metric-BNXhF2A-.js → record-metric-CgebwK0K.js} +439 -84
  24. package/dist/{report-error-BaQdqDfo.js → report-error-DYLN3xZA.js} +6 -6
  25. package/dist/{report-workflow-result-keduRDKN.js → report-workflow-result-BfR_cSwa.js} +8 -7
  26. package/dist/{should-fail-scan-gate-DobEL_kS.js → resolve-scan-exit-code-CMj5rx-z.js} +38 -41
  27. package/dist/{resolve-scope-_R9av4PA.js → resolve-scope-DlV1G6NB.js} +10 -9
  28. package/dist/{rules-mbLozamL.js → rules-CCbE4U-k.js} +7 -7
  29. package/dist/{run-scan-app-yG6ELpUl.js → run-scan-app-D8hbdBvF.js} +33 -23
  30. package/dist/{runtime-scan-DNhYo683.js → runtime-scan-BINkjxmp.js} +10 -10
  31. package/dist/{sanitize-runtime-url-DM_qbPGY.js → sanitize-runtime-url-B3CaL49D.js} +4 -4
  32. package/dist/{scan-CAAixMS9.js → scan-D0JRVcBc.js} +14 -13
  33. package/dist/{should-skip-prompts-CGTEgq2F.js → should-skip-prompts-BQ6Bv8nf.js} +4 -4
  34. package/dist/{should-use-tui-DG2l-Td3.js → should-use-tui-BxO6yE3o.js} +4 -4
  35. package/dist/skills/react-doctor/SKILL.md +19 -8
  36. package/dist/skills/react-doctor/references/explain.md +5 -0
  37. package/dist/{start-scan-preamble-BPz3nzCQ.js → start-scan-preamble-BbzEgrwo.js} +5 -5
  38. package/dist/start-scan-preamble.js +3 -3
  39. package/dist/{telemetry-runtime-CUn1--rM.js → telemetry-runtime-BmL4aFx2.js} +7 -7
  40. package/dist/{version-CbFBCUY9.js → version-D2xd0HSm.js} +5 -5
  41. package/dist/{why-BIX2FUbP.js → why-CO9Za1ph.js} +4 -4
  42. package/dist/{with-run-span-BsS7dU6e.js → with-run-span-CMr4jR2i.js} +6 -6
  43. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d2b0583c-877f-57cf-8b0a-65519428807c")}catch(e){}}();
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]="f19a4e97-e6d1-58b3-b9ee-17a3545fa20d")}catch(e){}}();
3
3
  import { i as __toESM, r as __require, t as __commonJSMin } from "./chunk-ChKA3wi6.js";
4
4
  import { createRequire } from "node:module";
5
5
  import * as fs$1$2 from "node:fs";
@@ -13,20 +13,20 @@ import { fileURLToPath } from "node:url";
13
13
  import * as os$1 from "node:os";
14
14
  import os from "node:os";
15
15
  import * as Crypto from "node:crypto";
16
- import crypto, { createHash, randomUUID } from "node:crypto";
16
+ import crypto, { createHash } from "node:crypto";
17
17
  import { Worker } from "node:worker_threads";
18
18
  import * as net from "node:net";
19
19
  import { parseSync } from "oxc-parser";
20
20
  import * as fs$1$1 from "node:fs/promises";
21
21
  import { ResolverFactory } from "oxc-resolver";
22
- import { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_OPT_IN_PROJECT_RULE_IDS, REACT_DOCTOR_PROJECT_RULES, REACT_DOCTOR_RULES, REACT_DOCTOR_RULE_REGISTRY, REACT_DOCTOR_SCAN_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor/core";
22
+ import { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_OPT_IN_PROJECT_RULE_IDS, REACT_DOCTOR_PROJECT_RULES, REACT_DOCTOR_RULES, REACT_DOCTOR_RULE_REGISTRY, REACT_DOCTOR_SCAN_RULES, atomicWriteFile, classifySecurityScanFile, collectCrossFileDependencyProbes, getDiagnosticContextPath, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor/core";
23
23
  import { parseJSON5, parseJSONC } from "confbox";
24
24
  import { createJiti } from "jiti";
25
25
  import { PassThrough } from "node:stream";
26
26
  import { convertToTSX } from "@astrojs/compiler/sync";
27
27
  import { STATUS_CODES } from "node:http";
28
28
  import { gzipSync } from "node:zlib";
29
- //#region ../core/dist/constants-E-ghW6VY.js
29
+ //#region ../core/dist/constants-C7CkEi1m.js
30
30
  const HTML_FILE_PATTERN = /\.html$/i;
31
31
  const SOURCE_FILE_PATTERN = /\.(?:astro|tsx?|jsx?|mts|mjs|[hH][tT][mM][lL])$/;
32
32
  const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
@@ -46,6 +46,7 @@ const IGNORED_DIRECTORIES = new Set([
46
46
  ".angular",
47
47
  ".astro",
48
48
  ".cache",
49
+ ".cloudflare",
49
50
  ".contentlayer",
50
51
  ".direnv",
51
52
  ".docusaurus",
@@ -438,7 +439,7 @@ const isPlainObject = (value) => {
438
439
  //#region ../core/dist/react-compiler-detection-worker-protocol-Dp5LlrE8.js
439
440
  const isReactCompilerDetectionReply = (value) => typeof value === "object" && value !== null && "id" in value && typeof value.id === "number" && "hasReactCompiler" in value && (typeof value.hasReactCompiler === "boolean" || value.hasReactCompiler === null);
440
441
  //#endregion
441
- //#region ../core/dist/react-compiler-detection-client-fc698QTY.js
442
+ //#region ../core/dist/react-compiler-detection-client-STyNa3cf.js
442
443
  const pendingOutputsByRequestKey = /* @__PURE__ */ new Map();
443
444
  const toRequestKey = (request) => [
444
445
  request.directory,
@@ -2708,7 +2709,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2708
2709
  module.exports = picomatch;
2709
2710
  }));
2710
2711
  //#endregion
2711
- //#region ../core/dist/collect-unplugin-auto-import-global-scopes-D2Skzhl1.js
2712
+ //#region ../core/dist/collect-unplugin-auto-import-global-scopes-BhuBw8nC.js
2712
2713
  var import_picomatch = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
2713
2714
  const pico = require_picomatch$1();
2714
2715
  const utils = require_utils();
@@ -3158,14 +3159,14 @@ const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }
3158
3159
  return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
3159
3160
  };
3160
3161
  //#endregion
3161
- //#region ../core/dist/detect-duplicate-jsx-subtrees-CzQouU4i.js
3162
+ //#region ../core/dist/detect-duplicate-jsx-subtrees-DcK8lwow.js
3162
3163
  const yieldToEventLoop = () => new Promise((resolve) => {
3163
3164
  setImmediate(resolve);
3164
3165
  });
3165
3166
  const getTypescriptScriptKind = (fileName) => {
3166
3167
  if (fileName.endsWith(".tsx")) return typescriptBinding.ScriptKind.TSX;
3167
3168
  if (fileName.endsWith(".jsx")) return typescriptBinding.ScriptKind.JSX;
3168
- if (fileName.endsWith(".ts")) return typescriptBinding.ScriptKind.TS;
3169
+ if (/\.[cm]?ts$/.test(fileName)) return typescriptBinding.ScriptKind.TS;
3169
3170
  return typescriptBinding.ScriptKind.JS;
3170
3171
  };
3171
3172
  const resolveBoundedSourceReadBytes = (maximumLengthChars, sizeBytes) => Math.min(sizeBytes, maximumLengthChars * 3 + 1);
@@ -3715,7 +3716,7 @@ const detectDuplicateJsxSubtreesCooperative = async (sourceReader, options = {})
3715
3716
  });
3716
3717
  };
3717
3718
  //#endregion
3718
- //#region ../core/dist/detect-react-compiler-DIKiMJ1N.js
3719
+ //#region ../core/dist/detect-react-compiler-DDLkt9mH.js
3719
3720
  const NEXT_CONFIG_FILENAMES = [
3720
3721
  "next.config.js",
3721
3722
  "next.config.mjs",
@@ -7837,6 +7838,37 @@ const mapInput = /* @__PURE__ */ dual(2, (self, f) => make$37((b1, b2) => self(f
7837
7838
  */
7838
7839
  const isGreaterThan$1 = (O) => dual(2, (self, that) => O(self, that) === 1);
7839
7840
  /**
7841
+ * Checks whether one value is greater than or equal to another according to the given order.
7842
+ *
7843
+ * **When to use**
7844
+ *
7845
+ * Use when you need a boolean greater-than-or-equal predicate using an
7846
+ * `Order`.
7847
+ *
7848
+ * **Details**
7849
+ *
7850
+ * Returns `true` if the order returns `1` or `0`, and returns `false` only if
7851
+ * the order returns `-1`.
7852
+ *
7853
+ * **Example** (Checking greater-than-or-equal comparisons)
7854
+ *
7855
+ * ```ts
7856
+ * import { Order } from "effect"
7857
+ *
7858
+ * const isGreaterThanOrEqualToNumber = Order.isGreaterThanOrEqualTo(Order.Number)
7859
+ *
7860
+ * console.log(isGreaterThanOrEqualToNumber(2, 1)) // true
7861
+ * console.log(isGreaterThanOrEqualToNumber(1, 1)) // true
7862
+ * console.log(isGreaterThanOrEqualToNumber(1, 2)) // false
7863
+ * ```
7864
+ *
7865
+ * @see {@link isGreaterThan} for strict greater than
7866
+ * @see {@link isLessThanOrEqualTo} for less than or equal
7867
+ * @category predicates
7868
+ * @since 4.0.0
7869
+ */
7870
+ const isGreaterThanOrEqualTo$1 = (O) => dual(2, (self, that) => O(self, that) !== -1);
7871
+ /**
7840
7872
  * Returns the maximum of two values according to the given order. If they are equal, returns the first argument.
7841
7873
  *
7842
7874
  * **When to use**
@@ -24721,6 +24753,203 @@ function link$1() {
24721
24753
  };
24722
24754
  }
24723
24755
  /**
24756
+ * Creates a custom validation filter from a predicate function.
24757
+ *
24758
+ * **Details**
24759
+ *
24760
+ * The predicate receives the decoded input value, the schema AST, and parse
24761
+ * options, and returns a `FilterOutput`. Non-success outputs are normalized into
24762
+ * schema issues. The `annotations` parameter annotates the filter itself; with
24763
+ * the default formatter, failures use `message` first, `expected` second, and
24764
+ * `<filter>` when neither is provided.
24765
+ *
24766
+ * When `abort` is `true`, parsing stops after this filter fails instead of
24767
+ * collecting later check failures.
24768
+ *
24769
+ * **Example** (Reporting failure at a nested path)
24770
+ *
24771
+ * ```ts
24772
+ * import { Schema } from "effect"
24773
+ *
24774
+ * const schema = Schema.Struct({ password: Schema.String, confirmPassword: Schema.String }).check(
24775
+ * Schema.makeFilter((o) =>
24776
+ * o.password === o.confirmPassword
24777
+ * ? undefined
24778
+ * : { path: ["password"], issue: "password and confirmPassword must match" }
24779
+ * )
24780
+ * )
24781
+ *
24782
+ * console.log(String(Schema.decodeUnknownExit(schema)({ password: "123456", confirmPassword: "1234567" })))
24783
+ * // Failure(Cause([Fail(SchemaError: password and confirmPassword must match
24784
+ * // at ["password"])]))
24785
+ * ```
24786
+ *
24787
+ * **Example** (Reporting multiple failures at once)
24788
+ *
24789
+ * ```ts
24790
+ * import { Schema } from "effect"
24791
+ *
24792
+ * const schema = Schema.Struct({ a: Schema.Finite, b: Schema.Finite, c: Schema.Finite }).check(
24793
+ * Schema.makeFilter((o) => {
24794
+ * const issues: Array<Schema.FilterIssue> = []
24795
+ * if (o.a > 0) {
24796
+ * if (o.b <= 0) issues.push({ path: ["b"], issue: "b must be greater than 0" })
24797
+ * if (o.c <= 0) issues.push({ path: ["c"], issue: "c must be greater than 0" })
24798
+ * }
24799
+ * return issues
24800
+ * })
24801
+ * )
24802
+ *
24803
+ * console.log(String(Schema.decodeUnknownExit(schema)({ a: 1, b: 0, c: 0 })))
24804
+ * // Failure(Cause([Fail(SchemaError: b must be greater than 0
24805
+ * // at ["b"]
24806
+ * // c must be greater than 0
24807
+ * // at ["c"])]))
24808
+ * ```
24809
+ *
24810
+ * @category constructors
24811
+ * @since 4.0.0
24812
+ */
24813
+ const makeFilter = makeFilter$1;
24814
+ /**
24815
+ * Creates a greater-than (`>`) check for any ordered type from an
24816
+ * `Order.Order` instance.
24817
+ *
24818
+ * @category Order checks
24819
+ * @since 4.0.0
24820
+ */
24821
+ function makeIsGreaterThan(options) {
24822
+ const gt = isGreaterThan$1(options.order);
24823
+ const formatter = options.formatter ?? format$1;
24824
+ return (exclusiveMinimum, annotations) => {
24825
+ return makeFilter((input) => gt(input, exclusiveMinimum), {
24826
+ expected: `a value greater than ${formatter(exclusiveMinimum)}`,
24827
+ arbitrary: { constraint: { ordered: {
24828
+ order: options.order,
24829
+ minimum: exclusiveMinimum,
24830
+ exclusiveMinimum: true
24831
+ } } },
24832
+ ...options.annotate?.(exclusiveMinimum),
24833
+ ...annotations
24834
+ });
24835
+ };
24836
+ }
24837
+ /**
24838
+ * Creates a greater-than-or-equal-to (`>=`) check for any ordered type from an
24839
+ * `Order.Order` instance.
24840
+ *
24841
+ * @category Order checks
24842
+ * @since 4.0.0
24843
+ */
24844
+ function makeIsGreaterThanOrEqualTo(options) {
24845
+ const gte = isGreaterThanOrEqualTo$1(options.order);
24846
+ const formatter = options.formatter ?? format$1;
24847
+ return (minimum, annotations) => {
24848
+ return makeFilter((input) => gte(input, minimum), {
24849
+ expected: `a value greater than or equal to ${formatter(minimum)}`,
24850
+ arbitrary: { constraint: { ordered: {
24851
+ order: options.order,
24852
+ minimum
24853
+ } } },
24854
+ ...options.annotate?.(minimum),
24855
+ ...annotations
24856
+ });
24857
+ };
24858
+ }
24859
+ function encodeNumberPayload(number) {
24860
+ if (!globalThis.Number.isFinite(number)) throw new globalThis.RangeError(`Expected a finite number, got ${format$1(number)}`);
24861
+ return number;
24862
+ }
24863
+ /**
24864
+ * Validates that a number is greater than the specified value (exclusive).
24865
+ *
24866
+ * **Details**
24867
+ *
24868
+ * JSON Schema:
24869
+ *
24870
+ * This check corresponds to the `exclusiveMinimum` constraint in JSON Schema.
24871
+ *
24872
+ * Arbitrary:
24873
+ *
24874
+ * When generating test data with fast-check, this applies an
24875
+ * `exclusiveMinimum` constraint to ensure generated numbers are greater than
24876
+ * the specified value.
24877
+ *
24878
+ * @category Number checks
24879
+ * @since 4.0.0
24880
+ */
24881
+ const isGreaterThan = /* @__PURE__ */ makeIsGreaterThan({
24882
+ order: Number$5,
24883
+ annotate: (exclusiveMinimum) => ({
24884
+ representation: {
24885
+ id: "effect/schema/isGreaterThan",
24886
+ payload: { exclusiveMinimum: encodeNumberPayload(exclusiveMinimum) }
24887
+ },
24888
+ toJsonSchema: () => ({ exclusiveMinimum }),
24889
+ toCode: () => ({ runtime: `Schema.isGreaterThan(${format$1(exclusiveMinimum)})` })
24890
+ })
24891
+ });
24892
+ /**
24893
+ * Validates that a number is greater than or equal to the specified value
24894
+ * (inclusive).
24895
+ *
24896
+ * **Details**
24897
+ *
24898
+ * JSON Schema:
24899
+ *
24900
+ * This check corresponds to the `minimum` constraint in JSON Schema.
24901
+ *
24902
+ * Arbitrary:
24903
+ *
24904
+ * When generating test data with fast-check, this applies a `minimum` constraint
24905
+ * to ensure generated numbers are greater than or equal to the specified value.
24906
+ *
24907
+ * @category Number checks
24908
+ * @since 4.0.0
24909
+ */
24910
+ const isGreaterThanOrEqualTo = /* @__PURE__ */ makeIsGreaterThanOrEqualTo({
24911
+ order: Number$5,
24912
+ annotate: (minimum) => ({
24913
+ representation: {
24914
+ id: "effect/schema/isGreaterThanOrEqualTo",
24915
+ payload: { minimum: encodeNumberPayload(minimum) }
24916
+ },
24917
+ toJsonSchema: () => ({ minimum }),
24918
+ toCode: () => ({ runtime: `Schema.isGreaterThanOrEqualTo(${format$1(minimum)})` })
24919
+ })
24920
+ });
24921
+ /**
24922
+ * Validates that a number is a safe integer (within the safe integer range
24923
+ * that can be exactly represented in JavaScript).
24924
+ *
24925
+ * **Details**
24926
+ *
24927
+ * JSON Schema:
24928
+ *
24929
+ * This check corresponds to the `type: "integer"` constraint in JSON Schema.
24930
+ *
24931
+ * Arbitrary:
24932
+ *
24933
+ * When generating test data with fast-check, this applies an `integer: true`
24934
+ * constraint to ensure generated numbers are integers.
24935
+ *
24936
+ * @category Integer checks
24937
+ * @since 4.0.0
24938
+ */
24939
+ function isInt(annotations) {
24940
+ return makeFilter((n) => globalThis.Number.isSafeInteger(n), {
24941
+ expected: "an integer",
24942
+ representation: {
24943
+ id: "effect/schema/isInt",
24944
+ payload: null
24945
+ },
24946
+ toJsonSchema: () => ({ type: "integer" }),
24947
+ toCode: () => ({ runtime: "Schema.isInt()" }),
24948
+ arbitrary: { constraint: { integer: true } },
24949
+ ...annotations
24950
+ });
24951
+ }
24952
+ /**
24724
24953
  * Schema for values that hide sensitive information from error output and
24725
24954
  * inspection.
24726
24955
  *
@@ -73107,39 +73336,46 @@ var Files = class Files extends Service()("react-doctor/Files") {
73107
73336
  };
73108
73337
  };
73109
73338
  const HUNK_HEADER_PATTERN = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@/;
73110
- /**
73111
- * Parses a `git diff --unified=0` patch into the inclusive 1-based line ranges
73112
- * each file added or modified on the new side. Files are keyed by the path in
73113
- * the `+++ b/<path>` header (with `--relative`, relative to the diff's cwd).
73114
- * Added/renamed/modified files appear; pure deletions (`+++ /dev/null`) are
73115
- * skipped because they have no new-side line to report on.
73116
- */
73117
- const parseChangedLineRanges = (patch) => {
73118
- const rangesByFile = /* @__PURE__ */ new Map();
73119
- let currentRanges = null;
73339
+ const parseChangedLineRanges = (patch, includeDeletions = false) => {
73340
+ const changesByFile = /* @__PURE__ */ new Map();
73341
+ let currentChanges = null;
73120
73342
  for (const line of patch.split("\n")) {
73343
+ if (includeDeletions && line.startsWith("rename to ")) {
73344
+ const file = line.slice(10);
73345
+ changesByFile.set(file, {
73346
+ file,
73347
+ ranges: [],
73348
+ deletionLines: []
73349
+ });
73350
+ }
73121
73351
  if (line.startsWith("+++ ")) {
73122
73352
  const target = line.slice(4).trim();
73123
73353
  if (target === "/dev/null") {
73124
- currentRanges = null;
73354
+ currentChanges = null;
73125
73355
  continue;
73126
73356
  }
73127
73357
  const file = target.startsWith("b/") ? target.slice(2) : target;
73128
- currentRanges = rangesByFile.get(file) ?? [];
73129
- rangesByFile.set(file, currentRanges);
73358
+ currentChanges = changesByFile.get(file) ?? {
73359
+ file,
73360
+ ranges: [],
73361
+ deletionLines: []
73362
+ };
73363
+ changesByFile.set(file, currentChanges);
73130
73364
  continue;
73131
73365
  }
73132
- if (currentRanges === null) continue;
73366
+ if (currentChanges === null) continue;
73133
73367
  const hunk = HUNK_HEADER_PATTERN.exec(line);
73134
73368
  if (hunk === null) continue;
73135
73369
  const start = Number(hunk[1]);
73136
73370
  const lineCount = hunk[2] === void 0 ? 1 : Number(hunk[2]);
73137
- if (lineCount <= 0) continue;
73138
- currentRanges.push([start, start + lineCount - 1]);
73371
+ if (lineCount === 0) {
73372
+ if (includeDeletions) currentChanges.deletionLines.push(start);
73373
+ } else currentChanges.ranges.push([start, start + lineCount - 1]);
73139
73374
  }
73140
- return [...rangesByFile].filter(([, ranges]) => ranges.length > 0).map(([file, ranges]) => ({
73375
+ return [...changesByFile.values()].filter((entry) => entry.ranges.length > 0 || includeDeletions).map(({ file, ranges, deletionLines }) => ({
73141
73376
  file,
73142
- ranges
73377
+ ranges,
73378
+ ...deletionLines.length > 0 ? { deletionLines } : {}
73143
73379
  }));
73144
73380
  };
73145
73381
  const trimOrNull = (value) => {
@@ -73624,7 +73860,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
73624
73860
  stdout: result.stdout
73625
73861
  };
73626
73862
  }).pipe(withSpan("Git.grep")),
73627
- changedLineRanges: ({ directory, baseRef, cached, files, includeUntracked = false }) => gen(function* () {
73863
+ changedLineRanges: ({ directory, baseRef, cached, files, includeUntracked = false, includeDeletions = false }) => gen(function* () {
73628
73864
  if (files.length === 0) return [];
73629
73865
  if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
73630
73866
  const result = yield* runGit(directory, [
@@ -73639,7 +73875,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
73639
73875
  ...files
73640
73876
  ]);
73641
73877
  if (result.status !== 0) return null;
73642
- const changedLineRanges = parseChangedLineRanges(result.stdout);
73878
+ const changedLineRanges = parseChangedLineRanges(result.stdout, includeDeletions);
73643
73879
  if (cached || !includeUntracked) return changedLineRanges;
73644
73880
  const untrackedFilePaths = yield* listUntrackedFilePaths(directory, files);
73645
73881
  if (untrackedFilePaths === null) return changedLineRanges;
@@ -74082,6 +74318,7 @@ const normalizeConfigForHash = (config) => {
74082
74318
  const clone = JSON.parse(JSON.stringify(config));
74083
74319
  if (clone?.settings?.["react-doctor"]) {
74084
74320
  const reactDoctorSettings = clone.settings["react-doctor"];
74321
+ delete reactDoctorSettings.diagnosticContextDirectory;
74085
74322
  reactDoctorSettings.rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
74086
74323
  if (Array.isArray(reactDoctorSettings.unpluginAutoImportRootDirectories)) reactDoctorSettings.unpluginAutoImportRootDirectories = [ROOT_DIRECTORY_PLACEHOLDER];
74087
74324
  }
@@ -74243,7 +74480,7 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
74243
74480
  }
74244
74481
  return enabled;
74245
74482
  };
74246
- const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, runtimeGlobals, unpluginAutoImportGlobalScopes, serverAuthFunctionNames, projectIndexModuleSources, severityControls, adoptedSettings = {}, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
74483
+ const createOxlintConfig = ({ pluginPath, diagnosticContextDirectory, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, runtimeGlobals, unpluginAutoImportGlobalScopes, serverAuthFunctionNames, projectIndexModuleSources, severityControls, adoptedSettings = {}, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
74247
74484
  const hasIncludedTags = includedTags.size > 0;
74248
74485
  const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
74249
74486
  const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
@@ -74263,10 +74500,10 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
74263
74500
  if (ruleSelection === "sidecar" && sidecarRuleIdFilter !== void 0 && !sidecarRuleIdFilter.has(registryEntry.id)) continue;
74264
74501
  if (rule.isScanRule || rule.isProjectRule === true) continue;
74265
74502
  if (registryEntry.id === "no-multi-component-file" && shouldUseExplicitNoMultiCompPolicy) continue;
74266
- if (customRulesOnly && registryEntry.originallyExternal) continue;
74267
74503
  if (rule.framework !== "global" && !rule.requires) continue;
74268
74504
  if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) continue;
74269
74505
  const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
74506
+ if (customRulesOnly && registryEntry.originallyExternal && (explicitRuleOverride === void 0 || explicitRuleOverride === "off")) continue;
74270
74507
  if (!shouldEnableRuleByDefaultStatus({
74271
74508
  defaultEnabled: rule.defaultEnabled,
74272
74509
  includeTagDefaults,
@@ -74303,6 +74540,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
74303
74540
  ...adoptedSettings,
74304
74541
  "react-doctor": {
74305
74542
  portedRuleMode: "curated",
74543
+ ...diagnosticContextDirectory ? { diagnosticContextDirectory } : {},
74306
74544
  framework: project.framework,
74307
74545
  rootDirectory: settingsRootDirectory,
74308
74546
  capabilities: [...capabilities].sort(),
@@ -74972,22 +75210,14 @@ const runOxlintProbeJob = async (input) => {
74972
75210
  if (!isProbeResult(parsed) || parsed.traces.length !== input.probeRequest.files.length) throw new Error("oxlint worker returned a malformed probe result");
74973
75211
  return parsed;
74974
75212
  };
74975
- const atomicWriteFile = (filePath, contents) => {
74976
- let temporaryPath = null;
74977
- try {
74978
- fs$1$2.mkdirSync(path$1$1.dirname(filePath), { recursive: true });
74979
- temporaryPath = `${filePath}.${process.pid}.${randomUUID()}.tmp`;
74980
- fs$1$2.writeFileSync(temporaryPath, contents);
74981
- fs$1$2.renameSync(temporaryPath, filePath);
74982
- temporaryPath = null;
74983
- } catch {
74984
- return;
74985
- } finally {
74986
- if (temporaryPath !== null) try {
74987
- fs$1$2.rmSync(temporaryPath, { force: true });
74988
- } catch {}
74989
- }
74990
- };
75213
+ var DiagnosticContextRangeSchema = class extends Class("DiagnosticContextRange")({
75214
+ offset: Number$1.check(isInt(), isGreaterThanOrEqualTo(0)),
75215
+ length: Number$1.check(isInt(), isGreaterThan(0))
75216
+ }) {};
75217
+ var CachedDiagnostic = class extends Class("CachedDiagnostic")({
75218
+ ...Diagnostic.fields,
75219
+ contextRanges: optional(ArraySchema(DiagnosticContextRangeSchema))
75220
+ }) {};
74991
75221
  const atomicWriteJson = (filePath, value) => {
74992
75222
  try {
74993
75223
  atomicWriteFile(filePath, JSON.stringify(value));
@@ -74995,7 +75225,7 @@ const atomicWriteJson = (filePath, value) => {
74995
75225
  return;
74996
75226
  }
74997
75227
  };
74998
- const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
75228
+ const validateDiagnostic$1 = decodeUnknownSync(CachedDiagnostic);
74999
75229
  const decodeDiagnostic = (raw) => {
75000
75230
  const diagnostic = validateDiagnostic$1(raw);
75001
75231
  return {
@@ -75115,7 +75345,7 @@ const createSidecarProbeAnswerResolver = (input) => {
75115
75345
  toRelativePath
75116
75346
  };
75117
75347
  };
75118
- const validateDiagnostic = decodeUnknownSync(Diagnostic);
75348
+ const validateDiagnostic = decodeUnknownSync(CachedDiagnostic);
75119
75349
  const isProbeKind = (value) => value === "content" || value === "exists";
75120
75350
  const isProbeIdArray = (value, probeCount) => Array.isArray(value) && value.every((probeId) => typeof probeId === "number" && Number.isInteger(probeId) && probeId >= 0 && probeId < probeCount);
75121
75351
  const createProbeTable = () => {
@@ -75357,6 +75587,29 @@ const columnOfUtf8Offset = (sourceBuffer, utf8Offset) => {
75357
75587
  while (lineStartOffset > 0 && sourceBuffer[lineStartOffset - 1] !== 10) lineStartOffset--;
75358
75588
  return sourceBuffer.subarray(lineStartOffset, boundedOffset).toString("utf8").length + 1;
75359
75589
  };
75590
+ const decodeRanges = decodeUnknownSync(ArraySchema(DiagnosticContextRangeSchema));
75591
+ const createDiagnosticContextReader = (directory) => {
75592
+ const recordedRules = /* @__PURE__ */ new Set();
75593
+ if (directory) try {
75594
+ for (const filename of fs$1$2.readdirSync(directory)) {
75595
+ if (!filename.endsWith(".json")) continue;
75596
+ recordedRules.add(filename.slice(0, filename.lastIndexOf("-")));
75597
+ }
75598
+ } catch {
75599
+ recordedRules.clear();
75600
+ }
75601
+ return (identity) => {
75602
+ if (!directory || !recordedRules.has(encodeURIComponent(identity.rule))) return [];
75603
+ try {
75604
+ return decodeRanges(failOpenReadJson(getDiagnosticContextPath({
75605
+ ...identity,
75606
+ directory
75607
+ }), []));
75608
+ } catch {
75609
+ return [];
75610
+ }
75611
+ };
75612
+ };
75360
75613
  const utf8OffsetFromSourcePosition = (sourceBuffer, lineNumber, zeroBasedColumn) => {
75361
75614
  if (lineNumber < 1 || zeroBasedColumn < 0) return null;
75362
75615
  const sourceLines = sourceBuffer.toString("utf8").split("\n");
@@ -75998,7 +76251,7 @@ const isOxlintOutput = (value) => isRecord(value) && Array.isArray(value.diagnos
75998
76251
  * to the first `{`. Raises `OxlintOutputUnparseable` when the
75999
76252
  * stdout isn't valid JSON or doesn't carry a `diagnostics` array.
76000
76253
  */
76001
- const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath) => {
76254
+ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath, diagnosticContextDirectory) => {
76002
76255
  if (!stdout) return [];
76003
76256
  const jsonStart = stdout.indexOf("{");
76004
76257
  const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
@@ -76048,19 +76301,33 @@ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath,
76048
76301
  minifiedFileCache.set(absolutePath, minified);
76049
76302
  return minified;
76050
76303
  };
76051
- return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.flatMap((diagnostic) => {
76304
+ const readContextRanges = createDiagnosticContextReader(diagnosticContextDirectory);
76305
+ return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.flatMap((rawDiagnostic) => {
76306
+ if (!isMappableOxlintDiagnostic(rawDiagnostic)) return [];
76307
+ const { plugin, rule } = parseRuleCode(rawDiagnostic.code);
76308
+ const primarySpan = rawDiagnostic.labels[0]?.span;
76309
+ const contextRanges = diagnosticContextDirectory && plugin === "react-doctor" && primarySpan ? readContextRanges({
76310
+ filename: resolveAbsolutePath(rawDiagnostic.filename),
76311
+ rule,
76312
+ offset: primarySpan.offset,
76313
+ message: rawDiagnostic.message
76314
+ }) : [];
76315
+ const diagnostic = {
76316
+ ...rawDiagnostic,
76317
+ contextRanges
76318
+ };
76052
76319
  const preparedSourceMap = resolvePreparedSourceMap(diagnostic.filename);
76053
76320
  if (preparedSourceMap === void 0) return [diagnostic];
76054
- const { plugin, rule } = parseRuleCode(diagnostic.code);
76055
76321
  if (plugin !== "react-doctor" || !REACT_DOCTOR_RULE_REGISTRY[rule]?.tags?.includes("design")) return [];
76056
76322
  const labels = mapPreparedSourceLabels(diagnostic.labels, preparedSourceMap);
76057
76323
  const sourceFilename = resolveMappedSourceFilename(diagnostic.filename);
76058
76324
  return labels === null || sourceFilename === void 0 ? [] : [{
76059
76325
  ...diagnostic,
76060
76326
  filename: sourceFilename,
76061
- labels
76327
+ labels,
76328
+ contextRanges: []
76062
76329
  }];
76063
- }).filter((diagnostic) => isMappableOxlintDiagnostic(diagnostic) && isLintableSourceFile(resolveSourceFilename(diagnostic.filename)) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
76330
+ }).filter((diagnostic) => isLintableSourceFile(resolveSourceFilename(diagnostic.filename)) && !(TYPESCRIPT_DECLARATION_FILE_PATTERN.test(diagnostic.filename) && OXLINT_IGNORED_DECLARATION_DIAGNOSTIC_CODES.has(diagnostic.code)) && !isMinifiedDiagnosticFile(diagnostic.filename) && !shouldSuppressLocalUseHookDiagnostic(diagnostic, rootDirectory) && !shouldSuppressCompilerFindingInWorklet(diagnostic, project, rootDirectory)).map((diagnostic) => {
76064
76331
  const { plugin, rule } = parseRuleCode(diagnostic.code);
76065
76332
  const primaryLabel = diagnostic.labels[0];
76066
76333
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
@@ -76097,6 +76364,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath,
76097
76364
  ...primarySpanEndLine !== void 0 ? { endLine: primarySpanEndLine } : {}
76098
76365
  } : {},
76099
76366
  category,
76367
+ ...diagnostic.contextRanges.length > 0 ? { contextRanges: diagnostic.contextRanges } : {},
76100
76368
  ...matchByOccurrence ? { matchByOccurrence: true } : {},
76101
76369
  ...relatedLocations.length > 0 ? { relatedLocations } : {}
76102
76370
  };
@@ -76209,7 +76477,7 @@ const spawnLintBatches = async (input) => {
76209
76477
  };
76210
76478
  const stdout = input.spawnSlots === void 0 ? await spawnBatch() : await input.spawnSlots.run(spawnBatch, signal);
76211
76479
  if (stdout === null) return [];
76212
- return parseOxlintOutput(stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath);
76480
+ return parseOxlintOutput(stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath, input.diagnosticContextDirectory);
76213
76481
  } catch (error) {
76214
76482
  if (!isSplittableReactDoctorError(error)) throw error;
76215
76483
  if (isPastDeadline()) {
@@ -76938,6 +77206,8 @@ const runOxlint = async (options) => {
76938
77206
  const configDirectory = fs$1$2.mkdtempSync(path$1$1.join(os.tmpdir(), "react-doctor-oxlintrc-"));
76939
77207
  const configPath = path$1$1.join(configDirectory, "oxlintrc.json");
76940
77208
  try {
77209
+ const diagnosticContextDirectory = path$1$1.join(configDirectory, "contexts");
77210
+ fs$1$2.mkdirSync(diagnosticContextDirectory);
76941
77211
  const oxlintBinary = resolveOxlintBinary();
76942
77212
  const sharedArgs = [];
76943
77213
  let tsconfigContent = null;
@@ -76986,6 +77256,7 @@ const runOxlint = async (options) => {
76986
77256
  } : project;
76987
77257
  const buildConfig = (overrides) => createOxlintConfig({
76988
77258
  pluginPath,
77259
+ diagnosticContextDirectory,
76989
77260
  project: lintProject,
76990
77261
  customRulesOnly,
76991
77262
  extendsPaths: overrides.extendsPaths,
@@ -77037,6 +77308,7 @@ const runOxlint = async (options) => {
77037
77308
  project: lintProject,
77038
77309
  sourcePathByLintPath: preparedLintSources.sourcePathByLintPath,
77039
77310
  sourceMapByLintPath: preparedLintSources.sourceMapByLintPath,
77311
+ diagnosticContextDirectory,
77040
77312
  onPartialFailure: reportPartialFailure,
77041
77313
  onAnalyzedFiles: (filePaths) => {
77042
77314
  analyzedFiles = filePaths;
@@ -77264,6 +77536,7 @@ const runOxlint = async (options) => {
77264
77536
  project: lintProject,
77265
77537
  sourcePathByLintPath: preparedLintSources.sourcePathByLintPath,
77266
77538
  sourceMapByLintPath: preparedLintSources.sourceMapByLintPath,
77539
+ diagnosticContextDirectory,
77267
77540
  onPartialFailure,
77268
77541
  onAnalyzedFiles: (filePaths) => {
77269
77542
  analyzedFiles = filePaths;
@@ -77560,7 +77833,7 @@ const ScoreApiResponseSchema = Struct({
77560
77833
  });
77561
77834
  const EMPTY_SCORE_REQUEST_METADATA = {};
77562
77835
  const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
77563
- const sanitizeScoreDiagnostics = (diagnostics) => diagnostics.map(({ filePath, fileContext: _fileContext, fixGroupId: _fixGroupId, ...rest }) => ({
77836
+ const sanitizeScoreDiagnostics = (diagnostics) => diagnostics.map(({ filePath, fileContext: _fileContext, fixGroupId: _fixGroupId, contextRanges: _contextRanges, ...rest }) => ({
77564
77837
  ...rest,
77565
77838
  filePath: redactSensitiveText(scrubSensitivePaths(filePath))
77566
77839
  }));
@@ -78816,12 +79089,13 @@ const findWorstScoredProject = (projects) => {
78816
79089
  return worst;
78817
79090
  };
78818
79091
  const toJsonReportDiagnostic = (diagnostic, projectRoot, reportRoot) => {
79092
+ const { contextRanges: _contextRanges, ...publicDiagnostic } = diagnostic;
78819
79093
  const resolvedFilePath = resolveCandidateReadPath(projectRoot, diagnostic.filePath);
78820
79094
  const normalizedFilePath = toNormalizedRelativePath(resolvedFilePath, projectRoot);
78821
79095
  const reportRelativeFilePath = toNormalizedRelativePath(resolvedFilePath, reportRoot);
78822
79096
  const ruleIdentity = getDiagnosticRuleIdentity(diagnostic);
78823
79097
  return {
78824
- ...diagnostic,
79098
+ ...publicDiagnostic,
78825
79099
  id: buildDiagnosticIdentity({
78826
79100
  filePath: reportRelativeFilePath,
78827
79101
  line: diagnostic.line,
@@ -79314,4 +79588,4 @@ const toJsonReport = (result, options) => buildJsonReport({
79314
79588
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
79315
79589
 
79316
79590
  //# sourceMappingURL=index.js.map
79317
- //# debugId=d2b0583c-877f-57cf-8b0a-65519428807c
79591
+ //# debugId=f19a4e97-e6d1-58b3-b9ee-17a3545fa20d