react-doctor 0.8.1-dev.cd9ca68 → 0.8.1-dev.d970055
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 +42 -289
- package/dist/index.d.ts +0 -27
- package/dist/index.js +38 -283
- package/dist/lsp.js +38 -283
- package/package.json +5 -5
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]="f645a3f8-ff1c-5f09-a174-8281db00eaa4")}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";
|
|
@@ -33375,10 +33375,10 @@ const FALLBACK_TSCONFIG_FILENAMES = ["tsconfig.app.json", "tsconfig.build.json"]
|
|
|
33375
33375
|
const FRAMEWORK_PACKAGES = {
|
|
33376
33376
|
next: "nextjs",
|
|
33377
33377
|
"@tanstack/react-start": "tanstack-start",
|
|
33378
|
-
"@remix-run/react": "remix",
|
|
33379
|
-
gatsby: "gatsby",
|
|
33380
33378
|
vite: "vite",
|
|
33381
33379
|
"react-scripts": "cra",
|
|
33380
|
+
"@remix-run/react": "remix",
|
|
33381
|
+
gatsby: "gatsby",
|
|
33382
33382
|
expo: "expo",
|
|
33383
33383
|
"react-native": "react-native"
|
|
33384
33384
|
};
|
|
@@ -33905,6 +33905,19 @@ const getPreactVersion = (packageJson) => {
|
|
|
33905
33905
|
...packageJson.devDependencies
|
|
33906
33906
|
}.preact ?? null;
|
|
33907
33907
|
};
|
|
33908
|
+
const TANSTACK_QUERY_PACKAGES = new Set([
|
|
33909
|
+
"@tanstack/react-query",
|
|
33910
|
+
"@tanstack/query-core",
|
|
33911
|
+
"react-query"
|
|
33912
|
+
]);
|
|
33913
|
+
const hasTanStackQuery = (packageJson) => {
|
|
33914
|
+
const allDependencies = {
|
|
33915
|
+
...packageJson.peerDependencies,
|
|
33916
|
+
...packageJson.dependencies,
|
|
33917
|
+
...packageJson.devDependencies
|
|
33918
|
+
};
|
|
33919
|
+
return Object.keys(allDependencies).some((packageName) => TANSTACK_QUERY_PACKAGES.has(packageName));
|
|
33920
|
+
};
|
|
33908
33921
|
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
33909
33922
|
if (version === null || !isCatalogReference(version)) return version;
|
|
33910
33923
|
const catalogName = extractCatalogName(version);
|
|
@@ -34107,60 +34120,7 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34107
34120
|
}
|
|
34108
34121
|
return packages;
|
|
34109
34122
|
};
|
|
34110
|
-
const getPreferredDependencyVersion = ({ packageJson, packageNames }) => {
|
|
34111
|
-
const allDependencies = {
|
|
34112
|
-
...packageJson.devDependencies,
|
|
34113
|
-
...packageJson.peerDependencies,
|
|
34114
|
-
...packageJson.dependencies
|
|
34115
|
-
};
|
|
34116
|
-
for (const packageName of packageNames) {
|
|
34117
|
-
const version = allDependencies[packageName];
|
|
34118
|
-
if (version !== void 0) return version;
|
|
34119
|
-
}
|
|
34120
|
-
return null;
|
|
34121
|
-
};
|
|
34122
|
-
const TANSTACK_REACT_QUERY_PACKAGES = ["@tanstack/react-query", "react-query"];
|
|
34123
|
-
const getTanStackQueryVersion = (packageJson) => {
|
|
34124
|
-
return getPreferredDependencyVersion({
|
|
34125
|
-
packageJson,
|
|
34126
|
-
packageNames: TANSTACK_REACT_QUERY_PACKAGES
|
|
34127
|
-
});
|
|
34128
|
-
};
|
|
34129
|
-
const STYLED_COMPONENTS_PACKAGES = ["styled-components"];
|
|
34130
|
-
const getStyledComponentsVersion = (packageJson) => {
|
|
34131
|
-
return getPreferredDependencyVersion({
|
|
34132
|
-
packageJson,
|
|
34133
|
-
packageNames: STYLED_COMPONENTS_PACKAGES
|
|
34134
|
-
});
|
|
34135
|
-
};
|
|
34136
|
-
const I18N_PACKAGES = [
|
|
34137
|
-
"i18next",
|
|
34138
|
-
"react-i18next",
|
|
34139
|
-
"next-i18next",
|
|
34140
|
-
"react-intl",
|
|
34141
|
-
"next-intl",
|
|
34142
|
-
"use-intl",
|
|
34143
|
-
"@formatjs/intl",
|
|
34144
|
-
"@lingui/core",
|
|
34145
|
-
"@lingui/react",
|
|
34146
|
-
"typesafe-i18n",
|
|
34147
|
-
"@tolgee/react",
|
|
34148
|
-
"react-intl-universal"
|
|
34149
|
-
];
|
|
34150
|
-
const hasI18nDependency = (packageJson) => {
|
|
34151
|
-
const allDependencies = {
|
|
34152
|
-
...packageJson.peerDependencies,
|
|
34153
|
-
...packageJson.dependencies,
|
|
34154
|
-
...packageJson.devDependencies,
|
|
34155
|
-
...packageJson.optionalDependencies
|
|
34156
|
-
};
|
|
34157
|
-
return I18N_PACKAGES.some((packageName) => allDependencies[packageName] !== void 0);
|
|
34158
|
-
};
|
|
34159
34123
|
const REANIMATED_DEPENDENCY_NAME = "react-native-reanimated";
|
|
34160
|
-
const MOBX_REACT_PACKAGE_NAME = "mobx-react";
|
|
34161
|
-
const MOBX_REACT_LITE_PACKAGE_NAME = "mobx-react-lite";
|
|
34162
|
-
const MOBX_STATE_TREE_PACKAGE_NAME = "mobx-state-tree";
|
|
34163
|
-
const MOBX_REACT_OBSERVER_PACKAGE_NAME = "mobx-react-observer";
|
|
34164
34124
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34165
34125
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34166
34126
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34179,26 +34139,7 @@ const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
|
34179
34139
|
if (nextMajor === null) return false;
|
|
34180
34140
|
return nextMajor < currentMajor;
|
|
34181
34141
|
};
|
|
34182
|
-
const
|
|
34183
|
-
if (currentFact.version === null) return true;
|
|
34184
|
-
if (nextFact.version === null) return false;
|
|
34185
|
-
const currentMajor = getLowestDependencyMajor(currentFact.version);
|
|
34186
|
-
const nextMajor = getLowestDependencyMajor(nextFact.version);
|
|
34187
|
-
if (currentMajor === null) return false;
|
|
34188
|
-
if (nextMajor === null) return true;
|
|
34189
|
-
if (currentMajor > latestSupportedMajor) return false;
|
|
34190
|
-
if (nextMajor > latestSupportedMajor) return true;
|
|
34191
|
-
return nextMajor < currentMajor;
|
|
34192
|
-
};
|
|
34193
|
-
const shouldReplaceStyledComponentsVersion = (currentVersion, nextVersion) => {
|
|
34194
|
-
if (!currentVersion) return true;
|
|
34195
|
-
const currentMajor = getLowestDependencyMajor(currentVersion);
|
|
34196
|
-
const nextMajor = getLowestDependencyMajor(nextVersion);
|
|
34197
|
-
if (currentMajor === null) return nextMajor !== null && nextMajor < 6;
|
|
34198
|
-
if (nextMajor === null) return currentMajor >= 6;
|
|
34199
|
-
return nextMajor < currentMajor;
|
|
34200
|
-
};
|
|
34201
|
-
const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, rootPackageJson) => {
|
|
34142
|
+
const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
34202
34143
|
if (facts.expo.version === null) {
|
|
34203
34144
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34204
34145
|
if (spec !== null) facts.expo = {
|
|
@@ -34220,74 +34161,13 @@ const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, roo
|
|
|
34220
34161
|
sourceDirectory: directory
|
|
34221
34162
|
};
|
|
34222
34163
|
}
|
|
34223
|
-
const mobxSpec = getDependencySpec(packageJson, "mobx");
|
|
34224
|
-
if (mobxSpec !== null) {
|
|
34225
|
-
const nextMobxFact = {
|
|
34226
|
-
version: resolveCatalogBackedDependencyVersion({
|
|
34227
|
-
rootDirectory: directory,
|
|
34228
|
-
rootPackageJson: packageJson,
|
|
34229
|
-
packageName: "mobx",
|
|
34230
|
-
version: mobxSpec
|
|
34231
|
-
}),
|
|
34232
|
-
sourceDirectory: directory
|
|
34233
|
-
};
|
|
34234
|
-
if (shouldReplaceSupportedDependencyFact(facts.mobx, nextMobxFact, 6)) facts.mobx = nextMobxFact;
|
|
34235
|
-
}
|
|
34236
|
-
facts.hasMobxReact = facts.hasMobxReact || getDependencySpec(packageJson, MOBX_REACT_PACKAGE_NAME) !== null;
|
|
34237
|
-
facts.hasMobxReactLite = facts.hasMobxReactLite || getDependencySpec(packageJson, MOBX_REACT_LITE_PACKAGE_NAME) !== null;
|
|
34238
|
-
facts.hasMobxStateTree = facts.hasMobxStateTree || getDependencySpec(packageJson, MOBX_STATE_TREE_PACKAGE_NAME) !== null;
|
|
34239
|
-
facts.hasMobxReactObserver = facts.hasMobxReactObserver || getDependencySpec(packageJson, MOBX_REACT_OBSERVER_PACKAGE_NAME) !== null;
|
|
34240
|
-
const zustandSpec = getDependencySpec(packageJson, "zustand");
|
|
34241
|
-
if (zustandSpec !== null) {
|
|
34242
|
-
const nextZustandFact = {
|
|
34243
|
-
version: resolveCatalogBackedDependencyVersion({
|
|
34244
|
-
rootDirectory: directory,
|
|
34245
|
-
rootPackageJson: packageJson,
|
|
34246
|
-
packageName: "zustand",
|
|
34247
|
-
version: zustandSpec
|
|
34248
|
-
}),
|
|
34249
|
-
sourceDirectory: directory
|
|
34250
|
-
};
|
|
34251
|
-
if (shouldReplaceSupportedDependencyFact(facts.zustand, nextZustandFact, 5)) facts.zustand = nextZustandFact;
|
|
34252
|
-
}
|
|
34253
34164
|
if (facts.reanimatedVersion === null) {
|
|
34254
34165
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34255
34166
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34256
34167
|
}
|
|
34257
|
-
if (facts.valtioVersion === null) {
|
|
34258
|
-
const spec = getDependencySpec(packageJson, "valtio");
|
|
34259
|
-
if (spec !== null) facts.valtioVersion = spec;
|
|
34260
|
-
}
|
|
34261
|
-
facts.tanstackQueryVersion ??= getTanStackQueryVersion(packageJson);
|
|
34262
|
-
const styledComponentsVersion = resolveCatalogBackedDependencyVersion({
|
|
34263
|
-
rootDirectory: directory,
|
|
34264
|
-
rootPackageJson: packageJson,
|
|
34265
|
-
packageName: "styled-components",
|
|
34266
|
-
version: getStyledComponentsVersion(packageJson)
|
|
34267
|
-
});
|
|
34268
|
-
if (styledComponentsVersion && shouldReplaceStyledComponentsVersion(facts.styledComponentsVersion, styledComponentsVersion)) facts.styledComponentsVersion = styledComponentsVersion;
|
|
34269
|
-
facts.hasI18nLibrary = facts.hasI18nLibrary || hasI18nDependency(packageJson);
|
|
34270
34168
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34271
34169
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34272
34170
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34273
|
-
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34274
|
-
if (remotionSpec !== null) {
|
|
34275
|
-
facts.hasRemotionDependency = true;
|
|
34276
|
-
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34277
|
-
rootDirectory,
|
|
34278
|
-
rootPackageJson,
|
|
34279
|
-
packageName: "remotion",
|
|
34280
|
-
version: remotionSpec
|
|
34281
|
-
});
|
|
34282
|
-
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34283
|
-
if (remotionMajorVersion === null) {
|
|
34284
|
-
facts.hasUnknownRemotionVersion = true;
|
|
34285
|
-
facts.remotionVersion = null;
|
|
34286
|
-
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34287
|
-
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34288
|
-
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34289
|
-
}
|
|
34290
|
-
}
|
|
34291
34171
|
};
|
|
34292
34172
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34293
34173
|
const facts = {
|
|
@@ -34307,31 +34187,12 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34307
34187
|
version: null,
|
|
34308
34188
|
sourceDirectory: null
|
|
34309
34189
|
},
|
|
34310
|
-
valtioVersion: null,
|
|
34311
|
-
mobx: {
|
|
34312
|
-
version: null,
|
|
34313
|
-
sourceDirectory: null
|
|
34314
|
-
},
|
|
34315
|
-
hasMobxReact: false,
|
|
34316
|
-
hasMobxReactLite: false,
|
|
34317
|
-
hasMobxStateTree: false,
|
|
34318
|
-
hasMobxReactObserver: false,
|
|
34319
|
-
zustand: {
|
|
34320
|
-
version: null,
|
|
34321
|
-
sourceDirectory: null
|
|
34322
|
-
},
|
|
34323
|
-
tanstackQueryVersion: null,
|
|
34324
|
-
styledComponentsVersion: null,
|
|
34325
|
-
hasI18nLibrary: false,
|
|
34326
34190
|
hasReactNativeAwarePackage: false,
|
|
34327
34191
|
hasReanimatedAwarePackage: false,
|
|
34328
34192
|
hasSsrDependency: false,
|
|
34329
|
-
hasRemotionDependency: false,
|
|
34330
|
-
hasUnknownRemotionVersion: false,
|
|
34331
|
-
remotionVersion: null,
|
|
34332
34193
|
reanimatedVersion: null
|
|
34333
34194
|
};
|
|
34334
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory
|
|
34195
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34335
34196
|
let isReactGroupSettled = !collectReactGroup;
|
|
34336
34197
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34337
34198
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
@@ -34340,7 +34201,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34340
34201
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34341
34202
|
visitedDirectories.add(workspaceDirectory);
|
|
34342
34203
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34343
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory
|
|
34204
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34344
34205
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34345
34206
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34346
34207
|
if (isReactGroupSettled) continue;
|
|
@@ -34564,27 +34425,11 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34564
34425
|
tailwindVersion: null,
|
|
34565
34426
|
zodVersion: null,
|
|
34566
34427
|
zodMajorVersion: null,
|
|
34567
|
-
mobxVersion: null,
|
|
34568
|
-
mobxMajorVersion: null,
|
|
34569
|
-
hasMobxReact: false,
|
|
34570
|
-
hasMobxReactLite: false,
|
|
34571
|
-
hasMobxStateTree: false,
|
|
34572
|
-
hasMobxReactObserver: false,
|
|
34573
|
-
zustandVersion: null,
|
|
34574
|
-
zustandMajorVersion: null,
|
|
34575
34428
|
framework: "unknown",
|
|
34576
34429
|
hasTypeScript: hasOwnTsConfig,
|
|
34577
34430
|
hasReactCompiler: false,
|
|
34578
34431
|
hasReactCompilerLintPlugin: false,
|
|
34579
34432
|
hasTanStackQuery: false,
|
|
34580
|
-
valtioVersion: null,
|
|
34581
|
-
valtioMajorVersion: null,
|
|
34582
|
-
hasRemotion: false,
|
|
34583
|
-
remotionVersion: null,
|
|
34584
|
-
remotionMajorVersion: null,
|
|
34585
|
-
hasI18nLibrary: false,
|
|
34586
|
-
tanstackQueryVersion: null,
|
|
34587
|
-
styledComponentsVersion: null,
|
|
34588
34433
|
hasSsrDependency: false,
|
|
34589
34434
|
preactVersion: null,
|
|
34590
34435
|
preactMajorVersion: null,
|
|
@@ -34683,12 +34528,6 @@ const discoverProject = (directory) => {
|
|
|
34683
34528
|
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
34684
34529
|
version: workspaceFacts.shopifyFlashList.version
|
|
34685
34530
|
}) : null;
|
|
34686
|
-
const zustandVersion = resolveCatalogBackedDependencyVersion({
|
|
34687
|
-
rootDirectory: directory,
|
|
34688
|
-
rootPackageJson: packageJson,
|
|
34689
|
-
packageName: "zustand",
|
|
34690
|
-
version: workspaceFacts.zustand.version
|
|
34691
|
-
});
|
|
34692
34531
|
const hasReanimated = hasReactNativeWorkspace && workspaceFacts.hasReanimatedAwarePackage;
|
|
34693
34532
|
const reanimatedVersion = hasReanimated ? workspaceFacts.reanimatedVersion : null;
|
|
34694
34533
|
const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
|
|
@@ -34697,21 +34536,7 @@ const discoverProject = (directory) => {
|
|
|
34697
34536
|
packageName: "next",
|
|
34698
34537
|
version: workspaceFacts.next.version
|
|
34699
34538
|
}) : null;
|
|
34700
|
-
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
34701
|
-
rootDirectory: directory,
|
|
34702
|
-
rootPackageJson: packageJson,
|
|
34703
|
-
packageName: "valtio",
|
|
34704
|
-
version: workspaceFacts.valtioVersion
|
|
34705
|
-
});
|
|
34706
|
-
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
34707
|
-
rootDirectory: directory,
|
|
34708
|
-
rootPackageJson: packageJson,
|
|
34709
|
-
packageName: "mobx",
|
|
34710
|
-
version: workspaceFacts.mobx.version
|
|
34711
|
-
});
|
|
34712
34539
|
const preactVersion = getPreactVersion(packageJson);
|
|
34713
|
-
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34714
|
-
const tanstackQueryVersion = getTanStackQueryVersion(packageJson) ?? workspaceFacts.tanstackQueryVersion;
|
|
34715
34540
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34716
34541
|
const projectInfo = {
|
|
34717
34542
|
rootDirectory: directory,
|
|
@@ -34721,27 +34546,11 @@ const discoverProject = (directory) => {
|
|
|
34721
34546
|
tailwindVersion,
|
|
34722
34547
|
zodVersion,
|
|
34723
34548
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
34724
|
-
mobxVersion,
|
|
34725
|
-
mobxMajorVersion: mobxVersion === null ? null : getLowestDependencyMajor(mobxVersion),
|
|
34726
|
-
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
34727
|
-
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
34728
|
-
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
34729
|
-
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
34730
|
-
zustandVersion,
|
|
34731
|
-
zustandMajorVersion: zustandVersion === null ? null : getLowestDependencyMajor(zustandVersion),
|
|
34732
34549
|
framework,
|
|
34733
34550
|
hasTypeScript,
|
|
34734
34551
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34735
34552
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
34736
|
-
hasTanStackQuery:
|
|
34737
|
-
hasI18nLibrary: workspaceFacts.hasI18nLibrary,
|
|
34738
|
-
tanstackQueryVersion,
|
|
34739
|
-
styledComponentsVersion: workspaceFacts.styledComponentsVersion,
|
|
34740
|
-
valtioVersion,
|
|
34741
|
-
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
34742
|
-
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
34743
|
-
remotionVersion,
|
|
34744
|
-
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
34553
|
+
hasTanStackQuery: hasTanStackQuery(packageJson),
|
|
34745
34554
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34746
34555
|
preactVersion,
|
|
34747
34556
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
@@ -34975,6 +34784,7 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
34975
34784
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
34976
34785
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
34977
34786
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34787
|
+
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
34978
34788
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
34979
34789
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
34980
34790
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37261,25 +37071,9 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37261
37071
|
".babelrc.json"
|
|
37262
37072
|
];
|
|
37263
37073
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37264
|
-
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37265
|
-
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37266
|
-
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37267
|
-
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37268
37074
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37269
37075
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37270
|
-
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37271
|
-
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37272
|
-
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37273
|
-
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37274
|
-
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37275
|
-
if (normalizedVersionRange === null) return false;
|
|
37276
|
-
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37277
|
-
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37278
|
-
};
|
|
37279
|
-
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37280
37076
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37281
|
-
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37282
|
-
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37283
37077
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37284
37078
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37285
37079
|
if (!isFile(filePath)) continue;
|
|
@@ -37289,7 +37083,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37289
37083
|
} catch {
|
|
37290
37084
|
continue;
|
|
37291
37085
|
}
|
|
37292
|
-
if (
|
|
37086
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
37293
37087
|
filePath: fileName,
|
|
37294
37088
|
rule: "rn-no-metro-babel-preset",
|
|
37295
37089
|
severity: "error",
|
|
@@ -37312,6 +37106,12 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37312
37106
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37313
37107
|
};
|
|
37314
37108
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37109
|
+
const DEPENDENCY_SECTIONS = [
|
|
37110
|
+
"dependencies",
|
|
37111
|
+
"devDependencies",
|
|
37112
|
+
"peerDependencies",
|
|
37113
|
+
"optionalDependencies"
|
|
37114
|
+
];
|
|
37315
37115
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37316
37116
|
"19.0": {
|
|
37317
37117
|
rceFixedVersion: "19.0.1",
|
|
@@ -37358,13 +37158,20 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37358
37158
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37359
37159
|
return [...directories];
|
|
37360
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
|
+
};
|
|
37361
37168
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37362
37169
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37363
37170
|
if (isFile(manifestPath)) {
|
|
37364
37171
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37365
37172
|
if (installedVersion !== null) return installedVersion;
|
|
37366
37173
|
}
|
|
37367
|
-
const candidateSpecs = [
|
|
37174
|
+
const candidateSpecs = [readDeclaredSpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37368
37175
|
for (const spec of candidateSpecs) {
|
|
37369
37176
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37370
37177
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -38032,7 +37839,6 @@ const buildCapabilities = (project) => {
|
|
|
38032
37839
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
38033
37840
|
if (project.isStaticExport) capabilities.add("nextjs:static-export");
|
|
38034
37841
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
38035
|
-
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 16) capabilities.add("nextjs:16");
|
|
38036
37842
|
addMajorLadder(capabilities, "react", project.reactMajorVersion, 17, 30);
|
|
38037
37843
|
if (project.reactMajorVersion !== null && project.reactMajorVersion >= 19 && isMajorMinorAtLeast(parseReactMajorMinor(project.reactVersion), {
|
|
38038
37844
|
major: 19,
|
|
@@ -38045,30 +37851,9 @@ const buildCapabilities = (project) => {
|
|
|
38045
37851
|
})) capabilities.add("tailwind:3.4");
|
|
38046
37852
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
38047
37853
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
38048
|
-
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
38049
|
-
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
38050
|
-
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
38051
|
-
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
38052
|
-
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
38053
|
-
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
38054
|
-
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addMajorLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
38055
|
-
if (project.zustandVersion !== void 0 && project.zustandVersion !== null) capabilities.add("zustand");
|
|
38056
|
-
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addMajorLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
38057
37854
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
38058
37855
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
38059
|
-
if (
|
|
38060
|
-
if (project.styledComponentsVersion) {
|
|
38061
|
-
capabilities.add("styled-components");
|
|
38062
|
-
const styledComponentsMajor = getLowestDependencyMajor(project.styledComponentsVersion);
|
|
38063
|
-
if (styledComponentsMajor !== null && styledComponentsMajor >= 6) capabilities.add("styled-components:6");
|
|
38064
|
-
}
|
|
38065
|
-
if (project.hasI18nLibrary) capabilities.add("i18n");
|
|
38066
|
-
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
38067
|
-
addMajorLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
38068
|
-
if (project.hasRemotion) {
|
|
38069
|
-
capabilities.add("remotion");
|
|
38070
|
-
addMajorLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
38071
|
-
}
|
|
37856
|
+
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
38072
37857
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
38073
37858
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
38074
37859
|
addMajorLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
@@ -40337,19 +40122,6 @@ const createSidecarLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
40337
40122
|
}
|
|
40338
40123
|
};
|
|
40339
40124
|
};
|
|
40340
|
-
const fingerprintCacheByFilePath = /* @__PURE__ */ new Map();
|
|
40341
|
-
const fingerprintFileContents = (filePath, fingerprintLength) => {
|
|
40342
|
-
const fileStats = NFS.statSync(filePath, { bigint: true });
|
|
40343
|
-
const cachedFingerprint = fingerprintCacheByFilePath.get(filePath);
|
|
40344
|
-
if (cachedFingerprint?.modifiedTimeNanoseconds === fileStats.mtimeNs && cachedFingerprint.sizeBytes === fileStats.size) return cachedFingerprint.fingerprint;
|
|
40345
|
-
const fingerprint = crypto.createHash("sha256").update(NFS.readFileSync(filePath)).digest("hex").slice(0, fingerprintLength);
|
|
40346
|
-
fingerprintCacheByFilePath.set(filePath, {
|
|
40347
|
-
fingerprint,
|
|
40348
|
-
modifiedTimeNanoseconds: fileStats.mtimeNs,
|
|
40349
|
-
sizeBytes: fileStats.size
|
|
40350
|
-
});
|
|
40351
|
-
return fingerprint;
|
|
40352
|
-
};
|
|
40353
40125
|
const bundledRequire = createRequire(import.meta.url);
|
|
40354
40126
|
const childNodeVersionByBinaryPath = /* @__PURE__ */ new Map();
|
|
40355
40127
|
const resolveChildNodeVersion = (nodeBinaryPath) => {
|
|
@@ -40373,13 +40145,6 @@ const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
|
40373
40145
|
"oxlint-plugin-react-doctor/package.json",
|
|
40374
40146
|
"eslint-plugin-react-hooks/package.json"
|
|
40375
40147
|
];
|
|
40376
|
-
const resolvePluginFingerprint = () => {
|
|
40377
|
-
try {
|
|
40378
|
-
return fingerprintFileContents(bundledRequire.resolve("oxlint-plugin-react-doctor"), 16);
|
|
40379
|
-
} catch {
|
|
40380
|
-
return "unresolved";
|
|
40381
|
-
}
|
|
40382
|
-
};
|
|
40383
40148
|
const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
40384
40149
|
const versions = [`node=${resolveChildNodeVersion(nodeBinaryPath)}`];
|
|
40385
40150
|
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
@@ -40389,7 +40154,6 @@ const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
|
40389
40154
|
} catch {
|
|
40390
40155
|
versions.push(`${specifier}=missing`);
|
|
40391
40156
|
}
|
|
40392
|
-
versions.push(`oxlint-plugin-react-doctor#fingerprint=${resolvePluginFingerprint()}`);
|
|
40393
40157
|
return versions;
|
|
40394
40158
|
};
|
|
40395
40159
|
const esmRequire = createRequire(import.meta.url);
|
|
@@ -41083,17 +40847,12 @@ const REACT_ERROR_BOUNDARY_MESSAGE = "This try/catch cannot catch errors thrown
|
|
|
41083
40847
|
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
41084
40848
|
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
41085
40849
|
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`.";
|
|
41086
|
-
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`.";
|
|
41087
40850
|
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
41088
40851
|
const buildReactCompilerMessage = (reasonSummary, action = REACT_COMPILER_ACTION) => {
|
|
41089
40852
|
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
41090
40853
|
if (!normalizedSummary) return `${REACT_COMPILER_IMPACT}. ${action}`;
|
|
41091
40854
|
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${action}`;
|
|
41092
40855
|
};
|
|
41093
|
-
const buildSetStateInEffectMessage = (reasonSummary) => {
|
|
41094
|
-
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
41095
|
-
return `This synchronous effect update causes an extra render${normalizedSummary ? `: ${normalizedSummary}` : ""}. ${SET_STATE_IN_EFFECT_ACTION}`;
|
|
41096
|
-
};
|
|
41097
40856
|
const PLUGIN_CATEGORY_MAP = {
|
|
41098
40857
|
react: "Bugs",
|
|
41099
40858
|
"react-hooks": "Bugs",
|
|
@@ -41151,10 +40910,6 @@ const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
|
41151
40910
|
message: REACT_ERROR_BOUNDARY_MESSAGE,
|
|
41152
40911
|
help: reasonDetail || help
|
|
41153
40912
|
};
|
|
41154
|
-
if (rule === "set-state-in-effect") return {
|
|
41155
|
-
message: buildSetStateInEffectMessage(reasonSummary.trim()),
|
|
41156
|
-
help: reasonDetail || help
|
|
41157
|
-
};
|
|
41158
40913
|
return {
|
|
41159
40914
|
message: buildReactCompilerMessage(reasonSummary.trim(), rule === "incompatible-library" ? REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION : REACT_COMPILER_ACTION),
|
|
41160
40915
|
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
@@ -44073,4 +43828,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
44073
43828
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
44074
43829
|
|
|
44075
43830
|
//# sourceMappingURL=index.js.map
|
|
44076
|
-
//# debugId=
|
|
43831
|
+
//# debugId=f645a3f8-ff1c-5f09-a174-8281db00eaa4
|