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/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]="d6dc69de-43c3-570a-8cc4-be7d4a3605ac")}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,75 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34120
34164
|
}
|
|
34121
34165
|
return packages;
|
|
34122
34166
|
};
|
|
34167
|
+
const getPreferredDependencyVersion = ({ packageJson, packageNames }) => {
|
|
34168
|
+
const allDependencies = {
|
|
34169
|
+
...packageJson.devDependencies,
|
|
34170
|
+
...packageJson.peerDependencies,
|
|
34171
|
+
...packageJson.dependencies
|
|
34172
|
+
};
|
|
34173
|
+
for (const packageName of packageNames) {
|
|
34174
|
+
const version = allDependencies[packageName];
|
|
34175
|
+
if (version !== void 0) return version;
|
|
34176
|
+
}
|
|
34177
|
+
return null;
|
|
34178
|
+
};
|
|
34179
|
+
const TANSTACK_REACT_QUERY_PACKAGES = ["@tanstack/react-query", "react-query"];
|
|
34180
|
+
const getTanStackQueryVersion = (packageJson) => {
|
|
34181
|
+
return getPreferredDependencyVersion({
|
|
34182
|
+
packageJson,
|
|
34183
|
+
packageNames: TANSTACK_REACT_QUERY_PACKAGES
|
|
34184
|
+
});
|
|
34185
|
+
};
|
|
34186
|
+
const STYLED_COMPONENTS_PACKAGES = ["styled-components"];
|
|
34187
|
+
const getStyledComponentsVersion = (packageJson) => {
|
|
34188
|
+
return getPreferredDependencyVersion({
|
|
34189
|
+
packageJson,
|
|
34190
|
+
packageNames: STYLED_COMPONENTS_PACKAGES
|
|
34191
|
+
});
|
|
34192
|
+
};
|
|
34193
|
+
const I18N_PACKAGES = [
|
|
34194
|
+
"i18next",
|
|
34195
|
+
"react-i18next",
|
|
34196
|
+
"next-i18next",
|
|
34197
|
+
"react-intl",
|
|
34198
|
+
"next-intl",
|
|
34199
|
+
"use-intl",
|
|
34200
|
+
"@formatjs/intl",
|
|
34201
|
+
"@lingui/core",
|
|
34202
|
+
"@lingui/react",
|
|
34203
|
+
"typesafe-i18n",
|
|
34204
|
+
"@tolgee/react",
|
|
34205
|
+
"react-intl-universal"
|
|
34206
|
+
];
|
|
34207
|
+
const hasI18nDependency = (packageJson) => {
|
|
34208
|
+
const allDependencies = {
|
|
34209
|
+
...packageJson.peerDependencies,
|
|
34210
|
+
...packageJson.dependencies,
|
|
34211
|
+
...packageJson.devDependencies,
|
|
34212
|
+
...packageJson.optionalDependencies
|
|
34213
|
+
};
|
|
34214
|
+
return I18N_PACKAGES.some((packageName) => allDependencies[packageName] !== void 0);
|
|
34215
|
+
};
|
|
34123
34216
|
const REANIMATED_DEPENDENCY_NAME = "react-native-reanimated";
|
|
34217
|
+
const MOBX_REACT_PACKAGE_NAME = "mobx-react";
|
|
34218
|
+
const MOBX_REACT_LITE_PACKAGE_NAME = "mobx-react-lite";
|
|
34219
|
+
const MOBX_STATE_TREE_PACKAGE_NAME = "mobx-state-tree";
|
|
34220
|
+
const MOBX_REACT_OBSERVER_PACKAGE_NAME = "mobx-react-observer";
|
|
34221
|
+
const REACT_THREE_FIBER_DEPENDENCY_NAMES = ["@react-three/fiber", "react-three-fiber"];
|
|
34222
|
+
const REACT_THREE_FIBER_SECTIONS = [
|
|
34223
|
+
"dependencies",
|
|
34224
|
+
"peerDependencies",
|
|
34225
|
+
"optionalDependencies",
|
|
34226
|
+
"devDependencies"
|
|
34227
|
+
];
|
|
34228
|
+
const THREE_DEPENDENCY_SECTIONS = [
|
|
34229
|
+
"dependencies",
|
|
34230
|
+
"peerDependencies",
|
|
34231
|
+
"optionalDependencies",
|
|
34232
|
+
"devDependencies"
|
|
34233
|
+
];
|
|
34234
|
+
const REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES = [...REACT_THREE_FIBER_DEPENDENCY_NAMES, "@react-three/drei"];
|
|
34235
|
+
const THREE_DEPENDENCY_NAMES = [...REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES, "three"];
|
|
34124
34236
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34125
34237
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34126
34238
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34131,7 +34243,7 @@ const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootD
|
|
|
34131
34243
|
if (!dependencyDeclaration.hasDeclaration) return null;
|
|
34132
34244
|
return concreteVersion ?? resolveCatalogVersion(workspacePackageJson, packageName, workspaceDirectory, dependencyDeclaration.catalogReference) ?? resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, dependencyDeclaration.catalogReference);
|
|
34133
34245
|
};
|
|
34134
|
-
const
|
|
34246
|
+
const shouldReplaceWithLowerMajor = (currentVersion, nextVersion) => {
|
|
34135
34247
|
if (!currentVersion) return true;
|
|
34136
34248
|
const currentMajor = parseReactMajor(currentVersion);
|
|
34137
34249
|
const nextMajor = parseReactMajor(nextVersion);
|
|
@@ -34139,7 +34251,62 @@ const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
|
34139
34251
|
if (nextMajor === null) return false;
|
|
34140
34252
|
return nextMajor < currentMajor;
|
|
34141
34253
|
};
|
|
34142
|
-
const
|
|
34254
|
+
const shouldReplaceSupportedDependencyFact = (currentFact, nextFact, latestSupportedMajor) => {
|
|
34255
|
+
if (currentFact.version === null) return true;
|
|
34256
|
+
if (nextFact.version === null) return false;
|
|
34257
|
+
const currentMajor = getLowestDependencyMajor(currentFact.version);
|
|
34258
|
+
const nextMajor = getLowestDependencyMajor(nextFact.version);
|
|
34259
|
+
if (currentMajor === null) return false;
|
|
34260
|
+
if (nextMajor === null) return true;
|
|
34261
|
+
if (currentMajor > latestSupportedMajor) return false;
|
|
34262
|
+
if (nextMajor > latestSupportedMajor) return true;
|
|
34263
|
+
return nextMajor < currentMajor;
|
|
34264
|
+
};
|
|
34265
|
+
const shouldReplaceStyledComponentsVersion = (currentVersion, nextVersion) => {
|
|
34266
|
+
if (!currentVersion) return true;
|
|
34267
|
+
const currentMajor = getLowestDependencyMajor(currentVersion);
|
|
34268
|
+
const nextMajor = getLowestDependencyMajor(nextVersion);
|
|
34269
|
+
if (currentMajor === null) return nextMajor !== null && nextMajor < 6;
|
|
34270
|
+
if (nextMajor === null) return currentMajor >= 6;
|
|
34271
|
+
return nextMajor < currentMajor;
|
|
34272
|
+
};
|
|
34273
|
+
const selectOldestDependencyVersion = (currentVersion, nextVersion) => {
|
|
34274
|
+
if (currentVersion === null || nextVersion === null) return null;
|
|
34275
|
+
const current = parseDependencyMajorMinor(currentVersion);
|
|
34276
|
+
const next = parseDependencyMajorMinor(nextVersion);
|
|
34277
|
+
if (current === null) return currentVersion;
|
|
34278
|
+
if (next === null) return nextVersion;
|
|
34279
|
+
if (next.major !== current.major) return next.major < current.major ? nextVersion : currentVersion;
|
|
34280
|
+
return next.minor < current.minor ? nextVersion : currentVersion;
|
|
34281
|
+
};
|
|
34282
|
+
const shouldReplaceMobxFact = (currentFact, nextFact) => {
|
|
34283
|
+
if (currentFact.sourceDirectory === null) return true;
|
|
34284
|
+
if (currentFact.version === null) return false;
|
|
34285
|
+
if (nextFact.version === null) return true;
|
|
34286
|
+
const currentMajor = getDependencyMajorWithinSupportedRange(currentFact.version, 6);
|
|
34287
|
+
const nextMajor = getDependencyMajorWithinSupportedRange(nextFact.version, 6);
|
|
34288
|
+
if (currentMajor === null) return false;
|
|
34289
|
+
if (nextMajor === null) return true;
|
|
34290
|
+
return selectOldestDependencyVersion(currentFact.version, nextFact.version) === nextFact.version;
|
|
34291
|
+
};
|
|
34292
|
+
const collectBindingVersion = (facts, packageJson, directory, packageName) => {
|
|
34293
|
+
const version = getDependencySpec(packageJson, packageName);
|
|
34294
|
+
if (version === null) return;
|
|
34295
|
+
const resolvedVersion = resolveCatalogBackedDependencyVersion({
|
|
34296
|
+
rootDirectory: directory,
|
|
34297
|
+
rootPackageJson: packageJson,
|
|
34298
|
+
packageName,
|
|
34299
|
+
version
|
|
34300
|
+
});
|
|
34301
|
+
if (packageName === MOBX_REACT_PACKAGE_NAME) {
|
|
34302
|
+
facts.mobxReactVersion = facts.hasMobxReact ? selectOldestDependencyVersion(facts.mobxReactVersion, resolvedVersion) : resolvedVersion;
|
|
34303
|
+
facts.hasMobxReact = true;
|
|
34304
|
+
return;
|
|
34305
|
+
}
|
|
34306
|
+
facts.mobxReactLiteVersion = facts.hasMobxReactLite ? selectOldestDependencyVersion(facts.mobxReactLiteVersion, resolvedVersion) : resolvedVersion;
|
|
34307
|
+
facts.hasMobxReactLite = true;
|
|
34308
|
+
};
|
|
34309
|
+
const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, rootPackageJson) => {
|
|
34143
34310
|
if (facts.expo.version === null) {
|
|
34144
34311
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34145
34312
|
if (spec !== null) facts.expo = {
|
|
@@ -34161,13 +34328,113 @@ const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
|
34161
34328
|
sourceDirectory: directory
|
|
34162
34329
|
};
|
|
34163
34330
|
}
|
|
34331
|
+
const mobxSpec = getDependencySpec(packageJson, "mobx");
|
|
34332
|
+
if (mobxSpec !== null) {
|
|
34333
|
+
const nextMobxFact = {
|
|
34334
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34335
|
+
rootDirectory: directory,
|
|
34336
|
+
rootPackageJson: packageJson,
|
|
34337
|
+
packageName: "mobx",
|
|
34338
|
+
version: mobxSpec
|
|
34339
|
+
}),
|
|
34340
|
+
sourceDirectory: directory
|
|
34341
|
+
};
|
|
34342
|
+
if (shouldReplaceMobxFact(facts.mobx, nextMobxFact)) facts.mobx = nextMobxFact;
|
|
34343
|
+
}
|
|
34344
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_PACKAGE_NAME);
|
|
34345
|
+
collectBindingVersion(facts, packageJson, directory, MOBX_REACT_LITE_PACKAGE_NAME);
|
|
34346
|
+
facts.hasMobxStateTree = facts.hasMobxStateTree || getDependencySpec(packageJson, MOBX_STATE_TREE_PACKAGE_NAME) !== null;
|
|
34347
|
+
facts.hasMobxReactObserver = facts.hasMobxReactObserver || getDependencySpec(packageJson, MOBX_REACT_OBSERVER_PACKAGE_NAME) !== null;
|
|
34348
|
+
const zustandSpec = getDependencySpec(packageJson, "zustand");
|
|
34349
|
+
if (zustandSpec !== null) {
|
|
34350
|
+
const nextZustandFact = {
|
|
34351
|
+
version: resolveCatalogBackedDependencyVersion({
|
|
34352
|
+
rootDirectory: directory,
|
|
34353
|
+
rootPackageJson: packageJson,
|
|
34354
|
+
packageName: "zustand",
|
|
34355
|
+
version: zustandSpec
|
|
34356
|
+
}),
|
|
34357
|
+
sourceDirectory: directory
|
|
34358
|
+
};
|
|
34359
|
+
if (shouldReplaceSupportedDependencyFact(facts.zustand, nextZustandFact, 5)) facts.zustand = nextZustandFact;
|
|
34360
|
+
}
|
|
34164
34361
|
if (facts.reanimatedVersion === null) {
|
|
34165
34362
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34166
34363
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34167
34364
|
}
|
|
34365
|
+
if (facts.valtioVersion === null) {
|
|
34366
|
+
const spec = getDependencySpec(packageJson, "valtio");
|
|
34367
|
+
if (spec !== null) facts.valtioVersion = spec;
|
|
34368
|
+
}
|
|
34369
|
+
facts.tanstackQueryVersion ??= getTanStackQueryVersion(packageJson);
|
|
34370
|
+
const styledComponentsVersion = resolveCatalogBackedDependencyVersion({
|
|
34371
|
+
rootDirectory: directory,
|
|
34372
|
+
rootPackageJson: packageJson,
|
|
34373
|
+
packageName: "styled-components",
|
|
34374
|
+
version: getStyledComponentsVersion(packageJson)
|
|
34375
|
+
});
|
|
34376
|
+
if (styledComponentsVersion && shouldReplaceStyledComponentsVersion(facts.styledComponentsVersion, styledComponentsVersion)) facts.styledComponentsVersion = styledComponentsVersion;
|
|
34377
|
+
facts.hasI18nLibrary = facts.hasI18nLibrary || hasI18nDependency(packageJson);
|
|
34378
|
+
for (const packageName of REACT_THREE_FIBER_DEPENDENCY_NAMES) {
|
|
34379
|
+
const version = resolveCatalogBackedDependencyVersion({
|
|
34380
|
+
rootDirectory,
|
|
34381
|
+
rootPackageJson,
|
|
34382
|
+
sourceDirectory: directory,
|
|
34383
|
+
sourcePackageJson: packageJson,
|
|
34384
|
+
packageName,
|
|
34385
|
+
version: getDependencyDeclaration({
|
|
34386
|
+
packageName,
|
|
34387
|
+
packageJson,
|
|
34388
|
+
sections: REACT_THREE_FIBER_SECTIONS
|
|
34389
|
+
}).version
|
|
34390
|
+
});
|
|
34391
|
+
if (version === null) continue;
|
|
34392
|
+
if (shouldReplaceWithLowerMajor(facts.reactThreeFiber.version, version)) facts.reactThreeFiber = {
|
|
34393
|
+
packageName,
|
|
34394
|
+
version,
|
|
34395
|
+
sourceDirectory: directory
|
|
34396
|
+
};
|
|
34397
|
+
}
|
|
34398
|
+
const threeVersion = resolveCatalogBackedDependencyVersion({
|
|
34399
|
+
rootDirectory,
|
|
34400
|
+
rootPackageJson,
|
|
34401
|
+
sourceDirectory: directory,
|
|
34402
|
+
sourcePackageJson: packageJson,
|
|
34403
|
+
packageName: "three",
|
|
34404
|
+
version: getDependencyDeclaration({
|
|
34405
|
+
packageName: "three",
|
|
34406
|
+
packageJson,
|
|
34407
|
+
sections: THREE_DEPENDENCY_SECTIONS
|
|
34408
|
+
}).version
|
|
34409
|
+
});
|
|
34410
|
+
if (threeVersion !== null) {
|
|
34411
|
+
const currentRelease = parseThreeRelease(facts.threeVersion);
|
|
34412
|
+
const nextRelease = parseThreeRelease(threeVersion);
|
|
34413
|
+
if (facts.threeVersion === null || nextRelease !== null && (currentRelease === null || nextRelease < currentRelease)) facts.threeVersion = threeVersion;
|
|
34414
|
+
}
|
|
34168
34415
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34169
34416
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34170
34417
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34418
|
+
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34419
|
+
if (remotionSpec !== null) {
|
|
34420
|
+
facts.hasRemotionDependency = true;
|
|
34421
|
+
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34422
|
+
rootDirectory,
|
|
34423
|
+
rootPackageJson,
|
|
34424
|
+
packageName: "remotion",
|
|
34425
|
+
version: remotionSpec
|
|
34426
|
+
});
|
|
34427
|
+
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34428
|
+
if (remotionMajorVersion === null) {
|
|
34429
|
+
facts.hasUnknownRemotionVersion = true;
|
|
34430
|
+
facts.remotionVersion = null;
|
|
34431
|
+
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34432
|
+
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34433
|
+
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34434
|
+
}
|
|
34435
|
+
}
|
|
34436
|
+
facts.hasThree = facts.hasThree || THREE_DEPENDENCY_NAMES.some((dependencyName) => getDependencySpec(packageJson, dependencyName) !== null);
|
|
34437
|
+
facts.hasReactThreeFiber = facts.hasReactThreeFiber || REACT_THREE_FIBER_ECOSYSTEM_DEPENDENCY_NAMES.some((dependencyName) => getDependencySpec(packageJson, dependencyName) !== null);
|
|
34171
34438
|
};
|
|
34172
34439
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34173
34440
|
const facts = {
|
|
@@ -34187,12 +34454,41 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34187
34454
|
version: null,
|
|
34188
34455
|
sourceDirectory: null
|
|
34189
34456
|
},
|
|
34457
|
+
valtioVersion: null,
|
|
34458
|
+
mobx: {
|
|
34459
|
+
version: null,
|
|
34460
|
+
sourceDirectory: null
|
|
34461
|
+
},
|
|
34462
|
+
hasMobxReact: false,
|
|
34463
|
+
mobxReactVersion: null,
|
|
34464
|
+
hasMobxReactLite: false,
|
|
34465
|
+
mobxReactLiteVersion: null,
|
|
34466
|
+
hasMobxStateTree: false,
|
|
34467
|
+
hasMobxReactObserver: false,
|
|
34468
|
+
zustand: {
|
|
34469
|
+
version: null,
|
|
34470
|
+
sourceDirectory: null
|
|
34471
|
+
},
|
|
34472
|
+
tanstackQueryVersion: null,
|
|
34473
|
+
styledComponentsVersion: null,
|
|
34474
|
+
hasI18nLibrary: false,
|
|
34190
34475
|
hasReactNativeAwarePackage: false,
|
|
34191
34476
|
hasReanimatedAwarePackage: false,
|
|
34192
34477
|
hasSsrDependency: false,
|
|
34478
|
+
hasRemotionDependency: false,
|
|
34479
|
+
hasUnknownRemotionVersion: false,
|
|
34480
|
+
remotionVersion: null,
|
|
34481
|
+
hasThree: false,
|
|
34482
|
+
threeVersion: null,
|
|
34483
|
+
hasReactThreeFiber: false,
|
|
34484
|
+
reactThreeFiber: {
|
|
34485
|
+
packageName: null,
|
|
34486
|
+
version: null,
|
|
34487
|
+
sourceDirectory: null
|
|
34488
|
+
},
|
|
34193
34489
|
reanimatedVersion: null
|
|
34194
34490
|
};
|
|
34195
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34491
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory, rootDirectory, rootPackageJson);
|
|
34196
34492
|
let isReactGroupSettled = !collectReactGroup;
|
|
34197
34493
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34198
34494
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
@@ -34201,7 +34497,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34201
34497
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34202
34498
|
visitedDirectories.add(workspaceDirectory);
|
|
34203
34499
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34204
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34500
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory, rootDirectory, rootPackageJson);
|
|
34205
34501
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34206
34502
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34207
34503
|
if (isReactGroupSettled) continue;
|
|
@@ -34232,7 +34528,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34232
34528
|
workspaceDirectory,
|
|
34233
34529
|
workspacePackageJson
|
|
34234
34530
|
});
|
|
34235
|
-
if (reactVersion &&
|
|
34531
|
+
if (reactVersion && shouldReplaceWithLowerMajor(facts.reactVersion, reactVersion)) facts.reactVersion = reactVersion;
|
|
34236
34532
|
if (tailwindVersion && !facts.tailwindVersion) facts.tailwindVersion = tailwindVersion;
|
|
34237
34533
|
if (zodVersion && !facts.zodVersion) facts.zodVersion = zodVersion;
|
|
34238
34534
|
const settledReactMajor = parseReactMajor(facts.reactVersion);
|
|
@@ -34425,11 +34721,35 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34425
34721
|
tailwindVersion: null,
|
|
34426
34722
|
zodVersion: null,
|
|
34427
34723
|
zodMajorVersion: null,
|
|
34724
|
+
mobxVersion: null,
|
|
34725
|
+
mobxMajorVersion: null,
|
|
34726
|
+
hasMobxReact: false,
|
|
34727
|
+
mobxReactVersion: null,
|
|
34728
|
+
hasMobxReactLite: false,
|
|
34729
|
+
mobxReactLiteVersion: null,
|
|
34730
|
+
hasMobxStateTree: false,
|
|
34731
|
+
hasMobxReactObserver: false,
|
|
34732
|
+
zustandVersion: null,
|
|
34733
|
+
zustandMajorVersion: null,
|
|
34428
34734
|
framework: "unknown",
|
|
34429
34735
|
hasTypeScript: hasOwnTsConfig,
|
|
34430
34736
|
hasReactCompiler: false,
|
|
34431
34737
|
hasReactCompilerLintPlugin: false,
|
|
34432
34738
|
hasTanStackQuery: false,
|
|
34739
|
+
valtioVersion: null,
|
|
34740
|
+
valtioMajorVersion: null,
|
|
34741
|
+
hasRemotion: false,
|
|
34742
|
+
remotionVersion: null,
|
|
34743
|
+
remotionMajorVersion: null,
|
|
34744
|
+
hasI18nLibrary: false,
|
|
34745
|
+
tanstackQueryVersion: null,
|
|
34746
|
+
styledComponentsVersion: null,
|
|
34747
|
+
hasThree: false,
|
|
34748
|
+
threeVersion: null,
|
|
34749
|
+
threeRelease: null,
|
|
34750
|
+
hasReactThreeFiber: false,
|
|
34751
|
+
reactThreeFiberVersion: null,
|
|
34752
|
+
reactThreeFiberMajorVersion: null,
|
|
34433
34753
|
hasSsrDependency: false,
|
|
34434
34754
|
preactVersion: null,
|
|
34435
34755
|
preactMajorVersion: null,
|
|
@@ -34528,6 +34848,12 @@ const discoverProject = (directory) => {
|
|
|
34528
34848
|
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
34529
34849
|
version: workspaceFacts.shopifyFlashList.version
|
|
34530
34850
|
}) : null;
|
|
34851
|
+
const zustandVersion = resolveCatalogBackedDependencyVersion({
|
|
34852
|
+
rootDirectory: directory,
|
|
34853
|
+
rootPackageJson: packageJson,
|
|
34854
|
+
packageName: "zustand",
|
|
34855
|
+
version: workspaceFacts.zustand.version
|
|
34856
|
+
});
|
|
34531
34857
|
const hasReanimated = hasReactNativeWorkspace && workspaceFacts.hasReanimatedAwarePackage;
|
|
34532
34858
|
const reanimatedVersion = hasReanimated ? workspaceFacts.reanimatedVersion : null;
|
|
34533
34859
|
const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
|
|
@@ -34536,7 +34862,33 @@ const discoverProject = (directory) => {
|
|
|
34536
34862
|
packageName: "next",
|
|
34537
34863
|
version: workspaceFacts.next.version
|
|
34538
34864
|
}) : null;
|
|
34865
|
+
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
34866
|
+
rootDirectory: directory,
|
|
34867
|
+
rootPackageJson: packageJson,
|
|
34868
|
+
packageName: "valtio",
|
|
34869
|
+
version: workspaceFacts.valtioVersion
|
|
34870
|
+
});
|
|
34871
|
+
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
34872
|
+
rootDirectory: directory,
|
|
34873
|
+
rootPackageJson: packageJson,
|
|
34874
|
+
packageName: "mobx",
|
|
34875
|
+
version: workspaceFacts.mobx.version
|
|
34876
|
+
});
|
|
34539
34877
|
const preactVersion = getPreactVersion(packageJson);
|
|
34878
|
+
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34879
|
+
const tanstackQueryVersion = getTanStackQueryVersion(packageJson) ?? workspaceFacts.tanstackQueryVersion;
|
|
34880
|
+
const reactThreeFiberVersion = workspaceFacts.reactThreeFiber.packageName ? resolveCatalogBackedDependencyVersion({
|
|
34881
|
+
rootDirectory: directory,
|
|
34882
|
+
rootPackageJson: packageJson,
|
|
34883
|
+
packageName: workspaceFacts.reactThreeFiber.packageName,
|
|
34884
|
+
version: workspaceFacts.reactThreeFiber.version
|
|
34885
|
+
}) : null;
|
|
34886
|
+
const threeVersion = resolveCatalogBackedDependencyVersion({
|
|
34887
|
+
rootDirectory: directory,
|
|
34888
|
+
rootPackageJson: packageJson,
|
|
34889
|
+
packageName: "three",
|
|
34890
|
+
version: workspaceFacts.threeVersion
|
|
34891
|
+
});
|
|
34540
34892
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34541
34893
|
const projectInfo = {
|
|
34542
34894
|
rootDirectory: directory,
|
|
@@ -34546,11 +34898,35 @@ const discoverProject = (directory) => {
|
|
|
34546
34898
|
tailwindVersion,
|
|
34547
34899
|
zodVersion,
|
|
34548
34900
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
34901
|
+
mobxVersion,
|
|
34902
|
+
mobxMajorVersion: mobxVersion === null ? null : getDependencyMajorWithinSupportedRange(mobxVersion, 6),
|
|
34903
|
+
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
34904
|
+
mobxReactVersion: workspaceFacts.mobxReactVersion,
|
|
34905
|
+
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
34906
|
+
mobxReactLiteVersion: workspaceFacts.mobxReactLiteVersion,
|
|
34907
|
+
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
34908
|
+
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
34909
|
+
zustandVersion,
|
|
34910
|
+
zustandMajorVersion: zustandVersion === null ? null : getLowestDependencyMajor(zustandVersion),
|
|
34549
34911
|
framework,
|
|
34550
34912
|
hasTypeScript,
|
|
34551
34913
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34552
34914
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
34553
|
-
hasTanStackQuery:
|
|
34915
|
+
hasTanStackQuery: tanstackQueryVersion !== null,
|
|
34916
|
+
hasI18nLibrary: workspaceFacts.hasI18nLibrary,
|
|
34917
|
+
tanstackQueryVersion,
|
|
34918
|
+
styledComponentsVersion: workspaceFacts.styledComponentsVersion,
|
|
34919
|
+
valtioVersion,
|
|
34920
|
+
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
34921
|
+
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
34922
|
+
remotionVersion,
|
|
34923
|
+
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
34924
|
+
hasThree: workspaceFacts.hasThree,
|
|
34925
|
+
threeVersion,
|
|
34926
|
+
threeRelease: parseThreeRelease(threeVersion),
|
|
34927
|
+
hasReactThreeFiber: workspaceFacts.hasReactThreeFiber,
|
|
34928
|
+
reactThreeFiberVersion,
|
|
34929
|
+
reactThreeFiberMajorVersion: reactThreeFiberVersion === null ? null : getLowestDependencyMajor(reactThreeFiberVersion),
|
|
34554
34930
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34555
34931
|
preactVersion,
|
|
34556
34932
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
@@ -34784,7 +35160,6 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
34784
35160
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
34785
35161
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
34786
35162
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34787
|
-
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
34788
35163
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
34789
35164
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
34790
35165
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37071,9 +37446,25 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37071
37446
|
".babelrc.json"
|
|
37072
37447
|
];
|
|
37073
37448
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37449
|
+
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37450
|
+
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37451
|
+
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37452
|
+
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37074
37453
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37075
37454
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37455
|
+
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37456
|
+
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37457
|
+
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37458
|
+
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37459
|
+
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37460
|
+
if (normalizedVersionRange === null) return false;
|
|
37461
|
+
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37462
|
+
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37463
|
+
};
|
|
37464
|
+
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37076
37465
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37466
|
+
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37467
|
+
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37077
37468
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37078
37469
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37079
37470
|
if (!isFile(filePath)) continue;
|
|
@@ -37083,7 +37474,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37083
37474
|
} catch {
|
|
37084
37475
|
continue;
|
|
37085
37476
|
}
|
|
37086
|
-
if (
|
|
37477
|
+
if (shouldReportLegacyPreset && LEGACY_PRESET_REFERENCE.test(contents)) return [buildReactNativeDiagnostic({
|
|
37087
37478
|
filePath: fileName,
|
|
37088
37479
|
rule: "rn-no-metro-babel-preset",
|
|
37089
37480
|
severity: "error",
|
|
@@ -37106,12 +37497,6 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37106
37497
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37107
37498
|
};
|
|
37108
37499
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37109
|
-
const DEPENDENCY_SECTIONS = [
|
|
37110
|
-
"dependencies",
|
|
37111
|
-
"devDependencies",
|
|
37112
|
-
"peerDependencies",
|
|
37113
|
-
"optionalDependencies"
|
|
37114
|
-
];
|
|
37115
37500
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37116
37501
|
"19.0": {
|
|
37117
37502
|
rceFixedVersion: "19.0.1",
|
|
@@ -37158,20 +37543,13 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37158
37543
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37159
37544
|
return [...directories];
|
|
37160
37545
|
};
|
|
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
37546
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37169
37547
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37170
37548
|
if (isFile(manifestPath)) {
|
|
37171
37549
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37172
37550
|
if (installedVersion !== null) return installedVersion;
|
|
37173
37551
|
}
|
|
37174
|
-
const candidateSpecs = [
|
|
37552
|
+
const candidateSpecs = [getDependencySpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37175
37553
|
for (const spec of candidateSpecs) {
|
|
37176
37554
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37177
37555
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -37823,10 +38201,10 @@ const SSR_FRAMEWORKS = new Set([
|
|
|
37823
38201
|
"gatsby",
|
|
37824
38202
|
"tanstack-start"
|
|
37825
38203
|
]);
|
|
37826
|
-
const
|
|
37827
|
-
if (
|
|
37828
|
-
const
|
|
37829
|
-
for (let candidate = earliest; candidate <=
|
|
38204
|
+
const addVersionCapabilityLadder = (capabilities, name, detectedVersion, earliest, latest) => {
|
|
38205
|
+
if (detectedVersion === null) return;
|
|
38206
|
+
const cappedVersion = Math.min(detectedVersion, latest);
|
|
38207
|
+
for (let candidate = earliest; candidate <= cappedVersion; candidate += 1) capabilities.add(`${name}:${candidate}`);
|
|
37830
38208
|
};
|
|
37831
38209
|
const buildCapabilities = (project) => {
|
|
37832
38210
|
const capabilities = /* @__PURE__ */ new Set();
|
|
@@ -37839,24 +38217,77 @@ const buildCapabilities = (project) => {
|
|
|
37839
38217
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
37840
38218
|
if (project.isStaticExport) capabilities.add("nextjs:static-export");
|
|
37841
38219
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
37842
|
-
|
|
38220
|
+
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 16) capabilities.add("nextjs:16");
|
|
38221
|
+
addVersionCapabilityLadder(capabilities, "react", project.reactMajorVersion, 17, 30);
|
|
37843
38222
|
if (project.reactMajorVersion !== null && project.reactMajorVersion >= 19 && isMajorMinorAtLeast(parseReactMajorMinor(project.reactVersion), {
|
|
37844
38223
|
major: 19,
|
|
37845
38224
|
minor: 2
|
|
37846
38225
|
})) capabilities.add("react:19.2");
|
|
37847
|
-
if (project.tailwindVersion !== null)
|
|
37848
|
-
|
|
37849
|
-
|
|
37850
|
-
|
|
37851
|
-
|
|
38226
|
+
if (project.tailwindVersion !== null) {
|
|
38227
|
+
capabilities.add("tailwind");
|
|
38228
|
+
const tailwindVersion = parseTailwindMajorMinor(project.tailwindVersion);
|
|
38229
|
+
if (isMajorMinorAtLeast(tailwindVersion, {
|
|
38230
|
+
major: 3,
|
|
38231
|
+
minor: 4
|
|
38232
|
+
})) capabilities.add("tailwind:3.4");
|
|
38233
|
+
if (tailwindVersion !== null && isMajorMinorAtLeast(tailwindVersion, {
|
|
38234
|
+
major: 4,
|
|
38235
|
+
minor: 0
|
|
38236
|
+
})) capabilities.add("tailwind:4");
|
|
38237
|
+
}
|
|
37852
38238
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
37853
38239
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
38240
|
+
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
38241
|
+
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
38242
|
+
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
38243
|
+
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
38244
|
+
const mobxReactVersion = parseDependencyMajorMinor(project.mobxReactVersion);
|
|
38245
|
+
const mobxReactLiteVersion = parseDependencyMajorMinor(project.mobxReactLiteVersion);
|
|
38246
|
+
const hasMobxReactObserverMemoGuard = mobxReactVersion !== null && isMajorMinorAtLeast(mobxReactVersion, {
|
|
38247
|
+
major: 7,
|
|
38248
|
+
minor: 3
|
|
38249
|
+
});
|
|
38250
|
+
const hasMobxReactLiteObserverMemoGuard = mobxReactLiteVersion !== null && isMajorMinorAtLeast(mobxReactLiteVersion, {
|
|
38251
|
+
major: 3,
|
|
38252
|
+
minor: 3
|
|
38253
|
+
});
|
|
38254
|
+
if (hasMobxReactObserverMemoGuard) capabilities.add("mobx-react-observer-memo-guard");
|
|
38255
|
+
if (hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-lite-observer-memo-guard");
|
|
38256
|
+
if (hasMobxReactObserverMemoGuard || hasMobxReactLiteObserverMemoGuard) capabilities.add("mobx-react-binding-observer-memo-guard");
|
|
38257
|
+
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
38258
|
+
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
38259
|
+
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addVersionCapabilityLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
38260
|
+
const mobxVersion = parseDependencyMajorMinor(project.mobxVersion);
|
|
38261
|
+
if (project.mobxMajorVersion === 6 && mobxVersion !== null && isMajorMinorAtLeast(mobxVersion, {
|
|
38262
|
+
major: 6,
|
|
38263
|
+
minor: 10
|
|
38264
|
+
})) capabilities.add("mobx:6.10");
|
|
38265
|
+
if (project.zustandVersion !== void 0 && project.zustandVersion !== null) capabilities.add("zustand");
|
|
38266
|
+
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addVersionCapabilityLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
37854
38267
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
37855
38268
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
37856
|
-
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
38269
|
+
if (Boolean(project.hasTanStackQuery) || Boolean(project.tanstackQueryVersion)) capabilities.add("tanstack-query");
|
|
38270
|
+
if (project.styledComponentsVersion) {
|
|
38271
|
+
capabilities.add("styled-components");
|
|
38272
|
+
const styledComponentsMajor = getLowestDependencyMajor(project.styledComponentsVersion);
|
|
38273
|
+
if (styledComponentsMajor !== null && styledComponentsMajor >= 6) capabilities.add("styled-components:6");
|
|
38274
|
+
}
|
|
38275
|
+
if (project.hasI18nLibrary) capabilities.add("i18n");
|
|
38276
|
+
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
38277
|
+
addVersionCapabilityLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
38278
|
+
if (project.hasRemotion) {
|
|
38279
|
+
capabilities.add("remotion");
|
|
38280
|
+
addVersionCapabilityLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
38281
|
+
}
|
|
38282
|
+
if (project.hasThree || project.hasReactThreeFiber) capabilities.add("three");
|
|
38283
|
+
addVersionCapabilityLadder(capabilities, "three", project.threeRelease ?? null, 145, 250);
|
|
38284
|
+
if (project.hasReactThreeFiber) {
|
|
38285
|
+
capabilities.add("r3f");
|
|
38286
|
+
addVersionCapabilityLadder(capabilities, "r3f", project.reactThreeFiberMajorVersion ?? null, 3, 10);
|
|
38287
|
+
}
|
|
37857
38288
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
37858
38289
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
37859
|
-
|
|
38290
|
+
addVersionCapabilityLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
37860
38291
|
if (project.preactVersion !== null && project.reactVersion === null) capabilities.add("pure-preact");
|
|
37861
38292
|
return capabilities;
|
|
37862
38293
|
};
|
|
@@ -37868,7 +38299,7 @@ const getCapabilities = (project) => {
|
|
|
37868
38299
|
capabilitiesByProject.set(project, capabilities);
|
|
37869
38300
|
return capabilities;
|
|
37870
38301
|
};
|
|
37871
|
-
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen) => {
|
|
38302
|
+
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen, includedTags) => {
|
|
37872
38303
|
if (requires) {
|
|
37873
38304
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
37874
38305
|
}
|
|
@@ -37879,20 +38310,29 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhe
|
|
|
37879
38310
|
if (tags) {
|
|
37880
38311
|
for (const tag of tags) if (ignoredTags.has(tag)) return false;
|
|
37881
38312
|
}
|
|
38313
|
+
if (includedTags && includedTags.size > 0) {
|
|
38314
|
+
if (!tags?.some((tag) => includedTags.has(tag))) return false;
|
|
38315
|
+
}
|
|
37882
38316
|
return true;
|
|
37883
38317
|
};
|
|
38318
|
+
const shouldEnableRuleByDefaultStatus = (options) => options.defaultEnabled !== false || options.hasExplicitOverride === true || options.includeTagDefaults && options.hasIncludedTags;
|
|
37884
38319
|
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
37885
38320
|
setImmediate(resolve);
|
|
37886
38321
|
});
|
|
37887
38322
|
const createSecurityScanSession = (rootDirectory, options) => {
|
|
37888
38323
|
const capabilities = options.project ? getCapabilities(options.project) : /* @__PURE__ */ new Set();
|
|
37889
38324
|
const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
|
|
38325
|
+
const includedTags = options.includedTags ?? /* @__PURE__ */ new Set();
|
|
37890
38326
|
const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
|
|
37891
38327
|
const rule = entry.rule;
|
|
37892
38328
|
const scan = rule.scan;
|
|
37893
38329
|
if (typeof scan !== "function") return [];
|
|
37894
|
-
if (
|
|
37895
|
-
|
|
38330
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
38331
|
+
defaultEnabled: rule.defaultEnabled,
|
|
38332
|
+
includeTagDefaults: options.includeTagDefaults === true,
|
|
38333
|
+
hasIncludedTags: includedTags.size > 0
|
|
38334
|
+
})) return [];
|
|
38335
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) return [];
|
|
37896
38336
|
return [{
|
|
37897
38337
|
entry,
|
|
37898
38338
|
scan,
|
|
@@ -39878,8 +40318,9 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
39878
40318
|
}
|
|
39879
40319
|
return enabled;
|
|
39880
40320
|
};
|
|
39881
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
39882
|
-
const
|
|
40321
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), includedTags = /* @__PURE__ */ new Set(), includeTagDefaults = false, serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
40322
|
+
const hasIncludedTags = includedTags.size > 0;
|
|
40323
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
39883
40324
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
39884
40325
|
const jsPlugins = [];
|
|
39885
40326
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -39894,9 +40335,14 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39894
40335
|
if (rule.scan !== void 0) continue;
|
|
39895
40336
|
if (customRulesOnly && registryEntry.originallyExternal) continue;
|
|
39896
40337
|
if (rule.framework !== "global" && !rule.requires) continue;
|
|
39897
|
-
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen)) continue;
|
|
40338
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) continue;
|
|
39898
40339
|
const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
|
|
39899
|
-
if (
|
|
40340
|
+
if (!shouldEnableRuleByDefaultStatus({
|
|
40341
|
+
defaultEnabled: rule.defaultEnabled,
|
|
40342
|
+
includeTagDefaults,
|
|
40343
|
+
hasIncludedTags,
|
|
40344
|
+
hasExplicitOverride: explicitRuleOverride !== void 0
|
|
40345
|
+
})) continue;
|
|
39900
40346
|
const severity = resolveRuleSeverityOverride({
|
|
39901
40347
|
ruleKey: registryEntry.key,
|
|
39902
40348
|
category: rule.category
|
|
@@ -39905,7 +40351,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
39905
40351
|
enabledReactDoctorRules[registryEntry.key] = severity;
|
|
39906
40352
|
}
|
|
39907
40353
|
const userPluginRules = {};
|
|
39908
|
-
if (ruleSelection !== "sidecar") for (const userPlugin of userPlugins) {
|
|
40354
|
+
if (ruleSelection !== "sidecar" && !hasIncludedTags) for (const userPlugin of userPlugins) {
|
|
39909
40355
|
Object.assign(userPluginRules, buildUserPluginRules(userPlugin, severityControls));
|
|
39910
40356
|
jsPlugins.push(userPlugin.entry);
|
|
39911
40357
|
}
|
|
@@ -40122,6 +40568,19 @@ const createSidecarLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
40122
40568
|
}
|
|
40123
40569
|
};
|
|
40124
40570
|
};
|
|
40571
|
+
const fingerprintCacheByFilePath = /* @__PURE__ */ new Map();
|
|
40572
|
+
const fingerprintFileContents = (filePath, fingerprintLength) => {
|
|
40573
|
+
const fileStats = NFS.statSync(filePath, { bigint: true });
|
|
40574
|
+
const cachedFingerprint = fingerprintCacheByFilePath.get(filePath);
|
|
40575
|
+
if (cachedFingerprint?.modifiedTimeNanoseconds === fileStats.mtimeNs && cachedFingerprint.sizeBytes === fileStats.size) return cachedFingerprint.fingerprint;
|
|
40576
|
+
const fingerprint = crypto.createHash("sha256").update(NFS.readFileSync(filePath)).digest("hex").slice(0, fingerprintLength);
|
|
40577
|
+
fingerprintCacheByFilePath.set(filePath, {
|
|
40578
|
+
fingerprint,
|
|
40579
|
+
modifiedTimeNanoseconds: fileStats.mtimeNs,
|
|
40580
|
+
sizeBytes: fileStats.size
|
|
40581
|
+
});
|
|
40582
|
+
return fingerprint;
|
|
40583
|
+
};
|
|
40125
40584
|
const bundledRequire = createRequire(import.meta.url);
|
|
40126
40585
|
const childNodeVersionByBinaryPath = /* @__PURE__ */ new Map();
|
|
40127
40586
|
const resolveChildNodeVersion = (nodeBinaryPath) => {
|
|
@@ -40145,6 +40604,13 @@ const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
|
40145
40604
|
"oxlint-plugin-react-doctor/package.json",
|
|
40146
40605
|
"eslint-plugin-react-hooks/package.json"
|
|
40147
40606
|
];
|
|
40607
|
+
const resolvePluginFingerprint = () => {
|
|
40608
|
+
try {
|
|
40609
|
+
return fingerprintFileContents(bundledRequire.resolve("oxlint-plugin-react-doctor"), 16);
|
|
40610
|
+
} catch {
|
|
40611
|
+
return "unresolved";
|
|
40612
|
+
}
|
|
40613
|
+
};
|
|
40148
40614
|
const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
40149
40615
|
const versions = [`node=${resolveChildNodeVersion(nodeBinaryPath)}`];
|
|
40150
40616
|
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
@@ -40154,6 +40620,7 @@ const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
|
40154
40620
|
} catch {
|
|
40155
40621
|
versions.push(`${specifier}=missing`);
|
|
40156
40622
|
}
|
|
40623
|
+
versions.push(`oxlint-plugin-react-doctor#fingerprint=${resolvePluginFingerprint()}`);
|
|
40157
40624
|
return versions;
|
|
40158
40625
|
};
|
|
40159
40626
|
const esmRequire = createRequire(import.meta.url);
|
|
@@ -41629,7 +42096,7 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
41629
42096
|
* 6. always restore disable directives + clean up the temp dir
|
|
41630
42097
|
*/
|
|
41631
42098
|
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;
|
|
42099
|
+
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
42100
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
41634
42101
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
41635
42102
|
validateRuleRegistration();
|
|
@@ -41643,13 +42110,15 @@ const runOxlint = async (options) => {
|
|
|
41643
42110
|
}
|
|
41644
42111
|
const pluginPath = resolvePluginPath();
|
|
41645
42112
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
41646
|
-
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
42113
|
+
const userPlugins = includedTags.size > 0 ? [] : resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
41647
42114
|
const buildConfig = (overrides) => createOxlintConfig({
|
|
41648
42115
|
pluginPath,
|
|
41649
42116
|
project,
|
|
41650
42117
|
customRulesOnly,
|
|
41651
42118
|
extendsPaths: overrides.extendsPaths,
|
|
41652
42119
|
ignoredTags,
|
|
42120
|
+
includedTags,
|
|
42121
|
+
includeTagDefaults,
|
|
41653
42122
|
serverAuthFunctionNames,
|
|
41654
42123
|
severityControls,
|
|
41655
42124
|
userPlugins,
|
|
@@ -42038,6 +42507,8 @@ var Linter = class Linter extends Service()("react-doctor/Linter") {
|
|
|
42038
42507
|
respectInlineDisables: input.respectInlineDisables,
|
|
42039
42508
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42040
42509
|
ignoredTags: input.ignoredTags,
|
|
42510
|
+
includedTags: input.includedTags,
|
|
42511
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
42041
42512
|
userConfig: input.userConfig ?? null,
|
|
42042
42513
|
configSourceDirectory: input.configSourceDirectory,
|
|
42043
42514
|
onPartialFailure: (reason) => {
|
|
@@ -42886,7 +43357,9 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42886
43357
|
const securityScanFailedRef = yield* make$13(false);
|
|
42887
43358
|
const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(tryPromise(() => checkSecurityScanCooperative(scanDirectory, {
|
|
42888
43359
|
project,
|
|
42889
|
-
ignoredTags: input.ignoredTags
|
|
43360
|
+
ignoredTags: input.ignoredTags,
|
|
43361
|
+
includedTags: input.includedTags,
|
|
43362
|
+
includeTagDefaults: input.includeTagDefaults
|
|
42890
43363
|
})).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), catch_$1(() => set(securityScanFailedRef, true).pipe(as(empty$4))))))).pipe(withSpan("SecurityScan.run")));
|
|
42891
43364
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
42892
43365
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
@@ -42977,6 +43450,8 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
42977
43450
|
respectInlineDisables: input.respectInlineDisables,
|
|
42978
43451
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42979
43452
|
ignoredTags: input.ignoredTags,
|
|
43453
|
+
includedTags: input.includedTags,
|
|
43454
|
+
includeTagDefaults: input.includeTagDefaults,
|
|
42980
43455
|
userConfig: resolvedConfig.config ?? void 0,
|
|
42981
43456
|
configSourceDirectory: resolvedConfig.configSourceDirectory ?? void 0,
|
|
42982
43457
|
onFileProgress: (scannedFileCount, totalFileCount) => {
|
|
@@ -43837,4 +44312,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
43837
44312
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
43838
44313
|
|
|
43839
44314
|
//# sourceMappingURL=index.js.map
|
|
43840
|
-
//# debugId=
|
|
44315
|
+
//# debugId=d6dc69de-43c3-570a-8cc4-be7d4a3605ac
|