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