* Validate the `extensions` map. Every failure mode degrades to "no overrides * from this entry" — a bad value or a typo'd language never throws.
(parsed: object, file: string)
| 231 | * from this entry" — a bad value or a typo'd language never throws. |
| 232 | */ |
| 233 | function extractExtensions(parsed: object, file: string): Record<string, Language> { |
| 234 | const exts = (parsed as ProjectConfig).extensions; |
| 235 | if (!exts || typeof exts !== 'object' || Array.isArray(exts)) return EMPTY_EXTENSIONS; |
| 236 | |
| 237 | const out: Record<string, Language> = {}; |
| 238 | for (const [rawKey, rawVal] of Object.entries(exts)) { |
| 239 | const key = normalizeExtKey(rawKey); |
| 240 | if (!key) { |
| 241 | logWarn(`Ignoring extension mapping in ${PROJECT_CONFIG_FILENAME}: "${rawKey}" is not a valid file extension`, { file }); |
| 242 | continue; |
| 243 | } |
| 244 | if (typeof rawVal !== 'string' || !isLanguageSupported(rawVal as Language)) { |
| 245 | logWarn(`Ignoring extension "${rawKey}" in ${PROJECT_CONFIG_FILENAME}: "${String(rawVal)}" is not a supported language`, { file }); |
| 246 | continue; |
| 247 | } |
| 248 | out[key] = rawVal as Language; |
| 249 | } |
| 250 | |
| 251 | return Object.keys(out).length > 0 ? out : EMPTY_EXTENSIONS; |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Validate the `includeIgnored` patterns: an array of non-empty gitignore-style |
no test coverage detected