Why: Dead exports were unchecked, and async run state needs one owner. Evidence: knip unused exports stay at 43. design-guard passed. Impact: A ratchet on export count. No runtime behavior change. Refs: feature/architecture-baseline Co-authored-by: Cursor <cursoragent@cursor.com>
24 lines
798 B
JavaScript
24 lines
798 B
JavaScript
import { readFileSync } from 'node:fs'
|
|
import { spawnSync } from 'node:child_process'
|
|
|
|
const run = spawnSync('npx', ['knip', '--reporter', 'json', '--include', 'exports,nsExports,types,nsTypes'], {
|
|
encoding: 'utf8',
|
|
})
|
|
if (!run.stdout) {
|
|
process.stderr.write(run.stderr || 'knip produced no output\n')
|
|
process.exit(1)
|
|
}
|
|
const data = JSON.parse(run.stdout)
|
|
let count = 0
|
|
for (const issue of data.issues ?? []) {
|
|
for (const key of ['exports', 'types', 'nsExports', 'nsTypes']) {
|
|
count += (issue[key] ?? []).length
|
|
}
|
|
}
|
|
const limit = JSON.parse(readFileSync(new URL('../knip-baseline.json', import.meta.url))).exports
|
|
if (count > limit) {
|
|
console.error(`knip unused exports ${count} exceed baseline ${limit}`)
|
|
process.exit(1)
|
|
}
|
|
console.log(`knip unused exports ${count} <= ${limit}`)
|