@compilr-dev/tooling 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,49 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 — 2026-12-06
4
+
5
+ **`./toolchain`** — `BASELINE` and `checkToolchain({ root, accept })`, plus a
6
+ `compilr-check-toolchain` bin.
7
+
8
+ Four app repos were measured and **14 of the 21 dev tools they share spanned more than one MAJOR**
9
+ — a build tool three majors apart, a test runner three, a CSS framework whose configuration model
10
+ had changed in between. None of it was decided by anyone: whoever last touched a repo set its
11
+ versions, nothing told the other three, and only one of the four had any dependency automation. The
12
+ oldest came from a scaffold template that pinned them seventeen months earlier. The skew reads like
13
+ neglect and is not — it is the absence of a shared statement of intent.
14
+
15
+ - **`BASELINE` is data, not `peerDependencies`.** That shape would force a version (destroying the
16
+ independent upgrade schedules this package exists to protect), need peer ranges spanning two
17
+ majors, and leave a repo that cannot upgrade yet unable to install. Starting values were DERIVED
18
+ — newest-in-use per package across the four manifests — so no number was invented.
19
+ - **It reports; it never fails on being behind.** A check that goes red because of a decision
20
+ somebody made gets switched off along with the checks that worked.
21
+ - **An acceptance requires a reason AND an expiry**, both enforced at runtime. The expiry is the
22
+ load-bearing field: a reason alone becomes permanent in silence.
23
+ - **`ahead` is reported too**, pointing the fix at the baseline rather than the repo — otherwise
24
+ the most-recently-upgraded repo silently becomes the standard and the baseline decays into a
25
+ floor.
26
+ - **An acceptance that has expired, or that names a package no longer behind, DOES fail** the bin.
27
+ Those are not decisions, they are decisions nobody re-made, and a dead acceptance hides the next
28
+ real one.
29
+
30
+ Whoever upgrades first bumps the baseline here, so one upgrade informs four repos.
31
+
32
+ ## 0.1.0 — 2026-12-06
33
+
34
+ First release. Two entry points, no runtime dependencies.
35
+
36
+ **`./eslint`** — `runtimeBlock(runtime, { files, globals })` and `RUNTIMES`: the six runtimes these
37
+ app repos ship code into, as data. It states `files` and `languageOptions` and nothing else; the
38
+ repo keeps its own eslint, plugins and rules and passes its own `globals` object in. That division
39
+ is why there are no dependencies: across the four repos this came from, eslint spanned two majors,
40
+ `globals` two, TypeScript two and the test runner three.
41
+
42
+ **`./audit`** and the `compilr-audit-gates` bin — `auditGates({ root })` reports the files no gate
43
+ covers and the gates that cannot fail: lint coverage per file class, a tsconfig a gate is aimed at
44
+ that resolves to none of your files, a claimed gate with no script, and a gate no workflow runs.
45
+ Returns findings rather than asserting.
46
+
47
+ Written after an audit of four app repos found **143 files linted by nothing** — including 72
48
+ production serverless functions, the modules a database access layer lived in, and a service worker
49
+ that ships to every browser — with `npm run lint` exiting 0 throughout.
package/LICENSE ADDED
@@ -0,0 +1,108 @@
1
+ Functional Source License, Version 1.1, MIT Future License
2
+
3
+ Abbreviation: FSL-1.1-MIT
4
+
5
+ Notice
6
+
7
+ Copyright 2026 Carmelo Scozzola
8
+
9
+ Terms and Conditions
10
+
11
+ Licensor ("We")
12
+
13
+ The party offering the Software under these Terms and Conditions.
14
+
15
+ The Software
16
+
17
+ The "Software" is each version of the software that we make available under
18
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
19
+ Conditions with the Software.
20
+
21
+ License Grant
22
+
23
+ Subject to your compliance with this License Grant and the Patents,
24
+ Redistribution and Trademark clauses below, we hereby grant you the right to
25
+ use, copy, modify, create derivative works, publicly perform, publicly display
26
+ and redistribute the Software for any Permitted Purpose identified below.
27
+
28
+ Permitted Purpose
29
+
30
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
31
+ means making the Software available to others in a commercial product or
32
+ service that:
33
+
34
+ 1. substitutes for the Software;
35
+
36
+ 2. substitutes for any other product or service we offer using the Software
37
+ that exists as of the date we make the Software available; or
38
+
39
+ 3. offers the same or substantially similar functionality as the Software.
40
+
41
+ Permitted Purposes specifically include using the Software:
42
+
43
+ 1. for your internal use and access;
44
+
45
+ 2. for non-commercial education;
46
+
47
+ 3. for non-commercial research; and
48
+
49
+ 4. in connection with professional services that you provide to a licensee
50
+ using the Software in accordance with these Terms and Conditions.
51
+
52
+ Patents
53
+
54
+ To the extent your use for a Permitted Purpose would necessarily infringe our
55
+ patents, the license grant above includes a license under our patents. If you
56
+ make a claim against any party that the Software infringes or contributes to
57
+ the infringement of any patent, then your patent license to the Software ends
58
+ immediately.
59
+
60
+ Redistribution
61
+
62
+ The Terms and Conditions apply to all copies, modifications and derivatives of
63
+ the Software.
64
+
65
+ If you redistribute any copies, modifications or derivatives of the Software,
66
+ you must include a copy of or a link to these Terms and Conditions and not
67
+ remove any copyright notices provided in or with the Software.
68
+
69
+ Disclaimer
70
+
71
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
72
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
73
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
74
+
75
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
76
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
77
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
78
+
79
+ Trademarks
80
+
81
+ Except for displaying the License Details and identifying us as the origin of
82
+ the Software, you have no right under these Terms and Conditions to use our
83
+ trademarks, trade names, service marks or product names.
84
+
85
+ Grant of Future License
86
+
87
+ We hereby irrevocably grant you an additional license to use the Software under
88
+ the MIT license that is effective on the second anniversary of the date we make
89
+ the Software available. On or after that date, you may use the Software under
90
+ the MIT license, in which case the following will apply:
91
+
92
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
93
+ this software and associated documentation files (the "Software"), to deal in
94
+ the Software without restriction, including without limitation the rights to
95
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
96
+ of the Software, and to permit persons to whom the Software is furnished to do
97
+ so, subject to the following conditions:
98
+
99
+ The above copyright notice and this permission notice shall be included in all
100
+ copies or substantial portions of the Software.
101
+
102
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
103
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
104
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
105
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
106
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
107
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
108
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,65 @@
1
- # Temporary Holding Version
1
+ # @compilr-dev/tooling
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared quality gates for app repos: **which runtime each class of source file belongs to**, and **an audit that reports the files no gate covers**.
4
+
5
+ ```bash
6
+ npm i -D @compilr-dev/tooling
7
+ ```
8
+
9
+ ## Why
10
+
11
+ Four app repos were audited and **143 files across them were linted by nothing**. Their eslint configs matched `*.{ts,tsx}` globs only, so every `.js`, `.mjs` and `.cjs` file sat outside the linter — 72 production serverless functions, the modules a database access layer lived in, a service worker that ships to every browser — while `npm run lint` exited 0 the whole time.
12
+
13
+ **A file no config block matched is indistinguishable, in an exit code, from a clean one.**
14
+
15
+ Fixing it four times produced the same discovery four times, which is what this package carries.
16
+
17
+ ## `./eslint` — the runtime facts
18
+
19
+ ```js
20
+ import globals from 'globals'
21
+ import js from '@eslint/js'
22
+ import { runtimeBlock } from '@compilr-dev/tooling/eslint'
23
+
24
+ export default [
25
+ { ...runtimeBlock('node-cjs', { files: ['netlify/functions/*.js'], globals }), ...js.configs.recommended },
26
+ { ...runtimeBlock('service-worker', { files: ['public/sw.js'], globals }), ...js.configs.recommended },
27
+ ]
28
+ ```
29
+
30
+ Six runtimes, because **one set of globals does not fit**:
31
+
32
+ | runtime | for | note |
33
+ |---|---|---|
34
+ | `node-esm` | build scripts, `.mjs` handlers, shared modules | |
35
+ | `node-cjs` | a CommonJS functions directory | a repo with `type: module` can still hold one; parsing it as ESM is a parse error |
36
+ | `edge-deno` | edge functions | Deno, not Node — no `process`, and a host-specific global |
37
+ | `service-worker` | `public/sw.js` | its own runtime: `self`, `caches`, `clients` — **not** `window` |
38
+ | `node-and-browser` | a driver script's `evaluate()` callbacks; a page module with a Node-tested pure half | both sets, because judging by either half is wrong |
39
+ | `browser` | a browser module | |
40
+
41
+ **It sets no rules.** The package owns the runtime facts; your repo owns which eslint, which plugins and which rules. That division is deliberate: across the four repos this came from, **eslint spanned two majors, `globals` two, TypeScript two and the test runner three** — so a package that imported any of them would break a lint run on skew. This one has **no runtime dependencies**; you pass your own `globals` in.
42
+
43
+ ⚠️ A flat-config block with `languageOptions` and no rules **lints nothing while looking configured**. Spread `js.configs.recommended` alongside, and let the audit confirm the class ends up with a non-empty rule set.
44
+
45
+ ## `./audit` and `compilr-audit-gates` — the holes a config cannot show you
46
+
47
+ ```jsonc
48
+ // package.json
49
+ "scripts": { "audit:gates": "compilr-audit-gates" }
50
+ ```
51
+
52
+ Four checks, each from a defect that shipped:
53
+
54
+ 1. **lint coverage** — every class of source file in the tree gets `eslint --print-config`; a class with zero rules is reported. ⚠️ A file the config *deliberately* ignores prints the literal `undefined` and is not a hole — two different silences.
55
+ 2. **a tsconfig a gate is aimed at must resolve to files of yours** — one repo aimed `tsc --noEmit` at a solution-style config holding only `references`, so it exited 0 having compiled an empty program. A config that resolves to nothing and that *nothing points at* is fine; that shape is the point of it.
56
+ 3. **claimed gates exist** — one repo had no `typecheck` script at all, so `npm run typecheck` printed "Missing script", which through a `| grep "error TS"` pipeline reads as a clean run.
57
+ 4. **something runs them** — a gate nothing runs looks exactly like one that passes. ⚠️ `npm test` without `run` counts.
58
+
59
+ It returns findings rather than asserting, so a test, a CI step or a script can use it. The CLI exits 1 on any finding.
60
+
61
+ **This package runs it on itself in CI**, and that found three of its own holes — including a relative-root bug that every fixture test missed, because they all passed absolute paths.
62
+
63
+ ## Licence
64
+
65
+ FSL-1.1-MIT.
@@ -0,0 +1,17 @@
1
+ export interface AuditOptions {
2
+ /** The repo root. */
3
+ root: string;
4
+ /** Directories never to walk. Defaults cover build output and dependencies. */
5
+ skipDirs?: readonly string[];
6
+ /** Extensions eslint is expected to cover. */
7
+ lintableExtensions?: readonly string[];
8
+ /** Gates that must exist as npm scripts AND be invoked by a workflow. */
9
+ requiredGates?: readonly string[];
10
+ }
11
+ export interface AuditFinding {
12
+ kind: 'unlinted' | 'empty-tsconfig' | 'missing-script' | 'gate-not-in-ci' | 'no-workflow' | 'probe-failed';
13
+ message: string;
14
+ /** Files or paths the finding is about, for a caller that wants to print them. */
15
+ subjects?: string[];
16
+ }
17
+ export declare function auditGates(options: AuditOptions): AuditFinding[];
package/dist/audit.js ADDED
@@ -0,0 +1,128 @@
1
+ import { readFileSync, readdirSync, existsSync } from 'node:fs';
2
+ import { join, extname, relative, resolve } from 'node:path';
3
+ import { execFileSync } from 'node:child_process';
4
+ const DEFAULT_SKIP = ['node_modules', 'dist', 'coverage', '.git', '.netlify', '.stryker-tmp', 'build', '__pycache__'];
5
+ const DEFAULT_EXTS = ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'];
6
+ const DEFAULT_GATES = ['lint', 'typecheck', 'test', 'build'];
7
+ const capture = (cwd, cmd, args) => {
8
+ try {
9
+ return execFileSync(cmd, args, { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
10
+ }
11
+ catch (e) {
12
+ const err = e;
13
+ return `${err.stdout ?? ''}${err.stderr ?? ''}`;
14
+ }
15
+ };
16
+ function walk(root, skip, exts, rel = '', out = []) {
17
+ for (const entry of readdirSync(join(root, rel), { withFileTypes: true })) {
18
+ if (skip.has(entry.name))
19
+ continue;
20
+ const next = rel ? `${rel}/${entry.name}` : entry.name;
21
+ if (entry.isDirectory())
22
+ walk(root, skip, exts, next, out);
23
+ else if (exts.has(extname(entry.name)))
24
+ out.push(next);
25
+ }
26
+ return out;
27
+ }
28
+ function fileClasses(files) {
29
+ const by = new Map();
30
+ for (const f of files) {
31
+ const parts = f.split('/');
32
+ const head = parts.slice(0, Math.min(2, parts.length - 1)).join('/') || '.';
33
+ const key = `${head}/*${extname(f)}`;
34
+ const found = by.get(key);
35
+ if (found)
36
+ found.count += 1;
37
+ else
38
+ by.set(key, { sample: f, count: 1 });
39
+ }
40
+ return by;
41
+ }
42
+ export function auditGates(options) {
43
+ const root = resolve(options.root);
44
+ const skip = new Set(options.skipDirs ?? DEFAULT_SKIP);
45
+ const exts = new Set(options.lintableExtensions ?? DEFAULT_EXTS);
46
+ const gates = options.requiredGates ?? DEFAULT_GATES;
47
+ const findings = [];
48
+ const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
49
+ const scripts = pkg.scripts ?? {};
50
+ const unlinted = [];
51
+ for (const [key, { sample, count }] of fileClasses(walk(root, skip, exts))) {
52
+ const text = capture(root, 'npx', ['eslint', '--print-config', sample]).trim();
53
+ if (text === 'undefined')
54
+ continue;
55
+ let rules;
56
+ try {
57
+ rules = Object.keys(JSON.parse(text).rules ?? {}).length;
58
+ }
59
+ catch {
60
+ findings.push({
61
+ kind: 'probe-failed',
62
+ message: `eslint printed no usable config for ${sample}: ${text.split('\n')[0] || '(no output)'}`,
63
+ subjects: [sample],
64
+ });
65
+ continue;
66
+ }
67
+ if (rules === 0)
68
+ unlinted.push({ key, count, sample });
69
+ }
70
+ if (unlinted.length) {
71
+ findings.push({
72
+ kind: 'unlinted',
73
+ message: `${unlinted.reduce((n, u) => n + u.count, 0)} file(s) in ${unlinted.length} class(es) are linted by ` +
74
+ `NOTHING: ${unlinted.map((u) => `${u.key} (${u.count})`).join(', ')}`,
75
+ subjects: unlinted.map((u) => u.sample),
76
+ });
77
+ }
78
+ const allScripts = Object.values(scripts).join(' ; ');
79
+ for (const file of readdirSync(root).filter((f) => /^tsconfig.*\.json$/.test(f))) {
80
+ const aimed = new RegExp(`(-p|--project)\\s+${file.replace('.', '\\.')}`).test(allScripts) ||
81
+ (file === 'tsconfig.json' && /\btsc\b(?![^;]*(-p|--project))/.test(allScripts));
82
+ if (!aimed)
83
+ continue;
84
+ const listed = capture(root, 'npx', ['tsc', '-p', file, '--listFilesOnly'])
85
+ .split('\n')
86
+ .map((l) => l.trim())
87
+ .filter((l) => l && !l.includes('node_modules') && l.startsWith(root));
88
+ if (listed.length === 0) {
89
+ findings.push({
90
+ kind: 'empty-tsconfig',
91
+ message: `a gate is aimed at ${file}, which resolves to ZERO of our files — that run exits 0 having checked nothing`,
92
+ subjects: [file],
93
+ });
94
+ }
95
+ }
96
+ for (const gate of gates) {
97
+ if (!scripts[gate]) {
98
+ findings.push({
99
+ kind: 'missing-script',
100
+ message: `no \`${gate}\` script — \`npm run ${gate}\` says "Missing script", which reads as silence in a pipeline`,
101
+ });
102
+ }
103
+ }
104
+ const wf = join(root, '.github', 'workflows');
105
+ const ci = existsSync(wf)
106
+ ? readdirSync(wf)
107
+ .filter((f) => /\.ya?ml$/.test(f))
108
+ .map((f) => readFileSync(join(wf, f), 'utf8'))
109
+ .join('\n')
110
+ : '';
111
+ if (!ci) {
112
+ findings.push({ kind: 'no-workflow', message: 'no GitHub workflow found — nothing runs any gate on push' });
113
+ }
114
+ else {
115
+ for (const gate of gates.filter((g) => scripts[g])) {
116
+ const invoked = new RegExp(`npm (run )?${gate}\\b`).test(ci) ||
117
+ new RegExp(`(yarn|pnpm) (run )?${gate}\\b`).test(ci) ||
118
+ new RegExp(`\\b${scripts[gate].split(' ')[0]}\\b`).test(ci);
119
+ if (!invoked) {
120
+ findings.push({
121
+ kind: 'gate-not-in-ci',
122
+ message: `\`${gate}\` exists but no workflow runs it — a gate nothing runs looks exactly like one that passes`,
123
+ });
124
+ }
125
+ }
126
+ }
127
+ return findings.map((f) => ({ ...f, subjects: f.subjects?.map((s) => relative(root, join(root, s))) }));
128
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs';
3
+ import { checkToolchain } from './toolchain.js';
4
+ const root = process.argv[2] ?? process.cwd();
5
+ const manifest = JSON.parse(readFileSync(`${root.replace(/\/$/, '')}/package.json`, 'utf8'));
6
+ const findings = checkToolchain({ root, accept: manifest.compilrToolchain?.accept });
7
+ const order = ['stale-acceptance', 'unused-acceptance', 'ahead', 'behind', 'accepted'];
8
+ const mark = {
9
+ 'stale-acceptance': '✗',
10
+ 'unused-acceptance': '✗',
11
+ ahead: '↑',
12
+ behind: '·',
13
+ accepted: '✓',
14
+ };
15
+ for (const kind of order) {
16
+ for (const f of findings.filter((x) => x.kind === kind))
17
+ console.log(` ${mark[kind]} ${f.message}`);
18
+ }
19
+ const lapsed = findings.filter((f) => f.kind === 'stale-acceptance' || f.kind === 'unused-acceptance');
20
+ const behind = findings.filter((f) => f.kind === 'behind');
21
+ const ahead = findings.filter((f) => f.kind === 'ahead');
22
+ console.log(`\n${behind.length} behind · ${findings.filter((f) => f.kind === 'accepted').length} accepted · ` +
23
+ `${ahead.length} ahead of the baseline · ${lapsed.length} lapsed`);
24
+ if (ahead.length) {
25
+ console.log('↑ means the BASELINE is stale: bump it in @compilr-dev/tooling so the other repos learn.');
26
+ }
27
+ if (lapsed.length) {
28
+ console.error('\nAn acceptance has expired or no longer applies. Decide again, or delete it.');
29
+ process.exit(1);
30
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ import { auditGates } from './audit.js';
3
+ const root = process.argv[2] ?? process.cwd();
4
+ const findings = auditGates({ root });
5
+ for (const f of findings)
6
+ console.error(` ✗ [${f.kind}] ${f.message}`);
7
+ if (findings.length) {
8
+ console.error(`\n${findings.length} gate hole(s). A file no gate covers is not a file that passed.`);
9
+ process.exit(1);
10
+ }
11
+ console.log('ok — every class of source file is covered, and every gate exists and runs');
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Which runtime does each class of source file actually belong to?
3
+ *
4
+ * ⚠️ **WHY THIS IS DATA AND NOT A CONFIG.** Four app repos were audited in December 2026 and 143
5
+ * files across them were linted by NOTHING: their eslint configs matched `*.{ts,tsx}` globs only,
6
+ * so every `.js`, `.mjs` and `.cjs` file — including 72 production serverless functions, the
7
+ * modules a database access layer lived in, and a service worker that ships to every browser — sat
8
+ * outside the linter while `npm run lint` exited 0. A file no config block matched is
9
+ * indistinguishable, in an exit code, from a clean one.
10
+ *
11
+ * Fixing that four times produced the same discovery four times: **one set of globals does not
12
+ * fit.** Those files ran in six different runtimes, and two of them were two runtimes AT ONCE.
13
+ * Judging a file by its outer runtime reports real globals as undefined, which teaches people to
14
+ * ignore the linter.
15
+ *
16
+ * ⚠️ **AND WHY THIS PACKAGE HAS NO DEPENDENCIES AT ALL.** Across those four repos, eslint spanned
17
+ * two majors, `globals` two, TypeScript two and the test runner three. A preset package that
18
+ * imported eslint, its plugins or `globals` would need peer ranges across two majors each and
19
+ * would break a lint run on skew. So the division is:
20
+ *
21
+ * - **this package owns the FACTS** — what runtime a class of file is, which `globals` groups it
22
+ * needs, and the `ecmaVersion` that class requires;
23
+ * - **the repo owns the CHOICES** — which eslint, which plugins, which rules, and it passes its
24
+ * OWN `globals` object in.
25
+ *
26
+ * Usage in a flat config:
27
+ *
28
+ * import globals from 'globals';
29
+ * import js from '@eslint/js';
30
+ * import { runtimeBlock } from '@compilr-dev/tooling/eslint';
31
+ *
32
+ * export default [
33
+ * { ...runtimeBlock('node-cjs', { files: ['netlify/functions/*.js'], globals }),
34
+ * ...js.configs.recommended },
35
+ * ];
36
+ *
37
+ * (A recursive glob is written here without its leading star-star: that sequence ENDS a block
38
+ * comment, and the zero-width space one reaches for to prevent it is itself a lint error. I made
39
+ * that mistake three times in one day before writing it down.)
40
+ */
41
+ /** The runtimes these app repos actually ship code into. */
42
+ export type RuntimeName =
43
+ /** Node, ES modules: build scripts, `.mjs` serverless handlers, shared library modules. */
44
+ 'node-esm'
45
+ /**
46
+ * Node, CommonJS. ⚠️ A repo whose root `package.json` says `type: module` can still hold a
47
+ * directory of CommonJS functions, pinned by its own `package.json`. Parsing those as ESM is a
48
+ * parse error, not a style complaint.
49
+ */
50
+ | 'node-cjs'
51
+ /**
52
+ * An edge runtime: Deno, not Node. No `process`; a `Deno` global, and on one host a `Netlify`
53
+ * global that exists nowhere else in the repo.
54
+ */
55
+ | 'edge-deno'
56
+ /**
57
+ * A service worker. ⚠️ Its own runtime: `self`, `caches`, `clients`, `skipWaiting` — NOT
58
+ * `window`, not Node. It is also classic-script scoped, not a module.
59
+ */
60
+ | 'service-worker'
61
+ /**
62
+ * Node AND browser in one file, which is not a mistake and not rare. Two real cases: a script
63
+ * whose callbacks are serialised and run in a page by a browser driver, and a page module with a
64
+ * pure half imported by a Node test and a bridge half that runs inside a host's iframe. Both
65
+ * global sets, because judging it by whichever half you read first is wrong either way.
66
+ */
67
+ | 'node-and-browser'
68
+ /** A browser module (not a worker, not a page bridge). */
69
+ | 'browser';
70
+ export interface RuntimeFacts {
71
+ /** `globals` package groups to spread, in order. The REPO supplies the package. */
72
+ globalsGroups: readonly string[];
73
+ /** Globals the `globals` package does not carry, as name → access. */
74
+ extraGlobals?: Readonly<Record<string, 'readonly' | 'writable'>>;
75
+ sourceType: 'module' | 'commonjs' | 'script';
76
+ /**
77
+ * ⚠️ 2025 rather than something older because of IMPORT ATTRIBUTES — `import x from './f.json'
78
+ * with { type: 'json' }`, which is how a module bundles an asset for a runtime that has no
79
+ * filesystem. An older setting stops the parser at `with` and reports a lint ERROR on a file
80
+ * that runs correctly on both Node and Deno.
81
+ */
82
+ ecmaVersion: number;
83
+ }
84
+ export declare const RUNTIMES: Readonly<Record<RuntimeName, RuntimeFacts>>;
85
+ /** The shape of the `globals` package: group name → globals map. Structural, so no import is needed. */
86
+ export type GlobalsPackage = Record<string, Record<string, boolean | 'readonly' | 'writable' | 'off'>>;
87
+ export interface RuntimeBlockOptions {
88
+ /** The glob(s) this block applies to. */
89
+ files: readonly string[];
90
+ /** YOUR `globals` package — `import globals from 'globals'`. Keeps this package dependency-free. */
91
+ globals: GlobalsPackage;
92
+ /** Extra globals for this block, merged last. */
93
+ extraGlobals?: Readonly<Record<string, 'readonly' | 'writable'>>;
94
+ /** Rules for this block. This package states no rule preferences; that is the repo's choice. */
95
+ rules?: Record<string, unknown>;
96
+ }
97
+ /**
98
+ * An eslint flat-config block for one runtime: `files` plus `languageOptions`, and nothing else.
99
+ *
100
+ * ⚠️ **It sets NO RULES, and a block with no rules LINTS NOTHING while looking configured.** That
101
+ * is a real failure mode — one was shipped during the audit above and only a coverage check found
102
+ * it. Spread `js.configs.recommended` (or your own) alongside, and let the audit confirm the file
103
+ * class ends up with a non-empty rule set.
104
+ */
105
+ export declare function runtimeBlock(runtime: RuntimeName, { files, globals, extraGlobals, rules }: RuntimeBlockOptions): {
106
+ files: string[];
107
+ languageOptions: {
108
+ ecmaVersion: number;
109
+ sourceType: 'module' | 'commonjs' | 'script';
110
+ globals: Record<string, unknown>;
111
+ };
112
+ rules?: Record<string, unknown>;
113
+ };
package/dist/eslint.js ADDED
@@ -0,0 +1,33 @@
1
+ export const RUNTIMES = {
2
+ 'node-esm': { globalsGroups: ['node'], sourceType: 'module', ecmaVersion: 2025 },
3
+ 'node-cjs': { globalsGroups: ['node'], sourceType: 'commonjs', ecmaVersion: 2025 },
4
+ 'edge-deno': {
5
+ globalsGroups: ['browser'],
6
+ extraGlobals: { Deno: 'readonly', Netlify: 'readonly' },
7
+ sourceType: 'module',
8
+ ecmaVersion: 2025,
9
+ },
10
+ 'service-worker': { globalsGroups: ['serviceworker'], sourceType: 'script', ecmaVersion: 2025 },
11
+ 'node-and-browser': { globalsGroups: ['node', 'browser'], sourceType: 'module', ecmaVersion: 2025 },
12
+ browser: { globalsGroups: ['browser'], sourceType: 'module', ecmaVersion: 2025 },
13
+ };
14
+ export function runtimeBlock(runtime, { files, globals, extraGlobals, rules }) {
15
+ const facts = RUNTIMES[runtime];
16
+ if (!facts)
17
+ throw new Error(`runtimeBlock: unknown runtime "${runtime}". Known: ${Object.keys(RUNTIMES).join(', ')}`);
18
+ const merged = {};
19
+ for (const group of facts.globalsGroups) {
20
+ const set = globals[group];
21
+ if (!set) {
22
+ throw new Error(`runtimeBlock("${runtime}"): the globals package has no "${group}" group. ` +
23
+ `Available: ${Object.keys(globals).slice(0, 12).join(', ')}…`);
24
+ }
25
+ Object.assign(merged, set);
26
+ }
27
+ Object.assign(merged, facts.extraGlobals ?? {}, extraGlobals ?? {});
28
+ return {
29
+ files: [...files],
30
+ languageOptions: { ecmaVersion: facts.ecmaVersion, sourceType: facts.sourceType, globals: merged },
31
+ ...(rules ? { rules } : {}),
32
+ };
33
+ }
@@ -0,0 +1,6 @@
1
+ export { RUNTIMES, runtimeBlock } from './eslint.js';
2
+ export type { RuntimeName, RuntimeFacts, RuntimeBlockOptions, GlobalsPackage } from './eslint.js';
3
+ export { auditGates } from './audit.js';
4
+ export type { AuditOptions, AuditFinding } from './audit.js';
5
+ export { BASELINE, checkToolchain } from './toolchain.js';
6
+ export type { ToolchainBaseline, ToolchainOptions, ToolchainFinding, Acceptance } from './toolchain.js';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { RUNTIMES, runtimeBlock } from './eslint.js';
2
+ export { auditGates } from './audit.js';
3
+ export { BASELINE, checkToolchain } from './toolchain.js';
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The toolchain baseline: what version of each shared tool the apps intend to be on, and a check
3
+ * that reports where each repo stands against it.
4
+ *
5
+ * ⚠️ **WHY A BASELINE AT ALL.** Four app repos were measured in December 2026 and **14 of the 21
6
+ * dev tools they share spanned more than one MAJOR** — a build tool three majors apart, a test
7
+ * runner three, a CSS framework whose configuration model had changed in between. None of it was
8
+ * decided by anyone: whoever last touched a repo set its versions, nothing told the other three,
9
+ * and only ONE of the four had any dependency automation at all. The oldest versions came from a
10
+ * scaffold template that had pinned them seventeen months earlier.
11
+ *
12
+ * The skew reads like neglect and is not. It is the absence of a shared statement of intent.
13
+ *
14
+ * ⚠️ **AND WHY IT IS DATA RATHER THAN `peerDependencies`.** That was the obvious shape and it is
15
+ * wrong three ways: it would FORCE a version, which destroys the independent upgrade schedules
16
+ * this package exists to protect; it needs peer ranges spanning two majors; and a repo that cannot
17
+ * upgrade yet could not install. So this is a published *statement of intent* each repo is
18
+ * measured against — the same division as the runtime facts: the package states, the repo decides.
19
+ *
20
+ * ⚠️ **It REPORTS. It must never fail a build.** A gate that goes red because of a decision
21
+ * somebody deliberately made gets switched off, and takes the checks that worked with it. One of
22
+ * these repos is a major behind on twenty-one packages by a decision already recorded; a blocking
23
+ * check there would be disabled on day one. "Two majors behind on the test runner, since
24
+ * 2025-07, owned, expires 2027-06" is a fact with a name on it, and that is the whole improvement.
25
+ *
26
+ * ## Who moves the baseline
27
+ *
28
+ * **Whoever upgrades first.** Bump the value here in the same change, and every other repo's next
29
+ * run says it is behind. That inverts the failure above: instead of the most-recently-touched repo
30
+ * silently becoming the standard, an upgrade PUBLISHES the standard. One upgrade, four informed
31
+ * repos.
32
+ *
33
+ * The starting values were DERIVED, not invented — newest-in-use per package across the four
34
+ * manifests, for every package three or more of them share. Nobody had to argue about a number.
35
+ * Consequence, accepted when it was chosen: every repo is immediately behind on something.
36
+ */
37
+ /** Package name → the range the apps intend to be on. */
38
+ export type ToolchainBaseline = Readonly<Record<string, string>>;
39
+ /**
40
+ * Newest-in-use per package across the four app manifests, for packages shared by three or more.
41
+ *
42
+ * ⚠️ Our own `@compilr-dev/*` packages are deliberately absent: they move on their own release
43
+ * cadence, so a baseline would do nothing but lag them.
44
+ */
45
+ export declare const BASELINE: ToolchainBaseline;
46
+ /**
47
+ * Why a repo is deliberately behind, and until when.
48
+ *
49
+ * ⚠️ **Both fields are required, and the expiry is the load-bearing one.** A reason alone becomes
50
+ * permanent in silence — which is exactly how three comments in these repos came to justify
51
+ * guards with claims that had stopped being true. Past `until`, the acceptance itself is reported,
52
+ * so the decision gets re-made rather than inherited.
53
+ */
54
+ export interface Acceptance {
55
+ /** Why — in a sentence someone who did not make the decision can evaluate. */
56
+ reason: string;
57
+ /** ISO `YYYY-MM-DD`. After this date the acceptance is itself a finding. */
58
+ until: string;
59
+ }
60
+ export interface ToolchainOptions {
61
+ root: string;
62
+ baseline?: ToolchainBaseline;
63
+ accept?: Readonly<Record<string, Acceptance>>;
64
+ /** For tests. Defaults to now. */
65
+ today?: Date;
66
+ }
67
+ export interface ToolchainFinding {
68
+ kind:
69
+ /** A major behind the baseline, and not accepted. */
70
+ 'behind'
71
+ /** PAST the baseline — so the baseline is stale and wants bumping here, not in the repo. */
72
+ | 'ahead'
73
+ /** Behind, with a live acceptance. Informational: it is a decision, not a defect. */
74
+ | 'accepted'
75
+ /** Accepted, but the expiry has passed. The decision is due again. */
76
+ | 'stale-acceptance'
77
+ /** An acceptance for something that is NOT behind — dead, and it hides the next real one. */
78
+ | 'unused-acceptance';
79
+ pkg: string;
80
+ declared?: string;
81
+ baseline: string;
82
+ message: string;
83
+ }
84
+ /**
85
+ * Compare a repo's manifest against the baseline.
86
+ *
87
+ * Only packages the repo actually declares are compared: a repo that does not use a tool is not
88
+ * behind on it. Returns findings; the caller decides what to do, and the answer should not be
89
+ * "fail the build" (see the note at the top of this file).
90
+ */
91
+ export declare function checkToolchain(options: ToolchainOptions): ToolchainFinding[];
@@ -0,0 +1,117 @@
1
+ import { readFileSync } from 'node:fs';
2
+ export const BASELINE = {
3
+ '@electric-sql/pglite': '^0.6.1',
4
+ '@electric-sql/pglite-socket': '^0.3.1',
5
+ '@eslint/js': '^10.0.1',
6
+ '@radix-ui/react-dialog': '^1.1.15',
7
+ '@radix-ui/react-dropdown-menu': '^2.2.1',
8
+ '@radix-ui/react-label': '^2.1.17',
9
+ '@radix-ui/react-popover': '^1.3.1',
10
+ '@radix-ui/react-slot': '^1.2.3',
11
+ '@radix-ui/react-tooltip': '^1.4.1',
12
+ '@supabase/supabase-js': '^2.112.3',
13
+ '@tanstack/react-query': '^5.105.3',
14
+ '@testing-library/jest-dom': '^7.0.1',
15
+ '@testing-library/react': '^16.3.3',
16
+ '@testing-library/user-event': '^14.6.8',
17
+ '@types/node': '^26.6.11',
18
+ '@types/react': '^19.3.0',
19
+ '@types/react-dom': '^19.3.0',
20
+ '@vitest/coverage-v8': '^4.1.12',
21
+ 'class-variance-authority': '^0.7.1',
22
+ clsx: '^2.1.1',
23
+ eslint: '^10.16.0',
24
+ 'eslint-plugin-react-hooks': '^7.1.1',
25
+ 'eslint-plugin-react-refresh': '^0.5.8',
26
+ globals: '^17.15.0',
27
+ jsdom: '^30.1.3',
28
+ 'lucide-react': '^1.67.0',
29
+ react: '^19.3.1',
30
+ 'react-dom': '^19.3.1',
31
+ 'react-router-dom': '^7.18.5',
32
+ recharts: '^3.10.1',
33
+ sonner: '^2.0.8',
34
+ 'tailwind-merge': '^3.7.0',
35
+ tailwindcss: '^4.3.3',
36
+ typescript: '^6.0.3',
37
+ 'typescript-eslint': '^8.74.0',
38
+ vite: '^8.3.5',
39
+ vitest: '^5.1.0',
40
+ };
41
+ const majorOf = (range) => {
42
+ const m = /(\d+)/.exec(String(range).replace(/^[^0-9]*/, ''));
43
+ return m ? Number(m[1]) : NaN;
44
+ };
45
+ const ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
46
+ export function checkToolchain(options) {
47
+ const baseline = options.baseline ?? BASELINE;
48
+ const accept = options.accept ?? {};
49
+ const today = options.today ?? new Date();
50
+ const pkgPath = `${options.root.replace(/\/$/, '')}/package.json`;
51
+ const manifest = JSON.parse(readFileSync(pkgPath, 'utf8'));
52
+ const declared = { ...manifest.dependencies, ...manifest.devDependencies };
53
+ for (const [pkg, a] of Object.entries(accept)) {
54
+ if (!a || typeof a.reason !== 'string' || !a.reason.trim()) {
55
+ throw new Error(`checkToolchain: the acceptance for "${pkg}" has no reason. Both fields are required.`);
56
+ }
57
+ if (!ISO_DATE.test(a.until ?? '')) {
58
+ throw new Error(`checkToolchain: the acceptance for "${pkg}" needs an expiry as YYYY-MM-DD, not ${JSON.stringify(a.until)}. ` +
59
+ 'An acceptance without one becomes permanent in silence.');
60
+ }
61
+ }
62
+ const out = [];
63
+ for (const [pkg, want] of Object.entries(baseline)) {
64
+ const have = declared[pkg];
65
+ if (!have)
66
+ continue;
67
+ const hv = majorOf(have);
68
+ const wv = majorOf(want);
69
+ if (Number.isNaN(hv) || Number.isNaN(wv))
70
+ continue;
71
+ const a = accept[pkg];
72
+ if (hv > wv) {
73
+ out.push({
74
+ kind: 'ahead',
75
+ pkg,
76
+ declared: have,
77
+ baseline: want,
78
+ message: `${pkg} is at ${have}, PAST the baseline ${want} — bump the baseline in @compilr-dev/tooling ` +
79
+ 'so the other repos learn they are behind. An upgrade nobody publishes is an upgrade nobody else gets.',
80
+ });
81
+ continue;
82
+ }
83
+ if (hv === wv) {
84
+ if (a) {
85
+ out.push({
86
+ kind: 'unused-acceptance',
87
+ pkg,
88
+ declared: have,
89
+ baseline: want,
90
+ message: `${pkg} is not behind, but an acceptance still names it — delete it, or it hides the next real one.`,
91
+ });
92
+ }
93
+ continue;
94
+ }
95
+ if (!a) {
96
+ out.push({
97
+ kind: 'behind',
98
+ pkg,
99
+ declared: have,
100
+ baseline: want,
101
+ message: `${pkg} is at ${have}, a major behind the baseline ${want}.`,
102
+ });
103
+ continue;
104
+ }
105
+ const expired = a.until < today.toISOString().slice(0, 10);
106
+ out.push({
107
+ kind: expired ? 'stale-acceptance' : 'accepted',
108
+ pkg,
109
+ declared: have,
110
+ baseline: want,
111
+ message: expired
112
+ ? `${pkg} is behind (${have} vs ${want}) and its acceptance EXPIRED on ${a.until}: "${a.reason}". Decide again.`
113
+ : `${pkg} is behind (${have} vs ${want}), accepted until ${a.until}: "${a.reason}".`,
114
+ });
115
+ }
116
+ return out;
117
+ }
package/package.json CHANGED
@@ -1,6 +1,74 @@
1
1
  {
2
2
  "name": "@compilr-dev/tooling",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Shared quality gates for app repos: which runtime each class of source file belongs to, and an audit that reports the files no gate covers",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./eslint": {
15
+ "types": "./dist/eslint.d.ts",
16
+ "import": "./dist/eslint.js",
17
+ "default": "./dist/eslint.js"
18
+ },
19
+ "./audit": {
20
+ "types": "./dist/audit.d.ts",
21
+ "import": "./dist/audit.js",
22
+ "default": "./dist/audit.js"
23
+ },
24
+ "./toolchain": {
25
+ "types": "./dist/toolchain.d.ts",
26
+ "import": "./dist/toolchain.js",
27
+ "default": "./dist/toolchain.js"
28
+ }
29
+ },
30
+ "bin": {
31
+ "compilr-audit-gates": "dist/cli.js",
32
+ "compilr-check-toolchain": "dist/cli-toolchain.js"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "LICENSE",
37
+ "CHANGELOG.md"
38
+ ],
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.build.json && tsc --emitDeclarationOnly",
41
+ "lint": "eslint src/ *.js",
42
+ "format": "prettier --write src/",
43
+ "format:check": "prettier --check src/",
44
+ "test": "vitest run",
45
+ "test:package": "node scripts/no-internal-refs.mjs",
46
+ "prepublishOnly": "npm run build",
47
+ "typecheck": "tsc --noEmit -p tsconfig.test.json",
48
+ "audit:self": "node dist/cli.js .",
49
+ "toolchain:self": "node dist/cli-toolchain.js ."
50
+ },
51
+ "devDependencies": {
52
+ "@eslint/js": "^10.0.1",
53
+ "@types/node": "^26.6.11",
54
+ "eslint": "^10.16.0",
55
+ "prettier": "^3.4.0",
56
+ "typescript": "^6.0.3",
57
+ "typescript-eslint": "^8.59.0",
58
+ "vitest": "^5.1.0",
59
+ "globals": "^17.15.0"
60
+ },
61
+ "sideEffects": false,
62
+ "engines": {
63
+ "node": ">=20.0.0"
64
+ },
65
+ "license": "FSL-1.1-MIT",
66
+ "author": "Carmelo Scozzola",
67
+ "keywords": [
68
+ "eslint",
69
+ "eslint-config",
70
+ "tooling",
71
+ "gates",
72
+ "lint-coverage"
73
+ ]
74
+ }