| 279 | } |
| 280 | |
| 281 | function extractRuleMaps(fm: ParsedFrontmatter): { |
| 282 | thresholds: Record<string, number>; |
| 283 | patterns: Record<string, string[]>; |
| 284 | fileTypes: Record<string, string[]>; |
| 285 | } { |
| 286 | const rawThresholds = fm.thresholds as Record<string, number | string | string[]> | undefined; |
| 287 | const thresholds: Record<string, number> = {}; |
| 288 | if (rawThresholds) { |
| 289 | for (const [k, v] of Object.entries(rawThresholds)) { |
| 290 | if (typeof v === 'number') thresholds[k] = v; |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | const patterns: Record<string, string[]> = {}; |
| 295 | const rawPatterns = fm.patterns as Record<string, string | string[]> | undefined; |
| 296 | if (rawPatterns) { |
| 297 | for (const [k, v] of Object.entries(rawPatterns)) { |
| 298 | if (Array.isArray(v)) patterns[k] = v; |
| 299 | else if (typeof v === 'string') patterns[k] = [v]; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | const fileTypes: Record<string, string[]> = {}; |
| 304 | const rawFileTypes = fm.fileTypes as Record<string, string | string[]> | undefined; |
| 305 | if (rawFileTypes) { |
| 306 | for (const [k, v] of Object.entries(rawFileTypes)) { |
| 307 | if (Array.isArray(v)) fileTypes[k] = v; |
| 308 | else if (typeof v === 'string') fileTypes[k] = [v]; |
| 309 | } |
| 310 | } |
| 311 | |
| 312 | return { thresholds, patterns, fileTypes }; |
| 313 | } |
| 314 | |
| 315 | const VALID_GROUPS = new Set(Object.keys(PRACTICE_GROUPS)); |
| 316 | const VALID_SEVERITIES = new Set<RuleSeverity>(['high', 'medium', 'low']); |