react-doctor 0.5.1-dev.fee3fc4 → 0.5.2-dev.094d470

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js 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]="ecc7e4af-d176-5569-bc51-c3fbe220a76b")}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]="74796c64-5e08-5b67-b3ec-6294b1811a26")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as NodeChildProcess from "node:child_process";
5
5
  import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
@@ -13,11 +13,11 @@ import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, FRAMEWORK_SPECIFIC_RULE_
13
13
  import * as OS from "node:os";
14
14
  import os, { tmpdir } from "node:os";
15
15
  import { parseJSON5 } from "confbox";
16
+ import * as NodeUrl from "node:url";
17
+ import { fileURLToPath } from "node:url";
16
18
  import { createJiti } from "jiti";
17
19
  import * as Crypto from "node:crypto";
18
20
  import crypto, { createHash, randomUUID } from "node:crypto";
19
- import * as NodeUrl from "node:url";
20
- import { fileURLToPath } from "node:url";
21
21
  import { gzipSync } from "node:zlib";
22
22
  import * as Sentry from "@sentry/node";
23
23
  import { performance as performance$1 } from "node:perf_hooks";
@@ -22356,6 +22356,7 @@ var Diagnostic = class extends Class("Diagnostic")({
22356
22356
  endLine: optional(Number$1),
22357
22357
  endColumn: optional(Number$1),
22358
22358
  category: String$1,
22359
+ fileContext: optional(Literals(["test", "story"])),
22359
22360
  suppressionHint: optional(String$1),
22360
22361
  relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation))
22361
22362
  }) {};
@@ -37767,8 +37768,10 @@ const isFileIgnoredByPatterns = (filePath, rootDirectory, patterns) => {
37767
37768
  const relativePath = toRelativePath(filePath, rootDirectory);
37768
37769
  return patterns.some((pattern) => pattern.test(relativePath));
37769
37770
  };
37771
+ const SCRIPT_EXTENSION_FRAGMENT = "[cm]?[jt]sx?";
37772
+ const STORY_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:stories|story)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
37773
+ const TEST_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:test|spec|fixture|fixtures)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
37770
37774
  const TEST_FILE_DIRECTORY_PATTERN = /(?:^|\/)(?:__tests__|__test__|tests|test|__mocks__|cypress|e2e|playwright)\//;
37771
- const TEST_FILE_SUFFIX_PATTERN = /\.(?:test|spec|stories|story|fixture|fixtures)\.(?:[cm]?[jt]sx?)$/;
37772
37775
  const FIXTURE_PROJECT_PATTERN = /\/(?:fixtures|__fixtures__)\//;
37773
37776
  const SOURCE_ROOT_PATTERN = /\/(?:src|app|lib|components|pages|features|modules|packages|apps|frontend|client)\//g;
37774
37777
  const stripAboveSourceRoot = (relativePath) => {
@@ -37779,12 +37782,23 @@ const stripAboveSourceRoot = (relativePath) => {
37779
37782
  if (lastIdx >= 0) return relativePath.slice(lastIdx);
37780
37783
  return relativePath.slice(fixtureMatch.index + fixtureMatch[0].length - 1);
37781
37784
  };
37782
- const isTestFilePath = (relativePath) => {
37783
- if (relativePath.length === 0) return false;
37785
+ /**
37786
+ * Classifies where a file sits relative to shipped code. A finding in a
37787
+ * `.stories.tsx` or `.spec.ts` file never runs in front of users, so
37788
+ * renderers label those sites instead of framing them as production
37789
+ * impact (`rn-no-raw-text` in a spec doesn't say users crash).
37790
+ *
37791
+ * `"story"` is the `.stories.*` / `.story.*` suffix; `"test"` is the
37792
+ * test/spec/fixture suffixes and test directories; `"production"` is
37793
+ * the default.
37794
+ */
37795
+ const classifyFileContext = (relativePath) => {
37796
+ if (relativePath.length === 0) return "production";
37784
37797
  const forwardSlashed = relativePath.replaceAll("\\", "/");
37785
- if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return true;
37798
+ if (STORY_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "story";
37799
+ if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "test";
37786
37800
  const scoped = stripAboveSourceRoot(forwardSlashed);
37787
- return TEST_FILE_DIRECTORY_PATTERN.test(scoped);
37801
+ return TEST_FILE_DIRECTORY_PATTERN.test(scoped) ? "test" : "production";
37788
37802
  };
37789
37803
  /**
37790
37804
  * Resolves the user-configured severity override for a rule.
@@ -38004,6 +38018,8 @@ const collectStringSet = (values) => {
38004
38018
  * 5. `rn-no-raw-text` suppression via configured `textComponents` and
38005
38019
  * `rawTextWrapperComponents` (config-driven JSX enclosure checks)
38006
38020
  * 6. inline suppressions (`// react-doctor-disable-next-line ...`)
38021
+ * 7. file-context stamping (`fileContext: "test" | "story"` on
38022
+ * survivors in non-production files, so renderers can label them)
38007
38023
  *
38008
38024
  * Returns `null` when the diagnostic is dropped, the (possibly
38009
38025
  * severity-restamped) diagnostic otherwise.
@@ -38023,7 +38039,7 @@ const buildDiagnosticPipeline = (input) => {
38023
38039
  const hasTextComponents = textComponentNames.size > 0;
38024
38040
  const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
38025
38041
  const fileLinesCache = /* @__PURE__ */ new Map();
38026
- const testFileCache = /* @__PURE__ */ new Map();
38042
+ const fileContextCache = /* @__PURE__ */ new Map();
38027
38043
  const libraryFileCache = /* @__PURE__ */ new Map();
38028
38044
  const isLibraryFile = (filePath) => {
38029
38045
  let cached = libraryFileCache.get(filePath);
@@ -38040,11 +38056,11 @@ const buildDiagnosticPipeline = (input) => {
38040
38056
  fileLinesCache.set(filePath, lines);
38041
38057
  return lines;
38042
38058
  };
38043
- const isTest = (filePath) => {
38044
- let cached = testFileCache.get(filePath);
38059
+ const getFileContext = (filePath) => {
38060
+ let cached = fileContextCache.get(filePath);
38045
38061
  if (cached === void 0) {
38046
- cached = isTestFilePath(filePath);
38047
- testFileCache.set(filePath, cached);
38062
+ cached = classifyFileContext(filePath);
38063
+ fileContextCache.set(filePath, cached);
38048
38064
  }
38049
38065
  return cached;
38050
38066
  };
@@ -38053,7 +38069,7 @@ const buildDiagnosticPipeline = (input) => {
38053
38069
  const rule = reactDoctorPlugin.rules[diagnostic.rule];
38054
38070
  if (!rule?.tags?.includes("test-noise")) return false;
38055
38071
  if (rule.tags.includes("migration-hint")) return false;
38056
- return isTest(diagnostic.filePath);
38072
+ return getFileContext(diagnostic.filePath) !== "production";
38057
38073
  };
38058
38074
  const isRuleIgnored = (ruleIdentifier) => {
38059
38075
  for (const ignored of ignoredRules) if (isSameRuleKey(ignored, ruleIdentifier)) return true;
@@ -38110,6 +38126,11 @@ const buildDiagnosticPipeline = (input) => {
38110
38126
  };
38111
38127
  }
38112
38128
  }
38129
+ const fileContext = getFileContext(current.filePath);
38130
+ if (fileContext !== "production") current = {
38131
+ ...current,
38132
+ fileContext
38133
+ };
38113
38134
  return current;
38114
38135
  } };
38115
38136
  };
@@ -38506,10 +38527,41 @@ const PACKAGE_JSON_CONFIG_KEY$1 = "reactDoctor";
38506
38527
  const LEGACY_CONFIG_FILENAME = "react-doctor.config.json";
38507
38528
  const jiti = createJiti(import.meta.url);
38508
38529
  const formatError = (error) => error instanceof Error ? error.message : String(error);
38509
- const loadModuleConfig = async (filePath) => {
38510
- const imported = await jiti.import(filePath);
38530
+ const importDefaultExport = async (jitiInstance, filePath) => {
38531
+ const imported = await jitiInstance.import(filePath);
38511
38532
  return imported?.default ?? imported;
38512
38533
  };
38534
+ const SELF_PACKAGE_IMPORT_SPECIFIER = "react-doctor/api";
38535
+ const SELF_PACKAGE_RESOLVE_TARGETS = ["react-doctor/api", "@react-doctor/core"];
38536
+ const MODULE_NOT_FOUND_ERROR_CODES = new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
38537
+ let selfAliasJiti;
38538
+ const getSelfAliasJiti = () => {
38539
+ if (selfAliasJiti !== void 0) return selfAliasJiti;
38540
+ for (const resolveTarget of SELF_PACKAGE_RESOLVE_TARGETS) try {
38541
+ const aliasTargetPath = fileURLToPath(jiti.esmResolve(resolveTarget));
38542
+ selfAliasJiti = createJiti(import.meta.url, { alias: { [SELF_PACKAGE_IMPORT_SPECIFIER]: aliasTargetPath } });
38543
+ return selfAliasJiti;
38544
+ } catch {
38545
+ continue;
38546
+ }
38547
+ selfAliasJiti = null;
38548
+ return selfAliasJiti;
38549
+ };
38550
+ const isSelfPackageResolutionError = (error) => error instanceof Error && "code" in error && typeof error.code === "string" && MODULE_NOT_FOUND_ERROR_CODES.has(error.code) && error.message.includes(SELF_PACKAGE_IMPORT_SPECIFIER);
38551
+ const loadModuleConfig = async (filePath) => {
38552
+ try {
38553
+ return await importDefaultExport(jiti, filePath);
38554
+ } catch (error) {
38555
+ if (!isSelfPackageResolutionError(error)) throw error;
38556
+ const aliasJiti = getSelfAliasJiti();
38557
+ if (!aliasJiti) throw error;
38558
+ try {
38559
+ return await importDefaultExport(aliasJiti, filePath);
38560
+ } catch (retryError) {
38561
+ throw new Error(`${formatError(error)} (retry with ${SELF_PACKAGE_IMPORT_SPECIFIER} aliased to the running react-doctor package also failed: ${formatError(retryError)})`, { cause: retryError });
38562
+ }
38563
+ }
38564
+ };
38513
38565
  const readDataConfig = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
38514
38566
  const readEmbeddedPackageJsonConfig = (directory) => {
38515
38567
  const packageJsonPath = Path.join(directory, PACKAGE_JSON_FILENAME);
@@ -39245,6 +39297,17 @@ const checkPnpmHardening = (rootDirectory) => {
39245
39297
  }));
39246
39298
  return diagnostics;
39247
39299
  };
39300
+ const buildReactNativeDiagnostic = (input) => ({
39301
+ filePath: input.filePath,
39302
+ plugin: "react-doctor",
39303
+ rule: input.rule,
39304
+ severity: input.severity ?? "warning",
39305
+ message: input.message,
39306
+ help: input.help,
39307
+ line: input.line ?? 0,
39308
+ column: input.column ?? 0,
39309
+ category: input.category ?? "Correctness"
39310
+ });
39248
39311
  const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
39249
39312
  const isBuilderBobLibrary = (packageJson) => {
39250
39313
  const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
@@ -39256,17 +39319,12 @@ const checkReactNativeLibraryDependencies = (rootDirectory) => {
39256
39319
  const misplaced = ["react", "react-native"].filter((name) => packageJson.dependencies?.[name] !== void 0);
39257
39320
  if (misplaced.length === 0) return [];
39258
39321
  const quoted = misplaced.map((name) => `"${name}"`).join(" and ");
39259
- return [{
39322
+ return [buildReactNativeDiagnostic({
39260
39323
  filePath: "package.json",
39261
- plugin: "react-doctor",
39262
39324
  rule: "rn-library-react-in-dependencies",
39263
- severity: "warning",
39264
39325
  message: `This react-native-builder-bob library lists ${quoted} in \`dependencies\` — that ships a second copy into consumer apps, causing "Invalid hook call" (duplicate React) and duplicate-native-module crashes.`,
39265
- help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`,
39266
- line: 0,
39267
- column: 0,
39268
- category: "Correctness"
39269
- }];
39326
+ help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`
39327
+ })];
39270
39328
  };
39271
39329
  const BABEL_CONFIG_FILE_NAMES = [
39272
39330
  "babel.config.js",
@@ -39278,6 +39336,8 @@ const BABEL_CONFIG_FILE_NAMES = [
39278
39336
  ".babelrc.json"
39279
39337
  ];
39280
39338
  const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
39339
+ const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
39340
+ const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
39281
39341
  const checkReactNativeMetroBabelPreset = (rootDirectory) => {
39282
39342
  for (const fileName of BABEL_CONFIG_FILE_NAMES) {
39283
39343
  const filePath = Path.join(rootDirectory, fileName);
@@ -39288,18 +39348,20 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
39288
39348
  } catch {
39289
39349
  continue;
39290
39350
  }
39291
- if (!contents.includes(LEGACY_PRESET_SPEC)) continue;
39292
- return [{
39351
+ if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
39293
39352
  filePath: fileName,
39294
- plugin: "react-doctor",
39295
39353
  rule: "rn-no-metro-babel-preset",
39296
39354
  severity: "error",
39297
39355
  message: "`module:metro-react-native-babel-preset` was renamed to `@react-native/babel-preset` and is no longer installed by React Native 0.73+ — this preset reference fails to resolve and breaks the Metro/Babel transform.",
39298
- help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency.",
39299
- line: 0,
39300
- column: 0,
39301
- category: "Correctness"
39302
- }];
39356
+ help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
39357
+ })];
39358
+ if (MODERN_PRESET_REFERENCE.test(contents) && !ENABLE_BABEL_RUNTIME_VERSION.test(contents)) return [buildReactNativeDiagnostic({
39359
+ filePath: fileName,
39360
+ rule: "rn-no-metro-babel-runtime-version",
39361
+ severity: "warning",
39362
+ message: "`module:@react-native/babel-preset` has no `enableBabelRuntime` version, so Babel runtime helpers can be duplicated across files instead of imported once from @babel/runtime, increasing the JS bundle size.",
39363
+ help: "Set `enableBabelRuntime` to the @babel/runtime version from package.json, e.g. `['module:@react-native/babel-preset', { enableBabelRuntime: '^7.26.0' }]`."
39364
+ })];
39303
39365
  }
39304
39366
  return [];
39305
39367
  };
@@ -41711,9 +41773,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
41711
41773
  return bindingResolution !== null && !bindingResolution.isReactUseBinding;
41712
41774
  };
41713
41775
  const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
41776
+ const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
41777
+ const TRAILING_PERIOD_PATTERN = /\.$/;
41714
41778
  const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
41715
41779
  const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
41716
- const REACT_COMPILER_MESSAGE = "This component misses React Compiler's automatic memoization & re-renders more than it should. Rewrite the flagged code so the compiler can optimize it.";
41780
+ const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
41781
+ const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
41782
+ const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
41783
+ const buildReactCompilerMessage = (reasonSummary) => {
41784
+ const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
41785
+ if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
41786
+ return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
41787
+ };
41717
41788
  const PLUGIN_CATEGORY_MAP = {
41718
41789
  react: "Bugs",
41719
41790
  "react-hooks": "Bugs",
@@ -41752,10 +41823,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
41752
41823
  };
41753
41824
  };
41754
41825
  const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
41755
- if (plugin === "react-hooks-js") return {
41756
- message: REACT_COMPILER_MESSAGE,
41757
- help: appendReanimatedSharedValueHint(message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || help, rule, project)
41758
- };
41826
+ if (plugin === "react-hooks-js") {
41827
+ const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
41828
+ if (rule === "todo") return {
41829
+ message: REACT_COMPILER_GENERIC_MESSAGE,
41830
+ help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
41831
+ };
41832
+ const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
41833
+ const reasonDetail = reasonDetailLines.join("\n").trim();
41834
+ return {
41835
+ message: buildReactCompilerMessage(reasonSummary.trim()),
41836
+ help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
41837
+ };
41838
+ }
41759
41839
  return {
41760
41840
  message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
41761
41841
  help: help || getRuleRecommendation(rule, project) || ""
@@ -42422,7 +42502,7 @@ const ScoreApiResponseSchema = Struct({
42422
42502
  })))
42423
42503
  });
42424
42504
  const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
42425
- const stripFilePaths = (diagnostics) => diagnostics.map(({ filePath: _filePath, ...rest }) => rest);
42505
+ const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, ...rest }) => rest);
42426
42506
  const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
42427
42507
  const describeFailure = (error) => {
42428
42508
  if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
@@ -42435,7 +42515,7 @@ const calculateScore = async (diagnostics, options = {}) => {
42435
42515
  const requestUrl = options.isCi ? `${SCORE_API_URL}?ci=1` : SCORE_API_URL;
42436
42516
  try {
42437
42517
  const compressedBody = gzipSync(JSON.stringify({
42438
- diagnostics: stripFilePaths(diagnostics),
42518
+ diagnostics: stripLocalFileFields(diagnostics),
42439
42519
  ...options.metadata?.repo ? { repo: options.metadata.repo } : {},
42440
42520
  ...options.metadata?.sha ? { sha: options.metadata.sha } : {},
42441
42521
  ...options.metadata?.framework ? { framework: options.metadata.framework } : {},
@@ -43721,7 +43801,7 @@ const makeNoopConsole = () => ({
43721
43801
  });
43722
43802
  //#endregion
43723
43803
  //#region src/cli/utils/version.ts
43724
- const VERSION = "0.5.1-dev.fee3fc4";
43804
+ const VERSION = "0.5.2-dev.094d470";
43725
43805
  //#endregion
43726
43806
  //#region src/cli/utils/json-mode.ts
43727
43807
  let context = null;
@@ -44079,13 +44159,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
44079
44159
  * uploads source-map artifacts under, so stack frames symbolicate. Honors the
44080
44160
  * standard `SENTRY_RELEASE` override.
44081
44161
  */
44082
- const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.1-dev.fee3fc4`;
44162
+ const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.5.2-dev.094d470`;
44083
44163
  /**
44084
44164
  * Deployment environment shown in Sentry's environment filter. Defaults to
44085
44165
  * `production` for tagged releases and `development` for dev/unbuilt versions,
44086
44166
  * overridable via the standard `SENTRY_ENVIRONMENT` env var.
44087
44167
  */
44088
- const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.1-dev.fee3fc4") ? "development" : "production");
44168
+ const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.5.2-dev.094d470") ? "development" : "production");
44089
44169
  /**
44090
44170
  * Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
44091
44171
  * (set to `0` to disable tracing) and falls back to
@@ -47690,6 +47770,12 @@ const buildOutcomeAttributes = (input) => {
47690
47770
  topRule = rule;
47691
47771
  topRuleCount = count;
47692
47772
  }
47773
+ let diagnosticsInTestFiles = 0;
47774
+ let diagnosticsInStoryFiles = 0;
47775
+ for (const diagnostic of result.diagnostics) {
47776
+ if (diagnostic.fileContext === "test") diagnosticsInTestFiles += 1;
47777
+ if (diagnostic.fileContext === "story") diagnosticsInStoryFiles += 1;
47778
+ }
47693
47779
  const attributes = {
47694
47780
  outcome,
47695
47781
  exitCode: wouldBlock ? 1 : 0,
@@ -47700,6 +47786,8 @@ const buildOutcomeAttributes = (input) => {
47700
47786
  errorCount: summary.errorCount,
47701
47787
  warningCount: summary.warningCount,
47702
47788
  affectedFiles: summary.affectedFileCount,
47789
+ diagnosticsInTestFiles,
47790
+ diagnosticsInStoryFiles,
47703
47791
  distinctRulesFired: countByRule.size,
47704
47792
  topRule,
47705
47793
  scannedFileCount: result.scannedFileCount ?? null,
@@ -48032,17 +48120,24 @@ const writeStdout = (text) => sync(() => {
48032
48120
  const POINTER = isUnicodeSupported() ? "›" : ">";
48033
48121
  const colorizeBySeverity = (text, severity) => severity === "error" ? highlighter.error(text) : highlighter.warn(text);
48034
48122
  const collectAffectedFiles = (diagnostics) => new Set(diagnostics.map((diagnostic) => diagnostic.filePath));
48035
- const buildVerboseSiteMap = (diagnostics) => {
48036
- const fileSites = /* @__PURE__ */ new Map();
48123
+ const formatFileContextTag = (diagnostic) => diagnostic.fileContext ? ` (${diagnostic.fileContext} file)` : "";
48124
+ const buildVerboseFileEntries = (diagnostics) => {
48125
+ const fileEntries = /* @__PURE__ */ new Map();
48037
48126
  for (const diagnostic of diagnostics) {
48038
- const sites = fileSites.get(diagnostic.filePath) ?? [];
48039
- if (diagnostic.line > 0) sites.push({
48127
+ let entry = fileEntries.get(diagnostic.filePath);
48128
+ if (entry === void 0) {
48129
+ entry = {
48130
+ contextTag: formatFileContextTag(diagnostic),
48131
+ sites: []
48132
+ };
48133
+ fileEntries.set(diagnostic.filePath, entry);
48134
+ }
48135
+ if (diagnostic.line > 0) entry.sites.push({
48040
48136
  line: diagnostic.line,
48041
48137
  suppressionHint: diagnostic.suppressionHint
48042
48138
  });
48043
- fileSites.set(diagnostic.filePath, sites);
48044
48139
  }
48045
- return fileSites;
48140
+ return fileEntries;
48046
48141
  };
48047
48142
  const formatSiteCountBadge = (count) => count > 1 ? `×${count}` : "";
48048
48143
  const formatTrailingSiteBadge = (count) => {
@@ -48131,10 +48226,11 @@ const clusterNearbyDiagnostics = (diagnostics) => {
48131
48226
  return clusters;
48132
48227
  };
48133
48228
  const formatClusterLocation = (cluster) => {
48134
- const { filePath } = cluster.diagnostics[0];
48135
- if (cluster.startLine <= 0) return filePath;
48136
- if (cluster.endLine > cluster.startLine) return `${filePath}:${cluster.startLine}-${cluster.endLine}`;
48137
- return `${filePath}:${cluster.startLine}`;
48229
+ const lead = cluster.diagnostics[0];
48230
+ const contextTag = formatFileContextTag(lead);
48231
+ if (cluster.startLine <= 0) return `${lead.filePath}${contextTag}`;
48232
+ if (cluster.endLine > cluster.startLine) return `${lead.filePath}:${cluster.startLine}-${cluster.endLine}${contextTag}`;
48233
+ return `${lead.filePath}:${cluster.startLine}${contextTag}`;
48138
48234
  };
48139
48235
  const buildDiagnosticClusterLines = (cluster, resolveSourceRoot, renderCodeFrame) => {
48140
48236
  const lead = cluster.diagnostics[0];
@@ -48277,25 +48373,26 @@ const formatElapsedTime = (elapsedMilliseconds) => {
48277
48373
  };
48278
48374
  const formatRuleSummary = (ruleKey, ruleDiagnostics) => {
48279
48375
  const firstDiagnostic = ruleDiagnostics[0];
48376
+ const distinctMessages = [...new Set(ruleDiagnostics.map((diagnostic) => diagnostic.message))];
48280
48377
  const sections = [
48281
48378
  `Rule: ${ruleKey}`,
48282
48379
  `Severity: ${firstDiagnostic.severity}`,
48283
48380
  `Category: ${firstDiagnostic.category}`,
48284
48381
  `Count: ${ruleDiagnostics.length}`,
48285
48382
  "",
48286
- firstDiagnostic.message
48383
+ distinctMessages.join("\n\n")
48287
48384
  ];
48288
48385
  if (firstDiagnostic.help) sections.push("", `Suggestion: ${firstDiagnostic.help}`);
48289
48386
  if (firstDiagnostic.url) sections.push("", `Docs: ${firstDiagnostic.url}`);
48290
48387
  const fixRecipeLine = formatFixRecipeLine(firstDiagnostic);
48291
48388
  if (fixRecipeLine) sections.push("", fixRecipeLine);
48292
48389
  sections.push("", "Files:");
48293
- const fileSites = buildVerboseSiteMap(ruleDiagnostics);
48294
- for (const [filePath, sites] of fileSites) if (sites.length > 0) for (const site of sites) {
48295
- sections.push(` ${filePath}:${site.line}`);
48390
+ const fileEntries = buildVerboseFileEntries(ruleDiagnostics);
48391
+ for (const [filePath, { contextTag, sites }] of fileEntries) if (sites.length > 0) for (const site of sites) {
48392
+ sections.push(` ${filePath}:${site.line}${contextTag}`);
48296
48393
  if (site.suppressionHint) sections.push(` ${site.suppressionHint}`);
48297
48394
  }
48298
- else sections.push(` ${filePath}`);
48395
+ else sections.push(` ${filePath}${contextTag}`);
48299
48396
  return sections.join("\n") + "\n";
48300
48397
  };
48301
48398
  //#endregion
@@ -53744,4 +53841,4 @@ Promise.resolve().then(() => assertNoRemovedFlags(process.argv)).then(() => prog
53744
53841
  export {};
53745
53842
 
53746
53843
  //# sourceMappingURL=cli.js.map
53747
- //# debugId=ecc7e4af-d176-5569-bc51-c3fbe220a76b
53844
+ //# debugId=74796c64-5e08-5b67-b3ec-6294b1811a26
package/dist/index.d.ts CHANGED
@@ -9452,6 +9452,7 @@ interface DiagnosticRelatedLocation {
9452
9452
  endColumn?: number;
9453
9453
  message: string;
9454
9454
  }
9455
+ type DiagnosticFileContext = "test" | "story" | "production";
9455
9456
  interface Diagnostic {
9456
9457
  filePath: string;
9457
9458
  plugin: string;
@@ -9478,6 +9479,12 @@ interface Diagnostic {
9478
9479
  /** 1-indexed end column of the primary span, when derivable. */
9479
9480
  endColumn?: number;
9480
9481
  category: string;
9482
+ /**
9483
+ * Set when the file never ships to users (`"test"` / `"story"`), so
9484
+ * renderers can label the site instead of implying production impact.
9485
+ * Omitted for production files (the default).
9486
+ */
9487
+ fileContext?: Exclude<DiagnosticFileContext, "production">;
9481
9488
  suppressionHint?: string;
9482
9489
  /** Secondary source locations (oxlint's non-primary labels). */
9483
9490
  relatedLocations?: DiagnosticRelatedLocation[];
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]="d789108a-ddf2-5b61-a479-4c797dba74cb")}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]="5c0d7930-333e-5d67-93cf-63eae9bd87f8")}catch(e){}}();
3
3
  import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
4
4
  import { createRequire } from "node:module";
5
5
  import * as NFS from "node:fs";
@@ -13,9 +13,10 @@ import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, FRAMEWORK_SPECIFIC_RULE_
13
13
  import * as OS from "node:os";
14
14
  import os from "node:os";
15
15
  import { parseJSON5 } from "confbox";
16
+ import * as NodeUrl from "node:url";
17
+ import { fileURLToPath } from "node:url";
16
18
  import { createJiti } from "jiti";
17
19
  import * as Crypto from "node:crypto";
18
- import * as NodeUrl from "node:url";
19
20
  import { gzipSync } from "node:zlib";
20
21
  //#region ../../node_modules/.pnpm/effect@4.0.0-beta.70/node_modules/effect/dist/Pipeable.js
21
22
  /**
@@ -19253,6 +19254,7 @@ var Diagnostic = class extends Class("Diagnostic")({
19253
19254
  endLine: optional(Number$1),
19254
19255
  endColumn: optional(Number$1),
19255
19256
  category: String$1,
19257
+ fileContext: optional(Literals(["test", "story"])),
19256
19258
  suppressionHint: optional(String$1),
19257
19259
  relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation))
19258
19260
  }) {};
@@ -34570,8 +34572,10 @@ const isFileIgnoredByPatterns = (filePath, rootDirectory, patterns) => {
34570
34572
  const relativePath = toRelativePath(filePath, rootDirectory);
34571
34573
  return patterns.some((pattern) => pattern.test(relativePath));
34572
34574
  };
34575
+ const SCRIPT_EXTENSION_FRAGMENT = "[cm]?[jt]sx?";
34576
+ const STORY_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:stories|story)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
34577
+ const TEST_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:test|spec|fixture|fixtures)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
34573
34578
  const TEST_FILE_DIRECTORY_PATTERN = /(?:^|\/)(?:__tests__|__test__|tests|test|__mocks__|cypress|e2e|playwright)\//;
34574
- const TEST_FILE_SUFFIX_PATTERN = /\.(?:test|spec|stories|story|fixture|fixtures)\.(?:[cm]?[jt]sx?)$/;
34575
34579
  const FIXTURE_PROJECT_PATTERN = /\/(?:fixtures|__fixtures__)\//;
34576
34580
  const SOURCE_ROOT_PATTERN = /\/(?:src|app|lib|components|pages|features|modules|packages|apps|frontend|client)\//g;
34577
34581
  const stripAboveSourceRoot = (relativePath) => {
@@ -34582,12 +34586,23 @@ const stripAboveSourceRoot = (relativePath) => {
34582
34586
  if (lastIdx >= 0) return relativePath.slice(lastIdx);
34583
34587
  return relativePath.slice(fixtureMatch.index + fixtureMatch[0].length - 1);
34584
34588
  };
34585
- const isTestFilePath = (relativePath) => {
34586
- if (relativePath.length === 0) return false;
34589
+ /**
34590
+ * Classifies where a file sits relative to shipped code. A finding in a
34591
+ * `.stories.tsx` or `.spec.ts` file never runs in front of users, so
34592
+ * renderers label those sites instead of framing them as production
34593
+ * impact (`rn-no-raw-text` in a spec doesn't say users crash).
34594
+ *
34595
+ * `"story"` is the `.stories.*` / `.story.*` suffix; `"test"` is the
34596
+ * test/spec/fixture suffixes and test directories; `"production"` is
34597
+ * the default.
34598
+ */
34599
+ const classifyFileContext = (relativePath) => {
34600
+ if (relativePath.length === 0) return "production";
34587
34601
  const forwardSlashed = relativePath.replaceAll("\\", "/");
34588
- if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return true;
34602
+ if (STORY_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "story";
34603
+ if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "test";
34589
34604
  const scoped = stripAboveSourceRoot(forwardSlashed);
34590
- return TEST_FILE_DIRECTORY_PATTERN.test(scoped);
34605
+ return TEST_FILE_DIRECTORY_PATTERN.test(scoped) ? "test" : "production";
34591
34606
  };
34592
34607
  /**
34593
34608
  * Resolves the user-configured severity override for a rule.
@@ -34811,6 +34826,8 @@ const collectStringSet = (values) => {
34811
34826
  * 5. `rn-no-raw-text` suppression via configured `textComponents` and
34812
34827
  * `rawTextWrapperComponents` (config-driven JSX enclosure checks)
34813
34828
  * 6. inline suppressions (`// react-doctor-disable-next-line ...`)
34829
+ * 7. file-context stamping (`fileContext: "test" | "story"` on
34830
+ * survivors in non-production files, so renderers can label them)
34814
34831
  *
34815
34832
  * Returns `null` when the diagnostic is dropped, the (possibly
34816
34833
  * severity-restamped) diagnostic otherwise.
@@ -34830,7 +34847,7 @@ const buildDiagnosticPipeline = (input) => {
34830
34847
  const hasTextComponents = textComponentNames.size > 0;
34831
34848
  const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
34832
34849
  const fileLinesCache = /* @__PURE__ */ new Map();
34833
- const testFileCache = /* @__PURE__ */ new Map();
34850
+ const fileContextCache = /* @__PURE__ */ new Map();
34834
34851
  const libraryFileCache = /* @__PURE__ */ new Map();
34835
34852
  const isLibraryFile = (filePath) => {
34836
34853
  let cached = libraryFileCache.get(filePath);
@@ -34847,11 +34864,11 @@ const buildDiagnosticPipeline = (input) => {
34847
34864
  fileLinesCache.set(filePath, lines);
34848
34865
  return lines;
34849
34866
  };
34850
- const isTest = (filePath) => {
34851
- let cached = testFileCache.get(filePath);
34867
+ const getFileContext = (filePath) => {
34868
+ let cached = fileContextCache.get(filePath);
34852
34869
  if (cached === void 0) {
34853
- cached = isTestFilePath(filePath);
34854
- testFileCache.set(filePath, cached);
34870
+ cached = classifyFileContext(filePath);
34871
+ fileContextCache.set(filePath, cached);
34855
34872
  }
34856
34873
  return cached;
34857
34874
  };
@@ -34860,7 +34877,7 @@ const buildDiagnosticPipeline = (input) => {
34860
34877
  const rule = reactDoctorPlugin.rules[diagnostic.rule];
34861
34878
  if (!rule?.tags?.includes("test-noise")) return false;
34862
34879
  if (rule.tags.includes("migration-hint")) return false;
34863
- return isTest(diagnostic.filePath);
34880
+ return getFileContext(diagnostic.filePath) !== "production";
34864
34881
  };
34865
34882
  const isRuleIgnored = (ruleIdentifier) => {
34866
34883
  for (const ignored of ignoredRules) if (isSameRuleKey(ignored, ruleIdentifier)) return true;
@@ -34917,6 +34934,11 @@ const buildDiagnosticPipeline = (input) => {
34917
34934
  };
34918
34935
  }
34919
34936
  }
34937
+ const fileContext = getFileContext(current.filePath);
34938
+ if (fileContext !== "production") current = {
34939
+ ...current,
34940
+ fileContext
34941
+ };
34920
34942
  return current;
34921
34943
  } };
34922
34944
  };
@@ -35313,10 +35335,41 @@ const PACKAGE_JSON_CONFIG_KEY = "reactDoctor";
35313
35335
  const LEGACY_CONFIG_FILENAME = "react-doctor.config.json";
35314
35336
  const jiti = createJiti(import.meta.url);
35315
35337
  const formatError = (error) => error instanceof Error ? error.message : String(error);
35316
- const loadModuleConfig = async (filePath) => {
35317
- const imported = await jiti.import(filePath);
35338
+ const importDefaultExport = async (jitiInstance, filePath) => {
35339
+ const imported = await jitiInstance.import(filePath);
35318
35340
  return imported?.default ?? imported;
35319
35341
  };
35342
+ const SELF_PACKAGE_IMPORT_SPECIFIER = "react-doctor/api";
35343
+ const SELF_PACKAGE_RESOLVE_TARGETS = ["react-doctor/api", "@react-doctor/core"];
35344
+ const MODULE_NOT_FOUND_ERROR_CODES = new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
35345
+ let selfAliasJiti;
35346
+ const getSelfAliasJiti = () => {
35347
+ if (selfAliasJiti !== void 0) return selfAliasJiti;
35348
+ for (const resolveTarget of SELF_PACKAGE_RESOLVE_TARGETS) try {
35349
+ const aliasTargetPath = fileURLToPath(jiti.esmResolve(resolveTarget));
35350
+ selfAliasJiti = createJiti(import.meta.url, { alias: { [SELF_PACKAGE_IMPORT_SPECIFIER]: aliasTargetPath } });
35351
+ return selfAliasJiti;
35352
+ } catch {
35353
+ continue;
35354
+ }
35355
+ selfAliasJiti = null;
35356
+ return selfAliasJiti;
35357
+ };
35358
+ const isSelfPackageResolutionError = (error) => error instanceof Error && "code" in error && typeof error.code === "string" && MODULE_NOT_FOUND_ERROR_CODES.has(error.code) && error.message.includes(SELF_PACKAGE_IMPORT_SPECIFIER);
35359
+ const loadModuleConfig = async (filePath) => {
35360
+ try {
35361
+ return await importDefaultExport(jiti, filePath);
35362
+ } catch (error) {
35363
+ if (!isSelfPackageResolutionError(error)) throw error;
35364
+ const aliasJiti = getSelfAliasJiti();
35365
+ if (!aliasJiti) throw error;
35366
+ try {
35367
+ return await importDefaultExport(aliasJiti, filePath);
35368
+ } catch (retryError) {
35369
+ throw new Error(`${formatError(error)} (retry with ${SELF_PACKAGE_IMPORT_SPECIFIER} aliased to the running react-doctor package also failed: ${formatError(retryError)})`, { cause: retryError });
35370
+ }
35371
+ }
35372
+ };
35320
35373
  const readDataConfig = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
35321
35374
  const readEmbeddedPackageJsonConfig = (directory) => {
35322
35375
  const packageJsonPath = Path.join(directory, PACKAGE_JSON_FILENAME);
@@ -36024,6 +36077,17 @@ const checkPnpmHardening = (rootDirectory) => {
36024
36077
  }));
36025
36078
  return diagnostics;
36026
36079
  };
36080
+ const buildReactNativeDiagnostic = (input) => ({
36081
+ filePath: input.filePath,
36082
+ plugin: "react-doctor",
36083
+ rule: input.rule,
36084
+ severity: input.severity ?? "warning",
36085
+ message: input.message,
36086
+ help: input.help,
36087
+ line: input.line ?? 0,
36088
+ column: input.column ?? 0,
36089
+ category: input.category ?? "Correctness"
36090
+ });
36027
36091
  const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
36028
36092
  const isBuilderBobLibrary = (packageJson) => {
36029
36093
  const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
@@ -36035,17 +36099,12 @@ const checkReactNativeLibraryDependencies = (rootDirectory) => {
36035
36099
  const misplaced = ["react", "react-native"].filter((name) => packageJson.dependencies?.[name] !== void 0);
36036
36100
  if (misplaced.length === 0) return [];
36037
36101
  const quoted = misplaced.map((name) => `"${name}"`).join(" and ");
36038
- return [{
36102
+ return [buildReactNativeDiagnostic({
36039
36103
  filePath: "package.json",
36040
- plugin: "react-doctor",
36041
36104
  rule: "rn-library-react-in-dependencies",
36042
- severity: "warning",
36043
36105
  message: `This react-native-builder-bob library lists ${quoted} in \`dependencies\` — that ships a second copy into consumer apps, causing "Invalid hook call" (duplicate React) and duplicate-native-module crashes.`,
36044
- help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`,
36045
- line: 0,
36046
- column: 0,
36047
- category: "Correctness"
36048
- }];
36106
+ help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`
36107
+ })];
36049
36108
  };
36050
36109
  const BABEL_CONFIG_FILE_NAMES = [
36051
36110
  "babel.config.js",
@@ -36057,6 +36116,8 @@ const BABEL_CONFIG_FILE_NAMES = [
36057
36116
  ".babelrc.json"
36058
36117
  ];
36059
36118
  const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
36119
+ const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
36120
+ const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
36060
36121
  const checkReactNativeMetroBabelPreset = (rootDirectory) => {
36061
36122
  for (const fileName of BABEL_CONFIG_FILE_NAMES) {
36062
36123
  const filePath = Path.join(rootDirectory, fileName);
@@ -36067,18 +36128,20 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
36067
36128
  } catch {
36068
36129
  continue;
36069
36130
  }
36070
- if (!contents.includes(LEGACY_PRESET_SPEC)) continue;
36071
- return [{
36131
+ if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
36072
36132
  filePath: fileName,
36073
- plugin: "react-doctor",
36074
36133
  rule: "rn-no-metro-babel-preset",
36075
36134
  severity: "error",
36076
36135
  message: "`module:metro-react-native-babel-preset` was renamed to `@react-native/babel-preset` and is no longer installed by React Native 0.73+ — this preset reference fails to resolve and breaks the Metro/Babel transform.",
36077
- help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency.",
36078
- line: 0,
36079
- column: 0,
36080
- category: "Correctness"
36081
- }];
36136
+ help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
36137
+ })];
36138
+ if (MODERN_PRESET_REFERENCE.test(contents) && !ENABLE_BABEL_RUNTIME_VERSION.test(contents)) return [buildReactNativeDiagnostic({
36139
+ filePath: fileName,
36140
+ rule: "rn-no-metro-babel-runtime-version",
36141
+ severity: "warning",
36142
+ message: "`module:@react-native/babel-preset` has no `enableBabelRuntime` version, so Babel runtime helpers can be duplicated across files instead of imported once from @babel/runtime, increasing the JS bundle size.",
36143
+ help: "Set `enableBabelRuntime` to the @babel/runtime version from package.json, e.g. `['module:@react-native/babel-preset', { enableBabelRuntime: '^7.26.0' }]`."
36144
+ })];
36082
36145
  }
36083
36146
  return [];
36084
36147
  };
@@ -38474,9 +38537,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
38474
38537
  return bindingResolution !== null && !bindingResolution.isReactUseBinding;
38475
38538
  };
38476
38539
  const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
38540
+ const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
38541
+ const TRAILING_PERIOD_PATTERN = /\.$/;
38477
38542
  const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
38478
38543
  const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
38479
- const REACT_COMPILER_MESSAGE = "This component misses React Compiler's automatic memoization & re-renders more than it should. Rewrite the flagged code so the compiler can optimize it.";
38544
+ const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
38545
+ const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
38546
+ const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
38547
+ const buildReactCompilerMessage = (reasonSummary) => {
38548
+ const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
38549
+ if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
38550
+ return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
38551
+ };
38480
38552
  const PLUGIN_CATEGORY_MAP = {
38481
38553
  react: "Bugs",
38482
38554
  "react-hooks": "Bugs",
@@ -38515,10 +38587,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
38515
38587
  };
38516
38588
  };
38517
38589
  const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
38518
- if (plugin === "react-hooks-js") return {
38519
- message: REACT_COMPILER_MESSAGE,
38520
- help: appendReanimatedSharedValueHint(message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || help, rule, project)
38521
- };
38590
+ if (plugin === "react-hooks-js") {
38591
+ const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
38592
+ if (rule === "todo") return {
38593
+ message: REACT_COMPILER_GENERIC_MESSAGE,
38594
+ help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
38595
+ };
38596
+ const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
38597
+ const reasonDetail = reasonDetailLines.join("\n").trim();
38598
+ return {
38599
+ message: buildReactCompilerMessage(reasonSummary.trim()),
38600
+ help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
38601
+ };
38602
+ }
38522
38603
  return {
38523
38604
  message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
38524
38605
  help: help || getRuleRecommendation(rule, project) || ""
@@ -39185,7 +39266,7 @@ const ScoreApiResponseSchema = Struct({
39185
39266
  })))
39186
39267
  });
39187
39268
  const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
39188
- const stripFilePaths = (diagnostics) => diagnostics.map(({ filePath: _filePath, ...rest }) => rest);
39269
+ const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, ...rest }) => rest);
39189
39270
  const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
39190
39271
  const describeFailure = (error) => {
39191
39272
  if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
@@ -39198,7 +39279,7 @@ const calculateScore = async (diagnostics, options = {}) => {
39198
39279
  const requestUrl = options.isCi ? `${SCORE_API_URL}?ci=1` : SCORE_API_URL;
39199
39280
  try {
39200
39281
  const compressedBody = gzipSync(JSON.stringify({
39201
- diagnostics: stripFilePaths(diagnostics),
39282
+ diagnostics: stripLocalFileFields(diagnostics),
39202
39283
  ...options.metadata?.repo ? { repo: options.metadata.repo } : {},
39203
39284
  ...options.metadata?.sha ? { sha: options.metadata.sha } : {},
39204
39285
  ...options.metadata?.framework ? { framework: options.metadata.framework } : {},
@@ -40273,4 +40354,4 @@ const toJsonReport = (result, options) => buildJsonReport({
40273
40354
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
40274
40355
 
40275
40356
  //# sourceMappingURL=index.js.map
40276
- //# debugId=d789108a-ddf2-5b61-a479-4c797dba74cb
40357
+ //# debugId=5c0d7930-333e-5d67-93cf-63eae9bd87f8
package/dist/lsp.js CHANGED
@@ -10,10 +10,11 @@ import { spawn, spawnSync } from "node:child_process";
10
10
  import * as ts from "typescript";
11
11
  import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, FRAMEWORK_SPECIFIC_RULE_KEYS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES } from "oxlint-plugin-react-doctor";
12
12
  import { parseJSON5 } from "confbox";
13
+ import * as NodeUrl from "node:url";
14
+ import { fileURLToPath } from "node:url";
13
15
  import { createJiti } from "jiti";
14
16
  import * as Crypto from "node:crypto";
15
17
  import crypto from "node:crypto";
16
- import * as NodeUrl from "node:url";
17
18
  import { gzipSync } from "node:zlib";
18
19
  import { CodeActionKind, CodeActionTriggerKind, DidChangeWatchedFilesNotification, DocumentDiagnosticReportKind, FileChangeType, TextDocumentSyncKind, TextDocuments, createConnection } from "vscode-languageserver/node.js";
19
20
  import { TextDocument } from "vscode-languageserver-textdocument";
@@ -19283,6 +19284,7 @@ var Diagnostic = class extends Class("Diagnostic")({
19283
19284
  endLine: optional(Number$1),
19284
19285
  endColumn: optional(Number$1),
19285
19286
  category: String$1,
19287
+ fileContext: optional(Literals(["test", "story"])),
19286
19288
  suppressionHint: optional(String$1),
19287
19289
  relatedLocations: optional(ArraySchema(DiagnosticRelatedLocation))
19288
19290
  }) {};
@@ -34630,8 +34632,10 @@ const isFileIgnoredByPatterns = (filePath, rootDirectory, patterns) => {
34630
34632
  const relativePath = toRelativePath(filePath, rootDirectory);
34631
34633
  return patterns.some((pattern) => pattern.test(relativePath));
34632
34634
  };
34635
+ const SCRIPT_EXTENSION_FRAGMENT = "[cm]?[jt]sx?";
34636
+ const STORY_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:stories|story)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
34637
+ const TEST_FILE_SUFFIX_PATTERN = new RegExp(`\\.(?:test|spec|fixture|fixtures)\\.(?:${SCRIPT_EXTENSION_FRAGMENT})$`);
34633
34638
  const TEST_FILE_DIRECTORY_PATTERN = /(?:^|\/)(?:__tests__|__test__|tests|test|__mocks__|cypress|e2e|playwright)\//;
34634
- const TEST_FILE_SUFFIX_PATTERN = /\.(?:test|spec|stories|story|fixture|fixtures)\.(?:[cm]?[jt]sx?)$/;
34635
34639
  const FIXTURE_PROJECT_PATTERN = /\/(?:fixtures|__fixtures__)\//;
34636
34640
  const SOURCE_ROOT_PATTERN = /\/(?:src|app|lib|components|pages|features|modules|packages|apps|frontend|client)\//g;
34637
34641
  const stripAboveSourceRoot = (relativePath) => {
@@ -34642,12 +34646,23 @@ const stripAboveSourceRoot = (relativePath) => {
34642
34646
  if (lastIdx >= 0) return relativePath.slice(lastIdx);
34643
34647
  return relativePath.slice(fixtureMatch.index + fixtureMatch[0].length - 1);
34644
34648
  };
34645
- const isTestFilePath = (relativePath) => {
34646
- if (relativePath.length === 0) return false;
34649
+ /**
34650
+ * Classifies where a file sits relative to shipped code. A finding in a
34651
+ * `.stories.tsx` or `.spec.ts` file never runs in front of users, so
34652
+ * renderers label those sites instead of framing them as production
34653
+ * impact (`rn-no-raw-text` in a spec doesn't say users crash).
34654
+ *
34655
+ * `"story"` is the `.stories.*` / `.story.*` suffix; `"test"` is the
34656
+ * test/spec/fixture suffixes and test directories; `"production"` is
34657
+ * the default.
34658
+ */
34659
+ const classifyFileContext = (relativePath) => {
34660
+ if (relativePath.length === 0) return "production";
34647
34661
  const forwardSlashed = relativePath.replaceAll("\\", "/");
34648
- if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return true;
34662
+ if (STORY_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "story";
34663
+ if (TEST_FILE_SUFFIX_PATTERN.test(forwardSlashed)) return "test";
34649
34664
  const scoped = stripAboveSourceRoot(forwardSlashed);
34650
- return TEST_FILE_DIRECTORY_PATTERN.test(scoped);
34665
+ return TEST_FILE_DIRECTORY_PATTERN.test(scoped) ? "test" : "production";
34651
34666
  };
34652
34667
  /**
34653
34668
  * Resolves the user-configured severity override for a rule.
@@ -34867,6 +34882,8 @@ const collectStringSet = (values) => {
34867
34882
  * 5. `rn-no-raw-text` suppression via configured `textComponents` and
34868
34883
  * `rawTextWrapperComponents` (config-driven JSX enclosure checks)
34869
34884
  * 6. inline suppressions (`// react-doctor-disable-next-line ...`)
34885
+ * 7. file-context stamping (`fileContext: "test" | "story"` on
34886
+ * survivors in non-production files, so renderers can label them)
34870
34887
  *
34871
34888
  * Returns `null` when the diagnostic is dropped, the (possibly
34872
34889
  * severity-restamped) diagnostic otherwise.
@@ -34886,7 +34903,7 @@ const buildDiagnosticPipeline = (input) => {
34886
34903
  const hasTextComponents = textComponentNames.size > 0;
34887
34904
  const hasRawTextWrappers = rawTextWrapperComponentNames.size > 0;
34888
34905
  const fileLinesCache = /* @__PURE__ */ new Map();
34889
- const testFileCache = /* @__PURE__ */ new Map();
34906
+ const fileContextCache = /* @__PURE__ */ new Map();
34890
34907
  const libraryFileCache = /* @__PURE__ */ new Map();
34891
34908
  const isLibraryFile = (filePath) => {
34892
34909
  let cached = libraryFileCache.get(filePath);
@@ -34903,11 +34920,11 @@ const buildDiagnosticPipeline = (input) => {
34903
34920
  fileLinesCache.set(filePath, lines);
34904
34921
  return lines;
34905
34922
  };
34906
- const isTest = (filePath) => {
34907
- let cached = testFileCache.get(filePath);
34923
+ const getFileContext = (filePath) => {
34924
+ let cached = fileContextCache.get(filePath);
34908
34925
  if (cached === void 0) {
34909
- cached = isTestFilePath(filePath);
34910
- testFileCache.set(filePath, cached);
34926
+ cached = classifyFileContext(filePath);
34927
+ fileContextCache.set(filePath, cached);
34911
34928
  }
34912
34929
  return cached;
34913
34930
  };
@@ -34916,7 +34933,7 @@ const buildDiagnosticPipeline = (input) => {
34916
34933
  const rule = reactDoctorPlugin.rules[diagnostic.rule];
34917
34934
  if (!rule?.tags?.includes("test-noise")) return false;
34918
34935
  if (rule.tags.includes("migration-hint")) return false;
34919
- return isTest(diagnostic.filePath);
34936
+ return getFileContext(diagnostic.filePath) !== "production";
34920
34937
  };
34921
34938
  const isRuleIgnored = (ruleIdentifier) => {
34922
34939
  for (const ignored of ignoredRules) if (isSameRuleKey(ignored, ruleIdentifier)) return true;
@@ -34973,6 +34990,11 @@ const buildDiagnosticPipeline = (input) => {
34973
34990
  };
34974
34991
  }
34975
34992
  }
34993
+ const fileContext = getFileContext(current.filePath);
34994
+ if (fileContext !== "production") current = {
34995
+ ...current,
34996
+ fileContext
34997
+ };
34976
34998
  return current;
34977
34999
  } };
34978
35000
  };
@@ -35347,10 +35369,41 @@ const PACKAGE_JSON_CONFIG_KEY = "reactDoctor";
35347
35369
  const LEGACY_CONFIG_FILENAME = "react-doctor.config.json";
35348
35370
  const jiti = createJiti(import.meta.url);
35349
35371
  const formatError = (error) => error instanceof Error ? error.message : String(error);
35350
- const loadModuleConfig = async (filePath) => {
35351
- const imported = await jiti.import(filePath);
35372
+ const importDefaultExport = async (jitiInstance, filePath) => {
35373
+ const imported = await jitiInstance.import(filePath);
35352
35374
  return imported?.default ?? imported;
35353
35375
  };
35376
+ const SELF_PACKAGE_IMPORT_SPECIFIER = "react-doctor/api";
35377
+ const SELF_PACKAGE_RESOLVE_TARGETS = ["react-doctor/api", "@react-doctor/core"];
35378
+ const MODULE_NOT_FOUND_ERROR_CODES = new Set(["MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND"]);
35379
+ let selfAliasJiti;
35380
+ const getSelfAliasJiti = () => {
35381
+ if (selfAliasJiti !== void 0) return selfAliasJiti;
35382
+ for (const resolveTarget of SELF_PACKAGE_RESOLVE_TARGETS) try {
35383
+ const aliasTargetPath = fileURLToPath(jiti.esmResolve(resolveTarget));
35384
+ selfAliasJiti = createJiti(import.meta.url, { alias: { [SELF_PACKAGE_IMPORT_SPECIFIER]: aliasTargetPath } });
35385
+ return selfAliasJiti;
35386
+ } catch {
35387
+ continue;
35388
+ }
35389
+ selfAliasJiti = null;
35390
+ return selfAliasJiti;
35391
+ };
35392
+ const isSelfPackageResolutionError = (error) => error instanceof Error && "code" in error && typeof error.code === "string" && MODULE_NOT_FOUND_ERROR_CODES.has(error.code) && error.message.includes(SELF_PACKAGE_IMPORT_SPECIFIER);
35393
+ const loadModuleConfig = async (filePath) => {
35394
+ try {
35395
+ return await importDefaultExport(jiti, filePath);
35396
+ } catch (error) {
35397
+ if (!isSelfPackageResolutionError(error)) throw error;
35398
+ const aliasJiti = getSelfAliasJiti();
35399
+ if (!aliasJiti) throw error;
35400
+ try {
35401
+ return await importDefaultExport(aliasJiti, filePath);
35402
+ } catch (retryError) {
35403
+ throw new Error(`${formatError(error)} (retry with ${SELF_PACKAGE_IMPORT_SPECIFIER} aliased to the running react-doctor package also failed: ${formatError(retryError)})`, { cause: retryError });
35404
+ }
35405
+ }
35406
+ };
35354
35407
  const readDataConfig = (filePath) => parseJSON5(NFS.readFileSync(filePath, "utf-8"));
35355
35408
  const readEmbeddedPackageJsonConfig = (directory) => {
35356
35409
  const packageJsonPath = Path.join(directory, PACKAGE_JSON_FILENAME);
@@ -36010,6 +36063,17 @@ const checkPnpmHardening = (rootDirectory) => {
36010
36063
  }));
36011
36064
  return diagnostics;
36012
36065
  };
36066
+ const buildReactNativeDiagnostic = (input) => ({
36067
+ filePath: input.filePath,
36068
+ plugin: "react-doctor",
36069
+ rule: input.rule,
36070
+ severity: input.severity ?? "warning",
36071
+ message: input.message,
36072
+ help: input.help,
36073
+ line: input.line ?? 0,
36074
+ column: input.column ?? 0,
36075
+ category: input.category ?? "Correctness"
36076
+ });
36013
36077
  const BUILDER_BOB_PACKAGE = "react-native-builder-bob";
36014
36078
  const isBuilderBobLibrary = (packageJson) => {
36015
36079
  const bobConfig = packageJson[BUILDER_BOB_PACKAGE];
@@ -36021,17 +36085,12 @@ const checkReactNativeLibraryDependencies = (rootDirectory) => {
36021
36085
  const misplaced = ["react", "react-native"].filter((name) => packageJson.dependencies?.[name] !== void 0);
36022
36086
  if (misplaced.length === 0) return [];
36023
36087
  const quoted = misplaced.map((name) => `"${name}"`).join(" and ");
36024
- return [{
36088
+ return [buildReactNativeDiagnostic({
36025
36089
  filePath: "package.json",
36026
- plugin: "react-doctor",
36027
36090
  rule: "rn-library-react-in-dependencies",
36028
- severity: "warning",
36029
36091
  message: `This react-native-builder-bob library lists ${quoted} in \`dependencies\` — that ships a second copy into consumer apps, causing "Invalid hook call" (duplicate React) and duplicate-native-module crashes.`,
36030
- help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`,
36031
- line: 0,
36032
- column: 0,
36033
- category: "Correctness"
36034
- }];
36092
+ help: `Move ${quoted} to \`peerDependencies\` (keep ${misplaced.length === 1 ? "it" : "them"} in \`devDependencies\` for local development).`
36093
+ })];
36035
36094
  };
36036
36095
  const BABEL_CONFIG_FILE_NAMES = [
36037
36096
  "babel.config.js",
@@ -36043,6 +36102,8 @@ const BABEL_CONFIG_FILE_NAMES = [
36043
36102
  ".babelrc.json"
36044
36103
  ];
36045
36104
  const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
36105
+ const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
36106
+ const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
36046
36107
  const checkReactNativeMetroBabelPreset = (rootDirectory) => {
36047
36108
  for (const fileName of BABEL_CONFIG_FILE_NAMES) {
36048
36109
  const filePath = Path.join(rootDirectory, fileName);
@@ -36053,18 +36114,20 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
36053
36114
  } catch {
36054
36115
  continue;
36055
36116
  }
36056
- if (!contents.includes(LEGACY_PRESET_SPEC)) continue;
36057
- return [{
36117
+ if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
36058
36118
  filePath: fileName,
36059
- plugin: "react-doctor",
36060
36119
  rule: "rn-no-metro-babel-preset",
36061
36120
  severity: "error",
36062
36121
  message: "`module:metro-react-native-babel-preset` was renamed to `@react-native/babel-preset` and is no longer installed by React Native 0.73+ — this preset reference fails to resolve and breaks the Metro/Babel transform.",
36063
- help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency.",
36064
- line: 0,
36065
- column: 0,
36066
- category: "Correctness"
36067
- }];
36122
+ help: "Replace the preset with `module:@react-native/babel-preset` (or `babel-preset-expo` on Expo) and remove the old `metro-react-native-babel-preset` dependency."
36123
+ })];
36124
+ if (MODERN_PRESET_REFERENCE.test(contents) && !ENABLE_BABEL_RUNTIME_VERSION.test(contents)) return [buildReactNativeDiagnostic({
36125
+ filePath: fileName,
36126
+ rule: "rn-no-metro-babel-runtime-version",
36127
+ severity: "warning",
36128
+ message: "`module:@react-native/babel-preset` has no `enableBabelRuntime` version, so Babel runtime helpers can be duplicated across files instead of imported once from @babel/runtime, increasing the JS bundle size.",
36129
+ help: "Set `enableBabelRuntime` to the @babel/runtime version from package.json, e.g. `['module:@react-native/babel-preset', { enableBabelRuntime: '^7.26.0' }]`."
36130
+ })];
36068
36131
  }
36069
36132
  return [];
36070
36133
  };
@@ -38460,9 +38523,18 @@ const shouldSuppressLocalUseHookDiagnostic = (diagnostic, rootDirectory) => {
38460
38523
  return bindingResolution !== null && !bindingResolution.isReactUseBinding;
38461
38524
  };
38462
38525
  const FILEPATH_WITH_LOCATION_PATTERN = /\S+\.\w+:\d+:\d+[\s\S]*$/;
38526
+ const LEADING_SEVERITY_LABEL_PATTERN = /^(?:Error|Warning):\s*/;
38527
+ const TRAILING_PERIOD_PATTERN = /\.$/;
38463
38528
  const REACT_COMPILER_TITLE = "React Compiler can't optimize this";
38464
38529
  const REACT_COMPILER_TODO_TITLE = "React Compiler doesn't support this syntax";
38465
- const REACT_COMPILER_MESSAGE = "This component misses React Compiler's automatic memoization & re-renders more than it should. Rewrite the flagged code so the compiler can optimize it.";
38530
+ const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
38531
+ const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
38532
+ const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
38533
+ const buildReactCompilerMessage = (reasonSummary) => {
38534
+ const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
38535
+ if (!normalizedSummary) return REACT_COMPILER_GENERIC_MESSAGE;
38536
+ return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${REACT_COMPILER_ACTION}`;
38537
+ };
38466
38538
  const PLUGIN_CATEGORY_MAP = {
38467
38539
  react: "Bugs",
38468
38540
  "react-hooks": "Bugs",
@@ -38501,10 +38573,19 @@ const cleanDiagnosticMessage = (message, help, plugin, rule, project) => {
38501
38573
  };
38502
38574
  };
38503
38575
  const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
38504
- if (plugin === "react-hooks-js") return {
38505
- message: REACT_COMPILER_MESSAGE,
38506
- help: appendReanimatedSharedValueHint(message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || help, rule, project)
38507
- };
38576
+ if (plugin === "react-hooks-js") {
38577
+ const bailoutReason = message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim().replace(LEADING_SEVERITY_LABEL_PATTERN, "").trim();
38578
+ if (rule === "todo") return {
38579
+ message: REACT_COMPILER_GENERIC_MESSAGE,
38580
+ help: appendReanimatedSharedValueHint(bailoutReason || help, rule, project)
38581
+ };
38582
+ const [reasonSummary = "", ...reasonDetailLines] = bailoutReason.split("\n");
38583
+ const reasonDetail = reasonDetailLines.join("\n").trim();
38584
+ return {
38585
+ message: buildReactCompilerMessage(reasonSummary.trim()),
38586
+ help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
38587
+ };
38588
+ }
38508
38589
  return {
38509
38590
  message: message.replace(FILEPATH_WITH_LOCATION_PATTERN, "").trim() || message,
38510
38591
  help: help || getRuleRecommendation(rule, project) || ""
@@ -39171,7 +39252,7 @@ const ScoreApiResponseSchema = Struct({
39171
39252
  })))
39172
39253
  });
39173
39254
  const parseScoreResult = (value) => getOrNull(decodeUnknownOption(ScoreApiResponseSchema)(value));
39174
- const stripFilePaths = (diagnostics) => diagnostics.map(({ filePath: _filePath, ...rest }) => rest);
39255
+ const stripLocalFileFields = (diagnostics) => diagnostics.map(({ filePath: _filePath, fileContext: _fileContext, ...rest }) => rest);
39175
39256
  const isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
39176
39257
  const describeFailure = (error) => {
39177
39258
  if (isAbortError(error)) return `timed out after ${FETCH_TIMEOUT_MS / 1e3}s`;
@@ -39184,7 +39265,7 @@ const calculateScore = async (diagnostics, options = {}) => {
39184
39265
  const requestUrl = options.isCi ? `${SCORE_API_URL}?ci=1` : SCORE_API_URL;
39185
39266
  try {
39186
39267
  const compressedBody = gzipSync(JSON.stringify({
39187
- diagnostics: stripFilePaths(diagnostics),
39268
+ diagnostics: stripLocalFileFields(diagnostics),
39188
39269
  ...options.metadata?.repo ? { repo: options.metadata.repo } : {},
39189
39270
  ...options.metadata?.sha ? { sha: options.metadata.sha } : {},
39190
39271
  ...options.metadata?.framework ? { framework: options.metadata.framework } : {},
@@ -40011,7 +40092,7 @@ const computeConfigFingerprint = (projectDirectory, version) => {
40011
40092
  /** Display name used in client-facing messages and progress titles. */
40012
40093
  const SERVER_DISPLAY_NAME = "React Doctor";
40013
40094
  /** Server version reported in `serverInfo`; injected at build, `dev` from source. */
40014
- const SERVER_VERSION = "0.5.1";
40095
+ const SERVER_VERSION = "0.5.2";
40015
40096
  /** `Diagnostic.source` shown next to every published diagnostic. */
40016
40097
  const DIAGNOSTIC_SOURCE = "react-doctor";
40017
40098
  /**
@@ -42058,5 +42139,5 @@ const startLanguageServer = () => {
42058
42139
  };
42059
42140
  //#endregion
42060
42141
  export { startLanguageServer };
42061
- !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]="1e6dd9cd-7bbf-509d-9302-bdf56d4cf879")}catch(e){}}();
42062
- //# debugId=1e6dd9cd-7bbf-509d-9302-bdf56d4cf879
42142
+ !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]="f84d06b3-b31c-5442-9457-b108cbc3cbbe")}catch(e){}}();
42143
+ //# debugId=f84d06b3-b31c-5442-9457-b108cbc3cbbe
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.5.1-dev.fee3fc4",
3
+ "version": "0.5.2-dev.094d470",
4
4
  "description": "Your agent writes bad React. This catches it",
5
5
  "keywords": [
6
6
  "accessibility",
@@ -54,7 +54,7 @@
54
54
  "agent-install": "0.0.5",
55
55
  "conf": "^15.1.0",
56
56
  "confbox": "^0.2.4",
57
- "deslop-js": "^0.0.23",
57
+ "deslop-js": "^0.0.24",
58
58
  "eslint-plugin-react-hooks": "^7.1.1",
59
59
  "jiti": "^2.7.0",
60
60
  "magicast": "^0.5.3",
@@ -64,7 +64,7 @@
64
64
  "vscode-languageserver": "^9.0.1",
65
65
  "vscode-languageserver-textdocument": "^1.0.12",
66
66
  "vscode-uri": "^3.1.0",
67
- "oxlint-plugin-react-doctor": "0.5.1-dev.fee3fc4"
67
+ "oxlint-plugin-react-doctor": "0.5.2-dev.094d470"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/babel__code-frame": "^7.27.0",
@@ -72,9 +72,9 @@
72
72
  "@xterm/headless": "^6.0.0",
73
73
  "commander": "^14.0.3",
74
74
  "ora": "^9.4.0",
75
- "@react-doctor/api": "0.5.1",
76
- "@react-doctor/language-server": "0.5.1",
77
- "@react-doctor/core": "0.5.1"
75
+ "@react-doctor/api": "0.5.2",
76
+ "@react-doctor/core": "0.5.2",
77
+ "@react-doctor/language-server": "0.5.2"
78
78
  },
79
79
  "engines": {
80
80
  "node": "^20.19.0 || >=22.13.0"