react-doctor 0.8.1-dev.a667b45 → 0.8.1-dev.af33723
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/README.md +14 -4
- package/dist/cli.js +549 -141
- package/dist/index.d.ts +29 -0
- package/dist/index.js +458 -97
- package/dist/lsp.js +458 -97
- package/dist/skills/react-doctor/SKILL.md +5 -0
- package/package.json +2 -2
package/dist/lsp.js
CHANGED
|
@@ -32883,44 +32883,6 @@ var AmbiguousProjectError = class extends Error {
|
|
|
32883
32883
|
}
|
|
32884
32884
|
};
|
|
32885
32885
|
const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
|
|
32886
|
-
const isErrnoException = (error) => error instanceof Error && "code" in error;
|
|
32887
|
-
const IGNORABLE_READDIR_ERROR_CODES = new Set([
|
|
32888
|
-
"EACCES",
|
|
32889
|
-
"EPERM",
|
|
32890
|
-
"ENOENT",
|
|
32891
|
-
"ENOTDIR",
|
|
32892
|
-
"EINVAL",
|
|
32893
|
-
"ELOOP",
|
|
32894
|
-
"ENAMETOOLONG"
|
|
32895
|
-
]);
|
|
32896
|
-
const isIgnorableReaddirError = (error) => isErrnoException(error) && typeof error.code === "string" && IGNORABLE_READDIR_ERROR_CODES.has(error.code);
|
|
32897
|
-
const readDirectoryEntries = (directoryPath) => {
|
|
32898
|
-
try {
|
|
32899
|
-
return NFS.readdirSync(directoryPath, { withFileTypes: true });
|
|
32900
|
-
} catch (error) {
|
|
32901
|
-
if (isIgnorableReaddirError(error)) return [];
|
|
32902
|
-
throw error;
|
|
32903
|
-
}
|
|
32904
|
-
};
|
|
32905
|
-
const isFile = (filePath) => {
|
|
32906
|
-
try {
|
|
32907
|
-
return NFS.statSync(filePath).isFile();
|
|
32908
|
-
} catch {
|
|
32909
|
-
return false;
|
|
32910
|
-
}
|
|
32911
|
-
};
|
|
32912
|
-
const isDirectory = (directoryPath) => {
|
|
32913
|
-
try {
|
|
32914
|
-
return NFS.statSync(directoryPath).isDirectory();
|
|
32915
|
-
} catch {
|
|
32916
|
-
return false;
|
|
32917
|
-
}
|
|
32918
|
-
};
|
|
32919
|
-
const isPlainObject = (value) => {
|
|
32920
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
32921
|
-
const prototype = Object.getPrototypeOf(value);
|
|
32922
|
-
return prototype === null || prototype === Object.prototype;
|
|
32923
|
-
};
|
|
32924
32886
|
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
|
|
32925
32887
|
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
32926
32888
|
const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
|
|
@@ -33102,6 +33064,44 @@ const SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS = 9e4;
|
|
|
33102
33064
|
const SUPPLY_CHAIN_CACHE_TTL_MS = 864e5;
|
|
33103
33065
|
const SUPPLY_CHAIN_CACHE_SUBDIR = "supply-chain";
|
|
33104
33066
|
const SUPPLY_CHAIN_IGNORED_PACKAGES = new Set(["next"]);
|
|
33067
|
+
const isErrnoException = (error) => error instanceof Error && "code" in error;
|
|
33068
|
+
const IGNORABLE_READDIR_ERROR_CODES = new Set([
|
|
33069
|
+
"EACCES",
|
|
33070
|
+
"EPERM",
|
|
33071
|
+
"ENOENT",
|
|
33072
|
+
"ENOTDIR",
|
|
33073
|
+
"EINVAL",
|
|
33074
|
+
"ELOOP",
|
|
33075
|
+
"ENAMETOOLONG"
|
|
33076
|
+
]);
|
|
33077
|
+
const isIgnorableReaddirError = (error) => isErrnoException(error) && typeof error.code === "string" && IGNORABLE_READDIR_ERROR_CODES.has(error.code);
|
|
33078
|
+
const readDirectoryEntries = (directoryPath) => {
|
|
33079
|
+
try {
|
|
33080
|
+
return NFS.readdirSync(directoryPath, { withFileTypes: true });
|
|
33081
|
+
} catch (error) {
|
|
33082
|
+
if (isIgnorableReaddirError(error)) return [];
|
|
33083
|
+
throw error;
|
|
33084
|
+
}
|
|
33085
|
+
};
|
|
33086
|
+
const isFile = (filePath) => {
|
|
33087
|
+
try {
|
|
33088
|
+
return NFS.statSync(filePath).isFile();
|
|
33089
|
+
} catch {
|
|
33090
|
+
return false;
|
|
33091
|
+
}
|
|
33092
|
+
};
|
|
33093
|
+
const isDirectory = (directoryPath) => {
|
|
33094
|
+
try {
|
|
33095
|
+
return NFS.statSync(directoryPath).isDirectory();
|
|
33096
|
+
} catch {
|
|
33097
|
+
return false;
|
|
33098
|
+
}
|
|
33099
|
+
};
|
|
33100
|
+
const isPlainObject = (value) => {
|
|
33101
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
33102
|
+
const prototype = Object.getPrototypeOf(value);
|
|
33103
|
+
return prototype === null || prototype === Object.prototype;
|
|
33104
|
+
};
|
|
33105
33105
|
const lastSourceMappingUrl = (fileContent) => {
|
|
33106
33106
|
const lastReference = [...fileContent.matchAll(/\/\/# sourceMappingURL=(\S+)/g)].at(-1);
|
|
33107
33107
|
return lastReference ? lastReference[1] : null;
|
|
@@ -33427,10 +33427,10 @@ const FALLBACK_TSCONFIG_FILENAMES = ["tsconfig.app.json", "tsconfig.build.json"]
|
|
|
33427
33427
|
const FRAMEWORK_PACKAGES = {
|
|
33428
33428
|
next: "nextjs",
|
|
33429
33429
|
"@tanstack/react-start": "tanstack-start",
|
|
33430
|
-
vite: "vite",
|
|
33431
|
-
"react-scripts": "cra",
|
|
33432
33430
|
"@remix-run/react": "remix",
|
|
33433
33431
|
gatsby: "gatsby",
|
|
33432
|
+
vite: "vite",
|
|
33433
|
+
"react-scripts": "cra",
|
|
33434
33434
|
expo: "expo",
|
|
33435
33435
|
"react-native": "react-native"
|
|
33436
33436
|
};
|
|
@@ -33454,11 +33454,17 @@ const NEXT_CONFIG_FILENAMES = [
|
|
|
33454
33454
|
];
|
|
33455
33455
|
const BABEL_CONFIG_FILENAMES = [
|
|
33456
33456
|
".babelrc",
|
|
33457
|
+
".babelrc.js",
|
|
33457
33458
|
".babelrc.json",
|
|
33459
|
+
".babelrc.cjs",
|
|
33460
|
+
".babelrc.mjs",
|
|
33461
|
+
".babelrc.cts",
|
|
33458
33462
|
"babel.config.js",
|
|
33459
33463
|
"babel.config.json",
|
|
33460
33464
|
"babel.config.cjs",
|
|
33461
|
-
"babel.config.mjs"
|
|
33465
|
+
"babel.config.mjs",
|
|
33466
|
+
"babel.config.ts",
|
|
33467
|
+
"babel.config.cts"
|
|
33462
33468
|
];
|
|
33463
33469
|
const VITE_CONFIG_FILENAMES = [
|
|
33464
33470
|
"vite.config.js",
|
|
@@ -33470,12 +33476,28 @@ const VITE_CONFIG_FILENAMES = [
|
|
|
33470
33476
|
"vitest.config.ts",
|
|
33471
33477
|
"vitest.config.js"
|
|
33472
33478
|
];
|
|
33479
|
+
const RSBUILD_CONFIG_FILENAMES = [
|
|
33480
|
+
"rsbuild.config.ts",
|
|
33481
|
+
"rsbuild.config.js",
|
|
33482
|
+
"rsbuild.config.mts",
|
|
33483
|
+
"rsbuild.config.mjs",
|
|
33484
|
+
"rsbuild.config.cts",
|
|
33485
|
+
"rsbuild.config.cjs"
|
|
33486
|
+
];
|
|
33487
|
+
const RSPACK_CONFIG_FILENAMES = [
|
|
33488
|
+
"rspack.config.ts",
|
|
33489
|
+
"rspack.config.js",
|
|
33490
|
+
"rspack.config.mts",
|
|
33491
|
+
"rspack.config.mjs",
|
|
33492
|
+
"rspack.config.cts",
|
|
33493
|
+
"rspack.config.cjs"
|
|
33494
|
+
];
|
|
33473
33495
|
const EXPO_APP_CONFIG_FILENAMES = [
|
|
33474
33496
|
"app.json",
|
|
33475
33497
|
"app.config.js",
|
|
33476
33498
|
"app.config.ts"
|
|
33477
33499
|
];
|
|
33478
|
-
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|["']react-compiler["']/;
|
|
33500
|
+
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|reactCompilerPreset\s*\(|["']react-compiler["']/;
|
|
33479
33501
|
const REACT_COMPILER_ENABLED_FLAG_PATTERN = /["']?reactCompiler["']?\s*:\s*(?:true\b|\{)/;
|
|
33480
33502
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
33481
33503
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
@@ -33510,6 +33532,8 @@ const detectReactCompiler = (directory, packageJson) => {
|
|
|
33510
33532
|
if (hasCompilerInConfigFiles(directory, NEXT_CONFIG_FILENAMES)) return true;
|
|
33511
33533
|
if (hasCompilerInConfigFiles(directory, BABEL_CONFIG_FILENAMES)) return true;
|
|
33512
33534
|
if (hasCompilerInConfigFiles(directory, VITE_CONFIG_FILENAMES)) return true;
|
|
33535
|
+
if (hasCompilerInConfigFiles(directory, RSBUILD_CONFIG_FILENAMES)) return true;
|
|
33536
|
+
if (hasCompilerInConfigFiles(directory, RSPACK_CONFIG_FILENAMES)) return true;
|
|
33513
33537
|
if (hasCompilerInConfigFiles(directory, EXPO_APP_CONFIG_FILENAMES)) return true;
|
|
33514
33538
|
return hasCompilerPackageInAncestors(directory, REACT_COMPILER_TRANSFORM_PACKAGES);
|
|
33515
33539
|
};
|
|
@@ -33651,6 +33675,16 @@ const getLowestDependencyMajor = (version) => {
|
|
|
33651
33675
|
}
|
|
33652
33676
|
return lowestMajor;
|
|
33653
33677
|
};
|
|
33678
|
+
const getDependencyMajorWithinSupportedRange = (version, latestSupportedMajor) => {
|
|
33679
|
+
const normalizedVersion = normalizeDependencyVersion(version);
|
|
33680
|
+
if (normalizedVersion === null) return null;
|
|
33681
|
+
const validRange = import_semver.validRange(normalizedVersion);
|
|
33682
|
+
if (validRange === null) return null;
|
|
33683
|
+
const minimumVersion = import_semver.minVersion(validRange);
|
|
33684
|
+
if (minimumVersion === null || minimumVersion.major > latestSupportedMajor) return null;
|
|
33685
|
+
if (import_semver.intersects(validRange, `>=${latestSupportedMajor + 1}.0.0`)) return null;
|
|
33686
|
+
return minimumVersion.major;
|
|
33687
|
+
};
|
|
33654
33688
|
const isConcreteDependencyVersion = (version) => {
|
|
33655
33689
|
const normalizedVersion = normalizeDependencyVersion(version);
|
|
33656
33690
|
return normalizedVersion !== null && /\d/.test(normalizedVersion);
|
|
@@ -33694,9 +33728,9 @@ const parseReactMajorMinor = (reactVersion) => {
|
|
|
33694
33728
|
};
|
|
33695
33729
|
};
|
|
33696
33730
|
const parseLowerBoundVersion = (versionSpec) => import_semver.validRange(versionSpec) !== null ? import_semver.minVersion(versionSpec) : import_semver.coerce(versionSpec);
|
|
33697
|
-
const
|
|
33698
|
-
if (typeof
|
|
33699
|
-
const trimmed =
|
|
33731
|
+
const parseDependencyMajorMinor = (dependencyVersion) => {
|
|
33732
|
+
if (typeof dependencyVersion !== "string") return null;
|
|
33733
|
+
const trimmed = dependencyVersion.trim();
|
|
33700
33734
|
if (trimmed.length === 0) return null;
|
|
33701
33735
|
const lowerBound = parseLowerBoundVersion(trimmed);
|
|
33702
33736
|
if (lowerBound === null || lowerBound.major <= 0) return null;
|
|
@@ -33705,6 +33739,7 @@ const parseTailwindMajorMinor = (tailwindVersion) => {
|
|
|
33705
33739
|
minor: lowerBound.minor
|
|
33706
33740
|
};
|
|
33707
33741
|
};
|
|
33742
|
+
const parseTailwindMajorMinor = (tailwindVersion) => parseDependencyMajorMinor(tailwindVersion);
|
|
33708
33743
|
const hasUpperBoundOnlyPeerRange = (range) => {
|
|
33709
33744
|
if (typeof range !== "string") return false;
|
|
33710
33745
|
const normalizedRange = normalizeDependencyVersion(range);
|
|
@@ -33957,19 +33992,6 @@ const getPreactVersion = (packageJson) => {
|
|
|
33957
33992
|
...packageJson.devDependencies
|
|
33958
33993
|
}.preact ?? null;
|
|
33959
33994
|
};
|
|
33960
|
-
const TANSTACK_QUERY_PACKAGES = new Set([
|
|
33961
|
-
"@tanstack/react-query",
|
|
33962
|
-
"@tanstack/query-core",
|
|
33963
|
-
"react-query"
|
|
33964
|
-
]);
|
|
33965
|
-
const hasTanStackQuery = (packageJson) => {
|
|
33966
|
-
const allDependencies = {
|
|
33967
|
-
...packageJson.peerDependencies,
|
|
33968
|
-
...packageJson.dependencies,
|
|
33969
|
-
...packageJson.devDependencies
|
|
33970
|
-
};
|
|
33971
|
-
return Object.keys(allDependencies).some((packageName) => TANSTACK_QUERY_PACKAGES.has(packageName));
|
|
33972
|
-
};
|
|
33973
33995
|
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
33974
33996
|
if (version === null || !isCatalogReference(version)) return version;
|
|
33975
33997
|
const catalogName = extractCatalogName(version);
|
|
@@ -34172,7 +34194,60 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34172
34194
|
}
|
|
34173
34195
|
return packages;
|
|
34174
34196
|
};
|
|
34197
|
+
const getPreferredDependencyVersion = ({ packageJson, packageNames }) => {
|
|
34198
|
+
const allDependencies = {
|
|
34199
|
+
...packageJson.devDependencies,
|
|
34200
|
+
...packageJson.peerDependencies,
|
|
34201
|
+
...packageJson.dependencies
|
|
34202
|
+
};
|
|
34203
|
+
for (const packageName of packageNames) {
|
|
34204
|
+
const version = allDependencies[packageName];
|
|
34205
|
+
if (version !== void 0) return version;
|
|
34206
|
+
}
|
|
34207
|
+
return null;
|
|
34208
|
+
};
|
|
34209
|
+
const TANSTACK_REACT_QUERY_PACKAGES = ["@tanstack/react-query", "react-query"];
|
|
34210
|
+
const getTanStackQueryVersion = (packageJson) => {
|
|
34211
|
+
return getPreferredDependencyVersion({
|
|
34212
|
+
packageJson,
|
|
34213
|
+
packageNames: TANSTACK_REACT_QUERY_PACKAGES
|
|
34214
|
+
});
|
|
34215
|
+
};
|
|
34216
|
+
const STYLED_COMPONENTS_PACKAGES = ["styled-components"];
|
|
34217
|
+
const getStyledComponentsVersion = (packageJson) => {
|
|
34218
|
+
return getPreferredDependencyVersion({
|
|
34219
|
+
packageJson,
|
|
34220
|
+
packageNames: STYLED_COMPONENTS_PACKAGES
|
|
34221
|
+
});
|
|
34222
|
+
};
|
|
34223
|
+
const I18N_PACKAGES = [
|
|
34224
|
+
"i18next",
|
|
34225
|
+
"react-i18next",
|
|
34226
|
+
"next-i18next",
|
|
34227
|
+
"react-intl",
|
|
34228
|
+
"next-intl",
|
|
34229
|
+
"use-intl",
|
|
34230
|
+
"@formatjs/intl",
|
|
34231
|
+
"@lingui/core",
|
|
34232
|
+
"@lingui/react",
|
|
34233
|
+
"typesafe-i18n",
|
|
34234
|
+
"@tolgee/react",
|
|
34235
|
+
"react-intl-universal"
|
|
34236
|
+
];
|
|
34237
|
+
const hasI18nDependency = (packageJson) => {
|
|
34238
|
+
const allDependencies = {
|
|
34239
|
+
...packageJson.peerDependencies,
|
|
34240
|
+
...packageJson.dependencies,
|
|
34241
|
+
...packageJson.devDependencies,
|
|
34242
|
+
...packageJson.optionalDependencies
|
|
34243
|
+
};
|
|
34244
|
+
return I18N_PACKAGES.some((packageName) => allDependencies[packageName] !== void 0);
|
|
34245
|
+
};
|
|
34175
34246
|
const REANIMATED_DEPENDENCY_NAME = "react-native-reanimated";
|
|
34247
|
+
const MOBX_REACT_PACKAGE_NAME = "mobx-react";
|
|
34248
|
+
const MOBX_REACT_LITE_PACKAGE_NAME = "mobx-react-lite";
|
|
34249
|
+
const MOBX_STATE_TREE_PACKAGE_NAME = "mobx-state-tree";
|
|
34250
|
+
const MOBX_REACT_OBSERVER_PACKAGE_NAME = "mobx-react-observer";
|
|
34176
34251
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34177
34252
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34178
34253
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34191,7 +34266,62 @@ const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
|
34191
34266
|
if (nextMajor === null) return false;
|
|
34192
34267
|
return nextMajor < currentMajor;
|
|
34193
34268
|
};
|
|
34194
|
-
const
|
|
34269
|
+
const shouldReplaceSupportedDependencyFact = (currentFact, nextFact, latestSupportedMajor) => {
|
|
34270
|
+
if (currentFact.version === null) return true;
|
|
34271
|
+
if (nextFact.version === null) return false;
|
|
34272
|
+
const currentMajor = getLowestDependencyMajor(currentFact.version);
|
|
34273
|
+
const nextMajor = getLowestDependencyMajor(nextFact.version);
|
|
34274
|
+
if (currentMajor === null) return false;
|
|
34275
|
+
if (nextMajor === null) return true;
|
|
34276
|
+
if (currentMajor > latestSupportedMajor) return false;
|
|
34277
|
+
if (nextMajor > latestSupportedMajor) return true;
|
|
34278
|
+
return nextMajor < currentMajor;
|
|
34279
|
+
};
|
|
34280
|
+
const shouldReplaceStyledComponentsVersion = (currentVersion, nextVersion) => {
|
|
34281
|
+
if (!currentVersion) return true;
|
|
34282
|
+
const currentMajor = getLowestDependencyMajor(currentVersion);
|
|
34283
|
+
const nextMajor = getLowestDependencyMajor(nextVersion);
|
|
34284
|
+
if (currentMajor === null) return nextMajor !== null && nextMajor < 6;
|
|
34285
|
+
if (nextMajor === null) return currentMajor >= 6;
|
|
34286
|
+
return nextMajor < currentMajor;
|
|
34287
|
+
};
|
|
34288
|
+
const selectOldestDependencyVersion = (currentVersion, nextVersion) => {
|
|
34289
|
+
if (currentVersion === null || nextVersion === null) return null;
|
|
34290
|
+
const current = parseDependencyMajorMinor(currentVersion);
|
|
34291
|
+
const next = parseDependencyMajorMinor(nextVersion);
|
|
34292
|
+
if (current === null) return currentVersion;
|
|
34293
|
+
if (next === null) return nextVersion;
|
|
34294
|
+
if (next.major !== current.major) return next.major < current.major ? nextVersion : currentVersion;
|
|
34295
|
+
return next.minor < current.minor ? nextVersion : currentVersion;
|
|
34296
|
+
};
|
|
34297
|
+
const shouldReplaceMobxFact = (currentFact, nextFact) => {
|
|
34298
|
+
if (currentFact.sourceDirectory === null) return true;
|
|
34299
|
+
if (currentFact.version === null) return false;
|
|
34300
|
+
if (nextFact.version === null) return true;
|
|
34301
|
+
const currentMajor = getDependencyMajorWithinSupportedRange(currentFact.version, 6);
|
|
34302
|
+
const nextMajor = getDependencyMajorWithinSupportedRange(nextFact.version, 6);
|
|
34303
|
+
if (currentMajor === null) return false;
|
|
34304
|
+
if (nextMajor === null) return true;
|
|
34305
|
+
return selectOldestDependencyVersion(currentFact.version, nextFact.version) === nextFact.version;
|
|
34306
|
+
};
|
|
34307
|
+
const collectBindingVersion = (facts, packageJson, directory, packageName) => {
|
|
34308
|
+
const version = getDependencySpec(packageJson, packageName);
|
|
34309
|
+
if (version === null) return;
|
|
34310
|
+
const resolvedVersion = resolveCatalogBackedDependencyVersion({
|
|
34311
|
+
rootDirectory: directory,
|
|
34312
|
+
rootPackageJson: packageJson,
|
|
34313
|
+
packageName,
|
|
34314
|
+
version
|
|
34315
|
+
});
|
|
34316
|
+
if (packageName === MOBX_REACT_PACKAGE_NAME) {
|
|
34317
|
+
facts.mobxReactVersion = facts.hasMobxReact ? selectOldestDependencyVersion(facts.mobxReactVersion, resolvedVersion) : resolvedVersion;
|
|
34318
|
+
facts.hasMobxReact = true;
|
|
34319
|
+
return;
|
|
34320
|
+
}
|
|
34321
|
+
facts.mobxReactLiteVersion = facts.hasMobxReactLite ? selectOldestDependencyVersion(facts.mobxReactLiteVersion, resolvedVersion) : resolvedVersion;
|
|
34322
|
+
facts.hasMobxReactLite = true;
|
|
34323
|
+
};
|
|
34324
|
+
const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, rootPackageJson) => {
|
|
34195
34325
|
if (facts.expo.version === null) {
|
|
34196
34326
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34197
34327
|
if (spec !== null) facts.expo = {
|
|
@@ -34213,13 +34343,74 @@ const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
|
34213
34343
|
sourceDirectory: directory
|
|
34214
34344
|
};
|
|
34215
34345
|
}
|
|
34346
|
+
const mobxSpec = getDependencySpec(packageJson, "mobx");
|
|
34347
|
+
if (mobxSpec !== null) {
|
|
34348
|
+
const nextMobxFact = {
|
|
34349
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34350
|
+
rootDirectory: directory,
|
|
34351
|
+
rootPackageJson: packageJson,
|
|
34352
|
+
packageName: "mobx",
|
|
34353
|
+
version: mobxSpec
|
|
34354
|
+
}),
|
|
34355
|
+
sourceDirectory: directory
|
|
34356
|
+
};
|
|
34357
|
+
if (shouldReplaceMobxFact(facts.mobx, nextMobxFact)) facts.mobx = nextMobxFact;
|
|
34358
|
+
}
|
|
34359
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_PACKAGE_NAME);
|
|
34360
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_LITE_PACKAGE_NAME);
|
|
34361
|
+
facts.hasMobxStateTree = facts.hasMobxStateTree || getDependencySpec(packageJson, MOBX_STATE_TREE_PACKAGE_NAME) !== null;
|
|
34362
|
+
facts.hasMobxReactObserver = facts.hasMobxReactObserver || getDependencySpec(packageJson, MOBX_REACT_OBSERVER_PACKAGE_NAME) !== null;
|
|
34363
|
+
const zustandSpec = getDependencySpec(packageJson, "zustand");
|
|
34364
|
+
if (zustandSpec !== null) {
|
|
34365
|
+
const nextZustandFact = {
|
|
34366
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34367
|
+
rootDirectory: directory,
|
|
34368
|
+
rootPackageJson: packageJson,
|
|
34369
|
+
packageName: "zustand",
|
|
34370
|
+
version: zustandSpec
|
|
34371
|
+
}),
|
|
34372
|
+
sourceDirectory: directory
|
|
34373
|
+
};
|
|
34374
|
+
if (shouldReplaceSupportedDependencyFact(facts.zustand, nextZustandFact, 5)) facts.zustand = nextZustandFact;
|
|
34375
|
+
}
|
|
34216
34376
|
if (facts.reanimatedVersion === null) {
|
|
34217
34377
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34218
34378
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34219
34379
|
}
|
|
34380
|
+
if (facts.valtioVersion === null) {
|
|
34381
|
+
const spec = getDependencySpec(packageJson, "valtio");
|
|
34382
|
+
if (spec !== null) facts.valtioVersion = spec;
|
|
34383
|
+
}
|
|
34384
|
+
facts.tanstackQueryVersion ??= getTanStackQueryVersion(packageJson);
|
|
34385
|
+
const styledComponentsVersion = resolveCatalogBackedDependencyVersion({
|
|
34386
|
+
rootDirectory: directory,
|
|
34387
|
+
rootPackageJson: packageJson,
|
|
34388
|
+
packageName: "styled-components",
|
|
34389
|
+
version: getStyledComponentsVersion(packageJson)
|
|
34390
|
+
});
|
|
34391
|
+
if (styledComponentsVersion && shouldReplaceStyledComponentsVersion(facts.styledComponentsVersion, styledComponentsVersion)) facts.styledComponentsVersion = styledComponentsVersion;
|
|
34392
|
+
facts.hasI18nLibrary = facts.hasI18nLibrary || hasI18nDependency(packageJson);
|
|
34220
34393
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34221
34394
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34222
34395
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34396
|
+
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34397
|
+
if (remotionSpec !== null) {
|
|
34398
|
+
facts.hasRemotionDependency = true;
|
|
34399
|
+
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34400
|
+
rootDirectory,
|
|
34401
|
+
rootPackageJson,
|
|
34402
|
+
packageName: "remotion",
|
|
34403
|
+
version: remotionSpec
|
|
34404
|
+
});
|
|
34405
|
+
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34406
|
+
if (remotionMajorVersion === null) {
|
|
34407
|
+
facts.hasUnknownRemotionVersion = true;
|
|
34408
|
+
facts.remotionVersion = null;
|
|
34409
|
+
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34410
|
+
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34411
|
+
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34412
|
+
}
|
|
34413
|
+
}
|
|
34223
34414
|
};
|
|
34224
34415
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34225
34416
|
const facts = {
|
|
@@ -34239,12 +34430,33 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34239
34430
|
version: null,
|
|
34240
34431
|
sourceDirectory: null
|
|
34241
34432
|
},
|
|
34433
|
+
valtioVersion: null,
|
|
34434
|
+
mobx: {
|
|
34435
|
+
version: null,
|
|
34436
|
+
sourceDirectory: null
|
|
34437
|
+
},
|
|
34438
|
+
hasMobxReact: false,
|
|
34439
|
+
mobxReactVersion: null,
|
|
34440
|
+
hasMobxReactLite: false,
|
|
34441
|
+
mobxReactLiteVersion: null,
|
|
34442
|
+
hasMobxStateTree: false,
|
|
34443
|
+
hasMobxReactObserver: false,
|
|
34444
|
+
zustand: {
|
|
34445
|
+
version: null,
|
|
34446
|
+
sourceDirectory: null
|
|
34447
|
+
},
|
|
34448
|
+
tanstackQueryVersion: null,
|
|
34449
|
+
styledComponentsVersion: null,
|
|
34450
|
+
hasI18nLibrary: false,
|
|
34242
34451
|
hasReactNativeAwarePackage: false,
|
|
34243
34452
|
hasReanimatedAwarePackage: false,
|
|
34244
34453
|
hasSsrDependency: false,
|
|
34454
|
+
hasRemotionDependency: false,
|
|
34455
|
+
hasUnknownRemotionVersion: false,
|
|
34456
|
+
remotionVersion: null,
|
|
34245
34457
|
reanimatedVersion: null
|
|
34246
34458
|
};
|
|
34247
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34459
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory, rootDirectory, rootPackageJson);
|
|
34248
34460
|
let isReactGroupSettled = !collectReactGroup;
|
|
34249
34461
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34250
34462
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
@@ -34253,7 +34465,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34253
34465
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34254
34466
|
visitedDirectories.add(workspaceDirectory);
|
|
34255
34467
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34256
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34468
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory, rootDirectory, rootPackageJson);
|
|
34257
34469
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34258
34470
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34259
34471
|
if (isReactGroupSettled) continue;
|
|
@@ -34477,11 +34689,29 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34477
34689
|
tailwindVersion: null,
|
|
34478
34690
|
zodVersion: null,
|
|
34479
34691
|
zodMajorVersion: null,
|
|
34692
|
+
mobxVersion: null,
|
|
34693
|
+
mobxMajorVersion: null,
|
|
34694
|
+
hasMobxReact: false,
|
|
34695
|
+
mobxReactVersion: null,
|
|
34696
|
+
hasMobxReactLite: false,
|
|
34697
|
+
mobxReactLiteVersion: null,
|
|
34698
|
+
hasMobxStateTree: false,
|
|
34699
|
+
hasMobxReactObserver: false,
|
|
34700
|
+
zustandVersion: null,
|
|
34701
|
+
zustandMajorVersion: null,
|
|
34480
34702
|
framework: "unknown",
|
|
34481
34703
|
hasTypeScript: hasOwnTsConfig,
|
|
34482
34704
|
hasReactCompiler: false,
|
|
34483
34705
|
hasReactCompilerLintPlugin: false,
|
|
34484
34706
|
hasTanStackQuery: false,
|
|
34707
|
+
valtioVersion: null,
|
|
34708
|
+
valtioMajorVersion: null,
|
|
34709
|
+
hasRemotion: false,
|
|
34710
|
+
remotionVersion: null,
|
|
34711
|
+
remotionMajorVersion: null,
|
|
34712
|
+
hasI18nLibrary: false,
|
|
34713
|
+
tanstackQueryVersion: null,
|
|
34714
|
+
styledComponentsVersion: null,
|
|
34485
34715
|
hasSsrDependency: false,
|
|
34486
34716
|
preactVersion: null,
|
|
34487
34717
|
preactMajorVersion: null,
|
|
@@ -34580,6 +34810,12 @@ const discoverProject = (directory) => {
|
|
|
34580
34810
|
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
34581
34811
|
version: workspaceFacts.shopifyFlashList.version
|
|
34582
34812
|
}) : null;
|
|
34813
|
+
const zustandVersion = resolveCatalogBackedDependencyVersion({
|
|
34814
|
+
rootDirectory: directory,
|
|
34815
|
+
rootPackageJson: packageJson,
|
|
34816
|
+
packageName: "zustand",
|
|
34817
|
+
version: workspaceFacts.zustand.version
|
|
34818
|
+
});
|
|
34583
34819
|
const hasReanimated = hasReactNativeWorkspace && workspaceFacts.hasReanimatedAwarePackage;
|
|
34584
34820
|
const reanimatedVersion = hasReanimated ? workspaceFacts.reanimatedVersion : null;
|
|
34585
34821
|
const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
|
|
@@ -34588,7 +34824,21 @@ const discoverProject = (directory) => {
|
|
|
34588
34824
|
packageName: "next",
|
|
34589
34825
|
version: workspaceFacts.next.version
|
|
34590
34826
|
}) : null;
|
|
34827
|
+
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
34828
|
+
rootDirectory: directory,
|
|
34829
|
+
rootPackageJson: packageJson,
|
|
34830
|
+
packageName: "valtio",
|
|
34831
|
+
version: workspaceFacts.valtioVersion
|
|
34832
|
+
});
|
|
34833
|
+
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
34834
|
+
rootDirectory: directory,
|
|
34835
|
+
rootPackageJson: packageJson,
|
|
34836
|
+
packageName: "mobx",
|
|
34837
|
+
version: workspaceFacts.mobx.version
|
|
34838
|
+
});
|
|
34591
34839
|
const preactVersion = getPreactVersion(packageJson);
|
|
34840
|
+
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34841
|
+
const tanstackQueryVersion = getTanStackQueryVersion(packageJson) ?? workspaceFacts.tanstackQueryVersion;
|
|
34592
34842
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34593
34843
|
const projectInfo = {
|
|
34594
34844
|
rootDirectory: directory,
|
|
@@ -34598,11 +34848,29 @@ const discoverProject = (directory) => {
|
|
|
34598
34848
|
tailwindVersion,
|
|
34599
34849
|
zodVersion,
|
|
34600
34850
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
34851
|
+
mobxVersion,
|
|
34852
|
+
mobxMajorVersion: mobxVersion === null ? null : getDependencyMajorWithinSupportedRange(mobxVersion, 6),
|
|
34853
|
+
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
34854
|
+
mobxReactVersion: workspaceFacts.mobxReactVersion,
|
|
34855
|
+
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
34856
|
+
mobxReactLiteVersion: workspaceFacts.mobxReactLiteVersion,
|
|
34857
|
+
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
34858
|
+
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
34859
|
+
zustandVersion,
|
|
34860
|
+
zustandMajorVersion: zustandVersion === null ? null : getLowestDependencyMajor(zustandVersion),
|
|
34601
34861
|
framework,
|
|
34602
34862
|
hasTypeScript,
|
|
34603
34863
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34604
34864
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
34605
|
-
hasTanStackQuery:
|
|
34865
|
+
hasTanStackQuery: tanstackQueryVersion !== null,
|
|
34866
|
+
hasI18nLibrary: workspaceFacts.hasI18nLibrary,
|
|
34867
|
+
tanstackQueryVersion,
|
|
34868
|
+
styledComponentsVersion: workspaceFacts.styledComponentsVersion,
|
|
34869
|
+
valtioVersion,
|
|
34870
|
+
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
34871
|
+
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
34872
|
+
remotionVersion,
|
|
34873
|
+
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
34606
34874
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34607
34875
|
preactVersion,
|
|
34608
34876
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
@@ -34836,7 +35104,6 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
34836
35104
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
34837
35105
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
34838
35106
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34839
|
-
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
34840
35107
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
34841
35108
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
34842
35109
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37049,9 +37316,25 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37049
37316
|
".babelrc.json"
|
|
37050
37317
|
];
|
|
37051
37318
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37319
|
+
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37320
|
+
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37321
|
+
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37322
|
+
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37052
37323
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37053
37324
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37325
|
+
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37326
|
+
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37327
|
+
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37328
|
+
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37329
|
+
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37330
|
+
if (normalizedVersionRange === null) return false;
|
|
37331
|
+
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37332
|
+
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37333
|
+
};
|
|
37334
|
+
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37054
37335
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37336
|
+
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37337
|
+
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37055
37338
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37056
37339
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37057
37340
|
if (!isFile(filePath)) continue;
|
|
@@ -37061,7 +37344,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37061
37344
|
} catch {
|
|
37062
37345
|
continue;
|
|
37063
37346
|
}
|
|
37064
|
-
if (
|
|
37347
|
+
if (shouldReportLegacyPreset && LEGACY_PRESET_REFERENCE.test(contents)) return [buildReactNativeDiagnostic({
|
|
37065
37348
|
filePath: fileName,
|
|
37066
37349
|
rule: "rn-no-metro-babel-preset",
|
|
37067
37350
|
severity: "error",
|
|
@@ -37084,12 +37367,6 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37084
37367
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37085
37368
|
};
|
|
37086
37369
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37087
|
-
const DEPENDENCY_SECTIONS = [
|
|
37088
|
-
"dependencies",
|
|
37089
|
-
"devDependencies",
|
|
37090
|
-
"peerDependencies",
|
|
37091
|
-
"optionalDependencies"
|
|
37092
|
-
];
|
|
37093
37370
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37094
37371
|
"19.0": {
|
|
37095
37372
|
rceFixedVersion: "19.0.1",
|
|
@@ -37136,20 +37413,13 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37136
37413
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37137
37414
|
return [...directories];
|
|
37138
37415
|
};
|
|
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
|
-
};
|
|
37146
37416
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37147
37417
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37148
37418
|
if (isFile(manifestPath)) {
|
|
37149
37419
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37150
37420
|
if (installedVersion !== null) return installedVersion;
|
|
37151
37421
|
}
|
|
37152
|
-
const candidateSpecs = [
|
|
37422
|
+
const candidateSpecs = [getDependencySpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37153
37423
|
for (const spec of candidateSpecs) {
|
|
37154
37424
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37155
37425
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -37817,21 +38087,68 @@ const buildCapabilities = (project) => {
|
|
|
37817
38087
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
37818
38088
|
if (project.isStaticExport) capabilities.add("nextjs:static-export");
|
|
37819
38089
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
38090
|
+
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 16) capabilities.add("nextjs:16");
|
|
37820
38091
|
addMajorLadder(capabilities, "react", project.reactMajorVersion, 17, 30);
|
|
37821
38092
|
if (project.reactMajorVersion !== null && project.reactMajorVersion >= 19 && isMajorMinorAtLeast(parseReactMajorMinor(project.reactVersion), {
|
|
37822
38093
|
major: 19,
|
|
37823
38094
|
minor: 2
|
|
37824
38095
|
})) capabilities.add("react:19.2");
|
|
37825
|
-
if (project.tailwindVersion !== null)
|
|
37826
|
-
|
|
37827
|
-
|
|
37828
|
-
|
|
37829
|
-
|
|
38096
|
+
if (project.tailwindVersion !== null) {
|
|
38097
|
+
capabilities.add("tailwind");
|
|
38098
|
+
const tailwindVersion = parseTailwindMajorMinor(project.tailwindVersion);
|
|
38099
|
+
if (isMajorMinorAtLeast(tailwindVersion, {
|
|
38100
|
+
major: 3,
|
|
38101
|
+
minor: 4
|
|
38102
|
+
})) capabilities.add("tailwind:3.4");
|
|
38103
|
+
if (tailwindVersion !== null && isMajorMinorAtLeast(tailwindVersion, {
|
|
38104
|
+
major: 4,
|
|
38105
|
+
minor: 0
|
|
38106
|
+
})) capabilities.add("tailwind:4");
|
|
38107
|
+
}
|
|
37830
38108
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
37831
38109
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
38110
|
+
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
38111
|
+
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
38112
|
+
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
38113
|
+
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
38114
|
+
const mobxReactVersion = parseDependencyMajorMinor(project.mobxReactVersion);
|
|
38115
|
+
const mobxReactLiteVersion = parseDependencyMajorMinor(project.mobxReactLiteVersion);
|
|
38116
|
+
const hasMobxReactObserverMemoGuard = mobxReactVersion !== null && isMajorMinorAtLeast(mobxReactVersion, {
|
|
38117
|
+
major: 7,
|
|
38118
|
+
minor: 3
|
|
38119
|
+
});
|
|
38120
|
+
const hasMobxReactLiteObserverMemoGuard = mobxReactLiteVersion !== null && isMajorMinorAtLeast(mobxReactLiteVersion, {
|
|
38121
|
+
major: 3,
|
|
38122
|
+
minor: 3
|
|
38123
|
+
});
|
|
38124
|
+
if (hasMobxReactObserverMemoGuard) capabilities.add("mobx-react-observer-memo-guard");
|
|
38125
|
+
if (hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-lite-observer-memo-guard");
|
|
38126
|
+
if (hasMobxReactObserverMemoGuard || hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-binding-observer-memo-guard");
|
|
38127
|
+
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
38128
|
+
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
38129
|
+
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addMajorLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
38130
|
+
const mobxVersion = parseDependencyMajorMinor(project.mobxVersion);
|
|
38131
|
+
if (project.mobxMajorVersion === 6 && mobxVersion !== null && isMajorMinorAtLeast(mobxVersion, {
|
|
38132
|
+
major: 6,
|
|
38133
|
+
minor: 10
|
|
38134
|
+
})) capabilities.add("mobx:6.10");
|
|
38135
|
+
if (project.zustandVersion !== void 0 && project.zustandVersion !== null) capabilities.add("zustand");
|
|
38136
|
+
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addMajorLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
37832
38137
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
37833
38138
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
37834
|
-
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
38139
|
+
if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
|
|
38140
|
+
if (project.styledComponentsVersion) {
|
|
38141
|
+
capabilities.add("styled-components");
|
|
38142
|
+
const styledComponentsMajor = getLowestDependencyMajor(project.styledComponentsVersion);
|
|
38143
|
+
if (styledComponentsMajor !== null && styledComponentsMajor >= 6) capabilities.add("styled-components:6");
|
|
38144
|
+
}
|
|
38145
|
+
if (project.hasI18nLibrary) capabilities.add("i18n");
|
|
38146
|
+
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
38147
|
+
addMajorLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
38148
|
+
if (project.hasRemotion) {
|
|
38149
|
+
capabilities.add("remotion");
|
|
38150
|
+
addMajorLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
38151
|
+
}
|
|
37835
38152
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
37836
38153
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
37837
38154
|
addMajorLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
@@ -37846,7 +38163,7 @@ const getCapabilities = (project) => {
|
|
|
37846
38163
|
capabilitiesByProject.set(project, capabilities);
|
|
37847
38164
|
return capabilities;
|
|
37848
38165
|
};
|
|
37849
|
-
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen) => {
|
|
38166
|
+
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen, includedTags) => {
|
|
37850
38167
|
if (requires) {
|
|
37851
38168
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
37852
38169
|
}
|
|
@@ -37857,20 +38174,29 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhe
|
|
|
37857
38174
|
if (tags) {
|
|
37858
38175
|
for (const tag of tags) if (ignoredTags.has(tag)) return false;
|
|
37859
38176
|
}
|
|
38177
|
+
if (includedTags && includedTags.size > 0) {
|
|
38178
|
+
if (!tags?.some((tag) => includedTags.has(tag))) return false;
|
|
38179
|
+
}
|
|
37860
38180
|
return true;
|
|
37861
38181
|
};
|
|
38182
|
+
const shouldEnableRuleByDefaultStatus = (options) => options.defaultEnabled !== false || options.hasExplicitOverride === true || options.includeTagDefaults && options.hasIncludedTags;
|
|
37862
38183
|
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
37863
38184
|
setImmediate(resolve);
|
|
37864
38185
|
});
|
|
37865
38186
|
const createSecurityScanSession = (rootDirectory, options) => {
|
|
37866
38187
|
const capabilities = options.project ? getCapabilities(options.project) : /* @__PURE__ */ new Set();
|
|
37867
38188
|
const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
|
|
38189
|
+
const includedTags = options.includedTags ?? /* @__PURE__ */ new Set();
|
|
37868
38190
|
const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
|
|
37869
38191
|
const rule = entry.rule;
|
|
37870
38192
|
const scan = rule.scan;
|
|
37871
38193
|
if (typeof scan !== "function") return [];
|
|
37872
|
-
if (
|
|
37873
|
-
|
|
38194
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
38195
|
+
defaultEnabled: rule.defaultEnabled,
|
|
38196
|
+
includeTagDefaults: options.includeTagDefaults === true,
|
|
38197
|
+
hasIncludedTags: includedTags.size > 0
|
|
38198
|
+
})) return [];
|
|
38199
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) return [];
|
|
37874
38200
|
return [{
|
|
37875
38201
|
entry,
|
|
37876
38202
|
scan,
|
|
@@ -39856,8 +40182,9 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
39856
40182
|
}
|
|
39857
40183
|
return enabled;
|
|
39858
40184
|
};
|
|
39859
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
39860
|
-
const
|
|
40185
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
40186
|
+
const hasIncludedTags = includedTags.size > 0;
|
|
40187
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
39861
40188
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
39862
40189
|
const jsPlugins = [];
|
|
39863
40190
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -39872,9 +40199,14 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39872
40199
|
if (rule.scan !== void 0) continue;
|
|
39873
40200
|
if (customRulesOnly && registryEntry.originallyExternal) continue;
|
|
39874
40201
|
if (rule.framework !== "global" && !rule.requires) continue;
|
|
39875
|
-
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen)) continue;
|
|
40202
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) continue;
|
|
39876
40203
|
const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
|
|
39877
|
-
if (
|
|
40204
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
40205
|
+
defaultEnabled: rule.defaultEnabled,
|
|
40206
|
+
includeTagDefaults,
|
|
40207
|
+
hasIncludedTags,
|
|
40208
|
+
hasExplicitOverride: explicitRuleOverride !== void 0
|
|
40209
|
+
})) continue;
|
|
39878
40210
|
const severity = resolveRuleSeverityOverride({
|
|
39879
40211
|
ruleKey: registryEntry.key,
|
|
39880
40212
|
category: rule.category
|
|
@@ -39883,7 +40215,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39883
40215
|
enabledReactDoctorRules[registryEntry.key] = severity;
|
|
39884
40216
|
}
|
|
39885
40217
|
const userPluginRules = {};
|
|
39886
|
-
if (ruleSelection !== "sidecar") for (const userPlugin of userPlugins) {
|
|
40218
|
+
if (ruleSelection !== "sidecar" && !hasIncludedTags) for (const userPlugin of userPlugins) {
|
|
39887
40219
|
Object.assign(userPluginRules, buildUserPluginRules(userPlugin, severityControls));
|
|
39888
40220
|
jsPlugins.push(userPlugin.entry);
|
|
39889
40221
|
}
|
|
@@ -40100,6 +40432,19 @@ const createSidecarLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
40100
40432
|
}
|
|
40101
40433
|
};
|
|
40102
40434
|
};
|
|
40435
|
+
const fingerprintCacheByFilePath = /* @__PURE__ */ new Map();
|
|
40436
|
+
const fingerprintFileContents = (filePath, fingerprintLength) => {
|
|
40437
|
+
const fileStats = NFS.statSync(filePath, { bigint: true });
|
|
40438
|
+
const cachedFingerprint = fingerprintCacheByFilePath.get(filePath);
|
|
40439
|
+
if (cachedFingerprint?.modifiedTimeNanoseconds === fileStats.mtimeNs && cachedFingerprint.sizeBytes === fileStats.size) return cachedFingerprint.fingerprint;
|
|
40440
|
+
const fingerprint = crypto.createHash("sha256").update(NFS.readFileSync(filePath)).digest("hex").slice(0, fingerprintLength);
|
|
40441
|
+
fingerprintCacheByFilePath.set(filePath, {
|
|
40442
|
+
fingerprint,
|
|
40443
|
+
modifiedTimeNanoseconds: fileStats.mtimeNs,
|
|
40444
|
+
sizeBytes: fileStats.size
|
|
40445
|
+
});
|
|
40446
|
+
return fingerprint;
|
|
40447
|
+
};
|
|
40103
40448
|
const bundledRequire = createRequire(import.meta.url);
|
|
40104
40449
|
const childNodeVersionByBinaryPath = /* @__PURE__ */ new Map();
|
|
40105
40450
|
const resolveChildNodeVersion = (nodeBinaryPath) => {
|
|
@@ -40123,6 +40468,13 @@ const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
|
40123
40468
|
"oxlint-plugin-react-doctor/package.json",
|
|
40124
40469
|
"eslint-plugin-react-hooks/package.json"
|
|
40125
40470
|
];
|
|
40471
|
+
const resolvePluginFingerprint = () => {
|
|
40472
|
+
try {
|
|
40473
|
+
return fingerprintFileContents(bundledRequire.resolve("oxlint-plugin-react-doctor"), 16);
|
|
40474
|
+
} catch {
|
|
40475
|
+
return "unresolved";
|
|
40476
|
+
}
|
|
40477
|
+
};
|
|
40126
40478
|
const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
40127
40479
|
const versions = [`node=${resolveChildNodeVersion(nodeBinaryPath)}`];
|
|
40128
40480
|
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
@@ -40132,6 +40484,7 @@ const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
|
40132
40484
|
} catch {
|
|
40133
40485
|
versions.push(`${specifier}=missing`);
|
|
40134
40486
|
}
|
|
40487
|
+
versions.push(`oxlint-plugin-react-doctor#fingerprint=${resolvePluginFingerprint()}`);
|
|
40135
40488
|
return versions;
|
|
40136
40489
|
};
|
|
40137
40490
|
const esmRequire = createRequire(import.meta.url);
|
|
@@ -41607,7 +41960,7 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
41607
41960
|
* 6. always restore disable directives + clean up the temp dir
|
|
41608
41961
|
*/
|
|
41609
41962
|
const runOxlint = async (options) => {
|
|
41610
|
-
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), userConfig, configSourceDirectory = rootDirectory, onPartialFailure, onFileCoverage, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
|
|
41963
|
+
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, userConfig, configSourceDirectory = rootDirectory, onPartialFailure, onFileCoverage, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
|
|
41611
41964
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
41612
41965
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
41613
41966
|
validateRuleRegistration();
|
|
@@ -41621,13 +41974,15 @@ const runOxlint = async (options) => {
|
|
|
41621
41974
|
}
|
|
41622
41975
|
const pluginPath = resolvePluginPath();
|
|
41623
41976
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
41624
|
-
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
41977
|
+
const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
41625
41978
|
const buildConfig = (overrides) => createOxlintConfig({
|
|
41626
41979
|
pluginPath,
|
|
41627
41980
|
project,
|
|
41628
41981
|
customRulesOnly,
|
|
41629
41982
|
extendsPaths: overrides.extendsPaths,
|
|
41630
41983
|
ignoredTags,
|
|
41984
|
+
includedTags,
|
|
41985
|
+
includeTagDefaults,
|
|
41631
41986
|
serverAuthFunctionNames,
|
|
41632
41987
|
severityControls,
|
|
41633
41988
|
userPlugins,
|
|
@@ -42016,6 +42371,8 @@ var Linter = class Linter extends Service()("react-doctor/Linter") {
|
|
|
42016
42371
|
respectInlineDisables: input.respectInlineDisables,
|
|
42017
42372
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42018
42373
|
ignoredTags: input.ignoredTags,
|
|
42374
|
+
includedTags: input.includedTags,
|
|
42375
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
42019
42376
|
userConfig: input.userConfig ?? null,
|
|
42020
42377
|
configSourceDirectory: input.configSourceDirectory,
|
|
42021
42378
|
onPartialFailure: (reason) => {
|
|
@@ -42864,7 +43221,9 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42864
43221
|
const securityScanFailedRef = yield* make$13(false);
|
|
42865
43222
|
const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(tryPromise(() => checkSecurityScanCooperative(scanDirectory, {
|
|
42866
43223
|
project,
|
|
42867
|
-
ignoredTags: input.ignoredTags
|
|
43224
|
+
ignoredTags: input.ignoredTags,
|
|
43225
|
+
includedTags: input.includedTags,
|
|
43226
|
+
includeTagDefaults: input.includeTagDefaults
|
|
42868
43227
|
})).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), catch_$1(() => set(securityScanFailedRef, true).pipe(as(empty$4))))))).pipe(withSpan("SecurityScan.run")));
|
|
42869
43228
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
42870
43229
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
@@ -42955,6 +43314,8 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42955
43314
|
respectInlineDisables: input.respectInlineDisables,
|
|
42956
43315
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42957
43316
|
ignoredTags: input.ignoredTags,
|
|
43317
|
+
includedTags: input.includedTags,
|
|
43318
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
42958
43319
|
userConfig: resolvedConfig.config ?? void 0,
|
|
42959
43320
|
configSourceDirectory: resolvedConfig.configSourceDirectory ?? void 0,
|
|
42960
43321
|
onFileProgress: (scannedFileCount, totalFileCount) => {
|
|
@@ -45457,5 +45818,5 @@ const startLanguageServer = () => {
|
|
|
45457
45818
|
};
|
|
45458
45819
|
//#endregion
|
|
45459
45820
|
export { startLanguageServer };
|
|
45460
|
-
!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]="
|
|
45461
|
-
//# debugId=
|
|
45821
|
+
!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]="f864b0b7-d64a-58b1-8eed-e2387bc445d5")}catch(e){}}();
|
|
45822
|
+
//# debugId=f864b0b7-d64a-58b1-8eed-e2387bc445d5
|