* 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)
| 165 | * from this entry" — a bad value or a typo'd language never throws. |
| 166 | */ |
| 167 | function extractExtensions(parsed: object, file: string): Record<string, Language> { |
| 168 | const exts = (parsed as ProjectConfig).extensions; |
| 169 | if (!exts || typeof exts !== 'object' || Array.isArray(exts)) return EMPTY_EXTENSIONS; |
| 170 | |
| 171 | const out: Record<string, Language> = {}; |
| 172 | for (const [rawKey, rawVal] of Object.entries(exts)) { |
| 173 | const key = normalizeExtKey(rawKey); |
| 174 | if (!key) { |
| 175 | logWarn(`Ignoring extension mapping in ${PROJECT_CONFIG_FILENAME}: "${rawKey}" is not a valid file extension`, { file }); |
| 176 | continue; |
| 177 | } |
| 178 | if (typeof rawVal !== 'string' || !isLanguageSupported(rawVal as Language)) { |
| 179 | logWarn(`Ignoring extension "${rawKey}" in ${PROJECT_CONFIG_FILENAME}: "${String(rawVal)}" is not a supported language`, { file }); |
| 180 | continue; |
| 181 | } |
| 182 | out[key] = rawVal as Language; |
| 183 | } |
| 184 | |
| 185 | return Object.keys(out).length > 0 ? out : EMPTY_EXTENSIONS; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Validate the `includeIgnored` patterns: an array of non-empty gitignore-style |
no test coverage detected