react-doctor 0.2.18-dev.e3b106e → 0.2.18-dev.eba20ae
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/cli.js +107 -37
- package/dist/index.d.ts +9 -0
- package/dist/index.js +97 -26
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="32d58bb2-956f-5f5d-9f5b-3c3e922c17d2")}catch(e){}}();
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
5
5
|
import * as Path from "node:path";
|
|
@@ -5943,6 +5943,23 @@ const getExpoDependencySpec = (packageJson) => {
|
|
|
5943
5943
|
return typeof spec === "string" ? spec : null;
|
|
5944
5944
|
};
|
|
5945
5945
|
const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getExpoDependencySpec);
|
|
5946
|
+
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
5947
|
+
const getShopifyFlashListDependencySpec = (packageJson) => {
|
|
5948
|
+
const spec = packageJson.dependencies?.["@shopify/flash-list"] ?? packageJson.devDependencies?.["@shopify/flash-list"] ?? packageJson.peerDependencies?.["@shopify/flash-list"] ?? packageJson.optionalDependencies?.["@shopify/flash-list"];
|
|
5949
|
+
return typeof spec === "string" ? spec : null;
|
|
5950
|
+
};
|
|
5951
|
+
const findShopifyFlashListVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getShopifyFlashListDependencySpec);
|
|
5952
|
+
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
5953
|
+
if (version === null || !isCatalogReference(version)) return version;
|
|
5954
|
+
const catalogName = extractCatalogName(version);
|
|
5955
|
+
const resolvedLocalVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
|
|
5956
|
+
if (resolvedLocalVersion) return resolvedLocalVersion;
|
|
5957
|
+
const monorepoRoot = findMonorepoRoot(rootDirectory);
|
|
5958
|
+
if (!monorepoRoot) return version;
|
|
5959
|
+
const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
|
|
5960
|
+
if (!isFile(monorepoPackageJsonPath)) return version;
|
|
5961
|
+
return resolveCatalogVersion(readPackageJson$1(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
|
|
5962
|
+
};
|
|
5946
5963
|
const getPreactVersion = (packageJson) => {
|
|
5947
5964
|
return {
|
|
5948
5965
|
...packageJson.peerDependencies,
|
|
@@ -6179,19 +6196,18 @@ const discoverProject = (directory) => {
|
|
|
6179
6196
|
const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
|
|
6180
6197
|
const sourceFileCount = countSourceFiles(directory);
|
|
6181
6198
|
const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
}
|
|
6199
|
+
const expoVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
|
|
6200
|
+
rootDirectory: directory,
|
|
6201
|
+
rootPackageJson: packageJson,
|
|
6202
|
+
packageName: "expo",
|
|
6203
|
+
version: findExpoVersion(directory, packageJson)
|
|
6204
|
+
}) : null;
|
|
6205
|
+
const shopifyFlashListVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
|
|
6206
|
+
rootDirectory: directory,
|
|
6207
|
+
rootPackageJson: packageJson,
|
|
6208
|
+
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
6209
|
+
version: findShopifyFlashListVersion(directory, packageJson)
|
|
6210
|
+
}) : null;
|
|
6195
6211
|
const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
|
|
6196
6212
|
const preactVersion = getPreactVersion(packageJson);
|
|
6197
6213
|
const projectInfo = {
|
|
@@ -6210,6 +6226,8 @@ const discoverProject = (directory) => {
|
|
|
6210
6226
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
6211
6227
|
hasReactNativeWorkspace,
|
|
6212
6228
|
expoVersion,
|
|
6229
|
+
shopifyFlashListVersion,
|
|
6230
|
+
shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
|
|
6213
6231
|
hasReanimated,
|
|
6214
6232
|
sourceFileCount
|
|
6215
6233
|
};
|
|
@@ -8521,6 +8539,63 @@ const collectIgnorePatterns = (rootDirectory) => {
|
|
|
8521
8539
|
cachedPatternsByRoot.set(rootDirectory, patterns);
|
|
8522
8540
|
return patterns;
|
|
8523
8541
|
};
|
|
8542
|
+
const KNIP_JSON_FILENAME = "knip.json";
|
|
8543
|
+
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8544
|
+
const readJsonFileSafe = (filePath) => {
|
|
8545
|
+
let rawContents;
|
|
8546
|
+
try {
|
|
8547
|
+
rawContents = fs.readFileSync(filePath, "utf-8");
|
|
8548
|
+
} catch {
|
|
8549
|
+
return null;
|
|
8550
|
+
}
|
|
8551
|
+
try {
|
|
8552
|
+
return JSON.parse(rawContents);
|
|
8553
|
+
} catch {
|
|
8554
|
+
return null;
|
|
8555
|
+
}
|
|
8556
|
+
};
|
|
8557
|
+
const readKnipConfig = (rootDirectory) => {
|
|
8558
|
+
const knipJson = readJsonFileSafe(path.join(rootDirectory, KNIP_JSON_FILENAME));
|
|
8559
|
+
if (isRecord$1(knipJson)) return knipJson;
|
|
8560
|
+
const packageJson = readJsonFileSafe(path.join(rootDirectory, "package.json"));
|
|
8561
|
+
const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
|
|
8562
|
+
return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
|
|
8563
|
+
};
|
|
8564
|
+
const normalizePatternList = (value) => {
|
|
8565
|
+
if (typeof value === "string" && value.length > 0) return [value];
|
|
8566
|
+
if (!Array.isArray(value)) return [];
|
|
8567
|
+
return value.filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
8568
|
+
};
|
|
8569
|
+
const prefixWorkspacePatterns = (workspacePattern, patterns) => {
|
|
8570
|
+
const normalizedWorkspacePattern = workspacePattern.replace(/\/+$/, "");
|
|
8571
|
+
return patterns.map((pattern) => pattern.startsWith("!") ? `!${normalizedWorkspacePattern}/${pattern.slice(1)}` : `${normalizedWorkspacePattern}/${pattern}`);
|
|
8572
|
+
};
|
|
8573
|
+
const collectKnipWorkspacePatterns = (workspaces, settingName) => {
|
|
8574
|
+
if (!isRecord$1(workspaces)) return [];
|
|
8575
|
+
const patterns = [];
|
|
8576
|
+
for (const [workspacePattern, workspaceConfig] of Object.entries(workspaces)) {
|
|
8577
|
+
if (!isRecord$1(workspaceConfig)) continue;
|
|
8578
|
+
patterns.push(...prefixWorkspacePatterns(workspacePattern, normalizePatternList(workspaceConfig[settingName])));
|
|
8579
|
+
}
|
|
8580
|
+
return patterns;
|
|
8581
|
+
};
|
|
8582
|
+
const collectKnipPatterns = (rootDirectory, settingName) => {
|
|
8583
|
+
const config = readKnipConfig(rootDirectory);
|
|
8584
|
+
if (!config) return [];
|
|
8585
|
+
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
8586
|
+
};
|
|
8587
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
|
|
8588
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8589
|
+
const sources = [
|
|
8590
|
+
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
8591
|
+
collectIgnorePatterns(rootDirectory),
|
|
8592
|
+
userConfig?.ignore?.files ?? [],
|
|
8593
|
+
collectKnipPatterns(rootDirectory, "ignore")
|
|
8594
|
+
];
|
|
8595
|
+
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
8596
|
+
return [...seen].filter((pattern) => pattern.length > 0);
|
|
8597
|
+
};
|
|
8598
|
+
const collectDeadCodeEntryPatterns = (rootDirectory) => [...new Set(collectKnipPatterns(rootDirectory, "entry"))].filter((pattern) => pattern.length > 0);
|
|
8524
8599
|
/**
|
|
8525
8600
|
* Resolves a path to its canonical, symlink-free form, falling back to
|
|
8526
8601
|
* the input when it cannot be realpath'd (broken symlink, permission
|
|
@@ -8546,6 +8621,7 @@ const toCanonicalPath = (filePath) => {
|
|
|
8546
8621
|
const DEAD_CODE_PLUGIN = "deslop";
|
|
8547
8622
|
const DEAD_CODE_CATEGORY = "Maintainability";
|
|
8548
8623
|
const TSCONFIG_FILENAMES$1 = ["tsconfig.json", "tsconfig.base.json"];
|
|
8624
|
+
const isRecord$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8549
8625
|
const DEAD_CODE_WORKER_SCRIPT = `
|
|
8550
8626
|
const inputChunks = [];
|
|
8551
8627
|
process.stdin.on("data", (chunk) => inputChunks.push(chunk));
|
|
@@ -8586,6 +8662,9 @@ process.stdin.on("end", () => {
|
|
|
8586
8662
|
const { analyze, defineConfig } = await import(workerInput.deslopJsModuleSpecifier);
|
|
8587
8663
|
const config = {
|
|
8588
8664
|
rootDir: workerInput.rootDirectory,
|
|
8665
|
+
...(workerInput.entryPatterns.length > 0
|
|
8666
|
+
? { entryPatterns: workerInput.entryPatterns }
|
|
8667
|
+
: {}),
|
|
8589
8668
|
...(workerInput.tsConfigPath ? { tsConfigPath: workerInput.tsConfigPath } : {}),
|
|
8590
8669
|
...(workerInput.ignorePatterns.length > 0
|
|
8591
8670
|
? { ignorePatterns: workerInput.ignorePatterns }
|
|
@@ -8605,21 +8684,10 @@ const resolveTsConfigPath = (rootDirectory) => {
|
|
|
8605
8684
|
if (fs.existsSync(candidate)) return candidate;
|
|
8606
8685
|
}
|
|
8607
8686
|
};
|
|
8608
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
|
|
8609
|
-
const seen = /* @__PURE__ */ new Set();
|
|
8610
|
-
const sources = [
|
|
8611
|
-
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
8612
|
-
collectIgnorePatterns(rootDirectory),
|
|
8613
|
-
userConfig?.ignore?.files ?? []
|
|
8614
|
-
];
|
|
8615
|
-
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
8616
|
-
return [...seen].filter((pattern) => pattern.length > 0);
|
|
8617
|
-
};
|
|
8618
8687
|
const toRelativeFilePath = (rootDirectory, filePath) => {
|
|
8619
8688
|
const relative = toRelativePath(filePath, rootDirectory);
|
|
8620
8689
|
return relative.length > 0 ? relative : filePath.replace(/\\/g, "/");
|
|
8621
8690
|
};
|
|
8622
|
-
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8623
8691
|
const parseArray = (value, label) => {
|
|
8624
8692
|
if (!Array.isArray(value)) throw new Error(`Dead-code worker returned invalid ${label}.`);
|
|
8625
8693
|
return value;
|
|
@@ -8643,7 +8711,7 @@ const parseUnusedFiles = (value) => {
|
|
|
8643
8711
|
const values = parseArray(value, "unusedFiles");
|
|
8644
8712
|
const unusedFiles = [];
|
|
8645
8713
|
for (const [index, entry] of values.entries()) {
|
|
8646
|
-
if (!isRecord$
|
|
8714
|
+
if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid unusedFiles[${index}].`);
|
|
8647
8715
|
unusedFiles.push({ path: parseString(entry.path, `unusedFiles[${index}].path`) });
|
|
8648
8716
|
}
|
|
8649
8717
|
return unusedFiles;
|
|
@@ -8652,7 +8720,7 @@ const parseUnusedExports = (value) => {
|
|
|
8652
8720
|
const values = parseArray(value, "unusedExports");
|
|
8653
8721
|
const unusedExports = [];
|
|
8654
8722
|
for (const [index, entry] of values.entries()) {
|
|
8655
|
-
if (!isRecord$
|
|
8723
|
+
if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid unusedExports[${index}].`);
|
|
8656
8724
|
unusedExports.push({
|
|
8657
8725
|
path: parseString(entry.path, `unusedExports[${index}].path`),
|
|
8658
8726
|
name: parseString(entry.name, `unusedExports[${index}].name`),
|
|
@@ -8667,7 +8735,7 @@ const parseUnusedDependencies = (value) => {
|
|
|
8667
8735
|
const values = parseArray(value, "unusedDependencies");
|
|
8668
8736
|
const unusedDependencies = [];
|
|
8669
8737
|
for (const [index, entry] of values.entries()) {
|
|
8670
|
-
if (!isRecord$
|
|
8738
|
+
if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid unusedDependencies[${index}].`);
|
|
8671
8739
|
unusedDependencies.push({
|
|
8672
8740
|
name: parseString(entry.name, `unusedDependencies[${index}].name`),
|
|
8673
8741
|
isDevDependency: parseBoolean(entry.isDevDependency, `unusedDependencies[${index}].isDevDependency`)
|
|
@@ -8679,13 +8747,13 @@ const parseCircularDependencies = (value) => {
|
|
|
8679
8747
|
const values = parseArray(value, "circularDependencies");
|
|
8680
8748
|
const circularDependencies = [];
|
|
8681
8749
|
for (const [index, entry] of values.entries()) {
|
|
8682
|
-
if (!isRecord$
|
|
8750
|
+
if (!isRecord$2(entry)) throw new Error(`Dead-code worker returned invalid circularDependencies[${index}].`);
|
|
8683
8751
|
circularDependencies.push({ files: parseStringArray(entry.files, `circularDependencies[${index}].files`) });
|
|
8684
8752
|
}
|
|
8685
8753
|
return circularDependencies;
|
|
8686
8754
|
};
|
|
8687
8755
|
const parseDeadCodeWorkerResult = (value) => {
|
|
8688
|
-
if (!isRecord$
|
|
8756
|
+
if (!isRecord$2(value)) throw new Error("Dead-code worker returned an invalid result.");
|
|
8689
8757
|
return {
|
|
8690
8758
|
unusedFiles: parseUnusedFiles(value.unusedFiles),
|
|
8691
8759
|
unusedExports: parseUnusedExports(value.unusedExports),
|
|
@@ -8694,7 +8762,7 @@ const parseDeadCodeWorkerResult = (value) => {
|
|
|
8694
8762
|
};
|
|
8695
8763
|
};
|
|
8696
8764
|
const parseDeadCodeWorkerError = (value) => {
|
|
8697
|
-
if (!isRecord$
|
|
8765
|
+
if (!isRecord$2(value) || typeof value.message !== "string") return { message: "Dead-code worker failed." };
|
|
8698
8766
|
return {
|
|
8699
8767
|
...typeof value.name === "string" ? { name: value.name } : {},
|
|
8700
8768
|
message: value.message,
|
|
@@ -8702,7 +8770,7 @@ const parseDeadCodeWorkerError = (value) => {
|
|
|
8702
8770
|
};
|
|
8703
8771
|
};
|
|
8704
8772
|
const parseDeadCodeWorkerMessage = (value) => {
|
|
8705
|
-
if (!isRecord$
|
|
8773
|
+
if (!isRecord$2(value)) throw new Error("Dead-code worker returned an invalid message.");
|
|
8706
8774
|
if (value.ok === true) return {
|
|
8707
8775
|
ok: true,
|
|
8708
8776
|
result: value.result
|
|
@@ -8802,9 +8870,11 @@ const checkDeadCode = async (options) => {
|
|
|
8802
8870
|
const { userConfig } = options;
|
|
8803
8871
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
8804
8872
|
if (!fs.existsSync(path.join(rootDirectory, "package.json"))) return [];
|
|
8873
|
+
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
8805
8874
|
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory, userConfig);
|
|
8806
8875
|
const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
|
|
8807
8876
|
rootDirectory,
|
|
8877
|
+
entryPatterns,
|
|
8808
8878
|
tsConfigPath: resolveTsConfigPath(rootDirectory),
|
|
8809
8879
|
ignorePatterns,
|
|
8810
8880
|
deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js")
|
|
@@ -9878,6 +9948,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
9878
9948
|
settings: { "react-doctor": {
|
|
9879
9949
|
framework: project.framework,
|
|
9880
9950
|
rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
|
|
9951
|
+
...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
|
|
9881
9952
|
...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
|
|
9882
9953
|
} },
|
|
9883
9954
|
rules: {
|
|
@@ -11947,7 +12018,7 @@ const makeNoopConsole = () => ({
|
|
|
11947
12018
|
});
|
|
11948
12019
|
//#endregion
|
|
11949
12020
|
//#region src/cli/utils/version.ts
|
|
11950
|
-
const VERSION = "0.2.18-dev.
|
|
12021
|
+
const VERSION = "0.2.18-dev.eba20ae";
|
|
11951
12022
|
//#endregion
|
|
11952
12023
|
//#region src/cli/utils/json-mode.ts
|
|
11953
12024
|
let context = null;
|
|
@@ -12305,13 +12376,13 @@ const isDevVersion = (version) => version === "0.0.0" || version.includes("-");
|
|
|
12305
12376
|
* uploads source-map artifacts under, so stack frames symbolicate. Honors the
|
|
12306
12377
|
* standard `SENTRY_RELEASE` override.
|
|
12307
12378
|
*/
|
|
12308
|
-
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.
|
|
12379
|
+
const resolveSentryRelease = () => process.env.SENTRY_RELEASE || `react-doctor@0.2.18-dev.eba20ae`;
|
|
12309
12380
|
/**
|
|
12310
12381
|
* Deployment environment shown in Sentry's environment filter. Defaults to
|
|
12311
12382
|
* `production` for tagged releases and `development` for dev/unbuilt versions,
|
|
12312
12383
|
* overridable via the standard `SENTRY_ENVIRONMENT` env var.
|
|
12313
12384
|
*/
|
|
12314
|
-
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.
|
|
12385
|
+
const resolveSentryEnvironment = () => process.env.SENTRY_ENVIRONMENT || (isDevVersion("0.2.18-dev.eba20ae") ? "development" : "production");
|
|
12315
12386
|
/**
|
|
12316
12387
|
* Performance-tracing sample rate in `[0, 1]`. Reads `SENTRY_TRACES_SAMPLE_RATE`
|
|
12317
12388
|
* (set to `0` to disable tracing) and falls back to
|
|
@@ -19253,7 +19324,6 @@ const validateModeFlags = (flags) => {
|
|
|
19253
19324
|
const coercedDiff = coerceDiffValue(flags.diff);
|
|
19254
19325
|
const exclusiveModes = [flags.staged ? "--staged" : null, coercedDiff !== void 0 && coercedDiff !== false ? "--diff" : null].filter((modeName) => modeName !== null);
|
|
19255
19326
|
if (exclusiveModes.length > 1) throw new CliInputError(`Cannot combine ${exclusiveModes.join(" and ")}; pick one mode.`);
|
|
19256
|
-
if (flags.yes && flags.full) throw new CliInputError("Cannot combine --yes and --full; pick one.");
|
|
19257
19327
|
if (flags.score && flags.json) throw new CliInputError("Cannot combine --score and --json; pick one output mode.");
|
|
19258
19328
|
if (flags.score && flags.telemetry === false) throw new CliInputError("Cannot combine --score with --no-telemetry; --score prints the score that --no-telemetry disables.");
|
|
19259
19329
|
if (flags.prComment && (flags.json || flags.score)) throw new CliInputError("--pr-comment cannot be combined with --json or --score.");
|
|
@@ -20442,4 +20512,4 @@ program.parseAsync(argv).then(() => flushSentry()).catch(async (error) => {
|
|
|
20442
20512
|
export {};
|
|
20443
20513
|
|
|
20444
20514
|
//# sourceMappingURL=cli.js.map
|
|
20445
|
-
//# debugId=
|
|
20515
|
+
//# debugId=32d58bb2-956f-5f5d-9f5b-3c3e922c17d2
|
package/dist/index.d.ts
CHANGED
|
@@ -407,6 +407,15 @@ interface ProjectInfo {
|
|
|
407
407
|
* rule) and the ported expo-doctor checks.
|
|
408
408
|
*/
|
|
409
409
|
expoVersion: string | null;
|
|
410
|
+
/**
|
|
411
|
+
* The declared `@shopify/flash-list` package version spec, or `null` when
|
|
412
|
+
* absent. FlashList v2 removed the need for `estimatedItemSize`, so this
|
|
413
|
+
* lets the RN list sizing rule stay scoped to versions where the prop is
|
|
414
|
+
* still useful.
|
|
415
|
+
*/
|
|
416
|
+
shopifyFlashListVersion: string | null;
|
|
417
|
+
/** Parsed major from `shopifyFlashListVersion`, or `null` when absent/unparseable. */
|
|
418
|
+
shopifyFlashListMajorVersion: number | null;
|
|
410
419
|
/**
|
|
411
420
|
* `true` when the project (or any of its workspace packages) declares
|
|
412
421
|
* `react-native-reanimated`. Lets diagnostics surface reanimated's
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ee53eb02-91ef-5d50-b736-4734e9a14f5d")}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";
|
|
@@ -2919,6 +2919,23 @@ const getExpoDependencySpec = (packageJson) => {
|
|
|
2919
2919
|
return typeof spec === "string" ? spec : null;
|
|
2920
2920
|
};
|
|
2921
2921
|
const findExpoVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getExpoDependencySpec);
|
|
2922
|
+
const SHOPIFY_FLASH_LIST_PACKAGE_NAME = "@shopify/flash-list";
|
|
2923
|
+
const getShopifyFlashListDependencySpec = (packageJson) => {
|
|
2924
|
+
const spec = packageJson.dependencies?.["@shopify/flash-list"] ?? packageJson.devDependencies?.["@shopify/flash-list"] ?? packageJson.peerDependencies?.["@shopify/flash-list"] ?? packageJson.optionalDependencies?.["@shopify/flash-list"];
|
|
2925
|
+
return typeof spec === "string" ? spec : null;
|
|
2926
|
+
};
|
|
2927
|
+
const findShopifyFlashListVersion = (rootDirectory, rootPackageJson) => findInWorkspacePackageJsons(rootDirectory, rootPackageJson, getShopifyFlashListDependencySpec);
|
|
2928
|
+
const resolveCatalogBackedDependencyVersion = ({ rootDirectory, rootPackageJson, packageName, version }) => {
|
|
2929
|
+
if (version === null || !isCatalogReference(version)) return version;
|
|
2930
|
+
const catalogName = extractCatalogName(version);
|
|
2931
|
+
const resolvedLocalVersion = resolveCatalogVersion(rootPackageJson, packageName, rootDirectory, catalogName);
|
|
2932
|
+
if (resolvedLocalVersion) return resolvedLocalVersion;
|
|
2933
|
+
const monorepoRoot = findMonorepoRoot(rootDirectory);
|
|
2934
|
+
if (!monorepoRoot) return version;
|
|
2935
|
+
const monorepoPackageJsonPath = path.join(monorepoRoot, "package.json");
|
|
2936
|
+
if (!isFile(monorepoPackageJsonPath)) return version;
|
|
2937
|
+
return resolveCatalogVersion(readPackageJson(monorepoPackageJsonPath), packageName, monorepoRoot, catalogName) ?? version;
|
|
2938
|
+
};
|
|
2922
2939
|
const getPreactVersion = (packageJson) => {
|
|
2923
2940
|
return {
|
|
2924
2941
|
...packageJson.peerDependencies,
|
|
@@ -3158,19 +3175,18 @@ const discoverProject = (directory) => {
|
|
|
3158
3175
|
const hasTypeScript = fs.existsSync(path.join(directory, "tsconfig.json"));
|
|
3159
3176
|
const sourceFileCount = countSourceFiles(directory);
|
|
3160
3177
|
const hasReactNativeWorkspace = framework === "expo" || framework === "react-native" || hasReactNativeWorkspaceAnywhere(directory, packageJson);
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
}
|
|
3178
|
+
const expoVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
|
|
3179
|
+
rootDirectory: directory,
|
|
3180
|
+
rootPackageJson: packageJson,
|
|
3181
|
+
packageName: "expo",
|
|
3182
|
+
version: findExpoVersion(directory, packageJson)
|
|
3183
|
+
}) : null;
|
|
3184
|
+
const shopifyFlashListVersion = hasReactNativeWorkspace ? resolveCatalogBackedDependencyVersion({
|
|
3185
|
+
rootDirectory: directory,
|
|
3186
|
+
rootPackageJson: packageJson,
|
|
3187
|
+
packageName: SHOPIFY_FLASH_LIST_PACKAGE_NAME,
|
|
3188
|
+
version: findShopifyFlashListVersion(directory, packageJson)
|
|
3189
|
+
}) : null;
|
|
3174
3190
|
const hasReanimated = hasReactNativeWorkspace && someWorkspacePackageJson(directory, packageJson, isPackageJsonReanimatedAware);
|
|
3175
3191
|
const preactVersion = getPreactVersion(packageJson);
|
|
3176
3192
|
const projectInfo = {
|
|
@@ -3189,6 +3205,8 @@ const discoverProject = (directory) => {
|
|
|
3189
3205
|
preactMajorVersion: parseReactMajor(preactVersion),
|
|
3190
3206
|
hasReactNativeWorkspace,
|
|
3191
3207
|
expoVersion,
|
|
3208
|
+
shopifyFlashListVersion,
|
|
3209
|
+
shopifyFlashListMajorVersion: shopifyFlashListVersion === null ? null : getLowestDependencyMajor(shopifyFlashListVersion),
|
|
3192
3210
|
hasReanimated,
|
|
3193
3211
|
sourceFileCount
|
|
3194
3212
|
};
|
|
@@ -5454,6 +5472,63 @@ const collectIgnorePatterns = (rootDirectory) => {
|
|
|
5454
5472
|
cachedPatternsByRoot.set(rootDirectory, patterns);
|
|
5455
5473
|
return patterns;
|
|
5456
5474
|
};
|
|
5475
|
+
const KNIP_JSON_FILENAME = "knip.json";
|
|
5476
|
+
const isRecord$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5477
|
+
const readJsonFileSafe = (filePath) => {
|
|
5478
|
+
let rawContents;
|
|
5479
|
+
try {
|
|
5480
|
+
rawContents = fs.readFileSync(filePath, "utf-8");
|
|
5481
|
+
} catch {
|
|
5482
|
+
return null;
|
|
5483
|
+
}
|
|
5484
|
+
try {
|
|
5485
|
+
return JSON.parse(rawContents);
|
|
5486
|
+
} catch {
|
|
5487
|
+
return null;
|
|
5488
|
+
}
|
|
5489
|
+
};
|
|
5490
|
+
const readKnipConfig = (rootDirectory) => {
|
|
5491
|
+
const knipJson = readJsonFileSafe(path.join(rootDirectory, KNIP_JSON_FILENAME));
|
|
5492
|
+
if (isRecord$1(knipJson)) return knipJson;
|
|
5493
|
+
const packageJson = readJsonFileSafe(path.join(rootDirectory, "package.json"));
|
|
5494
|
+
const packageKnipConfig = isRecord$1(packageJson) ? packageJson.knip : null;
|
|
5495
|
+
return isRecord$1(packageKnipConfig) ? packageKnipConfig : null;
|
|
5496
|
+
};
|
|
5497
|
+
const normalizePatternList = (value) => {
|
|
5498
|
+
if (typeof value === "string" && value.length > 0) return [value];
|
|
5499
|
+
if (!Array.isArray(value)) return [];
|
|
5500
|
+
return value.filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
5501
|
+
};
|
|
5502
|
+
const prefixWorkspacePatterns = (workspacePattern, patterns) => {
|
|
5503
|
+
const normalizedWorkspacePattern = workspacePattern.replace(/\/+$/, "");
|
|
5504
|
+
return patterns.map((pattern) => pattern.startsWith("!") ? `!${normalizedWorkspacePattern}/${pattern.slice(1)}` : `${normalizedWorkspacePattern}/${pattern}`);
|
|
5505
|
+
};
|
|
5506
|
+
const collectKnipWorkspacePatterns = (workspaces, settingName) => {
|
|
5507
|
+
if (!isRecord$1(workspaces)) return [];
|
|
5508
|
+
const patterns = [];
|
|
5509
|
+
for (const [workspacePattern, workspaceConfig] of Object.entries(workspaces)) {
|
|
5510
|
+
if (!isRecord$1(workspaceConfig)) continue;
|
|
5511
|
+
patterns.push(...prefixWorkspacePatterns(workspacePattern, normalizePatternList(workspaceConfig[settingName])));
|
|
5512
|
+
}
|
|
5513
|
+
return patterns;
|
|
5514
|
+
};
|
|
5515
|
+
const collectKnipPatterns = (rootDirectory, settingName) => {
|
|
5516
|
+
const config = readKnipConfig(rootDirectory);
|
|
5517
|
+
if (!config) return [];
|
|
5518
|
+
return [...normalizePatternList(config[settingName]), ...collectKnipWorkspacePatterns(config.workspaces, settingName)];
|
|
5519
|
+
};
|
|
5520
|
+
const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
|
|
5521
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5522
|
+
const sources = [
|
|
5523
|
+
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
5524
|
+
collectIgnorePatterns(rootDirectory),
|
|
5525
|
+
userConfig?.ignore?.files ?? [],
|
|
5526
|
+
collectKnipPatterns(rootDirectory, "ignore")
|
|
5527
|
+
];
|
|
5528
|
+
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
5529
|
+
return [...seen].filter((pattern) => pattern.length > 0);
|
|
5530
|
+
};
|
|
5531
|
+
const collectDeadCodeEntryPatterns = (rootDirectory) => [...new Set(collectKnipPatterns(rootDirectory, "entry"))].filter((pattern) => pattern.length > 0);
|
|
5457
5532
|
/**
|
|
5458
5533
|
* Resolves a path to its canonical, symlink-free form, falling back to
|
|
5459
5534
|
* the input when it cannot be realpath'd (broken symlink, permission
|
|
@@ -5479,6 +5554,7 @@ const toCanonicalPath = (filePath) => {
|
|
|
5479
5554
|
const DEAD_CODE_PLUGIN = "deslop";
|
|
5480
5555
|
const DEAD_CODE_CATEGORY = "Maintainability";
|
|
5481
5556
|
const TSCONFIG_FILENAMES$1 = ["tsconfig.json", "tsconfig.base.json"];
|
|
5557
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5482
5558
|
const DEAD_CODE_WORKER_SCRIPT = `
|
|
5483
5559
|
const inputChunks = [];
|
|
5484
5560
|
process.stdin.on("data", (chunk) => inputChunks.push(chunk));
|
|
@@ -5519,6 +5595,9 @@ process.stdin.on("end", () => {
|
|
|
5519
5595
|
const { analyze, defineConfig } = await import(workerInput.deslopJsModuleSpecifier);
|
|
5520
5596
|
const config = {
|
|
5521
5597
|
rootDir: workerInput.rootDirectory,
|
|
5598
|
+
...(workerInput.entryPatterns.length > 0
|
|
5599
|
+
? { entryPatterns: workerInput.entryPatterns }
|
|
5600
|
+
: {}),
|
|
5522
5601
|
...(workerInput.tsConfigPath ? { tsConfigPath: workerInput.tsConfigPath } : {}),
|
|
5523
5602
|
...(workerInput.ignorePatterns.length > 0
|
|
5524
5603
|
? { ignorePatterns: workerInput.ignorePatterns }
|
|
@@ -5538,21 +5617,10 @@ const resolveTsConfigPath = (rootDirectory) => {
|
|
|
5538
5617
|
if (fs.existsSync(candidate)) return candidate;
|
|
5539
5618
|
}
|
|
5540
5619
|
};
|
|
5541
|
-
const collectDeadCodeIgnorePatterns = (rootDirectory, userConfig) => {
|
|
5542
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5543
|
-
const sources = [
|
|
5544
|
-
readIgnoreFile(path.join(rootDirectory, ".gitignore")),
|
|
5545
|
-
collectIgnorePatterns(rootDirectory),
|
|
5546
|
-
userConfig?.ignore?.files ?? []
|
|
5547
|
-
];
|
|
5548
|
-
for (const source of sources) for (const pattern of source) seen.add(pattern);
|
|
5549
|
-
return [...seen].filter((pattern) => pattern.length > 0);
|
|
5550
|
-
};
|
|
5551
5620
|
const toRelativeFilePath = (rootDirectory, filePath) => {
|
|
5552
5621
|
const relative = toRelativePath(filePath, rootDirectory);
|
|
5553
5622
|
return relative.length > 0 ? relative : filePath.replace(/\\/g, "/");
|
|
5554
5623
|
};
|
|
5555
|
-
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5556
5624
|
const parseArray = (value, label) => {
|
|
5557
5625
|
if (!Array.isArray(value)) throw new Error(`Dead-code worker returned invalid ${label}.`);
|
|
5558
5626
|
return value;
|
|
@@ -5735,9 +5803,11 @@ const checkDeadCode = async (options) => {
|
|
|
5735
5803
|
const { userConfig } = options;
|
|
5736
5804
|
const rootDirectory = toCanonicalPath(options.rootDirectory);
|
|
5737
5805
|
if (!fs.existsSync(path.join(rootDirectory, "package.json"))) return [];
|
|
5806
|
+
const entryPatterns = collectDeadCodeEntryPatterns(rootDirectory);
|
|
5738
5807
|
const ignorePatterns = collectDeadCodeIgnorePatterns(rootDirectory, userConfig);
|
|
5739
5808
|
const result = parseDeadCodeWorkerResult(await runDeadCodeWorkerWithTimeout((options.createWorker ?? createDeadCodeWorker)({
|
|
5740
5809
|
rootDirectory,
|
|
5810
|
+
entryPatterns,
|
|
5741
5811
|
tsConfigPath: resolveTsConfigPath(rootDirectory),
|
|
5742
5812
|
ignorePatterns,
|
|
5743
5813
|
deslopJsModuleSpecifier: options.deslopJsModuleSpecifier ?? import.meta.resolve("deslop-js")
|
|
@@ -6811,6 +6881,7 @@ const createOxlintConfig = ({ pluginPath, project, customRulesOnly = false, exte
|
|
|
6811
6881
|
settings: { "react-doctor": {
|
|
6812
6882
|
framework: project.framework,
|
|
6813
6883
|
rootDirectory: resolveSettingsRootDirectory(project.rootDirectory),
|
|
6884
|
+
...project.shopifyFlashListMajorVersion !== null ? { shopifyFlashListMajorVersion: project.shopifyFlashListMajorVersion } : {},
|
|
6814
6885
|
...serverAuthFunctionNames && serverAuthFunctionNames.length > 0 ? { serverAuthFunctionNames: [...serverAuthFunctionNames] } : {}
|
|
6815
6886
|
} },
|
|
6816
6887
|
rules: {
|
|
@@ -8729,4 +8800,4 @@ const toJsonReport = (result, options) => buildJsonReport({
|
|
|
8729
8800
|
export { AmbiguousProjectError, NoReactDependencyError, NotADirectoryError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isProjectDiscoveryError, isReactDoctorError, summarizeDiagnostics, toJsonReport };
|
|
8730
8801
|
|
|
8731
8802
|
//# sourceMappingURL=index.js.map
|
|
8732
|
-
//# debugId=
|
|
8803
|
+
//# debugId=ee53eb02-91ef-5d50-b736-4734e9a14f5d
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-doctor",
|
|
3
|
-
"version": "0.2.18-dev.
|
|
3
|
+
"version": "0.2.18-dev.eba20ae",
|
|
4
4
|
"description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accessibility",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"agent-install": "0.0.5",
|
|
56
56
|
"conf": "^15.1.0",
|
|
57
57
|
"confbox": "^0.2.4",
|
|
58
|
-
"deslop-js": "^0.0.
|
|
58
|
+
"deslop-js": "^0.0.17",
|
|
59
59
|
"effect": "4.0.0-beta.70",
|
|
60
60
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
61
61
|
"jiti": "^2.7.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"oxlint": "^1.66.0",
|
|
64
64
|
"prompts": "^2.4.2",
|
|
65
65
|
"typescript": ">=5.0.4 <7",
|
|
66
|
-
"oxlint-plugin-react-doctor": "0.2.18-dev.
|
|
66
|
+
"oxlint-plugin-react-doctor": "0.2.18-dev.eba20ae"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/babel__code-frame": "^7.27.0",
|