/** * Abstract base class for all lenses */ import { Lens, LensConfig, LensOptions, LensResult, ExecuteResult, Executor, ToolConfiguration, UnknownParsedData, Issue, FileMetric, LensRequirements } from '../../types/index.js'; /** * Base implementation for quality lenses */ export declare abstract class BaseLens implements Lens { abstract readonly name: string; abstract readonly description: string; abstract readonly languages: string[]; abstract readonly supportedTools: string[]; /** Requirements for this lens to function (devDeps, scripts, configs) */ readonly requirements?: LensRequirements; protected config?: LensConfig; protected executor?: Executor; protected options: LensOptions; constructor(executor?: Executor, options?: LensOptions); /** * Configure the lens with tool configuration */ configure(config: LensConfig): void; /** * Set the executor for this lens */ setExecutor(executor: Executor): void; /** * Execute the quality tool */ execute(): Promise; /** * Parse tool output - must be implemented by subclasses */ abstract parse(output: ExecuteResult): TParsed; /** * Format parsed data - must be implemented by subclasses */ abstract format(parsed: TParsed): LensResult; /** * Run the complete pipeline */ run(): Promise; /** * Check if this lens can handle the given tool */ canHandle(tool: ToolConfiguration): boolean; /** * Prepare a command string before execution * Override in subclasses to add required flags for proper parsing * * This is called by the CLI when running config-based commands * to allow lenses to add necessary flags (e.g., for file metrics) * * @param command - The raw command string from config * @returns Modified command with any additional flags needed */ prepareCommand(command: string): string; /** * Helper to create relative paths */ protected toRelativePath(absolutePath: string, basePath?: string): string; /** * Helper to create an error result */ protected createErrorResult(error: unknown): LensResult; /** * Debug logging helper */ protected debug(message: string, ...args: unknown[]): void; /** * Helper to add tool-specific arguments to npm scripts * Automatically inserts '--' separator when needed */ protected addArgsToNpmScript(additionalArgs: string[]): void; /** * Helper to map common severity names */ protected mapSeverity(severity: string): 'error' | 'warning' | 'info' | 'hint'; /** * Build per-file quality metrics from issues array * Each lens can use this to populate fileMetrics in their format() method * * @param analyzedFiles - Array of all file paths that were analyzed (required) * @param issues - Array of issues found by the lens * @param options - Optional configuration for score calculation * @returns Array of FileMetric objects, one per analyzed file */ protected buildFileMetrics(analyzedFiles: string[], issues: Issue[], options?: { /** Weight for errors in score calculation (default: 10) */ errorWeight?: number; /** Weight for warnings in score calculation (default: 3) */ warningWeight?: number; /** Weight for info issues in score calculation (default: 1) */ infoWeight?: number; /** Weight for hints in score calculation (default: 0.5) */ hintWeight?: number; /** Check if an issue is fixable (default: checks for fix property) */ isFixable?: (issue: Issue) => boolean; }): FileMetric[]; } //# sourceMappingURL=BaseLens.d.ts.map