react-doctor 0.8.1-dev.0b0b5ac → 0.8.1-dev.1839566
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -14
- package/dist/cli.js +100 -446
- package/dist/index.d.ts +0 -27
- package/dist/index.js +56 -355
- package/dist/lsp.js +56 -355
- package/dist/skills/react-doctor/SKILL.md +0 -5
- package/package.json +5 -5
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]="f645a3f8-ff1c-5f09-a174-8281db00eaa4")}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";
|
|
@@ -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
|
-
"@remix-run/react": "remix",
|
|
33379
|
-
gatsby: "gatsby",
|
|
33380
33378
|
vite: "vite",
|
|
33381
33379
|
"react-scripts": "cra",
|
|
33380
|
+
"@remix-run/react": "remix",
|
|
33381
|
+
gatsby: "gatsby",
|
|
33382
33382
|
expo: "expo",
|
|
33383
33383
|
"react-native": "react-native"
|
|
33384
33384
|
};
|
|
@@ -33402,17 +33402,11 @@ const NEXT_CONFIG_FILENAMES = [
|
|
|
33402
33402
|
];
|
|
33403
33403
|
const BABEL_CONFIG_FILENAMES = [
|
|
33404
33404
|
".babelrc",
|
|
33405
|
-
".babelrc.js",
|
|
33406
33405
|
".babelrc.json",
|
|
33407
|
-
".babelrc.cjs",
|
|
33408
|
-
".babelrc.mjs",
|
|
33409
|
-
".babelrc.cts",
|
|
33410
33406
|
"babel.config.js",
|
|
33411
33407
|
"babel.config.json",
|
|
33412
33408
|
"babel.config.cjs",
|
|
33413
|
-
"babel.config.mjs"
|
|
33414
|
-
"babel.config.ts",
|
|
33415
|
-
"babel.config.cts"
|
|
33409
|
+
"babel.config.mjs"
|
|
33416
33410
|
];
|
|
33417
33411
|
const VITE_CONFIG_FILENAMES = [
|
|
33418
33412
|
"vite.config.js",
|
|
@@ -33424,28 +33418,12 @@ const VITE_CONFIG_FILENAMES = [
|
|
|
33424
33418
|
"vitest.config.ts",
|
|
33425
33419
|
"vitest.config.js"
|
|
33426
33420
|
];
|
|
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
|
-
];
|
|
33443
33421
|
const EXPO_APP_CONFIG_FILENAMES = [
|
|
33444
33422
|
"app.json",
|
|
33445
33423
|
"app.config.js",
|
|
33446
33424
|
"app.config.ts"
|
|
33447
33425
|
];
|
|
33448
|
-
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|
|
|
33426
|
+
const REACT_COMPILER_PACKAGE_REFERENCE_PATTERN = /babel-plugin-react-compiler|react-compiler-runtime|["']react-compiler["']/;
|
|
33449
33427
|
const REACT_COMPILER_ENABLED_FLAG_PATTERN = /["']?reactCompiler["']?\s*:\s*(?:true\b|\{)/;
|
|
33450
33428
|
const STATIC_EXPORT_OUTPUT_PATTERN = /(?:^|[^.\w])["']?output["']?\s*:\s*["']export["']/m;
|
|
33451
33429
|
const hasCompilerPackage = (packageJson, compilerPackages) => {
|
|
@@ -33480,8 +33458,6 @@ const detectReactCompiler = (directory, packageJson) => {
|
|
|
33480
33458
|
if (hasCompilerInConfigFiles(directory, NEXT_CONFIG_FILENAMES)) return true;
|
|
33481
33459
|
if (hasCompilerInConfigFiles(directory, BABEL_CONFIG_FILENAMES)) return true;
|
|
33482
33460
|
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;
|
|
33485
33461
|
if (hasCompilerInConfigFiles(directory, EXPO_APP_CONFIG_FILENAMES)) return true;
|
|
33486
33462
|
return hasCompilerPackageInAncestors(directory, REACT_COMPILER_TRANSFORM_PACKAGES);
|
|
33487
33463
|
};
|
|
@@ -33929,6 +33905,19 @@ const getPreactVersion = (packageJson) => {
|
|
|
33929
33905
|
...packageJson.devDependencies
|
|
33930
33906
|
}.preact ?? null;
|
|
33931
33907
|
};
|
|
33908
|
+
const TANSTACK_QUERY_PACKAGES = new Set([
|
|
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
|
+
};
|
|
33932
33921
|
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
33933
33922
|
if (version === null || !isCatalogReference(version)) return version;
|
|
33934
33923
|
const catalogName = extractCatalogName(version);
|
|
@@ -34131,60 +34120,7 @@ const listWorkspacePackages = (rootDirectory) => {
|
|
|
34131
34120
|
}
|
|
34132
34121
|
return packages;
|
|
34133
34122
|
};
|
|
34134
|
-
const getPreferredDependencyVersion = ({ packageJson, packageNames }) => {
|
|
34135
|
-
const allDependencies = {
|
|
34136
|
-
...packageJson.devDependencies,
|
|
34137
|
-
...packageJson.peerDependencies,
|
|
34138
|
-
...packageJson.dependencies
|
|
34139
|
-
};
|
|
34140
|
-
for (const packageName of packageNames) {
|
|
34141
|
-
const version = allDependencies[packageName];
|
|
34142
|
-
if (version !== void 0) return version;
|
|
34143
|
-
}
|
|
34144
|
-
return null;
|
|
34145
|
-
};
|
|
34146
|
-
const TANSTACK_REACT_QUERY_PACKAGES = ["@tanstack/react-query", "react-query"];
|
|
34147
|
-
const getTanStackQueryVersion = (packageJson) => {
|
|
34148
|
-
return getPreferredDependencyVersion({
|
|
34149
|
-
packageJson,
|
|
34150
|
-
packageNames: TANSTACK_REACT_QUERY_PACKAGES
|
|
34151
|
-
});
|
|
34152
|
-
};
|
|
34153
|
-
const STYLED_COMPONENTS_PACKAGES = ["styled-components"];
|
|
34154
|
-
const getStyledComponentsVersion = (packageJson) => {
|
|
34155
|
-
return getPreferredDependencyVersion({
|
|
34156
|
-
packageJson,
|
|
34157
|
-
packageNames: STYLED_COMPONENTS_PACKAGES
|
|
34158
|
-
});
|
|
34159
|
-
};
|
|
34160
|
-
const I18N_PACKAGES = [
|
|
34161
|
-
"i18next",
|
|
34162
|
-
"react-i18next",
|
|
34163
|
-
"next-i18next",
|
|
34164
|
-
"react-intl",
|
|
34165
|
-
"next-intl",
|
|
34166
|
-
"use-intl",
|
|
34167
|
-
"@formatjs/intl",
|
|
34168
|
-
"@lingui/core",
|
|
34169
|
-
"@lingui/react",
|
|
34170
|
-
"typesafe-i18n",
|
|
34171
|
-
"@tolgee/react",
|
|
34172
|
-
"react-intl-universal"
|
|
34173
|
-
];
|
|
34174
|
-
const hasI18nDependency = (packageJson) => {
|
|
34175
|
-
const allDependencies = {
|
|
34176
|
-
...packageJson.peerDependencies,
|
|
34177
|
-
...packageJson.dependencies,
|
|
34178
|
-
...packageJson.devDependencies,
|
|
34179
|
-
...packageJson.optionalDependencies
|
|
34180
|
-
};
|
|
34181
|
-
return I18N_PACKAGES.some((packageName) => allDependencies[packageName] !== void 0);
|
|
34182
|
-
};
|
|
34183
34123
|
const REANIMATED_DEPENDENCY_NAME = "react-native-reanimated";
|
|
34184
|
-
const MOBX_REACT_PACKAGE_NAME = "mobx-react";
|
|
34185
|
-
const MOBX_REACT_LITE_PACKAGE_NAME = "mobx-react-lite";
|
|
34186
|
-
const MOBX_STATE_TREE_PACKAGE_NAME = "mobx-state-tree";
|
|
34187
|
-
const MOBX_REACT_OBSERVER_PACKAGE_NAME = "mobx-react-observer";
|
|
34188
34124
|
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
34189
34125
|
const resolveWorkspaceDependencyVersion = ({ concreteVersion, packageName, rootDirectory, rootPackageJson, sections, workspaceDirectory, workspacePackageJson }) => {
|
|
34190
34126
|
const dependencyDeclaration = getDependencyDeclaration({
|
|
@@ -34203,26 +34139,7 @@ const shouldReplaceReactVersion = (currentVersion, nextVersion) => {
|
|
|
34203
34139
|
if (nextMajor === null) return false;
|
|
34204
34140
|
return nextMajor < currentMajor;
|
|
34205
34141
|
};
|
|
34206
|
-
const
|
|
34207
|
-
if (currentFact.version === null) return true;
|
|
34208
|
-
if (nextFact.version === null) return false;
|
|
34209
|
-
const currentMajor = getLowestDependencyMajor(currentFact.version);
|
|
34210
|
-
const nextMajor = getLowestDependencyMajor(nextFact.version);
|
|
34211
|
-
if (currentMajor === null) return false;
|
|
34212
|
-
if (nextMajor === null) return true;
|
|
34213
|
-
if (currentMajor > latestSupportedMajor) return false;
|
|
34214
|
-
if (nextMajor > latestSupportedMajor) return true;
|
|
34215
|
-
return nextMajor < currentMajor;
|
|
34216
|
-
};
|
|
34217
|
-
const shouldReplaceStyledComponentsVersion = (currentVersion, nextVersion) => {
|
|
34218
|
-
if (!currentVersion) return true;
|
|
34219
|
-
const currentMajor = getLowestDependencyMajor(currentVersion);
|
|
34220
|
-
const nextMajor = getLowestDependencyMajor(nextVersion);
|
|
34221
|
-
if (currentMajor === null) return nextMajor !== null && nextMajor < 6;
|
|
34222
|
-
if (nextMajor === null) return currentMajor >= 6;
|
|
34223
|
-
return nextMajor < currentMajor;
|
|
34224
|
-
};
|
|
34225
|
-
const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, rootPackageJson) => {
|
|
34142
|
+
const evaluateManifestFacts = (facts, packageJson, directory) => {
|
|
34226
34143
|
if (facts.expo.version === null) {
|
|
34227
34144
|
const spec = getDependencySpec(packageJson, "expo");
|
|
34228
34145
|
if (spec !== null) facts.expo = {
|
|
@@ -34244,74 +34161,13 @@ const evaluateManifestFacts = (facts, packageJson, directory, rootDirectory, roo
|
|
|
34244
34161
|
sourceDirectory: directory
|
|
34245
34162
|
};
|
|
34246
34163
|
}
|
|
34247
|
-
const mobxSpec = getDependencySpec(packageJson, "mobx");
|
|
34248
|
-
if (mobxSpec !== null) {
|
|
34249
|
-
const nextMobxFact = {
|
|
34250
|
-
version: resolveCatalogBackedDependencyVersion({
|
|
34251
|
-
rootDirectory: directory,
|
|
34252
|
-
rootPackageJson: packageJson,
|
|
34253
|
-
packageName: "mobx",
|
|
34254
|
-
version: mobxSpec
|
|
34255
|
-
}),
|
|
34256
|
-
sourceDirectory: directory
|
|
34257
|
-
};
|
|
34258
|
-
if (shouldReplaceSupportedDependencyFact(facts.mobx, nextMobxFact, 6)) facts.mobx = nextMobxFact;
|
|
34259
|
-
}
|
|
34260
|
-
facts.hasMobxReact = facts.hasMobxReact || getDependencySpec(packageJson, MOBX_REACT_PACKAGE_NAME) !== null;
|
|
34261
|
-
facts.hasMobxReactLite = facts.hasMobxReactLite || getDependencySpec(packageJson, MOBX_REACT_LITE_PACKAGE_NAME) !== null;
|
|
34262
|
-
facts.hasMobxStateTree = facts.hasMobxStateTree || getDependencySpec(packageJson, MOBX_STATE_TREE_PACKAGE_NAME) !== null;
|
|
34263
|
-
facts.hasMobxReactObserver = facts.hasMobxReactObserver || getDependencySpec(packageJson, MOBX_REACT_OBSERVER_PACKAGE_NAME) !== null;
|
|
34264
|
-
const zustandSpec = getDependencySpec(packageJson, "zustand");
|
|
34265
|
-
if (zustandSpec !== null) {
|
|
34266
|
-
const nextZustandFact = {
|
|
34267
|
-
version: resolveCatalogBackedDependencyVersion({
|
|
34268
|
-
rootDirectory: directory,
|
|
34269
|
-
rootPackageJson: packageJson,
|
|
34270
|
-
packageName: "zustand",
|
|
34271
|
-
version: zustandSpec
|
|
34272
|
-
}),
|
|
34273
|
-
sourceDirectory: directory
|
|
34274
|
-
};
|
|
34275
|
-
if (shouldReplaceSupportedDependencyFact(facts.zustand, nextZustandFact, 5)) facts.zustand = nextZustandFact;
|
|
34276
|
-
}
|
|
34277
34164
|
if (facts.reanimatedVersion === null) {
|
|
34278
34165
|
const spec = getDependencySpec(packageJson, REANIMATED_DEPENDENCY_NAME);
|
|
34279
34166
|
if (spec !== null) facts.reanimatedVersion = spec;
|
|
34280
34167
|
}
|
|
34281
|
-
if (facts.valtioVersion === null) {
|
|
34282
|
-
const spec = getDependencySpec(packageJson, "valtio");
|
|
34283
|
-
if (spec !== null) facts.valtioVersion = spec;
|
|
34284
|
-
}
|
|
34285
|
-
facts.tanstackQueryVersion ??= getTanStackQueryVersion(packageJson);
|
|
34286
|
-
const styledComponentsVersion = resolveCatalogBackedDependencyVersion({
|
|
34287
|
-
rootDirectory: directory,
|
|
34288
|
-
rootPackageJson: packageJson,
|
|
34289
|
-
packageName: "styled-components",
|
|
34290
|
-
version: getStyledComponentsVersion(packageJson)
|
|
34291
|
-
});
|
|
34292
|
-
if (styledComponentsVersion && shouldReplaceStyledComponentsVersion(facts.styledComponentsVersion, styledComponentsVersion)) facts.styledComponentsVersion = styledComponentsVersion;
|
|
34293
|
-
facts.hasI18nLibrary = facts.hasI18nLibrary || hasI18nDependency(packageJson);
|
|
34294
34168
|
facts.hasReactNativeAwarePackage = facts.hasReactNativeAwarePackage || isPackageJsonReactNativeAware(packageJson);
|
|
34295
34169
|
facts.hasReanimatedAwarePackage = facts.hasReanimatedAwarePackage || isPackageJsonReanimatedAware(packageJson);
|
|
34296
34170
|
facts.hasSsrDependency = facts.hasSsrDependency || isPackageJsonSsrAware(packageJson);
|
|
34297
|
-
const remotionSpec = getDependencySpec(packageJson, "remotion");
|
|
34298
|
-
if (remotionSpec !== null) {
|
|
34299
|
-
facts.hasRemotionDependency = true;
|
|
34300
|
-
const resolvedRemotionVersion = resolveCatalogBackedDependencyVersion({
|
|
34301
|
-
rootDirectory,
|
|
34302
|
-
rootPackageJson,
|
|
34303
|
-
packageName: "remotion",
|
|
34304
|
-
version: remotionSpec
|
|
34305
|
-
});
|
|
34306
|
-
const remotionMajorVersion = resolvedRemotionVersion === null ? null : getLowestDependencyMajor(resolvedRemotionVersion);
|
|
34307
|
-
if (remotionMajorVersion === null) {
|
|
34308
|
-
facts.hasUnknownRemotionVersion = true;
|
|
34309
|
-
facts.remotionVersion = null;
|
|
34310
|
-
} else if (!facts.hasUnknownRemotionVersion) {
|
|
34311
|
-
const currentRemotionMajorVersion = facts.remotionVersion === null ? null : getLowestDependencyMajor(facts.remotionVersion);
|
|
34312
|
-
if (currentRemotionMajorVersion === null || remotionMajorVersion < currentRemotionMajorVersion) facts.remotionVersion = resolvedRemotionVersion;
|
|
34313
|
-
}
|
|
34314
|
-
}
|
|
34315
34171
|
};
|
|
34316
34172
|
const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGroup }) => {
|
|
34317
34173
|
const facts = {
|
|
@@ -34331,31 +34187,12 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34331
34187
|
version: null,
|
|
34332
34188
|
sourceDirectory: null
|
|
34333
34189
|
},
|
|
34334
|
-
valtioVersion: null,
|
|
34335
|
-
mobx: {
|
|
34336
|
-
version: null,
|
|
34337
|
-
sourceDirectory: null
|
|
34338
|
-
},
|
|
34339
|
-
hasMobxReact: false,
|
|
34340
|
-
hasMobxReactLite: false,
|
|
34341
|
-
hasMobxStateTree: false,
|
|
34342
|
-
hasMobxReactObserver: false,
|
|
34343
|
-
zustand: {
|
|
34344
|
-
version: null,
|
|
34345
|
-
sourceDirectory: null
|
|
34346
|
-
},
|
|
34347
|
-
tanstackQueryVersion: null,
|
|
34348
|
-
styledComponentsVersion: null,
|
|
34349
|
-
hasI18nLibrary: false,
|
|
34350
34190
|
hasReactNativeAwarePackage: false,
|
|
34351
34191
|
hasReanimatedAwarePackage: false,
|
|
34352
34192
|
hasSsrDependency: false,
|
|
34353
|
-
hasRemotionDependency: false,
|
|
34354
|
-
hasUnknownRemotionVersion: false,
|
|
34355
|
-
remotionVersion: null,
|
|
34356
34193
|
reanimatedVersion: null
|
|
34357
34194
|
};
|
|
34358
|
-
evaluateManifestFacts(facts, rootPackageJson, rootDirectory
|
|
34195
|
+
evaluateManifestFacts(facts, rootPackageJson, rootDirectory);
|
|
34359
34196
|
let isReactGroupSettled = !collectReactGroup;
|
|
34360
34197
|
const visitedDirectories = /* @__PURE__ */ new Set();
|
|
34361
34198
|
for (const pattern of getWorkspacePatterns(rootDirectory, rootPackageJson)) {
|
|
@@ -34364,7 +34201,7 @@ const collectWorkspaceFacts = (rootDirectory, rootPackageJson, { collectReactGro
|
|
|
34364
34201
|
if (visitedDirectories.has(workspaceDirectory)) continue;
|
|
34365
34202
|
visitedDirectories.add(workspaceDirectory);
|
|
34366
34203
|
const workspacePackageJson = readPackageJson(Path.join(workspaceDirectory, "package.json"));
|
|
34367
|
-
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory
|
|
34204
|
+
evaluateManifestFacts(facts, workspacePackageJson, workspaceDirectory);
|
|
34368
34205
|
const info = extractDependencyInfo(workspacePackageJson);
|
|
34369
34206
|
if (info.framework !== "unknown" && frameworkMergeRank(info.framework) < frameworkMergeRank(facts.framework)) facts.framework = info.framework;
|
|
34370
34207
|
if (isReactGroupSettled) continue;
|
|
@@ -34588,27 +34425,11 @@ const discoverProjectWithoutPackageJson = (directory) => {
|
|
|
34588
34425
|
tailwindVersion: null,
|
|
34589
34426
|
zodVersion: null,
|
|
34590
34427
|
zodMajorVersion: null,
|
|
34591
|
-
mobxVersion: null,
|
|
34592
|
-
mobxMajorVersion: null,
|
|
34593
|
-
hasMobxReact: false,
|
|
34594
|
-
hasMobxReactLite: false,
|
|
34595
|
-
hasMobxStateTree: false,
|
|
34596
|
-
hasMobxReactObserver: false,
|
|
34597
|
-
zustandVersion: null,
|
|
34598
|
-
zustandMajorVersion: null,
|
|
34599
34428
|
framework: "unknown",
|
|
34600
34429
|
hasTypeScript: hasOwnTsConfig,
|
|
34601
34430
|
hasReactCompiler: false,
|
|
34602
34431
|
hasReactCompilerLintPlugin: false,
|
|
34603
34432
|
hasTanStackQuery: false,
|
|
34604
|
-
valtioVersion: null,
|
|
34605
|
-
valtioMajorVersion: null,
|
|
34606
|
-
hasRemotion: false,
|
|
34607
|
-
remotionVersion: null,
|
|
34608
|
-
remotionMajorVersion: null,
|
|
34609
|
-
hasI18nLibrary: false,
|
|
34610
|
-
tanstackQueryVersion: null,
|
|
34611
|
-
styledComponentsVersion: null,
|
|
34612
34433
|
hasSsrDependency: false,
|
|
34613
34434
|
preactVersion: null,
|
|
34614
34435
|
preactMajorVersion: null,
|
|
@@ -34707,12 +34528,6 @@ const discoverProject = (directory) => {
|
|
|
34707
34528
|
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
34708
34529
|
version: workspaceFacts.shopifyFlashList.version
|
|
34709
34530
|
}) : null;
|
|
34710
|
-
const zustandVersion = resolveCatalogBackedDependencyVersion({
|
|
34711
|
-
rootDirectory: directory,
|
|
34712
|
-
rootPackageJson: packageJson,
|
|
34713
|
-
packageName: "zustand",
|
|
34714
|
-
version: workspaceFacts.zustand.version
|
|
34715
|
-
});
|
|
34716
34531
|
const hasReanimated = hasReactNativeWorkspace && workspaceFacts.hasReanimatedAwarePackage;
|
|
34717
34532
|
const reanimatedVersion = hasReanimated ? workspaceFacts.reanimatedVersion : null;
|
|
34718
34533
|
const nextjsVersion = framework === "nextjs" ? resolveCatalogBackedDependencyVersion({
|
|
@@ -34721,21 +34536,7 @@ const discoverProject = (directory) => {
|
|
|
34721
34536
|
packageName: "next",
|
|
34722
34537
|
version: workspaceFacts.next.version
|
|
34723
34538
|
}) : null;
|
|
34724
|
-
const valtioVersion = resolveCatalogBackedDependencyVersion({
|
|
34725
|
-
rootDirectory: directory,
|
|
34726
|
-
rootPackageJson: packageJson,
|
|
34727
|
-
packageName: "valtio",
|
|
34728
|
-
version: workspaceFacts.valtioVersion
|
|
34729
|
-
});
|
|
34730
|
-
const mobxVersion = resolveCatalogBackedDependencyVersion({
|
|
34731
|
-
rootDirectory: directory,
|
|
34732
|
-
rootPackageJson: packageJson,
|
|
34733
|
-
packageName: "mobx",
|
|
34734
|
-
version: workspaceFacts.mobx.version
|
|
34735
|
-
});
|
|
34736
34539
|
const preactVersion = getPreactVersion(packageJson);
|
|
34737
|
-
const remotionVersion = workspaceFacts.remotionVersion;
|
|
34738
|
-
const tanstackQueryVersion = getTanStackQueryVersion(packageJson) ?? workspaceFacts.tanstackQueryVersion;
|
|
34739
34540
|
const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
|
|
34740
34541
|
const projectInfo = {
|
|
34741
34542
|
rootDirectory: directory,
|
|
@@ -34745,27 +34546,11 @@ const discoverProject = (directory) => {
|
|
|
34745
34546
|
tailwindVersion,
|
|
34746
34547
|
zodVersion,
|
|
34747
34548
|
zodMajorVersion: zodVersion === null ? null : getLowestDependencyMajor(zodVersion),
|
|
34748
|
-
mobxVersion,
|
|
34749
|
-
mobxMajorVersion: mobxVersion === null ? null : getLowestDependencyMajor(mobxVersion),
|
|
34750
|
-
hasMobxReact: workspaceFacts.hasMobxReact,
|
|
34751
|
-
hasMobxReactLite: workspaceFacts.hasMobxReactLite,
|
|
34752
|
-
hasMobxStateTree: workspaceFacts.hasMobxStateTree,
|
|
34753
|
-
hasMobxReactObserver: workspaceFacts.hasMobxReactObserver,
|
|
34754
|
-
zustandVersion,
|
|
34755
|
-
zustandMajorVersion: zustandVersion === null ? null : getLowestDependencyMajor(zustandVersion),
|
|
34756
34549
|
framework,
|
|
34757
34550
|
hasTypeScript,
|
|
34758
34551
|
hasReactCompiler: detectReactCompiler(directory, packageJson),
|
|
34759
34552
|
hasReactCompilerLintPlugin: detectReactCompilerLintPlugin(directory, packageJson),
|
|
34760
|
-
hasTanStackQuery:
|
|
34761
|
-
hasI18nLibrary: workspaceFacts.hasI18nLibrary,
|
|
34762
|
-
tanstackQueryVersion,
|
|
34763
|
-
styledComponentsVersion: workspaceFacts.styledComponentsVersion,
|
|
34764
|
-
valtioVersion,
|
|
34765
|
-
valtioMajorVersion: valtioVersion === null ? null : getLowestDependencyMajor(valtioVersion),
|
|
34766
|
-
hasRemotion: workspaceFacts.hasRemotionDependency,
|
|
34767
|
-
remotionVersion,
|
|
34768
|
-
remotionMajorVersion: remotionVersion === null ? null : getLowestDependencyMajor(remotionVersion),
|
|
34553
|
+
hasTanStackQuery: hasTanStackQuery(packageJson),
|
|
34769
34554
|
hasSsrDependency: workspaceFacts.hasSsrDependency,
|
|
34770
34555
|
preactVersion,
|
|
34771
34556
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
@@ -34999,6 +34784,7 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
34999
34784
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
35000
34785
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
35001
34786
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
34787
|
+
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
35002
34788
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
35003
34789
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
35004
34790
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -37285,25 +37071,9 @@ const BABEL_CONFIG_FILE_NAMES = [
|
|
|
37285
37071
|
".babelrc.json"
|
|
37286
37072
|
];
|
|
37287
37073
|
const LEGACY_PRESET_SPEC = "module:metro-react-native-babel-preset";
|
|
37288
|
-
const LEGACY_PRESET_PACKAGE = "metro-react-native-babel-preset";
|
|
37289
|
-
const REACT_NATIVE_PACKAGE = "react-native";
|
|
37290
|
-
const PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION = "0.73.0";
|
|
37291
|
-
const LEGACY_PRESET_REFERENCE = new RegExp(`['"]${LEGACY_PRESET_SPEC}['"]`);
|
|
37292
37074
|
const MODERN_PRESET_REFERENCE = new RegExp(`['"]module:@react-native/babel-preset['"]`);
|
|
37293
37075
|
const ENABLE_BABEL_RUNTIME_VERSION = /enableBabelRuntime["']?\s*:\s*['"]/;
|
|
37294
|
-
const isReactNativeVersionAtLeastPresetRename = (rootDirectory, packageJson) => {
|
|
37295
|
-
const installedReactNativeManifestPath = Path.join(rootDirectory, "node_modules", REACT_NATIVE_PACKAGE, "package.json");
|
|
37296
|
-
const reactNativeVersionSpec = (isFile(installedReactNativeManifestPath) ? readPackageJson(installedReactNativeManifestPath).version : void 0) ?? getDependencySpec(packageJson, REACT_NATIVE_PACKAGE);
|
|
37297
|
-
if (reactNativeVersionSpec === null || reactNativeVersionSpec === void 0) return false;
|
|
37298
|
-
const normalizedVersionRange = import_semver.validRange(reactNativeVersionSpec);
|
|
37299
|
-
if (normalizedVersionRange === null) return false;
|
|
37300
|
-
const minimumVersion = import_semver.minVersion(normalizedVersionRange);
|
|
37301
|
-
return minimumVersion !== null && import_semver.gte(minimumVersion, PRESET_RENAME_MINIMUM_REACT_NATIVE_VERSION);
|
|
37302
|
-
};
|
|
37303
|
-
const canResolveLegacyPreset = (rootDirectory, packageJson) => getDependencySpec(packageJson, LEGACY_PRESET_PACKAGE) !== null || isFile(Path.join(rootDirectory, "node_modules", LEGACY_PRESET_PACKAGE, "package.json"));
|
|
37304
37076
|
const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
37305
|
-
const packageJson = readPackageJson(Path.join(rootDirectory, "package.json"));
|
|
37306
|
-
const shouldReportLegacyPreset = isReactNativeVersionAtLeastPresetRename(rootDirectory, packageJson) && !canResolveLegacyPreset(rootDirectory, packageJson);
|
|
37307
37077
|
for (const fileName of BABEL_CONFIG_FILE_NAMES) {
|
|
37308
37078
|
const filePath = Path.join(rootDirectory, fileName);
|
|
37309
37079
|
if (!isFile(filePath)) continue;
|
|
@@ -37313,7 +37083,7 @@ const checkReactNativeMetroBabelPreset = (rootDirectory) => {
|
|
|
37313
37083
|
} catch {
|
|
37314
37084
|
continue;
|
|
37315
37085
|
}
|
|
37316
|
-
if (
|
|
37086
|
+
if (contents.includes(LEGACY_PRESET_SPEC)) return [buildReactNativeDiagnostic({
|
|
37317
37087
|
filePath: fileName,
|
|
37318
37088
|
rule: "rn-no-metro-babel-preset",
|
|
37319
37089
|
severity: "error",
|
|
@@ -37336,6 +37106,12 @@ const checkReactNativeProject = (rootDirectory, project) => {
|
|
|
37336
37106
|
return [...checkReactNativeMetroBabelPreset(rootDirectory), ...checkReactNativeLibraryDependencies(rootDirectory)];
|
|
37337
37107
|
};
|
|
37338
37108
|
const RULE_KEY = "no-vulnerable-react-server-components";
|
|
37109
|
+
const DEPENDENCY_SECTIONS = [
|
|
37110
|
+
"dependencies",
|
|
37111
|
+
"devDependencies",
|
|
37112
|
+
"peerDependencies",
|
|
37113
|
+
"optionalDependencies"
|
|
37114
|
+
];
|
|
37339
37115
|
const REACT_RSC_ADVISORIES_BY_MINOR = {
|
|
37340
37116
|
"19.0": {
|
|
37341
37117
|
rceFixedVersion: "19.0.1",
|
|
@@ -37382,13 +37158,20 @@ const enumerateWorkspaceDirectories = (workspaceRoot) => {
|
|
|
37382
37158
|
for (const pattern of patterns) for (const directory of resolveWorkspaceDirectories(workspaceRoot, pattern)) directories.add(directory);
|
|
37383
37159
|
return [...directories];
|
|
37384
37160
|
};
|
|
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
|
+
};
|
|
37385
37168
|
const resolveVersionInDirectory = (directory, packageName, declaredSpecOverride) => {
|
|
37386
37169
|
const manifestPath = Path.join(directory, "node_modules", packageName, "package.json");
|
|
37387
37170
|
if (isFile(manifestPath)) {
|
|
37388
37171
|
const installedVersion = import_semver.valid(readPackageJson(manifestPath).version ?? null);
|
|
37389
37172
|
if (installedVersion !== null) return installedVersion;
|
|
37390
37173
|
}
|
|
37391
|
-
const candidateSpecs = [
|
|
37174
|
+
const candidateSpecs = [readDeclaredSpec(readPackageJson(Path.join(directory, "package.json")), packageName), declaredSpecOverride];
|
|
37392
37175
|
for (const spec of candidateSpecs) {
|
|
37393
37176
|
const pinnedVersion = spec === null ? null : import_semver.valid(spec);
|
|
37394
37177
|
if (pinnedVersion !== null) return pinnedVersion;
|
|
@@ -38056,50 +37839,21 @@ const buildCapabilities = (project) => {
|
|
|
38056
37839
|
if (CLIENT_ONLY_FRAMEWORKS.has(project.framework)) capabilities.add("client-only");
|
|
38057
37840
|
if (project.isStaticExport) capabilities.add("nextjs:static-export");
|
|
38058
37841
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
38059
|
-
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 16) capabilities.add("nextjs:16");
|
|
38060
37842
|
addMajorLadder(capabilities, "react", project.reactMajorVersion, 17, 30);
|
|
38061
37843
|
if (project.reactMajorVersion !== null && project.reactMajorVersion >= 19 && isMajorMinorAtLeast(parseReactMajorMinor(project.reactVersion), {
|
|
38062
37844
|
major: 19,
|
|
38063
37845
|
minor: 2
|
|
38064
37846
|
})) capabilities.add("react:19.2");
|
|
38065
|
-
if (project.tailwindVersion !== null)
|
|
38066
|
-
|
|
38067
|
-
|
|
38068
|
-
|
|
38069
|
-
|
|
38070
|
-
minor: 4
|
|
38071
|
-
})) capabilities.add("tailwind:3.4");
|
|
38072
|
-
if (tailwindVersion !== null && isMajorMinorAtLeast(tailwindVersion, {
|
|
38073
|
-
major: 4,
|
|
38074
|
-
minor: 0
|
|
38075
|
-
})) capabilities.add("tailwind:4");
|
|
38076
|
-
}
|
|
37847
|
+
if (project.tailwindVersion !== null) capabilities.add("tailwind");
|
|
37848
|
+
if (project.tailwindVersion !== null && isMajorMinorAtLeast(parseTailwindMajorMinor(project.tailwindVersion), {
|
|
37849
|
+
major: 3,
|
|
37850
|
+
minor: 4
|
|
37851
|
+
})) capabilities.add("tailwind:3.4");
|
|
38077
37852
|
if (project.zodVersion !== null) capabilities.add("zod");
|
|
38078
37853
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
38079
|
-
if (project.mobxVersion !== void 0 && project.mobxVersion !== null || project.hasMobxReact === true || project.hasMobxReactLite === true || project.hasMobxStateTree === true || project.hasMobxReactObserver === true) capabilities.add("mobx");
|
|
38080
|
-
if (project.hasMobxReact === true) capabilities.add("mobx-react");
|
|
38081
|
-
if (project.hasMobxReactLite === true) capabilities.add("mobx-react-lite");
|
|
38082
|
-
if (project.hasMobxReact === true || project.hasMobxReactLite === true) capabilities.add("mobx-react-binding");
|
|
38083
|
-
if (project.hasMobxStateTree === true) capabilities.add("mobx-state-tree");
|
|
38084
|
-
if (project.hasMobxReactObserver === true) capabilities.add("mobx-react-observer");
|
|
38085
|
-
if (project.mobxMajorVersion !== void 0 && project.mobxMajorVersion !== null && project.mobxMajorVersion >= 4 && project.mobxMajorVersion <= 6) addMajorLadder(capabilities, "mobx", project.mobxMajorVersion, 4, 6);
|
|
38086
|
-
if (project.zustandVersion !== void 0 && project.zustandVersion !== null) capabilities.add("zustand");
|
|
38087
|
-
if (project.zustandMajorVersion !== void 0 && project.zustandMajorVersion !== null && project.zustandMajorVersion >= 1 && project.zustandMajorVersion <= 5) addMajorLadder(capabilities, "zustand", project.zustandMajorVersion, 1, 5);
|
|
38088
37854
|
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
38089
37855
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
38090
|
-
if (
|
|
38091
|
-
if (project.styledComponentsVersion) {
|
|
38092
|
-
capabilities.add("styled-components");
|
|
38093
|
-
const styledComponentsMajor = getLowestDependencyMajor(project.styledComponentsVersion);
|
|
38094
|
-
if (styledComponentsMajor !== null && styledComponentsMajor >= 6) capabilities.add("styled-components:6");
|
|
38095
|
-
}
|
|
38096
|
-
if (project.hasI18nLibrary) capabilities.add("i18n");
|
|
38097
|
-
if (project.valtioVersion !== null) capabilities.add("valtio");
|
|
38098
|
-
addMajorLadder(capabilities, "valtio", project.valtioMajorVersion, 1, 10);
|
|
38099
|
-
if (project.hasRemotion) {
|
|
38100
|
-
capabilities.add("remotion");
|
|
38101
|
-
addMajorLadder(capabilities, "remotion", project.remotionMajorVersion ?? null, 4, 30);
|
|
38102
|
-
}
|
|
37856
|
+
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
38103
37857
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
38104
37858
|
if (project.preactVersion !== null) capabilities.add("preact");
|
|
38105
37859
|
addMajorLadder(capabilities, "preact", project.preactMajorVersion, 10, 20);
|
|
@@ -38114,7 +37868,7 @@ const getCapabilities = (project) => {
|
|
|
38114
37868
|
capabilitiesByProject.set(project, capabilities);
|
|
38115
37869
|
return capabilities;
|
|
38116
37870
|
};
|
|
38117
|
-
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen
|
|
37871
|
+
const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhen) => {
|
|
38118
37872
|
if (requires) {
|
|
38119
37873
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
38120
37874
|
}
|
|
@@ -38125,29 +37879,20 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledWhe
|
|
|
38125
37879
|
if (tags) {
|
|
38126
37880
|
for (const tag of tags) if (ignoredTags.has(tag)) return false;
|
|
38127
37881
|
}
|
|
38128
|
-
if (includedTags && includedTags.size > 0) {
|
|
38129
|
-
if (!tags?.some((tag) => includedTags.has(tag))) return false;
|
|
38130
|
-
}
|
|
38131
37882
|
return true;
|
|
38132
37883
|
};
|
|
38133
|
-
const shouldEnableRuleByDefaultStatus = (options) => options.defaultEnabled !== false || options.hasExplicitOverride === true || options.includeTagDefaults && options.hasIncludedTags;
|
|
38134
37884
|
const yieldToEventLoop = () => new Promise((resolve) => {
|
|
38135
37885
|
setImmediate(resolve);
|
|
38136
37886
|
});
|
|
38137
37887
|
const createSecurityScanSession = (rootDirectory, options) => {
|
|
38138
37888
|
const capabilities = options.project ? getCapabilities(options.project) : /* @__PURE__ */ new Set();
|
|
38139
37889
|
const ignoredTags = options.ignoredTags ?? /* @__PURE__ */ new Set();
|
|
38140
|
-
const includedTags = options.includedTags ?? /* @__PURE__ */ new Set();
|
|
38141
37890
|
const enabledScanRules = REACT_DOCTOR_RULES.flatMap((entry) => {
|
|
38142
37891
|
const rule = entry.rule;
|
|
38143
37892
|
const scan = rule.scan;
|
|
38144
37893
|
if (typeof scan !== "function") return [];
|
|
38145
|
-
if (
|
|
38146
|
-
|
|
38147
|
-
includeTagDefaults: options.includeTagDefaults === true,
|
|
38148
|
-
hasIncludedTags: includedTags.size > 0
|
|
38149
|
-
})) return [];
|
|
38150
|
-
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen, includedTags)) return [];
|
|
37894
|
+
if (rule.defaultEnabled === false) return [];
|
|
37895
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen)) return [];
|
|
38151
37896
|
return [{
|
|
38152
37897
|
entry,
|
|
38153
37898
|
scan,
|
|
@@ -40133,9 +39878,8 @@ const buildUserPluginRules = (userPlugin, severityControls) => {
|
|
|
40133
39878
|
}
|
|
40134
39879
|
return enabled;
|
|
40135
39880
|
};
|
|
40136
|
-
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(),
|
|
40137
|
-
const
|
|
40138
|
-
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" || hasIncludedTags ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
39881
|
+
const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, extendsPaths = [], ignoredTags = /* @__PURE__ */ new Set(), serverAuthFunctionNames, severityControls, userPlugins = [], disableReactHooksJsPlugin = false, ruleSelection, sidecarRuleIdFilter }) => {
|
|
39882
|
+
const reactHooksJsPlugin = disableReactHooksJsPlugin || ruleSelection === "sidecar" ? null : resolveReactHooksJsPlugin(project.hasReactCompiler || project.hasReactCompilerLintPlugin === true, customRulesOnly);
|
|
40139
39883
|
const reactCompilerRules = reactHooksJsPlugin ? applyRuleSeverityControls(filterRulesToAvailable(REACT_COMPILER_RULES, "react-hooks-js", reactHooksJsPlugin.availableRuleNames), severityControls) : {};
|
|
40140
39884
|
const jsPlugins = [];
|
|
40141
39885
|
if (reactHooksJsPlugin) jsPlugins.push(reactHooksJsPlugin.entry);
|
|
@@ -40150,14 +39894,9 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
40150
39894
|
if (rule.scan !== void 0) continue;
|
|
40151
39895
|
if (customRulesOnly && registryEntry.originallyExternal) continue;
|
|
40152
39896
|
if (rule.framework !== "global" && !rule.requires) continue;
|
|
40153
|
-
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen
|
|
39897
|
+
if (!shouldEnableRule(rule.requires, rule.tags, capabilities, ignoredTags, rule.disabledWhen)) continue;
|
|
40154
39898
|
const explicitRuleOverride = resolveRuleSeverityOverride({ ruleKey: registryEntry.key }, severityControls);
|
|
40155
|
-
if (
|
|
40156
|
-
defaultEnabled: rule.defaultEnabled,
|
|
40157
|
-
includeTagDefaults,
|
|
40158
|
-
hasIncludedTags,
|
|
40159
|
-
hasExplicitOverride: explicitRuleOverride !== void 0
|
|
40160
|
-
})) continue;
|
|
39899
|
+
if (rule.defaultEnabled === false && explicitRuleOverride === void 0) continue;
|
|
40161
39900
|
const severity = resolveRuleSeverityOverride({
|
|
40162
39901
|
ruleKey: registryEntry.key,
|
|
40163
39902
|
category: rule.category
|
|
@@ -40166,7 +39905,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
40166
39905
|
enabledReactDoctorRules[registryEntry.key] = severity;
|
|
40167
39906
|
}
|
|
40168
39907
|
const userPluginRules = {};
|
|
40169
|
-
if (ruleSelection !== "sidecar"
|
|
39908
|
+
if (ruleSelection !== "sidecar") for (const userPlugin of userPlugins) {
|
|
40170
39909
|
Object.assign(userPluginRules, buildUserPluginRules(userPlugin, severityControls));
|
|
40171
39910
|
jsPlugins.push(userPlugin.entry);
|
|
40172
39911
|
}
|
|
@@ -40383,19 +40122,6 @@ const createSidecarLintCache = (cacheDirectory, rulesetHash) => {
|
|
|
40383
40122
|
}
|
|
40384
40123
|
};
|
|
40385
40124
|
};
|
|
40386
|
-
const fingerprintCacheByFilePath = /* @__PURE__ */ new Map();
|
|
40387
|
-
const fingerprintFileContents = (filePath, fingerprintLength) => {
|
|
40388
|
-
const fileStats = NFS.statSync(filePath, { bigint: true });
|
|
40389
|
-
const cachedFingerprint = fingerprintCacheByFilePath.get(filePath);
|
|
40390
|
-
if (cachedFingerprint?.modifiedTimeNanoseconds === fileStats.mtimeNs && cachedFingerprint.sizeBytes === fileStats.size) return cachedFingerprint.fingerprint;
|
|
40391
|
-
const fingerprint = crypto.createHash("sha256").update(NFS.readFileSync(filePath)).digest("hex").slice(0, fingerprintLength);
|
|
40392
|
-
fingerprintCacheByFilePath.set(filePath, {
|
|
40393
|
-
fingerprint,
|
|
40394
|
-
modifiedTimeNanoseconds: fileStats.mtimeNs,
|
|
40395
|
-
sizeBytes: fileStats.size
|
|
40396
|
-
});
|
|
40397
|
-
return fingerprint;
|
|
40398
|
-
};
|
|
40399
40125
|
const bundledRequire = createRequire(import.meta.url);
|
|
40400
40126
|
const childNodeVersionByBinaryPath = /* @__PURE__ */ new Map();
|
|
40401
40127
|
const resolveChildNodeVersion = (nodeBinaryPath) => {
|
|
@@ -40419,13 +40145,6 @@ const TOOLCHAIN_PACKAGE_SPECIFIERS = [
|
|
|
40419
40145
|
"oxlint-plugin-react-doctor/package.json",
|
|
40420
40146
|
"eslint-plugin-react-hooks/package.json"
|
|
40421
40147
|
];
|
|
40422
|
-
const resolvePluginFingerprint = () => {
|
|
40423
|
-
try {
|
|
40424
|
-
return fingerprintFileContents(bundledRequire.resolve("oxlint-plugin-react-doctor"), 16);
|
|
40425
|
-
} catch {
|
|
40426
|
-
return "unresolved";
|
|
40427
|
-
}
|
|
40428
|
-
};
|
|
40429
40148
|
const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
40430
40149
|
const versions = [`node=${resolveChildNodeVersion(nodeBinaryPath)}`];
|
|
40431
40150
|
for (const specifier of TOOLCHAIN_PACKAGE_SPECIFIERS) try {
|
|
@@ -40435,7 +40154,6 @@ const resolveOxlintToolchainVersions = (nodeBinaryPath = process.execPath) => {
|
|
|
40435
40154
|
} catch {
|
|
40436
40155
|
versions.push(`${specifier}=missing`);
|
|
40437
40156
|
}
|
|
40438
|
-
versions.push(`oxlint-plugin-react-doctor#fingerprint=${resolvePluginFingerprint()}`);
|
|
40439
40157
|
return versions;
|
|
40440
40158
|
};
|
|
40441
40159
|
const esmRequire = createRequire(import.meta.url);
|
|
@@ -41129,17 +40847,12 @@ const REACT_ERROR_BOUNDARY_MESSAGE = "This try/catch cannot catch errors thrown
|
|
|
41129
40847
|
const REACT_COMPILER_IMPACT = "This component misses React Compiler's automatic memoization & re-renders more than it should";
|
|
41130
40848
|
const REACT_COMPILER_ACTION = "Rewrite the flagged code so the compiler can optimize it.";
|
|
41131
40849
|
const REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION = "It's how the library works, not a bug in your code. Memoize values you pass from it into other memoized components, or suppress it with `// react-doctor-disable-next-line react-hooks-js/incompatible-library`.";
|
|
41132
|
-
const SET_STATE_IN_EFFECT_ACTION = "Prefer deriving or initializing the value before render. If the effect must read a browser API after mount, treat this as advisory or suppress it with `// react-doctor-disable-next-line react-hooks-js/set-state-in-effect`.";
|
|
41133
40850
|
const REACT_COMPILER_GENERIC_MESSAGE = `${REACT_COMPILER_IMPACT}. ${REACT_COMPILER_ACTION}`;
|
|
41134
40851
|
const buildReactCompilerMessage = (reasonSummary, action = REACT_COMPILER_ACTION) => {
|
|
41135
40852
|
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
41136
40853
|
if (!normalizedSummary) return `${REACT_COMPILER_IMPACT}. ${action}`;
|
|
41137
40854
|
return `${REACT_COMPILER_IMPACT}: ${normalizedSummary}. ${action}`;
|
|
41138
40855
|
};
|
|
41139
|
-
const buildSetStateInEffectMessage = (reasonSummary) => {
|
|
41140
|
-
const normalizedSummary = reasonSummary.replace(TRAILING_PERIOD_PATTERN, "");
|
|
41141
|
-
return `This synchronous effect update causes an extra render${normalizedSummary ? `: ${normalizedSummary}` : ""}. ${SET_STATE_IN_EFFECT_ACTION}`;
|
|
41142
|
-
};
|
|
41143
40856
|
const PLUGIN_CATEGORY_MAP = {
|
|
41144
40857
|
react: "Bugs",
|
|
41145
40858
|
"react-hooks": "Bugs",
|
|
@@ -41197,10 +40910,6 @@ const resolveCleanedDiagnostic = (message, help, plugin, rule, project) => {
|
|
|
41197
40910
|
message: REACT_ERROR_BOUNDARY_MESSAGE,
|
|
41198
40911
|
help: reasonDetail || help
|
|
41199
40912
|
};
|
|
41200
|
-
if (rule === "set-state-in-effect") return {
|
|
41201
|
-
message: buildSetStateInEffectMessage(reasonSummary.trim()),
|
|
41202
|
-
help: reasonDetail || help
|
|
41203
|
-
};
|
|
41204
40913
|
return {
|
|
41205
40914
|
message: buildReactCompilerMessage(reasonSummary.trim(), rule === "incompatible-library" ? REACT_COMPILER_INCOMPATIBLE_LIBRARY_ACTION : REACT_COMPILER_ACTION),
|
|
41206
40915
|
help: appendReanimatedSharedValueHint(reasonDetail || help, rule, project)
|
|
@@ -41911,7 +41620,7 @@ const reactHooksJsPluginDropNote = (error) => {
|
|
|
41911
41620
|
* 6. always restore disable directives + clean up the temp dir
|
|
41912
41621
|
*/
|
|
41913
41622
|
const runOxlint = async (options) => {
|
|
41914
|
-
const { rootDirectory, project, includePaths, nodeBinaryPath = process.execPath, customRulesOnly = false, respectInlineDisables = true, adoptExistingLintConfig = true, ignoredTags = /* @__PURE__ */ new Set(),
|
|
41623
|
+
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;
|
|
41915
41624
|
const serverAuthFunctionNames = Array.isArray(userConfig?.serverAuthFunctionNames) ? userConfig.serverAuthFunctionNames.filter((entry) => typeof entry === "string" && entry.length > 0) : void 0;
|
|
41916
41625
|
const severityControls = buildRuleSeverityControls(userConfig);
|
|
41917
41626
|
validateRuleRegistration();
|
|
@@ -41925,15 +41634,13 @@ const runOxlint = async (options) => {
|
|
|
41925
41634
|
}
|
|
41926
41635
|
const pluginPath = resolvePluginPath();
|
|
41927
41636
|
const extendsPaths = (adoptExistingLintConfig && !customRulesOnly ? detectUserLintConfigPaths(rootDirectory) : []).filter(canOxlintExtendConfig);
|
|
41928
|
-
const userPlugins =
|
|
41637
|
+
const userPlugins = resolveUserPlugins(userConfig?.plugins, configSourceDirectory);
|
|
41929
41638
|
const buildConfig = (overrides) => createOxlintConfig({
|
|
41930
41639
|
pluginPath,
|
|
41931
41640
|
project,
|
|
41932
41641
|
customRulesOnly,
|
|
41933
41642
|
extendsPaths: overrides.extendsPaths,
|
|
41934
41643
|
ignoredTags,
|
|
41935
|
-
includedTags,
|
|
41936
|
-
includeTagDefaults,
|
|
41937
41644
|
serverAuthFunctionNames,
|
|
41938
41645
|
severityControls,
|
|
41939
41646
|
userPlugins,
|
|
@@ -42322,8 +42029,6 @@ var Linter = class Linter extends Service()("react-doctor/Linter") {
|
|
|
42322
42029
|
respectInlineDisables: input.respectInlineDisables,
|
|
42323
42030
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
42324
42031
|
ignoredTags: input.ignoredTags,
|
|
42325
|
-
includedTags: input.includedTags,
|
|
42326
|
-
includeTagDefaults: input.includeTagDefaults,
|
|
42327
42032
|
userConfig: input.userConfig ?? null,
|
|
42328
42033
|
configSourceDirectory: input.configSourceDirectory,
|
|
42329
42034
|
onPartialFailure: (reason) => {
|
|
@@ -43172,9 +42877,7 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
43172
42877
|
const securityScanFailedRef = yield* make$13(false);
|
|
43173
42878
|
const securityScanFiber = yield* forkChild(runCollect(applyPerElementPipeline(isDiffMode ? empty$4 : unwrap(tryPromise(() => checkSecurityScanCooperative(scanDirectory, {
|
|
43174
42879
|
project,
|
|
43175
|
-
ignoredTags: input.ignoredTags
|
|
43176
|
-
includedTags: input.includedTags,
|
|
43177
|
-
includeTagDefaults: input.includeTagDefaults
|
|
42880
|
+
ignoredTags: input.ignoredTags
|
|
43178
42881
|
})).pipe(map$3((diagnostics) => fromIterable$1(diagnostics)), catch_$1(() => set(securityScanFailedRef, true).pipe(as(empty$4))))))).pipe(withSpan("SecurityScan.run")));
|
|
43179
42882
|
const shouldRunSupplyChain = !isDiffMode || (input.supplyChainManifestChanged ?? false);
|
|
43180
42883
|
const supplyChainOverlapTimeout = yield* SupplyChainOverlapTimeoutMs;
|
|
@@ -43265,8 +42968,6 @@ const runInspect = (input, hooks = {}) => gen(function* () {
|
|
|
43265
42968
|
respectInlineDisables: input.respectInlineDisables,
|
|
43266
42969
|
adoptExistingLintConfig: input.adoptExistingLintConfig,
|
|
43267
42970
|
ignoredTags: input.ignoredTags,
|
|
43268
|
-
includedTags: input.includedTags,
|
|
43269
|
-
includeTagDefaults: input.includeTagDefaults,
|
|
43270
42971
|
userConfig: resolvedConfig.config ?? void 0,
|
|
43271
42972
|
configSourceDirectory: resolvedConfig.configSourceDirectory ?? void 0,
|
|
43272
42973
|
onFileProgress: (scannedFileCount, totalFileCount) => {
|
|
@@ -44127,4 +43828,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
44127
43828
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, hasReactRuntime, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
44128
43829
|
|
|
44129
43830
|
//# sourceMappingURL=index.js.map
|
|
44130
|
-
//# debugId=
|
|
43831
|
+
//# debugId=f645a3f8-ff1c-5f09-a174-8281db00eaa4
|