Tools live under tools/<role>/<domain> (checks, generate, release, ci, dev), every tool is a workspace named @open-pencil/<domain>-tools, a shared tools/tsconfig.json backs the new check:tools gate that fixed 55 latent type errors, test:tools runs through bun --filter, the placement check is its own checks/test-homes package, and every tool resolves the repository through resolveWorkspaceRoot. Bun, Node, and mdast types live in a tools-root workspace so they never reach the app program.
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { expect, test } from 'bun:test'
|
|
import { join } from 'node:path'
|
|
|
|
import { openPencilArchitecturePlugin } from '../src/steiger-rules/index'
|
|
|
|
test('keeps tool test helpers beside tests without allowing arbitrary tool locations', () => {
|
|
const rule = openPencilArchitecturePlugin.ruleDefinitions.find(
|
|
(rule) => rule.name === 'open-pencil/strict-tools-layout'
|
|
)
|
|
if (!rule) throw new Error('Missing tool layout rule')
|
|
for (const [file, valid] of [
|
|
['tools/checks/lint/src/plugin.ts', true],
|
|
['tools/checks/lint/tests/example.test.ts', true],
|
|
['tools/checks/lint/tests/helpers/lint.ts', true],
|
|
['tools/checks/lint/tests/lint.ts', false],
|
|
['tools/checks/lint/helpers/lint.ts', false],
|
|
['tools/checks/lint/plugin.ts', false],
|
|
['tools/lint/src/plugin.ts', false],
|
|
['tools/test.ts', false],
|
|
['tools/tooling/lint/src/plugin.ts', false]
|
|
] as const) {
|
|
const root = process.cwd()
|
|
expect(
|
|
rule.check({
|
|
type: 'folder',
|
|
path: root,
|
|
children: [{ type: 'file', path: join(root, file) }]
|
|
}).diagnostics.length
|
|
).toBe(valid ? 0 : 1)
|
|
}
|
|
})
|