react-doctor 0.8.1-dev.26b4a0c → 0.8.1-dev.284b4e4
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 +684 -158
- package/dist/index.d.ts +41 -0
- package/dist/index.js +593 -114
- package/dist/lsp.js +593 -114
- package/dist/skills/react-doctor/SKILL.md +5 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="137db449-e390-5d6c-9d14-a8803909eea3")}catch(e){}}();
|
|
3
3
|
import { r as __toESM$1, t as __commonJSMin$1 } from "./chunk-N93fKeF6.js";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, CROSS_FILE_DEPENDENCY_COLLECTORS, CROSS_FILE_RULE_IDS, FRAMEWORK_SPECIFIC_RULE_KEYS, FRAMEWORK_TOKENS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES, classifySecurityScanFile, collectCrossFileDependencyProbes, resetManifestCaches, shouldReadSecurityScanContent } from "oxlint-plugin-react-doctor";
|
|
@@ -32854,44 +32854,6 @@ var AmbiguousProjectError = class extends Error {
|
|
|
32854
32854
|
}
|
|
32855
32855
|
};
|
|
32856
32856
|
const isProjectDiscoveryError = (value) => value instanceof ProjectNotFoundError || value instanceof NoReactDependencyError || value instanceof PackageJsonNotFoundError || value instanceof NotADirectoryError || value instanceof AmbiguousProjectError;
|
|
32857
|
-
const isErrnoException = (error) => error instanceof Error && "code" in error;
|
|
32858
|
-
const IGNORABLE_READDIR_ERROR_CODES = new Set([
|
|
32859
|
-
"EACCES",
|
|
32860
|
-
"EPERM",
|
|
32861
|
-
"ENOENT",
|
|
32862
|
-
"ENOTDIR",
|
|
32863
|
-
"EINVAL",
|
|
32864
|
-
"ELOOP",
|
|
32865
|
-
"ENAMETOOLONG"
|
|
32866
|
-
]);
|
|
32867
|
-
const isIgnorableReaddirError = (error) => isErrnoException(error) && typeof error.code === "string" && IGNORABLE_READDIR_ERROR_CODES.has(error.code);
|
|
32868
|
-
const readDirectoryEntries = (directoryPath) => {
|
|
32869
|
-
try {
|
|
32870
|
-
return NFS.readdirSync(directoryPath, { withFileTypes: true });
|
|
32871
|
-
} catch (error) {
|
|
32872
|
-
if (isIgnorableReaddirError(error)) return [];
|
|
32873
|
-
throw error;
|
|
32874
|
-
}
|
|
32875
|
-
};
|
|
32876
|
-
const isFile = (filePath) => {
|
|
32877
|
-
try {
|
|
32878
|
-
return NFS.statSync(filePath).isFile();
|
|
32879
|
-
} catch {
|
|
32880
|
-
return false;
|
|
32881
|
-
}
|
|
32882
|
-
};
|
|
32883
|
-
const isDirectory = (directoryPath) => {
|
|
32884
|
-
try {
|
|
32885
|
-
return NFS.statSync(directoryPath).isDirectory();
|
|
32886
|
-
} catch {
|
|
32887
|
-
return false;
|
|
32888
|
-
}
|
|
32889
|
-
};
|
|
32890
|
-
const isPlainObject = (value) => {
|
|
32891
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
32892
|
-
const prototype = Object.getPrototypeOf(value);
|
|
32893
|
-
return prototype === null || prototype === Object.prototype;
|
|
32894
|
-
};
|
|
32895
32857
|
const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
|
|
32896
32858
|
const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
|
|
32897
32859
|
const GENERATED_SOURCE_DIRECTORY_PATTERN = /(?:^|\/)__generated__\//;
|
|
@@ -33050,6 +33012,44 @@ const SUPPLY_CHAIN_OVERLAP_TIMEOUT_MS = 9e4;
|
|
|
33050
33012
|
const SUPPLY_CHAIN_CACHE_TTL_MS = 864e5;
|
|
33051
33013
|
const SUPPLY_CHAIN_CACHE_SUBDIR = "supply-chain";
|
|
33052
33014
|
const SUPPLY_CHAIN_IGNORED_PACKAGES = new Set(["next"]);
|
|
33015
|
+
const isErrnoException = (error) => error instanceof Error && "code" in error;
|
|
33016
|
+
const IGNORABLE_READDIR_ERROR_CODES = new Set([
|
|
33017
|
+
"EACCES",
|
|
33018
|
+
"EPERM",
|
|
33019
|
+
"ENOENT",
|
|
33020
|
+
"ENOTDIR",
|
|
33021
|
+
"EINVAL",
|
|
33022
|
+
"ELOOP",
|
|
33023
|
+
"ENAMETOOLONG"
|
|
33024
|
+
]);
|
|
33025
|
+
const isIgnorableReaddirError = (error) => isErrnoException(error) && typeof error.code === "string" && IGNORABLE_READDIR_ERROR_CODES.has(error.code);
|
|
33026
|
+
const readDirectoryEntries = (directoryPath) => {
|
|
33027
|
+
try {
|
|
33028
|
+
return NFS.readdirSync(directoryPath, { withFileTypes: true });
|
|
33029
|
+
} catch (error) {
|
|
33030
|
+
if (isIgnorableReaddirError(error)) return [];
|
|
33031
|
+
throw error;
|
|
33032
|
+
}
|
|
33033
|
+
};
|
|
33034
|
+
const isFile = (filePath) => {
|
|
33035
|
+
try {
|
|
33036
|
+
return NFS.statSync(filePath).isFile();
|
|
33037
|
+
} catch {
|
|
33038
|
+
return false;
|
|
33039
|
+
}
|
|
33040
|
+
};
|
|
33041
|
+
const isDirectory = (directoryPath) => {
|
|
33042
|
+
try {
|
|
33043
|
+
return NFS.statSync(directoryPath).isDirectory();
|
|
33044
|
+
} catch {
|
|
33045
|
+
return false;
|
|
33046
|
+
}
|
|
33047
|
+
};
|
|
33048
|
+
const isPlainObject = (value) => {
|
|
33049
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
33050
|
+
const prototype = Object.getPrototypeOf(value);
|
|
33051
|
+
return prototype === null || prototype === Object.prototype;
|
|
33052
|
+
};
|
|
33053
33053
|
const lastSourceMappingUrl = (fileContent) => {
|
|
33054
33054
|
const lastReference = [...fileContent.matchAll(/\/\/# sourceMappingURL=(\S+)/g)].at(-1);
|
|
33055
33055
|
return lastReference ? lastReference[1] : null;
|
|
@@ -33375,10 +33375,10 @@ const FALLBACK_TSCONFIG_FILENAMES = ["tsconfig.app.json", "tsconfig.build.json"]
|
|
|
33375
33375
|
const FRAMEWORK_PACKAGES = {
|
|
33376
33376
|
next: "nextjs",
|
|
33377
33377
|
"@tanstack/react-start": "tanstack-start",
|
|
33378
|
-
vite: "vite",
|
|
33379
|
-
"react-scripts": "cra",
|
|
33380
33378
|
"@remix-run/react": "remix",
|
|
33381
33379
|
gatsby: "gatsby",
|
|
33380
|
+
vite: "vite",
|
|
33381
|
+
"react-scripts": "cra",
|
|
33382
33382
|
expo: "expo",
|
|
33383
33383
|
"react-native": "react-native"
|
|
33384
33384
|
};
|
|
@@ -33402,11 +33402,17 @@ const NEXT_CONFIG_FILENAMES = [
|
|
|
33402
33402
|
];
|
|
33403
33403
|
const BABEL_CONFIG_FILENAMES = [
|
|
33404
33404
|
".babelrc",
|
|
33405
|
+
".babelrc.js",
|
|
33405
33406
|
".babelrc.json",
|
|
33407
|
+
".babelrc.cjs",
|
|
33408
|
+
".babelrc.mjs",
|
|
33409
|
+
".babelrc.cts",
|
|
33406
33410
|
"babel.config.js",
|
|
33407
33411
|
"babel.config.json",
|
|
33408
33412
|
"babel.config.cjs",
|
|
33409
|
-
"babel.config.mjs"
|
|
33413
|
+
"babel.config.mjs",
|
|
33414
|
+
"babel.config.ts",
|
|
33415
|
+
"babel.config.cts"
|
|
33410
33416
|
];
|
|
33411
33417
|
const VITE_CONFIG_FILENAMES = [
|
|
33412
33418
|
"vite.config.js",
|
|
@@ -33418,12 +33424,28 @@ const VITE_CONFIG_FILENAMES = [
|
|
|
33418
33424
|
"vitest.config.ts",
|
|
33419
33425
|
"vitest.config.js"
|
|
33420
33426
|
];
|
|
33427
|
+
const RSBUILD_CONFIG_FILENAMES = [
|
|
33428
|
+
"rsbuild.config.ts",
|
|
33429
|
+
"rsbuild.config.js",
|
|
33430
|
+
"rsbuild.config.mts",
|
|
33431
|
+
"rsbuild.config.mjs",
|
|
33432
|
+
"rsbuild.config.cts",
|
|
33433
|
+
"rsbuild.config.cjs"
|
|
33434
|
+
];
|
|
33435
|
+
const RSPACK_CONFIG_FILENAMES = [
|
|
33436
|
+
"rspack.config.ts",
|
|
33437
|
+
"rspack.config.js",
|
|
33438
|
+
"rspack.config.mts",
|
|
33439
|
+
"rspack.config.mjs",
|
|
33440
|
+
"rspack.config.cts",
|
|
33441
|
+
"rspack.config.cjs"
|
|
33442
|
+
];
|
|
33421
33443
|
const EXPO_APP_CONFIG_FILENAMES = [
|
|
33422
33444
|
"app.json",
|
|
33423
33445
|
"app.config.js",
|
|
33424
33446
|
"app.config.ts"
|
|
33425
33447
|
];
|
|
33426
|
-
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|["']react-compiler["']/;
|
|
33448
|
+
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|reactCompilerPreset\s*\(|["']react-compiler["']/;
|
|
33427
33449
|
const REACT_COMPILER_ENABLED_FLAG_PATTERN = /["']?reactCompiler["']?\s*:\s*(?:true\b|\{)/;
|
|
33428
33450
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
33429
33451
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
@@ -33458,6 +33480,8 @@ const detectReactCompiler = (directory, packageJson) => {
|
|
|
33458
33480
|
if (hasCompilerInConfigFiles(directory, NEXT_CONFIG_FILENAMES)) return true;
|
|
33459
33481
|
if (hasCompilerInConfigFiles(directory, BABEL_CONFIG_FILENAMES)) return true;
|
|
33460
33482
|
if (hasCompilerInConfigFiles(directory, VITE_CONFIG_FILENAMES)) return true;
|
|
33483
|
+
if (hasCompilerInConfigFiles(directory, RSBUILD_CONFIG_FILENAMES)) return true;
|
|
33484
|
+
if (hasCompilerInConfigFiles(directory, RSPACK_CONFIG_FILENAMES)) return true;
|
|
33461
33485
|
if (hasCompilerInConfigFiles(directory, EXPO_APP_CONFIG_FILENAMES)) return true;
|
|
33462
33486
|
return hasCompilerPackageInAncestors(directory, REACT_COMPILER_TRANSFORM_PACKAGES);
|
|
33463
33487
|
};
|
|
@@ -33466,7 +33490,7 @@ const detectNextjsStaticExport = (directory) => NEXT_CONFIG_FILENAMES.some((file
|
|
|
33466
33490
|
const filePath = Path.join(directory, filename);
|
|
33467
33491
|
return isFile(filePath) && STATIC_EXPORT_OUTPUT_PATTERN.test(NFS.readFileSync(filePath, "utf-8"));
|
|
33468
33492
|
});
|
|
33469
|
-
const UNRESOLVABLE_PROTOCOL_VERSION = /^(?:file|git|github|https?|link|patch|portal|workspace|npm):/i;
|
|
33493
|
+
const UNRESOLVABLE_PROTOCOL_VERSION = /^(?:catalog|file|git|github|https?|link|patch|portal|workspace|npm):/i;
|
|
33470
33494
|
const DIST_TAG_VERSION = /^[a-z][a-z0-9._-]*$/i;
|
|
33471
33495
|
const WILDCARD_VERSION = /^[*xX](?:\.[*xX])*$/;
|
|
33472
33496
|
const NPM_ALIAS_VERSION = /^npm:(?:@[^/]+\/[^@]+|[^@]+)@(.+)$/i;
|
|
@@ -33599,6 +33623,16 @@ const getLowestDependencyMajor = (version) => {
|
|
|
33599
33623
|
}
|
|
33600
33624
|
return lowestMajor;
|
|
33601
33625
|
};
|
|
33626
|
+
const getDependencyMajorWithinSupportedRange = (version, latestSupportedMajor) => {
|
|
33627
|
+
const normalizedVersion = normalizeDependencyVersion(version);
|
|
33628
|
+
if (normalizedVersion === null) return null;
|
|
33629
|
+
const validRange = import_semver.validRange(normalizedVersion);
|
|
33630
|
+
if (validRange === null) return null;
|
|
33631
|
+
const minimumVersion = import_semver.minVersion(validRange);
|
|
33632
|
+
if (minimumVersion === null || minimumVersion.major > latestSupportedMajor) return null;
|
|
33633
|
+
if (import_semver.intersects(validRange, `>=${latestSupportedMajor + 1}.0.0`)) return null;
|
|
33634
|
+
return minimumVersion.major;
|
|
33635
|
+
};
|
|
33602
33636
|
const isConcreteDependencyVersion = (version) => {
|
|
33603
33637
|
const normalizedVersion = normalizeDependencyVersion(version);
|
|
33604
33638
|
return normalizedVersion !== null && /\d/.test(normalizedVersion);
|
|
@@ -33642,9 +33676,18 @@ const parseReactMajorMinor = (reactVersion) => {
|
|
|
33642
33676
|
};
|
|
33643
33677
|
};
|
|
33644
33678
|
const parseLowerBoundVersion = (versionSpec) => import_semver.validRange(versionSpec) !== null ? import_semver.minVersion(versionSpec) : import_semver.coerce(versionSpec);
|
|
33645
|
-
const
|
|
33646
|
-
if (typeof
|
|
33647
|
-
const
|
|
33679
|
+
const parseThreeRelease = (threeVersion) => {
|
|
33680
|
+
if (typeof threeVersion !== "string") return null;
|
|
33681
|
+
const normalizedVersion = normalizeDependencyVersion(threeVersion);
|
|
33682
|
+
if (normalizedVersion === null) return null;
|
|
33683
|
+
const lowerBound = parseLowerBoundVersion(normalizedVersion);
|
|
33684
|
+
if (lowerBound === null) return null;
|
|
33685
|
+
if (lowerBound.major > 0) return Number.MAX_SAFE_INTEGER;
|
|
33686
|
+
return lowerBound.minor > 0 ? lowerBound.minor : null;
|
|
33687
|
+
};
|
|
33688
|
+
const parseDependencyMajorMinor = (dependencyVersion) => {
|
|
33689
|
+
if (typeof dependencyVersion !== "string") return null;
|
|
33690
|
+
const trimmed = dependencyVersion.trim();
|
|
33648
33691
|
if (trimmed.length === 0) return null;
|
|
33649
33692
|
const lowerBound = parseLowerBoundVersion(trimmed);
|
|
33650
33693
|
if (lowerBound === null || lowerBound.major <= 0) return null;
|
|
@@ -33653,6 +33696,7 @@ const parseTailwindMajorMinor = (tailwindVersion) => {
|
|
|
33653
33696
|
minor: lowerBound.minor
|
|
33654
33697
|
};
|
|
33655
33698
|
};
|
|
33699
|
+
const parseTailwindMajorMinor = (tailwindVersion) => parseDependencyMajorMinor(tailwindVersion);
|
|
33656
33700
|
const hasUpperBoundOnlyPeerRange = (range) => {
|
|
33657
33701
|
if (typeof range !== "string") return false;
|
|
33658
33702
|
const normalizedRange = normalizeDependencyVersion(range);
|
|
@@ -33674,7 +33718,7 @@ const resolveEffectiveReactMajor = (reactVersion, packageJson) => {
|
|
|
33674
33718
|
if (peerFloor === null) return hasUpperBoundOnlyPeerRange(peerReactRange) ? null : installedReactMajor;
|
|
33675
33719
|
return installedReactMajor !== null ? Math.min(installedReactMajor, peerFloor) : peerFloor;
|
|
33676
33720
|
};
|
|
33677
|
-
const isCatalogReference = (version) => version.startsWith("catalog:");
|
|
33721
|
+
const isCatalogReference = (version) => typeof version === "string" && version.startsWith("catalog:");
|
|
33678
33722
|
const extractCatalogName = (version) => {
|
|
33679
33723
|
if (!isCatalogReference(version)) return null;
|
|
33680
33724
|
const name = version.slice(8).trim();
|
|
@@ -33824,6 +33868,12 @@ const TAILWIND_ZOD_SECTIONS = [
|
|
|
33824
33868
|
"devDependencies",
|
|
33825
33869
|
"peerDependencies"
|
|
33826
33870
|
];
|
|
33871
|
+
const DEPENDENCY_SPEC_SECTIONS = [
|
|
33872
|
+
"dependencies",
|
|
33873
|
+
"devDependencies",
|
|
33874
|
+
"peerDependencies",
|
|
33875
|
+
"optionalDependencies"
|
|
33876
|
+
];
|
|
33827
33877
|
const EMPTY_DEPENDENCY_INFO = {
|
|
33828
33878
|
reactVersion: null,
|
|
33829
33879
|
tailwindVersion: null,
|
|
@@ -33833,7 +33883,7 @@ const EMPTY_DEPENDENCY_INFO = {
|
|
|
33833
33883
|
const pickConcreteVersion = (packageJson, packageName, sections) => {
|
|
33834
33884
|
for (const section of sections) {
|
|
33835
33885
|
const version = packageJson[section]?.[packageName];
|
|
33836
|
-
if (version
|
|
33886
|
+
if (typeof version !== "string") continue;
|
|
33837
33887
|
if (isCatalogReference(version)) return null;
|
|
33838
33888
|
if (isConcreteDependencyVersion(version)) return version;
|
|
33839
33889
|
}
|
|
@@ -33865,13 +33915,16 @@ const extractDependencyInfo = (packageJson) => {
|
|
|
33865
33915
|
};
|
|
33866
33916
|
};
|
|
33867
33917
|
const getDependencySpec = (packageJson, packageName) => {
|
|
33868
|
-
const
|
|
33869
|
-
|
|
33918
|
+
for (const section of DEPENDENCY_SPEC_SECTIONS) {
|
|
33919
|
+
const spec = packageJson[section]?.[packageName];
|
|
33920
|
+
if (typeof spec === "string") return spec;
|
|
33921
|
+
}
|
|
33922
|
+
return null;
|
|
33870
33923
|
};
|
|
33871
33924
|
const getDependencyDeclaration = ({ packageJson, packageName, sections }) => {
|
|
33872
33925
|
for (const section of sections) {
|
|
33873
33926
|
const version = packageJson[section]?.[packageName];
|
|
33874
|
-
if (version
|
|
33927
|
+
if (typeof version !== "string") continue;
|
|
33875
33928
|
return {
|
|
33876
33929
|
catalogReference: extractCatalogName(version) ?? null,
|
|
33877
33930
|
hasDeclaration: true,
|
|
@@ -33905,24 +33958,15 @@ const getPreactVersion = (packageJson) => {
|
|
|
33905
33958
|
...packageJson.devDependencies
|
|
33906
33959
|
}.preact ?? null;
|
|
33907
33960
|
};
|
|
33908
|
-
const
|
|
33909
|
-
"@tanstack/react-query",
|
|
33910
|
-
"@tanstack/query-core",
|
|
33911
|
-
"react-query"
|
|
33912
|
-
]);
|
|
33913
|
-
const hasTanStackQuery = (packageJson) => {
|
|
33914
|
-
const allDependencies = {
|
|
33915
|
-
...packageJson.peerDependencies,
|
|
33916
|
-
...packageJson.dependencies,
|
|
33917
|
-
...packageJson.devDependencies
|
|
33918
|
-
};
|
|
33919
|
-
return Object.keys(allDependencies).some((packageName) => TANSTACK_QUERY_PACKAGES.has(packageName));
|
|
33920
|
-
};
|
|
33921
|
-
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
33961
|
+
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, sourceDirectory = rootDirectory, sourcePackageJson = rootPackageJson, version }) => {
|
|
33922
33962
|
if (version === null || !isCatalogReference(version)) return version;
|
|
33923
33963
|
const catalogName = extractCatalogName(version);
|
|
33924
|
-
const
|
|
33925
|
-
if (
|
|
33964
|
+
const resolvedSourceVersion = resolveCatalogVersion(sourcePackageJson, packageName, sourceDirectory, catalogName);
|
|
33965
|
+
if (resolvedSourceVersion) return resolvedSourceVersion;
|
|
33966
|
+
if (sourceDirectory !== rootDirectory || sourcePackageJson !== rootPackageJson) {
|
|
33967
|
+
const resolvedRootVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
|
|
33968
|
+
if (resolvedRootVersion) return resolvedRootVersion;
|
|
33969
|
+
}
|
|
33926
33970
|
const monorepoRoot = findMonorepoRoot(rootDirectory);
|
|
33927
33971
|
if (!monorepoRoot) return version;
|
|
33928
33972
|
const monorepoPackageJsonPath = Path.join(monorepoRoot, "package.json");
|
|
@@ -34120,7 +34164,79 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34120
34164
|
}
|
|
34121
34165
|
return packages;
|
|
34122
34166
|
};
|
|
34167
|
+
const PREFERRED_DEPENDENCY_SECTIONS = [
|
|
34168
|
+
"dependencies",
|
|
34169
|
+
"peerDependencies",
|
|
34170
|
+
"devDependencies"
|
|
34171
|
+
];
|
|
34172
|
+
const getPreferredDependencyVersion = ({ packageJson, packageNames }) => {
|
|
34173
|
+
for (const packageName of packageNames) {
|
|
34174
|
+
const declaration = getDependencyDeclaration({
|
|
34175
|
+
packageJson,
|
|
34176
|
+
packageName,
|
|
34177
|
+
sections: PREFERRED_DEPENDENCY_SECTIONS
|
|
34178
|
+
});
|
|
34179
|
+
if (declaration.version !== null) return declaration.version;
|
|
34180
|
+
}
|
|
34181
|
+
return null;
|
|
34182
|
+
};
|
|
34183
|
+
const TANSTACK_REACT_QUERY_PACKAGES = ["@tanstack/react-query", "react-query"];
|
|
34184
|
+
const getTanStackQueryVersion = (packageJson) => {
|
|
34185
|
+
return getPreferredDependencyVersion({
|
|
34186
|
+
packageJson,
|
|
34187
|
+
packageNames: TANSTACK_REACT_QUERY_PACKAGES
|
|
34188
|
+
});
|
|
34189
|
+
};
|
|
34190
|
+
const STYLED_COMPONENTS_PACKAGES = ["styled-components"];
|
|
34191
|
+
const getStyledComponentsVersion = (packageJson) => {
|
|
34192
|
+
return getPreferredDependencyVersion({
|
|
34193
|
+
packageJson,
|
|
34194
|
+
packageNames: STYLED_COMPONENTS_PACKAGES
|
|
34195
|
+
});
|
|
34196
|
+
};
|
|
34197
|
+
const I18N_PACKAGES = [
|
|
34198
|
+
"i18next",
|
|
34199
|
+
"react-i18next",
|
|
34200
|
+
"next-i18next",
|
|
34201
|
+
"react-intl",
|
|
34202
|
+
"next-intl",
|
|
34203
|
+
"use-intl",
|
|
34204
|
+
"@formatjs/intl",
|
|
34205
|
+
"@lingui/core",
|
|
34206
|
+
"@lingui/react",
|
|
34207
|
+
"typesafe-i18n",
|
|
34208
|
+
"@tolgee/react",
|
|
34209
|
+
"react-intl-universal"
|
|
34210
|
+
];
|
|
34211
|
+
const hasI18nDependency = (packageJson) => {
|
|
34212
|
+
const allDependencies = {
|
|
34213
|
+
...packageJson.peerDependencies,
|
|
34214
|
+
...packageJson.dependencies,
|
|
34215
|
+
...packageJson.devDependencies,
|
|
34216
|
+
...packageJson.optionalDependencies
|
|
34217
|
+
};
|
|
34218
|
+
return I18N_PACKAGES.some((packageName) => allDependencies[packageName] !== void 0);
|
|
34219
|
+
};
|
|
34123
34220
|
const REANIMATED_DEPENDENCY_NAME = "react-native-reanimated";
|
|
34221
|
+
const MOBX_REACT_PACKAGE_NAME = "mobx-react";
|
|
34222
|
+
const MOBX_REACT_LITE_PACKAGE_NAME = "mobx-react-lite";
|
|
34223
|
+
const MOBX_STATE_TREE_PACKAGE_NAME = "mobx-state-tree";
|
|
34224
|
+
const MOBX_REACT_OBSERVER_PACKAGE_NAME = "mobx-react-observer";
|
|
34225
|
+
const REACT_THREE_FIBER_DEPENDENCY_NAMES = ["@react-three/fiber", "react-three-fiber"];
|
|
34226
|
+
const REACT_THREE_FIBER_SECTIONS = [
|
|
34227
|
+
"dependencies",
|
|
34228
|
+
"peerDependencies",
|
|
34229
|
+
"optionalDependencies",
|
|
34230
|
+
"devDependencies"
|
|
34231
|
+
];
|
|
34232
|
+
const THREE_DEPENDENCY_SECTIONS = [
|
|
34233
|
+
"dependencies",
|
|
34234
|
+
"peerDependencies",
|
|
34235
|
+
"optionalDependencies",
|
|
34236
|
+
"devDependencies"
|
|
34237
|
+
];
|
|
34238
|
+
const REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES = [...REACT_THREE_FIBER_DEPENDENCY_NAMES, "@react-three/drei"];
|
|
34239
|
+
const THREE_DEPENDENCY_NAMES = [...REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES, "three"];
|
|
34124
34240
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34125
34241
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34126
34242
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34131,7 +34247,7 @@ const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootD
|
|
|
34131
34247
|
if (!dependencyDeclaration.hasDeclaration) return null;
|
|
34132
34248
|
return concreteVersion ?? resolveCatalogVersion(workspacePackageJson, packageName, workspaceDirectory, dependencyDeclaration.catalogReference) ?? resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, dependencyDeclaration.catalogReference);
|
|
34133
34249
|
};
|
|
34134
|
-
const
|
|
34250
|
+
const shouldReplaceWithLowerMajor = (currentVersion, nextVersion) => {
|
|
34135
34251
|
if (!currentVersion) return true;
|
|
34136
34252
|
const currentMajor = parseReactMajor(currentVersion);
|
|
34137
34253
|
const nextMajor = parseReactMajor(nextVersion);
|
|
@@ -34139,7 +34255,62 @@ const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
|
34139
34255
|
if (nextMajor === null) return false;
|
|
34140
34256
|
return nextMajor < currentMajor;
|
|
34141
34257
|
};
|
|
34142
|
-
const
|
|
34258
|
+
const shouldReplaceSupportedDependencyFact = (currentFact, nextFact, latestSupportedMajor) => {
|
|
34259
|
+
if (currentFact.version === null) return true;
|
|
34260
|
+
if (nextFact.version === null) return false;
|
|
34261
|
+
const currentMajor = getLowestDependencyMajor(currentFact.version);
|
|
34262
|
+
const nextMajor = getLowestDependencyMajor(nextFact.version);
|
|
34263
|
+
if (currentMajor === null) return false;
|
|
34264
|
+
if (nextMajor === null) return true;
|
|
34265
|
+
if (currentMajor > latestSupportedMajor) return false;
|
|
34266
|
+
if (nextMajor > latestSupportedMajor) return true;
|
|
34267
|
+
return nextMajor < currentMajor;
|
|
34268
|
+
};
|
|
34269
|
+
const shouldReplaceStyledComponentsVersion = (currentVersion, nextVersion) => {
|
|
34270
|
+
if (!currentVersion) return true;
|
|
34271
|
+
const currentMajor = getLowestDependencyMajor(currentVersion);
|
|
34272
|
+
const nextMajor = getLowestDependencyMajor(nextVersion);
|
|
34273
|
+
if (currentMajor === null) return nextMajor !== null && nextMajor < 6;
|
|
34274
|
+
if (nextMajor === null) return currentMajor >= 6;
|
|
34275
|
+
return nextMajor < currentMajor;
|
|
34276
|
+
};
|
|
34277
|
+
const selectOldestDependencyVersion = (currentVersion, nextVersion) => {
|
|
34278
|
+
if (currentVersion === null || nextVersion === null) return null;
|
|
34279
|
+
const current = parseDependencyMajorMinor(currentVersion);
|
|
34280
|
+
const next = parseDependencyMajorMinor(nextVersion);
|
|
34281
|
+
if (current === null) return currentVersion;
|
|
34282
|
+
if (next === null) return nextVersion;
|
|
34283
|
+
if (next.major !== current.major) return next.major < current.major ? nextVersion : currentVersion;
|
|
34284
|
+
return next.minor < current.minor ? nextVersion : currentVersion;
|
|
34285
|
+
};
|
|
34286
|
+
const shouldReplaceMobxFact = (currentFact, nextFact) => {
|
|
34287
|
+
if (currentFact.sourceDirectory === null) return true;
|
|
34288
|
+
if (currentFact.version === null) return false;
|
|
34289
|
+
if (nextFact.version === null) return true;
|
|
34290
|
+
const currentMajor = getDependencyMajorWithinSupportedRange(currentFact.version, 6);
|
|
34291
|
+
const nextMajor = getDependencyMajorWithinSupportedRange(nextFact.version, 6);
|
|
34292
|
+
if (currentMajor === null) return false;
|
|
34293
|
+
if (nextMajor === null) return true;
|
|
34294
|
+
return selectOldestDependencyVersion(currentFact.version, nextFact.version) === nextFact.version;
|
|
34295
|
+
};
|
|
34296
|
+
const collectBindingVersion = (facts, packageJson, directory, packageName) => {
|
|
34297
|
+
const version = getDependencySpec(packageJson, packageName);
|
|
34298
|
+
if (version === null) return;
|
|
34299
|
+
const resolvedVersion = resolveCatalogBackedDependencyVersion({
|
|
34300
|
+
rootDirectory: directory,
|
|
34301
|
+
rootPackageJson: packageJson,
|
|
34302
|
+
packageName,
|
|
34303
|
+
version
|
|
34304
|
+
});
|
|
34305
|
+
if (packageName === MOBX_REACT_PACKAGE_NAME) {
|
|
34306
|
+
facts.mobxReactVersion = facts.hasMobxReact ? selectOldestDependencyVersion(facts.mobxReactVersion, resolvedVersion) : resolvedVersion;
|
|
34307
|
+
facts.hasMobxReact = true;
|
|
34308
|
+
return;
|
|
34309
|
+
}
|
|
34310
|
+
facts.mobxReactLiteVersion = facts.hasMobxReactLite ? selectOldestDependencyVersion(facts.mobxReactLiteVersion, resolvedVersion) : resolvedVersion;
|
|
34311
|
+
facts.hasMobxReactLite = true;
|
|
34312
|
+
};
|
|
34313
|
+
const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, rootPackageJson) => {
|
|
34143
34314
|
if (facts.expo.version === null) {
|
|
34144
34315
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34145
34316
|
if (spec !== null) facts.expo = {
|
|
@@ -34161,13 +34332,113 @@ const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
|
34161
34332
|
sourceDirectory: directory
|
|
34162
34333
|
};
|
|
34163
34334
|
}
|
|
34335
|
+
const mobxSpec = getDependencySpec(packageJson, "mobx");
|
|
34336
|
+
if (mobxSpec !== null) {
|
|
34337
|
+
const nextMobxFact = {
|
|
34338
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34339
|
+
rootDirectory: directory,
|
|
34340
|
+
rootPackageJson: packageJson,
|
|
34341
|
+
packageName: "mobx",
|
|
34342
|
+
version: mobxSpec
|
|
34343
|
+
}),
|
|
34344
|
+
sourceDirectory: directory
|
|
34345
|
+
};
|
|
34346
|
+
if (shouldReplaceMobxFact(facts.mobx, nextMobxFact)) facts.mobx = nextMobxFact;
|
|
34347
|
+
}
|
|
34348
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_PACKAGE_NAME);
|
|
34349
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_LITE_PACKAGE_NAME);
|
|
34350
|
+
facts.hasMobxStateTree = facts.hasMobxStateTree || getDependencySpec(packageJson, MOBX_STATE_TREE_PACKAGE_NAME) !== null;
|
|
34351
|
+
facts.hasMobxReactObserver = facts.hasMobxReactObserver || getDependencySpec(packageJson, MOBX_REACT_OBSERVER_PACKAGE_NAME) !== null;
|
|
34352
|
+
const zustandSpec = getDependencySpec(packageJson, "zustand");
|
|
34353
|
+
if (zustandSpec !== null) {
|
|
34354
|
+
const nextZustandFact = {
|
|
34355
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34356
|
+
rootDirectory: directory,
|
|
34357
|
+
rootPackageJson: packageJson,
|
|
34358
|
+
packageName: "zustand",
|
|
34359
|
+
version: zustandSpec
|
|
34360
|
+
}),
|
|
34361
|
+
sourceDirectory: directory
|
|
34362
|
+
};
|
|
34363
|
+
if (shouldReplaceSupportedDependencyFact(facts.zustand, nextZustandFact, 5)) facts.zustand = nextZustandFact;
|
|
34364
|
+
}
|
|
34164
34365
|
if (facts.reanimatedVersion === null) {
|
|
34165
34366
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34166
34367
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34167
34368
|
}
|
|
34369
|
+
if (facts.valtioVersion === null) {
|
|
34370
|
+
const spec = getDependencySpec(packageJson, "valtio");
|
|
34371
|
+
if (spec !== null) facts.valtioVersion = spec;
|
|
34372
|
+
}
|
|
34373
|
+
facts.tanstackQueryVersion ??= getTanStackQueryVersion(packageJson);
|
|
34374
|
+
const styledComponentsVersion = resolveCatalogBackedDependencyVersion({
|
|
34375
|
+
rootDirectory: directory,
|
|
34376
|
+
rootPackageJson: packageJson,
|
|
34377
|
+
packageName: "styled-components",
|
|
34378
|
+
version: getStyledComponentsVersion(packageJson)
|
|
34379
|
+
});
|
|
34380
|
+
if (styledComponentsVersion && shouldReplaceStyledComponentsVersion(facts.styledComponentsVersion, styledComponentsVersion)) facts.styledComponentsVersion = styledComponentsVersion;
|
|
34381
|
+
facts.hasI18nLibrary = facts.hasI18nLibrary || hasI18nDependency(packageJson);
|
|
34382
|
+
for (const packageName of REACT_THREE_FIBER_DEPENDENCY_NAMES) {
|
|
34383
|
+
const version = resolveCatalogBackedDependencyVersion({
|
|
34384
|
+
rootDirectory,
|
|
34385
|
+
rootPackageJson,
|
|
34386
|
+
sourceDirectory: directory,
|
|
34387
|
+
sourcePackageJson: packageJson,
|
|
34388
|
+
packageName,
|
|
34389
|
+
version: getDependencyDeclaration({
|
|
34390
|
+
packageName,
|
|
34391
|
+
packageJson,
|
|
34392
|
+
sections: REACT_THREE_FIBER_SECTIONS
|
|
34393
|
+
}).version
|
|
34394
|
+
});
|
|
34395
|
+
if (version === null) continue;
|
|
34396
|
+
if (shouldReplaceWithLowerMajor(facts.reactThreeFiber.version, version)) facts.reactThreeFiber = {
|
|
34397
|
+
packageName,
|
|
34398
|
+
version,
|
|
34399
|
+
sourceDirectory: directory
|
|
34400
|
+
};
|
|
34401
|
+
}
|
|
34402
|
+
const threeVersion = resolveCatalogBackedDependencyVersion({
|
|
34403
|
+
rootDirectory,
|
|
34404
|
+
rootPackageJson,
|
|
34405
|
+
sourceDirectory: directory,
|
|
34406
|
+
sourcePackageJson: packageJson,
|
|
34407
|
+
packageName: "three",
|
|
34408
|
+
version: getDependencyDeclaration({
|
|
34409
|
+
packageName: "three",
|
|
34410
|
+
packageJson,
|
|
34411
|
+
sections: THREE_DEPENDENCY_SECTIONS
|
|
34412
|
+
}).version
|
|
34413
|
+
});
|
|
34414
|
+
if (threeVersion !== null) {
|
|
34415
|
+
const currentRelease = parseThreeRelease(facts.threeVersion);
|
|
34416
|
+
const nextRelease = parseThreeRelease(threeVersion);
|
|
34417
|
+
if (facts.threeVersion === null || nextRelease !== null && (currentRelease === null || nextRelease < currentRelease)) facts.threeVersion = threeVersion;
|
|
34418
|
+
}
|
|
34168
34419
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34169
34420
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34170
34421
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34422
|
+
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34423
|
+
if (remotionSpec !== null) {
|
|
34424
|
+
facts.hasRemotionDependency = true;
|
|
34425
|
+
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34426
|
+
rootDirectory,
|
|
34427
|
+
rootPackageJson,
|
|
34428
|
+
packageName: "remotion",
|
|
34429
|
+
version: remotionSpec
|
|
34430
|
+
});
|
|
34431
|
+
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34432
|
+
if (remotionMajorVersion === null) {
|
|
34433
|
+
facts.hasUnknownRemotionVersion = true;
|
|
34434
|
+
facts.remotionVersion = null;
|
|
34435
|
+
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34436
|
+
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34437
|
+
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34438
|
+
}
|
|
34439
|
+
}
|
|
34440
|
+
facts.hasThree = facts.hasThree || THREE_DEPENDENCY_NAMES.some((dependencyName) => getDependencySpec(packageJson, dependencyName) !== null);
|
|
34441
|
+
facts.hasReactThreeFiber = facts.hasReactThreeFiber || REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES.some((dependencyName) => getDependencySpec(packageJson, dependencyName) !== null);
|
|
34171
34442
|
};
|
|
34172
34443
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34173
34444
|
const facts = {
|
|
@@ -34187,12 +34458,41 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34187
34458
|
version: null,
|
|
34188
34459
|
sourceDirectory: null
|
|
34189
34460
|
},
|
|
34461
|
+
valtioVersion: null,
|
|
34462
|
+
mobx: {
|
|
34463
|
+
version: null,
|
|
34464
|
+
sourceDirectory: null
|
|
34465
|
+
},
|
|
34466
|
+
hasMobxReact: false,
|
|
34467
|
+
mobxReactVersion: null,
|
|
34468
|
+
hasMobxReactLite: false,
|
|
34469
|
+
mobxReactLiteVersion: null,
|
|
34470
|
+
hasMobxStateTree: false,
|
|
34471
|
+
hasMobxReactObserver: false,
|
|
34472
|
+
zustand: {
|
|
34473
|
+
version: null,
|
|
34474
|
+
sourceDirectory: null
|
|
34475
|
+
},
|
|
34476
|
+
tanstackQueryVersion: null,
|
|
34477
|
+
styledComponentsVersion: null,
|
|
34478
|
+
hasI18nLibrary: false,
|
|
34190
34479
|
hasReactNativeAwarePackage: false,
|
|
34191
34480
|
hasReanimatedAwarePackage: false,
|
|
34192
34481
|
hasSsrDependency: false,
|
|
34482
|
+
hasRemotionDependency: false,
|
|
34483
|
+
hasUnknownRemotionVersion: false,
|
|
34484
|
+
remotionVersion: null,
|
|
34485
|
+
hasThree: false,
|
|
34486
|
+
threeVersion: null,
|
|
34487
|
+
hasReactThreeFiber: false,
|
|
34488
|
+
reactThreeFiber: {
|
|
34489
|
+
packageName: null,
|
|
34490
|
+
version: null,
|
|
34491
|
+
sourceDirectory: null
|
|
34492
|
+
},
|
|
34193
34493
|
reanimatedVersion: null
|
|
34194
34494
|
};
|
|
34195
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34495
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory, rootDirectory, rootPackageJson);
|
|
34196
34496
|
let isReactGroupSettled = !collectReactGroup;
|
|
34197
34497
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34198
34498
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
@@ -34201,7 +34501,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34201
34501
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34202
34502
|
visitedDirectories.add(workspaceDirectory);
|
|
34203
34503
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34204
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34504
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory, rootDirectory, rootPackageJson);
|
|
34205
34505
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34206
34506
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34207
34507
|
if (isReactGroupSettled) continue;
|
|
@@ -34232,7 +34532,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34232
34532
|
workspaceDirectory,
|
|
34233
34533
|
workspacePackageJson
|
|
34234
34534
|
});
|
|
34235
|
-
if (reactVersion &&
|
|
34535
|
+
if (reactVersion && shouldReplaceWithLowerMajor(facts.reactVersion, reactVersion)) facts.reactVersion = reactVersion;
|
|
34236
34536
|
if (tailwindVersion && !facts.tailwindVersion) facts.tailwindVersion = tailwindVersion;
|
|
34237
34537
|
if (zodVersion && !facts.zodVersion) facts.zodVersion = zodVersion;
|
|
34238
34538
|
const settledReactMajor = parseReactMajor(facts.reactVersion);
|
|
@@ -34425,11 +34725,35 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34425
34725
|
tailwindVersion: null,
|
|
34426
34726
|
zodVersion: null,
|
|
34427
34727
|
zodMajorVersion: null,
|
|
34728
|
+
mobxVersion: null,
|
|
34729
|
+
mobxMajorVersion: null,
|
|
34730
|
+
hasMobxReact: false,
|
|
34731
|
+
mobxReactVersion: null,
|
|
34732
|
+
hasMobxReactLite: false,
|
|
34733
|
+
mobxReactLiteVersion: null,
|
|
34734
|
+
hasMobxStateTree: false,
|
|
34735
|
+
hasMobxReactObserver: false,
|
|
34736
|
+
zustandVersion: null,
|
|
34737
|
+
zustandMajorVersion: null,
|
|
34428
34738
|
framework: "unknown",
|
|
34429
34739
|
hasTypeScript: hasOwnTsConfig,
|
|
34430
34740
|
hasReactCompiler: false,
|
|
34431
34741
|
hasReactCompilerLintPlugin: false,
|
|
34432
34742
|
hasTanStackQuery: false,
|
|
34743
|
+
valtioVersion: null,
|
|
34744
|
+
valtioMajorVersion: null,
|
|
34745
|
+
hasRemotion: false,
|
|
34746
|
+
remotionVersion: null,
|
|
34747
|
+
remotionMajorVersion: null,
|
|
34748
|
+
hasI18nLibrary: false,
|
|
34749
|
+
tanstackQueryVersion: null,
|
|
34750
|
+
styledComponentsVersion: null,
|
|
34751
|
+
hasThree: false,
|
|
34752
|
+
threeVersion: null,
|
|
34753
|
+
threeRelease: null,
|
|
34754
|
+
hasReactThreeFiber: false,
|
|
34755
|
+
reactThreeFiberVersion: null,
|
|
34756
|
+
reactThreeFiberMajorVersion: null,
|
|
34433
34757
|
hasSsrDependency: false,
|
|
34434
34758
|
preactVersion: null,
|
|
34435
34759
|
preactMajorVersion: null,
|
|
@@ -34528,6 +34852,12 @@ const discoverProject = (directory) => {
|
|
|
34528
34852
|
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
34529
34853
|
version: workspaceFacts.shopifyFlashList.version
|
|
34530
34854
|
}) : null;
|
|
34855
|
+
const zustandVersion = resolveCatalogBackedDependencyVersion({
|
|
34856
|
+
rootDirectory: directory,
|
|
34857
|
+
rootPackageJson: packageJson,
|
|
34858
|
+
packageName: "zustand",
|
|
34859
|
+
version: workspaceFacts.zustand.version
|
|
34860
|
+
});
|
|
34531
34861
|
const hasReanimated = hasReactNativeWorkspace && workspaceFacts.hasReanimatedAwarePackage;
|
|
34532
34862
|
const reanimatedVersion = hasReanimated ? workspaceFacts.reanimatedVersion : null;
|
|
34533
34863
|
const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
|
|
@@ -34536,7 +34866,33 @@ const discoverProject = (directory) => {
|
|
|
34536
34866
|
packageName: "next",
|
|
34537
34867
|
version: workspaceFacts.next.version
|
|
34538
34868
|
}) : null;
|
|
34869
|
+
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
34870
|
+
rootDirectory: directory,
|
|
34871
|
+
rootPackageJson: packageJson,
|
|
34872
|
+
packageName: "valtio",
|
|
34873
|
+
version: workspaceFacts.valtioVersion
|
|
34874
|
+
});
|
|
34875
|
+
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
34876
|
+
rootDirectory: directory,
|
|
34877
|
+
rootPackageJson: packageJson,
|
|
34878
|
+
packageName: "mobx",
|
|
34879
|
+
version: workspaceFacts.mobx.version
|
|
34880
|
+
});
|
|
34539
34881
|
const preactVersion = getPreactVersion(packageJson);
|
|
34882
|
+
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34883
|
+
const tanstackQueryVersion = getTanStackQueryVersion(packageJson) ?? workspaceFacts.tanstackQueryVersion;
|
|
34884
|
+
const reactThreeFiberVersion = workspaceFacts.reactThreeFiber.packageName ? resolveCatalogBackedDependencyVersion({
|
|
34885
|
+
rootDirectory: directory,
|
|
34886
|
+
rootPackageJson: packageJson,
|
|
34887
|
+
packageName: workspaceFacts.reactThreeFiber.packageName,
|
|
34888
|
+
version: workspaceFacts.reactThreeFiber.version
|
|
34889
|
+
}) : null;
|
|
34890
|
+
const threeVersion = resolveCatalogBackedDependencyVersion({
|
|
34891
|
+
rootDirectory: directory,
|
|
34892
|
+
rootPackageJson: packageJson,
|
|
34893
|
+
packageName: "three",
|
|
34894
|
+
version: workspaceFacts.threeVersion
|
|
34895
|
+
});
|
|
34540
34896
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34541
34897
|
const projectInfo = {
|
|
34542
34898
|
rootDirectory: directory,
|
|
@@ -34546,11 +34902,35 @@ const discoverProject = (directory) => {
|
|
|
34546
34902
|
tailwindVersion,
|
|
34547
34903
|
zodVersion,
|
|
34548
34904
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
34905
|
+
mobxVersion,
|
|
34906
|
+
mobxMajorVersion: mobxVersion === null ? null : getDependencyMajorWithinSupportedRange(mobxVersion, 6),
|
|
34907
|
+
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
34908
|
+
mobxReactVersion: workspaceFacts.mobxReactVersion,
|
|
34909
|
+
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
34910
|
+
mobxReactLiteVersion: workspaceFacts.mobxReactLiteVersion,
|
|
34911
|
+
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
34912
|
+
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
34913
|
+
zustandVersion,
|
|
34914
|
+
zustandMajorVersion: zustandVersion === null ? null : getLowestDependencyMajor(zustandVersion),
|
|
34549
34915
|
framework,
|
|
34550
34916
|
hasTypeScript,
|
|
34551
34917
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34552
34918
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
34553
|
-
hasTanStackQuery:
|
|
34919
|
+
hasTanStackQuery: tanstackQueryVersion !== null,
|
|
34920
|
+
hasI18nLibrary: workspaceFacts.hasI18nLibrary,
|
|
34921
|
+
tanstackQueryVersion,
|
|
34922
|
+
styledComponentsVersion: workspaceFacts.styledComponentsVersion,
|
|
34923
|
+
valtioVersion,
|
|
34924
|
+
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
34925
|
+
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
34926
|
+
remotionVersion,
|
|
34927
|
+
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
34928
|
+
hasThree: workspaceFacts.hasThree,
|
|
34929
|
+
threeVersion,
|
|
34930
|
+
threeRelease: parseThreeRelease(threeVersion),
|
|
34931
|
+
hasReactThreeFiber: workspaceFacts.hasReactThreeFiber,
|
|
34932
|
+
reactThreeFiberVersion,
|
|
34933
|
+
reactThreeFiberMajorVersion: reactThreeFiberVersion === null ? null : getLowestDependencyMajor(reactThreeFiberVersion),
|
|
34554
34934
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34555
34935
|
preactVersion,
|
|
34556
34936
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
@@ -34784,7 +35164,6 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
34784
35164
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
34785
35165
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
34786
35166
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34787
|
-
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
34788
35167
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
34789
35168
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
34790
35169
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37071,9 +37450,25 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37071
37450
|
".babelrc.json"
|
|
37072
37451
|
];
|
|
37073
37452
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37453
|
+
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37454
|
+
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37455
|
+
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37456
|
+
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37074
37457
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37075
37458
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37459
|
+
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37460
|
+
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37461
|
+
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37462
|
+
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37463
|
+
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37464
|
+
if (normalizedVersionRange === null) return false;
|
|
37465
|
+
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37466
|
+
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37467
|
+
};
|
|
37468
|
+
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37076
37469
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37470
|
+
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37471
|
+
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37077
37472
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37078
37473
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37079
37474
|
if (!isFile(filePath)) continue;
|
|
@@ -37083,7 +37478,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37083
37478
|
} catch {
|
|
37084
37479
|
continue;
|
|
37085
37480
|
}
|
|
37086
|
-
if (
|
|
37481
|
+
if (shouldReportLegacyPreset && LEGACY_PRESET_REFERENCE.test(contents)) return [buildReactNativeDiagnostic({
|
|
37087
37482
|
filePath: fileName,
|
|
37088
37483
|
rule: "rn-no-metro-babel-preset",
|
|
37089
37484
|
severity: "error",
|
|
@@ -37106,12 +37501,6 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37106
37501
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37107
37502
|
};
|
|
37108
37503
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37109
|
-
const DEPENDENCY_SECTIONS = [
|
|
37110
|
-
"dependencies",
|
|
37111
|
-
"devDependencies",
|
|
37112
|
-
"peerDependencies",
|
|
37113
|
-
"optionalDependencies"
|
|
37114
|
-
];
|
|
37115
37504
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37116
37505
|
"19.0": {
|
|
37117
37506
|
rceFixedVersion: "19.0.1",
|
|
@@ -37158,20 +37547,13 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37158
37547
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37159
37548
|
return [...directories];
|
|
37160
37549
|
};
|
|
37161
|
-
const readDeclaredSpec = (packageJson, packageName) => {
|
|
37162
|
-
for (const section of DEPENDENCY_SECTIONS) {
|
|
37163
|
-
const spec = packageJson[section]?.[packageName];
|
|
37164
|
-
if (typeof spec === "string") return spec;
|
|
37165
|
-
}
|
|
37166
|
-
return null;
|
|
37167
|
-
};
|
|
37168
37550
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37169
37551
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37170
37552
|
if (isFile(manifestPath)) {
|
|
37171
37553
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37172
37554
|
if (installedVersion !== null) return installedVersion;
|
|
37173
37555
|
}
|
|
37174
|
-
const candidateSpecs = [
|
|
37556
|
+
const candidateSpecs = [getDependencySpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37175
37557
|
for (const spec of candidateSpecs) {
|
|
37176
37558
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37177
37559
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -37823,10 +38205,10 @@ const SSR_FRAMEWORKS = new Set([
|
|
|
37823
38205
|
"gatsby",
|
|
37824
38206
|
"tanstack-start"
|
|
37825
38207
|
]);
|
|
37826
|
-
const
|
|
37827
|
-
if (
|
|
37828
|
-
const
|
|
37829
|
-
for (let candidate = earliest; candidate <=
|
|
38208
|
+
const addVersionCapabilityLadder = (capabilities, name, detectedVersion, earliest, latest) => {
|
|
38209
|
+
if (detectedVersion === null) return;
|
|
38210
|
+
const cappedVersion = Math.min(detectedVersion, latest);
|
|
38211
|
+
for (let candidate = earliest; candidate <= cappedVersion; candidate += 1) capabilities.add(`${name}:${candidate}`);
|
|
37830
38212
|
};
|
|
37831
38213
|
const buildCapabilities = (project) => {
|
|
37832
38214
|
const capabilities = /* @__PURE__ */ new Set();
|
|
@@ -37839,24 +38221,77 @@ const buildCapabilities = (project) => {
|
|
|
37839
38221
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
37840
38222
|
if (project.isStaticExport) capabilities.add("nextjs:static-export");
|
|
37841
38223
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
37842
|
-
|
|
38224
|
+
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 16) capabilities.add("nextjs:16");
|
|
38225
|
+
addVersionCapabilityLadder(capabilities, "react", project.reactMajorVersion, 17, 30);
|
|
37843
38226
|
if (project.reactMajorVersion !== null && project.reactMajorVersion >= 19 && isMajorMinorAtLeast(parseReactMajorMinor(project.reactVersion), {
|
|
37844
38227
|
major: 19,
|
|
37845
38228
|
minor: 2
|
|
37846
38229
|
})) capabilities.add("react:19.2");
|
|
37847
|
-
if (project.tailwindVersion !== null)
|
|
37848
|
-
|
|
37849
|
-
|
|
37850
|
-
|
|
37851
|
-
|
|
38230
|
+
if (project.tailwindVersion !== null) {
|
|
38231
|
+
capabilities.add("tailwind");
|
|
38232
|
+
const tailwindVersion = parseTailwindMajorMinor(project.tailwindVersion);
|
|
38233
|
+
if (isMajorMinorAtLeast(tailwindVersion, {
|
|
38234
|
+
major: 3,
|
|
38235
|
+
minor: 4
|
|
38236
|
+
})) capabilities.add("tailwind:3.4");
|
|
38237
|
+
if (tailwindVersion !== null && isMajorMinorAtLeast(tailwindVersion, {
|
|
38238
|
+
major: 4,
|
|
38239
|
+
minor: 0
|
|
38240
|
+
})) capabilities.add("tailwind:4");
|
|
38241
|
+
}
|
|
37852
38242
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
37853
38243
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
38244
|
+
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
38245
|
+
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
38246
|
+
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
38247
|
+
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
38248
|
+
const mobxReactVersion = parseDependencyMajorMinor(project.mobxReactVersion);
|
|
38249
|
+
const mobxReactLiteVersion = parseDependencyMajorMinor(project.mobxReactLiteVersion);
|
|
38250
|
+
const hasMobxReactObserverMemoGuard = mobxReactVersion !== null && isMajorMinorAtLeast(mobxReactVersion, {
|
|
38251
|
+
major: 7,
|
|
38252
|
+
minor: 3
|
|
38253
|
+
});
|
|
38254
|
+
const hasMobxReactLiteObserverMemoGuard = mobxReactLiteVersion !== null && isMajorMinorAtLeast(mobxReactLiteVersion, {
|
|
38255
|
+
major: 3,
|
|
38256
|
+
minor: 3
|
|
38257
|
+
});
|
|
38258
|
+
if (hasMobxReactObserverMemoGuard) capabilities.add("mobx-react-observer-memo-guard");
|
|
38259
|
+
if (hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-lite-observer-memo-guard");
|
|
38260
|
+
if (hasMobxReactObserverMemoGuard || hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-binding-observer-memo-guard");
|
|
38261
|
+
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
38262
|
+
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
38263
|
+
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addVersionCapabilityLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
38264
|
+
const mobxVersion = parseDependencyMajorMinor(project.mobxVersion);
|
|
38265
|
+
if (project.mobxMajorVersion === 6 && mobxVersion !== null && isMajorMinorAtLeast(mobxVersion, {
|
|
38266
|
+
major: 6,
|
|
38267
|
+
minor: 10
|
|
38268
|
+
})) capabilities.add("mobx:6.10");
|
|
38269
|
+
if (project.zustandVersion !== void 0 && project.zustandVersion !== null) capabilities.add("zustand");
|
|
38270
|
+
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addVersionCapabilityLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
37854
38271
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
37855
38272
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
37856
|
-
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
38273
|
+
if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
|
|
38274
|
+
if (project.styledComponentsVersion) {
|
|
38275
|
+
capabilities.add("styled-components");
|
|
38276
|
+
const styledComponentsMajor = getLowestDependencyMajor(project.styledComponentsVersion);
|
|
38277
|
+
if (styledComponentsMajor !== null && styledComponentsMajor >= 6) capabilities.add("styled-components:6");
|
|
38278
|
+
}
|
|
38279
|
+
if (project.hasI18nLibrary) capabilities.add("i18n");
|
|
38280
|
+
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
38281
|
+
addVersionCapabilityLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
38282
|
+
if (project.hasRemotion) {
|
|
38283
|
+
capabilities.add("remotion");
|
|
38284
|
+
addVersionCapabilityLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
38285
|
+
}
|
|
38286
|
+
if (project.hasThree || project.hasReactThreeFiber) capabilities.add("three");
|
|
38287
|
+
addVersionCapabilityLadder(capabilities, "three", project.threeRelease ?? null, 145, 250);
|
|
38288
|
+
if (project.hasReactThreeFiber) {
|
|
38289
|
+
capabilities.add("r3f");
|
|
38290
|
+
addVersionCapabilityLadder(capabilities, "r3f", project.reactThreeFiberMajorVersion ?? null, 3, 10);
|
|
38291
|
+
}
|
|
37857
38292
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
37858
38293
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
37859
|
-
|
|
38294
|
+
addVersionCapabilityLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
37860
38295
|
if (project.preactVersion !== null && project.reactVersion === null) capabilities.add("pure-preact");
|
|
37861
38296
|
return capabilities;
|
|
37862
38297
|
};
|
|
@@ -37868,7 +38303,7 @@ const getCapabilities = (project) => {
|
|
|
37868
38303
|
capabilitiesByProject.set(project, capabilities);
|
|
37869
38304
|
return capabilities;
|
|
37870
38305
|
};
|
|
37871
|
-
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen) => {
|
|
38306
|
+
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen, includedTags) => {
|
|
37872
38307
|
if (requires) {
|
|
37873
38308
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
37874
38309
|
}
|
|
@@ -37879,20 +38314,29 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhe
|
|
|
37879
38314
|
if (tags) {
|
|
37880
38315
|
for (const tag of tags) if (ignoredTags.has(tag)) return false;
|
|
37881
38316
|
}
|
|
38317
|
+
if (includedTags && includedTags.size > 0) {
|
|
38318
|
+
if (!tags?.some((tag) => includedTags.has(tag))) return false;
|
|
38319
|
+
}
|
|
37882
38320
|
return true;
|
|
37883
38321
|
};
|
|
38322
|
+
const shouldEnableRuleByDefaultStatus = (options) => options.defaultEnabled !== false || options.hasExplicitOverride === true || options.includeTagDefaults && options.hasIncludedTags;
|
|
37884
38323
|
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
37885
38324
|
setImmediate(resolve);
|
|
37886
38325
|
});
|
|
37887
38326
|
const createSecurityScanSession = (rootDirectory, options) => {
|
|
37888
38327
|
const capabilities = options.project ? getCapabilities(options.project) : /* @__PURE__ */ new Set();
|
|
37889
38328
|
const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
|
|
38329
|
+
const includedTags = options.includedTags ?? /* @__PURE__ */ new Set();
|
|
37890
38330
|
const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
|
|
37891
38331
|
const rule = entry.rule;
|
|
37892
38332
|
const scan = rule.scan;
|
|
37893
38333
|
if (typeof scan !== "function") return [];
|
|
37894
|
-
if (
|
|
37895
|
-
|
|
38334
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
38335
|
+
defaultEnabled: rule.defaultEnabled,
|
|
38336
|
+
includeTagDefaults: options.includeTagDefaults === true,
|
|
38337
|
+
hasIncludedTags: includedTags.size > 0
|
|
38338
|
+
})) return [];
|
|
38339
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) return [];
|
|
37896
38340
|
return [{
|
|
37897
38341
|
entry,
|
|
37898
38342
|
scan,
|
|
@@ -39878,8 +40322,9 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
39878
40322
|
}
|
|
39879
40323
|
return enabled;
|
|
39880
40324
|
};
|
|
39881
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
39882
|
-
const
|
|
40325
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
40326
|
+
const hasIncludedTags = includedTags.size > 0;
|
|
40327
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
39883
40328
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
39884
40329
|
const jsPlugins = [];
|
|
39885
40330
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -39894,9 +40339,14 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39894
40339
|
if (rule.scan !== void 0) continue;
|
|
39895
40340
|
if (customRulesOnly && registryEntry.originallyExternal) continue;
|
|
39896
40341
|
if (rule.framework !== "global" && !rule.requires) continue;
|
|
39897
|
-
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen)) continue;
|
|
40342
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) continue;
|
|
39898
40343
|
const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
|
|
39899
|
-
if (
|
|
40344
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
40345
|
+
defaultEnabled: rule.defaultEnabled,
|
|
40346
|
+
includeTagDefaults,
|
|
40347
|
+
hasIncludedTags,
|
|
40348
|
+
hasExplicitOverride: explicitRuleOverride !== void 0
|
|
40349
|
+
})) continue;
|
|
39900
40350
|
const severity = resolveRuleSeverityOverride({
|
|
39901
40351
|
ruleKey: registryEntry.key,
|
|
39902
40352
|
category: rule.category
|
|
@@ -39905,7 +40355,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39905
40355
|
enabledReactDoctorRules[registryEntry.key] = severity;
|
|
39906
40356
|
}
|
|
39907
40357
|
const userPluginRules = {};
|
|
39908
|
-
if (ruleSelection !== "sidecar") for (const userPlugin of userPlugins) {
|
|
40358
|
+
if (ruleSelection !== "sidecar" && !hasIncludedTags) for (const userPlugin of userPlugins) {
|
|
39909
40359
|
Object.assign(userPluginRules, buildUserPluginRules(userPlugin, severityControls));
|
|
39910
40360
|
jsPlugins.push(userPlugin.entry);
|
|
39911
40361
|
}
|
|
@@ -40122,6 +40572,19 @@ const createSidecarLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
40122
40572
|
}
|
|
40123
40573
|
};
|
|
40124
40574
|
};
|
|
40575
|
+
const fingerprintCacheByFilePath = /* @__PURE__ */ new Map();
|
|
40576
|
+
const fingerprintFileContents = (filePath, fingerprintLength) => {
|
|
40577
|
+
const fileStats = NFS.statSync(filePath, { bigint: true });
|
|
40578
|
+
const cachedFingerprint = fingerprintCacheByFilePath.get(filePath);
|
|
40579
|
+
if (cachedFingerprint?.modifiedTimeNanoseconds === fileStats.mtimeNs && cachedFingerprint.sizeBytes === fileStats.size) return cachedFingerprint.fingerprint;
|
|
40580
|
+
const fingerprint = crypto.createHash("sha256").update(NFS.readFileSync(filePath)).digest("hex").slice(0, fingerprintLength);
|
|
40581
|
+
fingerprintCacheByFilePath.set(filePath, {
|
|
40582
|
+
fingerprint,
|
|
40583
|
+
modifiedTimeNanoseconds: fileStats.mtimeNs,
|
|
40584
|
+
sizeBytes: fileStats.size
|
|
40585
|
+
});
|
|
40586
|
+
return fingerprint;
|
|
40587
|
+
};
|
|
40125
40588
|
const bundledRequire = createRequire(import.meta.url);
|
|
40126
40589
|
const childNodeVersionByBinaryPath = /* @__PURE__ */ new Map();
|
|
40127
40590
|
const resolveChildNodeVersion = (nodeBinaryPath) => {
|
|
@@ -40145,6 +40608,13 @@ const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
|
40145
40608
|
"oxlint-plugin-react-doctor/package.json",
|
|
40146
40609
|
"eslint-plugin-react-hooks/package.json"
|
|
40147
40610
|
];
|
|
40611
|
+
const resolvePluginFingerprint = () => {
|
|
40612
|
+
try {
|
|
40613
|
+
return fingerprintFileContents(bundledRequire.resolve("oxlint-plugin-react-doctor"), 16);
|
|
40614
|
+
} catch {
|
|
40615
|
+
return "unresolved";
|
|
40616
|
+
}
|
|
40617
|
+
};
|
|
40148
40618
|
const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
40149
40619
|
const versions = [`node=${resolveChildNodeVersion(nodeBinaryPath)}`];
|
|
40150
40620
|
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
@@ -40154,6 +40624,7 @@ const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
|
40154
40624
|
} catch {
|
|
40155
40625
|
versions.push(`${specifier}=missing`);
|
|
40156
40626
|
}
|
|
40627
|
+
versions.push(`oxlint-plugin-react-doctor#fingerprint=${resolvePluginFingerprint()}`);
|
|
40157
40628
|
return versions;
|
|
40158
40629
|
};
|
|
40159
40630
|
const esmRequire = createRequire(import.meta.url);
|
|
@@ -41629,7 +42100,7 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
41629
42100
|
* 6. always restore disable directives + clean up the temp dir
|
|
41630
42101
|
*/
|
|
41631
42102
|
const runOxlint = async (options) => {
|
|
41632
|
-
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;
|
|
42103
|
+
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;
|
|
41633
42104
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
41634
42105
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
41635
42106
|
validateRuleRegistration();
|
|
@@ -41643,13 +42114,15 @@ const runOxlint = async (options) => {
|
|
|
41643
42114
|
}
|
|
41644
42115
|
const pluginPath = resolvePluginPath();
|
|
41645
42116
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
41646
|
-
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
42117
|
+
const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
41647
42118
|
const buildConfig = (overrides) => createOxlintConfig({
|
|
41648
42119
|
pluginPath,
|
|
41649
42120
|
project,
|
|
41650
42121
|
customRulesOnly,
|
|
41651
42122
|
extendsPaths: overrides.extendsPaths,
|
|
41652
42123
|
ignoredTags,
|
|
42124
|
+
includedTags,
|
|
42125
|
+
includeTagDefaults,
|
|
41653
42126
|
serverAuthFunctionNames,
|
|
41654
42127
|
severityControls,
|
|
41655
42128
|
userPlugins,
|
|
@@ -42038,6 +42511,8 @@ var Linter = class Linter extends Service()("react-doctor/Linter") {
|
|
|
42038
42511
|
respectInlineDisables: input.respectInlineDisables,
|
|
42039
42512
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42040
42513
|
ignoredTags: input.ignoredTags,
|
|
42514
|
+
includedTags: input.includedTags,
|
|
42515
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
42041
42516
|
userConfig: input.userConfig ?? null,
|
|
42042
42517
|
configSourceDirectory: input.configSourceDirectory,
|
|
42043
42518
|
onPartialFailure: (reason) => {
|
|
@@ -42886,7 +43361,9 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42886
43361
|
const securityScanFailedRef = yield* make$13(false);
|
|
42887
43362
|
const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(tryPromise(() => checkSecurityScanCooperative(scanDirectory, {
|
|
42888
43363
|
project,
|
|
42889
|
-
ignoredTags: input.ignoredTags
|
|
43364
|
+
ignoredTags: input.ignoredTags,
|
|
43365
|
+
includedTags: input.includedTags,
|
|
43366
|
+
includeTagDefaults: input.includeTagDefaults
|
|
42890
43367
|
})).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), catch_$1(() => set(securityScanFailedRef, true).pipe(as(empty$4))))))).pipe(withSpan("SecurityScan.run")));
|
|
42891
43368
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
42892
43369
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
@@ -42977,6 +43454,8 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42977
43454
|
respectInlineDisables: input.respectInlineDisables,
|
|
42978
43455
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42979
43456
|
ignoredTags: input.ignoredTags,
|
|
43457
|
+
includedTags: input.includedTags,
|
|
43458
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
42980
43459
|
userConfig: resolvedConfig.config ?? void 0,
|
|
42981
43460
|
configSourceDirectory: resolvedConfig.configSourceDirectory ?? void 0,
|
|
42982
43461
|
onFileProgress: (scannedFileCount, totalFileCount) => {
|
|
@@ -43837,4 +44316,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
43837
44316
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
43838
44317
|
|
|
43839
44318
|
//# sourceMappingURL=index.js.map
|
|
43840
|
-
//# debugId=
|
|
44319
|
+
//# debugId=137db449-e390-5d6c-9d14-a8803909eea3
|