react-doctor 0.8.1-dev.6fcd9c9 → 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 -749
- package/dist/index.d.ts +15 -33
- package/dist/index.js +23 -254
- package/dist/lsp.js +23 -254
- package/package.json +3 -3
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 > latestSupportedMajor) return false;
|
|
34206
|
-
if (nextMajor > latestSupportedMajor) 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,65 +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 (shouldReplaceSupportedDependencyFact(facts.mobx, nextMobxFact, 6)) 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
|
-
const zustandSpec = getDependencySpec(packageJson, "zustand");
|
|
34249
|
-
if (zustandSpec !== null) {
|
|
34250
|
-
const nextZustandFact = {
|
|
34251
|
-
version: resolveCatalogBackedDependencyVersion({
|
|
34252
|
-
rootDirectory: directory,
|
|
34253
|
-
rootPackageJson: packageJson,
|
|
34254
|
-
packageName: "zustand",
|
|
34255
|
-
version: zustandSpec
|
|
34256
|
-
}),
|
|
34257
|
-
sourceDirectory: directory
|
|
34258
|
-
};
|
|
34259
|
-
if (shouldReplaceSupportedDependencyFact(facts.zustand, nextZustandFact, 5)) facts.zustand = nextZustandFact;
|
|
34260
|
-
}
|
|
34261
34216
|
if (facts.reanimatedVersion === null) {
|
|
34262
34217
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34263
34218
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34264
34219
|
}
|
|
34265
|
-
if (facts.valtioVersion === null) {
|
|
34266
|
-
const spec = getDependencySpec(packageJson, "valtio");
|
|
34267
|
-
if (spec !== null) facts.valtioVersion = spec;
|
|
34268
|
-
}
|
|
34269
34220
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34270
34221
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34271
34222
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34272
|
-
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34273
|
-
if (remotionSpec !== null) {
|
|
34274
|
-
facts.hasRemotionDependency = true;
|
|
34275
|
-
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34276
|
-
rootDirectory,
|
|
34277
|
-
rootPackageJson,
|
|
34278
|
-
packageName: "remotion",
|
|
34279
|
-
version: remotionSpec
|
|
34280
|
-
});
|
|
34281
|
-
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34282
|
-
if (remotionMajorVersion === null) {
|
|
34283
|
-
facts.hasUnknownRemotionVersion = true;
|
|
34284
|
-
facts.remotionVersion = null;
|
|
34285
|
-
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34286
|
-
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34287
|
-
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34288
|
-
}
|
|
34289
|
-
}
|
|
34290
34223
|
};
|
|
34291
34224
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34292
34225
|
const facts = {
|
|
@@ -34306,28 +34239,12 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34306
34239
|
version: null,
|
|
34307
34240
|
sourceDirectory: null
|
|
34308
34241
|
},
|
|
34309
|
-
valtioVersion: null,
|
|
34310
|
-
mobx: {
|
|
34311
|
-
version: null,
|
|
34312
|
-
sourceDirectory: null
|
|
34313
|
-
},
|
|
34314
|
-
hasMobxReact: false,
|
|
34315
|
-
hasMobxReactLite: false,
|
|
34316
|
-
hasMobxStateTree: false,
|
|
34317
|
-
hasMobxReactObserver: false,
|
|
34318
|
-
zustand: {
|
|
34319
|
-
version: null,
|
|
34320
|
-
sourceDirectory: null
|
|
34321
|
-
},
|
|
34322
34242
|
hasReactNativeAwarePackage: false,
|
|
34323
34243
|
hasReanimatedAwarePackage: false,
|
|
34324
34244
|
hasSsrDependency: false,
|
|
34325
|
-
hasRemotionDependency: false,
|
|
34326
|
-
hasUnknownRemotionVersion: false,
|
|
34327
|
-
remotionVersion: null,
|
|
34328
34245
|
reanimatedVersion: null
|
|
34329
34246
|
};
|
|
34330
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory
|
|
34247
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34331
34248
|
let isReactGroupSettled = !collectReactGroup;
|
|
34332
34249
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34333
34250
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
@@ -34336,7 +34253,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34336
34253
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34337
34254
|
visitedDirectories.add(workspaceDirectory);
|
|
34338
34255
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34339
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory
|
|
34256
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34340
34257
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34341
34258
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34342
34259
|
if (isReactGroupSettled) continue;
|
|
@@ -34560,24 +34477,11 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34560
34477
|
tailwindVersion: null,
|
|
34561
34478
|
zodVersion: null,
|
|
34562
34479
|
zodMajorVersion: null,
|
|
34563
|
-
mobxVersion: null,
|
|
34564
|
-
mobxMajorVersion: null,
|
|
34565
|
-
hasMobxReact: false,
|
|
34566
|
-
hasMobxReactLite: false,
|
|
34567
|
-
hasMobxStateTree: false,
|
|
34568
|
-
hasMobxReactObserver: false,
|
|
34569
|
-
zustandVersion: null,
|
|
34570
|
-
zustandMajorVersion: null,
|
|
34571
34480
|
framework: "unknown",
|
|
34572
34481
|
hasTypeScript: hasOwnTsConfig,
|
|
34573
34482
|
hasReactCompiler: false,
|
|
34574
34483
|
hasReactCompilerLintPlugin: false,
|
|
34575
34484
|
hasTanStackQuery: false,
|
|
34576
|
-
valtioVersion: null,
|
|
34577
|
-
valtioMajorVersion: null,
|
|
34578
|
-
hasRemotion: false,
|
|
34579
|
-
remotionVersion: null,
|
|
34580
|
-
remotionMajorVersion: null,
|
|
34581
34485
|
hasSsrDependency: false,
|
|
34582
34486
|
preactVersion: null,
|
|
34583
34487
|
preactMajorVersion: null,
|
|
@@ -34676,12 +34580,6 @@ const discoverProject = (directory) => {
|
|
|
34676
34580
|
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
34677
34581
|
version: workspaceFacts.shopifyFlashList.version
|
|
34678
34582
|
}) : null;
|
|
34679
|
-
const zustandVersion = resolveCatalogBackedDependencyVersion({
|
|
34680
|
-
rootDirectory: directory,
|
|
34681
|
-
rootPackageJson: packageJson,
|
|
34682
|
-
packageName: "zustand",
|
|
34683
|
-
version: workspaceFacts.zustand.version
|
|
34684
|
-
});
|
|
34685
34583
|
const hasReanimated = hasReactNativeWorkspace && workspaceFacts.hasReanimatedAwarePackage;
|
|
34686
34584
|
const reanimatedVersion = hasReanimated ? workspaceFacts.reanimatedVersion : null;
|
|
34687
34585
|
const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
|
|
@@ -34690,20 +34588,7 @@ const discoverProject = (directory) => {
|
|
|
34690
34588
|
packageName: "next",
|
|
34691
34589
|
version: workspaceFacts.next.version
|
|
34692
34590
|
}) : null;
|
|
34693
|
-
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
34694
|
-
rootDirectory: directory,
|
|
34695
|
-
rootPackageJson: packageJson,
|
|
34696
|
-
packageName: "valtio",
|
|
34697
|
-
version: workspaceFacts.valtioVersion
|
|
34698
|
-
});
|
|
34699
|
-
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
34700
|
-
rootDirectory: directory,
|
|
34701
|
-
rootPackageJson: packageJson,
|
|
34702
|
-
packageName: "mobx",
|
|
34703
|
-
version: workspaceFacts.mobx.version
|
|
34704
|
-
});
|
|
34705
34591
|
const preactVersion = getPreactVersion(packageJson);
|
|
34706
|
-
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34707
34592
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34708
34593
|
const projectInfo = {
|
|
34709
34594
|
rootDirectory: directory,
|
|
@@ -34713,24 +34598,11 @@ const discoverProject = (directory) => {
|
|
|
34713
34598
|
tailwindVersion,
|
|
34714
34599
|
zodVersion,
|
|
34715
34600
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
34716
|
-
mobxVersion,
|
|
34717
|
-
mobxMajorVersion: mobxVersion === null ? null : getLowestDependencyMajor(mobxVersion),
|
|
34718
|
-
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
34719
|
-
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
34720
|
-
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
34721
|
-
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
34722
|
-
zustandVersion,
|
|
34723
|
-
zustandMajorVersion: zustandVersion === null ? null : getLowestDependencyMajor(zustandVersion),
|
|
34724
34601
|
framework,
|
|
34725
34602
|
hasTypeScript,
|
|
34726
34603
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34727
34604
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
34728
34605
|
hasTanStackQuery: hasTanStackQuery(packageJson),
|
|
34729
|
-
valtioVersion,
|
|
34730
|
-
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
34731
|
-
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
34732
|
-
remotionVersion,
|
|
34733
|
-
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
34734
34606
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34735
34607
|
preactVersion,
|
|
34736
34608
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
@@ -34964,6 +34836,7 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
34964
34836
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
34965
34837
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
34966
34838
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34839
|
+
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
34967
34840
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
34968
34841
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
34969
34842
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37176,25 +37049,9 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37176
37049
|
".babelrc.json"
|
|
37177
37050
|
];
|
|
37178
37051
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37179
|
-
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37180
|
-
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37181
|
-
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37182
|
-
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37183
37052
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37184
37053
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37185
|
-
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37186
|
-
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37187
|
-
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37188
|
-
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37189
|
-
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37190
|
-
if (normalizedVersionRange === null) return false;
|
|
37191
|
-
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37192
|
-
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37193
|
-
};
|
|
37194
|
-
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37195
37054
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37196
|
-
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37197
|
-
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37198
37055
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37199
37056
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37200
37057
|
if (!isFile(filePath)) continue;
|
|
@@ -37204,7 +37061,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37204
37061
|
} catch {
|
|
37205
37062
|
continue;
|
|
37206
37063
|
}
|
|
37207
|
-
if (
|
|
37064
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
37208
37065
|
filePath: fileName,
|
|
37209
37066
|
rule: "rn-no-metro-babel-preset",
|
|
37210
37067
|
severity: "error",
|
|
@@ -37227,6 +37084,12 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37227
37084
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37228
37085
|
};
|
|
37229
37086
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37087
|
+
const DEPENDENCY_SECTIONS = [
|
|
37088
|
+
"dependencies",
|
|
37089
|
+
"devDependencies",
|
|
37090
|
+
"peerDependencies",
|
|
37091
|
+
"optionalDependencies"
|
|
37092
|
+
];
|
|
37230
37093
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37231
37094
|
"19.0": {
|
|
37232
37095
|
rceFixedVersion: "19.0.1",
|
|
@@ -37273,13 +37136,20 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37273
37136
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37274
37137
|
return [...directories];
|
|
37275
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
|
+
};
|
|
37276
37146
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37277
37147
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37278
37148
|
if (isFile(manifestPath)) {
|
|
37279
37149
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37280
37150
|
if (installedVersion !== null) return installedVersion;
|
|
37281
37151
|
}
|
|
37282
|
-
const candidateSpecs = [
|
|
37152
|
+
const candidateSpecs = [readDeclaredSpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37283
37153
|
for (const spec of candidateSpecs) {
|
|
37284
37154
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37285
37155
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -37959,24 +37829,9 @@ const buildCapabilities = (project) => {
|
|
|
37959
37829
|
})) capabilities.add("tailwind:3.4");
|
|
37960
37830
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
37961
37831
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
37962
|
-
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
37963
|
-
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
37964
|
-
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
37965
|
-
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
37966
|
-
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
37967
|
-
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
37968
|
-
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addMajorLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
37969
|
-
if (project.zustandVersion !== void 0 && project.zustandVersion !== null) capabilities.add("zustand");
|
|
37970
|
-
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addMajorLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
37971
37832
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
37972
37833
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
37973
37834
|
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
37974
|
-
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
37975
|
-
addMajorLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
37976
|
-
if (project.hasRemotion) {
|
|
37977
|
-
capabilities.add("remotion");
|
|
37978
|
-
addMajorLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
37979
|
-
}
|
|
37980
37835
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
37981
37836
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
37982
37837
|
addMajorLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
@@ -39213,35 +39068,6 @@ const parseGithubViewerPermission = (stdout) => {
|
|
|
39213
39068
|
return /^[A-Z_]+$/.test(value) ? value.toLowerCase() : null;
|
|
39214
39069
|
};
|
|
39215
39070
|
const splitNullSeparated = (value) => value.split("\0").filter((entry) => entry.length > 0);
|
|
39216
|
-
const parseBaselineDiffPlan = (value) => {
|
|
39217
|
-
const entries = splitNullSeparated(value);
|
|
39218
|
-
const baseFiles = /* @__PURE__ */ new Set();
|
|
39219
|
-
const headFiles = /* @__PURE__ */ new Set();
|
|
39220
|
-
for (let entryIndex = 0; entryIndex < entries.length; entryIndex += 2) {
|
|
39221
|
-
const status = entries[entryIndex];
|
|
39222
|
-
const filePath = entries[entryIndex + 1];
|
|
39223
|
-
if (status === void 0 || filePath === void 0 || status.length !== 1) return null;
|
|
39224
|
-
if (status === "A") {
|
|
39225
|
-
headFiles.add(filePath);
|
|
39226
|
-
continue;
|
|
39227
|
-
}
|
|
39228
|
-
if (status === "D") {
|
|
39229
|
-
baseFiles.add(filePath);
|
|
39230
|
-
continue;
|
|
39231
|
-
}
|
|
39232
|
-
if (status === "M" || status === "T") {
|
|
39233
|
-
baseFiles.add(filePath);
|
|
39234
|
-
headFiles.add(filePath);
|
|
39235
|
-
continue;
|
|
39236
|
-
}
|
|
39237
|
-
return null;
|
|
39238
|
-
}
|
|
39239
|
-
return {
|
|
39240
|
-
baseFiles: [...baseFiles],
|
|
39241
|
-
headFiles: [...headFiles],
|
|
39242
|
-
untrackedFiles: []
|
|
39243
|
-
};
|
|
39244
|
-
};
|
|
39245
39071
|
const UNTRACKED_FILE_LAST_LINE = Number.MAX_SAFE_INTEGER;
|
|
39246
39072
|
/**
|
|
39247
39073
|
* `Git` wraps every `git`-via-subprocess call react-doctor makes
|
|
@@ -39444,45 +39270,6 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
39444
39270
|
githubViewerPermission,
|
|
39445
39271
|
branchExists,
|
|
39446
39272
|
mergeBase,
|
|
39447
|
-
baselineDiffPlan: (input) => {
|
|
39448
|
-
if (!isSafeGitRevision(input.ref)) return succeed$2(null);
|
|
39449
|
-
return gen(function* () {
|
|
39450
|
-
const unmerged = yield* runGit(input.directory, [
|
|
39451
|
-
"diff",
|
|
39452
|
-
"--no-ext-diff",
|
|
39453
|
-
"-z",
|
|
39454
|
-
"--name-only",
|
|
39455
|
-
"--diff-filter=U",
|
|
39456
|
-
"--relative"
|
|
39457
|
-
]);
|
|
39458
|
-
if (unmerged.status !== 0 || unmerged.stdout.length > 0) return null;
|
|
39459
|
-
const result = yield* runGit(input.directory, [
|
|
39460
|
-
"diff",
|
|
39461
|
-
"--no-ext-diff",
|
|
39462
|
-
"--no-textconv",
|
|
39463
|
-
"--no-renames",
|
|
39464
|
-
"-z",
|
|
39465
|
-
"--name-status",
|
|
39466
|
-
"--relative",
|
|
39467
|
-
input.ref
|
|
39468
|
-
]);
|
|
39469
|
-
if (result.status !== 0) return null;
|
|
39470
|
-
const plan = parseBaselineDiffPlan(result.stdout);
|
|
39471
|
-
if (plan === null) return null;
|
|
39472
|
-
const untracked = yield* runGit(input.directory, [
|
|
39473
|
-
"ls-files",
|
|
39474
|
-
"--others",
|
|
39475
|
-
"--exclude-standard",
|
|
39476
|
-
"-z"
|
|
39477
|
-
]);
|
|
39478
|
-
if (untracked.status !== 0) return null;
|
|
39479
|
-
return {
|
|
39480
|
-
baseFiles: plan.baseFiles,
|
|
39481
|
-
headFiles: plan.headFiles,
|
|
39482
|
-
untrackedFiles: splitNullSeparated(untracked.stdout)
|
|
39483
|
-
};
|
|
39484
|
-
}).pipe(catch_$1(() => succeed$2(null)), withSpan("Git.baselineDiffPlan"));
|
|
39485
|
-
},
|
|
39486
39273
|
diffSelection: ({ directory, explicitBaseBranch, includeUntracked = false }) => gen(function* () {
|
|
39487
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." }) }));
|
|
39488
39275
|
if (explicitBaseBranch !== void 0) {
|
|
@@ -39632,7 +39419,6 @@ var Git = class Git extends Service()("react-doctor/Git") {
|
|
|
39632
39419
|
githubViewerPermission: () => succeed$2(snapshot.githubViewerPermission ?? null),
|
|
39633
39420
|
branchExists: (_directory, branch) => succeed$2(snapshot.branchExists?.get(branch) ?? false),
|
|
39634
39421
|
mergeBase: ({ ref }) => succeed$2(snapshot.mergeBase?.get(ref) ?? null),
|
|
39635
|
-
baselineDiffPlan: () => succeed$2(snapshot.baselineDiffPlan ?? null),
|
|
39636
39422
|
diffSelection: () => succeed$2(snapshot.diffSelection ?? null),
|
|
39637
39423
|
stagedFilePaths: () => succeed$2(snapshot.stagedFiles ?? []),
|
|
39638
39424
|
showStagedContent: (_directory, relativePath) => succeed$2(snapshot.stagedContent?.get(relativePath) ?? null),
|
|
@@ -40970,17 +40756,12 @@ const REACT_ERROR_BOUNDARY_MESSAGE = "This try/catch cannot catch errors thrown
|
|
|
40970
40756
|
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
40971
40757
|
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
40972
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`.";
|
|
40973
|
-
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`.";
|
|
40974
40759
|
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
40975
40760
|
const buildReactCompilerMessage = (reasonSummary, action = REACT_COMPILER_ACTION) => {
|
|
40976
40761
|
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
40977
40762
|
if (!normalizedSummary) return `${REACT_COMPILER_IMPACT}. ${action}`;
|
|
40978
40763
|
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${action}`;
|
|
40979
40764
|
};
|
|
40980
|
-
const buildSetStateInEffectMessage = (reasonSummary) => {
|
|
40981
|
-
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
40982
|
-
return `This synchronous effect update causes an extra render${normalizedSummary ? `: ${normalizedSummary}` : ""}. ${SET_STATE_IN_EFFECT_ACTION}`;
|
|
40983
|
-
};
|
|
40984
40765
|
const PLUGIN_CATEGORY_MAP = {
|
|
40985
40766
|
react: "Bugs",
|
|
40986
40767
|
"react-hooks": "Bugs",
|
|
@@ -41038,10 +40819,6 @@ const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
|
41038
40819
|
message: REACT_ERROR_BOUNDARY_MESSAGE,
|
|
41039
40820
|
help: reasonDetail || help
|
|
41040
40821
|
};
|
|
41041
|
-
if (rule === "set-state-in-effect") return {
|
|
41042
|
-
message: buildSetStateInEffectMessage(reasonSummary.trim()),
|
|
41043
|
-
help: reasonDetail || help
|
|
41044
|
-
};
|
|
41045
40822
|
return {
|
|
41046
40823
|
message: buildReactCompilerMessage(reasonSummary.trim(), rule === "incompatible-library" ? REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION : REACT_COMPILER_ACTION),
|
|
41047
40824
|
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
@@ -43367,19 +43144,12 @@ const isPathInsideDirectory = (childAbsolutePath, parentAbsolutePath) => {
|
|
|
43367
43144
|
*/
|
|
43368
43145
|
const materializeSourceTree = (input) => gen(function* () {
|
|
43369
43146
|
const materializedFiles = [];
|
|
43370
|
-
const unmaterializedFiles = [];
|
|
43371
43147
|
const resolvedTempDirectory = path.resolve(input.tempDirectory);
|
|
43372
43148
|
for (const relativePath of input.files) {
|
|
43373
43149
|
const content = yield* input.readContent(relativePath).pipe(orElseSucceed(() => null));
|
|
43374
|
-
if (content === null)
|
|
43375
|
-
unmaterializedFiles.push(relativePath);
|
|
43376
|
-
continue;
|
|
43377
|
-
}
|
|
43150
|
+
if (content === null) continue;
|
|
43378
43151
|
const candidateTargetPath = path.resolve(resolvedTempDirectory, relativePath);
|
|
43379
|
-
if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory))
|
|
43380
|
-
unmaterializedFiles.push(relativePath);
|
|
43381
|
-
continue;
|
|
43382
|
-
}
|
|
43152
|
+
if (!isPathInsideDirectory(candidateTargetPath, resolvedTempDirectory)) continue;
|
|
43383
43153
|
yield* sync(() => {
|
|
43384
43154
|
fs.mkdirSync(path.dirname(candidateTargetPath), { recursive: true });
|
|
43385
43155
|
fs.writeFileSync(candidateTargetPath, content);
|
|
@@ -43396,7 +43166,6 @@ const materializeSourceTree = (input) => gen(function* () {
|
|
|
43396
43166
|
return {
|
|
43397
43167
|
tempDirectory: input.tempDirectory,
|
|
43398
43168
|
materializedFiles,
|
|
43399
|
-
unmaterializedFiles,
|
|
43400
43169
|
cleanup: () => {
|
|
43401
43170
|
try {
|
|
43402
43171
|
fs.rmSync(input.tempDirectory, {
|
|
@@ -45602,5 +45371,5 @@ const startLanguageServer = () => {
|
|
|
45602
45371
|
};
|
|
45603
45372
|
//#endregion
|
|
45604
45373
|
export { startLanguageServer };
|
|
45605
|
-
!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]="
|
|
45606
|
-
//# 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",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"vscode-languageserver-textdocument": "^1.0.12",
|
|
66
66
|
"vscode-uri": "^3.1.0",
|
|
67
67
|
"yaml": "^2.9.0",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
68
|
+
"deslop-js": "0.8.1",
|
|
69
|
+
"oxlint-plugin-react-doctor": "0.8.1-dev.7818922"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@types/babel__code-frame": "^7.27.0",
|