react-doctor 0.8.1-dev.3018538 → 0.8.1-dev.359d9b3
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 +696 -166
- package/dist/index.d.ts +42 -1
- package/dist/index.js +608 -123
- package/dist/lsp.js +608 -123
- package/dist/skills/react-doctor/SKILL.md +5 -0
- package/package.json +5 -5
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__\//;
|
|
@@ -32961,6 +32923,58 @@ const IGNORED_DIRECTORIES = new Set([
|
|
|
32961
32923
|
"storybook-static"
|
|
32962
32924
|
]);
|
|
32963
32925
|
const MILLISECONDS_PER_SECOND = 1e3;
|
|
32926
|
+
const REACT_ROUTER_CAPABILITY_THRESHOLDS = [
|
|
32927
|
+
{
|
|
32928
|
+
capability: "react-router:6.4",
|
|
32929
|
+
major: 6,
|
|
32930
|
+
minor: 4
|
|
32931
|
+
},
|
|
32932
|
+
{
|
|
32933
|
+
capability: "react-router:6.7",
|
|
32934
|
+
major: 6,
|
|
32935
|
+
minor: 7
|
|
32936
|
+
},
|
|
32937
|
+
{
|
|
32938
|
+
capability: "react-router:6.9",
|
|
32939
|
+
major: 6,
|
|
32940
|
+
minor: 9
|
|
32941
|
+
},
|
|
32942
|
+
{
|
|
32943
|
+
capability: "react-router:6.19",
|
|
32944
|
+
major: 6,
|
|
32945
|
+
minor: 19
|
|
32946
|
+
},
|
|
32947
|
+
{
|
|
32948
|
+
capability: "react-router:7",
|
|
32949
|
+
major: 7,
|
|
32950
|
+
minor: 0
|
|
32951
|
+
},
|
|
32952
|
+
{
|
|
32953
|
+
capability: "react-router:7.8",
|
|
32954
|
+
major: 7,
|
|
32955
|
+
minor: 8
|
|
32956
|
+
},
|
|
32957
|
+
{
|
|
32958
|
+
capability: "react-router:7.9",
|
|
32959
|
+
major: 7,
|
|
32960
|
+
minor: 9
|
|
32961
|
+
},
|
|
32962
|
+
{
|
|
32963
|
+
capability: "react-router:7.10",
|
|
32964
|
+
major: 7,
|
|
32965
|
+
minor: 10
|
|
32966
|
+
},
|
|
32967
|
+
{
|
|
32968
|
+
capability: "react-router:7.15",
|
|
32969
|
+
major: 7,
|
|
32970
|
+
minor: 15
|
|
32971
|
+
},
|
|
32972
|
+
{
|
|
32973
|
+
capability: "react-router:8",
|
|
32974
|
+
major: 8,
|
|
32975
|
+
minor: 0
|
|
32976
|
+
}
|
|
32977
|
+
];
|
|
32964
32978
|
const SCORE_API_URL = "https://www.react.doctor/api/score";
|
|
32965
32979
|
const FETCH_TIMEOUT_MS = 1e4;
|
|
32966
32980
|
const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
|
|
@@ -33102,6 +33116,44 @@ const SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS = 9e4;
|
|
|
33102
33116
|
const SUPPLY_CHAIN_CACHE_TTL_MS = 864e5;
|
|
33103
33117
|
const SUPPLY_CHAIN_CACHE_SUBDIR = "supply-chain";
|
|
33104
33118
|
const SUPPLY_CHAIN_IGNORED_PACKAGES = new Set(["next"]);
|
|
33119
|
+
const isErrnoException = (error) => error instanceof Error && "code" in error;
|
|
33120
|
+
const IGNORABLE_READDIR_ERROR_CODES = new Set([
|
|
33121
|
+
"EACCES",
|
|
33122
|
+
"EPERM",
|
|
33123
|
+
"ENOENT",
|
|
33124
|
+
"ENOTDIR",
|
|
33125
|
+
"EINVAL",
|
|
33126
|
+
"ELOOP",
|
|
33127
|
+
"ENAMETOOLONG"
|
|
33128
|
+
]);
|
|
33129
|
+
const isIgnorableReaddirError = (error) => isErrnoException(error) && typeof error.code === "string" && IGNORABLE_READDIR_ERROR_CODES.has(error.code);
|
|
33130
|
+
const readDirectoryEntries = (directoryPath) => {
|
|
33131
|
+
try {
|
|
33132
|
+
return NFS.readdirSync(directoryPath, { withFileTypes: true });
|
|
33133
|
+
} catch (error) {
|
|
33134
|
+
if (isIgnorableReaddirError(error)) return [];
|
|
33135
|
+
throw error;
|
|
33136
|
+
}
|
|
33137
|
+
};
|
|
33138
|
+
const isFile = (filePath) => {
|
|
33139
|
+
try {
|
|
33140
|
+
return NFS.statSync(filePath).isFile();
|
|
33141
|
+
} catch {
|
|
33142
|
+
return false;
|
|
33143
|
+
}
|
|
33144
|
+
};
|
|
33145
|
+
const isDirectory = (directoryPath) => {
|
|
33146
|
+
try {
|
|
33147
|
+
return NFS.statSync(directoryPath).isDirectory();
|
|
33148
|
+
} catch {
|
|
33149
|
+
return false;
|
|
33150
|
+
}
|
|
33151
|
+
};
|
|
33152
|
+
const isPlainObject = (value) => {
|
|
33153
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
33154
|
+
const prototype = Object.getPrototypeOf(value);
|
|
33155
|
+
return prototype === null || prototype === Object.prototype;
|
|
33156
|
+
};
|
|
33105
33157
|
const lastSourceMappingUrl = (fileContent) => {
|
|
33106
33158
|
const lastReference = [...fileContent.matchAll(/\/\/# sourceMappingURL=(\S+)/g)].at(-1);
|
|
33107
33159
|
return lastReference ? lastReference[1] : null;
|
|
@@ -33454,11 +33506,17 @@ const NEXT_CONFIG_FILENAMES = [
|
|
|
33454
33506
|
];
|
|
33455
33507
|
const BABEL_CONFIG_FILENAMES = [
|
|
33456
33508
|
".babelrc",
|
|
33509
|
+
".babelrc.js",
|
|
33457
33510
|
".babelrc.json",
|
|
33511
|
+
".babelrc.cjs",
|
|
33512
|
+
".babelrc.mjs",
|
|
33513
|
+
".babelrc.cts",
|
|
33458
33514
|
"babel.config.js",
|
|
33459
33515
|
"babel.config.json",
|
|
33460
33516
|
"babel.config.cjs",
|
|
33461
|
-
"babel.config.mjs"
|
|
33517
|
+
"babel.config.mjs",
|
|
33518
|
+
"babel.config.ts",
|
|
33519
|
+
"babel.config.cts"
|
|
33462
33520
|
];
|
|
33463
33521
|
const VITE_CONFIG_FILENAMES = [
|
|
33464
33522
|
"vite.config.js",
|
|
@@ -33470,12 +33528,28 @@ const VITE_CONFIG_FILENAMES = [
|
|
|
33470
33528
|
"vitest.config.ts",
|
|
33471
33529
|
"vitest.config.js"
|
|
33472
33530
|
];
|
|
33531
|
+
const RSBUILD_CONFIG_FILENAMES = [
|
|
33532
|
+
"rsbuild.config.ts",
|
|
33533
|
+
"rsbuild.config.js",
|
|
33534
|
+
"rsbuild.config.mts",
|
|
33535
|
+
"rsbuild.config.mjs",
|
|
33536
|
+
"rsbuild.config.cts",
|
|
33537
|
+
"rsbuild.config.cjs"
|
|
33538
|
+
];
|
|
33539
|
+
const RSPACK_CONFIG_FILENAMES = [
|
|
33540
|
+
"rspack.config.ts",
|
|
33541
|
+
"rspack.config.js",
|
|
33542
|
+
"rspack.config.mts",
|
|
33543
|
+
"rspack.config.mjs",
|
|
33544
|
+
"rspack.config.cts",
|
|
33545
|
+
"rspack.config.cjs"
|
|
33546
|
+
];
|
|
33473
33547
|
const EXPO_APP_CONFIG_FILENAMES = [
|
|
33474
33548
|
"app.json",
|
|
33475
33549
|
"app.config.js",
|
|
33476
33550
|
"app.config.ts"
|
|
33477
33551
|
];
|
|
33478
|
-
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|["']react-compiler["']/;
|
|
33552
|
+
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|reactCompilerPreset\s*\(|["']react-compiler["']/;
|
|
33479
33553
|
const REACT_COMPILER_ENABLED_FLAG_PATTERN = /["']?reactCompiler["']?\s*:\s*(?:true\b|\{)/;
|
|
33480
33554
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
33481
33555
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
@@ -33510,6 +33584,8 @@ const detectReactCompiler = (directory, packageJson) => {
|
|
|
33510
33584
|
if (hasCompilerInConfigFiles(directory, NEXT_CONFIG_FILENAMES)) return true;
|
|
33511
33585
|
if (hasCompilerInConfigFiles(directory, BABEL_CONFIG_FILENAMES)) return true;
|
|
33512
33586
|
if (hasCompilerInConfigFiles(directory, VITE_CONFIG_FILENAMES)) return true;
|
|
33587
|
+
if (hasCompilerInConfigFiles(directory, RSBUILD_CONFIG_FILENAMES)) return true;
|
|
33588
|
+
if (hasCompilerInConfigFiles(directory, RSPACK_CONFIG_FILENAMES)) return true;
|
|
33513
33589
|
if (hasCompilerInConfigFiles(directory, EXPO_APP_CONFIG_FILENAMES)) return true;
|
|
33514
33590
|
return hasCompilerPackageInAncestors(directory, REACT_COMPILER_TRANSFORM_PACKAGES);
|
|
33515
33591
|
};
|
|
@@ -33518,7 +33594,7 @@ const detectNextjsStaticExport = (directory) => NEXT_CONFIG_FILENAMES.some((file
|
|
|
33518
33594
|
const filePath = Path.join(directory, filename);
|
|
33519
33595
|
return isFile(filePath) && STATIC_EXPORT_OUTPUT_PATTERN.test(NFS.readFileSync(filePath, "utf-8"));
|
|
33520
33596
|
});
|
|
33521
|
-
const UNRESOLVABLE_PROTOCOL_VERSION = /^(?:file|git|github|https?|link|patch|portal|workspace|npm):/i;
|
|
33597
|
+
const UNRESOLVABLE_PROTOCOL_VERSION = /^(?:catalog|file|git|github|https?|link|patch|portal|workspace|npm):/i;
|
|
33522
33598
|
const DIST_TAG_VERSION = /^[a-z][a-z0-9._-]*$/i;
|
|
33523
33599
|
const WILDCARD_VERSION = /^[*xX](?:\.[*xX])*$/;
|
|
33524
33600
|
const NPM_ALIAS_VERSION = /^npm:(?:@[^/]+\/[^@]+|[^@]+)@(.+)$/i;
|
|
@@ -33651,6 +33727,16 @@ const getLowestDependencyMajor = (version) => {
|
|
|
33651
33727
|
}
|
|
33652
33728
|
return lowestMajor;
|
|
33653
33729
|
};
|
|
33730
|
+
const getDependencyMajorWithinSupportedRange = (version, latestSupportedMajor) => {
|
|
33731
|
+
const normalizedVersion = normalizeDependencyVersion(version);
|
|
33732
|
+
if (normalizedVersion === null) return null;
|
|
33733
|
+
const validRange = import_semver.validRange(normalizedVersion);
|
|
33734
|
+
if (validRange === null) return null;
|
|
33735
|
+
const minimumVersion = import_semver.minVersion(validRange);
|
|
33736
|
+
if (minimumVersion === null || minimumVersion.major > latestSupportedMajor) return null;
|
|
33737
|
+
if (import_semver.intersects(validRange, `>=${latestSupportedMajor + 1}.0.0`)) return null;
|
|
33738
|
+
return minimumVersion.major;
|
|
33739
|
+
};
|
|
33654
33740
|
const isConcreteDependencyVersion = (version) => {
|
|
33655
33741
|
const normalizedVersion = normalizeDependencyVersion(version);
|
|
33656
33742
|
return normalizedVersion !== null && /\d/.test(normalizedVersion);
|
|
@@ -33694,9 +33780,18 @@ const parseReactMajorMinor = (reactVersion) => {
|
|
|
33694
33780
|
};
|
|
33695
33781
|
};
|
|
33696
33782
|
const parseLowerBoundVersion = (versionSpec) => import_semver.validRange(versionSpec) !== null ? import_semver.minVersion(versionSpec) : import_semver.coerce(versionSpec);
|
|
33697
|
-
const
|
|
33698
|
-
if (typeof
|
|
33699
|
-
const
|
|
33783
|
+
const parseThreeRelease = (threeVersion) => {
|
|
33784
|
+
if (typeof threeVersion !== "string") return null;
|
|
33785
|
+
const normalizedVersion = normalizeDependencyVersion(threeVersion);
|
|
33786
|
+
if (normalizedVersion === null) return null;
|
|
33787
|
+
const lowerBound = parseLowerBoundVersion(normalizedVersion);
|
|
33788
|
+
if (lowerBound === null) return null;
|
|
33789
|
+
if (lowerBound.major > 0) return Number.MAX_SAFE_INTEGER;
|
|
33790
|
+
return lowerBound.minor > 0 ? lowerBound.minor : null;
|
|
33791
|
+
};
|
|
33792
|
+
const parseDependencyMajorMinor = (dependencyVersion) => {
|
|
33793
|
+
if (typeof dependencyVersion !== "string") return null;
|
|
33794
|
+
const trimmed = dependencyVersion.trim();
|
|
33700
33795
|
if (trimmed.length === 0) return null;
|
|
33701
33796
|
const lowerBound = parseLowerBoundVersion(trimmed);
|
|
33702
33797
|
if (lowerBound === null || lowerBound.major <= 0) return null;
|
|
@@ -33705,6 +33800,7 @@ const parseTailwindMajorMinor = (tailwindVersion) => {
|
|
|
33705
33800
|
minor: lowerBound.minor
|
|
33706
33801
|
};
|
|
33707
33802
|
};
|
|
33803
|
+
const parseTailwindMajorMinor = (tailwindVersion) => parseDependencyMajorMinor(tailwindVersion);
|
|
33708
33804
|
const hasUpperBoundOnlyPeerRange = (range) => {
|
|
33709
33805
|
if (typeof range !== "string") return false;
|
|
33710
33806
|
const normalizedRange = normalizeDependencyVersion(range);
|
|
@@ -33726,7 +33822,7 @@ const resolveEffectiveReactMajor = (reactVersion, packageJson) => {
|
|
|
33726
33822
|
if (peerFloor === null) return hasUpperBoundOnlyPeerRange(peerReactRange) ? null : installedReactMajor;
|
|
33727
33823
|
return installedReactMajor !== null ? Math.min(installedReactMajor, peerFloor) : peerFloor;
|
|
33728
33824
|
};
|
|
33729
|
-
const isCatalogReference = (version) => version.startsWith("catalog:");
|
|
33825
|
+
const isCatalogReference = (version) => typeof version === "string" && version.startsWith("catalog:");
|
|
33730
33826
|
const extractCatalogName = (version) => {
|
|
33731
33827
|
if (!isCatalogReference(version)) return null;
|
|
33732
33828
|
const name = version.slice(8).trim();
|
|
@@ -33876,6 +33972,12 @@ const TAILWIND_ZOD_SECTIONS = [
|
|
|
33876
33972
|
"devDependencies",
|
|
33877
33973
|
"peerDependencies"
|
|
33878
33974
|
];
|
|
33975
|
+
const DEPENDENCY_SPEC_SECTIONS = [
|
|
33976
|
+
"dependencies",
|
|
33977
|
+
"devDependencies",
|
|
33978
|
+
"peerDependencies",
|
|
33979
|
+
"optionalDependencies"
|
|
33980
|
+
];
|
|
33879
33981
|
const EMPTY_DEPENDENCY_INFO = {
|
|
33880
33982
|
reactVersion: null,
|
|
33881
33983
|
tailwindVersion: null,
|
|
@@ -33885,7 +33987,7 @@ const EMPTY_DEPENDENCY_INFO = {
|
|
|
33885
33987
|
const pickConcreteVersion = (packageJson, packageName, sections) => {
|
|
33886
33988
|
for (const section of sections) {
|
|
33887
33989
|
const version = packageJson[section]?.[packageName];
|
|
33888
|
-
if (version
|
|
33990
|
+
if (typeof version !== "string") continue;
|
|
33889
33991
|
if (isCatalogReference(version)) return null;
|
|
33890
33992
|
if (isConcreteDependencyVersion(version)) return version;
|
|
33891
33993
|
}
|
|
@@ -33917,13 +34019,16 @@ const extractDependencyInfo = (packageJson) => {
|
|
|
33917
34019
|
};
|
|
33918
34020
|
};
|
|
33919
34021
|
const getDependencySpec = (packageJson, packageName) => {
|
|
33920
|
-
const
|
|
33921
|
-
|
|
34022
|
+
for (const section of DEPENDENCY_SPEC_SECTIONS) {
|
|
34023
|
+
const spec = packageJson[section]?.[packageName];
|
|
34024
|
+
if (typeof spec === "string") return spec;
|
|
34025
|
+
}
|
|
34026
|
+
return null;
|
|
33922
34027
|
};
|
|
33923
34028
|
const getDependencyDeclaration = ({ packageJson, packageName, sections }) => {
|
|
33924
34029
|
for (const section of sections) {
|
|
33925
34030
|
const version = packageJson[section]?.[packageName];
|
|
33926
|
-
if (version
|
|
34031
|
+
if (typeof version !== "string") continue;
|
|
33927
34032
|
return {
|
|
33928
34033
|
catalogReference: extractCatalogName(version) ?? null,
|
|
33929
34034
|
hasDeclaration: true,
|
|
@@ -33957,11 +34062,15 @@ const getPreactVersion = (packageJson) => {
|
|
|
33957
34062
|
...packageJson.devDependencies
|
|
33958
34063
|
}.preact ?? null;
|
|
33959
34064
|
};
|
|
33960
|
-
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
34065
|
+
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, sourceDirectory = rootDirectory, sourcePackageJson = rootPackageJson, version }) => {
|
|
33961
34066
|
if (version === null || !isCatalogReference(version)) return version;
|
|
33962
34067
|
const catalogName = extractCatalogName(version);
|
|
33963
|
-
const
|
|
33964
|
-
if (
|
|
34068
|
+
const resolvedSourceVersion = resolveCatalogVersion(sourcePackageJson, packageName, sourceDirectory, catalogName);
|
|
34069
|
+
if (resolvedSourceVersion) return resolvedSourceVersion;
|
|
34070
|
+
if (sourceDirectory !== rootDirectory || sourcePackageJson !== rootPackageJson) {
|
|
34071
|
+
const resolvedRootVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
|
|
34072
|
+
if (resolvedRootVersion) return resolvedRootVersion;
|
|
34073
|
+
}
|
|
33965
34074
|
const monorepoRoot = findMonorepoRoot(rootDirectory);
|
|
33966
34075
|
if (!monorepoRoot) return version;
|
|
33967
34076
|
const monorepoPackageJsonPath = Path.join(monorepoRoot, "package.json");
|
|
@@ -34159,15 +34268,19 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34159
34268
|
}
|
|
34160
34269
|
return packages;
|
|
34161
34270
|
};
|
|
34271
|
+
const PREFERRED_DEPENDENCY_SECTIONS = [
|
|
34272
|
+
"dependencies",
|
|
34273
|
+
"peerDependencies",
|
|
34274
|
+
"devDependencies"
|
|
34275
|
+
];
|
|
34162
34276
|
const getPreferredDependencyVersion = ({ packageJson, packageNames }) => {
|
|
34163
|
-
const allDependencies = {
|
|
34164
|
-
...packageJson.devDependencies,
|
|
34165
|
-
...packageJson.peerDependencies,
|
|
34166
|
-
...packageJson.dependencies
|
|
34167
|
-
};
|
|
34168
34277
|
for (const packageName of packageNames) {
|
|
34169
|
-
const
|
|
34170
|
-
|
|
34278
|
+
const declaration = getDependencyDeclaration({
|
|
34279
|
+
packageJson,
|
|
34280
|
+
packageName,
|
|
34281
|
+
sections: PREFERRED_DEPENDENCY_SECTIONS
|
|
34282
|
+
});
|
|
34283
|
+
if (declaration.version !== null) return declaration.version;
|
|
34171
34284
|
}
|
|
34172
34285
|
return null;
|
|
34173
34286
|
};
|
|
@@ -34178,18 +34291,6 @@ const getTanStackQueryVersion = (packageJson) => {
|
|
|
34178
34291
|
packageNames: TANSTACK_REACT_QUERY_PACKAGES
|
|
34179
34292
|
});
|
|
34180
34293
|
};
|
|
34181
|
-
const MOBX_PACKAGES = [
|
|
34182
|
-
"mobx",
|
|
34183
|
-
"mobx-react",
|
|
34184
|
-
"mobx-react-lite",
|
|
34185
|
-
"mobx-state-tree"
|
|
34186
|
-
];
|
|
34187
|
-
const getMobxVersion = (packageJson) => {
|
|
34188
|
-
return getPreferredDependencyVersion({
|
|
34189
|
-
packageJson,
|
|
34190
|
-
packageNames: MOBX_PACKAGES
|
|
34191
|
-
});
|
|
34192
|
-
};
|
|
34193
34294
|
const STYLED_COMPONENTS_PACKAGES = ["styled-components"];
|
|
34194
34295
|
const getStyledComponentsVersion = (packageJson) => {
|
|
34195
34296
|
return getPreferredDependencyVersion({
|
|
@@ -34221,6 +34322,30 @@ const hasI18nDependency = (packageJson) => {
|
|
|
34221
34322
|
return I18N_PACKAGES.some((packageName) => allDependencies[packageName] !== void 0);
|
|
34222
34323
|
};
|
|
34223
34324
|
const REANIMATED_DEPENDENCY_NAME = "react-native-reanimated";
|
|
34325
|
+
const MOBX_REACT_PACKAGE_NAME = "mobx-react";
|
|
34326
|
+
const MOBX_REACT_LITE_PACKAGE_NAME = "mobx-react-lite";
|
|
34327
|
+
const MOBX_STATE_TREE_PACKAGE_NAME = "mobx-state-tree";
|
|
34328
|
+
const MOBX_REACT_OBSERVER_PACKAGE_NAME = "mobx-react-observer";
|
|
34329
|
+
const REACT_THREE_FIBER_DEPENDENCY_NAMES = ["@react-three/fiber", "react-three-fiber"];
|
|
34330
|
+
const REACT_THREE_FIBER_SECTIONS = [
|
|
34331
|
+
"dependencies",
|
|
34332
|
+
"peerDependencies",
|
|
34333
|
+
"optionalDependencies",
|
|
34334
|
+
"devDependencies"
|
|
34335
|
+
];
|
|
34336
|
+
const THREE_DEPENDENCY_SECTIONS = [
|
|
34337
|
+
"dependencies",
|
|
34338
|
+
"peerDependencies",
|
|
34339
|
+
"optionalDependencies",
|
|
34340
|
+
"devDependencies"
|
|
34341
|
+
];
|
|
34342
|
+
const REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES = [...REACT_THREE_FIBER_DEPENDENCY_NAMES, "@react-three/drei"];
|
|
34343
|
+
const THREE_DEPENDENCY_NAMES = [...REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES, "three"];
|
|
34344
|
+
const REACT_ROUTER_DEPENDENCY_NAMES = [
|
|
34345
|
+
"@react-router/dev",
|
|
34346
|
+
"react-router-dom",
|
|
34347
|
+
"react-router"
|
|
34348
|
+
];
|
|
34224
34349
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34225
34350
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34226
34351
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34231,7 +34356,7 @@ const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootD
|
|
|
34231
34356
|
if (!dependencyDeclaration.hasDeclaration) return null;
|
|
34232
34357
|
return concreteVersion ?? resolveCatalogVersion(workspacePackageJson, packageName, workspaceDirectory, dependencyDeclaration.catalogReference) ?? resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, dependencyDeclaration.catalogReference);
|
|
34233
34358
|
};
|
|
34234
|
-
const
|
|
34359
|
+
const shouldReplaceWithLowerMajor = (currentVersion, nextVersion) => {
|
|
34235
34360
|
if (!currentVersion) return true;
|
|
34236
34361
|
const currentMajor = parseReactMajor(currentVersion);
|
|
34237
34362
|
const nextMajor = parseReactMajor(nextVersion);
|
|
@@ -34239,15 +34364,71 @@ const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
|
34239
34364
|
if (nextMajor === null) return false;
|
|
34240
34365
|
return nextMajor < currentMajor;
|
|
34241
34366
|
};
|
|
34367
|
+
const shouldReplaceSupportedDependencyFact = (currentFact, nextFact, latestSupportedMajor) => {
|
|
34368
|
+
if (currentFact.version === null) return true;
|
|
34369
|
+
if (nextFact.version === null) return false;
|
|
34370
|
+
const currentMajor = getLowestDependencyMajor(currentFact.version);
|
|
34371
|
+
const nextMajor = getLowestDependencyMajor(nextFact.version);
|
|
34372
|
+
if (currentMajor === null) return false;
|
|
34373
|
+
if (nextMajor === null) return true;
|
|
34374
|
+
if (currentMajor > latestSupportedMajor) return false;
|
|
34375
|
+
if (nextMajor > latestSupportedMajor) return true;
|
|
34376
|
+
return nextMajor < currentMajor;
|
|
34377
|
+
};
|
|
34242
34378
|
const shouldReplaceStyledComponentsVersion = (currentVersion, nextVersion) => {
|
|
34243
34379
|
if (!currentVersion) return true;
|
|
34244
34380
|
const currentMajor = getLowestDependencyMajor(currentVersion);
|
|
34245
34381
|
const nextMajor = getLowestDependencyMajor(nextVersion);
|
|
34382
|
+
if (currentMajor === null) return nextMajor !== null && nextMajor < 6;
|
|
34383
|
+
if (nextMajor === null) return currentMajor >= 6;
|
|
34384
|
+
return nextMajor < currentMajor;
|
|
34385
|
+
};
|
|
34386
|
+
const selectOldestDependencyVersion = (currentVersion, nextVersion) => {
|
|
34387
|
+
if (currentVersion === null || nextVersion === null) return null;
|
|
34388
|
+
const current = parseDependencyMajorMinor(currentVersion);
|
|
34389
|
+
const next = parseDependencyMajorMinor(nextVersion);
|
|
34390
|
+
if (current === null) return currentVersion;
|
|
34391
|
+
if (next === null) return nextVersion;
|
|
34392
|
+
if (next.major !== current.major) return next.major < current.major ? nextVersion : currentVersion;
|
|
34393
|
+
return next.minor < current.minor ? nextVersion : currentVersion;
|
|
34394
|
+
};
|
|
34395
|
+
const shouldReplaceMobxFact = (currentFact, nextFact) => {
|
|
34396
|
+
if (currentFact.sourceDirectory === null) return true;
|
|
34397
|
+
if (currentFact.version === null) return false;
|
|
34398
|
+
if (nextFact.version === null) return true;
|
|
34399
|
+
const currentMajor = getDependencyMajorWithinSupportedRange(currentFact.version, 6);
|
|
34400
|
+
const nextMajor = getDependencyMajorWithinSupportedRange(nextFact.version, 6);
|
|
34246
34401
|
if (currentMajor === null) return false;
|
|
34247
34402
|
if (nextMajor === null) return true;
|
|
34248
|
-
return
|
|
34403
|
+
return selectOldestDependencyVersion(currentFact.version, nextFact.version) === nextFact.version;
|
|
34404
|
+
};
|
|
34405
|
+
const collectBindingVersion = (facts, packageJson, directory, packageName) => {
|
|
34406
|
+
const version = getDependencySpec(packageJson, packageName);
|
|
34407
|
+
if (version === null) return;
|
|
34408
|
+
const resolvedVersion = resolveCatalogBackedDependencyVersion({
|
|
34409
|
+
rootDirectory: directory,
|
|
34410
|
+
rootPackageJson: packageJson,
|
|
34411
|
+
packageName,
|
|
34412
|
+
version
|
|
34413
|
+
});
|
|
34414
|
+
if (packageName === MOBX_REACT_PACKAGE_NAME) {
|
|
34415
|
+
facts.mobxReactVersion = facts.hasMobxReact ? selectOldestDependencyVersion(facts.mobxReactVersion, resolvedVersion) : resolvedVersion;
|
|
34416
|
+
facts.hasMobxReact = true;
|
|
34417
|
+
return;
|
|
34418
|
+
}
|
|
34419
|
+
facts.mobxReactLiteVersion = facts.hasMobxReactLite ? selectOldestDependencyVersion(facts.mobxReactLiteVersion, resolvedVersion) : resolvedVersion;
|
|
34420
|
+
facts.hasMobxReactLite = true;
|
|
34249
34421
|
};
|
|
34250
|
-
const
|
|
34422
|
+
const shouldReplaceReactRouterVersion = (currentVersion, nextVersion) => {
|
|
34423
|
+
if (currentVersion === null) return true;
|
|
34424
|
+
const current = parseReactMajorMinor(currentVersion);
|
|
34425
|
+
const next = parseReactMajorMinor(nextVersion);
|
|
34426
|
+
if (current === null) return next !== null;
|
|
34427
|
+
if (next === null) return false;
|
|
34428
|
+
if (next.major !== current.major) return next.major < current.major;
|
|
34429
|
+
return next.minor < current.minor;
|
|
34430
|
+
};
|
|
34431
|
+
const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, rootPackageJson) => {
|
|
34251
34432
|
if (facts.expo.version === null) {
|
|
34252
34433
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34253
34434
|
if (spec !== null) facts.expo = {
|
|
@@ -34262,6 +34443,23 @@ const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
|
34262
34443
|
sourceDirectory: directory
|
|
34263
34444
|
};
|
|
34264
34445
|
}
|
|
34446
|
+
for (const packageName of REACT_ROUTER_DEPENDENCY_NAMES) {
|
|
34447
|
+
const resolvedSpec = resolveCatalogBackedDependencyVersion({
|
|
34448
|
+
rootDirectory,
|
|
34449
|
+
rootPackageJson,
|
|
34450
|
+
sourceDirectory: directory,
|
|
34451
|
+
sourcePackageJson: packageJson,
|
|
34452
|
+
packageName,
|
|
34453
|
+
version: getDependencySpec(packageJson, packageName)
|
|
34454
|
+
});
|
|
34455
|
+
if (resolvedSpec === null || !shouldReplaceReactRouterVersion(facts.reactRouter.version, resolvedSpec)) continue;
|
|
34456
|
+
facts.reactRouter = {
|
|
34457
|
+
version: resolvedSpec,
|
|
34458
|
+
sourceDirectory: directory,
|
|
34459
|
+
packageName
|
|
34460
|
+
};
|
|
34461
|
+
}
|
|
34462
|
+
facts.hasReactRouterFramework = facts.hasReactRouterFramework || getDependencySpec(packageJson, "@react-router/dev") !== null;
|
|
34265
34463
|
if (facts.shopifyFlashList.version === null) {
|
|
34266
34464
|
const spec = getDependencySpec(packageJson, SHOPIFY_FLASH_LIST_PACKAGE_NAME);
|
|
34267
34465
|
if (spec !== null) facts.shopifyFlashList = {
|
|
@@ -34269,18 +34467,113 @@ const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
|
34269
34467
|
sourceDirectory: directory
|
|
34270
34468
|
};
|
|
34271
34469
|
}
|
|
34470
|
+
const mobxSpec = getDependencySpec(packageJson, "mobx");
|
|
34471
|
+
if (mobxSpec !== null) {
|
|
34472
|
+
const nextMobxFact = {
|
|
34473
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34474
|
+
rootDirectory: directory,
|
|
34475
|
+
rootPackageJson: packageJson,
|
|
34476
|
+
packageName: "mobx",
|
|
34477
|
+
version: mobxSpec
|
|
34478
|
+
}),
|
|
34479
|
+
sourceDirectory: directory
|
|
34480
|
+
};
|
|
34481
|
+
if (shouldReplaceMobxFact(facts.mobx, nextMobxFact)) facts.mobx = nextMobxFact;
|
|
34482
|
+
}
|
|
34483
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_PACKAGE_NAME);
|
|
34484
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_LITE_PACKAGE_NAME);
|
|
34485
|
+
facts.hasMobxStateTree = facts.hasMobxStateTree || getDependencySpec(packageJson, MOBX_STATE_TREE_PACKAGE_NAME) !== null;
|
|
34486
|
+
facts.hasMobxReactObserver = facts.hasMobxReactObserver || getDependencySpec(packageJson, MOBX_REACT_OBSERVER_PACKAGE_NAME) !== null;
|
|
34487
|
+
const zustandSpec = getDependencySpec(packageJson, "zustand");
|
|
34488
|
+
if (zustandSpec !== null) {
|
|
34489
|
+
const nextZustandFact = {
|
|
34490
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34491
|
+
rootDirectory: directory,
|
|
34492
|
+
rootPackageJson: packageJson,
|
|
34493
|
+
packageName: "zustand",
|
|
34494
|
+
version: zustandSpec
|
|
34495
|
+
}),
|
|
34496
|
+
sourceDirectory: directory
|
|
34497
|
+
};
|
|
34498
|
+
if (shouldReplaceSupportedDependencyFact(facts.zustand, nextZustandFact, 5)) facts.zustand = nextZustandFact;
|
|
34499
|
+
}
|
|
34272
34500
|
if (facts.reanimatedVersion === null) {
|
|
34273
34501
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34274
34502
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34275
34503
|
}
|
|
34504
|
+
if (facts.valtioVersion === null) {
|
|
34505
|
+
const spec = getDependencySpec(packageJson, "valtio");
|
|
34506
|
+
if (spec !== null) facts.valtioVersion = spec;
|
|
34507
|
+
}
|
|
34276
34508
|
facts.tanstackQueryVersion ??= getTanStackQueryVersion(packageJson);
|
|
34277
|
-
|
|
34278
|
-
|
|
34509
|
+
const styledComponentsVersion = resolveCatalogBackedDependencyVersion({
|
|
34510
|
+
rootDirectory: directory,
|
|
34511
|
+
rootPackageJson: packageJson,
|
|
34512
|
+
packageName: "styled-components",
|
|
34513
|
+
version: getStyledComponentsVersion(packageJson)
|
|
34514
|
+
});
|
|
34279
34515
|
if (styledComponentsVersion && shouldReplaceStyledComponentsVersion(facts.styledComponentsVersion, styledComponentsVersion)) facts.styledComponentsVersion = styledComponentsVersion;
|
|
34280
34516
|
facts.hasI18nLibrary = facts.hasI18nLibrary || hasI18nDependency(packageJson);
|
|
34517
|
+
for (const packageName of REACT_THREE_FIBER_DEPENDENCY_NAMES) {
|
|
34518
|
+
const version = resolveCatalogBackedDependencyVersion({
|
|
34519
|
+
rootDirectory,
|
|
34520
|
+
rootPackageJson,
|
|
34521
|
+
sourceDirectory: directory,
|
|
34522
|
+
sourcePackageJson: packageJson,
|
|
34523
|
+
packageName,
|
|
34524
|
+
version: getDependencyDeclaration({
|
|
34525
|
+
packageName,
|
|
34526
|
+
packageJson,
|
|
34527
|
+
sections: REACT_THREE_FIBER_SECTIONS
|
|
34528
|
+
}).version
|
|
34529
|
+
});
|
|
34530
|
+
if (version === null) continue;
|
|
34531
|
+
if (shouldReplaceWithLowerMajor(facts.reactThreeFiber.version, version)) facts.reactThreeFiber = {
|
|
34532
|
+
packageName,
|
|
34533
|
+
version,
|
|
34534
|
+
sourceDirectory: directory
|
|
34535
|
+
};
|
|
34536
|
+
}
|
|
34537
|
+
const threeVersion = resolveCatalogBackedDependencyVersion({
|
|
34538
|
+
rootDirectory,
|
|
34539
|
+
rootPackageJson,
|
|
34540
|
+
sourceDirectory: directory,
|
|
34541
|
+
sourcePackageJson: packageJson,
|
|
34542
|
+
packageName: "three",
|
|
34543
|
+
version: getDependencyDeclaration({
|
|
34544
|
+
packageName: "three",
|
|
34545
|
+
packageJson,
|
|
34546
|
+
sections: THREE_DEPENDENCY_SECTIONS
|
|
34547
|
+
}).version
|
|
34548
|
+
});
|
|
34549
|
+
if (threeVersion !== null) {
|
|
34550
|
+
const currentRelease = parseThreeRelease(facts.threeVersion);
|
|
34551
|
+
const nextRelease = parseThreeRelease(threeVersion);
|
|
34552
|
+
if (facts.threeVersion === null || nextRelease !== null && (currentRelease === null || nextRelease < currentRelease)) facts.threeVersion = threeVersion;
|
|
34553
|
+
}
|
|
34281
34554
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34282
34555
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34283
34556
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34557
|
+
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34558
|
+
if (remotionSpec !== null) {
|
|
34559
|
+
facts.hasRemotionDependency = true;
|
|
34560
|
+
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34561
|
+
rootDirectory,
|
|
34562
|
+
rootPackageJson,
|
|
34563
|
+
packageName: "remotion",
|
|
34564
|
+
version: remotionSpec
|
|
34565
|
+
});
|
|
34566
|
+
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34567
|
+
if (remotionMajorVersion === null) {
|
|
34568
|
+
facts.hasUnknownRemotionVersion = true;
|
|
34569
|
+
facts.remotionVersion = null;
|
|
34570
|
+
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34571
|
+
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34572
|
+
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34573
|
+
}
|
|
34574
|
+
}
|
|
34575
|
+
facts.hasThree = facts.hasThree || THREE_DEPENDENCY_NAMES.some((dependencyName) => getDependencySpec(packageJson, dependencyName) !== null);
|
|
34576
|
+
facts.hasReactThreeFiber = facts.hasReactThreeFiber || REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES.some((dependencyName) => getDependencySpec(packageJson, dependencyName) !== null);
|
|
34284
34577
|
};
|
|
34285
34578
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34286
34579
|
const facts = {
|
|
@@ -34296,29 +34589,60 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34296
34589
|
version: null,
|
|
34297
34590
|
sourceDirectory: null
|
|
34298
34591
|
},
|
|
34592
|
+
reactRouter: {
|
|
34593
|
+
version: null,
|
|
34594
|
+
sourceDirectory: null,
|
|
34595
|
+
packageName: null
|
|
34596
|
+
},
|
|
34299
34597
|
shopifyFlashList: {
|
|
34300
34598
|
version: null,
|
|
34301
34599
|
sourceDirectory: null
|
|
34302
34600
|
},
|
|
34601
|
+
valtioVersion: null,
|
|
34602
|
+
mobx: {
|
|
34603
|
+
version: null,
|
|
34604
|
+
sourceDirectory: null
|
|
34605
|
+
},
|
|
34606
|
+
hasMobxReact: false,
|
|
34607
|
+
mobxReactVersion: null,
|
|
34608
|
+
hasMobxReactLite: false,
|
|
34609
|
+
mobxReactLiteVersion: null,
|
|
34610
|
+
hasMobxStateTree: false,
|
|
34611
|
+
hasMobxReactObserver: false,
|
|
34612
|
+
zustand: {
|
|
34613
|
+
version: null,
|
|
34614
|
+
sourceDirectory: null
|
|
34615
|
+
},
|
|
34303
34616
|
tanstackQueryVersion: null,
|
|
34304
|
-
mobxVersion: null,
|
|
34305
34617
|
styledComponentsVersion: null,
|
|
34306
34618
|
hasI18nLibrary: false,
|
|
34307
34619
|
hasReactNativeAwarePackage: false,
|
|
34308
34620
|
hasReanimatedAwarePackage: false,
|
|
34309
34621
|
hasSsrDependency: false,
|
|
34622
|
+
hasRemotionDependency: false,
|
|
34623
|
+
hasUnknownRemotionVersion: false,
|
|
34624
|
+
remotionVersion: null,
|
|
34625
|
+
hasThree: false,
|
|
34626
|
+
threeVersion: null,
|
|
34627
|
+
hasReactThreeFiber: false,
|
|
34628
|
+
reactThreeFiber: {
|
|
34629
|
+
packageName: null,
|
|
34630
|
+
version: null,
|
|
34631
|
+
sourceDirectory: null
|
|
34632
|
+
},
|
|
34633
|
+
hasReactRouterFramework: false,
|
|
34310
34634
|
reanimatedVersion: null
|
|
34311
34635
|
};
|
|
34312
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34636
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory, rootDirectory, rootPackageJson);
|
|
34313
34637
|
let isReactGroupSettled = !collectReactGroup;
|
|
34314
34638
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34315
34639
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
34316
|
-
const directories =
|
|
34640
|
+
const directories = resolveWorkspaceDirectories(rootDirectory, pattern).toSorted();
|
|
34317
34641
|
for (const workspaceDirectory of directories) {
|
|
34318
34642
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34319
34643
|
visitedDirectories.add(workspaceDirectory);
|
|
34320
34644
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34321
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34645
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory, rootDirectory, rootPackageJson);
|
|
34322
34646
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34323
34647
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34324
34648
|
if (isReactGroupSettled) continue;
|
|
@@ -34349,7 +34673,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34349
34673
|
workspaceDirectory,
|
|
34350
34674
|
workspacePackageJson
|
|
34351
34675
|
});
|
|
34352
|
-
if (reactVersion &&
|
|
34676
|
+
if (reactVersion && shouldReplaceWithLowerMajor(facts.reactVersion, reactVersion)) facts.reactVersion = reactVersion;
|
|
34353
34677
|
if (tailwindVersion && !facts.tailwindVersion) facts.tailwindVersion = tailwindVersion;
|
|
34354
34678
|
if (zodVersion && !facts.zodVersion) facts.zodVersion = zodVersion;
|
|
34355
34679
|
const settledReactMajor = parseReactMajor(facts.reactVersion);
|
|
@@ -34542,21 +34866,43 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34542
34866
|
tailwindVersion: null,
|
|
34543
34867
|
zodVersion: null,
|
|
34544
34868
|
zodMajorVersion: null,
|
|
34869
|
+
mobxVersion: null,
|
|
34870
|
+
mobxMajorVersion: null,
|
|
34871
|
+
hasMobxReact: false,
|
|
34872
|
+
mobxReactVersion: null,
|
|
34873
|
+
hasMobxReactLite: false,
|
|
34874
|
+
mobxReactLiteVersion: null,
|
|
34875
|
+
hasMobxStateTree: false,
|
|
34876
|
+
hasMobxReactObserver: false,
|
|
34877
|
+
zustandVersion: null,
|
|
34878
|
+
zustandMajorVersion: null,
|
|
34545
34879
|
framework: "unknown",
|
|
34546
34880
|
hasTypeScript: hasOwnTsConfig,
|
|
34547
34881
|
hasReactCompiler: false,
|
|
34548
34882
|
hasReactCompilerLintPlugin: false,
|
|
34549
34883
|
hasTanStackQuery: false,
|
|
34884
|
+
valtioVersion: null,
|
|
34885
|
+
valtioMajorVersion: null,
|
|
34886
|
+
hasRemotion: false,
|
|
34887
|
+
remotionVersion: null,
|
|
34888
|
+
remotionMajorVersion: null,
|
|
34550
34889
|
hasI18nLibrary: false,
|
|
34551
34890
|
tanstackQueryVersion: null,
|
|
34552
|
-
mobxVersion: null,
|
|
34553
34891
|
styledComponentsVersion: null,
|
|
34892
|
+
hasThree: false,
|
|
34893
|
+
threeVersion: null,
|
|
34894
|
+
threeRelease: null,
|
|
34895
|
+
hasReactThreeFiber: false,
|
|
34896
|
+
reactThreeFiberVersion: null,
|
|
34897
|
+
reactThreeFiberMajorVersion: null,
|
|
34554
34898
|
hasSsrDependency: false,
|
|
34555
34899
|
preactVersion: null,
|
|
34556
34900
|
preactMajorVersion: null,
|
|
34557
34901
|
hasReactNativeWorkspace: false,
|
|
34558
34902
|
nextjsVersion: null,
|
|
34559
34903
|
nextjsMajorVersion: null,
|
|
34904
|
+
reactRouterVersion: null,
|
|
34905
|
+
hasReactRouterFramework: false,
|
|
34560
34906
|
expoVersion: null,
|
|
34561
34907
|
shopifyFlashListVersion: null,
|
|
34562
34908
|
shopifyFlashListMajorVersion: null,
|
|
@@ -34649,6 +34995,12 @@ const discoverProject = (directory) => {
|
|
|
34649
34995
|
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
34650
34996
|
version: workspaceFacts.shopifyFlashList.version
|
|
34651
34997
|
}) : null;
|
|
34998
|
+
const zustandVersion = resolveCatalogBackedDependencyVersion({
|
|
34999
|
+
rootDirectory: directory,
|
|
35000
|
+
rootPackageJson: packageJson,
|
|
35001
|
+
packageName: "zustand",
|
|
35002
|
+
version: workspaceFacts.zustand.version
|
|
35003
|
+
});
|
|
34652
35004
|
const hasReanimated = hasReactNativeWorkspace && workspaceFacts.hasReanimatedAwarePackage;
|
|
34653
35005
|
const reanimatedVersion = hasReanimated ? workspaceFacts.reanimatedVersion : null;
|
|
34654
35006
|
const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
|
|
@@ -34657,8 +35009,39 @@ const discoverProject = (directory) => {
|
|
|
34657
35009
|
packageName: "next",
|
|
34658
35010
|
version: workspaceFacts.next.version
|
|
34659
35011
|
}) : null;
|
|
35012
|
+
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
35013
|
+
rootDirectory: directory,
|
|
35014
|
+
rootPackageJson: packageJson,
|
|
35015
|
+
packageName: "valtio",
|
|
35016
|
+
version: workspaceFacts.valtioVersion
|
|
35017
|
+
});
|
|
35018
|
+
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
35019
|
+
rootDirectory: directory,
|
|
35020
|
+
rootPackageJson: packageJson,
|
|
35021
|
+
packageName: "mobx",
|
|
35022
|
+
version: workspaceFacts.mobx.version
|
|
35023
|
+
});
|
|
35024
|
+
const reactRouterVersion = workspaceFacts.reactRouter.packageName === null ? null : resolveCatalogBackedDependencyVersion({
|
|
35025
|
+
rootDirectory: directory,
|
|
35026
|
+
rootPackageJson: packageJson,
|
|
35027
|
+
packageName: workspaceFacts.reactRouter.packageName,
|
|
35028
|
+
version: workspaceFacts.reactRouter.version
|
|
35029
|
+
});
|
|
34660
35030
|
const preactVersion = getPreactVersion(packageJson);
|
|
35031
|
+
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34661
35032
|
const tanstackQueryVersion = getTanStackQueryVersion(packageJson) ?? workspaceFacts.tanstackQueryVersion;
|
|
35033
|
+
const reactThreeFiberVersion = workspaceFacts.reactThreeFiber.packageName ? resolveCatalogBackedDependencyVersion({
|
|
35034
|
+
rootDirectory: directory,
|
|
35035
|
+
rootPackageJson: packageJson,
|
|
35036
|
+
packageName: workspaceFacts.reactThreeFiber.packageName,
|
|
35037
|
+
version: workspaceFacts.reactThreeFiber.version
|
|
35038
|
+
}) : null;
|
|
35039
|
+
const threeVersion = resolveCatalogBackedDependencyVersion({
|
|
35040
|
+
rootDirectory: directory,
|
|
35041
|
+
rootPackageJson: packageJson,
|
|
35042
|
+
packageName: "three",
|
|
35043
|
+
version: workspaceFacts.threeVersion
|
|
35044
|
+
});
|
|
34662
35045
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34663
35046
|
const projectInfo = {
|
|
34664
35047
|
rootDirectory: directory,
|
|
@@ -34668,6 +35051,16 @@ const discoverProject = (directory) => {
|
|
|
34668
35051
|
tailwindVersion,
|
|
34669
35052
|
zodVersion,
|
|
34670
35053
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
35054
|
+
mobxVersion,
|
|
35055
|
+
mobxMajorVersion: mobxVersion === null ? null : getDependencyMajorWithinSupportedRange(mobxVersion, 6),
|
|
35056
|
+
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
35057
|
+
mobxReactVersion: workspaceFacts.mobxReactVersion,
|
|
35058
|
+
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
35059
|
+
mobxReactLiteVersion: workspaceFacts.mobxReactLiteVersion,
|
|
35060
|
+
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
35061
|
+
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
35062
|
+
zustandVersion,
|
|
35063
|
+
zustandMajorVersion: zustandVersion === null ? null : getLowestDependencyMajor(zustandVersion),
|
|
34671
35064
|
framework,
|
|
34672
35065
|
hasTypeScript,
|
|
34673
35066
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
@@ -34675,14 +35068,26 @@ const discoverProject = (directory) => {
|
|
|
34675
35068
|
hasTanStackQuery: tanstackQueryVersion !== null,
|
|
34676
35069
|
hasI18nLibrary: workspaceFacts.hasI18nLibrary,
|
|
34677
35070
|
tanstackQueryVersion,
|
|
34678
|
-
mobxVersion: workspaceFacts.mobxVersion,
|
|
34679
35071
|
styledComponentsVersion: workspaceFacts.styledComponentsVersion,
|
|
35072
|
+
valtioVersion,
|
|
35073
|
+
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
35074
|
+
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
35075
|
+
remotionVersion,
|
|
35076
|
+
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
35077
|
+
hasThree: workspaceFacts.hasThree,
|
|
35078
|
+
threeVersion,
|
|
35079
|
+
threeRelease: parseThreeRelease(threeVersion),
|
|
35080
|
+
hasReactThreeFiber: workspaceFacts.hasReactThreeFiber,
|
|
35081
|
+
reactThreeFiberVersion,
|
|
35082
|
+
reactThreeFiberMajorVersion: reactThreeFiberVersion === null ? null : getLowestDependencyMajor(reactThreeFiberVersion),
|
|
34680
35083
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34681
35084
|
preactVersion,
|
|
34682
35085
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
34683
35086
|
hasReactNativeWorkspace,
|
|
34684
35087
|
nextjsVersion,
|
|
34685
35088
|
nextjsMajorVersion: nextjsVersion === null ? null : getLowestDependencyMajor(nextjsVersion),
|
|
35089
|
+
reactRouterVersion,
|
|
35090
|
+
hasReactRouterFramework: workspaceFacts.hasReactRouterFramework,
|
|
34686
35091
|
expoVersion,
|
|
34687
35092
|
shopifyFlashListVersion,
|
|
34688
35093
|
shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
|
|
@@ -37122,9 +37527,25 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37122
37527
|
".babelrc.json"
|
|
37123
37528
|
];
|
|
37124
37529
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37530
|
+
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37531
|
+
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37532
|
+
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37533
|
+
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37125
37534
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37126
37535
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37536
|
+
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37537
|
+
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37538
|
+
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37539
|
+
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37540
|
+
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37541
|
+
if (normalizedVersionRange === null) return false;
|
|
37542
|
+
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37543
|
+
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37544
|
+
};
|
|
37545
|
+
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37127
37546
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37547
|
+
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37548
|
+
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37128
37549
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37129
37550
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37130
37551
|
if (!isFile(filePath)) continue;
|
|
@@ -37134,7 +37555,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37134
37555
|
} catch {
|
|
37135
37556
|
continue;
|
|
37136
37557
|
}
|
|
37137
|
-
if (
|
|
37558
|
+
if (shouldReportLegacyPreset && LEGACY_PRESET_REFERENCE.test(contents)) return [buildReactNativeDiagnostic({
|
|
37138
37559
|
filePath: fileName,
|
|
37139
37560
|
rule: "rn-no-metro-babel-preset",
|
|
37140
37561
|
severity: "error",
|
|
@@ -37157,12 +37578,6 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37157
37578
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37158
37579
|
};
|
|
37159
37580
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37160
|
-
const DEPENDENCY_SECTIONS = [
|
|
37161
|
-
"dependencies",
|
|
37162
|
-
"devDependencies",
|
|
37163
|
-
"peerDependencies",
|
|
37164
|
-
"optionalDependencies"
|
|
37165
|
-
];
|
|
37166
37581
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37167
37582
|
"19.0": {
|
|
37168
37583
|
rceFixedVersion: "19.0.1",
|
|
@@ -37209,20 +37624,13 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37209
37624
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37210
37625
|
return [...directories];
|
|
37211
37626
|
};
|
|
37212
|
-
const readDeclaredSpec = (packageJson, packageName) => {
|
|
37213
|
-
for (const section of DEPENDENCY_SECTIONS) {
|
|
37214
|
-
const spec = packageJson[section]?.[packageName];
|
|
37215
|
-
if (typeof spec === "string") return spec;
|
|
37216
|
-
}
|
|
37217
|
-
return null;
|
|
37218
|
-
};
|
|
37219
37627
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37220
37628
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37221
37629
|
if (isFile(manifestPath)) {
|
|
37222
37630
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37223
37631
|
if (installedVersion !== null) return installedVersion;
|
|
37224
37632
|
}
|
|
37225
|
-
const candidateSpecs = [
|
|
37633
|
+
const candidateSpecs = [getDependencySpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37226
37634
|
for (const spec of candidateSpecs) {
|
|
37227
37635
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37228
37636
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -37874,10 +38282,10 @@ const SSR_FRAMEWORKS = new Set([
|
|
|
37874
38282
|
"gatsby",
|
|
37875
38283
|
"tanstack-start"
|
|
37876
38284
|
]);
|
|
37877
|
-
const
|
|
37878
|
-
if (
|
|
37879
|
-
const
|
|
37880
|
-
for (let candidate = earliest; candidate <=
|
|
38285
|
+
const addVersionCapabilityLadder = (capabilities, name, detectedVersion, earliest, latest) => {
|
|
38286
|
+
if (detectedVersion === null) return;
|
|
38287
|
+
const cappedVersion = Math.min(detectedVersion, latest);
|
|
38288
|
+
for (let candidate = earliest; candidate <= cappedVersion; candidate += 1) capabilities.add(`${name}:${candidate}`);
|
|
37881
38289
|
};
|
|
37882
38290
|
const buildCapabilities = (project) => {
|
|
37883
38291
|
const capabilities = /* @__PURE__ */ new Set();
|
|
@@ -37891,31 +38299,85 @@ const buildCapabilities = (project) => {
|
|
|
37891
38299
|
if (project.isStaticExport) capabilities.add("nextjs:static-export");
|
|
37892
38300
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
37893
38301
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 16) capabilities.add("nextjs:16");
|
|
37894
|
-
|
|
38302
|
+
const reactRouterVersion = project.reactRouterVersion ?? null;
|
|
38303
|
+
if (reactRouterVersion !== null) {
|
|
38304
|
+
capabilities.add("react-router");
|
|
38305
|
+
if (project.hasReactRouterFramework === true) capabilities.add("react-router-framework");
|
|
38306
|
+
const detectedVersion = parseReactMajorMinor(reactRouterVersion);
|
|
38307
|
+
if (detectedVersion !== null) {
|
|
38308
|
+
for (const threshold of REACT_ROUTER_CAPABILITY_THRESHOLDS) if (isMajorMinorAtLeast(detectedVersion, threshold)) capabilities.add(threshold.capability);
|
|
38309
|
+
}
|
|
38310
|
+
}
|
|
38311
|
+
addVersionCapabilityLadder(capabilities, "react", project.reactMajorVersion, 17, 30);
|
|
37895
38312
|
if (project.reactMajorVersion !== null && project.reactMajorVersion >= 19 && isMajorMinorAtLeast(parseReactMajorMinor(project.reactVersion), {
|
|
37896
38313
|
major: 19,
|
|
37897
38314
|
minor: 2
|
|
37898
38315
|
})) capabilities.add("react:19.2");
|
|
37899
|
-
if (project.tailwindVersion !== null)
|
|
37900
|
-
|
|
37901
|
-
|
|
37902
|
-
|
|
37903
|
-
|
|
38316
|
+
if (project.tailwindVersion !== null) {
|
|
38317
|
+
capabilities.add("tailwind");
|
|
38318
|
+
const tailwindVersion = parseTailwindMajorMinor(project.tailwindVersion);
|
|
38319
|
+
if (isMajorMinorAtLeast(tailwindVersion, {
|
|
38320
|
+
major: 3,
|
|
38321
|
+
minor: 4
|
|
38322
|
+
})) capabilities.add("tailwind:3.4");
|
|
38323
|
+
if (tailwindVersion !== null && isMajorMinorAtLeast(tailwindVersion, {
|
|
38324
|
+
major: 4,
|
|
38325
|
+
minor: 0
|
|
38326
|
+
})) capabilities.add("tailwind:4");
|
|
38327
|
+
}
|
|
37904
38328
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
37905
38329
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
38330
|
+
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
38331
|
+
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
38332
|
+
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
38333
|
+
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
38334
|
+
const mobxReactVersion = parseDependencyMajorMinor(project.mobxReactVersion);
|
|
38335
|
+
const mobxReactLiteVersion = parseDependencyMajorMinor(project.mobxReactLiteVersion);
|
|
38336
|
+
const hasMobxReactObserverMemoGuard = mobxReactVersion !== null && isMajorMinorAtLeast(mobxReactVersion, {
|
|
38337
|
+
major: 7,
|
|
38338
|
+
minor: 3
|
|
38339
|
+
});
|
|
38340
|
+
const hasMobxReactLiteObserverMemoGuard = mobxReactLiteVersion !== null && isMajorMinorAtLeast(mobxReactLiteVersion, {
|
|
38341
|
+
major: 3,
|
|
38342
|
+
minor: 3
|
|
38343
|
+
});
|
|
38344
|
+
if (hasMobxReactObserverMemoGuard) capabilities.add("mobx-react-observer-memo-guard");
|
|
38345
|
+
if (hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-lite-observer-memo-guard");
|
|
38346
|
+
if (hasMobxReactObserverMemoGuard || hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-binding-observer-memo-guard");
|
|
38347
|
+
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
38348
|
+
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
38349
|
+
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addVersionCapabilityLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
38350
|
+
const mobxVersion = parseDependencyMajorMinor(project.mobxVersion);
|
|
38351
|
+
if (project.mobxMajorVersion === 6 && mobxVersion !== null && isMajorMinorAtLeast(mobxVersion, {
|
|
38352
|
+
major: 6,
|
|
38353
|
+
minor: 10
|
|
38354
|
+
})) capabilities.add("mobx:6.10");
|
|
38355
|
+
if (project.zustandVersion !== void 0 && project.zustandVersion !== null) capabilities.add("zustand");
|
|
38356
|
+
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addVersionCapabilityLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
37906
38357
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
37907
38358
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
37908
38359
|
if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
|
|
37909
|
-
if (project.mobxVersion) capabilities.add("mobx");
|
|
37910
38360
|
if (project.styledComponentsVersion) {
|
|
37911
38361
|
capabilities.add("styled-components");
|
|
37912
38362
|
const styledComponentsMajor = getLowestDependencyMajor(project.styledComponentsVersion);
|
|
37913
38363
|
if (styledComponentsMajor !== null && styledComponentsMajor >= 6) capabilities.add("styled-components:6");
|
|
37914
38364
|
}
|
|
37915
38365
|
if (project.hasI18nLibrary) capabilities.add("i18n");
|
|
38366
|
+
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
38367
|
+
addVersionCapabilityLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
38368
|
+
if (project.hasRemotion) {
|
|
38369
|
+
capabilities.add("remotion");
|
|
38370
|
+
addVersionCapabilityLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
38371
|
+
}
|
|
38372
|
+
if (project.hasThree || project.hasReactThreeFiber) capabilities.add("three");
|
|
38373
|
+
addVersionCapabilityLadder(capabilities, "three", project.threeRelease ?? null, 145, 250);
|
|
38374
|
+
if (project.hasReactThreeFiber) {
|
|
38375
|
+
capabilities.add("r3f");
|
|
38376
|
+
addVersionCapabilityLadder(capabilities, "r3f", project.reactThreeFiberMajorVersion ?? null, 3, 10);
|
|
38377
|
+
}
|
|
37916
38378
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
37917
38379
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
37918
|
-
|
|
38380
|
+
addVersionCapabilityLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
37919
38381
|
if (project.preactVersion !== null && project.reactVersion === null) capabilities.add("pure-preact");
|
|
37920
38382
|
return capabilities;
|
|
37921
38383
|
};
|
|
@@ -37927,7 +38389,7 @@ const getCapabilities = (project) => {
|
|
|
37927
38389
|
capabilitiesByProject.set(project, capabilities);
|
|
37928
38390
|
return capabilities;
|
|
37929
38391
|
};
|
|
37930
|
-
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen) => {
|
|
38392
|
+
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen, includedTags) => {
|
|
37931
38393
|
if (requires) {
|
|
37932
38394
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
37933
38395
|
}
|
|
@@ -37938,20 +38400,29 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhe
|
|
|
37938
38400
|
if (tags) {
|
|
37939
38401
|
for (const tag of tags) if (ignoredTags.has(tag)) return false;
|
|
37940
38402
|
}
|
|
38403
|
+
if (includedTags && includedTags.size > 0) {
|
|
38404
|
+
if (!tags?.some((tag) => includedTags.has(tag))) return false;
|
|
38405
|
+
}
|
|
37941
38406
|
return true;
|
|
37942
38407
|
};
|
|
38408
|
+
const shouldEnableRuleByDefaultStatus = (options) => options.defaultEnabled !== false || options.hasExplicitOverride === true || options.includeTagDefaults && options.hasIncludedTags;
|
|
37943
38409
|
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
37944
38410
|
setImmediate(resolve);
|
|
37945
38411
|
});
|
|
37946
38412
|
const createSecurityScanSession = (rootDirectory, options) => {
|
|
37947
38413
|
const capabilities = options.project ? getCapabilities(options.project) : /* @__PURE__ */ new Set();
|
|
37948
38414
|
const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
|
|
38415
|
+
const includedTags = options.includedTags ?? /* @__PURE__ */ new Set();
|
|
37949
38416
|
const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
|
|
37950
38417
|
const rule = entry.rule;
|
|
37951
38418
|
const scan = rule.scan;
|
|
37952
38419
|
if (typeof scan !== "function") return [];
|
|
37953
|
-
if (
|
|
37954
|
-
|
|
38420
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
38421
|
+
defaultEnabled: rule.defaultEnabled,
|
|
38422
|
+
includeTagDefaults: options.includeTagDefaults === true,
|
|
38423
|
+
hasIncludedTags: includedTags.size > 0
|
|
38424
|
+
})) return [];
|
|
38425
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) return [];
|
|
37955
38426
|
return [{
|
|
37956
38427
|
entry,
|
|
37957
38428
|
scan,
|
|
@@ -39937,8 +40408,9 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
39937
40408
|
}
|
|
39938
40409
|
return enabled;
|
|
39939
40410
|
};
|
|
39940
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
39941
|
-
const
|
|
40411
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
40412
|
+
const hasIncludedTags = includedTags.size > 0;
|
|
40413
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
39942
40414
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
39943
40415
|
const jsPlugins = [];
|
|
39944
40416
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -39953,9 +40425,14 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39953
40425
|
if (rule.scan !== void 0) continue;
|
|
39954
40426
|
if (customRulesOnly && registryEntry.originallyExternal) continue;
|
|
39955
40427
|
if (rule.framework !== "global" && !rule.requires) continue;
|
|
39956
|
-
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen)) continue;
|
|
40428
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) continue;
|
|
39957
40429
|
const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
|
|
39958
|
-
if (
|
|
40430
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
40431
|
+
defaultEnabled: rule.defaultEnabled,
|
|
40432
|
+
includeTagDefaults,
|
|
40433
|
+
hasIncludedTags,
|
|
40434
|
+
hasExplicitOverride: explicitRuleOverride !== void 0
|
|
40435
|
+
})) continue;
|
|
39959
40436
|
const severity = resolveRuleSeverityOverride({
|
|
39960
40437
|
ruleKey: registryEntry.key,
|
|
39961
40438
|
category: rule.category
|
|
@@ -39964,7 +40441,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39964
40441
|
enabledReactDoctorRules[registryEntry.key] = severity;
|
|
39965
40442
|
}
|
|
39966
40443
|
const userPluginRules = {};
|
|
39967
|
-
if (ruleSelection !== "sidecar") for (const userPlugin of userPlugins) {
|
|
40444
|
+
if (ruleSelection !== "sidecar" && !hasIncludedTags) for (const userPlugin of userPlugins) {
|
|
39968
40445
|
Object.assign(userPluginRules, buildUserPluginRules(userPlugin, severityControls));
|
|
39969
40446
|
jsPlugins.push(userPlugin.entry);
|
|
39970
40447
|
}
|
|
@@ -41709,7 +42186,7 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
41709
42186
|
* 6. always restore disable directives + clean up the temp dir
|
|
41710
42187
|
*/
|
|
41711
42188
|
const runOxlint = async (options) => {
|
|
41712
|
-
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;
|
|
42189
|
+
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;
|
|
41713
42190
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
41714
42191
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
41715
42192
|
validateRuleRegistration();
|
|
@@ -41723,13 +42200,15 @@ const runOxlint = async (options) => {
|
|
|
41723
42200
|
}
|
|
41724
42201
|
const pluginPath = resolvePluginPath();
|
|
41725
42202
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
41726
|
-
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
42203
|
+
const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
41727
42204
|
const buildConfig = (overrides) => createOxlintConfig({
|
|
41728
42205
|
pluginPath,
|
|
41729
42206
|
project,
|
|
41730
42207
|
customRulesOnly,
|
|
41731
42208
|
extendsPaths: overrides.extendsPaths,
|
|
41732
42209
|
ignoredTags,
|
|
42210
|
+
includedTags,
|
|
42211
|
+
includeTagDefaults,
|
|
41733
42212
|
serverAuthFunctionNames,
|
|
41734
42213
|
severityControls,
|
|
41735
42214
|
userPlugins,
|
|
@@ -42118,6 +42597,8 @@ var Linter = class Linter extends Service()("react-doctor/Linter") {
|
|
|
42118
42597
|
respectInlineDisables: input.respectInlineDisables,
|
|
42119
42598
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42120
42599
|
ignoredTags: input.ignoredTags,
|
|
42600
|
+
includedTags: input.includedTags,
|
|
42601
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
42121
42602
|
userConfig: input.userConfig ?? null,
|
|
42122
42603
|
configSourceDirectory: input.configSourceDirectory,
|
|
42123
42604
|
onPartialFailure: (reason) => {
|
|
@@ -42966,7 +43447,9 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42966
43447
|
const securityScanFailedRef = yield* make$13(false);
|
|
42967
43448
|
const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(tryPromise(() => checkSecurityScanCooperative(scanDirectory, {
|
|
42968
43449
|
project,
|
|
42969
|
-
ignoredTags: input.ignoredTags
|
|
43450
|
+
ignoredTags: input.ignoredTags,
|
|
43451
|
+
includedTags: input.includedTags,
|
|
43452
|
+
includeTagDefaults: input.includeTagDefaults
|
|
42970
43453
|
})).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), catch_$1(() => set(securityScanFailedRef, true).pipe(as(empty$4))))))).pipe(withSpan("SecurityScan.run")));
|
|
42971
43454
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
42972
43455
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
@@ -43057,6 +43540,8 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
43057
43540
|
respectInlineDisables: input.respectInlineDisables,
|
|
43058
43541
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
43059
43542
|
ignoredTags: input.ignoredTags,
|
|
43543
|
+
includedTags: input.includedTags,
|
|
43544
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
43060
43545
|
userConfig: resolvedConfig.config ?? void 0,
|
|
43061
43546
|
configSourceDirectory: resolvedConfig.configSourceDirectory ?? void 0,
|
|
43062
43547
|
onFileProgress: (scannedFileCount, totalFileCount) => {
|
|
@@ -45559,5 +46044,5 @@ const startLanguageServer = () => {
|
|
|
45559
46044
|
};
|
|
45560
46045
|
//#endregion
|
|
45561
46046
|
export { startLanguageServer };
|
|
45562
|
-
!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]="
|
|
45563
|
-
//# debugId=
|
|
46047
|
+
!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]="f391589f-4666-5b19-95b9-028be54a868d")}catch(e){}}();
|
|
46048
|
+
//# debugId=f391589f-4666-5b19-95b9-028be54a868d
|