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/lsp.js
CHANGED
|
@@ -34173,10 +34173,6 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34173
34173
|
return packages;
|
|
34174
34174
|
};
|
|
34175
34175
|
const REANIMATED_DEPENDENCY_NAME = "react-native-reanimated";
|
|
34176
|
-
const MOBX_REACT_PACKAGE_NAME = "mobx-react";
|
|
34177
|
-
const MOBX_REACT_LITE_PACKAGE_NAME = "mobx-react-lite";
|
|
34178
|
-
const MOBX_STATE_TREE_PACKAGE_NAME = "mobx-state-tree";
|
|
34179
|
-
const MOBX_REACT_OBSERVER_PACKAGE_NAME = "mobx-react-observer";
|
|
34180
34176
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34181
34177
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34182
34178
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34195,18 +34191,7 @@ const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
|
34195
34191
|
if (nextMajor === null) return false;
|
|
34196
34192
|
return nextMajor < currentMajor;
|
|
34197
34193
|
};
|
|
34198
|
-
const
|
|
34199
|
-
if (currentFact.version === null) return true;
|
|
34200
|
-
if (nextFact.version === null) return false;
|
|
34201
|
-
const currentMajor = getLowestDependencyMajor(currentFact.version);
|
|
34202
|
-
const nextMajor = getLowestDependencyMajor(nextFact.version);
|
|
34203
|
-
if (currentMajor === null) return false;
|
|
34204
|
-
if (nextMajor === null) return true;
|
|
34205
|
-
if (currentMajor > 6) return false;
|
|
34206
|
-
if (nextMajor > 6) return true;
|
|
34207
|
-
return nextMajor < currentMajor;
|
|
34208
|
-
};
|
|
34209
|
-
const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, rootPackageJson) => {
|
|
34194
|
+
const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
34210
34195
|
if (facts.expo.version === null) {
|
|
34211
34196
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34212
34197
|
if (spec !== null) facts.expo = {
|
|
@@ -34228,52 +34213,13 @@ const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, roo
|
|
|
34228
34213
|
sourceDirectory: directory
|
|
34229
34214
|
};
|
|
34230
34215
|
}
|
|
34231
|
-
const mobxSpec = getDependencySpec(packageJson, "mobx");
|
|
34232
|
-
if (mobxSpec !== null) {
|
|
34233
|
-
const nextMobxFact = {
|
|
34234
|
-
version: resolveCatalogBackedDependencyVersion({
|
|
34235
|
-
rootDirectory: directory,
|
|
34236
|
-
rootPackageJson: packageJson,
|
|
34237
|
-
packageName: "mobx",
|
|
34238
|
-
version: mobxSpec
|
|
34239
|
-
}),
|
|
34240
|
-
sourceDirectory: directory
|
|
34241
|
-
};
|
|
34242
|
-
if (shouldReplaceMobxFact(facts.mobx, nextMobxFact)) facts.mobx = nextMobxFact;
|
|
34243
|
-
}
|
|
34244
|
-
facts.hasMobxReact = facts.hasMobxReact || getDependencySpec(packageJson, MOBX_REACT_PACKAGE_NAME) !== null;
|
|
34245
|
-
facts.hasMobxReactLite = facts.hasMobxReactLite || getDependencySpec(packageJson, MOBX_REACT_LITE_PACKAGE_NAME) !== null;
|
|
34246
|
-
facts.hasMobxStateTree = facts.hasMobxStateTree || getDependencySpec(packageJson, MOBX_STATE_TREE_PACKAGE_NAME) !== null;
|
|
34247
|
-
facts.hasMobxReactObserver = facts.hasMobxReactObserver || getDependencySpec(packageJson, MOBX_REACT_OBSERVER_PACKAGE_NAME) !== null;
|
|
34248
34216
|
if (facts.reanimatedVersion === null) {
|
|
34249
34217
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34250
34218
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34251
34219
|
}
|
|
34252
|
-
if (facts.valtioVersion === null) {
|
|
34253
|
-
const spec = getDependencySpec(packageJson, "valtio");
|
|
34254
|
-
if (spec !== null) facts.valtioVersion = spec;
|
|
34255
|
-
}
|
|
34256
34220
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34257
34221
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34258
34222
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34259
|
-
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34260
|
-
if (remotionSpec !== null) {
|
|
34261
|
-
facts.hasRemotionDependency = true;
|
|
34262
|
-
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34263
|
-
rootDirectory,
|
|
34264
|
-
rootPackageJson,
|
|
34265
|
-
packageName: "remotion",
|
|
34266
|
-
version: remotionSpec
|
|
34267
|
-
});
|
|
34268
|
-
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34269
|
-
if (remotionMajorVersion === null) {
|
|
34270
|
-
facts.hasUnknownRemotionVersion = true;
|
|
34271
|
-
facts.remotionVersion = null;
|
|
34272
|
-
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34273
|
-
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34274
|
-
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34275
|
-
}
|
|
34276
|
-
}
|
|
34277
34223
|
};
|
|
34278
34224
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34279
34225
|
const facts = {
|
|
@@ -34293,24 +34239,12 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34293
34239
|
version: null,
|
|
34294
34240
|
sourceDirectory: null
|
|
34295
34241
|
},
|
|
34296
|
-
valtioVersion: null,
|
|
34297
|
-
mobx: {
|
|
34298
|
-
version: null,
|
|
34299
|
-
sourceDirectory: null
|
|
34300
|
-
},
|
|
34301
|
-
hasMobxReact: false,
|
|
34302
|
-
hasMobxReactLite: false,
|
|
34303
|
-
hasMobxStateTree: false,
|
|
34304
|
-
hasMobxReactObserver: false,
|
|
34305
34242
|
hasReactNativeAwarePackage: false,
|
|
34306
34243
|
hasReanimatedAwarePackage: false,
|
|
34307
34244
|
hasSsrDependency: false,
|
|
34308
|
-
hasRemotionDependency: false,
|
|
34309
|
-
hasUnknownRemotionVersion: false,
|
|
34310
|
-
remotionVersion: null,
|
|
34311
34245
|
reanimatedVersion: null
|
|
34312
34246
|
};
|
|
34313
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory
|
|
34247
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34314
34248
|
let isReactGroupSettled = !collectReactGroup;
|
|
34315
34249
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34316
34250
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
@@ -34319,7 +34253,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34319
34253
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34320
34254
|
visitedDirectories.add(workspaceDirectory);
|
|
34321
34255
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34322
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory
|
|
34256
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34323
34257
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34324
34258
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34325
34259
|
if (isReactGroupSettled) continue;
|
|
@@ -34543,22 +34477,11 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34543
34477
|
tailwindVersion: null,
|
|
34544
34478
|
zodVersion: null,
|
|
34545
34479
|
zodMajorVersion: null,
|
|
34546
|
-
mobxVersion: null,
|
|
34547
|
-
mobxMajorVersion: null,
|
|
34548
|
-
hasMobxReact: false,
|
|
34549
|
-
hasMobxReactLite: false,
|
|
34550
|
-
hasMobxStateTree: false,
|
|
34551
|
-
hasMobxReactObserver: false,
|
|
34552
34480
|
framework: "unknown",
|
|
34553
34481
|
hasTypeScript: hasOwnTsConfig,
|
|
34554
34482
|
hasReactCompiler: false,
|
|
34555
34483
|
hasReactCompilerLintPlugin: false,
|
|
34556
34484
|
hasTanStackQuery: false,
|
|
34557
|
-
valtioVersion: null,
|
|
34558
|
-
valtioMajorVersion: null,
|
|
34559
|
-
hasRemotion: false,
|
|
34560
|
-
remotionVersion: null,
|
|
34561
|
-
remotionMajorVersion: null,
|
|
34562
34485
|
hasSsrDependency: false,
|
|
34563
34486
|
preactVersion: null,
|
|
34564
34487
|
preactMajorVersion: null,
|
|
@@ -34665,20 +34588,7 @@ const discoverProject = (directory) => {
|
|
|
34665
34588
|
packageName: "next",
|
|
34666
34589
|
version: workspaceFacts.next.version
|
|
34667
34590
|
}) : null;
|
|
34668
|
-
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
34669
|
-
rootDirectory: directory,
|
|
34670
|
-
rootPackageJson: packageJson,
|
|
34671
|
-
packageName: "valtio",
|
|
34672
|
-
version: workspaceFacts.valtioVersion
|
|
34673
|
-
});
|
|
34674
|
-
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
34675
|
-
rootDirectory: directory,
|
|
34676
|
-
rootPackageJson: packageJson,
|
|
34677
|
-
packageName: "mobx",
|
|
34678
|
-
version: workspaceFacts.mobx.version
|
|
34679
|
-
});
|
|
34680
34591
|
const preactVersion = getPreactVersion(packageJson);
|
|
34681
|
-
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34682
34592
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34683
34593
|
const projectInfo = {
|
|
34684
34594
|
rootDirectory: directory,
|
|
@@ -34688,22 +34598,11 @@ const discoverProject = (directory) => {
|
|
|
34688
34598
|
tailwindVersion,
|
|
34689
34599
|
zodVersion,
|
|
34690
34600
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
34691
|
-
mobxVersion,
|
|
34692
|
-
mobxMajorVersion: mobxVersion === null ? null : getLowestDependencyMajor(mobxVersion),
|
|
34693
|
-
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
34694
|
-
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
34695
|
-
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
34696
|
-
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
34697
34601
|
framework,
|
|
34698
34602
|
hasTypeScript,
|
|
34699
34603
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34700
34604
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
34701
34605
|
hasTanStackQuery: hasTanStackQuery(packageJson),
|
|
34702
|
-
valtioVersion,
|
|
34703
|
-
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
34704
|
-
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
34705
|
-
remotionVersion,
|
|
34706
|
-
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
34707
34606
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34708
34607
|
preactVersion,
|
|
34709
34608
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
@@ -34937,6 +34836,7 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
34937
34836
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
34938
34837
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
34939
34838
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34839
|
+
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
34940
34840
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
34941
34841
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
34942
34842
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37149,25 +37049,9 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37149
37049
|
".babelrc.json"
|
|
37150
37050
|
];
|
|
37151
37051
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37152
|
-
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37153
|
-
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37154
|
-
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37155
|
-
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37156
37052
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37157
37053
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37158
|
-
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37159
|
-
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37160
|
-
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37161
|
-
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37162
|
-
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37163
|
-
if (normalizedVersionRange === null) return false;
|
|
37164
|
-
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37165
|
-
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37166
|
-
};
|
|
37167
|
-
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37168
37054
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37169
|
-
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37170
|
-
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37171
37055
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37172
37056
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37173
37057
|
if (!isFile(filePath)) continue;
|
|
@@ -37177,7 +37061,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37177
37061
|
} catch {
|
|
37178
37062
|
continue;
|
|
37179
37063
|
}
|
|
37180
|
-
if (
|
|
37064
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
37181
37065
|
filePath: fileName,
|
|
37182
37066
|
rule: "rn-no-metro-babel-preset",
|
|
37183
37067
|
severity: "error",
|
|
@@ -37200,6 +37084,12 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37200
37084
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37201
37085
|
};
|
|
37202
37086
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37087
|
+
const DEPENDENCY_SECTIONS = [
|
|
37088
|
+
"dependencies",
|
|
37089
|
+
"devDependencies",
|
|
37090
|
+
"peerDependencies",
|
|
37091
|
+
"optionalDependencies"
|
|
37092
|
+
];
|
|
37203
37093
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37204
37094
|
"19.0": {
|
|
37205
37095
|
rceFixedVersion: "19.0.1",
|
|
@@ -37246,13 +37136,20 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37246
37136
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37247
37137
|
return [...directories];
|
|
37248
37138
|
};
|
|
37139
|
+
const readDeclaredSpec = (packageJson, packageName) => {
|
|
37140
|
+
for (const section of DEPENDENCY_SECTIONS) {
|
|
37141
|
+
const spec = packageJson[section]?.[packageName];
|
|
37142
|
+
if (typeof spec === "string") return spec;
|
|
37143
|
+
}
|
|
37144
|
+
return null;
|
|
37145
|
+
};
|
|
37249
37146
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37250
37147
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37251
37148
|
if (isFile(manifestPath)) {
|
|
37252
37149
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37253
37150
|
if (installedVersion !== null) return installedVersion;
|
|
37254
37151
|
}
|
|
37255
|
-
const candidateSpecs = [
|
|
37152
|
+
const candidateSpecs = [readDeclaredSpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37256
37153
|
for (const spec of candidateSpecs) {
|
|
37257
37154
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37258
37155
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -37932,22 +37829,9 @@ const buildCapabilities = (project) => {
|
|
|
37932
37829
|
})) capabilities.add("tailwind:3.4");
|
|
37933
37830
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
37934
37831
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
37935
|
-
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
37936
|
-
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
37937
|
-
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
37938
|
-
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
37939
|
-
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
37940
|
-
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
37941
|
-
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addMajorLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
37942
37832
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
37943
37833
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
37944
37834
|
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
37945
|
-
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
37946
|
-
addMajorLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
37947
|
-
if (project.hasRemotion) {
|
|
37948
|
-
capabilities.add("remotion");
|
|
37949
|
-
addMajorLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
37950
|
-
}
|
|
37951
37835
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
37952
37836
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
37953
37837
|
addMajorLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
@@ -39184,35 +39068,6 @@ const parseGithubViewerPermission = (stdout) => {
|
|
|
39184
39068
|
return /^[A-Z_]+$/.test(value) ? value.toLowerCase() : null;
|
|
39185
39069
|
};
|
|
39186
39070
|
const splitNullSeparated = (value) => value.split("\0").filter((entry) => entry.length > 0);
|
|
39187
|
-
const parseBaselineDiffPlan = (value) => {
|
|
39188
|
-
const entries = splitNullSeparated(value);
|
|
39189
|
-
const baseFiles = /* @__PURE__ */ new Set();
|
|
39190
|
-
const headFiles = /* @__PURE__ */ new Set();
|
|
39191
|
-
for (let entryIndex = 0; entryIndex < entries.length; entryIndex += 2) {
|
|
39192
|
-
const status = entries[entryIndex];
|
|
39193
|
-
const filePath = entries[entryIndex + 1];
|
|
39194
|
-
if (status === void 0 || filePath === void 0 || status.length !== 1) return null;
|
|
39195
|
-
if (status === "A") {
|
|
39196
|
-
headFiles.add(filePath);
|
|
39197
|
-
continue;
|
|
39198
|
-
}
|
|
39199
|
-
if (status === "D") {
|
|
39200
|
-
baseFiles.add(filePath);
|
|
39201
|
-
continue;
|
|
39202
|
-
}
|
|
39203
|
-
if (status === "M" || status === "T") {
|
|
39204
|
-
baseFiles.add(filePath);
|
|
39205
|
-
headFiles.add(filePath);
|
|
39206
|
-
continue;
|
|
39207
|
-
}
|
|
39208
|
-
return null;
|
|
39209
|
-
}
|
|
39210
|
-
return {
|
|
39211
|
-
baseFiles: [...baseFiles],
|
|
39212
|
-
headFiles: [...headFiles],
|
|
39213
|
-
untrackedFiles: []
|
|
39214
|
-
};
|
|
39215
|
-
};
|
|
39216
39071
|
const UNTRACKED_FILE_LAST_LINE = Number.MAX_SAFE_INTEGER;
|
|
39217
39072
|
/**
|
|
39218
39073
|
* `Git` wraps every `git`-via-subprocess call react-doctor makes
|
|
@@ -39415,45 +39270,6 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
39415
39270
|
githubViewerPermission,
|
|
39416
39271
|
branchExists,
|
|
39417
39272
|
mergeBase,
|
|
39418
|
-
baselineDiffPlan: (input) => {
|
|
39419
|
-
if (!isSafeGitRevision(input.ref)) return succeed$2(null);
|
|
39420
|
-
return gen(function* () {
|
|
39421
|
-
const unmerged = yield* runGit(input.directory, [
|
|
39422
|
-
"diff",
|
|
39423
|
-
"--no-ext-diff",
|
|
39424
|
-
"-z",
|
|
39425
|
-
"--name-only",
|
|
39426
|
-
"--diff-filter=U",
|
|
39427
|
-
"--relative"
|
|
39428
|
-
]);
|
|
39429
|
-
if (unmerged.status !== 0 || unmerged.stdout.length > 0) return null;
|
|
39430
|
-
const result = yield* runGit(input.directory, [
|
|
39431
|
-
"diff",
|
|
39432
|
-
"--no-ext-diff",
|
|
39433
|
-
"--no-textconv",
|
|
39434
|
-
"--no-renames",
|
|
39435
|
-
"-z",
|
|
39436
|
-
"--name-status",
|
|
39437
|
-
"--relative",
|
|
39438
|
-
input.ref
|
|
39439
|
-
]);
|
|
39440
|
-
if (result.status !== 0) return null;
|
|
39441
|
-
const plan = parseBaselineDiffPlan(result.stdout);
|
|
39442
|
-
if (plan === null) return null;
|
|
39443
|
-
const untracked = yield* runGit(input.directory, [
|
|
39444
|
-
"ls-files",
|
|
39445
|
-
"--others",
|
|
39446
|
-
"--exclude-standard",
|
|
39447
|
-
"-z"
|
|
39448
|
-
]);
|
|
39449
|
-
if (untracked.status !== 0) return null;
|
|
39450
|
-
return {
|
|
39451
|
-
baseFiles: plan.baseFiles,
|
|
39452
|
-
headFiles: plan.headFiles,
|
|
39453
|
-
untrackedFiles: splitNullSeparated(untracked.stdout)
|
|
39454
|
-
};
|
|
39455
|
-
}).pipe(catch_$1(() => succeed$2(null)), withSpan("Git.baselineDiffPlan"));
|
|
39456
|
-
},
|
|
39457
39273
|
diffSelection: ({ directory, explicitBaseBranch, includeUntracked = false }) => gen(function* () {
|
|
39458
39274
|
if (explicitBaseBranch !== void 0 && explicitBaseBranch.trim().length === 0) return yield* fail$4(new ReactDoctorError({ reason: new GitBaseBranchInvalid({ detail: "Diff base branch cannot be empty." }) }));
|
|
39459
39275
|
if (explicitBaseBranch !== void 0) {
|
|
@@ -39603,7 +39419,6 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
39603
39419
|
githubViewerPermission: () => succeed$2(snapshot.githubViewerPermission ?? null),
|
|
39604
39420
|
branchExists: (_directory, branch) => succeed$2(snapshot.branchExists?.get(branch) ?? false),
|
|
39605
39421
|
mergeBase: ({ ref }) => succeed$2(snapshot.mergeBase?.get(ref) ?? null),
|
|
39606
|
-
baselineDiffPlan: () => succeed$2(snapshot.baselineDiffPlan ?? null),
|
|
39607
39422
|
diffSelection: () => succeed$2(snapshot.diffSelection ?? null),
|
|
39608
39423
|
stagedFilePaths: () => succeed$2(snapshot.stagedFiles ?? []),
|
|
39609
39424
|
showStagedContent: (_directory, relativePath) => succeed$2(snapshot.stagedContent?.get(relativePath) ?? null),
|
|
@@ -40941,17 +40756,12 @@ const REACT_ERROR_BOUNDARY_MESSAGE = "This try/catch cannot catch errors thrown
|
|
|
40941
40756
|
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
40942
40757
|
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
40943
40758
|
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`.";
|
|
40944
|
-
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`.";
|
|
40945
40759
|
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
40946
40760
|
const buildReactCompilerMessage = (reasonSummary, action = REACT_COMPILER_ACTION) => {
|
|
40947
40761
|
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
40948
40762
|
if (!normalizedSummary) return `${REACT_COMPILER_IMPACT}. ${action}`;
|
|
40949
40763
|
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${action}`;
|
|
40950
40764
|
};
|
|
40951
|
-
const buildSetStateInEffectMessage = (reasonSummary) => {
|
|
40952
|
-
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
40953
|
-
return `This synchronous effect update causes an extra render${normalizedSummary ? `: ${normalizedSummary}` : ""}. ${SET_STATE_IN_EFFECT_ACTION}`;
|
|
40954
|
-
};
|
|
40955
40765
|
const PLUGIN_CATEGORY_MAP = {
|
|
40956
40766
|
react: "Bugs",
|
|
40957
40767
|
"react-hooks": "Bugs",
|
|
@@ -41009,10 +40819,6 @@ const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
|
41009
40819
|
message: REACT_ERROR_BOUNDARY_MESSAGE,
|
|
41010
40820
|
help: reasonDetail || help
|
|
41011
40821
|
};
|
|
41012
|
-
if (rule === "set-state-in-effect") return {
|
|
41013
|
-
message: buildSetStateInEffectMessage(reasonSummary.trim()),
|
|
41014
|
-
help: reasonDetail || help
|
|
41015
|
-
};
|
|
41016
40822
|
return {
|
|
41017
40823
|
message: buildReactCompilerMessage(reasonSummary.trim(), rule === "incompatible-library" ? REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION : REACT_COMPILER_ACTION),
|
|
41018
40824
|
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
@@ -43338,19 +43144,12 @@ const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
|
|
|
43338
43144
|
*/
|
|
43339
43145
|
const materializeSourceTree = (input) => gen(function* () {
|
|
43340
43146
|
const materializedFiles = [];
|
|
43341
|
-
const unmaterializedFiles = [];
|
|
43342
43147
|
const resolvedTempDirectory = path.resolve(input.tempDirectory);
|
|
43343
43148
|
for (const relativePath of input.files) {
|
|
43344
43149
|
const content = yield* input.readContent(relativePath).pipe(orElseSucceed(() => null));
|
|
43345
|
-
if (content === null)
|
|
43346
|
-
unmaterializedFiles.push(relativePath);
|
|
43347
|
-
continue;
|
|
43348
|
-
}
|
|
43150
|
+
if (content === null) continue;
|
|
43349
43151
|
const candidateTargetPath = path.resolve(resolvedTempDirectory, relativePath);
|
|
43350
|
-
if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory))
|
|
43351
|
-
unmaterializedFiles.push(relativePath);
|
|
43352
|
-
continue;
|
|
43353
|
-
}
|
|
43152
|
+
if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory)) continue;
|
|
43354
43153
|
yield* sync(() => {
|
|
43355
43154
|
fs.mkdirSync(path.dirname(candidateTargetPath), { recursive: true });
|
|
43356
43155
|
fs.writeFileSync(candidateTargetPath, content);
|
|
@@ -43367,7 +43166,6 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
43367
43166
|
return {
|
|
43368
43167
|
tempDirectory: input.tempDirectory,
|
|
43369
43168
|
materializedFiles,
|
|
43370
|
-
unmaterializedFiles,
|
|
43371
43169
|
cleanup: () => {
|
|
43372
43170
|
try {
|
|
43373
43171
|
fs.rmSync(input.tempDirectory, {
|
|
@@ -45573,5 +45371,5 @@ const startLanguageServer = () => {
|
|
|
45573
45371
|
};
|
|
45574
45372
|
//#endregion
|
|
45575
45373
|
export { startLanguageServer };
|
|
45576
|
-
!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]="
|
|
45577
|
-
//# debugId=
|
|
45374
|
+
!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]="0f56accc-b639-5b90-a1a3-5faa727907dc")}catch(e){}}();
|
|
45375
|
+
//# debugId=0f56accc-b639-5b90-a1a3-5faa727907dc
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.8.1-dev.
|
|
3
|
+
"version": "0.8.1-dev.7818922",
|
|
4
4
|
"description": "Your agent writes bad React. This catches it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"vscode-uri": "^3.1.0",
|
|
67
67
|
"yaml": "^2.9.0",
|
|
68
68
|
"deslop-js": "0.8.1",
|
|
69
|
-
"oxlint-plugin-react-doctor": "0.8.1-dev.
|
|
69
|
+
"oxlint-plugin-react-doctor": "0.8.1-dev.7818922"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/babel__code-frame": "^7.27.0",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"@xterm/headless": "^6.0.0",
|
|
75
75
|
"commander": "^14.0.3",
|
|
76
76
|
"ora": "^9.4.0",
|
|
77
|
-
"@react-doctor/core": "0.8.1",
|
|
78
77
|
"@react-doctor/api": "0.8.1",
|
|
79
|
-
"@react-doctor/language-server": "0.8.1"
|
|
78
|
+
"@react-doctor/language-server": "0.8.1",
|
|
79
|
+
"@react-doctor/core": "0.8.1"
|
|
80
80
|
},
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": "^20.19.0 || >=22.13.0"
|