import { AlertCircle, AlertTriangle, CheckCircle2, Wrench } from "lucide-react";
import type { LintResult, LintViolation } from "@/lib/api";
interface LintPanelProps {
result: LintResult | null;
onJumpToLine?: (line: number) => void;
}
function SeverityBadge({ warning }: { warning: boolean }) {
if (warning) {
return (
WARN
);
}
return (
ERROR
);
}
function RuleCodeBadge({ code }: { code: string }) {
return (
{code}
);
}
function ViolationRow({ v, onJumpToLine }: { v: LintViolation; onJumpToLine?: (line: number) => void }) {
return (
onJumpToLine?.(v.line_no)}
>
L{v.line_no}:{v.line_pos}
{v.fixable && (
fixable
)}
{v.description}
);
}
export function LintPanel({ result, onJumpToLine }: LintPanelProps) {
if (!result) {
return (
Run analysis to see lint results
);
}
const { violations, passed, stats } = result;
return (
{/* Summary bar */}
{passed ? (
All checks passed
) : (
{stats.total} violation{stats.total !== 1 ? "s" : ""}
)}
{stats.errors > 0 && (
{stats.errors} error{stats.errors !== 1 ? "s" : ""}
)}
{stats.warnings > 0 && (
{stats.warnings} warning{stats.warnings !== 1 ? "s" : ""}
)}
{stats.fixable > 0 && (
{stats.fixable} fixable
)}
{/* Violations list */}
{passed ? (
No violations found
Your SQL is clean for dialect: {result.dialect}
) : (
{violations.map((v, i) => (
))}
)}
);
}