react-doctor 0.8.1-dev.61bf03e → 0.8.1-dev.7818922
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 +92 -720
- package/dist/index.d.ts +15 -29
- package/dist/index.js +23 -225
- package/dist/lsp.js +23 -225
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -9030,12 +9030,11 @@ interface Diagnostic {
|
|
|
9030
9030
|
* Set when the finding's identity is the flagged element itself (a missing
|
|
9031
9031
|
* attribute, a wrong element) rather than the flagged line's text — every
|
|
9032
9032
|
* Accessibility-category finding, plus rules that opt in via their
|
|
9033
|
-
* `matchByOccurrence` metadata flag.
|
|
9034
|
-
* `
|
|
9035
|
-
*
|
|
9036
|
-
*
|
|
9037
|
-
*
|
|
9038
|
-
* matching (the default).
|
|
9033
|
+
* `matchByOccurrence` metadata flag. `computeDiagnosticDelta` matches these
|
|
9034
|
+
* by `(filePath, plugin/rule)` occurrence count, so reformatting the flagged
|
|
9035
|
+
* line doesn't reclassify a pre-existing finding as new. Resolved at
|
|
9036
|
+
* diagnostic creation, where rule metadata is available. Absent means
|
|
9037
|
+
* line-text-sensitive matching (the default).
|
|
9039
9038
|
*/
|
|
9040
9039
|
matchByOccurrence?: boolean;
|
|
9041
9040
|
/**
|
|
@@ -9543,31 +9542,11 @@ interface ProjectInfo {
|
|
|
9543
9542
|
zodVersion: string | null;
|
|
9544
9543
|
/** Parsed major from `zodVersion`, or `null` when absent/unparseable. Mirrors `reactMajorVersion`. */
|
|
9545
9544
|
zodMajorVersion: number | null;
|
|
9546
|
-
/** Declared MobX core version spec. Optional so existing `ProjectInfo` consumers remain source-compatible. */
|
|
9547
|
-
mobxVersion?: string | null;
|
|
9548
|
-
/** Parsed major from `mobxVersion`, or `null` when absent/unparseable. */
|
|
9549
|
-
mobxMajorVersion?: number | null;
|
|
9550
|
-
hasMobxReact?: boolean;
|
|
9551
|
-
hasMobxReactLite?: boolean;
|
|
9552
|
-
hasMobxStateTree?: boolean;
|
|
9553
|
-
hasMobxReactObserver?: boolean;
|
|
9554
9545
|
framework: Framework;
|
|
9555
9546
|
hasTypeScript: boolean;
|
|
9556
9547
|
hasReactCompiler: boolean;
|
|
9557
9548
|
hasReactCompilerLintPlugin?: boolean;
|
|
9558
9549
|
hasTanStackQuery: boolean;
|
|
9559
|
-
hasRemotion?: boolean;
|
|
9560
|
-
remotionVersion?: string | null;
|
|
9561
|
-
remotionMajorVersion?: number | null;
|
|
9562
|
-
/**
|
|
9563
|
-
* The declared `valtio` version spec, or `null` when no package in the
|
|
9564
|
-
* analyzed project declares Valtio. `useSnapshot` has kept the same
|
|
9565
|
-
* render-read contract across Valtio 1 and 2, so presence alone drives the
|
|
9566
|
-
* `valtio` capability and its parsed major-version ladder.
|
|
9567
|
-
*/
|
|
9568
|
-
valtioVersion: string | null;
|
|
9569
|
-
/** Parsed major from `valtioVersion`, or `null` when absent/unparseable. */
|
|
9570
|
-
valtioMajorVersion: number | null;
|
|
9571
9550
|
/**
|
|
9572
9551
|
* `true` when the project or a workspace declares a Vite-based SSR runtime
|
|
9573
9552
|
* such as React Router's Node adapter, Vike, or vite-plugin-ssr.
|
|
@@ -9868,8 +9847,7 @@ interface InspectResult {
|
|
|
9868
9847
|
baselineDelta?: {
|
|
9869
9848
|
/** The commit the base content was read from (resolved merge-base). */baseRef: string; /** Findings present at base but gone at head — resolved by the change. */
|
|
9870
9849
|
fixedCount: number; /** Total findings at base (over the same files), for context. */
|
|
9871
|
-
baseTotalCount: number;
|
|
9872
|
-
crossFileMatchCount?: number;
|
|
9850
|
+
baseTotalCount: number;
|
|
9873
9851
|
};
|
|
9874
9852
|
}
|
|
9875
9853
|
/**
|
|
@@ -10285,7 +10263,15 @@ declare const buildJsonReport: (input: BuildJsonReportInput) => JsonReportV3$1;
|
|
|
10285
10263
|
* `GitBaseBranchMissing`) as clean user errors instead of crashes.
|
|
10286
10264
|
*/
|
|
10287
10265
|
declare const getDiffInfo: (directory: string, explicitBaseBranch?: string, includeUntracked?: boolean) => Promise<DiffInfo | null>;
|
|
10288
|
-
declare const filterSourceFiles: (filePaths:
|
|
10266
|
+
declare const filterSourceFiles: (filePaths: string[]) => string[];
|
|
10267
|
+
/**
|
|
10268
|
+
* Programmatic façade over `Git.changedLineRanges` (the `lines` scope). Diffs
|
|
10269
|
+
* `files` with `--unified=0` against `baseRef` (or the index when `cached`),
|
|
10270
|
+
* returning per-file changed line ranges relative to `directory`. Returns
|
|
10271
|
+
* `null` when the ranges can't be computed (git unavailable / unsafe ref /
|
|
10272
|
+
* non-zero exit) so the caller degrades to file-level scope; an empty array
|
|
10273
|
+
* means git succeeded but the files added no lines.
|
|
10274
|
+
*/
|
|
10289
10275
|
//#endregion
|
|
10290
10276
|
//#region src/summarize-diagnostics.d.ts
|
|
10291
10277
|
declare const summarizeDiagnostics: (diagnostics: Diagnostic[], worstScore?: number | null, worstScoreLabel?: string | null) => JsonReportSummary; //#endregion
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3121a4e4-8a4a-55ea-ade8-47d0bf576a2f")}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 reactDoctorPlugin, { 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_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
|
|
@@ -34121,10 +34121,6 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34121
34121
|
return packages;
|
|
34122
34122
|
};
|
|
34123
34123
|
const REANIMATED_DEPENDENCY_NAME = "react-native-reanimated";
|
|
34124
|
-
const MOBX_REACT_PACKAGE_NAME = "mobx-react";
|
|
34125
|
-
const MOBX_REACT_LITE_PACKAGE_NAME = "mobx-react-lite";
|
|
34126
|
-
const MOBX_STATE_TREE_PACKAGE_NAME = "mobx-state-tree";
|
|
34127
|
-
const MOBX_REACT_OBSERVER_PACKAGE_NAME = "mobx-react-observer";
|
|
34128
34124
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34129
34125
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34130
34126
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34143,18 +34139,7 @@ const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
|
34143
34139
|
if (nextMajor === null) return false;
|
|
34144
34140
|
return nextMajor < currentMajor;
|
|
34145
34141
|
};
|
|
34146
|
-
const
|
|
34147
|
-
if (currentFact.version === null) return true;
|
|
34148
|
-
if (nextFact.version === null) return false;
|
|
34149
|
-
const currentMajor = getLowestDependencyMajor(currentFact.version);
|
|
34150
|
-
const nextMajor = getLowestDependencyMajor(nextFact.version);
|
|
34151
|
-
if (currentMajor === null) return false;
|
|
34152
|
-
if (nextMajor === null) return true;
|
|
34153
|
-
if (currentMajor > 6) return false;
|
|
34154
|
-
if (nextMajor > 6) return true;
|
|
34155
|
-
return nextMajor < currentMajor;
|
|
34156
|
-
};
|
|
34157
|
-
const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, rootPackageJson) => {
|
|
34142
|
+
const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
34158
34143
|
if (facts.expo.version === null) {
|
|
34159
34144
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34160
34145
|
if (spec !== null) facts.expo = {
|
|
@@ -34176,52 +34161,13 @@ const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, roo
|
|
|
34176
34161
|
sourceDirectory: directory
|
|
34177
34162
|
};
|
|
34178
34163
|
}
|
|
34179
|
-
const mobxSpec = getDependencySpec(packageJson, "mobx");
|
|
34180
|
-
if (mobxSpec !== null) {
|
|
34181
|
-
const nextMobxFact = {
|
|
34182
|
-
version: resolveCatalogBackedDependencyVersion({
|
|
34183
|
-
rootDirectory: directory,
|
|
34184
|
-
rootPackageJson: packageJson,
|
|
34185
|
-
packageName: "mobx",
|
|
34186
|
-
version: mobxSpec
|
|
34187
|
-
}),
|
|
34188
|
-
sourceDirectory: directory
|
|
34189
|
-
};
|
|
34190
|
-
if (shouldReplaceMobxFact(facts.mobx, nextMobxFact)) facts.mobx = nextMobxFact;
|
|
34191
|
-
}
|
|
34192
|
-
facts.hasMobxReact = facts.hasMobxReact || getDependencySpec(packageJson, MOBX_REACT_PACKAGE_NAME) !== null;
|
|
34193
|
-
facts.hasMobxReactLite = facts.hasMobxReactLite || getDependencySpec(packageJson, MOBX_REACT_LITE_PACKAGE_NAME) !== null;
|
|
34194
|
-
facts.hasMobxStateTree = facts.hasMobxStateTree || getDependencySpec(packageJson, MOBX_STATE_TREE_PACKAGE_NAME) !== null;
|
|
34195
|
-
facts.hasMobxReactObserver = facts.hasMobxReactObserver || getDependencySpec(packageJson, MOBX_REACT_OBSERVER_PACKAGE_NAME) !== null;
|
|
34196
34164
|
if (facts.reanimatedVersion === null) {
|
|
34197
34165
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34198
34166
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34199
34167
|
}
|
|
34200
|
-
if (facts.valtioVersion === null) {
|
|
34201
|
-
const spec = getDependencySpec(packageJson, "valtio");
|
|
34202
|
-
if (spec !== null) facts.valtioVersion = spec;
|
|
34203
|
-
}
|
|
34204
34168
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34205
34169
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34206
34170
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34207
|
-
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34208
|
-
if (remotionSpec !== null) {
|
|
34209
|
-
facts.hasRemotionDependency = true;
|
|
34210
|
-
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34211
|
-
rootDirectory,
|
|
34212
|
-
rootPackageJson,
|
|
34213
|
-
packageName: "remotion",
|
|
34214
|
-
version: remotionSpec
|
|
34215
|
-
});
|
|
34216
|
-
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34217
|
-
if (remotionMajorVersion === null) {
|
|
34218
|
-
facts.hasUnknownRemotionVersion = true;
|
|
34219
|
-
facts.remotionVersion = null;
|
|
34220
|
-
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34221
|
-
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34222
|
-
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34223
|
-
}
|
|
34224
|
-
}
|
|
34225
34171
|
};
|
|
34226
34172
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34227
34173
|
const facts = {
|
|
@@ -34241,24 +34187,12 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34241
34187
|
version: null,
|
|
34242
34188
|
sourceDirectory: null
|
|
34243
34189
|
},
|
|
34244
|
-
valtioVersion: null,
|
|
34245
|
-
mobx: {
|
|
34246
|
-
version: null,
|
|
34247
|
-
sourceDirectory: null
|
|
34248
|
-
},
|
|
34249
|
-
hasMobxReact: false,
|
|
34250
|
-
hasMobxReactLite: false,
|
|
34251
|
-
hasMobxStateTree: false,
|
|
34252
|
-
hasMobxReactObserver: false,
|
|
34253
34190
|
hasReactNativeAwarePackage: false,
|
|
34254
34191
|
hasReanimatedAwarePackage: false,
|
|
34255
34192
|
hasSsrDependency: false,
|
|
34256
|
-
hasRemotionDependency: false,
|
|
34257
|
-
hasUnknownRemotionVersion: false,
|
|
34258
|
-
remotionVersion: null,
|
|
34259
34193
|
reanimatedVersion: null
|
|
34260
34194
|
};
|
|
34261
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory
|
|
34195
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34262
34196
|
let isReactGroupSettled = !collectReactGroup;
|
|
34263
34197
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34264
34198
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
@@ -34267,7 +34201,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34267
34201
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34268
34202
|
visitedDirectories.add(workspaceDirectory);
|
|
34269
34203
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34270
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory
|
|
34204
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34271
34205
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34272
34206
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34273
34207
|
if (isReactGroupSettled) continue;
|
|
@@ -34491,22 +34425,11 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34491
34425
|
tailwindVersion: null,
|
|
34492
34426
|
zodVersion: null,
|
|
34493
34427
|
zodMajorVersion: null,
|
|
34494
|
-
mobxVersion: null,
|
|
34495
|
-
mobxMajorVersion: null,
|
|
34496
|
-
hasMobxReact: false,
|
|
34497
|
-
hasMobxReactLite: false,
|
|
34498
|
-
hasMobxStateTree: false,
|
|
34499
|
-
hasMobxReactObserver: false,
|
|
34500
34428
|
framework: "unknown",
|
|
34501
34429
|
hasTypeScript: hasOwnTsConfig,
|
|
34502
34430
|
hasReactCompiler: false,
|
|
34503
34431
|
hasReactCompilerLintPlugin: false,
|
|
34504
34432
|
hasTanStackQuery: false,
|
|
34505
|
-
valtioVersion: null,
|
|
34506
|
-
valtioMajorVersion: null,
|
|
34507
|
-
hasRemotion: false,
|
|
34508
|
-
remotionVersion: null,
|
|
34509
|
-
remotionMajorVersion: null,
|
|
34510
34433
|
hasSsrDependency: false,
|
|
34511
34434
|
preactVersion: null,
|
|
34512
34435
|
preactMajorVersion: null,
|
|
@@ -34613,20 +34536,7 @@ const discoverProject = (directory) => {
|
|
|
34613
34536
|
packageName: "next",
|
|
34614
34537
|
version: workspaceFacts.next.version
|
|
34615
34538
|
}) : null;
|
|
34616
|
-
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
34617
|
-
rootDirectory: directory,
|
|
34618
|
-
rootPackageJson: packageJson,
|
|
34619
|
-
packageName: "valtio",
|
|
34620
|
-
version: workspaceFacts.valtioVersion
|
|
34621
|
-
});
|
|
34622
|
-
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
34623
|
-
rootDirectory: directory,
|
|
34624
|
-
rootPackageJson: packageJson,
|
|
34625
|
-
packageName: "mobx",
|
|
34626
|
-
version: workspaceFacts.mobx.version
|
|
34627
|
-
});
|
|
34628
34539
|
const preactVersion = getPreactVersion(packageJson);
|
|
34629
|
-
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34630
34540
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34631
34541
|
const projectInfo = {
|
|
34632
34542
|
rootDirectory: directory,
|
|
@@ -34636,22 +34546,11 @@ const discoverProject = (directory) => {
|
|
|
34636
34546
|
tailwindVersion,
|
|
34637
34547
|
zodVersion,
|
|
34638
34548
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
34639
|
-
mobxVersion,
|
|
34640
|
-
mobxMajorVersion: mobxVersion === null ? null : getLowestDependencyMajor(mobxVersion),
|
|
34641
|
-
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
34642
|
-
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
34643
|
-
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
34644
|
-
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
34645
34549
|
framework,
|
|
34646
34550
|
hasTypeScript,
|
|
34647
34551
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34648
34552
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
34649
34553
|
hasTanStackQuery: hasTanStackQuery(packageJson),
|
|
34650
|
-
valtioVersion,
|
|
34651
|
-
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
34652
|
-
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
34653
|
-
remotionVersion,
|
|
34654
|
-
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
34655
34554
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34656
34555
|
preactVersion,
|
|
34657
34556
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
@@ -34885,6 +34784,7 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
34885
34784
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
34886
34785
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
34887
34786
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34787
|
+
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
34888
34788
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
34889
34789
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
34890
34790
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37171,25 +37071,9 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37171
37071
|
".babelrc.json"
|
|
37172
37072
|
];
|
|
37173
37073
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37174
|
-
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37175
|
-
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37176
|
-
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37177
|
-
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37178
37074
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37179
37075
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37180
|
-
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37181
|
-
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37182
|
-
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37183
|
-
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37184
|
-
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37185
|
-
if (normalizedVersionRange === null) return false;
|
|
37186
|
-
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37187
|
-
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37188
|
-
};
|
|
37189
|
-
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37190
37076
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37191
|
-
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37192
|
-
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37193
37077
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37194
37078
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37195
37079
|
if (!isFile(filePath)) continue;
|
|
@@ -37199,7 +37083,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37199
37083
|
} catch {
|
|
37200
37084
|
continue;
|
|
37201
37085
|
}
|
|
37202
|
-
if (
|
|
37086
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
37203
37087
|
filePath: fileName,
|
|
37204
37088
|
rule: "rn-no-metro-babel-preset",
|
|
37205
37089
|
severity: "error",
|
|
@@ -37222,6 +37106,12 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37222
37106
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37223
37107
|
};
|
|
37224
37108
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37109
|
+
const DEPENDENCY_SECTIONS = [
|
|
37110
|
+
"dependencies",
|
|
37111
|
+
"devDependencies",
|
|
37112
|
+
"peerDependencies",
|
|
37113
|
+
"optionalDependencies"
|
|
37114
|
+
];
|
|
37225
37115
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37226
37116
|
"19.0": {
|
|
37227
37117
|
rceFixedVersion: "19.0.1",
|
|
@@ -37268,13 +37158,20 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37268
37158
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37269
37159
|
return [...directories];
|
|
37270
37160
|
};
|
|
37161
|
+
const readDeclaredSpec = (packageJson, packageName) => {
|
|
37162
|
+
for (const section of DEPENDENCY_SECTIONS) {
|
|
37163
|
+
const spec = packageJson[section]?.[packageName];
|
|
37164
|
+
if (typeof spec === "string") return spec;
|
|
37165
|
+
}
|
|
37166
|
+
return null;
|
|
37167
|
+
};
|
|
37271
37168
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37272
37169
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37273
37170
|
if (isFile(manifestPath)) {
|
|
37274
37171
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37275
37172
|
if (installedVersion !== null) return installedVersion;
|
|
37276
37173
|
}
|
|
37277
|
-
const candidateSpecs = [
|
|
37174
|
+
const candidateSpecs = [readDeclaredSpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37278
37175
|
for (const spec of candidateSpecs) {
|
|
37279
37176
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37280
37177
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -37954,22 +37851,9 @@ const buildCapabilities = (project) => {
|
|
|
37954
37851
|
})) capabilities.add("tailwind:3.4");
|
|
37955
37852
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
37956
37853
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
37957
|
-
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
37958
|
-
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
37959
|
-
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
37960
|
-
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
37961
|
-
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
37962
|
-
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
37963
|
-
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addMajorLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
37964
37854
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
37965
37855
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
37966
37856
|
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
37967
|
-
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
37968
|
-
addMajorLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
37969
|
-
if (project.hasRemotion) {
|
|
37970
|
-
capabilities.add("remotion");
|
|
37971
|
-
addMajorLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
37972
|
-
}
|
|
37973
37857
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
37974
37858
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
37975
37859
|
addMajorLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
@@ -39206,35 +39090,6 @@ const parseGithubViewerPermission = (stdout) => {
|
|
|
39206
39090
|
return /^[A-Z_]+$/.test(value) ? value.toLowerCase() : null;
|
|
39207
39091
|
};
|
|
39208
39092
|
const splitNullSeparated = (value) => value.split("\0").filter((entry) => entry.length > 0);
|
|
39209
|
-
const parseBaselineDiffPlan = (value) => {
|
|
39210
|
-
const entries = splitNullSeparated(value);
|
|
39211
|
-
const baseFiles = /* @__PURE__ */ new Set();
|
|
39212
|
-
const headFiles = /* @__PURE__ */ new Set();
|
|
39213
|
-
for (let entryIndex = 0; entryIndex < entries.length; entryIndex += 2) {
|
|
39214
|
-
const status = entries[entryIndex];
|
|
39215
|
-
const filePath = entries[entryIndex + 1];
|
|
39216
|
-
if (status === void 0 || filePath === void 0 || status.length !== 1) return null;
|
|
39217
|
-
if (status === "A") {
|
|
39218
|
-
headFiles.add(filePath);
|
|
39219
|
-
continue;
|
|
39220
|
-
}
|
|
39221
|
-
if (status === "D") {
|
|
39222
|
-
baseFiles.add(filePath);
|
|
39223
|
-
continue;
|
|
39224
|
-
}
|
|
39225
|
-
if (status === "M" || status === "T") {
|
|
39226
|
-
baseFiles.add(filePath);
|
|
39227
|
-
headFiles.add(filePath);
|
|
39228
|
-
continue;
|
|
39229
|
-
}
|
|
39230
|
-
return null;
|
|
39231
|
-
}
|
|
39232
|
-
return {
|
|
39233
|
-
baseFiles: [...baseFiles],
|
|
39234
|
-
headFiles: [...headFiles],
|
|
39235
|
-
untrackedFiles: []
|
|
39236
|
-
};
|
|
39237
|
-
};
|
|
39238
39093
|
const UNTRACKED_FILE_LAST_LINE = Number.MAX_SAFE_INTEGER;
|
|
39239
39094
|
/**
|
|
39240
39095
|
* `Git` wraps every `git`-via-subprocess call react-doctor makes
|
|
@@ -39437,45 +39292,6 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
39437
39292
|
githubViewerPermission,
|
|
39438
39293
|
branchExists,
|
|
39439
39294
|
mergeBase,
|
|
39440
|
-
baselineDiffPlan: (input) => {
|
|
39441
|
-
if (!isSafeGitRevision(input.ref)) return succeed$2(null);
|
|
39442
|
-
return gen(function* () {
|
|
39443
|
-
const unmerged = yield* runGit(input.directory, [
|
|
39444
|
-
"diff",
|
|
39445
|
-
"--no-ext-diff",
|
|
39446
|
-
"-z",
|
|
39447
|
-
"--name-only",
|
|
39448
|
-
"--diff-filter=U",
|
|
39449
|
-
"--relative"
|
|
39450
|
-
]);
|
|
39451
|
-
if (unmerged.status !== 0 || unmerged.stdout.length > 0) return null;
|
|
39452
|
-
const result = yield* runGit(input.directory, [
|
|
39453
|
-
"diff",
|
|
39454
|
-
"--no-ext-diff",
|
|
39455
|
-
"--no-textconv",
|
|
39456
|
-
"--no-renames",
|
|
39457
|
-
"-z",
|
|
39458
|
-
"--name-status",
|
|
39459
|
-
"--relative",
|
|
39460
|
-
input.ref
|
|
39461
|
-
]);
|
|
39462
|
-
if (result.status !== 0) return null;
|
|
39463
|
-
const plan = parseBaselineDiffPlan(result.stdout);
|
|
39464
|
-
if (plan === null) return null;
|
|
39465
|
-
const untracked = yield* runGit(input.directory, [
|
|
39466
|
-
"ls-files",
|
|
39467
|
-
"--others",
|
|
39468
|
-
"--exclude-standard",
|
|
39469
|
-
"-z"
|
|
39470
|
-
]);
|
|
39471
|
-
if (untracked.status !== 0) return null;
|
|
39472
|
-
return {
|
|
39473
|
-
baseFiles: plan.baseFiles,
|
|
39474
|
-
headFiles: plan.headFiles,
|
|
39475
|
-
untrackedFiles: splitNullSeparated(untracked.stdout)
|
|
39476
|
-
};
|
|
39477
|
-
}).pipe(catch_$1(() => succeed$2(null)), withSpan("Git.baselineDiffPlan"));
|
|
39478
|
-
},
|
|
39479
39295
|
diffSelection: ({ directory, explicitBaseBranch, includeUntracked = false }) => gen(function* () {
|
|
39480
39296
|
if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* fail$4(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
|
|
39481
39297
|
if (explicitBaseBranch !== void 0) {
|
|
@@ -39625,7 +39441,6 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
39625
39441
|
githubViewerPermission: () => succeed$2(snapshot.githubViewerPermission ?? null),
|
|
39626
39442
|
branchExists: (_directory, branch) => succeed$2(snapshot.branchExists?.get(branch) ?? false),
|
|
39627
39443
|
mergeBase: ({ ref }) => succeed$2(snapshot.mergeBase?.get(ref) ?? null),
|
|
39628
|
-
baselineDiffPlan: () => succeed$2(snapshot.baselineDiffPlan ?? null),
|
|
39629
39444
|
diffSelection: () => succeed$2(snapshot.diffSelection ?? null),
|
|
39630
39445
|
stagedFilePaths: () => succeed$2(snapshot.stagedFiles ?? []),
|
|
39631
39446
|
showStagedContent: (_directory, relativePath) => succeed$2(snapshot.stagedContent?.get(relativePath) ?? null),
|
|
@@ -40963,17 +40778,12 @@ const REACT_ERROR_BOUNDARY_MESSAGE = "This try/catch cannot catch errors thrown
|
|
|
40963
40778
|
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
40964
40779
|
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
40965
40780
|
const REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION = "It's how the library works, not a bug in your code. Memoize values you pass from it into other memoized components, or suppress it with `// react-doctor-disable-next-line react-hooks-js/incompatible-library`.";
|
|
40966
|
-
const SET_STATE_IN_EFFECT_ACTION = "Prefer deriving or initializing the value before render. If the effect must read a browser API after mount, treat this as advisory or suppress it with `// react-doctor-disable-next-line react-hooks-js/set-state-in-effect`.";
|
|
40967
40781
|
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
40968
40782
|
const buildReactCompilerMessage = (reasonSummary, action = REACT_COMPILER_ACTION) => {
|
|
40969
40783
|
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
40970
40784
|
if (!normalizedSummary) return `${REACT_COMPILER_IMPACT}. ${action}`;
|
|
40971
40785
|
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${action}`;
|
|
40972
40786
|
};
|
|
40973
|
-
const buildSetStateInEffectMessage = (reasonSummary) => {
|
|
40974
|
-
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
40975
|
-
return `This synchronous effect update causes an extra render${normalizedSummary ? `: ${normalizedSummary}` : ""}. ${SET_STATE_IN_EFFECT_ACTION}`;
|
|
40976
|
-
};
|
|
40977
40787
|
const PLUGIN_CATEGORY_MAP = {
|
|
40978
40788
|
react: "Bugs",
|
|
40979
40789
|
"react-hooks": "Bugs",
|
|
@@ -41031,10 +40841,6 @@ const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
|
41031
40841
|
message: REACT_ERROR_BOUNDARY_MESSAGE,
|
|
41032
40842
|
help: reasonDetail || help
|
|
41033
40843
|
};
|
|
41034
|
-
if (rule === "set-state-in-effect") return {
|
|
41035
|
-
message: buildSetStateInEffectMessage(reasonSummary.trim()),
|
|
41036
|
-
help: reasonDetail || help
|
|
41037
|
-
};
|
|
41038
40844
|
return {
|
|
41039
40845
|
message: buildReactCompilerMessage(reasonSummary.trim(), rule === "incompatible-library" ? REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION : REACT_COMPILER_ACTION),
|
|
41040
40846
|
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
@@ -43360,19 +43166,12 @@ const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
|
|
|
43360
43166
|
*/
|
|
43361
43167
|
const materializeSourceTree = (input) => gen(function* () {
|
|
43362
43168
|
const materializedFiles = [];
|
|
43363
|
-
const unmaterializedFiles = [];
|
|
43364
43169
|
const resolvedTempDirectory = path.resolve(input.tempDirectory);
|
|
43365
43170
|
for (const relativePath of input.files) {
|
|
43366
43171
|
const content = yield* input.readContent(relativePath).pipe(orElseSucceed(() => null));
|
|
43367
|
-
if (content === null)
|
|
43368
|
-
unmaterializedFiles.push(relativePath);
|
|
43369
|
-
continue;
|
|
43370
|
-
}
|
|
43172
|
+
if (content === null) continue;
|
|
43371
43173
|
const candidateTargetPath = path.resolve(resolvedTempDirectory, relativePath);
|
|
43372
|
-
if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory))
|
|
43373
|
-
unmaterializedFiles.push(relativePath);
|
|
43374
|
-
continue;
|
|
43375
|
-
}
|
|
43174
|
+
if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory)) continue;
|
|
43376
43175
|
yield* sync(() => {
|
|
43377
43176
|
fs.mkdirSync(path.dirname(candidateTargetPath), { recursive: true });
|
|
43378
43177
|
fs.writeFileSync(candidateTargetPath, content);
|
|
@@ -43389,7 +43188,6 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
43389
43188
|
return {
|
|
43390
43189
|
tempDirectory: input.tempDirectory,
|
|
43391
43190
|
materializedFiles,
|
|
43392
|
-
unmaterializedFiles,
|
|
43393
43191
|
cleanup: () => {
|
|
43394
43192
|
try {
|
|
43395
43193
|
fs.rmSync(input.tempDirectory, {
|
|
@@ -43953,4 +43751,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
43953
43751
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
43954
43752
|
|
|
43955
43753
|
//# sourceMappingURL=index.js.map
|
|
43956
|
-
//# debugId=
|
|
43754
|
+
//# debugId=3121a4e4-8a4a-55ea-ade8-47d0bf576a2f
|