react-doctor 0.4.2-dev.7cf52d8 → 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]="03c21420-4548-560c-9a26-8c22558218d8")}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;
@@ -3695,7 +3873,6 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
3695
3873
  "react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
3696
3874
  "react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
3697
3875
  "react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
3698
- "react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
3699
3876
  "react/jsx-no-undef": "react-doctor/jsx-no-undef",
3700
3877
  "react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
3701
3878
  "react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
@@ -4867,51 +5044,51 @@ const FLAGGED_DEPENDENCIES = [
4867
5044
  {
4868
5045
  packageName: "expo-modules-autolinking",
4869
5046
  rule: "expo-no-redundant-dependency",
4870
- 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",
4871
5048
  help: "Remove `expo-modules-autolinking` from your package.json"
4872
5049
  },
4873
5050
  {
4874
5051
  packageName: "expo-dev-launcher",
4875
5052
  rule: "expo-no-redundant-dependency",
4876
- 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",
4877
5054
  help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
4878
5055
  },
4879
5056
  {
4880
5057
  packageName: "expo-dev-menu",
4881
5058
  rule: "expo-no-redundant-dependency",
4882
- 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",
4883
5060
  help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
4884
5061
  },
4885
5062
  {
4886
5063
  packageName: "expo-modules-core",
4887
5064
  rule: "expo-no-redundant-dependency",
4888
- 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",
4889
5066
  help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
4890
5067
  },
4891
5068
  {
4892
5069
  packageName: "@expo/metro-config",
4893
5070
  rule: "expo-no-redundant-dependency",
4894
- 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",
4895
5072
  help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
4896
5073
  },
4897
5074
  {
4898
5075
  packageName: "@types/react-native",
4899
5076
  rule: "expo-no-redundant-dependency",
4900
- 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",
4901
5078
  help: "Remove `@types/react-native` from your package.json",
4902
5079
  minSdkMajor: 48
4903
5080
  },
4904
5081
  {
4905
5082
  packageName: "@expo/config-plugins",
4906
5083
  rule: "expo-no-redundant-dependency",
4907
- 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",
4908
5085
  help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
4909
5086
  minSdkMajor: 48
4910
5087
  },
4911
5088
  {
4912
5089
  packageName: "@expo/prebuild-config",
4913
5090
  rule: "expo-no-redundant-dependency",
4914
- 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",
4915
5092
  help: "Remove `@expo/prebuild-config` from your package.json",
4916
5093
  minSdkMajor: 53
4917
5094
  },
@@ -4925,28 +5102,28 @@ const FLAGGED_DEPENDENCIES = [
4925
5102
  {
4926
5103
  packageName: "expo-app-loading",
4927
5104
  rule: "expo-no-redundant-dependency",
4928
- 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",
4929
5106
  help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
4930
5107
  minSdkMajor: 49
4931
5108
  },
4932
5109
  {
4933
5110
  packageName: "expo-firebase-analytics",
4934
5111
  rule: "expo-no-redundant-dependency",
4935
- 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",
4936
5113
  help: FIREBASE_HELP,
4937
5114
  minSdkMajor: 48
4938
5115
  },
4939
5116
  {
4940
5117
  packageName: "expo-firebase-recaptcha",
4941
5118
  rule: "expo-no-redundant-dependency",
4942
- 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",
4943
5120
  help: FIREBASE_HELP,
4944
5121
  minSdkMajor: 48
4945
5122
  },
4946
5123
  {
4947
5124
  packageName: "expo-firebase-core",
4948
5125
  rule: "expo-no-redundant-dependency",
4949
- 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",
4950
5127
  help: FIREBASE_HELP,
4951
5128
  minSdkMajor: 48
4952
5129
  }
@@ -4987,7 +5164,7 @@ const checkExpoGitignore = (context) => {
4987
5164
  }));
4988
5165
  if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
4989
5166
  rule: "expo-gitignore",
4990
- 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.",
4991
5168
  help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
4992
5169
  }));
4993
5170
  return diagnostics;
@@ -5049,17 +5226,16 @@ const checkExpoPackageJsonConflicts = (context) => {
5049
5226
  const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
5050
5227
  if (conflictingScriptNames.length > 0) {
5051
5228
  const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
5052
- const shadowsExpoCli = conflictingScriptNames.includes("expo");
5053
5229
  diagnostics.push(buildExpoDiagnostic({
5054
5230
  rule: "expo-package-json-conflict",
5055
- 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.`,
5056
5232
  help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
5057
5233
  }));
5058
5234
  }
5059
5235
  const packageName = packageJson.name;
5060
5236
  if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
5061
5237
  rule: "expo-package-json-conflict",
5062
- 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.`,
5063
5239
  help: "Rename your package so it no longer matches one of its dependencies"
5064
5240
  }));
5065
5241
  return diagnostics;
@@ -5130,7 +5306,7 @@ const checkExpoRouterReactNavigation = (context) => {
5130
5306
  if (reactNavigationNames.length === 0) return [];
5131
5307
  return [buildExpoDiagnostic({
5132
5308
  rule: "expo-router-no-react-navigation",
5133
- 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.`,
5134
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/"
5135
5311
  })];
5136
5312
  };
@@ -5483,7 +5659,9 @@ const highlighter = {
5483
5659
  gray: import_picocolors.default.gray,
5484
5660
  bold: import_picocolors.default.bold
5485
5661
  };
5486
- 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;
5487
5665
  const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
5488
5666
  const FALSY_VALUES = new Set([
5489
5667
  "false",
@@ -5912,7 +6090,7 @@ const checkDeadCode = async (options) => {
5912
6090
  plugin: DEAD_CODE_PLUGIN,
5913
6091
  rule: "unused-file",
5914
6092
  severity: "warning",
5915
- 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.",
5916
6094
  help: "Delete the file if it is truly unreachable, or import it from an entry point.",
5917
6095
  line: 0,
5918
6096
  column: 0,
@@ -5925,7 +6103,7 @@ const checkDeadCode = async (options) => {
5925
6103
  plugin: DEAD_CODE_PLUGIN,
5926
6104
  rule: unusedExport.isTypeOnly ? "unused-type" : "unused-export",
5927
6105
  severity: "warning",
5928
- 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.`,
5929
6107
  help: "Drop the `export` keyword (or remove the declaration) if no other module uses this symbol.",
5930
6108
  line: unusedExport.line,
5931
6109
  column: unusedExport.column,
@@ -5940,7 +6118,7 @@ const checkDeadCode = async (options) => {
5940
6118
  rule: unusedDependency.isDevDependency ? "unused-dev-dependency" : "unused-dependency",
5941
6119
  severity: "warning",
5942
6120
  message: `Unused ${label}: \`${unusedDependency.name}\``,
5943
- 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.`,
5944
6122
  line: 0,
5945
6123
  column: 0,
5946
6124
  category: DEAD_CODE_CATEGORY
@@ -5953,7 +6131,7 @@ const checkDeadCode = async (options) => {
5953
6131
  plugin: DEAD_CODE_PLUGIN,
5954
6132
  rule: "circular-dependency",
5955
6133
  severity: "warning",
5956
- 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.`,
5957
6135
  help: "Break the cycle by extracting the shared code into a third module that both files import.",
5958
6136
  line: 0,
5959
6137
  column: 0,
@@ -6036,11 +6214,11 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
6036
6214
  return filePaths;
6037
6215
  };
6038
6216
  const listSourceFiles = (rootDirectory) => excludeMinifiedFiles(rootDirectory, listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory));
6039
- const resolveLintIncludePaths = (rootDirectory, userConfig) => {
6217
+ const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
6040
6218
  if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
6041
6219
  const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
6042
6220
  return listSourceFiles(rootDirectory).filter((filePath) => {
6043
- if (!JSX_FILE_PATTERN.test(filePath)) return false;
6221
+ if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
6044
6222
  return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
6045
6223
  });
6046
6224
  };
@@ -6743,6 +6921,7 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
6743
6921
  const buildCapabilities = (project) => {
6744
6922
  const capabilities = /* @__PURE__ */ new Set();
6745
6923
  capabilities.add(project.framework);
6924
+ if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
6746
6925
  if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
6747
6926
  if (project.expoVersion !== null) capabilities.add("expo");
6748
6927
  if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
@@ -6768,6 +6947,7 @@ const buildCapabilities = (project) => {
6768
6947
  capabilities.add("zod");
6769
6948
  if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
6770
6949
  }
6950
+ if (project.isPreES2023Target) capabilities.add("pre-es2023");
6771
6951
  if (project.hasReactCompiler) capabilities.add("react-compiler");
6772
6952
  if (project.hasTanStackQuery) capabilities.add("tanstack-query");
6773
6953
  if (project.hasTypeScript) capabilities.add("typescript");
@@ -6786,6 +6966,7 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledBy)
6786
6966
  if (requires) {
6787
6967
  for (const capability of requires) if (!capabilities.has(capability)) return false;
6788
6968
  }
6969
+ if (tags?.includes("react-jsx-only") && !capabilities.has("react")) return false;
6789
6970
  if (disabledBy) {
6790
6971
  for (const capability of disabledBy) if (capabilities.has(capability)) return false;
6791
6972
  }
@@ -8392,7 +8573,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
8392
8573
  directory: scanDirectory,
8393
8574
  repo
8394
8575
  }).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
8395
- 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);
8396
8577
  const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
8397
8578
  const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
8398
8579
  const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
@@ -8990,4 +9171,4 @@ const toJsonReport = (result, options) => buildJsonReport({
8990
9171
  export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, defineConfig, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
8991
9172
 
8992
9173
  //# sourceMappingURL=index.js.map
8993
- //# debugId=03c21420-4548-560c-9a26-8c22558218d8
9174
+ //# debugId=5dfe6666-edcf-5833-87df-c46425e29677