react-doctor 0.8.1-dev.412377e → 0.8.1-dev.5332cb6
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 +4 -14
- package/dist/cli.js +159 -793
- package/dist/index.d.ts +0 -45
- package/dist/index.js +115 -702
- package/dist/lsp.js +115 -702
- package/dist/skills/react-doctor/SKILL.md +0 -5
- package/package.json +3 -3
package/dist/lsp.js
CHANGED
|
@@ -32883,6 +32883,44 @@ 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
|
+
};
|
|
32886
32924
|
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
|
|
32887
32925
|
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
32888
32926
|
const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
|
|
@@ -32923,58 +32961,6 @@ const IGNORED_DIRECTORIES = new Set([
|
|
|
32923
32961
|
"storybook-static"
|
|
32924
32962
|
]);
|
|
32925
32963
|
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
|
-
];
|
|
32978
32964
|
const SCORE_API_URL = "https://www.react.doctor/api/score";
|
|
32979
32965
|
const FETCH_TIMEOUT_MS = 1e4;
|
|
32980
32966
|
const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
|
|
@@ -33116,44 +33102,6 @@ const SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS = 9e4;
|
|
|
33116
33102
|
const SUPPLY_CHAIN_CACHE_TTL_MS = 864e5;
|
|
33117
33103
|
const SUPPLY_CHAIN_CACHE_SUBDIR = "supply-chain";
|
|
33118
33104
|
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
|
-
};
|
|
33157
33105
|
const lastSourceMappingUrl = (fileContent) => {
|
|
33158
33106
|
const lastReference = [...fileContent.matchAll(/\/\/# sourceMappingURL=(\S+)/g)].at(-1);
|
|
33159
33107
|
return lastReference ? lastReference[1] : null;
|
|
@@ -33479,10 +33427,10 @@ const FALLBACK_TSCONFIG_FILENAMES = ["tsconfig.app.json", "tsconfig.build.json"]
|
|
|
33479
33427
|
const FRAMEWORK_PACKAGES = {
|
|
33480
33428
|
next: "nextjs",
|
|
33481
33429
|
"@tanstack/react-start": "tanstack-start",
|
|
33482
|
-
"@remix-run/react": "remix",
|
|
33483
|
-
gatsby: "gatsby",
|
|
33484
33430
|
vite: "vite",
|
|
33485
33431
|
"react-scripts": "cra",
|
|
33432
|
+
"@remix-run/react": "remix",
|
|
33433
|
+
gatsby: "gatsby",
|
|
33486
33434
|
expo: "expo",
|
|
33487
33435
|
"react-native": "react-native"
|
|
33488
33436
|
};
|
|
@@ -33506,17 +33454,11 @@ const NEXT_CONFIG_FILENAMES = [
|
|
|
33506
33454
|
];
|
|
33507
33455
|
const BABEL_CONFIG_FILENAMES = [
|
|
33508
33456
|
".babelrc",
|
|
33509
|
-
".babelrc.js",
|
|
33510
33457
|
".babelrc.json",
|
|
33511
|
-
".babelrc.cjs",
|
|
33512
|
-
".babelrc.mjs",
|
|
33513
|
-
".babelrc.cts",
|
|
33514
33458
|
"babel.config.js",
|
|
33515
33459
|
"babel.config.json",
|
|
33516
33460
|
"babel.config.cjs",
|
|
33517
|
-
"babel.config.mjs"
|
|
33518
|
-
"babel.config.ts",
|
|
33519
|
-
"babel.config.cts"
|
|
33461
|
+
"babel.config.mjs"
|
|
33520
33462
|
];
|
|
33521
33463
|
const VITE_CONFIG_FILENAMES = [
|
|
33522
33464
|
"vite.config.js",
|
|
@@ -33528,28 +33470,12 @@ const VITE_CONFIG_FILENAMES = [
|
|
|
33528
33470
|
"vitest.config.ts",
|
|
33529
33471
|
"vitest.config.js"
|
|
33530
33472
|
];
|
|
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
|
-
];
|
|
33547
33473
|
const EXPO_APP_CONFIG_FILENAMES = [
|
|
33548
33474
|
"app.json",
|
|
33549
33475
|
"app.config.js",
|
|
33550
33476
|
"app.config.ts"
|
|
33551
33477
|
];
|
|
33552
|
-
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|
|
|
33478
|
+
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|["']react-compiler["']/;
|
|
33553
33479
|
const REACT_COMPILER_ENABLED_FLAG_PATTERN = /["']?reactCompiler["']?\s*:\s*(?:true\b|\{)/;
|
|
33554
33480
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
33555
33481
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
@@ -33584,8 +33510,6 @@ const detectReactCompiler = (directory, packageJson) => {
|
|
|
33584
33510
|
if (hasCompilerInConfigFiles(directory, NEXT_CONFIG_FILENAMES)) return true;
|
|
33585
33511
|
if (hasCompilerInConfigFiles(directory, BABEL_CONFIG_FILENAMES)) return true;
|
|
33586
33512
|
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;
|
|
33589
33513
|
if (hasCompilerInConfigFiles(directory, EXPO_APP_CONFIG_FILENAMES)) return true;
|
|
33590
33514
|
return hasCompilerPackageInAncestors(directory, REACT_COMPILER_TRANSFORM_PACKAGES);
|
|
33591
33515
|
};
|
|
@@ -33594,7 +33518,7 @@ const detectNextjsStaticExport = (directory) => NEXT_CONFIG_FILENAMES.some((file
|
|
|
33594
33518
|
const filePath = Path.join(directory, filename);
|
|
33595
33519
|
return isFile(filePath) && STATIC_EXPORT_OUTPUT_PATTERN.test(NFS.readFileSync(filePath, "utf-8"));
|
|
33596
33520
|
});
|
|
33597
|
-
const UNRESOLVABLE_PROTOCOL_VERSION = /^(?:
|
|
33521
|
+
const UNRESOLVABLE_PROTOCOL_VERSION = /^(?:file|git|github|https?|link|patch|portal|workspace|npm):/i;
|
|
33598
33522
|
const DIST_TAG_VERSION = /^[a-z][a-z0-9._-]*$/i;
|
|
33599
33523
|
const WILDCARD_VERSION = /^[*xX](?:\.[*xX])*$/;
|
|
33600
33524
|
const NPM_ALIAS_VERSION = /^npm:(?:@[^/]+\/[^@]+|[^@]+)@(.+)$/i;
|
|
@@ -33727,16 +33651,6 @@ const getLowestDependencyMajor = (version) => {
|
|
|
33727
33651
|
}
|
|
33728
33652
|
return lowestMajor;
|
|
33729
33653
|
};
|
|
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
|
-
};
|
|
33740
33654
|
const isConcreteDependencyVersion = (version) => {
|
|
33741
33655
|
const normalizedVersion = normalizeDependencyVersion(version);
|
|
33742
33656
|
return normalizedVersion !== null && /\d/.test(normalizedVersion);
|
|
@@ -33780,18 +33694,9 @@ const parseReactMajorMinor = (reactVersion) => {
|
|
|
33780
33694
|
};
|
|
33781
33695
|
};
|
|
33782
33696
|
const parseLowerBoundVersion = (versionSpec) => import_semver.validRange(versionSpec) !== null ? import_semver.minVersion(versionSpec) : import_semver.coerce(versionSpec);
|
|
33783
|
-
const
|
|
33784
|
-
if (typeof
|
|
33785
|
-
const
|
|
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();
|
|
33697
|
+
const parseTailwindMajorMinor = (tailwindVersion) => {
|
|
33698
|
+
if (typeof tailwindVersion !== "string") return null;
|
|
33699
|
+
const trimmed = tailwindVersion.trim();
|
|
33795
33700
|
if (trimmed.length === 0) return null;
|
|
33796
33701
|
const lowerBound = parseLowerBoundVersion(trimmed);
|
|
33797
33702
|
if (lowerBound === null || lowerBound.major <= 0) return null;
|
|
@@ -33800,7 +33705,6 @@ const parseDependencyMajorMinor = (dependencyVersion) => {
|
|
|
33800
33705
|
minor: lowerBound.minor
|
|
33801
33706
|
};
|
|
33802
33707
|
};
|
|
33803
|
-
const parseTailwindMajorMinor = (tailwindVersion) => parseDependencyMajorMinor(tailwindVersion);
|
|
33804
33708
|
const hasUpperBoundOnlyPeerRange = (range) => {
|
|
33805
33709
|
if (typeof range !== "string") return false;
|
|
33806
33710
|
const normalizedRange = normalizeDependencyVersion(range);
|
|
@@ -33822,7 +33726,7 @@ const resolveEffectiveReactMajor = (reactVersion, packageJson) => {
|
|
|
33822
33726
|
if (peerFloor === null) return hasUpperBoundOnlyPeerRange(peerReactRange) ? null : installedReactMajor;
|
|
33823
33727
|
return installedReactMajor !== null ? Math.min(installedReactMajor, peerFloor) : peerFloor;
|
|
33824
33728
|
};
|
|
33825
|
-
const isCatalogReference = (version) =>
|
|
33729
|
+
const isCatalogReference = (version) => version.startsWith("catalog:");
|
|
33826
33730
|
const extractCatalogName = (version) => {
|
|
33827
33731
|
if (!isCatalogReference(version)) return null;
|
|
33828
33732
|
const name = version.slice(8).trim();
|
|
@@ -33972,12 +33876,6 @@ const TAILWIND_ZOD_SECTIONS = [
|
|
|
33972
33876
|
"devDependencies",
|
|
33973
33877
|
"peerDependencies"
|
|
33974
33878
|
];
|
|
33975
|
-
const DEPENDENCY_SPEC_SECTIONS = [
|
|
33976
|
-
"dependencies",
|
|
33977
|
-
"devDependencies",
|
|
33978
|
-
"peerDependencies",
|
|
33979
|
-
"optionalDependencies"
|
|
33980
|
-
];
|
|
33981
33879
|
const EMPTY_DEPENDENCY_INFO = {
|
|
33982
33880
|
reactVersion: null,
|
|
33983
33881
|
tailwindVersion: null,
|
|
@@ -33987,7 +33885,7 @@ const EMPTY_DEPENDENCY_INFO = {
|
|
|
33987
33885
|
const pickConcreteVersion = (packageJson, packageName, sections) => {
|
|
33988
33886
|
for (const section of sections) {
|
|
33989
33887
|
const version = packageJson[section]?.[packageName];
|
|
33990
|
-
if (
|
|
33888
|
+
if (version === void 0) continue;
|
|
33991
33889
|
if (isCatalogReference(version)) return null;
|
|
33992
33890
|
if (isConcreteDependencyVersion(version)) return version;
|
|
33993
33891
|
}
|
|
@@ -34019,16 +33917,13 @@ const extractDependencyInfo = (packageJson) => {
|
|
|
34019
33917
|
};
|
|
34020
33918
|
};
|
|
34021
33919
|
const getDependencySpec = (packageJson, packageName) => {
|
|
34022
|
-
|
|
34023
|
-
|
|
34024
|
-
if (typeof spec === "string") return spec;
|
|
34025
|
-
}
|
|
34026
|
-
return null;
|
|
33920
|
+
const spec = packageJson.dependencies?.[packageName] ?? packageJson.devDependencies?.[packageName] ?? packageJson.peerDependencies?.[packageName] ?? packageJson.optionalDependencies?.[packageName];
|
|
33921
|
+
return typeof spec === "string" ? spec : null;
|
|
34027
33922
|
};
|
|
34028
33923
|
const getDependencyDeclaration = ({ packageJson, packageName, sections }) => {
|
|
34029
33924
|
for (const section of sections) {
|
|
34030
33925
|
const version = packageJson[section]?.[packageName];
|
|
34031
|
-
if (
|
|
33926
|
+
if (version === void 0) continue;
|
|
34032
33927
|
return {
|
|
34033
33928
|
catalogReference: extractCatalogName(version) ?? null,
|
|
34034
33929
|
hasDeclaration: true,
|
|
@@ -34062,15 +33957,24 @@ const getPreactVersion = (packageJson) => {
|
|
|
34062
33957
|
...packageJson.devDependencies
|
|
34063
33958
|
}.preact ?? null;
|
|
34064
33959
|
};
|
|
34065
|
-
const
|
|
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
|
+
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
34066
33974
|
if (version === null || !isCatalogReference(version)) return version;
|
|
34067
33975
|
const catalogName = extractCatalogName(version);
|
|
34068
|
-
const
|
|
34069
|
-
if (
|
|
34070
|
-
if (sourceDirectory !== rootDirectory || sourcePackageJson !== rootPackageJson) {
|
|
34071
|
-
const resolvedRootVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
|
|
34072
|
-
if (resolvedRootVersion) return resolvedRootVersion;
|
|
34073
|
-
}
|
|
33976
|
+
const resolvedLocalVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
|
|
33977
|
+
if (resolvedLocalVersion) return resolvedLocalVersion;
|
|
34074
33978
|
const monorepoRoot = findMonorepoRoot(rootDirectory);
|
|
34075
33979
|
if (!monorepoRoot) return version;
|
|
34076
33980
|
const monorepoPackageJsonPath = Path.join(monorepoRoot, "package.json");
|
|
@@ -34268,84 +34172,7 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34268
34172
|
}
|
|
34269
34173
|
return packages;
|
|
34270
34174
|
};
|
|
34271
|
-
const PREFERRED_DEPENDENCY_SECTIONS = [
|
|
34272
|
-
"dependencies",
|
|
34273
|
-
"peerDependencies",
|
|
34274
|
-
"devDependencies"
|
|
34275
|
-
];
|
|
34276
|
-
const getPreferredDependencyVersion = ({ packageJson, packageNames }) => {
|
|
34277
|
-
for (const packageName of packageNames) {
|
|
34278
|
-
const declaration = getDependencyDeclaration({
|
|
34279
|
-
packageJson,
|
|
34280
|
-
packageName,
|
|
34281
|
-
sections: PREFERRED_DEPENDENCY_SECTIONS
|
|
34282
|
-
});
|
|
34283
|
-
if (declaration.version !== null) return declaration.version;
|
|
34284
|
-
}
|
|
34285
|
-
return null;
|
|
34286
|
-
};
|
|
34287
|
-
const TANSTACK_REACT_QUERY_PACKAGES = ["@tanstack/react-query", "react-query"];
|
|
34288
|
-
const getTanStackQueryVersion = (packageJson) => {
|
|
34289
|
-
return getPreferredDependencyVersion({
|
|
34290
|
-
packageJson,
|
|
34291
|
-
packageNames: TANSTACK_REACT_QUERY_PACKAGES
|
|
34292
|
-
});
|
|
34293
|
-
};
|
|
34294
|
-
const STYLED_COMPONENTS_PACKAGES = ["styled-components"];
|
|
34295
|
-
const getStyledComponentsVersion = (packageJson) => {
|
|
34296
|
-
return getPreferredDependencyVersion({
|
|
34297
|
-
packageJson,
|
|
34298
|
-
packageNames: STYLED_COMPONENTS_PACKAGES
|
|
34299
|
-
});
|
|
34300
|
-
};
|
|
34301
|
-
const I18N_PACKAGES = [
|
|
34302
|
-
"i18next",
|
|
34303
|
-
"react-i18next",
|
|
34304
|
-
"next-i18next",
|
|
34305
|
-
"react-intl",
|
|
34306
|
-
"next-intl",
|
|
34307
|
-
"use-intl",
|
|
34308
|
-
"@formatjs/intl",
|
|
34309
|
-
"@lingui/core",
|
|
34310
|
-
"@lingui/react",
|
|
34311
|
-
"typesafe-i18n",
|
|
34312
|
-
"@tolgee/react",
|
|
34313
|
-
"react-intl-universal"
|
|
34314
|
-
];
|
|
34315
|
-
const hasI18nDependency = (packageJson) => {
|
|
34316
|
-
const allDependencies = {
|
|
34317
|
-
...packageJson.peerDependencies,
|
|
34318
|
-
...packageJson.dependencies,
|
|
34319
|
-
...packageJson.devDependencies,
|
|
34320
|
-
...packageJson.optionalDependencies
|
|
34321
|
-
};
|
|
34322
|
-
return I18N_PACKAGES.some((packageName) => allDependencies[packageName] !== void 0);
|
|
34323
|
-
};
|
|
34324
34175
|
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
|
-
];
|
|
34349
34176
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34350
34177
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34351
34178
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34356,7 +34183,7 @@ const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootD
|
|
|
34356
34183
|
if (!dependencyDeclaration.hasDeclaration) return null;
|
|
34357
34184
|
return concreteVersion ?? resolveCatalogVersion(workspacePackageJson, packageName, workspaceDirectory, dependencyDeclaration.catalogReference) ?? resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, dependencyDeclaration.catalogReference);
|
|
34358
34185
|
};
|
|
34359
|
-
const
|
|
34186
|
+
const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
34360
34187
|
if (!currentVersion) return true;
|
|
34361
34188
|
const currentMajor = parseReactMajor(currentVersion);
|
|
34362
34189
|
const nextMajor = parseReactMajor(nextVersion);
|
|
@@ -34364,71 +34191,7 @@ const shouldReplaceWithLowerMajor = (currentVersion, nextVersion) => {
|
|
|
34364
34191
|
if (nextMajor === null) return false;
|
|
34365
34192
|
return nextMajor < currentMajor;
|
|
34366
34193
|
};
|
|
34367
|
-
const
|
|
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
|
-
};
|
|
34378
|
-
const shouldReplaceStyledComponentsVersion = (currentVersion, nextVersion) => {
|
|
34379
|
-
if (!currentVersion) return true;
|
|
34380
|
-
const currentMajor = getLowestDependencyMajor(currentVersion);
|
|
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);
|
|
34401
|
-
if (currentMajor === null) return false;
|
|
34402
|
-
if (nextMajor === null) return true;
|
|
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;
|
|
34421
|
-
};
|
|
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) => {
|
|
34194
|
+
const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
34432
34195
|
if (facts.expo.version === null) {
|
|
34433
34196
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34434
34197
|
if (spec !== null) facts.expo = {
|
|
@@ -34443,23 +34206,6 @@ const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, roo
|
|
|
34443
34206
|
sourceDirectory: directory
|
|
34444
34207
|
};
|
|
34445
34208
|
}
|
|
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;
|
|
34463
34209
|
if (facts.shopifyFlashList.version === null) {
|
|
34464
34210
|
const spec = getDependencySpec(packageJson, SHOPIFY_FLASH_LIST_PACKAGE_NAME);
|
|
34465
34211
|
if (spec !== null) facts.shopifyFlashList = {
|
|
@@ -34467,113 +34213,13 @@ const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, roo
|
|
|
34467
34213
|
sourceDirectory: directory
|
|
34468
34214
|
};
|
|
34469
34215
|
}
|
|
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
|
-
}
|
|
34500
34216
|
if (facts.reanimatedVersion === null) {
|
|
34501
34217
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34502
34218
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34503
34219
|
}
|
|
34504
|
-
if (facts.valtioVersion === null) {
|
|
34505
|
-
const spec = getDependencySpec(packageJson, "valtio");
|
|
34506
|
-
if (spec !== null) facts.valtioVersion = spec;
|
|
34507
|
-
}
|
|
34508
|
-
facts.tanstackQueryVersion ??= getTanStackQueryVersion(packageJson);
|
|
34509
|
-
const styledComponentsVersion = resolveCatalogBackedDependencyVersion({
|
|
34510
|
-
rootDirectory: directory,
|
|
34511
|
-
rootPackageJson: packageJson,
|
|
34512
|
-
packageName: "styled-components",
|
|
34513
|
-
version: getStyledComponentsVersion(packageJson)
|
|
34514
|
-
});
|
|
34515
|
-
if (styledComponentsVersion && shouldReplaceStyledComponentsVersion(facts.styledComponentsVersion, styledComponentsVersion)) facts.styledComponentsVersion = styledComponentsVersion;
|
|
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
|
-
}
|
|
34554
34220
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34555
34221
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34556
34222
|
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);
|
|
34577
34223
|
};
|
|
34578
34224
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34579
34225
|
const facts = {
|
|
@@ -34589,60 +34235,25 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34589
34235
|
version: null,
|
|
34590
34236
|
sourceDirectory: null
|
|
34591
34237
|
},
|
|
34592
|
-
reactRouter: {
|
|
34593
|
-
version: null,
|
|
34594
|
-
sourceDirectory: null,
|
|
34595
|
-
packageName: null
|
|
34596
|
-
},
|
|
34597
34238
|
shopifyFlashList: {
|
|
34598
34239
|
version: null,
|
|
34599
34240
|
sourceDirectory: null
|
|
34600
34241
|
},
|
|
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
|
-
},
|
|
34616
|
-
tanstackQueryVersion: null,
|
|
34617
|
-
styledComponentsVersion: null,
|
|
34618
|
-
hasI18nLibrary: false,
|
|
34619
34242
|
hasReactNativeAwarePackage: false,
|
|
34620
34243
|
hasReanimatedAwarePackage: false,
|
|
34621
34244
|
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,
|
|
34634
34245
|
reanimatedVersion: null
|
|
34635
34246
|
};
|
|
34636
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory
|
|
34247
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34637
34248
|
let isReactGroupSettled = !collectReactGroup;
|
|
34638
34249
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34639
34250
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
34640
|
-
const directories = resolveWorkspaceDirectories(rootDirectory, pattern).
|
|
34251
|
+
const directories = [...resolveWorkspaceDirectories(rootDirectory, pattern)].sort();
|
|
34641
34252
|
for (const workspaceDirectory of directories) {
|
|
34642
34253
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34643
34254
|
visitedDirectories.add(workspaceDirectory);
|
|
34644
34255
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34645
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory
|
|
34256
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34646
34257
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34647
34258
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34648
34259
|
if (isReactGroupSettled) continue;
|
|
@@ -34673,7 +34284,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34673
34284
|
workspaceDirectory,
|
|
34674
34285
|
workspacePackageJson
|
|
34675
34286
|
});
|
|
34676
|
-
if (reactVersion &&
|
|
34287
|
+
if (reactVersion && shouldReplaceReactVersion(facts.reactVersion, reactVersion)) facts.reactVersion = reactVersion;
|
|
34677
34288
|
if (tailwindVersion && !facts.tailwindVersion) facts.tailwindVersion = tailwindVersion;
|
|
34678
34289
|
if (zodVersion && !facts.zodVersion) facts.zodVersion = zodVersion;
|
|
34679
34290
|
const settledReactMajor = parseReactMajor(facts.reactVersion);
|
|
@@ -34866,43 +34477,17 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34866
34477
|
tailwindVersion: null,
|
|
34867
34478
|
zodVersion: null,
|
|
34868
34479
|
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,
|
|
34879
34480
|
framework: "unknown",
|
|
34880
34481
|
hasTypeScript: hasOwnTsConfig,
|
|
34881
34482
|
hasReactCompiler: false,
|
|
34882
34483
|
hasReactCompilerLintPlugin: false,
|
|
34883
34484
|
hasTanStackQuery: false,
|
|
34884
|
-
valtioVersion: null,
|
|
34885
|
-
valtioMajorVersion: null,
|
|
34886
|
-
hasRemotion: false,
|
|
34887
|
-
remotionVersion: null,
|
|
34888
|
-
remotionMajorVersion: null,
|
|
34889
|
-
hasI18nLibrary: false,
|
|
34890
|
-
tanstackQueryVersion: null,
|
|
34891
|
-
styledComponentsVersion: null,
|
|
34892
|
-
hasThree: false,
|
|
34893
|
-
threeVersion: null,
|
|
34894
|
-
threeRelease: null,
|
|
34895
|
-
hasReactThreeFiber: false,
|
|
34896
|
-
reactThreeFiberVersion: null,
|
|
34897
|
-
reactThreeFiberMajorVersion: null,
|
|
34898
34485
|
hasSsrDependency: false,
|
|
34899
34486
|
preactVersion: null,
|
|
34900
34487
|
preactMajorVersion: null,
|
|
34901
34488
|
hasReactNativeWorkspace: false,
|
|
34902
34489
|
nextjsVersion: null,
|
|
34903
34490
|
nextjsMajorVersion: null,
|
|
34904
|
-
reactRouterVersion: null,
|
|
34905
|
-
hasReactRouterFramework: false,
|
|
34906
34491
|
expoVersion: null,
|
|
34907
34492
|
shopifyFlashListVersion: null,
|
|
34908
34493
|
shopifyFlashListMajorVersion: null,
|
|
@@ -34995,12 +34580,6 @@ const discoverProject = (directory) => {
|
|
|
34995
34580
|
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
34996
34581
|
version: workspaceFacts.shopifyFlashList.version
|
|
34997
34582
|
}) : null;
|
|
34998
|
-
const zustandVersion = resolveCatalogBackedDependencyVersion({
|
|
34999
|
-
rootDirectory: directory,
|
|
35000
|
-
rootPackageJson: packageJson,
|
|
35001
|
-
packageName: "zustand",
|
|
35002
|
-
version: workspaceFacts.zustand.version
|
|
35003
|
-
});
|
|
35004
34583
|
const hasReanimated = hasReactNativeWorkspace && workspaceFacts.hasReanimatedAwarePackage;
|
|
35005
34584
|
const reanimatedVersion = hasReanimated ? workspaceFacts.reanimatedVersion : null;
|
|
35006
34585
|
const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
|
|
@@ -35009,39 +34588,7 @@ const discoverProject = (directory) => {
|
|
|
35009
34588
|
packageName: "next",
|
|
35010
34589
|
version: workspaceFacts.next.version
|
|
35011
34590
|
}) : 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
|
-
});
|
|
35030
34591
|
const preactVersion = getPreactVersion(packageJson);
|
|
35031
|
-
const remotionVersion = workspaceFacts.remotionVersion;
|
|
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
|
-
});
|
|
35045
34592
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
35046
34593
|
const projectInfo = {
|
|
35047
34594
|
rootDirectory: directory,
|
|
@@ -35051,43 +34598,17 @@ const discoverProject = (directory) => {
|
|
|
35051
34598
|
tailwindVersion,
|
|
35052
34599
|
zodVersion,
|
|
35053
34600
|
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),
|
|
35064
34601
|
framework,
|
|
35065
34602
|
hasTypeScript,
|
|
35066
34603
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
35067
34604
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
35068
|
-
hasTanStackQuery:
|
|
35069
|
-
hasI18nLibrary: workspaceFacts.hasI18nLibrary,
|
|
35070
|
-
tanstackQueryVersion,
|
|
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),
|
|
34605
|
+
hasTanStackQuery: hasTanStackQuery(packageJson),
|
|
35083
34606
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
35084
34607
|
preactVersion,
|
|
35085
34608
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
35086
34609
|
hasReactNativeWorkspace,
|
|
35087
34610
|
nextjsVersion,
|
|
35088
34611
|
nextjsMajorVersion: nextjsVersion === null ? null : getLowestDependencyMajor(nextjsVersion),
|
|
35089
|
-
reactRouterVersion,
|
|
35090
|
-
hasReactRouterFramework: workspaceFacts.hasReactRouterFramework,
|
|
35091
34612
|
expoVersion,
|
|
35092
34613
|
shopifyFlashListVersion,
|
|
35093
34614
|
shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
|
|
@@ -35315,6 +34836,7 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
35315
34836
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
35316
34837
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
35317
34838
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34839
|
+
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
35318
34840
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
35319
34841
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
35320
34842
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37527,25 +37049,9 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37527
37049
|
".babelrc.json"
|
|
37528
37050
|
];
|
|
37529
37051
|
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}['"]`);
|
|
37534
37052
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37535
37053
|
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"));
|
|
37546
37054
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37547
|
-
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37548
|
-
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37549
37055
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37550
37056
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37551
37057
|
if (!isFile(filePath)) continue;
|
|
@@ -37555,7 +37061,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37555
37061
|
} catch {
|
|
37556
37062
|
continue;
|
|
37557
37063
|
}
|
|
37558
|
-
if (
|
|
37064
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
37559
37065
|
filePath: fileName,
|
|
37560
37066
|
rule: "rn-no-metro-babel-preset",
|
|
37561
37067
|
severity: "error",
|
|
@@ -37578,6 +37084,12 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37578
37084
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37579
37085
|
};
|
|
37580
37086
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37087
|
+
const DEPENDENCY_SECTIONS = [
|
|
37088
|
+
"dependencies",
|
|
37089
|
+
"devDependencies",
|
|
37090
|
+
"peerDependencies",
|
|
37091
|
+
"optionalDependencies"
|
|
37092
|
+
];
|
|
37581
37093
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37582
37094
|
"19.0": {
|
|
37583
37095
|
rceFixedVersion: "19.0.1",
|
|
@@ -37624,13 +37136,20 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37624
37136
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37625
37137
|
return [...directories];
|
|
37626
37138
|
};
|
|
37139
|
+
const readDeclaredSpec = (packageJson, packageName) => {
|
|
37140
|
+
for (const section of DEPENDENCY_SECTIONS) {
|
|
37141
|
+
const spec = packageJson[section]?.[packageName];
|
|
37142
|
+
if (typeof spec === "string") return spec;
|
|
37143
|
+
}
|
|
37144
|
+
return null;
|
|
37145
|
+
};
|
|
37627
37146
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37628
37147
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37629
37148
|
if (isFile(manifestPath)) {
|
|
37630
37149
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37631
37150
|
if (installedVersion !== null) return installedVersion;
|
|
37632
37151
|
}
|
|
37633
|
-
const candidateSpecs = [
|
|
37152
|
+
const candidateSpecs = [readDeclaredSpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37634
37153
|
for (const spec of candidateSpecs) {
|
|
37635
37154
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37636
37155
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -38282,10 +37801,10 @@ const SSR_FRAMEWORKS = new Set([
|
|
|
38282
37801
|
"gatsby",
|
|
38283
37802
|
"tanstack-start"
|
|
38284
37803
|
]);
|
|
38285
|
-
const
|
|
38286
|
-
if (
|
|
38287
|
-
const
|
|
38288
|
-
for (let candidate = earliest; candidate <=
|
|
37804
|
+
const addMajorLadder = (capabilities, name, major, earliest, latest) => {
|
|
37805
|
+
if (major === null) return;
|
|
37806
|
+
const cappedMajor = Math.min(major, latest);
|
|
37807
|
+
for (let candidate = earliest; candidate <= cappedMajor; candidate += 1) capabilities.add(`${name}:${candidate}`);
|
|
38289
37808
|
};
|
|
38290
37809
|
const buildCapabilities = (project) => {
|
|
38291
37810
|
const capabilities = /* @__PURE__ */ new Set();
|
|
@@ -38298,86 +37817,24 @@ const buildCapabilities = (project) => {
|
|
|
38298
37817
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
38299
37818
|
if (project.isStaticExport) capabilities.add("nextjs:static-export");
|
|
38300
37819
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
38301
|
-
|
|
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);
|
|
37820
|
+
addMajorLadder(capabilities, "react", project.reactMajorVersion, 17, 30);
|
|
38312
37821
|
if (project.reactMajorVersion !== null && project.reactMajorVersion >= 19 && isMajorMinorAtLeast(parseReactMajorMinor(project.reactVersion), {
|
|
38313
37822
|
major: 19,
|
|
38314
37823
|
minor: 2
|
|
38315
37824
|
})) capabilities.add("react:19.2");
|
|
38316
|
-
if (project.tailwindVersion !== null)
|
|
38317
|
-
|
|
38318
|
-
|
|
38319
|
-
|
|
38320
|
-
|
|
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
|
-
}
|
|
37825
|
+
if (project.tailwindVersion !== null) capabilities.add("tailwind");
|
|
37826
|
+
if (project.tailwindVersion !== null && isMajorMinorAtLeast(parseTailwindMajorMinor(project.tailwindVersion), {
|
|
37827
|
+
major: 3,
|
|
37828
|
+
minor: 4
|
|
37829
|
+
})) capabilities.add("tailwind:3.4");
|
|
38328
37830
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
38329
37831
|
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);
|
|
38357
37832
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
38358
37833
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
38359
|
-
if (
|
|
38360
|
-
if (project.styledComponentsVersion) {
|
|
38361
|
-
capabilities.add("styled-components");
|
|
38362
|
-
const styledComponentsMajor = getLowestDependencyMajor(project.styledComponentsVersion);
|
|
38363
|
-
if (styledComponentsMajor !== null && styledComponentsMajor >= 6) capabilities.add("styled-components:6");
|
|
38364
|
-
}
|
|
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
|
-
}
|
|
37834
|
+
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
38378
37835
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
38379
37836
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
38380
|
-
|
|
37837
|
+
addMajorLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
38381
37838
|
if (project.preactVersion !== null && project.reactVersion === null) capabilities.add("pure-preact");
|
|
38382
37839
|
return capabilities;
|
|
38383
37840
|
};
|
|
@@ -38389,7 +37846,7 @@ const getCapabilities = (project) => {
|
|
|
38389
37846
|
capabilitiesByProject.set(project, capabilities);
|
|
38390
37847
|
return capabilities;
|
|
38391
37848
|
};
|
|
38392
|
-
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen
|
|
37849
|
+
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen) => {
|
|
38393
37850
|
if (requires) {
|
|
38394
37851
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
38395
37852
|
}
|
|
@@ -38400,29 +37857,20 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhe
|
|
|
38400
37857
|
if (tags) {
|
|
38401
37858
|
for (const tag of tags) if (ignoredTags.has(tag)) return false;
|
|
38402
37859
|
}
|
|
38403
|
-
if (includedTags && includedTags.size > 0) {
|
|
38404
|
-
if (!tags?.some((tag) => includedTags.has(tag))) return false;
|
|
38405
|
-
}
|
|
38406
37860
|
return true;
|
|
38407
37861
|
};
|
|
38408
|
-
const shouldEnableRuleByDefaultStatus = (options) => options.defaultEnabled !== false || options.hasExplicitOverride === true || options.includeTagDefaults && options.hasIncludedTags;
|
|
38409
37862
|
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
38410
37863
|
setImmediate(resolve);
|
|
38411
37864
|
});
|
|
38412
37865
|
const createSecurityScanSession = (rootDirectory, options) => {
|
|
38413
37866
|
const capabilities = options.project ? getCapabilities(options.project) : /* @__PURE__ */ new Set();
|
|
38414
37867
|
const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
|
|
38415
|
-
const includedTags = options.includedTags ?? /* @__PURE__ */ new Set();
|
|
38416
37868
|
const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
|
|
38417
37869
|
const rule = entry.rule;
|
|
38418
37870
|
const scan = rule.scan;
|
|
38419
37871
|
if (typeof scan !== "function") return [];
|
|
38420
|
-
if (
|
|
38421
|
-
|
|
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 [];
|
|
37872
|
+
if (rule.defaultEnabled === false) return [];
|
|
37873
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen)) return [];
|
|
38426
37874
|
return [{
|
|
38427
37875
|
entry,
|
|
38428
37876
|
scan,
|
|
@@ -40408,9 +39856,8 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
40408
39856
|
}
|
|
40409
39857
|
return enabled;
|
|
40410
39858
|
};
|
|
40411
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(),
|
|
40412
|
-
const
|
|
40413
|
-
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
39859
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
39860
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
40414
39861
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
40415
39862
|
const jsPlugins = [];
|
|
40416
39863
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -40425,14 +39872,9 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
40425
39872
|
if (rule.scan !== void 0) continue;
|
|
40426
39873
|
if (customRulesOnly && registryEntry.originallyExternal) continue;
|
|
40427
39874
|
if (rule.framework !== "global" && !rule.requires) continue;
|
|
40428
|
-
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen
|
|
39875
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen)) continue;
|
|
40429
39876
|
const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
|
|
40430
|
-
if (
|
|
40431
|
-
defaultEnabled: rule.defaultEnabled,
|
|
40432
|
-
includeTagDefaults,
|
|
40433
|
-
hasIncludedTags,
|
|
40434
|
-
hasExplicitOverride: explicitRuleOverride !== void 0
|
|
40435
|
-
})) continue;
|
|
39877
|
+
if (rule.defaultEnabled === false && explicitRuleOverride === void 0) continue;
|
|
40436
39878
|
const severity = resolveRuleSeverityOverride({
|
|
40437
39879
|
ruleKey: registryEntry.key,
|
|
40438
39880
|
category: rule.category
|
|
@@ -40441,7 +39883,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
40441
39883
|
enabledReactDoctorRules[registryEntry.key] = severity;
|
|
40442
39884
|
}
|
|
40443
39885
|
const userPluginRules = {};
|
|
40444
|
-
if (ruleSelection !== "sidecar"
|
|
39886
|
+
if (ruleSelection !== "sidecar") for (const userPlugin of userPlugins) {
|
|
40445
39887
|
Object.assign(userPluginRules, buildUserPluginRules(userPlugin, severityControls));
|
|
40446
39888
|
jsPlugins.push(userPlugin.entry);
|
|
40447
39889
|
}
|
|
@@ -40658,19 +40100,6 @@ const createSidecarLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
40658
40100
|
}
|
|
40659
40101
|
};
|
|
40660
40102
|
};
|
|
40661
|
-
const fingerprintCacheByFilePath = /* @__PURE__ */ new Map();
|
|
40662
|
-
const fingerprintFileContents = (filePath, fingerprintLength) => {
|
|
40663
|
-
const fileStats = NFS.statSync(filePath, { bigint: true });
|
|
40664
|
-
const cachedFingerprint = fingerprintCacheByFilePath.get(filePath);
|
|
40665
|
-
if (cachedFingerprint?.modifiedTimeNanoseconds === fileStats.mtimeNs && cachedFingerprint.sizeBytes === fileStats.size) return cachedFingerprint.fingerprint;
|
|
40666
|
-
const fingerprint = crypto.createHash("sha256").update(NFS.readFileSync(filePath)).digest("hex").slice(0, fingerprintLength);
|
|
40667
|
-
fingerprintCacheByFilePath.set(filePath, {
|
|
40668
|
-
fingerprint,
|
|
40669
|
-
modifiedTimeNanoseconds: fileStats.mtimeNs,
|
|
40670
|
-
sizeBytes: fileStats.size
|
|
40671
|
-
});
|
|
40672
|
-
return fingerprint;
|
|
40673
|
-
};
|
|
40674
40103
|
const bundledRequire = createRequire(import.meta.url);
|
|
40675
40104
|
const childNodeVersionByBinaryPath = /* @__PURE__ */ new Map();
|
|
40676
40105
|
const resolveChildNodeVersion = (nodeBinaryPath) => {
|
|
@@ -40694,13 +40123,6 @@ const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
|
40694
40123
|
"oxlint-plugin-react-doctor/package.json",
|
|
40695
40124
|
"eslint-plugin-react-hooks/package.json"
|
|
40696
40125
|
];
|
|
40697
|
-
const resolvePluginFingerprint = () => {
|
|
40698
|
-
try {
|
|
40699
|
-
return fingerprintFileContents(bundledRequire.resolve("oxlint-plugin-react-doctor"), 16);
|
|
40700
|
-
} catch {
|
|
40701
|
-
return "unresolved";
|
|
40702
|
-
}
|
|
40703
|
-
};
|
|
40704
40126
|
const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
40705
40127
|
const versions = [`node=${resolveChildNodeVersion(nodeBinaryPath)}`];
|
|
40706
40128
|
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
@@ -40710,7 +40132,6 @@ const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
|
40710
40132
|
} catch {
|
|
40711
40133
|
versions.push(`${specifier}=missing`);
|
|
40712
40134
|
}
|
|
40713
|
-
versions.push(`oxlint-plugin-react-doctor#fingerprint=${resolvePluginFingerprint()}`);
|
|
40714
40135
|
return versions;
|
|
40715
40136
|
};
|
|
40716
40137
|
const esmRequire = createRequire(import.meta.url);
|
|
@@ -42186,7 +41607,7 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
42186
41607
|
* 6. always restore disable directives + clean up the temp dir
|
|
42187
41608
|
*/
|
|
42188
41609
|
const runOxlint = async (options) => {
|
|
42189
|
-
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(),
|
|
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;
|
|
42190
41611
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
42191
41612
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
42192
41613
|
validateRuleRegistration();
|
|
@@ -42200,15 +41621,13 @@ const runOxlint = async (options) => {
|
|
|
42200
41621
|
}
|
|
42201
41622
|
const pluginPath = resolvePluginPath();
|
|
42202
41623
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
42203
|
-
const userPlugins =
|
|
41624
|
+
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
42204
41625
|
const buildConfig = (overrides) => createOxlintConfig({
|
|
42205
41626
|
pluginPath,
|
|
42206
41627
|
project,
|
|
42207
41628
|
customRulesOnly,
|
|
42208
41629
|
extendsPaths: overrides.extendsPaths,
|
|
42209
41630
|
ignoredTags,
|
|
42210
|
-
includedTags,
|
|
42211
|
-
includeTagDefaults,
|
|
42212
41631
|
serverAuthFunctionNames,
|
|
42213
41632
|
severityControls,
|
|
42214
41633
|
userPlugins,
|
|
@@ -42597,8 +42016,6 @@ var Linter = class Linter extends Service()("react-doctor/Linter") {
|
|
|
42597
42016
|
respectInlineDisables: input.respectInlineDisables,
|
|
42598
42017
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42599
42018
|
ignoredTags: input.ignoredTags,
|
|
42600
|
-
includedTags: input.includedTags,
|
|
42601
|
-
includeTagDefaults: input.includeTagDefaults,
|
|
42602
42019
|
userConfig: input.userConfig ?? null,
|
|
42603
42020
|
configSourceDirectory: input.configSourceDirectory,
|
|
42604
42021
|
onPartialFailure: (reason) => {
|
|
@@ -43447,9 +42864,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
43447
42864
|
const securityScanFailedRef = yield* make$13(false);
|
|
43448
42865
|
const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(tryPromise(() => checkSecurityScanCooperative(scanDirectory, {
|
|
43449
42866
|
project,
|
|
43450
|
-
ignoredTags: input.ignoredTags
|
|
43451
|
-
includedTags: input.includedTags,
|
|
43452
|
-
includeTagDefaults: input.includeTagDefaults
|
|
42867
|
+
ignoredTags: input.ignoredTags
|
|
43453
42868
|
})).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), catch_$1(() => set(securityScanFailedRef, true).pipe(as(empty$4))))))).pipe(withSpan("SecurityScan.run")));
|
|
43454
42869
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
43455
42870
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
@@ -43540,8 +42955,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
43540
42955
|
respectInlineDisables: input.respectInlineDisables,
|
|
43541
42956
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
43542
42957
|
ignoredTags: input.ignoredTags,
|
|
43543
|
-
includedTags: input.includedTags,
|
|
43544
|
-
includeTagDefaults: input.includeTagDefaults,
|
|
43545
42958
|
userConfig: resolvedConfig.config ?? void 0,
|
|
43546
42959
|
configSourceDirectory: resolvedConfig.configSourceDirectory ?? void 0,
|
|
43547
42960
|
onFileProgress: (scannedFileCount, totalFileCount) => {
|
|
@@ -46044,5 +45457,5 @@ const startLanguageServer = () => {
|
|
|
46044
45457
|
};
|
|
46045
45458
|
//#endregion
|
|
46046
45459
|
export { startLanguageServer };
|
|
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]="
|
|
46048
|
-
//# debugId=
|
|
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]="ecc1704a-4f8c-583e-93b2-78c6feb9cfd6")}catch(e){}}();
|
|
45461
|
+
//# debugId=ecc1704a-4f8c-583e-93b2-78c6feb9cfd6
|