@geoql/doctor-core 0.1.0-alpha.0 → 0.1.0

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
@@ -1,6 +1,81 @@
1
+ //#region src/score.d.ts
2
+ interface ScoreBreakdownEntry {
3
+ ruleId: string;
4
+ occurrences: number;
5
+ weightPerOccurrence: number;
6
+ penalty: number;
7
+ }
8
+ interface ScoreResult {
9
+ score: number;
10
+ passed: boolean;
11
+ threshold: number;
12
+ totalFindings: number;
13
+ errorCount: number;
14
+ warnCount: number;
15
+ infoCount: number;
16
+ breakdown: ScoreBreakdownEntry[];
17
+ }
18
+ interface ScoreConfig {
19
+ rules?: Record<string, {
20
+ weight?: number;
21
+ }>;
22
+ threshold?: number;
23
+ }
24
+ declare function scoreDiagnostics(diagnostics: Diagnostic[], config?: ScoreConfig): ScoreResult;
25
+ //#endregion
26
+ //#region src/types/project-info.d.ts
27
+ type Framework = 'vue' | 'nuxt' | 'unknown';
28
+ type Capability = string;
29
+ type MonorepoKind = 'pnpm' | 'yarn' | 'npm' | 'turbo' | null;
30
+ interface ProjectInfo {
31
+ readonly framework: Framework;
32
+ readonly rootDirectory: string;
33
+ readonly packageJsonPath: string | null;
34
+ readonly vueVersion: string | null;
35
+ readonly nuxtVersion: string | null;
36
+ readonly typescriptVersion: string | null;
37
+ readonly hasAutoImports: boolean;
38
+ readonly hasComponentsAutoImport: boolean;
39
+ readonly hasPinia: boolean;
40
+ readonly hasVueRouter: boolean;
41
+ readonly nitroPreset: string | null;
42
+ readonly nuxtCompatibilityVersion: 3 | 4 | null;
43
+ readonly monorepoKind: MonorepoKind;
44
+ readonly nuxtConfigPath: string | null;
45
+ readonly hasAppDir: boolean;
46
+ readonly appDirPath: string | null;
47
+ readonly hasServerDir: boolean;
48
+ readonly hasPagesDir: boolean;
49
+ readonly hasWranglerConfig: boolean;
50
+ readonly capabilities: ReadonlySet<Capability>;
51
+ }
52
+ //#endregion
53
+ //#region src/reporters/types.d.ts
54
+ interface ProjectInfoLite {
55
+ readonly framework: Framework;
56
+ readonly vueVersion: string | null;
57
+ readonly nuxtVersion: string | null;
58
+ readonly capabilities: readonly string[];
59
+ readonly rootDirectory: string;
60
+ }
61
+ interface ReporterInput {
62
+ readonly toolName: string;
63
+ readonly toolVersion: string;
64
+ readonly rootDirectory: string;
65
+ readonly analyzedFileCount: number;
66
+ readonly elapsedMs: number;
67
+ readonly diagnostics: readonly Diagnostic[];
68
+ readonly score: ScoreResult;
69
+ readonly projectInfo: ProjectInfoLite;
70
+ }
71
+ interface ReporterOptions {
72
+ readonly color?: boolean;
73
+ readonly quiet?: boolean;
74
+ }
75
+ //#endregion
1
76
  //#region src/types.d.ts
2
- type Severity = 'error' | 'warning';
3
- type DiagnosticSource = 'template' | 'oxlint';
77
+ type Severity = 'error' | 'warn' | 'info';
78
+ type DiagnosticSource = 'template' | 'oxlint' | 'sfc' | 'dead-code' | 'project' | 'deps';
4
79
  interface Diagnostic {
5
80
  file: string;
6
81
  line: number;
@@ -12,13 +87,26 @@ interface Diagnostic {
12
87
  message: string;
13
88
  source: DiagnosticSource;
14
89
  recommendation?: string;
90
+ codeSnippet?: string;
15
91
  }
16
92
  interface AuditConfig {
17
93
  rootDir?: string;
18
94
  include?: string[];
19
95
  exclude?: string[];
20
96
  rules?: Record<string, Severity | 'off'>;
21
- failOn?: Severity;
97
+ failOn?: 'error' | 'warn' | 'none';
98
+ deadCode?: boolean;
99
+ lint?: boolean;
100
+ threshold?: number;
101
+ scopeFiles?: string[];
102
+ respectInlineDisables?: boolean;
103
+ }
104
+ interface AuditTimings {
105
+ template: number;
106
+ sfc: number;
107
+ script: number;
108
+ deadCode: number;
109
+ total: number;
22
110
  }
23
111
  interface AuditReport {
24
112
  rootDir: string;
@@ -26,23 +114,305 @@ interface AuditReport {
26
114
  diagnostics: Diagnostic[];
27
115
  score: number;
28
116
  errorCount: number;
29
- warningCount: number;
117
+ warnCount: number;
118
+ infoCount: number;
30
119
  exitCode: 0 | 1 | 2;
120
+ scoreResult: ScoreResult;
121
+ projectInfo: ProjectInfoLite;
122
+ elapsedMs: number;
123
+ timings: AuditTimings;
124
+ ruleCounts: Record<string, number>;
31
125
  }
32
126
  //#endregion
127
+ //#region src/annotations.d.ts
128
+ declare function encodeAnnotation(diagnostic: Diagnostic): string;
129
+ declare function encodeAnnotations(diagnostics: Diagnostic[]): string;
130
+ //#endregion
33
131
  //#region src/audit.d.ts
34
132
  declare function audit(config?: AuditConfig): Promise<AuditReport>;
35
133
  //#endregion
36
- //#region src/config.d.ts
37
- interface LoadedConfig {
38
- config: AuditConfig;
134
+ //#region src/check-build-quality.d.ts
135
+ declare function checkBuildQuality(projectInfo: ProjectInfo): Promise<Diagnostic[]>;
136
+ //#endregion
137
+ //#region src/check-deps.d.ts
138
+ declare function checkDeps(projectInfo: ProjectInfo): Promise<Diagnostic[]>;
139
+ //#endregion
140
+ //#region src/config/types.d.ts
141
+ type ConfigSource = 'flag' | 'ts' | 'mjs' | 'js' | 'json' | 'package.json' | 'built-in';
142
+ interface DoctorUserConfig {
143
+ rootDir?: string;
144
+ include?: string[];
145
+ exclude?: string[];
146
+ failOn?: 'error' | 'warn' | 'none';
147
+ threshold?: number;
148
+ preset?: string;
149
+ rules?: Record<string, Severity | 'off'>;
150
+ extends?: string[];
151
+ }
152
+ /**
153
+ * Resolved + normalized config that audit consumes.
154
+ * - `rules` is the merged effective severity map (preset base + user overrides - explicit offs).
155
+ * - `preset` is the preset name that was applied as the base.
156
+ */
157
+ interface ResolvedDoctorConfig {
158
+ rootDir: string;
159
+ include: string[];
160
+ exclude: string[];
161
+ failOn: 'error' | 'warn' | 'none';
162
+ threshold: number;
163
+ rules: Record<string, Severity>;
164
+ preset: 'minimal' | 'recommended' | 'strict' | 'all';
165
+ source: ConfigSource;
39
166
  configFile?: string;
40
167
  }
41
- declare function loadAuditConfig(rootDir: string, explicitPath?: string): Promise<LoadedConfig>;
168
+ //#endregion
169
+ //#region src/dead-code/dedupe.d.ts
170
+ declare function dedupeDeadCodeAgainstLint(deadCode: Diagnostic[], lint: Diagnostic[]): Diagnostic[];
171
+ //#endregion
172
+ //#region src/dead-code/errors.d.ts
173
+ declare class DeadCodeTimeoutError extends Error {
174
+ name: "DeadCodeTimeoutError";
175
+ constructor(timeoutMs: number);
176
+ }
177
+ declare class DeadCodeImportFailed extends Error {
178
+ name: "DeadCodeImportFailed";
179
+ constructor(cause?: unknown);
180
+ }
181
+ //#endregion
182
+ //#region src/check-dead-code.d.ts
183
+ interface CheckDeadCodeOptions {
184
+ projectInfo: ProjectInfo;
185
+ doctorConfig: ResolvedDoctorConfig;
186
+ enabled: boolean;
187
+ timeoutMs?: number;
188
+ }
189
+ declare function checkDeadCode(options: CheckDeadCodeOptions): Promise<Diagnostic[]>;
190
+ //#endregion
191
+ //#region src/check-nuxt-project.d.ts
192
+ declare function checkNuxtProject(projectInfo: ProjectInfo): Promise<Diagnostic[]>;
193
+ //#endregion
194
+ //#region src/config/built-in.d.ts
195
+ declare const BUILT_IN_RECOMMENDED: Omit<ResolvedDoctorConfig, 'rootDir' | 'source' | 'configFile'>;
196
+ //#endregion
197
+ //#region src/config/merge-cli-overrides.d.ts
198
+ interface CliOverrides {
199
+ include?: string[];
200
+ exclude?: string[];
201
+ failOn?: 'error' | 'warn' | 'none';
202
+ threshold?: number;
203
+ rules?: Record<string, Severity | 'off'>;
204
+ }
205
+ declare function mergeCliOverrides(resolved: ResolvedDoctorConfig, cli: CliOverrides): ResolvedDoctorConfig;
206
+ //#endregion
207
+ //#region src/config/errors.d.ts
208
+ declare class ConfigFileNotFoundError extends Error {
209
+ name: "ConfigFileNotFoundError";
210
+ constructor(path: string);
211
+ }
212
+ declare class ConfigCycleError extends Error {
213
+ name: "ConfigCycleError";
214
+ constructor(chain: string[]);
215
+ }
216
+ declare class InvalidConfigError extends Error {
217
+ name: "InvalidConfigError";
218
+ }
219
+ //#endregion
220
+ //#region src/config/define-config.d.ts
221
+ declare function defineConfig<T extends DoctorUserConfig>(config: T): T;
222
+ //#endregion
223
+ //#region src/config/load.d.ts
224
+ interface LoadDoctorConfigOptions {
225
+ readonly explicitPath?: string;
226
+ readonly presetOverride?: string;
227
+ }
228
+ declare function loadDoctorConfig(rootDir: string, explicitPathOrOptions?: string | LoadDoctorConfigOptions): Promise<ResolvedDoctorConfig>;
229
+ //#endregion
230
+ //#region src/config/validate.d.ts
231
+ declare function validateConfig(raw: unknown): void;
232
+ //#endregion
233
+ //#region src/detect-project.d.ts
234
+ declare function detectProject(rootDirectory: string): Promise<ProjectInfo>;
235
+ //#endregion
236
+ //#region src/disables/apply.d.ts
237
+ interface ApplyInlineDisablesOptions {
238
+ respect: boolean;
239
+ }
240
+ declare function applyInlineDisables(diags: Diagnostic[], opts: ApplyInlineDisablesOptions): Diagnostic[];
241
+ //#endregion
242
+ //#region src/disables/parse-directives.d.ts
243
+ interface DirectiveRange {
244
+ start: number;
245
+ end: number;
246
+ rules: string[];
247
+ }
248
+ interface DirectiveLine {
249
+ line: number;
250
+ rules: string[];
251
+ }
252
+ interface DirectiveSet {
253
+ blocks: DirectiveRange[];
254
+ nextLine: DirectiveLine[];
255
+ sameLine: DirectiveLine[];
256
+ }
257
+ declare function parseDirectives(text: string): DirectiveSet;
258
+ //#endregion
259
+ //#region src/git-scope.d.ts
260
+ type GitScopeMode = 'diff' | 'staged';
261
+ interface GitScopeOptions {
262
+ rootDir: string;
263
+ mode: GitScopeMode;
264
+ }
265
+ declare function listChangedFiles(options: GitScopeOptions): Promise<string[]>;
266
+ //#endregion
267
+ //#region src/nuxt/file-role.d.ts
268
+ /**
269
+ * True when the path points at a Nuxt page component — a `.vue` file under
270
+ * `pages/` (Nuxt 3 layout) or `app/pages/` (Nuxt 4 layout) at the project root.
271
+ */
272
+ declare function isNuxtPageFile(relPath: string): boolean;
273
+ /**
274
+ * True when the path points at a Nitro server file — a `.ts` file under the
275
+ * project-root `server/` directory.
276
+ */
277
+ declare function isNuxtServerFile(relPath: string): boolean;
278
+ /**
279
+ * True when the path points at a Nuxt layout component — a `.vue` file under
280
+ * `layouts/` (Nuxt 3 layout) or `app/layouts/` (Nuxt 4 layout) at the project
281
+ * root.
282
+ */
283
+ declare function isNuxtLayoutFile(relPath: string): boolean;
284
+ //#endregion
285
+ //#region src/nuxt/cross-file/run.d.ts
286
+ interface CrossFilePassOptions {
287
+ files: string[];
288
+ projectInfo: ProjectInfo;
289
+ }
290
+ declare function runCrossFilePass(opts: CrossFilePassOptions): Promise<Diagnostic[]>;
291
+ //#endregion
292
+ //#region src/oxlint/errors.d.ts
293
+ declare class OxlintSpawnFailed extends Error {
294
+ name: "OxlintSpawnFailed";
295
+ constructor(exitCode: number | null, stderr: string);
296
+ }
297
+ declare class OxlintOutputTooLarge extends Error {
298
+ name: "OxlintOutputTooLarge";
299
+ constructor(maxBytes: number);
300
+ }
301
+ //#endregion
302
+ //#region src/reporters/agent.d.ts
303
+ declare function agentReport(input: ReporterInput, options?: ReporterOptions): string;
304
+ //#endregion
305
+ //#region src/reporters/docs-url.d.ts
306
+ declare function docsUrl(ruleId: string): string;
307
+ //#endregion
308
+ //#region src/reporters/sarif.d.ts
309
+ declare function sarifReport(input: ReporterInput): string;
310
+ //#endregion
311
+ //#region src/reporters/verbose.d.ts
312
+ interface VerboseTraceOptions {
313
+ configSource?: ConfigSource;
314
+ }
315
+ declare function renderVerboseTrace(report: AuditReport, options: VerboseTraceOptions): string;
42
316
  //#endregion
43
317
  //#region src/reporters/index.d.ts
44
- type ReporterFormat = 'text' | 'json';
45
- declare function format(report: AuditReport, kind: ReporterFormat): string;
318
+ type ReporterFormat = 'agent' | 'pretty' | 'json' | 'json-compact' | 'sarif' | 'html';
319
+ declare function format(input: ReporterInput, kind?: ReporterFormat, options?: ReporterOptions): string;
320
+ //#endregion
321
+ //#region src/reporters/json.d.ts
322
+ declare const DOCTOR_REPORT_SCHEMA_VERSION = "1";
323
+ interface DoctorReportDiagnostic {
324
+ file: string;
325
+ line: number;
326
+ column: number;
327
+ endLine?: number;
328
+ endColumn?: number;
329
+ ruleId: string;
330
+ severity: Severity;
331
+ message: string;
332
+ source: string;
333
+ recommendation?: string;
334
+ }
335
+ interface DoctorReportBreakdownEntry {
336
+ ruleId: string;
337
+ occurrences: number;
338
+ weightPerOccurrence: number;
339
+ penalty: number;
340
+ }
341
+ interface DoctorReport {
342
+ schemaVersion: string;
343
+ tool: {
344
+ name: string;
345
+ version: string;
346
+ };
347
+ projectInfo: {
348
+ framework: string;
349
+ vueVersion: string | null;
350
+ nuxtVersion: string | null;
351
+ capabilities: string[];
352
+ rootDirectory: string;
353
+ };
354
+ score: {
355
+ value: number;
356
+ threshold: number;
357
+ passed: boolean;
358
+ bySeverity: {
359
+ error: number;
360
+ warn: number;
361
+ info: number;
362
+ };
363
+ breakdown: DoctorReportBreakdownEntry[];
364
+ };
365
+ diagnostics: DoctorReportDiagnostic[];
366
+ timing: {
367
+ elapsedMs: number;
368
+ analyzedFileCount: number;
369
+ };
370
+ }
371
+ declare function buildDoctorReport(input: ReporterInput): DoctorReport;
372
+ declare function jsonReport(input: ReporterInput): string;
373
+ //#endregion
374
+ //#region src/reporters/json-compact.d.ts
375
+ declare function jsonCompactReport(input: ReporterInput): string;
376
+ //#endregion
377
+ //#region src/reporters/pretty.d.ts
378
+ declare function prettyReport(input: ReporterInput, options?: ReporterOptions): string;
379
+ //#endregion
380
+ //#region src/rule-docs.d.ts
381
+ interface RuleDoc {
382
+ readonly id: string;
383
+ readonly title: string;
384
+ readonly severity: string;
385
+ readonly category: string;
386
+ readonly recommended: boolean;
387
+ readonly source: string;
388
+ readonly helpUri: string;
389
+ readonly description: string;
390
+ readonly hasOverride: boolean;
391
+ }
392
+ interface LoadRuleDocOptions {
393
+ readonly docsRoot?: string;
394
+ }
395
+ declare function loadRuleDoc(ruleId: string, options?: LoadRuleDocOptions): RuleDoc | null;
396
+ declare function loadAllRuleDocs(options?: LoadRuleDocOptions): RuleDoc[];
397
+ //#endregion
398
+ //#region src/rule-registry.d.ts
399
+ type RuleCategory = 'ai-slop' | 'reactivity' | 'composition' | 'performance' | 'template' | 'template-perf' | 'build-quality' | 'deps' | 'dead-code' | 'sfc' | 'vue-builtin' | 'structure' | 'modules-deps' | 'nitro' | 'seo' | 'cloudflare' | 'server-routes' | 'hydration' | 'data-fetching';
400
+ type RuleSource = 'doctor' | 'oxlint-builtin' | 'eslint-plugin-vue';
401
+ interface RegisteredRule {
402
+ readonly id: string;
403
+ readonly severity: Severity;
404
+ readonly category: RuleCategory;
405
+ readonly source: RuleSource;
406
+ readonly recommended: boolean;
407
+ }
408
+ declare const RULE_REGISTRY: readonly RegisteredRule[];
409
+ interface ListRulesFilter {
410
+ readonly preset?: 'recommended' | 'all';
411
+ readonly category?: RuleCategory;
412
+ readonly source?: RuleSource;
413
+ readonly severity?: Severity;
414
+ }
415
+ declare function listRules(filter?: ListRulesFilter): RegisteredRule[];
46
416
  //#endregion
47
- export { type AuditConfig, type AuditReport, type Diagnostic, type DiagnosticSource, type ReporterFormat, type Severity, audit, format, loadAuditConfig };
417
+ export { type ApplyInlineDisablesOptions, type AuditConfig, type AuditReport, type AuditTimings, BUILT_IN_RECOMMENDED, type Capability, type CliOverrides, ConfigCycleError, ConfigFileNotFoundError, type ConfigSource, DOCTOR_REPORT_SCHEMA_VERSION, DeadCodeImportFailed, DeadCodeTimeoutError, type Diagnostic, type DiagnosticSource, type DirectiveLine, type DirectiveRange, type DirectiveSet, type DoctorReport, type DoctorUserConfig, type Framework, type GitScopeMode, InvalidConfigError, type ListRulesFilter, type LoadRuleDocOptions, type MonorepoKind, OxlintOutputTooLarge, OxlintSpawnFailed, type ProjectInfo, type ProjectInfoLite, RULE_REGISTRY, type RegisteredRule, type ReporterFormat, type ReporterInput, type ReporterOptions, type ResolvedDoctorConfig, type RuleCategory, type RuleDoc, type RuleSource, type ScoreBreakdownEntry, type ScoreConfig, type ScoreResult, type Severity, type VerboseTraceOptions, agentReport, applyInlineDisables, audit, buildDoctorReport, checkBuildQuality, checkDeadCode, checkDeps, checkNuxtProject, dedupeDeadCodeAgainstLint, defineConfig, detectProject, docsUrl, encodeAnnotation, encodeAnnotations, format, isNuxtLayoutFile, isNuxtPageFile, isNuxtServerFile, jsonCompactReport, jsonReport, listChangedFiles, listRules, loadAllRuleDocs, loadDoctorConfig, loadRuleDoc, mergeCliOverrides, parseDirectives, prettyReport, renderVerboseTrace, runCrossFilePass, sarifReport, scoreDiagnostics, validateConfig };
48
418
  //# sourceMappingURL=index.d.ts.map