react-doctor 0.8.1-dev.5332cb6 → 0.8.1-dev.5b468f8
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 +680 -158
- package/dist/index.d.ts +41 -0
- package/dist/index.js +589 -114
- package/dist/lsp.js +589 -114
- package/dist/skills/react-doctor/SKILL.md +5 -0
- package/package.json +2 -2
package/dist/lsp.js
CHANGED
|
@@ -32883,44 +32883,6 @@ var AmbiguousProjectError = class extends Error {
|
|
|
32883
32883
|
}
|
|
32884
32884
|
};
|
|
32885
32885
|
const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
|
|
32886
|
-
const isErrnoException = (error) => error instanceof Error && "code" in error;
|
|
32887
|
-
const IGNORABLE_READDIR_ERROR_CODES = new Set([
|
|
32888
|
-
"EACCES",
|
|
32889
|
-
"EPERM",
|
|
32890
|
-
"ENOENT",
|
|
32891
|
-
"ENOTDIR",
|
|
32892
|
-
"EINVAL",
|
|
32893
|
-
"ELOOP",
|
|
32894
|
-
"ENAMETOOLONG"
|
|
32895
|
-
]);
|
|
32896
|
-
const isIgnorableReaddirError = (error) => isErrnoException(error) && typeof error.code === "string" && IGNORABLE_READDIR_ERROR_CODES.has(error.code);
|
|
32897
|
-
const readDirectoryEntries = (directoryPath) => {
|
|
32898
|
-
try {
|
|
32899
|
-
return NFS.readdirSync(directoryPath, { withFileTypes: true });
|
|
32900
|
-
} catch (error) {
|
|
32901
|
-
if (isIgnorableReaddirError(error)) return [];
|
|
32902
|
-
throw error;
|
|
32903
|
-
}
|
|
32904
|
-
};
|
|
32905
|
-
const isFile = (filePath) => {
|
|
32906
|
-
try {
|
|
32907
|
-
return NFS.statSync(filePath).isFile();
|
|
32908
|
-
} catch {
|
|
32909
|
-
return false;
|
|
32910
|
-
}
|
|
32911
|
-
};
|
|
32912
|
-
const isDirectory = (directoryPath) => {
|
|
32913
|
-
try {
|
|
32914
|
-
return NFS.statSync(directoryPath).isDirectory();
|
|
32915
|
-
} catch {
|
|
32916
|
-
return false;
|
|
32917
|
-
}
|
|
32918
|
-
};
|
|
32919
|
-
const isPlainObject = (value) => {
|
|
32920
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
32921
|
-
const prototype = Object.getPrototypeOf(value);
|
|
32922
|
-
return prototype === null || prototype === Object.prototype;
|
|
32923
|
-
};
|
|
32924
32886
|
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
|
|
32925
32887
|
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
32926
32888
|
const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
|
|
@@ -33102,6 +33064,44 @@ const SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS = 9e4;
|
|
|
33102
33064
|
const SUPPLY_CHAIN_CACHE_TTL_MS = 864e5;
|
|
33103
33065
|
const SUPPLY_CHAIN_CACHE_SUBDIR = "supply-chain";
|
|
33104
33066
|
const SUPPLY_CHAIN_IGNORED_PACKAGES = new Set(["next"]);
|
|
33067
|
+
const isErrnoException = (error) => error instanceof Error && "code" in error;
|
|
33068
|
+
const IGNORABLE_READDIR_ERROR_CODES = new Set([
|
|
33069
|
+
"EACCES",
|
|
33070
|
+
"EPERM",
|
|
33071
|
+
"ENOENT",
|
|
33072
|
+
"ENOTDIR",
|
|
33073
|
+
"EINVAL",
|
|
33074
|
+
"ELOOP",
|
|
33075
|
+
"ENAMETOOLONG"
|
|
33076
|
+
]);
|
|
33077
|
+
const isIgnorableReaddirError = (error) => isErrnoException(error) && typeof error.code === "string" && IGNORABLE_READDIR_ERROR_CODES.has(error.code);
|
|
33078
|
+
const readDirectoryEntries = (directoryPath) => {
|
|
33079
|
+
try {
|
|
33080
|
+
return NFS.readdirSync(directoryPath, { withFileTypes: true });
|
|
33081
|
+
} catch (error) {
|
|
33082
|
+
if (isIgnorableReaddirError(error)) return [];
|
|
33083
|
+
throw error;
|
|
33084
|
+
}
|
|
33085
|
+
};
|
|
33086
|
+
const isFile = (filePath) => {
|
|
33087
|
+
try {
|
|
33088
|
+
return NFS.statSync(filePath).isFile();
|
|
33089
|
+
} catch {
|
|
33090
|
+
return false;
|
|
33091
|
+
}
|
|
33092
|
+
};
|
|
33093
|
+
const isDirectory = (directoryPath) => {
|
|
33094
|
+
try {
|
|
33095
|
+
return NFS.statSync(directoryPath).isDirectory();
|
|
33096
|
+
} catch {
|
|
33097
|
+
return false;
|
|
33098
|
+
}
|
|
33099
|
+
};
|
|
33100
|
+
const isPlainObject = (value) => {
|
|
33101
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
33102
|
+
const prototype = Object.getPrototypeOf(value);
|
|
33103
|
+
return prototype === null || prototype === Object.prototype;
|
|
33104
|
+
};
|
|
33105
33105
|
const lastSourceMappingUrl = (fileContent) => {
|
|
33106
33106
|
const lastReference = [...fileContent.matchAll(/\/\/# sourceMappingURL=(\S+)/g)].at(-1);
|
|
33107
33107
|
return lastReference ? lastReference[1] : null;
|
|
@@ -33427,10 +33427,10 @@ const FALLBACK_TSCONFIG_FILENAMES = ["tsconfig.app.json", "tsconfig.build.json"]
|
|
|
33427
33427
|
const FRAMEWORK_PACKAGES = {
|
|
33428
33428
|
next: "nextjs",
|
|
33429
33429
|
"@tanstack/react-start": "tanstack-start",
|
|
33430
|
-
vite: "vite",
|
|
33431
|
-
"react-scripts": "cra",
|
|
33432
33430
|
"@remix-run/react": "remix",
|
|
33433
33431
|
gatsby: "gatsby",
|
|
33432
|
+
vite: "vite",
|
|
33433
|
+
"react-scripts": "cra",
|
|
33434
33434
|
expo: "expo",
|
|
33435
33435
|
"react-native": "react-native"
|
|
33436
33436
|
};
|
|
@@ -33454,11 +33454,17 @@ const NEXT_CONFIG_FILENAMES = [
|
|
|
33454
33454
|
];
|
|
33455
33455
|
const BABEL_CONFIG_FILENAMES = [
|
|
33456
33456
|
".babelrc",
|
|
33457
|
+
".babelrc.js",
|
|
33457
33458
|
".babelrc.json",
|
|
33459
|
+
".babelrc.cjs",
|
|
33460
|
+
".babelrc.mjs",
|
|
33461
|
+
".babelrc.cts",
|
|
33458
33462
|
"babel.config.js",
|
|
33459
33463
|
"babel.config.json",
|
|
33460
33464
|
"babel.config.cjs",
|
|
33461
|
-
"babel.config.mjs"
|
|
33465
|
+
"babel.config.mjs",
|
|
33466
|
+
"babel.config.ts",
|
|
33467
|
+
"babel.config.cts"
|
|
33462
33468
|
];
|
|
33463
33469
|
const VITE_CONFIG_FILENAMES = [
|
|
33464
33470
|
"vite.config.js",
|
|
@@ -33470,12 +33476,28 @@ const VITE_CONFIG_FILENAMES = [
|
|
|
33470
33476
|
"vitest.config.ts",
|
|
33471
33477
|
"vitest.config.js"
|
|
33472
33478
|
];
|
|
33479
|
+
const RSBUILD_CONFIG_FILENAMES = [
|
|
33480
|
+
"rsbuild.config.ts",
|
|
33481
|
+
"rsbuild.config.js",
|
|
33482
|
+
"rsbuild.config.mts",
|
|
33483
|
+
"rsbuild.config.mjs",
|
|
33484
|
+
"rsbuild.config.cts",
|
|
33485
|
+
"rsbuild.config.cjs"
|
|
33486
|
+
];
|
|
33487
|
+
const RSPACK_CONFIG_FILENAMES = [
|
|
33488
|
+
"rspack.config.ts",
|
|
33489
|
+
"rspack.config.js",
|
|
33490
|
+
"rspack.config.mts",
|
|
33491
|
+
"rspack.config.mjs",
|
|
33492
|
+
"rspack.config.cts",
|
|
33493
|
+
"rspack.config.cjs"
|
|
33494
|
+
];
|
|
33473
33495
|
const EXPO_APP_CONFIG_FILENAMES = [
|
|
33474
33496
|
"app.json",
|
|
33475
33497
|
"app.config.js",
|
|
33476
33498
|
"app.config.ts"
|
|
33477
33499
|
];
|
|
33478
|
-
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|["']react-compiler["']/;
|
|
33500
|
+
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|reactCompilerPreset\s*\(|["']react-compiler["']/;
|
|
33479
33501
|
const REACT_COMPILER_ENABLED_FLAG_PATTERN = /["']?reactCompiler["']?\s*:\s*(?:true\b|\{)/;
|
|
33480
33502
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
33481
33503
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
@@ -33510,6 +33532,8 @@ const detectReactCompiler = (directory, packageJson) => {
|
|
|
33510
33532
|
if (hasCompilerInConfigFiles(directory, NEXT_CONFIG_FILENAMES)) return true;
|
|
33511
33533
|
if (hasCompilerInConfigFiles(directory, BABEL_CONFIG_FILENAMES)) return true;
|
|
33512
33534
|
if (hasCompilerInConfigFiles(directory, VITE_CONFIG_FILENAMES)) return true;
|
|
33535
|
+
if (hasCompilerInConfigFiles(directory, RSBUILD_CONFIG_FILENAMES)) return true;
|
|
33536
|
+
if (hasCompilerInConfigFiles(directory, RSPACK_CONFIG_FILENAMES)) return true;
|
|
33513
33537
|
if (hasCompilerInConfigFiles(directory, EXPO_APP_CONFIG_FILENAMES)) return true;
|
|
33514
33538
|
return hasCompilerPackageInAncestors(directory, REACT_COMPILER_TRANSFORM_PACKAGES);
|
|
33515
33539
|
};
|
|
@@ -33518,7 +33542,7 @@ const detectNextjsStaticExport = (directory) => NEXT_CONFIG_FILENAMES.some((file
|
|
|
33518
33542
|
const filePath = Path.join(directory, filename);
|
|
33519
33543
|
return isFile(filePath) && STATIC_EXPORT_OUTPUT_PATTERN.test(NFS.readFileSync(filePath, "utf-8"));
|
|
33520
33544
|
});
|
|
33521
|
-
const UNRESOLVABLE_PROTOCOL_VERSION = /^(?:file|git|github|https?|link|patch|portal|workspace|npm):/i;
|
|
33545
|
+
const UNRESOLVABLE_PROTOCOL_VERSION = /^(?:catalog|file|git|github|https?|link|patch|portal|workspace|npm):/i;
|
|
33522
33546
|
const DIST_TAG_VERSION = /^[a-z][a-z0-9._-]*$/i;
|
|
33523
33547
|
const WILDCARD_VERSION = /^[*xX](?:\.[*xX])*$/;
|
|
33524
33548
|
const NPM_ALIAS_VERSION = /^npm:(?:@[^/]+\/[^@]+|[^@]+)@(.+)$/i;
|
|
@@ -33651,6 +33675,16 @@ const getLowestDependencyMajor = (version) => {
|
|
|
33651
33675
|
}
|
|
33652
33676
|
return lowestMajor;
|
|
33653
33677
|
};
|
|
33678
|
+
const getDependencyMajorWithinSupportedRange = (version, latestSupportedMajor) => {
|
|
33679
|
+
const normalizedVersion = normalizeDependencyVersion(version);
|
|
33680
|
+
if (normalizedVersion === null) return null;
|
|
33681
|
+
const validRange = import_semver.validRange(normalizedVersion);
|
|
33682
|
+
if (validRange === null) return null;
|
|
33683
|
+
const minimumVersion = import_semver.minVersion(validRange);
|
|
33684
|
+
if (minimumVersion === null || minimumVersion.major > latestSupportedMajor) return null;
|
|
33685
|
+
if (import_semver.intersects(validRange, `>=${latestSupportedMajor + 1}.0.0`)) return null;
|
|
33686
|
+
return minimumVersion.major;
|
|
33687
|
+
};
|
|
33654
33688
|
const isConcreteDependencyVersion = (version) => {
|
|
33655
33689
|
const normalizedVersion = normalizeDependencyVersion(version);
|
|
33656
33690
|
return normalizedVersion !== null && /\d/.test(normalizedVersion);
|
|
@@ -33694,9 +33728,18 @@ const parseReactMajorMinor = (reactVersion) => {
|
|
|
33694
33728
|
};
|
|
33695
33729
|
};
|
|
33696
33730
|
const parseLowerBoundVersion = (versionSpec) => import_semver.validRange(versionSpec) !== null ? import_semver.minVersion(versionSpec) : import_semver.coerce(versionSpec);
|
|
33697
|
-
const
|
|
33698
|
-
if (typeof
|
|
33699
|
-
const
|
|
33731
|
+
const parseThreeRelease = (threeVersion) => {
|
|
33732
|
+
if (typeof threeVersion !== "string") return null;
|
|
33733
|
+
const normalizedVersion = normalizeDependencyVersion(threeVersion);
|
|
33734
|
+
if (normalizedVersion === null) return null;
|
|
33735
|
+
const lowerBound = parseLowerBoundVersion(normalizedVersion);
|
|
33736
|
+
if (lowerBound === null) return null;
|
|
33737
|
+
if (lowerBound.major > 0) return Number.MAX_SAFE_INTEGER;
|
|
33738
|
+
return lowerBound.minor > 0 ? lowerBound.minor : null;
|
|
33739
|
+
};
|
|
33740
|
+
const parseDependencyMajorMinor = (dependencyVersion) => {
|
|
33741
|
+
if (typeof dependencyVersion !== "string") return null;
|
|
33742
|
+
const trimmed = dependencyVersion.trim();
|
|
33700
33743
|
if (trimmed.length === 0) return null;
|
|
33701
33744
|
const lowerBound = parseLowerBoundVersion(trimmed);
|
|
33702
33745
|
if (lowerBound === null || lowerBound.major <= 0) return null;
|
|
@@ -33705,6 +33748,7 @@ const parseTailwindMajorMinor = (tailwindVersion) => {
|
|
|
33705
33748
|
minor: lowerBound.minor
|
|
33706
33749
|
};
|
|
33707
33750
|
};
|
|
33751
|
+
const parseTailwindMajorMinor = (tailwindVersion) => parseDependencyMajorMinor(tailwindVersion);
|
|
33708
33752
|
const hasUpperBoundOnlyPeerRange = (range) => {
|
|
33709
33753
|
if (typeof range !== "string") return false;
|
|
33710
33754
|
const normalizedRange = normalizeDependencyVersion(range);
|
|
@@ -33726,7 +33770,7 @@ const resolveEffectiveReactMajor = (reactVersion, packageJson) => {
|
|
|
33726
33770
|
if (peerFloor === null) return hasUpperBoundOnlyPeerRange(peerReactRange) ? null : installedReactMajor;
|
|
33727
33771
|
return installedReactMajor !== null ? Math.min(installedReactMajor, peerFloor) : peerFloor;
|
|
33728
33772
|
};
|
|
33729
|
-
const isCatalogReference = (version) => version.startsWith("catalog:");
|
|
33773
|
+
const isCatalogReference = (version) => typeof version === "string" && version.startsWith("catalog:");
|
|
33730
33774
|
const extractCatalogName = (version) => {
|
|
33731
33775
|
if (!isCatalogReference(version)) return null;
|
|
33732
33776
|
const name = version.slice(8).trim();
|
|
@@ -33876,6 +33920,12 @@ const TAILWIND_ZOD_SECTIONS = [
|
|
|
33876
33920
|
"devDependencies",
|
|
33877
33921
|
"peerDependencies"
|
|
33878
33922
|
];
|
|
33923
|
+
const DEPENDENCY_SPEC_SECTIONS = [
|
|
33924
|
+
"dependencies",
|
|
33925
|
+
"devDependencies",
|
|
33926
|
+
"peerDependencies",
|
|
33927
|
+
"optionalDependencies"
|
|
33928
|
+
];
|
|
33879
33929
|
const EMPTY_DEPENDENCY_INFO = {
|
|
33880
33930
|
reactVersion: null,
|
|
33881
33931
|
tailwindVersion: null,
|
|
@@ -33885,7 +33935,7 @@ const EMPTY_DEPENDENCY_INFO = {
|
|
|
33885
33935
|
const pickConcreteVersion = (packageJson, packageName, sections) => {
|
|
33886
33936
|
for (const section of sections) {
|
|
33887
33937
|
const version = packageJson[section]?.[packageName];
|
|
33888
|
-
if (version
|
|
33938
|
+
if (typeof version !== "string") continue;
|
|
33889
33939
|
if (isCatalogReference(version)) return null;
|
|
33890
33940
|
if (isConcreteDependencyVersion(version)) return version;
|
|
33891
33941
|
}
|
|
@@ -33917,13 +33967,16 @@ const extractDependencyInfo = (packageJson) => {
|
|
|
33917
33967
|
};
|
|
33918
33968
|
};
|
|
33919
33969
|
const getDependencySpec = (packageJson, packageName) => {
|
|
33920
|
-
const
|
|
33921
|
-
|
|
33970
|
+
for (const section of DEPENDENCY_SPEC_SECTIONS) {
|
|
33971
|
+
const spec = packageJson[section]?.[packageName];
|
|
33972
|
+
if (typeof spec === "string") return spec;
|
|
33973
|
+
}
|
|
33974
|
+
return null;
|
|
33922
33975
|
};
|
|
33923
33976
|
const getDependencyDeclaration = ({ packageJson, packageName, sections }) => {
|
|
33924
33977
|
for (const section of sections) {
|
|
33925
33978
|
const version = packageJson[section]?.[packageName];
|
|
33926
|
-
if (version
|
|
33979
|
+
if (typeof version !== "string") continue;
|
|
33927
33980
|
return {
|
|
33928
33981
|
catalogReference: extractCatalogName(version) ?? null,
|
|
33929
33982
|
hasDeclaration: true,
|
|
@@ -33957,24 +34010,15 @@ const getPreactVersion = (packageJson) => {
|
|
|
33957
34010
|
...packageJson.devDependencies
|
|
33958
34011
|
}.preact ?? null;
|
|
33959
34012
|
};
|
|
33960
|
-
const
|
|
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 }) => {
|
|
34013
|
+
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, sourceDirectory = rootDirectory, sourcePackageJson = rootPackageJson, version }) => {
|
|
33974
34014
|
if (version === null || !isCatalogReference(version)) return version;
|
|
33975
34015
|
const catalogName = extractCatalogName(version);
|
|
33976
|
-
const
|
|
33977
|
-
if (
|
|
34016
|
+
const resolvedSourceVersion = resolveCatalogVersion(sourcePackageJson, packageName, sourceDirectory, catalogName);
|
|
34017
|
+
if (resolvedSourceVersion) return resolvedSourceVersion;
|
|
34018
|
+
if (sourceDirectory !== rootDirectory || sourcePackageJson !== rootPackageJson) {
|
|
34019
|
+
const resolvedRootVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
|
|
34020
|
+
if (resolvedRootVersion) return resolvedRootVersion;
|
|
34021
|
+
}
|
|
33978
34022
|
const monorepoRoot = findMonorepoRoot(rootDirectory);
|
|
33979
34023
|
if (!monorepoRoot) return version;
|
|
33980
34024
|
const monorepoPackageJsonPath = Path.join(monorepoRoot, "package.json");
|
|
@@ -34172,7 +34216,75 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34172
34216
|
}
|
|
34173
34217
|
return packages;
|
|
34174
34218
|
};
|
|
34219
|
+
const getPreferredDependencyVersion = ({ packageJson, packageNames }) => {
|
|
34220
|
+
const allDependencies = {
|
|
34221
|
+
...packageJson.devDependencies,
|
|
34222
|
+
...packageJson.peerDependencies,
|
|
34223
|
+
...packageJson.dependencies
|
|
34224
|
+
};
|
|
34225
|
+
for (const packageName of packageNames) {
|
|
34226
|
+
const version = allDependencies[packageName];
|
|
34227
|
+
if (version !== void 0) return version;
|
|
34228
|
+
}
|
|
34229
|
+
return null;
|
|
34230
|
+
};
|
|
34231
|
+
const TANSTACK_REACT_QUERY_PACKAGES = ["@tanstack/react-query", "react-query"];
|
|
34232
|
+
const getTanStackQueryVersion = (packageJson) => {
|
|
34233
|
+
return getPreferredDependencyVersion({
|
|
34234
|
+
packageJson,
|
|
34235
|
+
packageNames: TANSTACK_REACT_QUERY_PACKAGES
|
|
34236
|
+
});
|
|
34237
|
+
};
|
|
34238
|
+
const STYLED_COMPONENTS_PACKAGES = ["styled-components"];
|
|
34239
|
+
const getStyledComponentsVersion = (packageJson) => {
|
|
34240
|
+
return getPreferredDependencyVersion({
|
|
34241
|
+
packageJson,
|
|
34242
|
+
packageNames: STYLED_COMPONENTS_PACKAGES
|
|
34243
|
+
});
|
|
34244
|
+
};
|
|
34245
|
+
const I18N_PACKAGES = [
|
|
34246
|
+
"i18next",
|
|
34247
|
+
"react-i18next",
|
|
34248
|
+
"next-i18next",
|
|
34249
|
+
"react-intl",
|
|
34250
|
+
"next-intl",
|
|
34251
|
+
"use-intl",
|
|
34252
|
+
"@formatjs/intl",
|
|
34253
|
+
"@lingui/core",
|
|
34254
|
+
"@lingui/react",
|
|
34255
|
+
"typesafe-i18n",
|
|
34256
|
+
"@tolgee/react",
|
|
34257
|
+
"react-intl-universal"
|
|
34258
|
+
];
|
|
34259
|
+
const hasI18nDependency = (packageJson) => {
|
|
34260
|
+
const allDependencies = {
|
|
34261
|
+
...packageJson.peerDependencies,
|
|
34262
|
+
...packageJson.dependencies,
|
|
34263
|
+
...packageJson.devDependencies,
|
|
34264
|
+
...packageJson.optionalDependencies
|
|
34265
|
+
};
|
|
34266
|
+
return I18N_PACKAGES.some((packageName) => allDependencies[packageName] !== void 0);
|
|
34267
|
+
};
|
|
34175
34268
|
const REANIMATED_DEPENDENCY_NAME = "react-native-reanimated";
|
|
34269
|
+
const MOBX_REACT_PACKAGE_NAME = "mobx-react";
|
|
34270
|
+
const MOBX_REACT_LITE_PACKAGE_NAME = "mobx-react-lite";
|
|
34271
|
+
const MOBX_STATE_TREE_PACKAGE_NAME = "mobx-state-tree";
|
|
34272
|
+
const MOBX_REACT_OBSERVER_PACKAGE_NAME = "mobx-react-observer";
|
|
34273
|
+
const REACT_THREE_FIBER_DEPENDENCY_NAMES = ["@react-three/fiber", "react-three-fiber"];
|
|
34274
|
+
const REACT_THREE_FIBER_SECTIONS = [
|
|
34275
|
+
"dependencies",
|
|
34276
|
+
"peerDependencies",
|
|
34277
|
+
"optionalDependencies",
|
|
34278
|
+
"devDependencies"
|
|
34279
|
+
];
|
|
34280
|
+
const THREE_DEPENDENCY_SECTIONS = [
|
|
34281
|
+
"dependencies",
|
|
34282
|
+
"peerDependencies",
|
|
34283
|
+
"optionalDependencies",
|
|
34284
|
+
"devDependencies"
|
|
34285
|
+
];
|
|
34286
|
+
const REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES = [...REACT_THREE_FIBER_DEPENDENCY_NAMES, "@react-three/drei"];
|
|
34287
|
+
const THREE_DEPENDENCY_NAMES = [...REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES, "three"];
|
|
34176
34288
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34177
34289
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34178
34290
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34183,7 +34295,7 @@ const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootD
|
|
|
34183
34295
|
if (!dependencyDeclaration.hasDeclaration) return null;
|
|
34184
34296
|
return concreteVersion ?? resolveCatalogVersion(workspacePackageJson, packageName, workspaceDirectory, dependencyDeclaration.catalogReference) ?? resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, dependencyDeclaration.catalogReference);
|
|
34185
34297
|
};
|
|
34186
|
-
const
|
|
34298
|
+
const shouldReplaceWithLowerMajor = (currentVersion, nextVersion) => {
|
|
34187
34299
|
if (!currentVersion) return true;
|
|
34188
34300
|
const currentMajor = parseReactMajor(currentVersion);
|
|
34189
34301
|
const nextMajor = parseReactMajor(nextVersion);
|
|
@@ -34191,7 +34303,62 @@ const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
|
34191
34303
|
if (nextMajor === null) return false;
|
|
34192
34304
|
return nextMajor < currentMajor;
|
|
34193
34305
|
};
|
|
34194
|
-
const
|
|
34306
|
+
const shouldReplaceSupportedDependencyFact = (currentFact, nextFact, latestSupportedMajor) => {
|
|
34307
|
+
if (currentFact.version === null) return true;
|
|
34308
|
+
if (nextFact.version === null) return false;
|
|
34309
|
+
const currentMajor = getLowestDependencyMajor(currentFact.version);
|
|
34310
|
+
const nextMajor = getLowestDependencyMajor(nextFact.version);
|
|
34311
|
+
if (currentMajor === null) return false;
|
|
34312
|
+
if (nextMajor === null) return true;
|
|
34313
|
+
if (currentMajor > latestSupportedMajor) return false;
|
|
34314
|
+
if (nextMajor > latestSupportedMajor) return true;
|
|
34315
|
+
return nextMajor < currentMajor;
|
|
34316
|
+
};
|
|
34317
|
+
const shouldReplaceStyledComponentsVersion = (currentVersion, nextVersion) => {
|
|
34318
|
+
if (!currentVersion) return true;
|
|
34319
|
+
const currentMajor = getLowestDependencyMajor(currentVersion);
|
|
34320
|
+
const nextMajor = getLowestDependencyMajor(nextVersion);
|
|
34321
|
+
if (currentMajor === null) return nextMajor !== null && nextMajor < 6;
|
|
34322
|
+
if (nextMajor === null) return currentMajor >= 6;
|
|
34323
|
+
return nextMajor < currentMajor;
|
|
34324
|
+
};
|
|
34325
|
+
const selectOldestDependencyVersion = (currentVersion, nextVersion) => {
|
|
34326
|
+
if (currentVersion === null || nextVersion === null) return null;
|
|
34327
|
+
const current = parseDependencyMajorMinor(currentVersion);
|
|
34328
|
+
const next = parseDependencyMajorMinor(nextVersion);
|
|
34329
|
+
if (current === null) return currentVersion;
|
|
34330
|
+
if (next === null) return nextVersion;
|
|
34331
|
+
if (next.major !== current.major) return next.major < current.major ? nextVersion : currentVersion;
|
|
34332
|
+
return next.minor < current.minor ? nextVersion : currentVersion;
|
|
34333
|
+
};
|
|
34334
|
+
const shouldReplaceMobxFact = (currentFact, nextFact) => {
|
|
34335
|
+
if (currentFact.sourceDirectory === null) return true;
|
|
34336
|
+
if (currentFact.version === null) return false;
|
|
34337
|
+
if (nextFact.version === null) return true;
|
|
34338
|
+
const currentMajor = getDependencyMajorWithinSupportedRange(currentFact.version, 6);
|
|
34339
|
+
const nextMajor = getDependencyMajorWithinSupportedRange(nextFact.version, 6);
|
|
34340
|
+
if (currentMajor === null) return false;
|
|
34341
|
+
if (nextMajor === null) return true;
|
|
34342
|
+
return selectOldestDependencyVersion(currentFact.version, nextFact.version) === nextFact.version;
|
|
34343
|
+
};
|
|
34344
|
+
const collectBindingVersion = (facts, packageJson, directory, packageName) => {
|
|
34345
|
+
const version = getDependencySpec(packageJson, packageName);
|
|
34346
|
+
if (version === null) return;
|
|
34347
|
+
const resolvedVersion = resolveCatalogBackedDependencyVersion({
|
|
34348
|
+
rootDirectory: directory,
|
|
34349
|
+
rootPackageJson: packageJson,
|
|
34350
|
+
packageName,
|
|
34351
|
+
version
|
|
34352
|
+
});
|
|
34353
|
+
if (packageName === MOBX_REACT_PACKAGE_NAME) {
|
|
34354
|
+
facts.mobxReactVersion = facts.hasMobxReact ? selectOldestDependencyVersion(facts.mobxReactVersion, resolvedVersion) : resolvedVersion;
|
|
34355
|
+
facts.hasMobxReact = true;
|
|
34356
|
+
return;
|
|
34357
|
+
}
|
|
34358
|
+
facts.mobxReactLiteVersion = facts.hasMobxReactLite ? selectOldestDependencyVersion(facts.mobxReactLiteVersion, resolvedVersion) : resolvedVersion;
|
|
34359
|
+
facts.hasMobxReactLite = true;
|
|
34360
|
+
};
|
|
34361
|
+
const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, rootPackageJson) => {
|
|
34195
34362
|
if (facts.expo.version === null) {
|
|
34196
34363
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34197
34364
|
if (spec !== null) facts.expo = {
|
|
@@ -34213,13 +34380,113 @@ const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
|
34213
34380
|
sourceDirectory: directory
|
|
34214
34381
|
};
|
|
34215
34382
|
}
|
|
34383
|
+
const mobxSpec = getDependencySpec(packageJson, "mobx");
|
|
34384
|
+
if (mobxSpec !== null) {
|
|
34385
|
+
const nextMobxFact = {
|
|
34386
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34387
|
+
rootDirectory: directory,
|
|
34388
|
+
rootPackageJson: packageJson,
|
|
34389
|
+
packageName: "mobx",
|
|
34390
|
+
version: mobxSpec
|
|
34391
|
+
}),
|
|
34392
|
+
sourceDirectory: directory
|
|
34393
|
+
};
|
|
34394
|
+
if (shouldReplaceMobxFact(facts.mobx, nextMobxFact)) facts.mobx = nextMobxFact;
|
|
34395
|
+
}
|
|
34396
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_PACKAGE_NAME);
|
|
34397
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_LITE_PACKAGE_NAME);
|
|
34398
|
+
facts.hasMobxStateTree = facts.hasMobxStateTree || getDependencySpec(packageJson, MOBX_STATE_TREE_PACKAGE_NAME) !== null;
|
|
34399
|
+
facts.hasMobxReactObserver = facts.hasMobxReactObserver || getDependencySpec(packageJson, MOBX_REACT_OBSERVER_PACKAGE_NAME) !== null;
|
|
34400
|
+
const zustandSpec = getDependencySpec(packageJson, "zustand");
|
|
34401
|
+
if (zustandSpec !== null) {
|
|
34402
|
+
const nextZustandFact = {
|
|
34403
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34404
|
+
rootDirectory: directory,
|
|
34405
|
+
rootPackageJson: packageJson,
|
|
34406
|
+
packageName: "zustand",
|
|
34407
|
+
version: zustandSpec
|
|
34408
|
+
}),
|
|
34409
|
+
sourceDirectory: directory
|
|
34410
|
+
};
|
|
34411
|
+
if (shouldReplaceSupportedDependencyFact(facts.zustand, nextZustandFact, 5)) facts.zustand = nextZustandFact;
|
|
34412
|
+
}
|
|
34216
34413
|
if (facts.reanimatedVersion === null) {
|
|
34217
34414
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34218
34415
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34219
34416
|
}
|
|
34417
|
+
if (facts.valtioVersion === null) {
|
|
34418
|
+
const spec = getDependencySpec(packageJson, "valtio");
|
|
34419
|
+
if (spec !== null) facts.valtioVersion = spec;
|
|
34420
|
+
}
|
|
34421
|
+
facts.tanstackQueryVersion ??= getTanStackQueryVersion(packageJson);
|
|
34422
|
+
const styledComponentsVersion = resolveCatalogBackedDependencyVersion({
|
|
34423
|
+
rootDirectory: directory,
|
|
34424
|
+
rootPackageJson: packageJson,
|
|
34425
|
+
packageName: "styled-components",
|
|
34426
|
+
version: getStyledComponentsVersion(packageJson)
|
|
34427
|
+
});
|
|
34428
|
+
if (styledComponentsVersion && shouldReplaceStyledComponentsVersion(facts.styledComponentsVersion, styledComponentsVersion)) facts.styledComponentsVersion = styledComponentsVersion;
|
|
34429
|
+
facts.hasI18nLibrary = facts.hasI18nLibrary || hasI18nDependency(packageJson);
|
|
34430
|
+
for (const packageName of REACT_THREE_FIBER_DEPENDENCY_NAMES) {
|
|
34431
|
+
const version = resolveCatalogBackedDependencyVersion({
|
|
34432
|
+
rootDirectory,
|
|
34433
|
+
rootPackageJson,
|
|
34434
|
+
sourceDirectory: directory,
|
|
34435
|
+
sourcePackageJson: packageJson,
|
|
34436
|
+
packageName,
|
|
34437
|
+
version: getDependencyDeclaration({
|
|
34438
|
+
packageName,
|
|
34439
|
+
packageJson,
|
|
34440
|
+
sections: REACT_THREE_FIBER_SECTIONS
|
|
34441
|
+
}).version
|
|
34442
|
+
});
|
|
34443
|
+
if (version === null) continue;
|
|
34444
|
+
if (shouldReplaceWithLowerMajor(facts.reactThreeFiber.version, version)) facts.reactThreeFiber = {
|
|
34445
|
+
packageName,
|
|
34446
|
+
version,
|
|
34447
|
+
sourceDirectory: directory
|
|
34448
|
+
};
|
|
34449
|
+
}
|
|
34450
|
+
const threeVersion = resolveCatalogBackedDependencyVersion({
|
|
34451
|
+
rootDirectory,
|
|
34452
|
+
rootPackageJson,
|
|
34453
|
+
sourceDirectory: directory,
|
|
34454
|
+
sourcePackageJson: packageJson,
|
|
34455
|
+
packageName: "three",
|
|
34456
|
+
version: getDependencyDeclaration({
|
|
34457
|
+
packageName: "three",
|
|
34458
|
+
packageJson,
|
|
34459
|
+
sections: THREE_DEPENDENCY_SECTIONS
|
|
34460
|
+
}).version
|
|
34461
|
+
});
|
|
34462
|
+
if (threeVersion !== null) {
|
|
34463
|
+
const currentRelease = parseThreeRelease(facts.threeVersion);
|
|
34464
|
+
const nextRelease = parseThreeRelease(threeVersion);
|
|
34465
|
+
if (facts.threeVersion === null || nextRelease !== null && (currentRelease === null || nextRelease < currentRelease)) facts.threeVersion = threeVersion;
|
|
34466
|
+
}
|
|
34220
34467
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34221
34468
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34222
34469
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34470
|
+
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34471
|
+
if (remotionSpec !== null) {
|
|
34472
|
+
facts.hasRemotionDependency = true;
|
|
34473
|
+
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34474
|
+
rootDirectory,
|
|
34475
|
+
rootPackageJson,
|
|
34476
|
+
packageName: "remotion",
|
|
34477
|
+
version: remotionSpec
|
|
34478
|
+
});
|
|
34479
|
+
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34480
|
+
if (remotionMajorVersion === null) {
|
|
34481
|
+
facts.hasUnknownRemotionVersion = true;
|
|
34482
|
+
facts.remotionVersion = null;
|
|
34483
|
+
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34484
|
+
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34485
|
+
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34486
|
+
}
|
|
34487
|
+
}
|
|
34488
|
+
facts.hasThree = facts.hasThree || THREE_DEPENDENCY_NAMES.some((dependencyName) => getDependencySpec(packageJson, dependencyName) !== null);
|
|
34489
|
+
facts.hasReactThreeFiber = facts.hasReactThreeFiber || REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES.some((dependencyName) => getDependencySpec(packageJson, dependencyName) !== null);
|
|
34223
34490
|
};
|
|
34224
34491
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34225
34492
|
const facts = {
|
|
@@ -34239,12 +34506,41 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34239
34506
|
version: null,
|
|
34240
34507
|
sourceDirectory: null
|
|
34241
34508
|
},
|
|
34509
|
+
valtioVersion: null,
|
|
34510
|
+
mobx: {
|
|
34511
|
+
version: null,
|
|
34512
|
+
sourceDirectory: null
|
|
34513
|
+
},
|
|
34514
|
+
hasMobxReact: false,
|
|
34515
|
+
mobxReactVersion: null,
|
|
34516
|
+
hasMobxReactLite: false,
|
|
34517
|
+
mobxReactLiteVersion: null,
|
|
34518
|
+
hasMobxStateTree: false,
|
|
34519
|
+
hasMobxReactObserver: false,
|
|
34520
|
+
zustand: {
|
|
34521
|
+
version: null,
|
|
34522
|
+
sourceDirectory: null
|
|
34523
|
+
},
|
|
34524
|
+
tanstackQueryVersion: null,
|
|
34525
|
+
styledComponentsVersion: null,
|
|
34526
|
+
hasI18nLibrary: false,
|
|
34242
34527
|
hasReactNativeAwarePackage: false,
|
|
34243
34528
|
hasReanimatedAwarePackage: false,
|
|
34244
34529
|
hasSsrDependency: false,
|
|
34530
|
+
hasRemotionDependency: false,
|
|
34531
|
+
hasUnknownRemotionVersion: false,
|
|
34532
|
+
remotionVersion: null,
|
|
34533
|
+
hasThree: false,
|
|
34534
|
+
threeVersion: null,
|
|
34535
|
+
hasReactThreeFiber: false,
|
|
34536
|
+
reactThreeFiber: {
|
|
34537
|
+
packageName: null,
|
|
34538
|
+
version: null,
|
|
34539
|
+
sourceDirectory: null
|
|
34540
|
+
},
|
|
34245
34541
|
reanimatedVersion: null
|
|
34246
34542
|
};
|
|
34247
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34543
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory, rootDirectory, rootPackageJson);
|
|
34248
34544
|
let isReactGroupSettled = !collectReactGroup;
|
|
34249
34545
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34250
34546
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
@@ -34253,7 +34549,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34253
34549
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34254
34550
|
visitedDirectories.add(workspaceDirectory);
|
|
34255
34551
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34256
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34552
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory, rootDirectory, rootPackageJson);
|
|
34257
34553
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34258
34554
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34259
34555
|
if (isReactGroupSettled) continue;
|
|
@@ -34284,7 +34580,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34284
34580
|
workspaceDirectory,
|
|
34285
34581
|
workspacePackageJson
|
|
34286
34582
|
});
|
|
34287
|
-
if (reactVersion &&
|
|
34583
|
+
if (reactVersion && shouldReplaceWithLowerMajor(facts.reactVersion, reactVersion)) facts.reactVersion = reactVersion;
|
|
34288
34584
|
if (tailwindVersion && !facts.tailwindVersion) facts.tailwindVersion = tailwindVersion;
|
|
34289
34585
|
if (zodVersion && !facts.zodVersion) facts.zodVersion = zodVersion;
|
|
34290
34586
|
const settledReactMajor = parseReactMajor(facts.reactVersion);
|
|
@@ -34477,11 +34773,35 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34477
34773
|
tailwindVersion: null,
|
|
34478
34774
|
zodVersion: null,
|
|
34479
34775
|
zodMajorVersion: null,
|
|
34776
|
+
mobxVersion: null,
|
|
34777
|
+
mobxMajorVersion: null,
|
|
34778
|
+
hasMobxReact: false,
|
|
34779
|
+
mobxReactVersion: null,
|
|
34780
|
+
hasMobxReactLite: false,
|
|
34781
|
+
mobxReactLiteVersion: null,
|
|
34782
|
+
hasMobxStateTree: false,
|
|
34783
|
+
hasMobxReactObserver: false,
|
|
34784
|
+
zustandVersion: null,
|
|
34785
|
+
zustandMajorVersion: null,
|
|
34480
34786
|
framework: "unknown",
|
|
34481
34787
|
hasTypeScript: hasOwnTsConfig,
|
|
34482
34788
|
hasReactCompiler: false,
|
|
34483
34789
|
hasReactCompilerLintPlugin: false,
|
|
34484
34790
|
hasTanStackQuery: false,
|
|
34791
|
+
valtioVersion: null,
|
|
34792
|
+
valtioMajorVersion: null,
|
|
34793
|
+
hasRemotion: false,
|
|
34794
|
+
remotionVersion: null,
|
|
34795
|
+
remotionMajorVersion: null,
|
|
34796
|
+
hasI18nLibrary: false,
|
|
34797
|
+
tanstackQueryVersion: null,
|
|
34798
|
+
styledComponentsVersion: null,
|
|
34799
|
+
hasThree: false,
|
|
34800
|
+
threeVersion: null,
|
|
34801
|
+
threeRelease: null,
|
|
34802
|
+
hasReactThreeFiber: false,
|
|
34803
|
+
reactThreeFiberVersion: null,
|
|
34804
|
+
reactThreeFiberMajorVersion: null,
|
|
34485
34805
|
hasSsrDependency: false,
|
|
34486
34806
|
preactVersion: null,
|
|
34487
34807
|
preactMajorVersion: null,
|
|
@@ -34580,6 +34900,12 @@ const discoverProject = (directory) => {
|
|
|
34580
34900
|
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
34581
34901
|
version: workspaceFacts.shopifyFlashList.version
|
|
34582
34902
|
}) : null;
|
|
34903
|
+
const zustandVersion = resolveCatalogBackedDependencyVersion({
|
|
34904
|
+
rootDirectory: directory,
|
|
34905
|
+
rootPackageJson: packageJson,
|
|
34906
|
+
packageName: "zustand",
|
|
34907
|
+
version: workspaceFacts.zustand.version
|
|
34908
|
+
});
|
|
34583
34909
|
const hasReanimated = hasReactNativeWorkspace && workspaceFacts.hasReanimatedAwarePackage;
|
|
34584
34910
|
const reanimatedVersion = hasReanimated ? workspaceFacts.reanimatedVersion : null;
|
|
34585
34911
|
const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
|
|
@@ -34588,7 +34914,33 @@ const discoverProject = (directory) => {
|
|
|
34588
34914
|
packageName: "next",
|
|
34589
34915
|
version: workspaceFacts.next.version
|
|
34590
34916
|
}) : null;
|
|
34917
|
+
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
34918
|
+
rootDirectory: directory,
|
|
34919
|
+
rootPackageJson: packageJson,
|
|
34920
|
+
packageName: "valtio",
|
|
34921
|
+
version: workspaceFacts.valtioVersion
|
|
34922
|
+
});
|
|
34923
|
+
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
34924
|
+
rootDirectory: directory,
|
|
34925
|
+
rootPackageJson: packageJson,
|
|
34926
|
+
packageName: "mobx",
|
|
34927
|
+
version: workspaceFacts.mobx.version
|
|
34928
|
+
});
|
|
34591
34929
|
const preactVersion = getPreactVersion(packageJson);
|
|
34930
|
+
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34931
|
+
const tanstackQueryVersion = getTanStackQueryVersion(packageJson) ?? workspaceFacts.tanstackQueryVersion;
|
|
34932
|
+
const reactThreeFiberVersion = workspaceFacts.reactThreeFiber.packageName ? resolveCatalogBackedDependencyVersion({
|
|
34933
|
+
rootDirectory: directory,
|
|
34934
|
+
rootPackageJson: packageJson,
|
|
34935
|
+
packageName: workspaceFacts.reactThreeFiber.packageName,
|
|
34936
|
+
version: workspaceFacts.reactThreeFiber.version
|
|
34937
|
+
}) : null;
|
|
34938
|
+
const threeVersion = resolveCatalogBackedDependencyVersion({
|
|
34939
|
+
rootDirectory: directory,
|
|
34940
|
+
rootPackageJson: packageJson,
|
|
34941
|
+
packageName: "three",
|
|
34942
|
+
version: workspaceFacts.threeVersion
|
|
34943
|
+
});
|
|
34592
34944
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34593
34945
|
const projectInfo = {
|
|
34594
34946
|
rootDirectory: directory,
|
|
@@ -34598,11 +34950,35 @@ const discoverProject = (directory) => {
|
|
|
34598
34950
|
tailwindVersion,
|
|
34599
34951
|
zodVersion,
|
|
34600
34952
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
34953
|
+
mobxVersion,
|
|
34954
|
+
mobxMajorVersion: mobxVersion === null ? null : getDependencyMajorWithinSupportedRange(mobxVersion, 6),
|
|
34955
|
+
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
34956
|
+
mobxReactVersion: workspaceFacts.mobxReactVersion,
|
|
34957
|
+
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
34958
|
+
mobxReactLiteVersion: workspaceFacts.mobxReactLiteVersion,
|
|
34959
|
+
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
34960
|
+
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
34961
|
+
zustandVersion,
|
|
34962
|
+
zustandMajorVersion: zustandVersion === null ? null : getLowestDependencyMajor(zustandVersion),
|
|
34601
34963
|
framework,
|
|
34602
34964
|
hasTypeScript,
|
|
34603
34965
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34604
34966
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
34605
|
-
hasTanStackQuery:
|
|
34967
|
+
hasTanStackQuery: tanstackQueryVersion !== null,
|
|
34968
|
+
hasI18nLibrary: workspaceFacts.hasI18nLibrary,
|
|
34969
|
+
tanstackQueryVersion,
|
|
34970
|
+
styledComponentsVersion: workspaceFacts.styledComponentsVersion,
|
|
34971
|
+
valtioVersion,
|
|
34972
|
+
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
34973
|
+
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
34974
|
+
remotionVersion,
|
|
34975
|
+
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
34976
|
+
hasThree: workspaceFacts.hasThree,
|
|
34977
|
+
threeVersion,
|
|
34978
|
+
threeRelease: parseThreeRelease(threeVersion),
|
|
34979
|
+
hasReactThreeFiber: workspaceFacts.hasReactThreeFiber,
|
|
34980
|
+
reactThreeFiberVersion,
|
|
34981
|
+
reactThreeFiberMajorVersion: reactThreeFiberVersion === null ? null : getLowestDependencyMajor(reactThreeFiberVersion),
|
|
34606
34982
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34607
34983
|
preactVersion,
|
|
34608
34984
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
@@ -34836,7 +35212,6 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
34836
35212
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
34837
35213
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
34838
35214
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34839
|
-
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
34840
35215
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
34841
35216
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
34842
35217
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37049,9 +37424,25 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37049
37424
|
".babelrc.json"
|
|
37050
37425
|
];
|
|
37051
37426
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37427
|
+
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37428
|
+
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37429
|
+
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37430
|
+
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37052
37431
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37053
37432
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37433
|
+
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37434
|
+
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37435
|
+
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37436
|
+
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37437
|
+
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37438
|
+
if (normalizedVersionRange === null) return false;
|
|
37439
|
+
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37440
|
+
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37441
|
+
};
|
|
37442
|
+
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37054
37443
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37444
|
+
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37445
|
+
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37055
37446
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37056
37447
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37057
37448
|
if (!isFile(filePath)) continue;
|
|
@@ -37061,7 +37452,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37061
37452
|
} catch {
|
|
37062
37453
|
continue;
|
|
37063
37454
|
}
|
|
37064
|
-
if (
|
|
37455
|
+
if (shouldReportLegacyPreset && LEGACY_PRESET_REFERENCE.test(contents)) return [buildReactNativeDiagnostic({
|
|
37065
37456
|
filePath: fileName,
|
|
37066
37457
|
rule: "rn-no-metro-babel-preset",
|
|
37067
37458
|
severity: "error",
|
|
@@ -37084,12 +37475,6 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37084
37475
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37085
37476
|
};
|
|
37086
37477
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37087
|
-
const DEPENDENCY_SECTIONS = [
|
|
37088
|
-
"dependencies",
|
|
37089
|
-
"devDependencies",
|
|
37090
|
-
"peerDependencies",
|
|
37091
|
-
"optionalDependencies"
|
|
37092
|
-
];
|
|
37093
37478
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37094
37479
|
"19.0": {
|
|
37095
37480
|
rceFixedVersion: "19.0.1",
|
|
@@ -37136,20 +37521,13 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37136
37521
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37137
37522
|
return [...directories];
|
|
37138
37523
|
};
|
|
37139
|
-
const readDeclaredSpec = (packageJson, packageName) => {
|
|
37140
|
-
for (const section of DEPENDENCY_SECTIONS) {
|
|
37141
|
-
const spec = packageJson[section]?.[packageName];
|
|
37142
|
-
if (typeof spec === "string") return spec;
|
|
37143
|
-
}
|
|
37144
|
-
return null;
|
|
37145
|
-
};
|
|
37146
37524
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37147
37525
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37148
37526
|
if (isFile(manifestPath)) {
|
|
37149
37527
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37150
37528
|
if (installedVersion !== null) return installedVersion;
|
|
37151
37529
|
}
|
|
37152
|
-
const candidateSpecs = [
|
|
37530
|
+
const candidateSpecs = [getDependencySpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37153
37531
|
for (const spec of candidateSpecs) {
|
|
37154
37532
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37155
37533
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -37801,10 +38179,10 @@ const SSR_FRAMEWORKS = new Set([
|
|
|
37801
38179
|
"gatsby",
|
|
37802
38180
|
"tanstack-start"
|
|
37803
38181
|
]);
|
|
37804
|
-
const
|
|
37805
|
-
if (
|
|
37806
|
-
const
|
|
37807
|
-
for (let candidate = earliest; candidate <=
|
|
38182
|
+
const addVersionCapabilityLadder = (capabilities, name, detectedVersion, earliest, latest) => {
|
|
38183
|
+
if (detectedVersion === null) return;
|
|
38184
|
+
const cappedVersion = Math.min(detectedVersion, latest);
|
|
38185
|
+
for (let candidate = earliest; candidate <= cappedVersion; candidate += 1) capabilities.add(`${name}:${candidate}`);
|
|
37808
38186
|
};
|
|
37809
38187
|
const buildCapabilities = (project) => {
|
|
37810
38188
|
const capabilities = /* @__PURE__ */ new Set();
|
|
@@ -37817,24 +38195,77 @@ const buildCapabilities = (project) => {
|
|
|
37817
38195
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
37818
38196
|
if (project.isStaticExport) capabilities.add("nextjs:static-export");
|
|
37819
38197
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
37820
|
-
|
|
38198
|
+
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 16) capabilities.add("nextjs:16");
|
|
38199
|
+
addVersionCapabilityLadder(capabilities, "react", project.reactMajorVersion, 17, 30);
|
|
37821
38200
|
if (project.reactMajorVersion !== null && project.reactMajorVersion >= 19 && isMajorMinorAtLeast(parseReactMajorMinor(project.reactVersion), {
|
|
37822
38201
|
major: 19,
|
|
37823
38202
|
minor: 2
|
|
37824
38203
|
})) capabilities.add("react:19.2");
|
|
37825
|
-
if (project.tailwindVersion !== null)
|
|
37826
|
-
|
|
37827
|
-
|
|
37828
|
-
|
|
37829
|
-
|
|
38204
|
+
if (project.tailwindVersion !== null) {
|
|
38205
|
+
capabilities.add("tailwind");
|
|
38206
|
+
const tailwindVersion = parseTailwindMajorMinor(project.tailwindVersion);
|
|
38207
|
+
if (isMajorMinorAtLeast(tailwindVersion, {
|
|
38208
|
+
major: 3,
|
|
38209
|
+
minor: 4
|
|
38210
|
+
})) capabilities.add("tailwind:3.4");
|
|
38211
|
+
if (tailwindVersion !== null && isMajorMinorAtLeast(tailwindVersion, {
|
|
38212
|
+
major: 4,
|
|
38213
|
+
minor: 0
|
|
38214
|
+
})) capabilities.add("tailwind:4");
|
|
38215
|
+
}
|
|
37830
38216
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
37831
38217
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
38218
|
+
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
38219
|
+
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
38220
|
+
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
38221
|
+
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
38222
|
+
const mobxReactVersion = parseDependencyMajorMinor(project.mobxReactVersion);
|
|
38223
|
+
const mobxReactLiteVersion = parseDependencyMajorMinor(project.mobxReactLiteVersion);
|
|
38224
|
+
const hasMobxReactObserverMemoGuard = mobxReactVersion !== null && isMajorMinorAtLeast(mobxReactVersion, {
|
|
38225
|
+
major: 7,
|
|
38226
|
+
minor: 3
|
|
38227
|
+
});
|
|
38228
|
+
const hasMobxReactLiteObserverMemoGuard = mobxReactLiteVersion !== null && isMajorMinorAtLeast(mobxReactLiteVersion, {
|
|
38229
|
+
major: 3,
|
|
38230
|
+
minor: 3
|
|
38231
|
+
});
|
|
38232
|
+
if (hasMobxReactObserverMemoGuard) capabilities.add("mobx-react-observer-memo-guard");
|
|
38233
|
+
if (hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-lite-observer-memo-guard");
|
|
38234
|
+
if (hasMobxReactObserverMemoGuard || hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-binding-observer-memo-guard");
|
|
38235
|
+
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
38236
|
+
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
38237
|
+
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addVersionCapabilityLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
38238
|
+
const mobxVersion = parseDependencyMajorMinor(project.mobxVersion);
|
|
38239
|
+
if (project.mobxMajorVersion === 6 && mobxVersion !== null && isMajorMinorAtLeast(mobxVersion, {
|
|
38240
|
+
major: 6,
|
|
38241
|
+
minor: 10
|
|
38242
|
+
})) capabilities.add("mobx:6.10");
|
|
38243
|
+
if (project.zustandVersion !== void 0 && project.zustandVersion !== null) capabilities.add("zustand");
|
|
38244
|
+
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addVersionCapabilityLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
37832
38245
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
37833
38246
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
37834
|
-
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
38247
|
+
if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
|
|
38248
|
+
if (project.styledComponentsVersion) {
|
|
38249
|
+
capabilities.add("styled-components");
|
|
38250
|
+
const styledComponentsMajor = getLowestDependencyMajor(project.styledComponentsVersion);
|
|
38251
|
+
if (styledComponentsMajor !== null && styledComponentsMajor >= 6) capabilities.add("styled-components:6");
|
|
38252
|
+
}
|
|
38253
|
+
if (project.hasI18nLibrary) capabilities.add("i18n");
|
|
38254
|
+
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
38255
|
+
addVersionCapabilityLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
38256
|
+
if (project.hasRemotion) {
|
|
38257
|
+
capabilities.add("remotion");
|
|
38258
|
+
addVersionCapabilityLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
38259
|
+
}
|
|
38260
|
+
if (project.hasThree || project.hasReactThreeFiber) capabilities.add("three");
|
|
38261
|
+
addVersionCapabilityLadder(capabilities, "three", project.threeRelease ?? null, 145, 250);
|
|
38262
|
+
if (project.hasReactThreeFiber) {
|
|
38263
|
+
capabilities.add("r3f");
|
|
38264
|
+
addVersionCapabilityLadder(capabilities, "r3f", project.reactThreeFiberMajorVersion ?? null, 3, 10);
|
|
38265
|
+
}
|
|
37835
38266
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
37836
38267
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
37837
|
-
|
|
38268
|
+
addVersionCapabilityLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
37838
38269
|
if (project.preactVersion !== null && project.reactVersion === null) capabilities.add("pure-preact");
|
|
37839
38270
|
return capabilities;
|
|
37840
38271
|
};
|
|
@@ -37846,7 +38277,7 @@ const getCapabilities = (project) => {
|
|
|
37846
38277
|
capabilitiesByProject.set(project, capabilities);
|
|
37847
38278
|
return capabilities;
|
|
37848
38279
|
};
|
|
37849
|
-
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen) => {
|
|
38280
|
+
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen, includedTags) => {
|
|
37850
38281
|
if (requires) {
|
|
37851
38282
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
37852
38283
|
}
|
|
@@ -37857,20 +38288,29 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhe
|
|
|
37857
38288
|
if (tags) {
|
|
37858
38289
|
for (const tag of tags) if (ignoredTags.has(tag)) return false;
|
|
37859
38290
|
}
|
|
38291
|
+
if (includedTags && includedTags.size > 0) {
|
|
38292
|
+
if (!tags?.some((tag) => includedTags.has(tag))) return false;
|
|
38293
|
+
}
|
|
37860
38294
|
return true;
|
|
37861
38295
|
};
|
|
38296
|
+
const shouldEnableRuleByDefaultStatus = (options) => options.defaultEnabled !== false || options.hasExplicitOverride === true || options.includeTagDefaults && options.hasIncludedTags;
|
|
37862
38297
|
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
37863
38298
|
setImmediate(resolve);
|
|
37864
38299
|
});
|
|
37865
38300
|
const createSecurityScanSession = (rootDirectory, options) => {
|
|
37866
38301
|
const capabilities = options.project ? getCapabilities(options.project) : /* @__PURE__ */ new Set();
|
|
37867
38302
|
const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
|
|
38303
|
+
const includedTags = options.includedTags ?? /* @__PURE__ */ new Set();
|
|
37868
38304
|
const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
|
|
37869
38305
|
const rule = entry.rule;
|
|
37870
38306
|
const scan = rule.scan;
|
|
37871
38307
|
if (typeof scan !== "function") return [];
|
|
37872
|
-
if (
|
|
37873
|
-
|
|
38308
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
38309
|
+
defaultEnabled: rule.defaultEnabled,
|
|
38310
|
+
includeTagDefaults: options.includeTagDefaults === true,
|
|
38311
|
+
hasIncludedTags: includedTags.size > 0
|
|
38312
|
+
})) return [];
|
|
38313
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) return [];
|
|
37874
38314
|
return [{
|
|
37875
38315
|
entry,
|
|
37876
38316
|
scan,
|
|
@@ -39856,8 +40296,9 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
39856
40296
|
}
|
|
39857
40297
|
return enabled;
|
|
39858
40298
|
};
|
|
39859
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
39860
|
-
const
|
|
40299
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
40300
|
+
const hasIncludedTags = includedTags.size > 0;
|
|
40301
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
39861
40302
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
39862
40303
|
const jsPlugins = [];
|
|
39863
40304
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -39872,9 +40313,14 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39872
40313
|
if (rule.scan !== void 0) continue;
|
|
39873
40314
|
if (customRulesOnly && registryEntry.originallyExternal) continue;
|
|
39874
40315
|
if (rule.framework !== "global" && !rule.requires) continue;
|
|
39875
|
-
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen)) continue;
|
|
40316
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) continue;
|
|
39876
40317
|
const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
|
|
39877
|
-
if (
|
|
40318
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
40319
|
+
defaultEnabled: rule.defaultEnabled,
|
|
40320
|
+
includeTagDefaults,
|
|
40321
|
+
hasIncludedTags,
|
|
40322
|
+
hasExplicitOverride: explicitRuleOverride !== void 0
|
|
40323
|
+
})) continue;
|
|
39878
40324
|
const severity = resolveRuleSeverityOverride({
|
|
39879
40325
|
ruleKey: registryEntry.key,
|
|
39880
40326
|
category: rule.category
|
|
@@ -39883,7 +40329,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39883
40329
|
enabledReactDoctorRules[registryEntry.key] = severity;
|
|
39884
40330
|
}
|
|
39885
40331
|
const userPluginRules = {};
|
|
39886
|
-
if (ruleSelection !== "sidecar") for (const userPlugin of userPlugins) {
|
|
40332
|
+
if (ruleSelection !== "sidecar" && !hasIncludedTags) for (const userPlugin of userPlugins) {
|
|
39887
40333
|
Object.assign(userPluginRules, buildUserPluginRules(userPlugin, severityControls));
|
|
39888
40334
|
jsPlugins.push(userPlugin.entry);
|
|
39889
40335
|
}
|
|
@@ -40100,6 +40546,19 @@ const createSidecarLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
40100
40546
|
}
|
|
40101
40547
|
};
|
|
40102
40548
|
};
|
|
40549
|
+
const fingerprintCacheByFilePath = /* @__PURE__ */ new Map();
|
|
40550
|
+
const fingerprintFileContents = (filePath, fingerprintLength) => {
|
|
40551
|
+
const fileStats = NFS.statSync(filePath, { bigint: true });
|
|
40552
|
+
const cachedFingerprint = fingerprintCacheByFilePath.get(filePath);
|
|
40553
|
+
if (cachedFingerprint?.modifiedTimeNanoseconds === fileStats.mtimeNs && cachedFingerprint.sizeBytes === fileStats.size) return cachedFingerprint.fingerprint;
|
|
40554
|
+
const fingerprint = crypto.createHash("sha256").update(NFS.readFileSync(filePath)).digest("hex").slice(0, fingerprintLength);
|
|
40555
|
+
fingerprintCacheByFilePath.set(filePath, {
|
|
40556
|
+
fingerprint,
|
|
40557
|
+
modifiedTimeNanoseconds: fileStats.mtimeNs,
|
|
40558
|
+
sizeBytes: fileStats.size
|
|
40559
|
+
});
|
|
40560
|
+
return fingerprint;
|
|
40561
|
+
};
|
|
40103
40562
|
const bundledRequire = createRequire(import.meta.url);
|
|
40104
40563
|
const childNodeVersionByBinaryPath = /* @__PURE__ */ new Map();
|
|
40105
40564
|
const resolveChildNodeVersion = (nodeBinaryPath) => {
|
|
@@ -40123,6 +40582,13 @@ const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
|
40123
40582
|
"oxlint-plugin-react-doctor/package.json",
|
|
40124
40583
|
"eslint-plugin-react-hooks/package.json"
|
|
40125
40584
|
];
|
|
40585
|
+
const resolvePluginFingerprint = () => {
|
|
40586
|
+
try {
|
|
40587
|
+
return fingerprintFileContents(bundledRequire.resolve("oxlint-plugin-react-doctor"), 16);
|
|
40588
|
+
} catch {
|
|
40589
|
+
return "unresolved";
|
|
40590
|
+
}
|
|
40591
|
+
};
|
|
40126
40592
|
const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
40127
40593
|
const versions = [`node=${resolveChildNodeVersion(nodeBinaryPath)}`];
|
|
40128
40594
|
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
@@ -40132,6 +40598,7 @@ const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
|
40132
40598
|
} catch {
|
|
40133
40599
|
versions.push(`${specifier}=missing`);
|
|
40134
40600
|
}
|
|
40601
|
+
versions.push(`oxlint-plugin-react-doctor#fingerprint=${resolvePluginFingerprint()}`);
|
|
40135
40602
|
return versions;
|
|
40136
40603
|
};
|
|
40137
40604
|
const esmRequire = createRequire(import.meta.url);
|
|
@@ -41607,7 +42074,7 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
41607
42074
|
* 6. always restore disable directives + clean up the temp dir
|
|
41608
42075
|
*/
|
|
41609
42076
|
const runOxlint = async (options) => {
|
|
41610
|
-
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), userConfig, configSourceDirectory = rootDirectory, onPartialFailure, onFileCoverage, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
|
|
42077
|
+
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, userConfig, configSourceDirectory = rootDirectory, onPartialFailure, onFileCoverage, perFileLintCacheEnabled = false, sidecarLintCacheEnabled = false, onCacheStats, onSidecarStats, spawnTimeoutMs, outputMaxBytes, lintBatchOrdering = "cost" } = options;
|
|
41611
42078
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
41612
42079
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
41613
42080
|
validateRuleRegistration();
|
|
@@ -41621,13 +42088,15 @@ const runOxlint = async (options) => {
|
|
|
41621
42088
|
}
|
|
41622
42089
|
const pluginPath = resolvePluginPath();
|
|
41623
42090
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
41624
|
-
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
42091
|
+
const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
41625
42092
|
const buildConfig = (overrides) => createOxlintConfig({
|
|
41626
42093
|
pluginPath,
|
|
41627
42094
|
project,
|
|
41628
42095
|
customRulesOnly,
|
|
41629
42096
|
extendsPaths: overrides.extendsPaths,
|
|
41630
42097
|
ignoredTags,
|
|
42098
|
+
includedTags,
|
|
42099
|
+
includeTagDefaults,
|
|
41631
42100
|
serverAuthFunctionNames,
|
|
41632
42101
|
severityControls,
|
|
41633
42102
|
userPlugins,
|
|
@@ -42016,6 +42485,8 @@ var Linter = class Linter extends Service()("react-doctor/Linter") {
|
|
|
42016
42485
|
respectInlineDisables: input.respectInlineDisables,
|
|
42017
42486
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42018
42487
|
ignoredTags: input.ignoredTags,
|
|
42488
|
+
includedTags: input.includedTags,
|
|
42489
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
42019
42490
|
userConfig: input.userConfig ?? null,
|
|
42020
42491
|
configSourceDirectory: input.configSourceDirectory,
|
|
42021
42492
|
onPartialFailure: (reason) => {
|
|
@@ -42864,7 +43335,9 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42864
43335
|
const securityScanFailedRef = yield* make$13(false);
|
|
42865
43336
|
const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(tryPromise(() => checkSecurityScanCooperative(scanDirectory, {
|
|
42866
43337
|
project,
|
|
42867
|
-
ignoredTags: input.ignoredTags
|
|
43338
|
+
ignoredTags: input.ignoredTags,
|
|
43339
|
+
includedTags: input.includedTags,
|
|
43340
|
+
includeTagDefaults: input.includeTagDefaults
|
|
42868
43341
|
})).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), catch_$1(() => set(securityScanFailedRef, true).pipe(as(empty$4))))))).pipe(withSpan("SecurityScan.run")));
|
|
42869
43342
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
42870
43343
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
@@ -42955,6 +43428,8 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42955
43428
|
respectInlineDisables: input.respectInlineDisables,
|
|
42956
43429
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42957
43430
|
ignoredTags: input.ignoredTags,
|
|
43431
|
+
includedTags: input.includedTags,
|
|
43432
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
42958
43433
|
userConfig: resolvedConfig.config ?? void 0,
|
|
42959
43434
|
configSourceDirectory: resolvedConfig.configSourceDirectory ?? void 0,
|
|
42960
43435
|
onFileProgress: (scannedFileCount, totalFileCount) => {
|
|
@@ -45457,5 +45932,5 @@ const startLanguageServer = () => {
|
|
|
45457
45932
|
};
|
|
45458
45933
|
//#endregion
|
|
45459
45934
|
export { startLanguageServer };
|
|
45460
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
45461
|
-
//# debugId=
|
|
45935
|
+
!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]="51dfb658-30e2-586b-8f8e-5eaa86b6350a")}catch(e){}}();
|
|
45936
|
+
//# debugId=51dfb658-30e2-586b-8f8e-5eaa86b6350a
|