react-doctor 0.9.17 → 0.9.18-dev.813bd63

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-dm7eyygx.js} +5 -5
  3. package/dist/{ci-DNtt9X6S.js → ci-Cs3iD71x.js} +24 -14
  4. package/dist/cli.js +41 -32
  5. package/dist/{constants-DHn5rUeg.js → constants-ClqojoT2.js} +8 -5
  6. package/dist/constants-DNh19qg9.js +2 -2
  7. package/dist/{design-u2afuNir.js → design-5HU24djx.js} +4 -4
  8. package/dist/duplicate-jsx-worker.js +3 -3
  9. package/dist/{exit-gracefully-DlI5QxjC.js → exit-gracefully-wYeFSUnb.js} +6 -6
  10. package/dist/{handle-error-ChH7NTTt.js → handle-error-SLUu0g1m.js} +6 -6
  11. package/dist/index.d.ts +14 -6
  12. package/dist/index.js +334 -58
  13. package/dist/{inspect-BEMrqB0D.js → inspect-cPD5eW0z.js} +31 -23
  14. package/dist/{install-rmw4kZuQ.js → install-CZefUZ92.js} +10 -10
  15. package/dist/{install-doctor-script-D5XbyGON.js → install-doctor-script-B8Xe0Mag.js} +10 -6
  16. package/dist/{install-github-workflow-bsR3MAJ4.js → install-github-workflow-BxDIC-U8.js} +22 -8
  17. package/dist/{install-react-doctor-CEZd9boZ.js → install-react-doctor-B8C1JYku.js} +9 -9
  18. package/dist/{is-cache-globally-disabled-DDlh_f1u.js → is-cache-globally-disabled-DnyI809X.js} +4 -4
  19. package/dist/{jsx-runtime-RhgTgCyJ.js → jsx-runtime-CI4NT3b7.js} +6 -6
  20. package/dist/{print-branded-header-DUpSxfB1.js → print-branded-header-C76LxHJV.js} +4 -4
  21. package/dist/{prompt-runtime-scan-url-ClnyA-kD.js → prompt-runtime-scan-url-JEKSBImN.js} +5 -5
  22. package/dist/{read-object-file-BmbbCthv.js → read-object-file-BS-5zIix.js} +4 -4
  23. package/dist/{record-metric-BNXhF2A-.js → record-metric-D2Sa2-8-.js} +440 -84
  24. package/dist/{report-error-BaQdqDfo.js → report-error-2AuVnp86.js} +6 -6
  25. package/dist/{report-workflow-result-keduRDKN.js → report-workflow-result-BaBn-KfJ.js} +8 -7
  26. package/dist/{should-fail-scan-gate-DobEL_kS.js → resolve-scan-exit-code-jAj4CxMz.js} +38 -41
  27. package/dist/{resolve-scope-_R9av4PA.js → resolve-scope-DagI1fQi.js} +10 -9
  28. package/dist/{rules-mbLozamL.js → rules-C8iVdbp-.js} +7 -7
  29. package/dist/{run-scan-app-yG6ELpUl.js → run-scan-app-CjXVZiDW.js} +33 -23
  30. package/dist/{runtime-scan-DNhYo683.js → runtime-scan-CjpmdWgB.js} +10 -10
  31. package/dist/{sanitize-runtime-url-DM_qbPGY.js → sanitize-runtime-url-T9kZq9xg.js} +4 -4
  32. package/dist/{scan-CAAixMS9.js → scan-yyDeSdpu.js} +14 -13
  33. package/dist/{should-skip-prompts-CGTEgq2F.js → should-skip-prompts-CgXCf-fu.js} +4 -4
  34. package/dist/{should-use-tui-DG2l-Td3.js → should-use-tui-ChbrCcWt.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-DgEn5GlY.js} +5 -5
  38. package/dist/start-scan-preamble.js +3 -3
  39. package/dist/{telemetry-runtime-CUn1--rM.js → telemetry-runtime-d441ptET.js} +7 -7
  40. package/dist/{version-CbFBCUY9.js → version-Dsv4KbVD.js} +5 -5
  41. package/dist/{why-BIX2FUbP.js → why-BtPJ-AQi.js} +4 -4
  42. package/dist/{with-run-span-BsS7dU6e.js → with-run-span-CKkLeVWr.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]="afc70a52-08b0-58db-884e-b2a97b988208")}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-C2xkPKhq.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",
@@ -57,6 +58,7 @@ const IGNORED_DIRECTORIES = new Set([
57
58
  ".next",
58
59
  ".nuxt",
59
60
  ".nx",
61
+ ".open-next",
60
62
  ".output",
61
63
  ".parcel-cache",
62
64
  ".serverless",
@@ -438,7 +440,7 @@ const isPlainObject = (value) => {
438
440
  //#region ../core/dist/react-compiler-detection-worker-protocol-Dp5LlrE8.js
439
441
  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
442
  //#endregion
441
- //#region ../core/dist/react-compiler-detection-client-fc698QTY.js
443
+ //#region ../core/dist/react-compiler-detection-client-DdqffphF.js
442
444
  const pendingOutputsByRequestKey = /* @__PURE__ */ new Map();
443
445
  const toRequestKey = (request) => [
444
446
  request.directory,
@@ -2708,7 +2710,7 @@ var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
2708
2710
  module.exports = picomatch;
2709
2711
  }));
2710
2712
  //#endregion
2711
- //#region ../core/dist/collect-unplugin-auto-import-global-scopes-D2Skzhl1.js
2713
+ //#region ../core/dist/collect-unplugin-auto-import-global-scopes-BQdHXHtB.js
2712
2714
  var import_picomatch = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
2713
2715
  const pico = require_picomatch$1();
2714
2716
  const utils = require_utils();
@@ -3158,14 +3160,14 @@ const collectUnpluginAutoImportGlobalScopes = ({ rootDirectory, candidateFiles }
3158
3160
  return scopes.some((scope) => scope.names.length > 0) ? scopes : [];
3159
3161
  };
3160
3162
  //#endregion
3161
- //#region ../core/dist/detect-duplicate-jsx-subtrees-CzQouU4i.js
3163
+ //#region ../core/dist/detect-duplicate-jsx-subtrees-Bzyc0NTl.js
3162
3164
  const yieldToEventLoop = () => new Promise((resolve) => {
3163
3165
  setImmediate(resolve);
3164
3166
  });
3165
3167
  const getTypescriptScriptKind = (fileName) => {
3166
3168
  if (fileName.endsWith(".tsx")) return typescriptBinding.ScriptKind.TSX;
3167
3169
  if (fileName.endsWith(".jsx")) return typescriptBinding.ScriptKind.JSX;
3168
- if (fileName.endsWith(".ts")) return typescriptBinding.ScriptKind.TS;
3170
+ if (/\.[cm]?ts$/.test(fileName)) return typescriptBinding.ScriptKind.TS;
3169
3171
  return typescriptBinding.ScriptKind.JS;
3170
3172
  };
3171
3173
  const resolveBoundedSourceReadBytes = (maximumLengthChars, sizeBytes) => Math.min(sizeBytes, maximumLengthChars * 3 + 1);
@@ -3715,7 +3717,7 @@ const detectDuplicateJsxSubtreesCooperative = async (sourceReader, options = {})
3715
3717
  });
3716
3718
  };
3717
3719
  //#endregion
3718
- //#region ../core/dist/detect-react-compiler-DIKiMJ1N.js
3720
+ //#region ../core/dist/detect-react-compiler-CPYDw8CR.js
3719
3721
  const NEXT_CONFIG_FILENAMES = [
3720
3722
  "next.config.js",
3721
3723
  "next.config.mjs",
@@ -7837,6 +7839,37 @@ const mapInput = /* @__PURE__ */ dual(2, (self, f) => make$37((b1, b2) => self(f
7837
7839
  */
7838
7840
  const isGreaterThan$1 = (O) => dual(2, (self, that) => O(self, that) === 1);
7839
7841
  /**
7842
+ * Checks whether one value is greater than or equal to another according to the given order.
7843
+ *
7844
+ * **When to use**
7845
+ *
7846
+ * Use when you need a boolean greater-than-or-equal predicate using an
7847
+ * `Order`.
7848
+ *
7849
+ * **Details**
7850
+ *
7851
+ * Returns `true` if the order returns `1` or `0`, and returns `false` only if
7852
+ * the order returns `-1`.
7853
+ *
7854
+ * **Example** (Checking greater-than-or-equal comparisons)
7855
+ *
7856
+ * ```ts
7857
+ * import { Order } from "effect"
7858
+ *
7859
+ * const isGreaterThanOrEqualToNumber = Order.isGreaterThanOrEqualTo(Order.Number)
7860
+ *
7861
+ * console.log(isGreaterThanOrEqualToNumber(2, 1)) // true
7862
+ * console.log(isGreaterThanOrEqualToNumber(1, 1)) // true
7863
+ * console.log(isGreaterThanOrEqualToNumber(1, 2)) // false
7864
+ * ```
7865
+ *
7866
+ * @see {@link isGreaterThan} for strict greater than
7867
+ * @see {@link isLessThanOrEqualTo} for less than or equal
7868
+ * @category predicates
7869
+ * @since 4.0.0
7870
+ */
7871
+ const isGreaterThanOrEqualTo$1 = (O) => dual(2, (self, that) => O(self, that) !== -1);
7872
+ /**
7840
7873
  * Returns the maximum of two values according to the given order. If they are equal, returns the first argument.
7841
7874
  *
7842
7875
  * **When to use**
@@ -24721,6 +24754,203 @@ function link$1() {
24721
24754
  };
24722
24755
  }
24723
24756
  /**
24757
+ * Creates a custom validation filter from a predicate function.
24758
+ *
24759
+ * **Details**
24760
+ *
24761
+ * The predicate receives the decoded input value, the schema AST, and parse
24762
+ * options, and returns a `FilterOutput`. Non-success outputs are normalized into
24763
+ * schema issues. The `annotations` parameter annotates the filter itself; with
24764
+ * the default formatter, failures use `message` first, `expected` second, and
24765
+ * `<filter>` when neither is provided.
24766
+ *
24767
+ * When `abort` is `true`, parsing stops after this filter fails instead of
24768
+ * collecting later check failures.
24769
+ *
24770
+ * **Example** (Reporting failure at a nested path)
24771
+ *
24772
+ * ```ts
24773
+ * import { Schema } from "effect"
24774
+ *
24775
+ * const schema = Schema.Struct({ password: Schema.String, confirmPassword: Schema.String }).check(
24776
+ * Schema.makeFilter((o) =>
24777
+ * o.password === o.confirmPassword
24778
+ * ? undefined
24779
+ * : { path: ["password"], issue: "password and confirmPassword must match" }
24780
+ * )
24781
+ * )
24782
+ *
24783
+ * console.log(String(Schema.decodeUnknownExit(schema)({ password: "123456", confirmPassword: "1234567" })))
24784
+ * // Failure(Cause([Fail(SchemaError: password and confirmPassword must match
24785
+ * // at ["password"])]))
24786
+ * ```
24787
+ *
24788
+ * **Example** (Reporting multiple failures at once)
24789
+ *
24790
+ * ```ts
24791
+ * import { Schema } from "effect"
24792
+ *
24793
+ * const schema = Schema.Struct({ a: Schema.Finite, b: Schema.Finite, c: Schema.Finite }).check(
24794
+ * Schema.makeFilter((o) => {
24795
+ * const issues: Array<Schema.FilterIssue> = []
24796
+ * if (o.a > 0) {
24797
+ * if (o.b <= 0) issues.push({ path: ["b"], issue: "b must be greater than 0" })
24798
+ * if (o.c <= 0) issues.push({ path: ["c"], issue: "c must be greater than 0" })
24799
+ * }
24800
+ * return issues
24801
+ * })
24802
+ * )
24803
+ *
24804
+ * console.log(String(Schema.decodeUnknownExit(schema)({ a: 1, b: 0, c: 0 })))
24805
+ * // Failure(Cause([Fail(SchemaError: b must be greater than 0
24806
+ * // at ["b"]
24807
+ * // c must be greater than 0
24808
+ * // at ["c"])]))
24809
+ * ```
24810
+ *
24811
+ * @category constructors
24812
+ * @since 4.0.0
24813
+ */
24814
+ const makeFilter = makeFilter$1;
24815
+ /**
24816
+ * Creates a greater-than (`>`) check for any ordered type from an
24817
+ * `Order.Order` instance.
24818
+ *
24819
+ * @category Order checks
24820
+ * @since 4.0.0
24821
+ */
24822
+ function makeIsGreaterThan(options) {
24823
+ const gt = isGreaterThan$1(options.order);
24824
+ const formatter = options.formatter ?? format$1;
24825
+ return (exclusiveMinimum, annotations) => {
24826
+ return makeFilter((input) => gt(input, exclusiveMinimum), {
24827
+ expected: `a value greater than ${formatter(exclusiveMinimum)}`,
24828
+ arbitrary: { constraint: { ordered: {
24829
+ order: options.order,
24830
+ minimum: exclusiveMinimum,
24831
+ exclusiveMinimum: true
24832
+ } } },
24833
+ ...options.annotate?.(exclusiveMinimum),
24834
+ ...annotations
24835
+ });
24836
+ };
24837
+ }
24838
+ /**
24839
+ * Creates a greater-than-or-equal-to (`>=`) check for any ordered type from an
24840
+ * `Order.Order` instance.
24841
+ *
24842
+ * @category Order checks
24843
+ * @since 4.0.0
24844
+ */
24845
+ function makeIsGreaterThanOrEqualTo(options) {
24846
+ const gte = isGreaterThanOrEqualTo$1(options.order);
24847
+ const formatter = options.formatter ?? format$1;
24848
+ return (minimum, annotations) => {
24849
+ return makeFilter((input) => gte(input, minimum), {
24850
+ expected: `a value greater than or equal to ${formatter(minimum)}`,
24851
+ arbitrary: { constraint: { ordered: {
24852
+ order: options.order,
24853
+ minimum
24854
+ } } },
24855
+ ...options.annotate?.(minimum),
24856
+ ...annotations
24857
+ });
24858
+ };
24859
+ }
24860
+ function encodeNumberPayload(number) {
24861
+ if (!globalThis.Number.isFinite(number)) throw new globalThis.RangeError(`Expected a finite number, got ${format$1(number)}`);
24862
+ return number;
24863
+ }
24864
+ /**
24865
+ * Validates that a number is greater than the specified value (exclusive).
24866
+ *
24867
+ * **Details**
24868
+ *
24869
+ * JSON Schema:
24870
+ *
24871
+ * This check corresponds to the `exclusiveMinimum` constraint in JSON Schema.
24872
+ *
24873
+ * Arbitrary:
24874
+ *
24875
+ * When generating test data with fast-check, this applies an
24876
+ * `exclusiveMinimum` constraint to ensure generated numbers are greater than
24877
+ * the specified value.
24878
+ *
24879
+ * @category Number checks
24880
+ * @since 4.0.0
24881
+ */
24882
+ const isGreaterThan = /* @__PURE__ */ makeIsGreaterThan({
24883
+ order: Number$5,
24884
+ annotate: (exclusiveMinimum) => ({
24885
+ representation: {
24886
+ id: "effect/schema/isGreaterThan",
24887
+ payload: { exclusiveMinimum: encodeNumberPayload(exclusiveMinimum) }
24888
+ },
24889
+ toJsonSchema: () => ({ exclusiveMinimum }),
24890
+ toCode: () => ({ runtime: `Schema.isGreaterThan(${format$1(exclusiveMinimum)})` })
24891
+ })
24892
+ });
24893
+ /**
24894
+ * Validates that a number is greater than or equal to the specified value
24895
+ * (inclusive).
24896
+ *
24897
+ * **Details**
24898
+ *
24899
+ * JSON Schema:
24900
+ *
24901
+ * This check corresponds to the `minimum` constraint in JSON Schema.
24902
+ *
24903
+ * Arbitrary:
24904
+ *
24905
+ * When generating test data with fast-check, this applies a `minimum` constraint
24906
+ * to ensure generated numbers are greater than or equal to the specified value.
24907
+ *
24908
+ * @category Number checks
24909
+ * @since 4.0.0
24910
+ */
24911
+ const isGreaterThanOrEqualTo = /* @__PURE__ */ makeIsGreaterThanOrEqualTo({
24912
+ order: Number$5,
24913
+ annotate: (minimum) => ({
24914
+ representation: {
24915
+ id: "effect/schema/isGreaterThanOrEqualTo",
24916
+ payload: { minimum: encodeNumberPayload(minimum) }
24917
+ },
24918
+ toJsonSchema: () => ({ minimum }),
24919
+ toCode: () => ({ runtime: `Schema.isGreaterThanOrEqualTo(${format$1(minimum)})` })
24920
+ })
24921
+ });
24922
+ /**
24923
+ * Validates that a number is a safe integer (within the safe integer range
24924
+ * that can be exactly represented in JavaScript).
24925
+ *
24926
+ * **Details**
24927
+ *
24928
+ * JSON Schema:
24929
+ *
24930
+ * This check corresponds to the `type: "integer"` constraint in JSON Schema.
24931
+ *
24932
+ * Arbitrary:
24933
+ *
24934
+ * When generating test data with fast-check, this applies an `integer: true`
24935
+ * constraint to ensure generated numbers are integers.
24936
+ *
24937
+ * @category Integer checks
24938
+ * @since 4.0.0
24939
+ */
24940
+ function isInt(annotations) {
24941
+ return makeFilter((n) => globalThis.Number.isSafeInteger(n), {
24942
+ expected: "an integer",
24943
+ representation: {
24944
+ id: "effect/schema/isInt",
24945
+ payload: null
24946
+ },
24947
+ toJsonSchema: () => ({ type: "integer" }),
24948
+ toCode: () => ({ runtime: "Schema.isInt()" }),
24949
+ arbitrary: { constraint: { integer: true } },
24950
+ ...annotations
24951
+ });
24952
+ }
24953
+ /**
24724
24954
  * Schema for values that hide sensitive information from error output and
24725
24955
  * inspection.
24726
24956
  *
@@ -72104,6 +72334,7 @@ const SECURITY_SCAN_MAX_FILE_SIZE_BYTES = 2 * 1024 * 1024;
72104
72334
  const SECURITY_SCAN_MAX_BUNDLE_FILE_SIZE_BYTES = 8 * 1024 * 1024;
72105
72335
  const SKIPPED_DIRECTORY_NAMES = new Set([
72106
72336
  ".git",
72337
+ ".open-next",
72107
72338
  ".turbo",
72108
72339
  ".vercel",
72109
72340
  "coverage",
@@ -73107,39 +73338,46 @@ var Files = class Files extends Service()("react-doctor/Files") {
73107
73338
  };
73108
73339
  };
73109
73340
  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;
73341
+ const parseChangedLineRanges = (patch, includeDeletions = false) => {
73342
+ const changesByFile = /* @__PURE__ */ new Map();
73343
+ let currentChanges = null;
73120
73344
  for (const line of patch.split("\n")) {
73345
+ if (includeDeletions && line.startsWith("rename to ")) {
73346
+ const file = line.slice(10);
73347
+ changesByFile.set(file, {
73348
+ file,
73349
+ ranges: [],
73350
+ deletionLines: []
73351
+ });
73352
+ }
73121
73353
  if (line.startsWith("+++ ")) {
73122
73354
  const target = line.slice(4).trim();
73123
73355
  if (target === "/dev/null") {
73124
- currentRanges = null;
73356
+ currentChanges = null;
73125
73357
  continue;
73126
73358
  }
73127
73359
  const file = target.startsWith("b/") ? target.slice(2) : target;
73128
- currentRanges = rangesByFile.get(file) ?? [];
73129
- rangesByFile.set(file, currentRanges);
73360
+ currentChanges = changesByFile.get(file) ?? {
73361
+ file,
73362
+ ranges: [],
73363
+ deletionLines: []
73364
+ };
73365
+ changesByFile.set(file, currentChanges);
73130
73366
  continue;
73131
73367
  }
73132
- if (currentRanges === null) continue;
73368
+ if (currentChanges === null) continue;
73133
73369
  const hunk = HUNK_HEADER_PATTERN.exec(line);
73134
73370
  if (hunk === null) continue;
73135
73371
  const start = Number(hunk[1]);
73136
73372
  const lineCount = hunk[2] === void 0 ? 1 : Number(hunk[2]);
73137
- if (lineCount <= 0) continue;
73138
- currentRanges.push([start, start + lineCount - 1]);
73373
+ if (lineCount === 0) {
73374
+ if (includeDeletions) currentChanges.deletionLines.push(start);
73375
+ } else currentChanges.ranges.push([start, start + lineCount - 1]);
73139
73376
  }
73140
- return [...rangesByFile].filter(([, ranges]) => ranges.length > 0).map(([file, ranges]) => ({
73377
+ return [...changesByFile.values()].filter((entry) => entry.ranges.length > 0 || includeDeletions).map(({ file, ranges, deletionLines }) => ({
73141
73378
  file,
73142
- ranges
73379
+ ranges,
73380
+ ...deletionLines.length > 0 ? { deletionLines } : {}
73143
73381
  }));
73144
73382
  };
73145
73383
  const trimOrNull = (value) => {
@@ -73624,7 +73862,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
73624
73862
  stdout: result.stdout
73625
73863
  };
73626
73864
  }).pipe(withSpan("Git.grep")),
73627
- changedLineRanges: ({ directory, baseRef, cached, files, includeUntracked = false }) => gen(function* () {
73865
+ changedLineRanges: ({ directory, baseRef, cached, files, includeUntracked = false, includeDeletions = false }) => gen(function* () {
73628
73866
  if (files.length === 0) return [];
73629
73867
  if (baseRef !== void 0 && !isSafeGitRevision(baseRef)) return null;
73630
73868
  const result = yield* runGit(directory, [
@@ -73639,7 +73877,7 @@ var Git = class Git extends Service()("react-doctor/Git") {
73639
73877
  ...files
73640
73878
  ]);
73641
73879
  if (result.status !== 0) return null;
73642
- const changedLineRanges = parseChangedLineRanges(result.stdout);
73880
+ const changedLineRanges = parseChangedLineRanges(result.stdout, includeDeletions);
73643
73881
  if (cached || !includeUntracked) return changedLineRanges;
73644
73882
  const untrackedFilePaths = yield* listUntrackedFilePaths(directory, files);
73645
73883
  if (untrackedFilePaths === null) return changedLineRanges;
@@ -74082,6 +74320,7 @@ const normalizeConfigForHash = (config) => {
74082
74320
  const clone = JSON.parse(JSON.stringify(config));
74083
74321
  if (clone?.settings?.["react-doctor"]) {
74084
74322
  const reactDoctorSettings = clone.settings["react-doctor"];
74323
+ delete reactDoctorSettings.diagnosticContextDirectory;
74085
74324
  reactDoctorSettings.rootDirectory = ROOT_DIRECTORY_PLACEHOLDER;
74086
74325
  if (Array.isArray(reactDoctorSettings.unpluginAutoImportRootDirectories)) reactDoctorSettings.unpluginAutoImportRootDirectories = [ROOT_DIRECTORY_PLACEHOLDER];
74087
74326
  }
@@ -74243,7 +74482,7 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
74243
74482
  }
74244
74483
  return enabled;
74245
74484
  };
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 }) => {
74485
+ 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
74486
  const hasIncludedTags = includedTags.size > 0;
74248
74487
  const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
74249
74488
  const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
@@ -74263,10 +74502,10 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
74263
74502
  if (ruleSelection === "sidecar" && sidecarRuleIdFilter !== void 0 && !sidecarRuleIdFilter.has(registryEntry.id)) continue;
74264
74503
  if (rule.isScanRule || rule.isProjectRule === true) continue;
74265
74504
  if (registryEntry.id === "no-multi-component-file" && shouldUseExplicitNoMultiCompPolicy) continue;
74266
- if (customRulesOnly && registryEntry.originallyExternal) continue;
74267
74505
  if (rule.framework !== "global" && !rule.requires) continue;
74268
74506
  if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) continue;
74269
74507
  const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
74508
+ if (customRulesOnly && registryEntry.originallyExternal && (explicitRuleOverride === void 0 || explicitRuleOverride === "off")) continue;
74270
74509
  if (!shouldEnableRuleByDefaultStatus({
74271
74510
  defaultEnabled: rule.defaultEnabled,
74272
74511
  includeTagDefaults,
@@ -74303,6 +74542,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
74303
74542
  ...adoptedSettings,
74304
74543
  "react-doctor": {
74305
74544
  portedRuleMode: "curated",
74545
+ ...diagnosticContextDirectory ? { diagnosticContextDirectory } : {},
74306
74546
  framework: project.framework,
74307
74547
  rootDirectory: settingsRootDirectory,
74308
74548
  capabilities: [...capabilities].sort(),
@@ -74972,22 +75212,14 @@ const runOxlintProbeJob = async (input) => {
74972
75212
  if (!isProbeResult(parsed) || parsed.traces.length !== input.probeRequest.files.length) throw new Error("oxlint worker returned a malformed probe result");
74973
75213
  return parsed;
74974
75214
  };
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
- };
75215
+ var DiagnosticContextRangeSchema = class extends Class("DiagnosticContextRange")({
75216
+ offset: Number$1.check(isInt(), isGreaterThanOrEqualTo(0)),
75217
+ length: Number$1.check(isInt(), isGreaterThan(0))
75218
+ }) {};
75219
+ var CachedDiagnostic = class extends Class("CachedDiagnostic")({
75220
+ ...Diagnostic.fields,
75221
+ contextRanges: optional(ArraySchema(DiagnosticContextRangeSchema))
75222
+ }) {};
74991
75223
  const atomicWriteJson = (filePath, value) => {
74992
75224
  try {
74993
75225
  atomicWriteFile(filePath, JSON.stringify(value));
@@ -74995,7 +75227,7 @@ const atomicWriteJson = (filePath, value) => {
74995
75227
  return;
74996
75228
  }
74997
75229
  };
74998
- const validateDiagnostic$1 = decodeUnknownSync(Diagnostic);
75230
+ const validateDiagnostic$1 = decodeUnknownSync(CachedDiagnostic);
74999
75231
  const decodeDiagnostic = (raw) => {
75000
75232
  const diagnostic = validateDiagnostic$1(raw);
75001
75233
  return {
@@ -75115,7 +75347,7 @@ const createSidecarProbeAnswerResolver = (input) => {
75115
75347
  toRelativePath
75116
75348
  };
75117
75349
  };
75118
- const validateDiagnostic = decodeUnknownSync(Diagnostic);
75350
+ const validateDiagnostic = decodeUnknownSync(CachedDiagnostic);
75119
75351
  const isProbeKind = (value) => value === "content" || value === "exists";
75120
75352
  const isProbeIdArray = (value, probeCount) => Array.isArray(value) && value.every((probeId) => typeof probeId === "number" && Number.isInteger(probeId) && probeId >= 0 && probeId < probeCount);
75121
75353
  const createProbeTable = () => {
@@ -75357,6 +75589,29 @@ const columnOfUtf8Offset = (sourceBuffer, utf8Offset) => {
75357
75589
  while (lineStartOffset > 0 && sourceBuffer[lineStartOffset - 1] !== 10) lineStartOffset--;
75358
75590
  return sourceBuffer.subarray(lineStartOffset, boundedOffset).toString("utf8").length + 1;
75359
75591
  };
75592
+ const decodeRanges = decodeUnknownSync(ArraySchema(DiagnosticContextRangeSchema));
75593
+ const createDiagnosticContextReader = (directory) => {
75594
+ const recordedRules = /* @__PURE__ */ new Set();
75595
+ if (directory) try {
75596
+ for (const filename of fs$1$2.readdirSync(directory)) {
75597
+ if (!filename.endsWith(".json")) continue;
75598
+ recordedRules.add(filename.slice(0, filename.lastIndexOf("-")));
75599
+ }
75600
+ } catch {
75601
+ recordedRules.clear();
75602
+ }
75603
+ return (identity) => {
75604
+ if (!directory || !recordedRules.has(encodeURIComponent(identity.rule))) return [];
75605
+ try {
75606
+ return decodeRanges(failOpenReadJson(getDiagnosticContextPath({
75607
+ ...identity,
75608
+ directory
75609
+ }), []));
75610
+ } catch {
75611
+ return [];
75612
+ }
75613
+ };
75614
+ };
75360
75615
  const utf8OffsetFromSourcePosition = (sourceBuffer, lineNumber, zeroBasedColumn) => {
75361
75616
  if (lineNumber < 1 || zeroBasedColumn < 0) return null;
75362
75617
  const sourceLines = sourceBuffer.toString("utf8").split("\n");
@@ -75998,7 +76253,7 @@ const isOxlintOutput = (value) => isRecord(value) && Array.isArray(value.diagnos
75998
76253
  * to the first `{`. Raises `OxlintOutputUnparseable` when the
75999
76254
  * stdout isn't valid JSON or doesn't carry a `diagnostics` array.
76000
76255
  */
76001
- const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath) => {
76256
+ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath, diagnosticContextDirectory) => {
76002
76257
  if (!stdout) return [];
76003
76258
  const jsonStart = stdout.indexOf("{");
76004
76259
  const sanitizedStdout = jsonStart > 0 ? stdout.slice(jsonStart) : stdout;
@@ -76048,19 +76303,33 @@ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath,
76048
76303
  minifiedFileCache.set(absolutePath, minified);
76049
76304
  return minified;
76050
76305
  };
76051
- return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.flatMap((diagnostic) => {
76306
+ const readContextRanges = createDiagnosticContextReader(diagnosticContextDirectory);
76307
+ return suppressMemoizationInBailedOutFunctions(parsed.diagnostics.flatMap((rawDiagnostic) => {
76308
+ if (!isMappableOxlintDiagnostic(rawDiagnostic)) return [];
76309
+ const { plugin, rule } = parseRuleCode(rawDiagnostic.code);
76310
+ const primarySpan = rawDiagnostic.labels[0]?.span;
76311
+ const contextRanges = diagnosticContextDirectory && plugin === "react-doctor" && primarySpan ? readContextRanges({
76312
+ filename: resolveAbsolutePath(rawDiagnostic.filename),
76313
+ rule,
76314
+ offset: primarySpan.offset,
76315
+ message: rawDiagnostic.message
76316
+ }) : [];
76317
+ const diagnostic = {
76318
+ ...rawDiagnostic,
76319
+ contextRanges
76320
+ };
76052
76321
  const preparedSourceMap = resolvePreparedSourceMap(diagnostic.filename);
76053
76322
  if (preparedSourceMap === void 0) return [diagnostic];
76054
- const { plugin, rule } = parseRuleCode(diagnostic.code);
76055
76323
  if (plugin !== "react-doctor" || !REACT_DOCTOR_RULE_REGISTRY[rule]?.tags?.includes("design")) return [];
76056
76324
  const labels = mapPreparedSourceLabels(diagnostic.labels, preparedSourceMap);
76057
76325
  const sourceFilename = resolveMappedSourceFilename(diagnostic.filename);
76058
76326
  return labels === null || sourceFilename === void 0 ? [] : [{
76059
76327
  ...diagnostic,
76060
76328
  filename: sourceFilename,
76061
- labels
76329
+ labels,
76330
+ contextRanges: []
76062
76331
  }];
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) => {
76332
+ }).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
76333
  const { plugin, rule } = parseRuleCode(diagnostic.code);
76065
76334
  const primaryLabel = diagnostic.labels[0];
76066
76335
  const cleaned = cleanDiagnosticMessage(diagnostic.message, diagnostic.help, plugin, rule, project);
@@ -76097,6 +76366,7 @@ const parseOxlintOutput = (stdout, project, rootDirectory, sourcePathByLintPath,
76097
76366
  ...primarySpanEndLine !== void 0 ? { endLine: primarySpanEndLine } : {}
76098
76367
  } : {},
76099
76368
  category,
76369
+ ...diagnostic.contextRanges.length > 0 ? { contextRanges: diagnostic.contextRanges } : {},
76100
76370
  ...matchByOccurrence ? { matchByOccurrence: true } : {},
76101
76371
  ...relatedLocations.length > 0 ? { relatedLocations } : {}
76102
76372
  };
@@ -76209,7 +76479,7 @@ const spawnLintBatches = async (input) => {
76209
76479
  };
76210
76480
  const stdout = input.spawnSlots === void 0 ? await spawnBatch() : await input.spawnSlots.run(spawnBatch, signal);
76211
76481
  if (stdout === null) return [];
76212
- return parseOxlintOutput(stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath);
76482
+ return parseOxlintOutput(stdout, project, rootDirectory, sourcePathByLintPath, sourceMapByLintPath, input.diagnosticContextDirectory);
76213
76483
  } catch (error) {
76214
76484
  if (!isSplittableReactDoctorError(error)) throw error;
76215
76485
  if (isPastDeadline()) {
@@ -76938,6 +77208,8 @@ const runOxlint = async (options) => {
76938
77208
  const configDirectory = fs$1$2.mkdtempSync(path$1$1.join(os.tmpdir(), "react-doctor-oxlintrc-"));
76939
77209
  const configPath = path$1$1.join(configDirectory, "oxlintrc.json");
76940
77210
  try {
77211
+ const diagnosticContextDirectory = path$1$1.join(configDirectory, "contexts");
77212
+ fs$1$2.mkdirSync(diagnosticContextDirectory);
76941
77213
  const oxlintBinary = resolveOxlintBinary();
76942
77214
  const sharedArgs = [];
76943
77215
  let tsconfigContent = null;
@@ -76986,6 +77258,7 @@ const runOxlint = async (options) => {
76986
77258
  } : project;
76987
77259
  const buildConfig = (overrides) => createOxlintConfig({
76988
77260
  pluginPath,
77261
+ diagnosticContextDirectory,
76989
77262
  project: lintProject,
76990
77263
  customRulesOnly,
76991
77264
  extendsPaths: overrides.extendsPaths,
@@ -77037,6 +77310,7 @@ const runOxlint = async (options) => {
77037
77310
  project: lintProject,
77038
77311
  sourcePathByLintPath: preparedLintSources.sourcePathByLintPath,
77039
77312
  sourceMapByLintPath: preparedLintSources.sourceMapByLintPath,
77313
+ diagnosticContextDirectory,
77040
77314
  onPartialFailure: reportPartialFailure,
77041
77315
  onAnalyzedFiles: (filePaths) => {
77042
77316
  analyzedFiles = filePaths;
@@ -77264,6 +77538,7 @@ const runOxlint = async (options) => {
77264
77538
  project: lintProject,
77265
77539
  sourcePathByLintPath: preparedLintSources.sourcePathByLintPath,
77266
77540
  sourceMapByLintPath: preparedLintSources.sourceMapByLintPath,
77541
+ diagnosticContextDirectory,
77267
77542
  onPartialFailure,
77268
77543
  onAnalyzedFiles: (filePaths) => {
77269
77544
  analyzedFiles = filePaths;
@@ -77560,7 +77835,7 @@ const ScoreApiResponseSchema = Struct({
77560
77835
  });
77561
77836
  const EMPTY_SCORE_REQUEST_METADATA = {};
77562
77837
  const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
77563
- const sanitizeScoreDiagnostics = (diagnostics) => diagnostics.map(({ filePath, fileContext: _fileContext, fixGroupId: _fixGroupId, ...rest }) => ({
77838
+ const sanitizeScoreDiagnostics = (diagnostics) => diagnostics.map(({ filePath, fileContext: _fileContext, fixGroupId: _fixGroupId, contextRanges: _contextRanges, ...rest }) => ({
77564
77839
  ...rest,
77565
77840
  filePath: redactSensitiveText(scrubSensitivePaths(filePath))
77566
77841
  }));
@@ -78816,12 +79091,13 @@ const findWorstScoredProject = (projects) => {
78816
79091
  return worst;
78817
79092
  };
78818
79093
  const toJsonReportDiagnostic = (diagnostic, projectRoot, reportRoot) => {
79094
+ const { contextRanges: _contextRanges, ...publicDiagnostic } = diagnostic;
78819
79095
  const resolvedFilePath = resolveCandidateReadPath(projectRoot, diagnostic.filePath);
78820
79096
  const normalizedFilePath = toNormalizedRelativePath(resolvedFilePath, projectRoot);
78821
79097
  const reportRelativeFilePath = toNormalizedRelativePath(resolvedFilePath, reportRoot);
78822
79098
  const ruleIdentity = getDiagnosticRuleIdentity(diagnostic);
78823
79099
  return {
78824
- ...diagnostic,
79100
+ ...publicDiagnostic,
78825
79101
  id: buildDiagnosticIdentity({
78826
79102
  filePath: reportRelativeFilePath,
78827
79103
  line: diagnostic.line,
@@ -79314,4 +79590,4 @@ const toJsonReport = (result, options) => buildJsonReport({
79314
79590
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
79315
79591
 
79316
79592
  //# sourceMappingURL=index.js.map
79317
- //# debugId=d2b0583c-877f-57cf-8b0a-65519428807c
79593
+ //# debugId=afc70a52-08b0-58db-884e-b2a97b988208