UNPKG

@felixgeelhaar/cclint

Version:

Catch CLAUDE.md drift before Claude misbehaves. Lints CLAUDE.md, skills, subagents, and hooks for Claude Code projects.

69 lines 2.96 kB
import { DiagnosticSeverity, type CodeAction, type Diagnostic, type Position, type Range, type TextEdit } from 'vscode-languageserver'; import { Severity } from '../domain/Severity.js'; import type { Location } from '../domain/Location.js'; import type { Violation } from '../domain/Violation.js'; import type { LintingResult } from '../domain/LintingResult.js'; import type { Fix } from '../domain/AutoFix.js'; /** * The `source` field attached to every diagnostic, so editors label cclint * findings distinctly from other language servers active on the same document. */ export declare const CCLINT_SOURCE = "cclint"; /** * Structured payload carried on each diagnostic's `data` field. * * @remarks * `fixable` lets a client decide whether to request a code action without * re-linting; it mirrors whether the originating {@link Violation} carried a * structured {@link Fix}. */ export interface DiagnosticData { ruleId: string; fixable: boolean; } /** * Map a cclint {@link Severity} to the corresponding LSP `DiagnosticSeverity`. */ export declare function severityToDiagnosticSeverity(severity: Severity): DiagnosticSeverity; /** * Convert a cclint {@link Location} (1-based line and column) to an LSP * {@link Position} (0-based line and character). * * @remarks * cclint columns are 1-based; a defensive `Math.max` guards the rare case of a * column reported as `0` so the character never becomes negative. */ export declare function locationToPosition(location: Location): Position; /** * Convert a cclint {@link Fix} range (1-based start/end {@link Location}s) to an * LSP {@link Range} (0-based positions). */ export declare function fixRangeToRange(range: Fix['range']): Range; /** * Map a single cclint {@link Violation} to an LSP {@link Diagnostic}. */ export declare function violationToDiagnostic(violation: Violation): Diagnostic; /** * Map every violation in a {@link LintingResult} to LSP diagnostics, preserving * order. Returns an empty array for a clean result. */ export declare function violationsToDiagnostics(result: LintingResult): Diagnostic[]; /** * Convert a cclint {@link Fix} to an LSP {@link TextEdit}. */ export declare function fixToTextEdit(fix: Fix): TextEdit; /** * Build a quick-fix {@link CodeAction} for a violation that carries a structured * {@link Fix}, or `undefined` when the violation has no fix. * * @param violation - the violation to offer a fix for * @param uri - the document URI the edit applies to * * @remarks * The fix comes straight from the rule that detected the problem (via * {@link Violation.fix}), so the edit is authoritative rather than re-derived * by pattern-matching the message. The originating diagnostic is attached to * the action so editors can associate the fix with the squiggle it resolves. */ export declare function violationToCodeAction(violation: Violation, uri: string): CodeAction | undefined; //# sourceMappingURL=diagnostics.d.ts.map