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/index.d.ts CHANGED
@@ -487,6 +487,17 @@ interface ProjectInfo {
487
487
  * apply, instead of on every React Native project.
488
488
  */
489
489
  hasReanimated: boolean;
490
+ /**
491
+ * `true` when the project's `tsconfig.json` `compilerOptions.target` or
492
+ * `compilerOptions.lib` indicates the output environment predates ES2023
493
+ * (e.g. `target: "es2022"` or `lib: ["es2022"]`). Drives the `pre-es2023`
494
+ * capability in `buildCapabilities` so rules recommending ES2023-only
495
+ * methods (`toSorted`, `toReversed`, `toSpliced`, `with`, etc.) are
496
+ * silenced on projects that would get a type error or runtime crash.
497
+ * `false` when no tsconfig is found, when the target is ES2023+, or when
498
+ * the config is unparseable — the safe default is to keep the rule active.
499
+ */
500
+ isPreES2023Target: boolean;
490
501
  sourceFileCount: number;
491
502
  }
492
503
  //#endregion
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]="82aa4a60-8b72-5f7a-bdd2-285b7fe0e8f3")}catch(e){}}();
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]="5dfe6666-edcf-5833-87df-c46425e29677")}catch(e){}}();
3
3
  import { createRequire } from "node:module";
4
4
  import * as Schema from "effect/Schema";
5
5
  import * as fs$1 from "node:fs";
@@ -7,6 +7,7 @@ import fs from "node:fs";
7
7
  import * as path$1 from "node:path";
8
8
  import path from "node:path";
9
9
  import { spawn, spawnSync } from "node:child_process";
10
+ import * as ts from "typescript";
10
11
  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";
11
12
  import * as Cause from "effect/Cause";
12
13
  import * as Effect from "effect/Effect";
@@ -31,7 +32,6 @@ import * as NodeFileSystem from "@effect/platform-node-shared/NodeFileSystem";
31
32
  import * as NodePath from "@effect/platform-node-shared/NodePath";
32
33
  import * as ChildProcess from "effect/unstable/process/ChildProcess";
33
34
  import { ChildProcessSpawner } from "effect/unstable/process/ChildProcessSpawner";
34
- import * as ts from "typescript";
35
35
  import { gzipSync } from "node:zlib";
36
36
  import "effect/Exit";
37
37
  //#region \0rolldown/runtime.js
@@ -2125,8 +2125,8 @@ const isFile = (filePath) => {
2125
2125
  return false;
2126
2126
  }
2127
2127
  };
2128
- const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?)$/;
2129
- const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.js$/i;
2128
+ const SOURCE_FILE_PATTERN = /\.(tsx?|jsx?|mts|mjs)$/;
2129
+ const GENERATED_BUNDLE_FILE_PATTERN = /\.(iife|umd|global|min)\.m?js$/i;
2130
2130
  const MINIFIED_SNIFF_BYTES = 65536;
2131
2131
  const GIT_LS_FILES_MAX_BUFFER_BYTES = 50 * 1024 * 1024;
2132
2132
  const IGNORED_DIRECTORIES = new Set([
@@ -3041,6 +3041,171 @@ const resolveEffectiveReactMajor = (reactVersion, packageJson) => {
3041
3041
  if (peerFloor === null) return hasUpperBoundOnlyPeerRange(peerReactRange) ? null : installedReactMajor;
3042
3042
  return installedReactMajor !== null ? Math.min(installedReactMajor, peerFloor) : peerFloor;
3043
3043
  };
3044
+ const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
3045
+ const MILLISECONDS_PER_SECOND = 1e3;
3046
+ const SCORE_API_URL = "https://www.react.doctor/api/score";
3047
+ const FETCH_TIMEOUT_MS = 1e4;
3048
+ const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
3049
+ const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
3050
+ const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
3051
+ const GIT_SHOW_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
3052
+ const ES_TARGET_YEAR_BY_NAME = {
3053
+ es3: 1999,
3054
+ es5: 2009,
3055
+ es6: 2015,
3056
+ es2015: 2015,
3057
+ es2016: 2016,
3058
+ es2017: 2017,
3059
+ es2018: 2018,
3060
+ es2019: 2019,
3061
+ es2020: 2020,
3062
+ es2021: 2021,
3063
+ es2022: 2022,
3064
+ es2023: 2023,
3065
+ es2024: 2024,
3066
+ es2025: 2025,
3067
+ esnext: 9999
3068
+ };
3069
+ /**
3070
+ * Project-config files that `StagedFiles.materialize` copies into
3071
+ * the temp directory alongside staged sources so oxlint resolves
3072
+ * `tsconfig` / `package.json` / lint configs the same way it would
3073
+ * in the working tree. Hoisted out of the staged-files helper so
3074
+ * the constant lives next to the rest of the IO budget knobs.
3075
+ */
3076
+ const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
3077
+ "tsconfig.json",
3078
+ "tsconfig.base.json",
3079
+ "package.json",
3080
+ "doctor.config.ts",
3081
+ "doctor.config.mts",
3082
+ "doctor.config.cts",
3083
+ "doctor.config.js",
3084
+ "doctor.config.mjs",
3085
+ "doctor.config.cjs",
3086
+ "doctor.config.json",
3087
+ "doctor.config.jsonc",
3088
+ "oxlint.json",
3089
+ ".oxlintrc.json"
3090
+ ];
3091
+ const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
3092
+ const OXLINT_SPAWN_TIMEOUT_MS = 6e4;
3093
+ const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
3094
+ const RECOMMENDED_PNPM_MINIMUM_RELEASE_AGE_MINUTES = 10080;
3095
+ const DIAGNOSTIC_CATEGORY_BUCKETS = [
3096
+ "Security",
3097
+ "Bugs",
3098
+ "Performance",
3099
+ "Accessibility",
3100
+ "Maintainability"
3101
+ ];
3102
+ const APP_ONLY_RULE_KEYS = new Set([
3103
+ "react-hooks-js/static-components",
3104
+ "react-doctor/no-render-prop-children",
3105
+ "react-doctor/prefer-explicit-variants"
3106
+ ]);
3107
+ const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
3108
+ const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
3109
+ const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
3110
+ const CONFIG_CACHE_TTL_MS = 300 * 1e3;
3111
+ const TSCONFIG_FILENAME = "tsconfig.json";
3112
+ const isRelativeExtendsValue = (extendsValue) => extendsValue.startsWith("./") || extendsValue.startsWith("../") || path$1.isAbsolute(extendsValue);
3113
+ const ensureJsonExtension = (filePath) => path$1.extname(filePath) === "" ? `${filePath}.json` : filePath;
3114
+ const resolvePackageExtendsPath = (extendsValue, fromConfigDirectory) => {
3115
+ const requireFromConfig = createRequire(path$1.join(fromConfigDirectory, "tsconfig.json"));
3116
+ const candidates = [
3117
+ extendsValue,
3118
+ ensureJsonExtension(extendsValue),
3119
+ `${extendsValue.replace(/\/$/, "")}/tsconfig.json`
3120
+ ];
3121
+ for (const candidate of candidates) try {
3122
+ return requireFromConfig.resolve(candidate);
3123
+ } catch {
3124
+ continue;
3125
+ }
3126
+ return null;
3127
+ };
3128
+ const resolveExtendsPath = (extendsValue, fromConfigDirectory) => {
3129
+ if (isRelativeExtendsValue(extendsValue)) return ensureJsonExtension(path$1.resolve(fromConfigDirectory, extendsValue));
3130
+ return resolvePackageExtendsPath(extendsValue, fromConfigDirectory);
3131
+ };
3132
+ const normalizeCompilerOptions = (compilerOptions) => {
3133
+ if (!isPlainObject(compilerOptions)) return { hasExplicitLib: false };
3134
+ const target = typeof compilerOptions.target === "string" ? compilerOptions.target : void 0;
3135
+ const hasExplicitLib = Object.hasOwn(compilerOptions, "lib");
3136
+ return {
3137
+ target,
3138
+ lib: Array.isArray(compilerOptions.lib) ? compilerOptions.lib.filter((entry) => typeof entry === "string") : void 0,
3139
+ hasExplicitLib
3140
+ };
3141
+ };
3142
+ const readTsConfig = (filePath) => {
3143
+ let content;
3144
+ try {
3145
+ content = fs$1.readFileSync(filePath, "utf-8");
3146
+ } catch {
3147
+ return null;
3148
+ }
3149
+ const parsed = ts.parseConfigFileTextToJson(filePath, content);
3150
+ if (!isPlainObject(parsed.config)) return null;
3151
+ return {
3152
+ extends: typeof parsed.config.extends === "string" ? parsed.config.extends : void 0,
3153
+ compilerOptions: normalizeCompilerOptions(parsed.config.compilerOptions)
3154
+ };
3155
+ };
3156
+ const mergeCompilerOptions = (inherited, current) => {
3157
+ const target = current.target ?? inherited?.target;
3158
+ const hasExplicitLib = current.hasExplicitLib || Boolean(inherited?.hasExplicitLib);
3159
+ return {
3160
+ target,
3161
+ lib: current.hasExplicitLib ? current.lib : inherited?.lib,
3162
+ hasExplicitLib
3163
+ };
3164
+ };
3165
+ const readResolvedCompilerOptions = (tsConfigPath, extendsDepth, visitedPaths) => {
3166
+ const realPath = fs$1.realpathSync.native(tsConfigPath);
3167
+ if (visitedPaths.has(realPath)) return null;
3168
+ const tsConfig = readTsConfig(realPath);
3169
+ if (!tsConfig) return null;
3170
+ const nextVisitedPaths = new Set(visitedPaths);
3171
+ nextVisitedPaths.add(realPath);
3172
+ if (tsConfig.extends && extendsDepth < 8) {
3173
+ const parentPath = resolveExtendsPath(tsConfig.extends, path$1.dirname(realPath));
3174
+ if (parentPath && isFile(parentPath)) return mergeCompilerOptions(readResolvedCompilerOptions(parentPath, extendsDepth + 1, nextVisitedPaths), tsConfig.compilerOptions);
3175
+ }
3176
+ return tsConfig.compilerOptions;
3177
+ };
3178
+ const targetYearIsPreES2023 = (target) => {
3179
+ const year = ES_TARGET_YEAR_BY_NAME[target.toLowerCase()];
3180
+ return year !== void 0 && year < 2023;
3181
+ };
3182
+ const libEntryIncludesES2023Array = (entry) => {
3183
+ const normalizedEntry = entry.toLowerCase();
3184
+ if (normalizedEntry === "esnext" || normalizedEntry === "esnext.array") return true;
3185
+ const esYearMatch = /^es(\d{4})(?:\.(.+))?$/.exec(normalizedEntry);
3186
+ if (!esYearMatch) return false;
3187
+ if (Number(esYearMatch[1]) < 2023) return false;
3188
+ const component = esYearMatch[2];
3189
+ return component === void 0 || component === "array";
3190
+ };
3191
+ const libIncludesES2023 = (lib) => lib.some(libEntryIncludesES2023Array);
3192
+ const compilerOptionsArePreES2023 = (compilerOptions) => {
3193
+ if (compilerOptions.hasExplicitLib) return !libIncludesES2023(compilerOptions.lib ?? []);
3194
+ if (compilerOptions.target) return targetYearIsPreES2023(compilerOptions.target);
3195
+ return false;
3196
+ };
3197
+ const compilerOptionsDeclareTargetOrLib = (compilerOptions) => compilerOptions.hasExplicitLib || compilerOptions.target !== void 0;
3198
+ const detectPreES2023FromConfig = (tsConfigPath) => {
3199
+ const compilerOptions = readResolvedCompilerOptions(tsConfigPath, 0, /* @__PURE__ */ new Set());
3200
+ if (!compilerOptions) return false;
3201
+ if (!compilerOptionsDeclareTargetOrLib(compilerOptions)) return false;
3202
+ return compilerOptionsArePreES2023(compilerOptions);
3203
+ };
3204
+ const detectPreES2023Target = (directory) => {
3205
+ const tsConfigPath = path$1.join(directory, TSCONFIG_FILENAME);
3206
+ if (isFile(tsConfigPath)) return detectPreES2023FromConfig(tsConfigPath);
3207
+ return false;
3208
+ };
3044
3209
  const REACT_DEPENDENCY_NAMES = new Set([
3045
3210
  "react",
3046
3211
  "react-native",
@@ -3155,11 +3320,63 @@ const cachedProjectInfos = /* @__PURE__ */ new Map();
3155
3320
  const clearProjectCache = () => {
3156
3321
  cachedProjectInfos.clear();
3157
3322
  };
3323
+ /**
3324
+ * Build a `ProjectInfo` for a directory that has no `package.json` of
3325
+ * its own — a monorepo subfolder like `repo/packages`, or any loose tree
3326
+ * of TypeScript/JavaScript files. Dependency + framework detection is
3327
+ * inherited from the enclosing workspace root when there is one, so
3328
+ * scanning a subdirectory of a React monorepo still gets the React
3329
+ * capabilities; a standalone non-React directory simply scans with the
3330
+ * framework-agnostic rules. Throws only when the directory has nothing
3331
+ * to scan (no enclosing project and no source files of its own).
3332
+ */
3333
+ const discoverProjectWithoutPackageJson = (directory) => {
3334
+ const sourceFileCount = countSourceFiles(directory);
3335
+ const hasOwnTsConfig = fs$1.existsSync(path$1.join(directory, "tsconfig.json"));
3336
+ const monorepoRoot = findMonorepoRoot(directory);
3337
+ const enclosingProject = monorepoRoot !== null && isFile(path$1.join(monorepoRoot, "package.json")) ? discoverProject(monorepoRoot) : null;
3338
+ if (enclosingProject !== null) return {
3339
+ ...enclosingProject,
3340
+ rootDirectory: directory,
3341
+ projectName: path$1.basename(directory),
3342
+ hasTypeScript: hasOwnTsConfig || enclosingProject.hasTypeScript,
3343
+ sourceFileCount
3344
+ };
3345
+ if (sourceFileCount === 0) throw new PackageJsonNotFoundError(directory);
3346
+ return {
3347
+ rootDirectory: directory,
3348
+ projectName: path$1.basename(directory),
3349
+ reactVersion: null,
3350
+ reactMajorVersion: null,
3351
+ tailwindVersion: null,
3352
+ zodVersion: null,
3353
+ zodMajorVersion: null,
3354
+ framework: "unknown",
3355
+ hasTypeScript: hasOwnTsConfig,
3356
+ hasReactCompiler: false,
3357
+ hasTanStackQuery: false,
3358
+ preactVersion: null,
3359
+ preactMajorVersion: null,
3360
+ hasReactNativeWorkspace: false,
3361
+ nextjsVersion: null,
3362
+ nextjsMajorVersion: null,
3363
+ expoVersion: null,
3364
+ shopifyFlashListVersion: null,
3365
+ shopifyFlashListMajorVersion: null,
3366
+ hasReanimated: false,
3367
+ isPreES2023Target: hasOwnTsConfig && detectPreES2023Target(directory),
3368
+ sourceFileCount
3369
+ };
3370
+ };
3158
3371
  const discoverProject = (directory) => {
3159
3372
  const cached = cachedProjectInfos.get(directory);
3160
3373
  if (cached !== void 0) return cached;
3161
3374
  const packageJsonPath = path$1.join(directory, "package.json");
3162
- if (!isFile(packageJsonPath)) throw new PackageJsonNotFoundError(directory);
3375
+ if (!isFile(packageJsonPath)) {
3376
+ const synthesized = discoverProjectWithoutPackageJson(directory);
3377
+ cachedProjectInfos.set(directory, synthesized);
3378
+ return synthesized;
3379
+ }
3163
3380
  const packageJson = readPackageJson(packageJsonPath);
3164
3381
  let { reactVersion, tailwindVersion, zodVersion, framework } = extractDependencyInfo(packageJson);
3165
3382
  const reactDeclaration = getDependencyDeclaration({
@@ -3245,6 +3462,7 @@ const discoverProject = (directory) => {
3245
3462
  version: findNextjsVersion(directory, packageJson)
3246
3463
  }) : null;
3247
3464
  const preactVersion = getPreactVersion(packageJson);
3465
+ const isPreES2023Target = hasTypeScript && detectPreES2023Target(directory);
3248
3466
  const projectInfo = {
3249
3467
  rootDirectory: directory,
3250
3468
  projectName,
@@ -3266,12 +3484,22 @@ const discoverProject = (directory) => {
3266
3484
  shopifyFlashListVersion,
3267
3485
  shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
3268
3486
  hasReanimated,
3487
+ isPreES2023Target,
3269
3488
  sourceFileCount
3270
3489
  };
3271
3490
  cachedProjectInfos.set(directory, projectInfo);
3272
3491
  return projectInfo;
3273
3492
  };
3274
- const isAnalyzableProject = (project) => project.reactVersion !== null || project.preactVersion !== null;
3493
+ /**
3494
+ * A project is worth scanning when it has React/Preact (the framework-
3495
+ * specific rules apply) OR it simply has source files to lint. The
3496
+ * second arm is what lets a plain TypeScript/JavaScript codebase — no
3497
+ * React dependency at all — run the framework-agnostic rules
3498
+ * (security, architecture, zod, bundle-size, …) instead of hard-failing
3499
+ * with "No React dependency". Only a directory with neither React nor a
3500
+ * single source file has nothing to analyze.
3501
+ */
3502
+ const isAnalyzableProject = (project) => project.reactVersion !== null || project.preactVersion !== null || project.sourceFileCount > 0;
3275
3503
  const MAJOR_MINOR_PATTERN = /(\d{1,4})\.(\d{1,4})/;
3276
3504
  const MAJOR_ONLY_PATTERN = /(\d{1,4})/;
3277
3505
  const UPPER_BOUND_COMPARATOR_PATTERN = /<=?\s{0,8}\d{1,4}(?:\.\d{1,4}){0,2}(?:-[^\s,|]+)?/g;
@@ -3335,56 +3563,6 @@ const isTailwindAtLeast = (detected, required) => {
3335
3563
  if (detected.major !== required.major) return detected.major > required.major;
3336
3564
  return detected.minor >= required.minor;
3337
3565
  };
3338
- const JSX_FILE_PATTERN = /\.(tsx|jsx)$/;
3339
- const MILLISECONDS_PER_SECOND = 1e3;
3340
- const SCORE_API_URL = "https://www.react.doctor/api/score";
3341
- const FETCH_TIMEOUT_MS = 1e4;
3342
- const GITHUB_VIEWER_PERMISSION_TIMEOUT_MS = 2e3;
3343
- const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
3344
- const ADOPTABLE_LINT_CONFIG_FILENAMES = [".oxlintrc.json", ".eslintrc.json"];
3345
- const GIT_SHOW_MAX_BUFFER_BYTES = 10 * 1024 * 1024;
3346
- /**
3347
- * Project-config files that `StagedFiles.materialize` copies into
3348
- * the temp directory alongside staged sources so oxlint resolves
3349
- * `tsconfig` / `package.json` / lint configs the same way it would
3350
- * in the working tree. Hoisted out of the staged-files helper so
3351
- * the constant lives next to the rest of the IO budget knobs.
3352
- */
3353
- const STAGED_FILES_PROJECT_CONFIG_FILENAMES = [
3354
- "tsconfig.json",
3355
- "tsconfig.base.json",
3356
- "package.json",
3357
- "doctor.config.ts",
3358
- "doctor.config.mts",
3359
- "doctor.config.cts",
3360
- "doctor.config.js",
3361
- "doctor.config.mjs",
3362
- "doctor.config.cjs",
3363
- "doctor.config.json",
3364
- "doctor.config.jsonc",
3365
- "oxlint.json",
3366
- ".oxlintrc.json"
3367
- ];
3368
- const OXLINT_OUTPUT_MAX_BYTES = 50 * 1024 * 1024;
3369
- const OXLINT_SPAWN_TIMEOUT_MS = 6e4;
3370
- const DEAD_CODE_WORKER_MAX_OLD_SPACE_MB = 8192;
3371
- const RECOMMENDED_PNPM_MINIMUM_RELEASE_AGE_MINUTES = 10080;
3372
- const DIAGNOSTIC_CATEGORY_BUCKETS = [
3373
- "Security",
3374
- "Bugs",
3375
- "Performance",
3376
- "Accessibility",
3377
- "Maintainability"
3378
- ];
3379
- const APP_ONLY_RULE_KEYS = new Set([
3380
- "react-hooks-js/static-components",
3381
- "react-doctor/no-render-prop-children",
3382
- "react-doctor/prefer-explicit-variants"
3383
- ]);
3384
- const COMPILER_CLEANUP_BUCKET = "compiler-cleanup";
3385
- const COMPILER_CLEANUP_RULE_KEYS = new Set(["react-doctor/react-compiler-no-manual-memoization"]);
3386
- const MAX_GLOB_PATTERN_LENGTH_CHARS = 1024;
3387
- const CONFIG_CACHE_TTL_MS = 300 * 1e3;
3388
3566
  var InvalidGlobPatternError = class extends Error {
3389
3567
  pattern;
3390
3568
  reason;
@@ -4866,51 +5044,51 @@ const FLAGGED_DEPENDENCIES = [
4866
5044
  {
4867
5045
  packageName: "expo-modules-autolinking",
4868
5046
  rule: "expo-no-redundant-dependency",
4869
- message: "\"expo-modules-autolinking\" should not be a direct dependency — Expo installs it transitively as needed",
5047
+ 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",
4870
5048
  help: "Remove `expo-modules-autolinking` from your package.json"
4871
5049
  },
4872
5050
  {
4873
5051
  packageName: "expo-dev-launcher",
4874
5052
  rule: "expo-no-redundant-dependency",
4875
- message: "\"expo-dev-launcher\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
5053
+ 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",
4876
5054
  help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
4877
5055
  },
4878
5056
  {
4879
5057
  packageName: "expo-dev-menu",
4880
5058
  rule: "expo-no-redundant-dependency",
4881
- message: "\"expo-dev-menu\" should not be a direct dependency — it is pulled in by `expo-dev-client`",
5059
+ 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",
4882
5060
  help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
4883
5061
  },
4884
5062
  {
4885
5063
  packageName: "expo-modules-core",
4886
5064
  rule: "expo-no-redundant-dependency",
4887
- message: "\"expo-modules-core\" should not be a direct dependency — use the API re-exported from the `expo` package",
5065
+ 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",
4888
5066
  help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
4889
5067
  },
4890
5068
  {
4891
5069
  packageName: "@expo/metro-config",
4892
5070
  rule: "expo-no-redundant-dependency",
4893
- message: "\"@expo/metro-config\" should not be a direct dependency — use the `expo/metro-config` sub-export of the `expo` package",
5071
+ 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",
4894
5072
  help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
4895
5073
  },
4896
5074
  {
4897
5075
  packageName: "@types/react-native",
4898
5076
  rule: "expo-no-redundant-dependency",
4899
- message: "\"@types/react-native\" should not be installed — React Native ships its own types since SDK 48",
5077
+ 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",
4900
5078
  help: "Remove `@types/react-native` from your package.json",
4901
5079
  minSdkMajor: 48
4902
5080
  },
4903
5081
  {
4904
5082
  packageName: "@expo/config-plugins",
4905
5083
  rule: "expo-no-redundant-dependency",
4906
- message: "\"@expo/config-plugins\" should not be a direct dependency — use the `expo/config-plugins` sub-export of the `expo` package",
5084
+ 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",
4907
5085
  help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
4908
5086
  minSdkMajor: 48
4909
5087
  },
4910
5088
  {
4911
5089
  packageName: "@expo/prebuild-config",
4912
5090
  rule: "expo-no-redundant-dependency",
4913
- message: "\"@expo/prebuild-config\" should not be a direct dependency — Expo installs it transitively",
5091
+ 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",
4914
5092
  help: "Remove `@expo/prebuild-config` from your package.json",
4915
5093
  minSdkMajor: 53
4916
5094
  },
@@ -4924,28 +5102,28 @@ const FLAGGED_DEPENDENCIES = [
4924
5102
  {
4925
5103
  packageName: "expo-app-loading",
4926
5104
  rule: "expo-no-redundant-dependency",
4927
- message: "\"expo-app-loading\" was removed in SDK 49",
5105
+ message: "\"expo-app-loading\" was removed in SDK 49, so keeping it can leave imports unresolved after upgrading Expo",
4928
5106
  help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
4929
5107
  minSdkMajor: 49
4930
5108
  },
4931
5109
  {
4932
5110
  packageName: "expo-firebase-analytics",
4933
5111
  rule: "expo-no-redundant-dependency",
4934
- message: "\"expo-firebase-analytics\" was removed in SDK 48",
5112
+ message: "\"expo-firebase-analytics\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
4935
5113
  help: FIREBASE_HELP,
4936
5114
  minSdkMajor: 48
4937
5115
  },
4938
5116
  {
4939
5117
  packageName: "expo-firebase-recaptcha",
4940
5118
  rule: "expo-no-redundant-dependency",
4941
- message: "\"expo-firebase-recaptcha\" was removed in SDK 48",
5119
+ message: "\"expo-firebase-recaptcha\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
4942
5120
  help: FIREBASE_HELP,
4943
5121
  minSdkMajor: 48
4944
5122
  },
4945
5123
  {
4946
5124
  packageName: "expo-firebase-core",
4947
5125
  rule: "expo-no-redundant-dependency",
4948
- message: "\"expo-firebase-core\" was removed in SDK 48",
5126
+ message: "\"expo-firebase-core\" was removed in SDK 48, so keeping it can leave imports unresolved or fail native builds after upgrading Expo",
4949
5127
  help: FIREBASE_HELP,
4950
5128
  minSdkMajor: 48
4951
5129
  }
@@ -4986,7 +5164,7 @@ const checkExpoGitignore = (context) => {
4986
5164
  }));
4987
5165
  if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
4988
5166
  rule: "expo-gitignore",
4989
- 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",
5167
+ 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.",
4990
5168
  help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
4991
5169
  }));
4992
5170
  return diagnostics;
@@ -5048,17 +5226,16 @@ const checkExpoPackageJsonConflicts = (context) => {
5048
5226
  const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
5049
5227
  if (conflictingScriptNames.length > 0) {
5050
5228
  const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
5051
- const shadowsExpoCli = conflictingScriptNames.includes("expo");
5052
5229
  diagnostics.push(buildExpoDiagnostic({
5053
5230
  rule: "expo-package-json-conflict",
5054
- 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" : ""}`,
5231
+ 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.`,
5055
5232
  help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
5056
5233
  }));
5057
5234
  }
5058
5235
  const packageName = packageJson.name;
5059
5236
  if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
5060
5237
  rule: "expo-package-json-conflict",
5061
- message: `package.json "name" is "${packageName}", which collides with a dependency of the same name`,
5238
+ 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.`,
5062
5239
  help: "Rename your package so it no longer matches one of its dependencies"
5063
5240
  }));
5064
5241
  return diagnostics;
@@ -5129,7 +5306,7 @@ const checkExpoRouterReactNavigation = (context) => {
5129
5306
  if (reactNavigationNames.length === 0) return [];
5130
5307
  return [buildExpoDiagnostic({
5131
5308
  rule: "expo-router-no-react-navigation",
5132
- 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"}`,
5309
+ 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.`,
5133
5310
  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/"
5134
5311
  })];
5135
5312
  };
@@ -5482,7 +5659,9 @@ const highlighter = {
5482
5659
  gray: import_picocolors.default.gray,
5483
5660
  bold: import_picocolors.default.bold
5484
5661
  };
5485
- const computeJsxIncludePaths = (includePaths) => includePaths.length > 0 ? includePaths.filter((filePath) => JSX_FILE_PATTERN.test(filePath)) : void 0;
5662
+ const NEXT_ENTRY_FILE_PATTERN = /^(?:\.\/)?(?:src\/)?(?:middleware|proxy)\.(?:tsx?|jsx?|mts|mjs)$/;
5663
+ const shouldIncludeExplicitLintPath = (filePath, project) => JSX_FILE_PATTERN.test(filePath) || project?.framework === "nextjs" && NEXT_ENTRY_FILE_PATTERN.test(filePath);
5664
+ const computeExplicitLintIncludePaths = (includePaths, project) => includePaths.length > 0 ? includePaths.filter((filePath) => shouldIncludeExplicitLintPath(filePath, project)) : void 0;
5486
5665
  const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
5487
5666
  const FALSY_VALUES = new Set([
5488
5667
  "false",
@@ -5911,7 +6090,7 @@ const checkDeadCode = async (options) => {
5911
6090
  plugin: DEAD_CODE_PLUGIN,
5912
6091
  rule: "unused-file",
5913
6092
  severity: "warning",
5914
- message: "Unused file — not reachable from any entry point",
6093
+ message: "Unused file is not reachable from any entry point, so it adds maintenance surface without shipping any code.",
5915
6094
  help: "Delete the file if it is truly unreachable, or import it from an entry point.",
5916
6095
  line: 0,
5917
6096
  column: 0,
@@ -5924,7 +6103,7 @@ const checkDeadCode = async (options) => {
5924
6103
  plugin: DEAD_CODE_PLUGIN,
5925
6104
  rule: unusedExport.isTypeOnly ? "unused-type" : "unused-export",
5926
6105
  severity: "warning",
5927
- message: `Unused ${label}: \`${unusedExport.name}\``,
6106
+ 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.`,
5928
6107
  help: "Drop the `export` keyword (or remove the declaration) if no other module uses this symbol.",
5929
6108
  line: unusedExport.line,
5930
6109
  column: unusedExport.column,
@@ -5939,7 +6118,7 @@ const checkDeadCode = async (options) => {
5939
6118
  rule: unusedDependency.isDevDependency ? "unused-dev-dependency" : "unused-dependency",
5940
6119
  severity: "warning",
5941
6120
  message: `Unused ${label}: \`${unusedDependency.name}\``,
5942
- help: "Remove the dependency from package.json if it is genuinely unused.",
6121
+ help: `An unused ${label} adds install time and supply-chain surface without being used; remove it from package.json if it is genuinely unused.`,
5943
6122
  line: 0,
5944
6123
  column: 0,
5945
6124
  category: DEAD_CODE_CATEGORY
@@ -5952,7 +6131,7 @@ const checkDeadCode = async (options) => {
5952
6131
  plugin: DEAD_CODE_PLUGIN,
5953
6132
  rule: "circular-dependency",
5954
6133
  severity: "warning",
5955
- message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}`,
6134
+ message: `Circular import cycle: ${cycle.files.map(toRelative).join(" → ")}. Modules in the cycle can observe partially initialized exports, causing order-dependent bugs.`,
5956
6135
  help: "Break the cycle by extracting the shared code into a third module that both files import.",
5957
6136
  line: 0,
5958
6137
  column: 0,
@@ -6035,11 +6214,11 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
6035
6214
  return filePaths;
6036
6215
  };
6037
6216
  const listSourceFiles = (rootDirectory) => excludeMinifiedFiles(rootDirectory, listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory));
6038
- const resolveLintIncludePaths = (rootDirectory, userConfig) => {
6217
+ const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
6039
6218
  if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
6040
6219
  const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
6041
6220
  return listSourceFiles(rootDirectory).filter((filePath) => {
6042
- if (!JSX_FILE_PATTERN.test(filePath)) return false;
6221
+ if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
6043
6222
  return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
6044
6223
  });
6045
6224
  };
@@ -6742,6 +6921,7 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
6742
6921
  const buildCapabilities = (project) => {
6743
6922
  const capabilities = /* @__PURE__ */ new Set();
6744
6923
  capabilities.add(project.framework);
6924
+ if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
6745
6925
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6746
6926
  if (project.expoVersion !== null) capabilities.add("expo");
6747
6927
  if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
@@ -6767,6 +6947,7 @@ const buildCapabilities = (project) => {
6767
6947
  capabilities.add("zod");
6768
6948
  if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
6769
6949
  }
6950
+ if (project.isPreES2023Target) capabilities.add("pre-es2023");
6770
6951
  if (project.hasReactCompiler) capabilities.add("react-compiler");
6771
6952
  if (project.hasTanStackQuery) capabilities.add("tanstack-query");
6772
6953
  if (project.hasTypeScript) capabilities.add("typescript");
@@ -6785,6 +6966,7 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledBy)
6785
6966
  if (requires) {
6786
6967
  for (const capability of requires) if (!capabilities.has(capability)) return false;
6787
6968
  }
6969
+ if (tags?.includes("react-jsx-only") && !capabilities.has("react")) return false;
6788
6970
  if (disabledBy) {
6789
6971
  for (const capability of disabledBy) if (capabilities.has(capability)) return false;
6790
6972
  }
@@ -8391,7 +8573,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
8391
8573
  directory: scanDirectory,
8392
8574
  repo
8393
8575
  }).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
8394
- const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeJsxIncludePaths([...input.includePaths])) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config);
8576
+ const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
8395
8577
  const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
8396
8578
  const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
8397
8579
  const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
@@ -8989,4 +9171,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8989
9171
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8990
9172
 
8991
9173
  //# sourceMappingURL=index.js.map
8992
- //# debugId=82aa4a60-8b72-5f7a-bdd2-285b7fe0e8f3
9174
+ //# debugId=5dfe6666-edcf-5833-87df-c46425e29677