react-doctor 0.4.2-dev.829655c → 0.4.2-dev.93d4eec

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/dist/lsp.js CHANGED
@@ -6,6 +6,7 @@ import * as path$1 from "node:path";
6
6
  import path from "node:path";
7
7
  import * as Schema from "effect/Schema";
8
8
  import { spawn, spawnSync } from "node:child_process";
9
+ import * as ts from "typescript";
9
10
  import reactDoctorPlugin, { ALL_REACT_DOCTOR_RULE_KEYS, FRAMEWORK_SPECIFIC_RULE_KEYS, MOTION_LIBRARY_PACKAGES, REACT_COMPILER_RULES, REACT_DOCTOR_RULES } from "oxlint-plugin-react-doctor";
10
11
  import * as Cause from "effect/Cause";
11
12
  import * as Effect from "effect/Effect";
@@ -29,7 +30,6 @@ import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
29
30
  import * as NodePath from "@effect/platform-node-shared/NodePath";
30
31
  import * as ChildProcess from "effect/unstable/process/ChildProcess";
31
32
  import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
32
- import * as ts from "typescript";
33
33
  import { gzipSync } from "node:zlib";
34
34
  import crypto from "node:crypto";
35
35
  import * as Exit from "effect/Exit";
@@ -2136,8 +2136,8 @@ const isFile = (filePath) => {
2136
2136
  return false;
2137
2137
  }
2138
2138
  };
2139
- const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?)$/;
2140
- const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.js$/i;
2139
+ const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
2140
+ const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
2141
2141
  const MINIFIED_SNIFF_BYTES = 65536;
2142
2142
  const GIT_LS_FILES_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
2143
2143
  const IGNORED_DIRECTORIES = new Set([
@@ -3052,6 +3052,194 @@ const resolveEffectiveReactMajor = (reactVersion, packageJson) => {
3052
3052
  if (peerFloor === null) return hasUpperBoundOnlyPeerRange(peerReactRange) ? null : installedReactMajor;
3053
3053
  return installedReactMajor !== null ? Math.min(installedReactMajor, peerFloor) : peerFloor;
3054
3054
  };
3055
+ const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
3056
+ const MILLISECONDS_PER_SECOND = 1e3;
3057
+ const SCORE_API_URL = "https://www.react.doctor/api/score";
3058
+ const FETCH_TIMEOUT_MS = 1e4;
3059
+ const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
3060
+ const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
3061
+ const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
3062
+ const GIT_SHOW_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
3063
+ const ES_TARGET_YEAR_BY_NAME = {
3064
+ es3: 1999,
3065
+ es5: 2009,
3066
+ es6: 2015,
3067
+ es2015: 2015,
3068
+ es2016: 2016,
3069
+ es2017: 2017,
3070
+ es2018: 2018,
3071
+ es2019: 2019,
3072
+ es2020: 2020,
3073
+ es2021: 2021,
3074
+ es2022: 2022,
3075
+ es2023: 2023,
3076
+ es2024: 2024,
3077
+ es2025: 2025,
3078
+ esnext: 9999
3079
+ };
3080
+ /**
3081
+ * Project-config files that `StagedFiles.materialize` copies into
3082
+ * the temp directory alongside staged sources so oxlint resolves
3083
+ * `tsconfig` / `package.json` / lint configs the same way it would
3084
+ * in the working tree. Hoisted out of the staged-files helper so
3085
+ * the constant lives next to the rest of the IO budget knobs.
3086
+ */
3087
+ const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
3088
+ "tsconfig.json",
3089
+ "tsconfig.base.json",
3090
+ "package.json",
3091
+ "doctor.config.ts",
3092
+ "doctor.config.mts",
3093
+ "doctor.config.cts",
3094
+ "doctor.config.js",
3095
+ "doctor.config.mjs",
3096
+ "doctor.config.cjs",
3097
+ "doctor.config.json",
3098
+ "doctor.config.jsonc",
3099
+ "oxlint.json",
3100
+ ".oxlintrc.json"
3101
+ ];
3102
+ const CONFIG_FINGERPRINT_FILENAMES = [
3103
+ "doctor.config.ts",
3104
+ "doctor.config.mts",
3105
+ "doctor.config.cts",
3106
+ "doctor.config.js",
3107
+ "doctor.config.mjs",
3108
+ "doctor.config.cjs",
3109
+ "doctor.config.json",
3110
+ "doctor.config.jsonc",
3111
+ "react-doctor.config.json",
3112
+ "package.json",
3113
+ "pnpm-workspace.yaml",
3114
+ "tsconfig.json",
3115
+ "tsconfig.base.json",
3116
+ ".oxlintrc.json",
3117
+ ".eslintrc.json",
3118
+ "pnpm-lock.yaml",
3119
+ "package-lock.json",
3120
+ "yarn.lock",
3121
+ "bun.lock",
3122
+ "bun.lockb",
3123
+ ".gitignore"
3124
+ ];
3125
+ const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
3126
+ const OXLINT_SPAWN_TIMEOUT_MS = 6e4;
3127
+ const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
3128
+ const RECOMMENDED_PNPM_MINIMUM_RELEASE_AGE_MINUTES = 10080;
3129
+ const DIAGNOSTIC_CATEGORY_BUCKETS = [
3130
+ "Security",
3131
+ "Bugs",
3132
+ "Performance",
3133
+ "Accessibility",
3134
+ "Maintainability"
3135
+ ];
3136
+ const APP_ONLY_RULE_KEYS = new Set([
3137
+ "react-hooks-js/static-components",
3138
+ "react-doctor/no-render-prop-children",
3139
+ "react-doctor/prefer-explicit-variants"
3140
+ ]);
3141
+ const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
3142
+ const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
3143
+ const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
3144
+ const CONFIG_CACHE_TTL_MS = 300 * 1e3;
3145
+ const TSCONFIG_FILENAME = "tsconfig.json";
3146
+ const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || path$1.isAbsolute(extendsValue);
3147
+ const ensureJsonExtension = (filePath) => path$1.extname(filePath) === "" ? `${filePath}.json` : filePath;
3148
+ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
3149
+ const requireFromConfig = createRequire(path$1.join(fromConfigDirectory, "tsconfig.json"));
3150
+ const candidates = [
3151
+ extendsValue,
3152
+ ensureJsonExtension(extendsValue),
3153
+ `${extendsValue.replace(/\/$/, "")}/tsconfig.json`
3154
+ ];
3155
+ for (const candidate of candidates) try {
3156
+ return requireFromConfig.resolve(candidate);
3157
+ } catch {
3158
+ continue;
3159
+ }
3160
+ return null;
3161
+ };
3162
+ const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
3163
+ if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(path$1.resolve(fromConfigDirectory, extendsValue));
3164
+ return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
3165
+ };
3166
+ const normalizeCompilerOptions = (compilerOptions) => {
3167
+ if (!isPlainObject(compilerOptions)) return { hasExplicitLib: false };
3168
+ const target = typeof compilerOptions.target === "string" ? compilerOptions.target : void 0;
3169
+ const hasExplicitLib = Object.hasOwn(compilerOptions, "lib");
3170
+ return {
3171
+ target,
3172
+ lib: Array.isArray(compilerOptions.lib) ? compilerOptions.lib.filter((entry) => typeof entry === "string") : void 0,
3173
+ hasExplicitLib
3174
+ };
3175
+ };
3176
+ const readTsConfig = (filePath) => {
3177
+ let content;
3178
+ try {
3179
+ content = fs$1.readFileSync(filePath, "utf-8");
3180
+ } catch {
3181
+ return null;
3182
+ }
3183
+ const parsed = ts.parseConfigFileTextToJson(filePath, content);
3184
+ if (!isPlainObject(parsed.config)) return null;
3185
+ return {
3186
+ extends: typeof parsed.config.extends === "string" ? parsed.config.extends : void 0,
3187
+ compilerOptions: normalizeCompilerOptions(parsed.config.compilerOptions)
3188
+ };
3189
+ };
3190
+ const mergeCompilerOptions = (inherited, current) => {
3191
+ const target = current.target ?? inherited?.target;
3192
+ const hasExplicitLib = current.hasExplicitLib || Boolean(inherited?.hasExplicitLib);
3193
+ return {
3194
+ target,
3195
+ lib: current.hasExplicitLib ? current.lib : inherited?.lib,
3196
+ hasExplicitLib
3197
+ };
3198
+ };
3199
+ const readResolvedCompilerOptions = (tsConfigPath, extendsDepth, visitedPaths) => {
3200
+ const realPath = fs$1.realpathSync.native(tsConfigPath);
3201
+ if (visitedPaths.has(realPath)) return null;
3202
+ const tsConfig = readTsConfig(realPath);
3203
+ if (!tsConfig) return null;
3204
+ const nextVisitedPaths = new Set(visitedPaths);
3205
+ nextVisitedPaths.add(realPath);
3206
+ if (tsConfig.extends && extendsDepth < 8) {
3207
+ const parentPath = resolveExtendsPath(tsConfig.extends, path$1.dirname(realPath));
3208
+ if (parentPath && isFile(parentPath)) return mergeCompilerOptions(readResolvedCompilerOptions(parentPath, extendsDepth + 1, nextVisitedPaths), tsConfig.compilerOptions);
3209
+ }
3210
+ return tsConfig.compilerOptions;
3211
+ };
3212
+ const targetYearIsPreES2023 = (target) => {
3213
+ const year = ES_TARGET_YEAR_BY_NAME[target.toLowerCase()];
3214
+ return year !== void 0 && year < 2023;
3215
+ };
3216
+ const libEntryIncludesES2023Array = (entry) => {
3217
+ const normalizedEntry = entry.toLowerCase();
3218
+ if (normalizedEntry === "esnext" || normalizedEntry === "esnext.array") return true;
3219
+ const esYearMatch = /^es(\d{4})(?:\.(.+))?$/.exec(normalizedEntry);
3220
+ if (!esYearMatch) return false;
3221
+ if (Number(esYearMatch[1]) < 2023) return false;
3222
+ const component = esYearMatch[2];
3223
+ return component === void 0 || component === "array";
3224
+ };
3225
+ const libIncludesES2023 = (lib) => lib.some(libEntryIncludesES2023Array);
3226
+ const compilerOptionsArePreES2023 = (compilerOptions) => {
3227
+ if (compilerOptions.hasExplicitLib) return !libIncludesES2023(compilerOptions.lib ?? []);
3228
+ if (compilerOptions.target) return targetYearIsPreES2023(compilerOptions.target);
3229
+ return false;
3230
+ };
3231
+ const compilerOptionsDeclareTargetOrLib = (compilerOptions) => compilerOptions.hasExplicitLib || compilerOptions.target !== void 0;
3232
+ const detectPreES2023FromConfig = (tsConfigPath) => {
3233
+ const compilerOptions = readResolvedCompilerOptions(tsConfigPath, 0, /* @__PURE__ */ new Set());
3234
+ if (!compilerOptions) return false;
3235
+ if (!compilerOptionsDeclareTargetOrLib(compilerOptions)) return false;
3236
+ return compilerOptionsArePreES2023(compilerOptions);
3237
+ };
3238
+ const detectPreES2023Target = (directory) => {
3239
+ const tsConfigPath = path$1.join(directory, TSCONFIG_FILENAME);
3240
+ if (isFile(tsConfigPath)) return detectPreES2023FromConfig(tsConfigPath);
3241
+ return false;
3242
+ };
3055
3243
  const REACT_DEPENDENCY_NAMES = new Set([
3056
3244
  "react",
3057
3245
  "react-native",
@@ -3166,11 +3354,63 @@ const cachedProjectInfos = /* @__PURE__ */ new Map();
3166
3354
  const clearProjectCache = () => {
3167
3355
  cachedProjectInfos.clear();
3168
3356
  };
3357
+ /**
3358
+ * Build a `ProjectInfo` for a directory that has no `package.json` of
3359
+ * its own — a monorepo subfolder like `repo/packages`, or any loose tree
3360
+ * of TypeScript/JavaScript files. Dependency + framework detection is
3361
+ * inherited from the enclosing workspace root when there is one, so
3362
+ * scanning a subdirectory of a React monorepo still gets the React
3363
+ * capabilities; a standalone non-React directory simply scans with the
3364
+ * framework-agnostic rules. Throws only when the directory has nothing
3365
+ * to scan (no enclosing project and no source files of its own).
3366
+ */
3367
+ const discoverProjectWithoutPackageJson = (directory) => {
3368
+ const sourceFileCount = countSourceFiles(directory);
3369
+ const hasOwnTsConfig = fs$1.existsSync(path$1.join(directory, "tsconfig.json"));
3370
+ const monorepoRoot = findMonorepoRoot(directory);
3371
+ const enclosingProject = monorepoRoot !== null && isFile(path$1.join(monorepoRoot, "package.json")) ? discoverProject(monorepoRoot) : null;
3372
+ if (enclosingProject !== null) return {
3373
+ ...enclosingProject,
3374
+ rootDirectory: directory,
3375
+ projectName: path$1.basename(directory),
3376
+ hasTypeScript: hasOwnTsConfig || enclosingProject.hasTypeScript,
3377
+ sourceFileCount
3378
+ };
3379
+ if (sourceFileCount === 0) throw new PackageJsonNotFoundError(directory);
3380
+ return {
3381
+ rootDirectory: directory,
3382
+ projectName: path$1.basename(directory),
3383
+ reactVersion: null,
3384
+ reactMajorVersion: null,
3385
+ tailwindVersion: null,
3386
+ zodVersion: null,
3387
+ zodMajorVersion: null,
3388
+ framework: "unknown",
3389
+ hasTypeScript: hasOwnTsConfig,
3390
+ hasReactCompiler: false,
3391
+ hasTanStackQuery: false,
3392
+ preactVersion: null,
3393
+ preactMajorVersion: null,
3394
+ hasReactNativeWorkspace: false,
3395
+ nextjsVersion: null,
3396
+ nextjsMajorVersion: null,
3397
+ expoVersion: null,
3398
+ shopifyFlashListVersion: null,
3399
+ shopifyFlashListMajorVersion: null,
3400
+ hasReanimated: false,
3401
+ isPreES2023Target: hasOwnTsConfig && detectPreES2023Target(directory),
3402
+ sourceFileCount
3403
+ };
3404
+ };
3169
3405
  const discoverProject = (directory) => {
3170
3406
  const cached = cachedProjectInfos.get(directory);
3171
3407
  if (cached !== void 0) return cached;
3172
3408
  const packageJsonPath = path$1.join(directory, "package.json");
3173
- if (!isFile(packageJsonPath)) throw new PackageJsonNotFoundError(directory);
3409
+ if (!isFile(packageJsonPath)) {
3410
+ const synthesized = discoverProjectWithoutPackageJson(directory);
3411
+ cachedProjectInfos.set(directory, synthesized);
3412
+ return synthesized;
3413
+ }
3174
3414
  const packageJson = readPackageJson(packageJsonPath);
3175
3415
  let { reactVersion, tailwindVersion, zodVersion, framework } = extractDependencyInfo(packageJson);
3176
3416
  const reactDeclaration = getDependencyDeclaration({
@@ -3256,6 +3496,7 @@ const discoverProject = (directory) => {
3256
3496
  version: findNextjsVersion(directory, packageJson)
3257
3497
  }) : null;
3258
3498
  const preactVersion = getPreactVersion(packageJson);
3499
+ const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
3259
3500
  const projectInfo = {
3260
3501
  rootDirectory: directory,
3261
3502
  projectName,
@@ -3277,12 +3518,22 @@ const discoverProject = (directory) => {
3277
3518
  shopifyFlashListVersion,
3278
3519
  shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
3279
3520
  hasReanimated,
3521
+ isPreES2023Target,
3280
3522
  sourceFileCount
3281
3523
  };
3282
3524
  cachedProjectInfos.set(directory, projectInfo);
3283
3525
  return projectInfo;
3284
3526
  };
3285
- const isAnalyzableProject = (project) => project.reactVersion !== null || project.preactVersion !== null;
3527
+ /**
3528
+ * A project is worth scanning when it has React/Preact (the framework-
3529
+ * specific rules apply) OR it simply has source files to lint. The
3530
+ * second arm is what lets a plain TypeScript/JavaScript codebase — no
3531
+ * React dependency at all — run the framework-agnostic rules
3532
+ * (security, architecture, zod, bundle-size, …) instead of hard-failing
3533
+ * with "No React dependency". Only a directory with neither React nor a
3534
+ * single source file has nothing to analyze.
3535
+ */
3536
+ const isAnalyzableProject = (project) => project.reactVersion !== null || project.preactVersion !== null || project.sourceFileCount > 0;
3286
3537
  const MAJOR_MINOR_PATTERN = /(\d{1,4})\.(\d{1,4})/;
3287
3538
  const MAJOR_ONLY_PATTERN = /(\d{1,4})/;
3288
3539
  const UPPER_BOUND_COMPARATOR_PATTERN = /<=?\s{0,8}\d{1,4}(?:\.\d{1,4}){0,2}(?:-[^\s,|]+)?/g;
@@ -3346,56 +3597,6 @@ const isTailwindAtLeast = (detected, required) => {
3346
3597
  if (detected.major !== required.major) return detected.major > required.major;
3347
3598
  return detected.minor >= required.minor;
3348
3599
  };
3349
- const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
3350
- const MILLISECONDS_PER_SECOND = 1e3;
3351
- const SCORE_API_URL = "https://www.react.doctor/api/score";
3352
- const FETCH_TIMEOUT_MS = 1e4;
3353
- const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
3354
- const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
3355
- const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
3356
- const GIT_SHOW_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
3357
- /**
3358
- * Project-config files that `StagedFiles.materialize` copies into
3359
- * the temp directory alongside staged sources so oxlint resolves
3360
- * `tsconfig` / `package.json` / lint configs the same way it would
3361
- * in the working tree. Hoisted out of the staged-files helper so
3362
- * the constant lives next to the rest of the IO budget knobs.
3363
- */
3364
- const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
3365
- "tsconfig.json",
3366
- "tsconfig.base.json",
3367
- "package.json",
3368
- "doctor.config.ts",
3369
- "doctor.config.mts",
3370
- "doctor.config.cts",
3371
- "doctor.config.js",
3372
- "doctor.config.mjs",
3373
- "doctor.config.cjs",
3374
- "doctor.config.json",
3375
- "doctor.config.jsonc",
3376
- "oxlint.json",
3377
- ".oxlintrc.json"
3378
- ];
3379
- const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
3380
- const OXLINT_SPAWN_TIMEOUT_MS = 6e4;
3381
- const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
3382
- const RECOMMENDED_PNPM_MINIMUM_RELEASE_AGE_MINUTES = 10080;
3383
- const DIAGNOSTIC_CATEGORY_BUCKETS = [
3384
- "Security",
3385
- "Bugs",
3386
- "Performance",
3387
- "Accessibility",
3388
- "Maintainability"
3389
- ];
3390
- const APP_ONLY_RULE_KEYS = new Set([
3391
- "react-hooks-js/static-components",
3392
- "react-doctor/no-render-prop-children",
3393
- "react-doctor/prefer-explicit-variants"
3394
- ]);
3395
- const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
3396
- const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
3397
- const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
3398
- const CONFIG_CACHE_TTL_MS = 300 * 1e3;
3399
3600
  var InvalidGlobPatternError = class extends Error {
3400
3601
  pattern;
3401
3602
  reason;
@@ -4803,51 +5004,51 @@ const FLAGGED_DEPENDENCIES = [
4803
5004
  {
4804
5005
  packageName: "expo-modules-autolinking",
4805
5006
  rule: "expo-no-redundant-dependency",
4806
- message: "\"expo-modules-autolinking\" should not be a direct dependency — Expo installs it transitively as needed",
5007
+ message: "\"expo-modules-autolinking\" should not be a direct dependency. Expo pins the compatible version through the SDK, and a direct entry can drift to a version that breaks prebuild, Metro, or native builds",
4807
5008
  help: "Remove `expo-modules-autolinking` from your package.json"
4808
5009
  },
4809
5010
  {
4810
5011
  packageName: "expo-dev-launcher",
4811
5012
  rule: "expo-no-redundant-dependency",
4812
- message: "\"expo-dev-launcher\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
5013
+ message: "\"expo-dev-launcher\" should not be a direct dependency. `expo-dev-client` pins the compatible launcher, and a direct entry can drift to a version that breaks native builds",
4813
5014
  help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
4814
5015
  },
4815
5016
  {
4816
5017
  packageName: "expo-dev-menu",
4817
5018
  rule: "expo-no-redundant-dependency",
4818
- message: "\"expo-dev-menu\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
5019
+ message: "\"expo-dev-menu\" should not be a direct dependency. `expo-dev-client` pins the compatible dev menu, and a direct entry can drift to a version that breaks native builds",
4819
5020
  help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
4820
5021
  },
4821
5022
  {
4822
5023
  packageName: "expo-modules-core",
4823
5024
  rule: "expo-no-redundant-dependency",
4824
- message: "\"expo-modules-core\" should not be a direct dependency — use the API re-exported from the `expo` package",
5025
+ message: "\"expo-modules-core\" should not be a direct dependency. Expo pins the compatible native core, and a direct entry can drift to a version that breaks prebuild or native builds",
4825
5026
  help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
4826
5027
  },
4827
5028
  {
4828
5029
  packageName: "@expo/metro-config",
4829
5030
  rule: "expo-no-redundant-dependency",
4830
- message: "\"@expo/metro-config\" should not be a direct dependency — use the `expo/metro-config` sub-export of the `expo` package",
5031
+ message: "\"@expo/metro-config\" should not be a direct dependency. Expo pins the compatible Metro config, and a direct entry can drift to a version that breaks bundling",
4831
5032
  help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
4832
5033
  },
4833
5034
  {
4834
5035
  packageName: "@types/react-native",
4835
5036
  rule: "expo-no-redundant-dependency",
4836
- message: "\"@types/react-native\" should not be installed — React Native ships its own types since SDK 48",
5037
+ message: "\"@types/react-native\" should not be installed. React Native ships its own types since SDK 48, so the extra package can introduce duplicate or stale type definitions",
4837
5038
  help: "Remove `@types/react-native` from your package.json",
4838
5039
  minSdkMajor: 48
4839
5040
  },
4840
5041
  {
4841
5042
  packageName: "@expo/config-plugins",
4842
5043
  rule: "expo-no-redundant-dependency",
4843
- message: "\"@expo/config-plugins\" should not be a direct dependency — use the `expo/config-plugins` sub-export of the `expo` package",
5044
+ message: "\"@expo/config-plugins\" should not be a direct dependency. Expo pins the compatible config-plugin API, and a direct entry can drift to a version that breaks prebuild",
4844
5045
  help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
4845
5046
  minSdkMajor: 48
4846
5047
  },
4847
5048
  {
4848
5049
  packageName: "@expo/prebuild-config",
4849
5050
  rule: "expo-no-redundant-dependency",
4850
- message: "\"@expo/prebuild-config\" should not be a direct dependency — Expo installs it transitively",
5051
+ message: "\"@expo/prebuild-config\" should not be a direct dependency. Expo pins the compatible prebuild config, and a direct entry can drift to a version that breaks prebuild",
4851
5052
  help: "Remove `@expo/prebuild-config` from your package.json",
4852
5053
  minSdkMajor: 53
4853
5054
  },
@@ -4861,28 +5062,28 @@ const FLAGGED_DEPENDENCIES = [
4861
5062
  {
4862
5063
  packageName: "expo-app-loading",
4863
5064
  rule: "expo-no-redundant-dependency",
4864
- message: "\"expo-app-loading\" was removed in SDK 49",
5065
+ message: "\"expo-app-loading\" was removed in SDK 49, so keeping it can leave imports unresolved after upgrading Expo",
4865
5066
  help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
4866
5067
  minSdkMajor: 49
4867
5068
  },
4868
5069
  {
4869
5070
  packageName: "expo-firebase-analytics",
4870
5071
  rule: "expo-no-redundant-dependency",
4871
- message: "\"expo-firebase-analytics\" was removed in SDK 48",
5072
+ message: "\"expo-firebase-analytics\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
4872
5073
  help: FIREBASE_HELP,
4873
5074
  minSdkMajor: 48
4874
5075
  },
4875
5076
  {
4876
5077
  packageName: "expo-firebase-recaptcha",
4877
5078
  rule: "expo-no-redundant-dependency",
4878
- message: "\"expo-firebase-recaptcha\" was removed in SDK 48",
5079
+ message: "\"expo-firebase-recaptcha\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
4879
5080
  help: FIREBASE_HELP,
4880
5081
  minSdkMajor: 48
4881
5082
  },
4882
5083
  {
4883
5084
  packageName: "expo-firebase-core",
4884
5085
  rule: "expo-no-redundant-dependency",
4885
- message: "\"expo-firebase-core\" was removed in SDK 48",
5086
+ message: "\"expo-firebase-core\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
4886
5087
  help: FIREBASE_HELP,
4887
5088
  minSdkMajor: 48
4888
5089
  }
@@ -4923,7 +5124,7 @@ const checkExpoGitignore = (context) => {
4923
5124
  }));
4924
5125
  if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
4925
5126
  rule: "expo-gitignore",
4926
- message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored — usually caused by an overly broad `ios`/`android` ignore rule",
5127
+ message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored, so required native code can be missing from CI or teammate checkouts.",
4927
5128
  help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
4928
5129
  }));
4929
5130
  return diagnostics;
@@ -4985,17 +5186,16 @@ const checkExpoPackageJsonConflicts = (context) => {
4985
5186
  const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
4986
5187
  if (conflictingScriptNames.length > 0) {
4987
5188
  const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
4988
- const shadowsExpoCli = conflictingScriptNames.includes("expo");
4989
5189
  diagnostics.push(buildExpoDiagnostic({
4990
5190
  rule: "expo-package-json-conflict",
4991
- message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that conflicts" : "as scripts that conflict"} with binaries in node_modules/.bin${shadowsExpoCli ? " — a `expo` script shadows the Expo CLI and will likely cause build failures" : ""}`,
5191
+ message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that shadows" : "as scripts that shadow"} Expo/React Native binaries in node_modules/.bin, so tooling can run the local script instead of the expected CLI and fail builds.`,
4992
5192
  help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
4993
5193
  }));
4994
5194
  }
4995
5195
  const packageName = packageJson.name;
4996
5196
  if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
4997
5197
  rule: "expo-package-json-conflict",
4998
- message: `package.json "name" is "${packageName}", which collides with a dependency of the same name`,
5198
+ message: `package.json "name" is "${packageName}", which collides with a dependency of the same name, so package self-resolution can shadow the dependency and break imports that expect the installed package.`,
4999
5199
  help: "Rename your package so it no longer matches one of its dependencies"
5000
5200
  }));
5001
5201
  return diagnostics;
@@ -5066,7 +5266,7 @@ const checkExpoRouterReactNavigation = (context) => {
5066
5266
  if (reactNavigationNames.length === 0) return [];
5067
5267
  return [buildExpoDiagnostic({
5068
5268
  rule: "expo-router-no-react-navigation",
5069
- message: `As of SDK 56, expo-router is no longer compatible with react-navigation, but ${reactNavigationNames.map((name) => `"${name}"`).join(", ")} ${reactNavigationNames.length === 1 ? "is" : "are"} installed as direct ${reactNavigationNames.length === 1 ? "dependency" : "dependencies"}`,
5269
+ message: `As of SDK 56, expo-router is no longer compatible with directly installed @react-navigation packages, so keeping ${reactNavigationNames.map((name) => `"${name}"`).join(", ")} can break routing or linking behavior after the SDK upgrade.`,
5070
5270
  help: "Remove these `@react-navigation/*` packages and replace direct imports with their expo-router equivalents. See https://docs.expo.dev/router/migrate/sdk-55-to-56/"
5071
5271
  })];
5072
5272
  };
@@ -5419,7 +5619,9 @@ const highlighter = {
5419
5619
  gray: import_picocolors.default.gray,
5420
5620
  bold: import_picocolors.default.bold
5421
5621
  };
5422
- const computeJsxIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter((filePath) => JSX_FILE_PATTERN.test(filePath)) : void 0;
5622
+ const NEXT_ENTRY_FILE_PATTERN = /^(?:\.\/)?(?:src\/)?(?:middleware|proxy)\.(?:tsx?|jsx?|mts|mjs)$/;
5623
+ const shouldIncludeExplicitLintPath = (filePath, project) => JSX_FILE_PATTERN.test(filePath) || project?.framework === "nextjs" && NEXT_ENTRY_FILE_PATTERN.test(filePath);
5624
+ const computeExplicitLintIncludePaths = (includePaths, project) => includePaths.length > 0 ? includePaths.filter((filePath) => shouldIncludeExplicitLintPath(filePath, project)) : void 0;
5423
5625
  const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
5424
5626
  const FALSY_VALUES = new Set([
5425
5627
  "false",
@@ -5848,7 +6050,7 @@ const checkDeadCode = async (options) => {
5848
6050
  plugin: DEAD_CODE_PLUGIN,
5849
6051
  rule: "unused-file",
5850
6052
  severity: "warning",
5851
- message: "Unused file — not reachable from any entry point",
6053
+ message: "Unused file is not reachable from any entry point, so it adds maintenance surface without shipping any code.",
5852
6054
  help: "Delete the file if it is truly unreachable, or import it from an entry point.",
5853
6055
  line: 0,
5854
6056
  column: 0,
@@ -5861,7 +6063,7 @@ const checkDeadCode = async (options) => {
5861
6063
  plugin: DEAD_CODE_PLUGIN,
5862
6064
  rule: unusedExport.isTypeOnly ? "unused-type" : "unused-export",
5863
6065
  severity: "warning",
5864
- message: `Unused ${label}: \`${unusedExport.name}\``,
6066
+ message: `Unused ${label}: \`${unusedExport.name}\` is exported but no module imports it, so it expands the public surface and can mislead callers about supported API.`,
5865
6067
  help: "Drop the `export` keyword (or remove the declaration) if no other module uses this symbol.",
5866
6068
  line: unusedExport.line,
5867
6069
  column: unusedExport.column,
@@ -5876,7 +6078,7 @@ const checkDeadCode = async (options) => {
5876
6078
  rule: unusedDependency.isDevDependency ? "unused-dev-dependency" : "unused-dependency",
5877
6079
  severity: "warning",
5878
6080
  message: `Unused ${label}: \`${unusedDependency.name}\``,
5879
- help: "Remove the dependency from package.json if it is genuinely unused.",
6081
+ help: `An unused ${label} adds install time and supply-chain surface without being used; remove it from package.json if it is genuinely unused.`,
5880
6082
  line: 0,
5881
6083
  column: 0,
5882
6084
  category: DEAD_CODE_CATEGORY
@@ -5889,7 +6091,7 @@ const checkDeadCode = async (options) => {
5889
6091
  plugin: DEAD_CODE_PLUGIN,
5890
6092
  rule: "circular-dependency",
5891
6093
  severity: "warning",
5892
- message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}`,
6094
+ message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}. Modules in the cycle can observe partially initialized exports, causing order-dependent bugs.`,
5893
6095
  help: "Break the cycle by extracting the shared code into a third module that both files import.",
5894
6096
  line: 0,
5895
6097
  column: 0,
@@ -5972,11 +6174,11 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
5972
6174
  return filePaths;
5973
6175
  };
5974
6176
  const listSourceFiles = (rootDirectory) => excludeMinifiedFiles(rootDirectory, listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory));
5975
- const resolveLintIncludePaths = (rootDirectory, userConfig) => {
6177
+ const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
5976
6178
  if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
5977
6179
  const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
5978
6180
  return listSourceFiles(rootDirectory).filter((filePath) => {
5979
- if (!JSX_FILE_PATTERN.test(filePath)) return false;
6181
+ if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
5980
6182
  return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
5981
6183
  });
5982
6184
  };
@@ -6679,6 +6881,7 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
6679
6881
  const buildCapabilities = (project) => {
6680
6882
  const capabilities = /* @__PURE__ */ new Set();
6681
6883
  capabilities.add(project.framework);
6884
+ if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
6682
6885
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6683
6886
  if (project.expoVersion !== null) capabilities.add("expo");
6684
6887
  if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
@@ -6704,6 +6907,7 @@ const buildCapabilities = (project) => {
6704
6907
  capabilities.add("zod");
6705
6908
  if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
6706
6909
  }
6910
+ if (project.isPreES2023Target) capabilities.add("pre-es2023");
6707
6911
  if (project.hasReactCompiler) capabilities.add("react-compiler");
6708
6912
  if (project.hasTanStackQuery) capabilities.add("tanstack-query");
6709
6913
  if (project.hasTypeScript) capabilities.add("typescript");
@@ -6722,6 +6926,7 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledBy)
6722
6926
  if (requires) {
6723
6927
  for (const capability of requires) if (!capabilities.has(capability)) return false;
6724
6928
  }
6929
+ if (tags?.includes("react-jsx-only") && !capabilities.has("react")) return false;
6725
6930
  if (disabledBy) {
6726
6931
  for (const capability of disabledBy) if (capabilities.has(capability)) return false;
6727
6932
  }
@@ -8328,7 +8533,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
8328
8533
  directory: scanDirectory,
8329
8534
  repo
8330
8535
  }).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
8331
- const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeJsxIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
8536
+ const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
8332
8537
  const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
8333
8538
  const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
8334
8539
  const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
@@ -8760,6 +8965,22 @@ const getRuleMetadata = (plugin, rule) => {
8760
8965
  defaultEnabled: definition.defaultEnabled ?? true
8761
8966
  };
8762
8967
  };
8968
+ const computeConfigFingerprint = (projectDirectory, version) => {
8969
+ const parts = [`v=${version}`];
8970
+ let directory = projectDirectory;
8971
+ for (;;) {
8972
+ for (const filename of CONFIG_FINGERPRINT_FILENAMES) try {
8973
+ const stat = fs.statSync(path.join(directory, filename));
8974
+ parts.push(`${directory}/${filename}=${stat.mtimeMs}:${stat.size}`);
8975
+ } catch {
8976
+ continue;
8977
+ }
8978
+ const parent = path.dirname(directory);
8979
+ if (parent === directory) break;
8980
+ directory = parent;
8981
+ }
8982
+ return crypto.createHash("sha1").update(parts.join("|")).digest("hex");
8983
+ };
8763
8984
  //#endregion
8764
8985
  //#region ../language-server/dist/index.js
8765
8986
  /** Display name used in client-facing messages and progress titles. */
@@ -8805,31 +9026,9 @@ const SCANNABLE_EXTENSIONS = [
8805
9026
  ".ts",
8806
9027
  ".tsx",
8807
9028
  ".js",
8808
- ".jsx"
8809
- ];
8810
- /** Filenames whose change invalidates project/config caches. */
8811
- const CONFIG_WATCH_FILENAMES = [
8812
- "doctor.config.ts",
8813
- "doctor.config.mts",
8814
- "doctor.config.cts",
8815
- "doctor.config.js",
8816
- "doctor.config.mjs",
8817
- "doctor.config.cjs",
8818
- "doctor.config.json",
8819
- "doctor.config.jsonc",
8820
- "react-doctor.config.json",
8821
- "package.json",
8822
- "pnpm-workspace.yaml",
8823
- "tsconfig.json",
8824
- "tsconfig.base.json",
8825
- ".oxlintrc.json",
8826
- ".eslintrc.json",
8827
- "pnpm-lock.yaml",
8828
- "package-lock.json",
8829
- "yarn.lock",
8830
- "bun.lock",
8831
- "bun.lockb",
8832
- ".gitignore"
9029
+ ".jsx",
9030
+ ".mts",
9031
+ ".mjs"
8833
9032
  ];
8834
9033
  const SILENT_LOGGER = {
8835
9034
  info: () => {},
@@ -9447,27 +9646,6 @@ const createProjectGraph = (options) => {
9447
9646
  }
9448
9647
  };
9449
9648
  };
9450
- /**
9451
- * Fingerprint of everything (outside file content) that affects lint
9452
- * output for a project: the React Doctor version plus the size + mtime of
9453
- * each config / manifest / lockfile. A change to any of them invalidates
9454
- * the persisted per-file lint cache, since rules, capabilities, adopted
9455
- * configs, and dependency-derived settings all flow from these files.
9456
- */
9457
- const computeConfigFingerprint = (projectDirectory, version) => {
9458
- const parts = [`v=${version}`];
9459
- let directory = projectDirectory;
9460
- for (;;) {
9461
- for (const filename of CONFIG_WATCH_FILENAMES) try {
9462
- const stat = fs.statSync(path.join(directory, filename));
9463
- parts.push(`${directory}/${filename}=${stat.mtimeMs}:${stat.size}`);
9464
- } catch {}
9465
- const parent = path.dirname(directory);
9466
- if (parent === directory) break;
9467
- directory = parent;
9468
- }
9469
- return crypto.createHash("sha1").update(parts.join("|")).digest("hex");
9470
- };
9471
9649
  const resolveCacheFilePath = (projectDirectory) => {
9472
9650
  const nodeModules = path.join(projectDirectory, "node_modules");
9473
9651
  if (fs.existsSync(nodeModules)) return path.join(nodeModules, ".cache", "react-doctor", "lint-cache.json");
@@ -10251,7 +10429,7 @@ const createServer = (connection, options = {}) => {
10251
10429
  };
10252
10430
  });
10253
10431
  connection.onInitialized(() => {
10254
- if (supportsWatchedFileRegistration) connection.client.register(DidChangeWatchedFilesNotification.type, { watchers: [{ globPattern: `**/{${CONFIG_WATCH_FILENAMES.join(",")}}` }, { globPattern: `**/*.{${SCANNABLE_EXTENSIONS.map((extension) => extension.slice(1)).join(",")}}` }] });
10432
+ if (supportsWatchedFileRegistration) connection.client.register(DidChangeWatchedFilesNotification.type, { watchers: [{ globPattern: `**/{${CONFIG_FINGERPRINT_FILENAMES.join(",")}}` }, { globPattern: `**/*.{${SCANNABLE_EXTENSIONS.map((extension) => extension.slice(1)).join(",")}}` }] });
10255
10433
  if (nodeBinaryPath === null) logger.warn(`${SERVER_DISPLAY_NAME}: no Node binary compatible with the oxlint native binding was found; lint will be skipped until you switch to a supported Node version.`);
10256
10434
  if (supportsWorkspaceFolderChange) connection.workspace.onDidChangeWorkspaceFolders((event) => {
10257
10435
  const removedRoots = event.removed.map((folder) => normalizeFsPath(uriToFsPath(folder.uri)));
@@ -10304,7 +10482,7 @@ const createServer = (connection, options = {}) => {
10304
10482
  for (const change of params.changes) {
10305
10483
  const fsPath = uriToFsPath(change.uri);
10306
10484
  const baseName = path.basename(fsPath);
10307
- if (CONFIG_WATCH_FILENAMES.some((watched) => watched === baseName)) {
10485
+ if (CONFIG_FINGERPRINT_FILENAMES.some((watched) => watched === baseName)) {
10308
10486
  configChanged = true;
10309
10487
  continue;
10310
10488
  }
@@ -10853,5 +11031,5 @@ const startLanguageServer = () => {
10853
11031
  };
10854
11032
  //#endregion
10855
11033
  export { startLanguageServer };
10856
- !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]="3b471215-177c-57c1-8d5c-36e42d96995b")}catch(e){}}();
10857
- //# debugId=3b471215-177c-57c1-8d5c-36e42d96995b
11034
+ !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]="a515bd97-c428-5447-b931-4f92cc280b30")}catch(e){}}();
11035
+ //# debugId=a515bd97-c428-5447-b931-4f92cc280b30