(filePath, { canonical, aliases })
| 79 | } |
| 80 | |
| 81 | function lintFile(filePath, { canonical, aliases }) { |
| 82 | const violations = []; |
| 83 | let doc; |
| 84 | try { |
| 85 | doc = yaml.load(fs.readFileSync(filePath, 'utf8')); |
| 86 | } catch (err) { |
| 87 | return [{ filePath, trail: [], code: null, reason: `skipped (YAML parse failed: ${err.message}) — fix via upstream YAML lint`, severity: 'warn' }]; |
| 88 | } |
| 89 | if (!doc) return violations; |
| 90 | for (const hit of findErrorCodeAssertions(doc, [])) { |
| 91 | if (canonical.has(hit.code)) continue; |
| 92 | if (aliases.has(hit.code)) { |
| 93 | violations.push({ |
| 94 | filePath, |
| 95 | trail: hit.trail, |
| 96 | code: hit.code, |
| 97 | reason: `deprecated alias — remove or migrate before the alias sunsets`, |
| 98 | severity: 'warn', |
| 99 | }); |
| 100 | continue; |
| 101 | } |
| 102 | violations.push({ |
| 103 | filePath, |
| 104 | trail: hit.trail, |
| 105 | code: hit.code, |
| 106 | reason: `not in canonical error-code enum (static/schemas/source/enums/error-code.json)`, |
| 107 | severity: 'error', |
| 108 | }); |
| 109 | } |
| 110 | return violations; |
| 111 | } |
| 112 | |
| 113 | function formatTrail(trail) { |
| 114 | return trail.map(seg => (typeof seg === 'number' ? `[${seg}]` : `.${seg}`)).join('').replace(/^\./, ''); |
no test coverage detected