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/README.md +4 -23
- package/dist/cli.js +2136 -1525
- package/dist/index.d.ts +11 -0
- package/dist/index.js +264 -83
- package/dist/lsp.js +308 -131
- package/dist/skills/react-doctor/SKILL.md +2 -2
- package/dist/skills/{doctor-explain/SKILL.md → react-doctor/references/explain.md} +6 -9
- package/package.json +6 -6
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))
|
|
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
|
-
|
|
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;
|
|
@@ -3706,7 +3907,6 @@ const LEGACY_RULE_KEY_TO_NATIVE_RULE_KEY = {
|
|
|
3706
3907
|
"react/jsx-no-new-function-as-prop": "react-doctor/jsx-no-new-function-as-prop",
|
|
3707
3908
|
"react/jsx-no-new-object-as-prop": "react-doctor/jsx-no-new-object-as-prop",
|
|
3708
3909
|
"react/jsx-no-script-url": "react-doctor/jsx-no-script-url",
|
|
3709
|
-
"react/jsx-no-target-blank": "react-doctor/jsx-no-target-blank",
|
|
3710
3910
|
"react/jsx-no-undef": "react-doctor/jsx-no-undef",
|
|
3711
3911
|
"react/jsx-no-useless-fragment": "react-doctor/jsx-no-useless-fragment",
|
|
3712
3912
|
"react/jsx-pascal-case": "react-doctor/jsx-pascal-case",
|
|
@@ -4804,51 +5004,51 @@ const FLAGGED_DEPENDENCIES = [
|
|
|
4804
5004
|
{
|
|
4805
5005
|
packageName: "expo-modules-autolinking",
|
|
4806
5006
|
rule: "expo-no-redundant-dependency",
|
|
4807
|
-
message: "\"expo-modules-autolinking\" should not be a direct dependency
|
|
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",
|
|
4808
5008
|
help: "Remove `expo-modules-autolinking` from your package.json"
|
|
4809
5009
|
},
|
|
4810
5010
|
{
|
|
4811
5011
|
packageName: "expo-dev-launcher",
|
|
4812
5012
|
rule: "expo-no-redundant-dependency",
|
|
4813
|
-
message: "\"expo-dev-launcher\" should not be a direct dependency
|
|
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",
|
|
4814
5014
|
help: "Remove `expo-dev-launcher` and depend on `expo-dev-client` instead"
|
|
4815
5015
|
},
|
|
4816
5016
|
{
|
|
4817
5017
|
packageName: "expo-dev-menu",
|
|
4818
5018
|
rule: "expo-no-redundant-dependency",
|
|
4819
|
-
message: "\"expo-dev-menu\" should not be a direct dependency
|
|
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",
|
|
4820
5020
|
help: "Remove `expo-dev-menu` and depend on `expo-dev-client` instead"
|
|
4821
5021
|
},
|
|
4822
5022
|
{
|
|
4823
5023
|
packageName: "expo-modules-core",
|
|
4824
5024
|
rule: "expo-no-redundant-dependency",
|
|
4825
|
-
message: "\"expo-modules-core\" should not be a direct dependency
|
|
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",
|
|
4826
5026
|
help: "Remove `expo-modules-core` from your package.json and import from `expo` instead"
|
|
4827
5027
|
},
|
|
4828
5028
|
{
|
|
4829
5029
|
packageName: "@expo/metro-config",
|
|
4830
5030
|
rule: "expo-no-redundant-dependency",
|
|
4831
|
-
message: "\"@expo/metro-config\" should not be a direct dependency
|
|
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",
|
|
4832
5032
|
help: "Remove `@expo/metro-config` and import `expo/metro-config` in your metro.config.js"
|
|
4833
5033
|
},
|
|
4834
5034
|
{
|
|
4835
5035
|
packageName: "@types/react-native",
|
|
4836
5036
|
rule: "expo-no-redundant-dependency",
|
|
4837
|
-
message: "\"@types/react-native\" should not be installed
|
|
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",
|
|
4838
5038
|
help: "Remove `@types/react-native` from your package.json",
|
|
4839
5039
|
minSdkMajor: 48
|
|
4840
5040
|
},
|
|
4841
5041
|
{
|
|
4842
5042
|
packageName: "@expo/config-plugins",
|
|
4843
5043
|
rule: "expo-no-redundant-dependency",
|
|
4844
|
-
message: "\"@expo/config-plugins\" should not be a direct dependency
|
|
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",
|
|
4845
5045
|
help: "Remove `@expo/config-plugins`; config-plugin authors should import from `expo/config-plugins`. See https://github.com/expo/expo/pull/18855",
|
|
4846
5046
|
minSdkMajor: 48
|
|
4847
5047
|
},
|
|
4848
5048
|
{
|
|
4849
5049
|
packageName: "@expo/prebuild-config",
|
|
4850
5050
|
rule: "expo-no-redundant-dependency",
|
|
4851
|
-
message: "\"@expo/prebuild-config\" should not be a direct dependency
|
|
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",
|
|
4852
5052
|
help: "Remove `@expo/prebuild-config` from your package.json",
|
|
4853
5053
|
minSdkMajor: 53
|
|
4854
5054
|
},
|
|
@@ -4862,28 +5062,28 @@ const FLAGGED_DEPENDENCIES = [
|
|
|
4862
5062
|
{
|
|
4863
5063
|
packageName: "expo-app-loading",
|
|
4864
5064
|
rule: "expo-no-redundant-dependency",
|
|
4865
|
-
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",
|
|
4866
5066
|
help: "Remove `expo-app-loading` and use `expo-splash-screen` instead. See https://docs.expo.dev/versions/latest/sdk/splash-screen/",
|
|
4867
5067
|
minSdkMajor: 49
|
|
4868
5068
|
},
|
|
4869
5069
|
{
|
|
4870
5070
|
packageName: "expo-firebase-analytics",
|
|
4871
5071
|
rule: "expo-no-redundant-dependency",
|
|
4872
|
-
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",
|
|
4873
5073
|
help: FIREBASE_HELP,
|
|
4874
5074
|
minSdkMajor: 48
|
|
4875
5075
|
},
|
|
4876
5076
|
{
|
|
4877
5077
|
packageName: "expo-firebase-recaptcha",
|
|
4878
5078
|
rule: "expo-no-redundant-dependency",
|
|
4879
|
-
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",
|
|
4880
5080
|
help: FIREBASE_HELP,
|
|
4881
5081
|
minSdkMajor: 48
|
|
4882
5082
|
},
|
|
4883
5083
|
{
|
|
4884
5084
|
packageName: "expo-firebase-core",
|
|
4885
5085
|
rule: "expo-no-redundant-dependency",
|
|
4886
|
-
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",
|
|
4887
5087
|
help: FIREBASE_HELP,
|
|
4888
5088
|
minSdkMajor: 48
|
|
4889
5089
|
}
|
|
@@ -4924,7 +5124,7 @@ const checkExpoGitignore = (context) => {
|
|
|
4924
5124
|
}));
|
|
4925
5125
|
if (findLocalModuleNativeFiles(rootDirectory).find((nativeFilePath) => isPathGitIgnored(rootDirectory, nativeFilePath) === true) !== void 0) diagnostics.push(buildExpoDiagnostic({
|
|
4926
5126
|
rule: "expo-gitignore",
|
|
4927
|
-
message: "The native `ios`/`android` directories of a local Expo module under `modules/` are gitignored
|
|
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.",
|
|
4928
5128
|
help: "Use anchored patterns like `/ios` and `/android` in .gitignore so only the top-level native directories are excluded, not those inside `modules/`"
|
|
4929
5129
|
}));
|
|
4930
5130
|
return diagnostics;
|
|
@@ -4986,17 +5186,16 @@ const checkExpoPackageJsonConflicts = (context) => {
|
|
|
4986
5186
|
const conflictingScriptNames = CONFLICTING_SCRIPT_NAMES.filter((scriptName) => Boolean(packageJson.scripts?.[scriptName]));
|
|
4987
5187
|
if (conflictingScriptNames.length > 0) {
|
|
4988
5188
|
const quotedNames = conflictingScriptNames.map((name) => `"${name}"`).join(", ");
|
|
4989
|
-
const shadowsExpoCli = conflictingScriptNames.includes("expo");
|
|
4990
5189
|
diagnostics.push(buildExpoDiagnostic({
|
|
4991
5190
|
rule: "expo-package-json-conflict",
|
|
4992
|
-
message: `package.json defines ${quotedNames} ${conflictingScriptNames.length === 1 ? "as a script that
|
|
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.`,
|
|
4993
5192
|
help: "Rename these scripts so they don't collide with the `expo` / `react-native` binaries"
|
|
4994
5193
|
}));
|
|
4995
5194
|
}
|
|
4996
5195
|
const packageName = packageJson.name;
|
|
4997
5196
|
if (typeof packageName === "string" && context.directDependencyNames.has(packageName)) diagnostics.push(buildExpoDiagnostic({
|
|
4998
5197
|
rule: "expo-package-json-conflict",
|
|
4999
|
-
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.`,
|
|
5000
5199
|
help: "Rename your package so it no longer matches one of its dependencies"
|
|
5001
5200
|
}));
|
|
5002
5201
|
return diagnostics;
|
|
@@ -5067,7 +5266,7 @@ const checkExpoRouterReactNavigation = (context) => {
|
|
|
5067
5266
|
if (reactNavigationNames.length === 0) return [];
|
|
5068
5267
|
return [buildExpoDiagnostic({
|
|
5069
5268
|
rule: "expo-router-no-react-navigation",
|
|
5070
|
-
message: `As of SDK 56, expo-router is no longer compatible with react-navigation,
|
|
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.`,
|
|
5071
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/"
|
|
5072
5271
|
})];
|
|
5073
5272
|
};
|
|
@@ -5420,7 +5619,9 @@ const highlighter = {
|
|
|
5420
5619
|
gray: import_picocolors.default.gray,
|
|
5421
5620
|
bold: import_picocolors.default.bold
|
|
5422
5621
|
};
|
|
5423
|
-
const
|
|
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;
|
|
5424
5625
|
const LINGUIST_ATTRIBUTE_PATTERN = /^linguist-(?:vendored|generated)(?:=([a-zA-Z0-9]+))?$/i;
|
|
5425
5626
|
const FALSY_VALUES = new Set([
|
|
5426
5627
|
"false",
|
|
@@ -5849,7 +6050,7 @@ const checkDeadCode = async (options) => {
|
|
|
5849
6050
|
plugin: DEAD_CODE_PLUGIN,
|
|
5850
6051
|
rule: "unused-file",
|
|
5851
6052
|
severity: "warning",
|
|
5852
|
-
message: "Unused file
|
|
6053
|
+
message: "Unused file is not reachable from any entry point, so it adds maintenance surface without shipping any code.",
|
|
5853
6054
|
help: "Delete the file if it is truly unreachable, or import it from an entry point.",
|
|
5854
6055
|
line: 0,
|
|
5855
6056
|
column: 0,
|
|
@@ -5862,7 +6063,7 @@ const checkDeadCode = async (options) => {
|
|
|
5862
6063
|
plugin: DEAD_CODE_PLUGIN,
|
|
5863
6064
|
rule: unusedExport.isTypeOnly ? "unused-type" : "unused-export",
|
|
5864
6065
|
severity: "warning",
|
|
5865
|
-
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.`,
|
|
5866
6067
|
help: "Drop the `export` keyword (or remove the declaration) if no other module uses this symbol.",
|
|
5867
6068
|
line: unusedExport.line,
|
|
5868
6069
|
column: unusedExport.column,
|
|
@@ -5877,7 +6078,7 @@ const checkDeadCode = async (options) => {
|
|
|
5877
6078
|
rule: unusedDependency.isDevDependency ? "unused-dev-dependency" : "unused-dependency",
|
|
5878
6079
|
severity: "warning",
|
|
5879
6080
|
message: `Unused ${label}: \`${unusedDependency.name}\``,
|
|
5880
|
-
help:
|
|
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.`,
|
|
5881
6082
|
line: 0,
|
|
5882
6083
|
column: 0,
|
|
5883
6084
|
category: DEAD_CODE_CATEGORY
|
|
@@ -5890,7 +6091,7 @@ const checkDeadCode = async (options) => {
|
|
|
5890
6091
|
plugin: DEAD_CODE_PLUGIN,
|
|
5891
6092
|
rule: "circular-dependency",
|
|
5892
6093
|
severity: "warning",
|
|
5893
|
-
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.`,
|
|
5894
6095
|
help: "Break the cycle by extracting the shared code into a third module that both files import.",
|
|
5895
6096
|
line: 0,
|
|
5896
6097
|
column: 0,
|
|
@@ -5973,11 +6174,11 @@ const listSourceFilesViaFilesystem = (rootDirectory) => {
|
|
|
5973
6174
|
return filePaths;
|
|
5974
6175
|
};
|
|
5975
6176
|
const listSourceFiles = (rootDirectory) => excludeMinifiedFiles(rootDirectory, listSourceFilesViaGit(rootDirectory) ?? listSourceFilesViaFilesystem(rootDirectory));
|
|
5976
|
-
const resolveLintIncludePaths = (rootDirectory, userConfig) => {
|
|
6177
|
+
const resolveLintIncludePaths = (rootDirectory, userConfig, project) => {
|
|
5977
6178
|
if (!Array.isArray(userConfig?.ignore?.files) || userConfig.ignore.files.length === 0) return;
|
|
5978
6179
|
const ignoredPatterns = compileIgnoredFilePatterns(userConfig);
|
|
5979
6180
|
return listSourceFiles(rootDirectory).filter((filePath) => {
|
|
5980
|
-
if (!
|
|
6181
|
+
if (!shouldIncludeExplicitLintPath(filePath, project)) return false;
|
|
5981
6182
|
return !isFileIgnoredByPatterns(filePath, rootDirectory, ignoredPatterns);
|
|
5982
6183
|
});
|
|
5983
6184
|
};
|
|
@@ -6680,6 +6881,7 @@ const neutralizeDisableDirectives = async (rootDirectory, includePaths) => {
|
|
|
6680
6881
|
const buildCapabilities = (project) => {
|
|
6681
6882
|
const capabilities = /* @__PURE__ */ new Set();
|
|
6682
6883
|
capabilities.add(project.framework);
|
|
6884
|
+
if (project.reactVersion !== null || project.preactVersion !== null) capabilities.add("react");
|
|
6683
6885
|
if (project.framework === "expo" || project.framework === "react-native" || project.hasReactNativeWorkspace) capabilities.add("react-native");
|
|
6684
6886
|
if (project.expoVersion !== null) capabilities.add("expo");
|
|
6685
6887
|
if (project.nextjsMajorVersion !== null && project.nextjsMajorVersion >= 15) capabilities.add("nextjs:15");
|
|
@@ -6705,6 +6907,7 @@ const buildCapabilities = (project) => {
|
|
|
6705
6907
|
capabilities.add("zod");
|
|
6706
6908
|
if (project.zodMajorVersion !== null && project.zodMajorVersion >= 4) capabilities.add("zod:4");
|
|
6707
6909
|
}
|
|
6910
|
+
if (project.isPreES2023Target) capabilities.add("pre-es2023");
|
|
6708
6911
|
if (project.hasReactCompiler) capabilities.add("react-compiler");
|
|
6709
6912
|
if (project.hasTanStackQuery) capabilities.add("tanstack-query");
|
|
6710
6913
|
if (project.hasTypeScript) capabilities.add("typescript");
|
|
@@ -6723,6 +6926,7 @@ const shouldEnableRule = (requires, tags, capabilities, ignoredTags, disabledBy)
|
|
|
6723
6926
|
if (requires) {
|
|
6724
6927
|
for (const capability of requires) if (!capabilities.has(capability)) return false;
|
|
6725
6928
|
}
|
|
6929
|
+
if (tags?.includes("react-jsx-only") && !capabilities.has("react")) return false;
|
|
6726
6930
|
if (disabledBy) {
|
|
6727
6931
|
for (const capability of disabledBy) if (capabilities.has(capability)) return false;
|
|
6728
6932
|
}
|
|
@@ -8329,7 +8533,7 @@ const runInspect = (input, hooks = {}) => Effect.gen(function* () {
|
|
|
8329
8533
|
directory: scanDirectory,
|
|
8330
8534
|
repo
|
|
8331
8535
|
}).pipe(Effect.orElseSucceed(() => null)) : Effect.succeed(null));
|
|
8332
|
-
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 :
|
|
8536
|
+
const lintIncludePaths = (input.skipJsxIncludeFilter ? input.includePaths.length > 0 ? [...input.includePaths] : void 0 : computeExplicitLintIncludePaths([...input.includePaths], project)) ?? resolveLintIncludePaths(scanDirectory, resolvedConfig.config, project);
|
|
8333
8537
|
const scannedFilePaths = input.suppressScanSummary ? (lintIncludePaths ?? (yield* filesService.listSourceFiles(scanDirectory))).map((relativePath) => path$1.resolve(scanDirectory, relativePath)) : [];
|
|
8334
8538
|
const beforeLint = hooks.beforeLint ?? NO_HOOKS.beforeLint;
|
|
8335
8539
|
const afterLint = hooks.afterLint ?? NO_HOOKS.afterLint;
|
|
@@ -8761,6 +8965,22 @@ const getRuleMetadata = (plugin, rule) => {
|
|
|
8761
8965
|
defaultEnabled: definition.defaultEnabled ?? true
|
|
8762
8966
|
};
|
|
8763
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
|
+
};
|
|
8764
8984
|
//#endregion
|
|
8765
8985
|
//#region ../language-server/dist/index.js
|
|
8766
8986
|
/** Display name used in client-facing messages and progress titles. */
|
|
@@ -8806,31 +9026,9 @@ const SCANNABLE_EXTENSIONS = [
|
|
|
8806
9026
|
".ts",
|
|
8807
9027
|
".tsx",
|
|
8808
9028
|
".js",
|
|
8809
|
-
".jsx"
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
const CONFIG_WATCH_FILENAMES = [
|
|
8813
|
-
"doctor.config.ts",
|
|
8814
|
-
"doctor.config.mts",
|
|
8815
|
-
"doctor.config.cts",
|
|
8816
|
-
"doctor.config.js",
|
|
8817
|
-
"doctor.config.mjs",
|
|
8818
|
-
"doctor.config.cjs",
|
|
8819
|
-
"doctor.config.json",
|
|
8820
|
-
"doctor.config.jsonc",
|
|
8821
|
-
"react-doctor.config.json",
|
|
8822
|
-
"package.json",
|
|
8823
|
-
"pnpm-workspace.yaml",
|
|
8824
|
-
"tsconfig.json",
|
|
8825
|
-
"tsconfig.base.json",
|
|
8826
|
-
".oxlintrc.json",
|
|
8827
|
-
".eslintrc.json",
|
|
8828
|
-
"pnpm-lock.yaml",
|
|
8829
|
-
"package-lock.json",
|
|
8830
|
-
"yarn.lock",
|
|
8831
|
-
"bun.lock",
|
|
8832
|
-
"bun.lockb",
|
|
8833
|
-
".gitignore"
|
|
9029
|
+
".jsx",
|
|
9030
|
+
".mts",
|
|
9031
|
+
".mjs"
|
|
8834
9032
|
];
|
|
8835
9033
|
const SILENT_LOGGER = {
|
|
8836
9034
|
info: () => {},
|
|
@@ -9448,27 +9646,6 @@ const createProjectGraph = (options) => {
|
|
|
9448
9646
|
}
|
|
9449
9647
|
};
|
|
9450
9648
|
};
|
|
9451
|
-
/**
|
|
9452
|
-
* Fingerprint of everything (outside file content) that affects lint
|
|
9453
|
-
* output for a project: the React Doctor version plus the size + mtime of
|
|
9454
|
-
* each config / manifest / lockfile. A change to any of them invalidates
|
|
9455
|
-
* the persisted per-file lint cache, since rules, capabilities, adopted
|
|
9456
|
-
* configs, and dependency-derived settings all flow from these files.
|
|
9457
|
-
*/
|
|
9458
|
-
const computeConfigFingerprint = (projectDirectory, version) => {
|
|
9459
|
-
const parts = [`v=${version}`];
|
|
9460
|
-
let directory = projectDirectory;
|
|
9461
|
-
for (;;) {
|
|
9462
|
-
for (const filename of CONFIG_WATCH_FILENAMES) try {
|
|
9463
|
-
const stat = fs.statSync(path.join(directory, filename));
|
|
9464
|
-
parts.push(`${directory}/${filename}=${stat.mtimeMs}:${stat.size}`);
|
|
9465
|
-
} catch {}
|
|
9466
|
-
const parent = path.dirname(directory);
|
|
9467
|
-
if (parent === directory) break;
|
|
9468
|
-
directory = parent;
|
|
9469
|
-
}
|
|
9470
|
-
return crypto.createHash("sha1").update(parts.join("|")).digest("hex");
|
|
9471
|
-
};
|
|
9472
9649
|
const resolveCacheFilePath = (projectDirectory) => {
|
|
9473
9650
|
const nodeModules = path.join(projectDirectory, "node_modules");
|
|
9474
9651
|
if (fs.existsSync(nodeModules)) return path.join(nodeModules, ".cache", "react-doctor", "lint-cache.json");
|
|
@@ -10252,7 +10429,7 @@ const createServer = (connection, options = {}) => {
|
|
|
10252
10429
|
};
|
|
10253
10430
|
});
|
|
10254
10431
|
connection.onInitialized(() => {
|
|
10255
|
-
if (supportsWatchedFileRegistration) connection.client.register(DidChangeWatchedFilesNotification.type, { watchers: [{ globPattern: `**/{${
|
|
10432
|
+
if (supportsWatchedFileRegistration) connection.client.register(DidChangeWatchedFilesNotification.type, { watchers: [{ globPattern: `**/{${CONFIG_FINGERPRINT_FILENAMES.join(",")}}` }, { globPattern: `**/*.{${SCANNABLE_EXTENSIONS.map((extension) => extension.slice(1)).join(",")}}` }] });
|
|
10256
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.`);
|
|
10257
10434
|
if (supportsWorkspaceFolderChange) connection.workspace.onDidChangeWorkspaceFolders((event) => {
|
|
10258
10435
|
const removedRoots = event.removed.map((folder) => normalizeFsPath(uriToFsPath(folder.uri)));
|
|
@@ -10305,7 +10482,7 @@ const createServer = (connection, options = {}) => {
|
|
|
10305
10482
|
for (const change of params.changes) {
|
|
10306
10483
|
const fsPath = uriToFsPath(change.uri);
|
|
10307
10484
|
const baseName = path.basename(fsPath);
|
|
10308
|
-
if (
|
|
10485
|
+
if (CONFIG_FINGERPRINT_FILENAMES.some((watched) => watched === baseName)) {
|
|
10309
10486
|
configChanged = true;
|
|
10310
10487
|
continue;
|
|
10311
10488
|
}
|
|
@@ -10854,5 +11031,5 @@ const startLanguageServer = () => {
|
|
|
10854
11031
|
};
|
|
10855
11032
|
//#endregion
|
|
10856
11033
|
export { startLanguageServer };
|
|
10857
|
-
!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]="
|
|
10858
|
-
//# debugId=
|
|
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
|