MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / main

Function main

scripts/lint-error-codes.cjs:117–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

115}
116
117function main() {
118 const enumData = loadEnum();
119 const files = walk(SOURCE_DIR);
120 let errorCount = 0;
121 let warnCount = 0;
122 for (const file of files) {
123 const violations = lintFile(file, enumData);
124 for (const v of violations) {
125 const rel = path.relative(ROOT, v.filePath);
126 const loc = v.trail.length ? ` at ${formatTrail(v.trail)}` : '';
127 const codeRef = v.code ? ` "${v.code}"` : '';
128 const tag = v.severity === 'warn' ? 'warn' : 'error';
129 console.error(` ${tag}: ${rel}${loc}${codeRef} — ${v.reason}`);
130 if (v.severity === 'warn') warnCount++; else errorCount++;
131 }
132 }
133 if (errorCount || warnCount) {
134 console.error(`\n storyboard error-code lint: ${errorCount} error(s), ${warnCount} warning(s)`);
135 }
136 if (errorCount) {
137 console.error(`\n Add the code to static/schemas/source/enums/error-code.json or register it as an alias in error-code-aliases.json.`);
138 process.exit(1);
139 }
140 if (!errorCount && !warnCount) {
141 console.log(` storyboard error-code lint: clean (${files.length} storyboard files scanned against ${enumData.canonical.size} canonical codes)`);
142 }
143}
144
145main();

Callers 1

Calls 4

loadEnumFunction · 0.85
walkFunction · 0.70
lintFileFunction · 0.70
formatTrailFunction · 0.70

Tested by

no test coverage detected