Files
qqq-cli/scripts/lint.mjs
T
james.maesandClaude Fable 5.1 7f1ad5e120 ci: prepublishOnly and lint scripts the qqq-orb node profile runs
The orb's node_install_dependencies runs npm run prepublishOnly (now the workspace build) and
node_run_tests runs npm test then npm run lint. lint checks license headers and that no
package imports another package's src. Also records finding 10: the sample app has no
uploaded-file archive table, so bulk load cannot be exercised against it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-31 17:31:32 -05:00

42 lines
1.5 KiB
JavaScript

/*
* Copyright 2026 QRun.IO, Inc.
* Licensed under the Apache License, Version 2.0 (see LICENSE).
*/
/**
* Repository lint: every TypeScript and script source carries the license header, and no file under
* packages/* /src imports from another package's src (only from its built entry point).
*
* Usage: node scripts/lint.mjs
*/
import { readdirSync, readFileSync, statSync } from 'node:fs'
import { join, relative } from 'node:path'
const HEADER = 'Copyright 2026 QRun.IO, Inc.'
const roots = ['packages/ui-api-client/src', 'packages/core/src', 'packages/conformance/src', 'packages/cli/src', 'scripts']
const problems = []
function walk(dir) {
for (const name of readdirSync(dir)) {
const path = join(dir, name)
if (name === 'node_modules' || name === 'dist') continue
if (statSync(path).isDirectory()) walk(path)
else if (/\.(ts|tsx|mjs|js)$/.test(name) && !name.endsWith('.d.ts') && name !== 'schema.ts' && name !== 'operations.ts') check(path)
}
}
function check(path) {
const text = readFileSync(path, 'utf8')
if (!text.slice(0, 400).includes(HEADER)) problems.push(`${relative('.', path)}: missing license header`)
const cross = text.match(/from '(\.\.\/)+(ui-api-client|core|conformance|cli)\/src\//)
if (cross) problems.push(`${relative('.', path)}: imports another package's src (${cross[0]}); import the package by name`)
}
for (const root of roots) walk(root)
if (problems.length) {
console.error(problems.join('\n'))
process.exit(1)
}
console.log('lint: ok')