|
| 1 | +import type { Operation } from "effection"; |
| 2 | +import type { Diagnostics, DoctorResult, OxlintDiagnostic, PR } from "../types.ts"; |
| 3 | +import { buildDiagnostics } from "../parse-diagnostics.ts"; |
| 4 | +import { returns as rawDiagnosticsSchema } from "./OxlintDiagnostics.ts"; |
| 5 | +import { returns as doctorSchema } from "./Doctor.ts"; |
| 6 | + |
| 7 | +export const props = { |
| 8 | + type: "object", |
| 9 | + properties: { |
| 10 | + raw: rawDiagnosticsSchema, |
| 11 | + pr: { type: "object" }, |
| 12 | + doctor: doctorSchema, |
| 13 | + }, |
| 14 | + required: ["raw", "pr", "doctor"], |
| 15 | + additionalProperties: false, |
| 16 | +}; |
| 17 | + |
| 18 | +const groupSchema = { |
| 19 | + type: "object", |
| 20 | + properties: { |
| 21 | + ruleId: { type: "string" }, |
| 22 | + count: { type: "number" }, |
| 23 | + files: { type: "array", items: { type: "string" } }, |
| 24 | + instances: rawDiagnosticsSchema, |
| 25 | + }, |
| 26 | + required: ["ruleId", "count", "files", "instances"], |
| 27 | + additionalProperties: false, |
| 28 | +}; |
| 29 | +const groupsSchema = { type: "array", items: groupSchema }; |
| 30 | + |
| 31 | +export const returns = { |
| 32 | + type: "object", |
| 33 | + properties: { |
| 34 | + groups: groupsSchema, |
| 35 | + total: { type: "number" }, |
| 36 | + fileCount: { type: "number" }, |
| 37 | + ruleCount: { type: "number" }, |
| 38 | + byCategory: { |
| 39 | + type: "object", |
| 40 | + properties: { |
| 41 | + structural: groupsSchema, |
| 42 | + verbosity: groupsSchema, |
| 43 | + typeAware: groupsSchema, |
| 44 | + other: groupsSchema, |
| 45 | + }, |
| 46 | + required: ["structural", "verbosity", "typeAware", "other"], |
| 47 | + additionalProperties: false, |
| 48 | + }, |
| 49 | + summary: { type: "string" }, |
| 50 | + density: { type: "number" }, |
| 51 | + }, |
| 52 | + required: ["groups", "total", "fileCount", "ruleCount", "byCategory", "summary", "density"], |
| 53 | + additionalProperties: false, |
| 54 | +}; |
| 55 | + |
| 56 | +interface ReviewDiagnosticsProps { |
| 57 | + raw: OxlintDiagnostic[]; |
| 58 | + pr: PR; |
| 59 | + doctor: DoctorResult; |
| 60 | +} |
| 61 | + |
| 62 | +export default function* ReviewDiagnostics({ |
| 63 | + raw, |
| 64 | + pr, |
| 65 | + doctor, |
| 66 | +}: ReviewDiagnosticsProps): Operation<Diagnostics> { |
| 67 | + return buildDiagnostics(raw, pr, doctor); |
| 68 | +} |
0 commit comments