react-doctor 0.2.0-beta.1 → 0.2.0-beta.2

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.
@@ -0,0 +1,16 @@
1
+ import { buildJsonReport, buildJsonReportError, filterSourceFiles, getDiffInfo, summarizeDiagnostics } from "@react-doctor/core";
2
+ import { AmbiguousProjectError, NoReactDependencyError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, isReactDoctorError } from "@react-doctor/project-info";
3
+ import { DiagnoseOptions, DiagnoseResult, Diagnostic, DiffInfo, JsonReport, JsonReportDiffInfo, JsonReportError, JsonReportMode, JsonReportProjectEntry, JsonReportSummary, ProjectInfo, ReactDoctorConfig, ScoreResult } from "@react-doctor/types";
4
+
5
+ //#region src/index.d.ts
6
+ declare const clearCaches: () => void;
7
+ interface ToJsonReportOptions {
8
+ version: string;
9
+ directory?: string;
10
+ mode?: JsonReportMode;
11
+ }
12
+ declare const toJsonReport: (result: DiagnoseResult, options: ToJsonReportOptions) => JsonReport;
13
+ declare const diagnose: (directory: string, options?: DiagnoseOptions) => Promise<DiagnoseResult>;
14
+ //#endregion
15
+ export { AmbiguousProjectError, type DiagnoseOptions, type DiagnoseResult, type Diagnostic, type DiffInfo, type JsonReport, type JsonReportDiffInfo, type JsonReportError, type JsonReportMode, type JsonReportProjectEntry, type JsonReportSummary, NoReactDependencyError, PackageJsonNotFoundError, type ProjectInfo, ProjectNotFoundError, type ReactDoctorConfig, ReactDoctorError, type ScoreResult, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isReactDoctorError, summarizeDiagnostics, toJsonReport };
16
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,77 @@
1
+ import path from "node:path";
2
+ import { buildJsonReport, buildJsonReportError, calculateScore, clearAutoSuppressionCaches, clearConfigCache, clearIgnorePatternsCache, combineDiagnostics, computeJsxIncludePaths, createNodeReadFileLinesSync, filterSourceFiles, getDiffInfo, loadConfigWithSource, resolveConfigRootDir, resolveDiagnoseTarget, resolveLintIncludePaths, runOxlint, summarizeDiagnostics } from "@react-doctor/core";
3
+ import { AmbiguousProjectError, NoReactDependencyError, NoReactDependencyError as NoReactDependencyError$1, PackageJsonNotFoundError, ProjectNotFoundError, ProjectNotFoundError as ProjectNotFoundError$1, ReactDoctorError, clearPackageJsonCache, clearProjectCache, discoverProject, isReactDoctorError } from "@react-doctor/project-info";
4
+ //#region src/index.ts
5
+ const clearCaches = () => {
6
+ clearProjectCache();
7
+ clearConfigCache();
8
+ clearPackageJsonCache();
9
+ clearIgnorePatternsCache();
10
+ clearAutoSuppressionCaches();
11
+ };
12
+ const toJsonReport = (result, options) => buildJsonReport({
13
+ version: options.version,
14
+ directory: options.directory ?? result.project.rootDirectory,
15
+ mode: options.mode ?? "full",
16
+ diff: null,
17
+ scans: [{
18
+ directory: result.project.rootDirectory,
19
+ result: {
20
+ diagnostics: result.diagnostics,
21
+ score: result.score,
22
+ skippedChecks: [],
23
+ project: result.project,
24
+ elapsedMilliseconds: result.elapsedMilliseconds
25
+ }
26
+ }],
27
+ totalElapsedMilliseconds: result.elapsedMilliseconds
28
+ });
29
+ const EMPTY_DIAGNOSTICS = [];
30
+ const diagnose = async (directory, options = {}) => {
31
+ const startTime = globalThis.performance.now();
32
+ const requestedDirectory = path.resolve(directory);
33
+ const initialLoadedConfig = loadConfigWithSource(requestedDirectory);
34
+ const directoryAfterRedirect = resolveConfigRootDir(initialLoadedConfig?.config ?? null, initialLoadedConfig?.sourceDirectory ?? null) ?? requestedDirectory;
35
+ const resolvedDirectory = resolveDiagnoseTarget(directoryAfterRedirect);
36
+ if (!resolvedDirectory) throw new ProjectNotFoundError$1(directoryAfterRedirect);
37
+ const userConfig = initialLoadedConfig?.config ?? loadConfigWithSource(resolvedDirectory)?.config ?? null;
38
+ const includePaths = options.includePaths ?? [];
39
+ const isDiffMode = includePaths.length > 0;
40
+ const projectInfo = discoverProject(resolvedDirectory);
41
+ if (!projectInfo.reactVersion) throw new NoReactDependencyError$1(resolvedDirectory);
42
+ const lintIncludePaths = computeJsxIncludePaths(includePaths) ?? resolveLintIncludePaths(resolvedDirectory, userConfig);
43
+ const readFileLinesSync = createNodeReadFileLinesSync(resolvedDirectory);
44
+ const effectiveLint = options.lint ?? userConfig?.lint ?? true;
45
+ const effectiveRespectInlineDisables = options.respectInlineDisables ?? userConfig?.respectInlineDisables ?? true;
46
+ const ignoredTags = new Set(userConfig?.ignore?.tags ?? []);
47
+ const diagnostics = combineDiagnostics({
48
+ lintDiagnostics: effectiveLint ? await runOxlint({
49
+ rootDirectory: resolvedDirectory,
50
+ project: projectInfo,
51
+ includePaths: lintIncludePaths,
52
+ customRulesOnly: userConfig?.customRulesOnly ?? false,
53
+ respectInlineDisables: effectiveRespectInlineDisables,
54
+ adoptExistingLintConfig: userConfig?.adoptExistingLintConfig ?? true,
55
+ ignoredTags
56
+ }).catch((error) => {
57
+ console.error("Lint failed:", error);
58
+ return EMPTY_DIAGNOSTICS;
59
+ }) : EMPTY_DIAGNOSTICS,
60
+ directory: resolvedDirectory,
61
+ isDiffMode,
62
+ userConfig,
63
+ readFileLinesSync,
64
+ respectInlineDisables: effectiveRespectInlineDisables
65
+ });
66
+ const elapsedMilliseconds = globalThis.performance.now() - startTime;
67
+ return {
68
+ diagnostics,
69
+ score: await calculateScore(diagnostics),
70
+ project: projectInfo,
71
+ elapsedMilliseconds
72
+ };
73
+ };
74
+ //#endregion
75
+ export { AmbiguousProjectError, NoReactDependencyError, PackageJsonNotFoundError, ProjectNotFoundError, ReactDoctorError, buildJsonReport, buildJsonReportError, clearCaches, diagnose, filterSourceFiles, getDiffInfo, isReactDoctorError, summarizeDiagnostics, toJsonReport };
76
+
77
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "react-doctor",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.2",
4
4
  "description": "Diagnose and fix React codebases for security, performance, correctness, accessibility, bundle-size, and architecture issues",
5
5
  "keywords": [
6
6
  "accessibility",
7
7
  "diagnostics",
8
- "knip",
9
8
  "linter",
10
9
  "nextjs",
11
10
  "oxlint",
@@ -41,51 +40,50 @@
41
40
  "sideEffects": false,
42
41
  "exports": {
43
42
  ".": {
44
- "types": "./dist/sdk.d.ts",
45
- "default": "./dist/sdk.js"
43
+ "types": "./dist/cli.d.ts",
44
+ "default": "./dist/cli.js"
46
45
  },
47
46
  "./api": {
48
- "types": "./dist/compat.d.ts",
49
- "default": "./dist/compat.js"
50
- },
51
- "./score": {
52
- "types": "./dist/score.d.ts",
53
- "default": "./dist/score.js"
54
- },
55
- "./eslint-plugin": {
56
- "types": "./dist/eslint-plugin.d.ts",
57
- "default": "./dist/eslint-plugin.js"
58
- },
59
- "./oxlint-plugin": {
60
- "types": "./dist/oxlint-plugin.d.ts",
61
- "default": "./dist/oxlint-plugin.js"
47
+ "types": "./dist/index.d.ts",
48
+ "default": "./dist/index.js"
62
49
  }
63
50
  },
64
51
  "dependencies": {
65
52
  "agent-install": "0.0.5",
66
53
  "commander": "^14.0.3",
67
- "eslint-plugin-react-hooks": "^7.1.1",
68
54
  "ora": "^9.4.0",
69
- "oxc-parser": "^0.130.0",
70
- "oxc-resolver": "^11.19.1",
71
55
  "oxlint": "^1.63.0",
72
56
  "picocolors": "^1.1.1",
73
- "prompts": "^2.4.2"
57
+ "prompts": "^2.4.2",
58
+ "typescript": ">=5.0.4 <7"
74
59
  },
75
60
  "devDependencies": {
76
- "@oxc-project/types": "^0.130.0",
77
- "@types/node": "^25.6.0",
78
61
  "@types/prompts": "^2.4.9",
79
- "vite-plus": "^0.1.15"
62
+ "eslint-plugin-react-hooks": "^7.1.1",
63
+ "eslint-plugin-react-you-might-not-need-an-effect": "^0.10.1",
64
+ "@react-doctor/core": "0.2.0-beta.2",
65
+ "@react-doctor/project-info": "0.2.0-beta.2",
66
+ "@react-doctor/types": "0.2.0-beta.2"
67
+ },
68
+ "peerDependencies": {
69
+ "eslint-plugin-react-hooks": "^6 || ^7",
70
+ "eslint-plugin-react-you-might-not-need-an-effect": "^0.10"
71
+ },
72
+ "peerDependenciesMeta": {
73
+ "eslint-plugin-react-hooks": {
74
+ "optional": true
75
+ },
76
+ "eslint-plugin-react-you-might-not-need-an-effect": {
77
+ "optional": true
78
+ }
80
79
  },
81
80
  "engines": {
82
- "node": ">=22.12.0"
81
+ "node": ">=22"
83
82
  },
84
83
  "scripts": {
85
84
  "dev": "vp pack --watch",
86
85
  "build": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && NODE_ENV=production vp pack",
87
86
  "typecheck": "tsc --noEmit",
88
- "test": "vp test run",
89
- "test:regression": "node --experimental-strip-types --no-warnings scripts/run-regression.ts"
87
+ "test": "vp test run"
90
88
  }
91
89
  }