@rookcom/monarch-conformance 0.0.0-stage → 0.3.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 +21 -0
- package/README.md +4 -2
- package/dist/check.d.ts +81 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +350 -0
- package/dist/check.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +175 -0
- package/dist/cli.js.map +1 -0
- package/dist/glob.d.ts +3 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +70 -0
- package/dist/glob.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/monarch-components.d.ts +122 -0
- package/dist/monarch-components.d.ts.map +1 -0
- package/dist/monarch-components.js +47 -0
- package/dist/monarch-components.js.map +1 -0
- package/dist/registry.d.ts +77 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +259 -0
- package/dist/registry.js.map +1 -0
- package/dist/report.d.ts +8 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +122 -0
- package/dist/report.js.map +1 -0
- package/dist/rules.d.ts +155 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +685 -0
- package/dist/rules.js.map +1 -0
- package/dist/schema.d.ts +24 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +91 -0
- package/dist/schema.js.map +1 -0
- package/dist/semver.d.ts +27 -0
- package/dist/semver.d.ts.map +1 -0
- package/dist/semver.js +235 -0
- package/dist/semver.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +10 -0
- package/dist/version.js.map +1 -0
- package/package.json +48 -4
package/dist/registry.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { check, gitState, loadConfig, monarchDependencies, readJson, } from './check.js';
|
|
4
|
+
import { assertSupported, validate } from './schema.js';
|
|
5
|
+
import { minVersion, parseVersion, satisfies, format } from './semver.js';
|
|
6
|
+
import { TOOL_NAME, VERSION } from './version.js';
|
|
7
|
+
export function loadProducts(registry) {
|
|
8
|
+
const dir = join(registry, 'products');
|
|
9
|
+
return readdirSync(dir)
|
|
10
|
+
.filter((f) => f.endsWith('.json'))
|
|
11
|
+
.sort()
|
|
12
|
+
.map((f) => readJson(join(dir, f)));
|
|
13
|
+
}
|
|
14
|
+
export function loadCompatibility(registry) {
|
|
15
|
+
const p = join(registry, 'compatibility.json');
|
|
16
|
+
return existsSync(p) ? readJson(p) : undefined;
|
|
17
|
+
}
|
|
18
|
+
export function loadDeprecations(registry) {
|
|
19
|
+
const p = join(registry, 'deprecations.json');
|
|
20
|
+
return existsSync(p) ? readJson(p).deprecations : [];
|
|
21
|
+
}
|
|
22
|
+
export function validateRegistry(registry) {
|
|
23
|
+
const errors = [];
|
|
24
|
+
const schema = readJson(join(registry, 'product.schema.json'));
|
|
25
|
+
assertSupported(schema);
|
|
26
|
+
const dir = join(registry, 'products');
|
|
27
|
+
const files = readdirSync(dir)
|
|
28
|
+
.filter((f) => f.endsWith('.json'))
|
|
29
|
+
.sort();
|
|
30
|
+
const seen = {
|
|
31
|
+
id: new Map(),
|
|
32
|
+
domain: new Map(),
|
|
33
|
+
repository: new Map(),
|
|
34
|
+
};
|
|
35
|
+
for (const f of files) {
|
|
36
|
+
let data;
|
|
37
|
+
try {
|
|
38
|
+
data = JSON.parse(readFileSync(join(dir, f), 'utf8'));
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
errors.push(`${f}: invalid JSON (${e.message})`);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
for (const e of validate(data, schema))
|
|
45
|
+
errors.push(`${f}: ${e}`);
|
|
46
|
+
const p = data;
|
|
47
|
+
if (typeof p.id === 'string' && `${p.id}.json` !== f)
|
|
48
|
+
errors.push(`${f}: id "${p.id}" must match the file name`);
|
|
49
|
+
for (const key of ['id', 'domain', 'repository']) {
|
|
50
|
+
const v = p[key];
|
|
51
|
+
if (typeof v !== 'string')
|
|
52
|
+
continue;
|
|
53
|
+
const prev = seen[key].get(v);
|
|
54
|
+
if (prev)
|
|
55
|
+
errors.push(`${f}: ${key} "${v}" already used by ${prev}`);
|
|
56
|
+
else
|
|
57
|
+
seen[key].set(v, f);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const compat = loadCompatibility(registry);
|
|
61
|
+
if (compat) {
|
|
62
|
+
for (const [name, entry] of Object.entries(compat.packages)) {
|
|
63
|
+
if (!parseVersion(entry.current))
|
|
64
|
+
errors.push(`compatibility.json: ${name}.current is not a version`);
|
|
65
|
+
else if (!satisfies(entry.current, entry.supported))
|
|
66
|
+
errors.push(`compatibility.json: ${name}.current is outside its supported range`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { products: files.length, errors };
|
|
70
|
+
}
|
|
71
|
+
const TRACKED = ['next', 'react', 'react-dom', 'vite', 'tailwindcss', 'typescript'];
|
|
72
|
+
export function detectFramework(checkout) {
|
|
73
|
+
const pkgPath = join(checkout, 'package.json');
|
|
74
|
+
if (!existsSync(pkgPath))
|
|
75
|
+
return { name: 'unknown', versions: {} };
|
|
76
|
+
const pkg = readJson(pkgPath);
|
|
77
|
+
const deps = { ...pkg.devDependencies, ...pkg.dependencies };
|
|
78
|
+
const versions = {};
|
|
79
|
+
for (const k of TRACKED)
|
|
80
|
+
if (deps[k])
|
|
81
|
+
versions[k] = deps[k];
|
|
82
|
+
const name = deps.next
|
|
83
|
+
? 'next'
|
|
84
|
+
: deps.vite && deps.react
|
|
85
|
+
? 'vite-react'
|
|
86
|
+
: deps.react
|
|
87
|
+
? 'react'
|
|
88
|
+
: 'unknown';
|
|
89
|
+
return { name, versions };
|
|
90
|
+
}
|
|
91
|
+
export function classifyCompatibility(versions, compat) {
|
|
92
|
+
if (!compat)
|
|
93
|
+
return { status: 'unknown', notes: ['registry/compatibility.json not found'] };
|
|
94
|
+
const notes = [];
|
|
95
|
+
let failed = false;
|
|
96
|
+
let unknown = !versions.react;
|
|
97
|
+
if (!versions.react)
|
|
98
|
+
notes.push('react not found in package.json');
|
|
99
|
+
for (const [peer, range] of Object.entries(compat.peers)) {
|
|
100
|
+
const spec = versions[peer];
|
|
101
|
+
if (!spec)
|
|
102
|
+
continue;
|
|
103
|
+
const min = minVersion(spec);
|
|
104
|
+
if (!min) {
|
|
105
|
+
unknown = true;
|
|
106
|
+
notes.push(`${peer}@${spec}: version spec not understood`);
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (!satisfies(min, range)) {
|
|
110
|
+
failed = true;
|
|
111
|
+
if (peer === 'tailwindcss' && min.major >= 4) {
|
|
112
|
+
notes.push(`tailwindcss@${spec}: the Monarch Tailwind preset targets v3. Use the CSS-only path (import @rookcom/monarch-tokens/css and the mn-* variables) or the v4 @theme mapping once it ships.`);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
notes.push(`${peer}@${spec} (min ${format(min)}) is outside the supported range ${range}`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (failed)
|
|
120
|
+
return { status: 'needs-migration', notes };
|
|
121
|
+
if (unknown)
|
|
122
|
+
return { status: 'unknown', notes };
|
|
123
|
+
return {
|
|
124
|
+
status: 'compatible',
|
|
125
|
+
notes: notes.length ? notes : ['react, next and tailwindcss are within Monarch peer ranges'],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export function classifyAdoption(monarchPkgs, result) {
|
|
129
|
+
const names = Object.keys(monarchPkgs);
|
|
130
|
+
const localTokens = result.counts.byRule['tokens/local-token-definitions'] ?? 0;
|
|
131
|
+
const duplicates = result.counts.byRule['components/duplicated-primitive'] ?? 0;
|
|
132
|
+
const cssImported = result.monarchCssImports.length > 0;
|
|
133
|
+
const evidence = [];
|
|
134
|
+
if (names.length === 0) {
|
|
135
|
+
evidence.push('no @rookcom/monarch-* dependency in package.json');
|
|
136
|
+
if (localTokens)
|
|
137
|
+
evidence.push(`${localTokens} local token definition block(s)`);
|
|
138
|
+
if (duplicates)
|
|
139
|
+
evidence.push(`${duplicates} local component file(s) duplicating Monarch`);
|
|
140
|
+
return { status: 'not-adopted', evidence };
|
|
141
|
+
}
|
|
142
|
+
evidence.push(`depends on ${names.map((n) => `${n}@${monarchPkgs[n]}`).join(', ')}`);
|
|
143
|
+
evidence.push(cssImported
|
|
144
|
+
? `imports Monarch CSS in ${result.monarchCssImports.slice(0, 3).join(', ')}`
|
|
145
|
+
: 'does not import @rookcom/monarch-tokens/css');
|
|
146
|
+
if (localTokens)
|
|
147
|
+
evidence.push(`${localTokens} local token definition block(s) remain`);
|
|
148
|
+
if (duplicates)
|
|
149
|
+
evidence.push(`${duplicates} duplicated component file(s) remain`);
|
|
150
|
+
const adopted = cssImported && localTokens === 0 && duplicates === 0;
|
|
151
|
+
return { status: adopted ? 'adopted' : 'partial', evidence };
|
|
152
|
+
}
|
|
153
|
+
export function verifyProduct(opts) {
|
|
154
|
+
const product = loadProducts(opts.registry).find((p) => p.id === opts.productId);
|
|
155
|
+
if (!product)
|
|
156
|
+
throw new Error(`Unknown product "${opts.productId}" in ${opts.registry}`);
|
|
157
|
+
if (!existsSync(join(opts.checkout, 'package.json')))
|
|
158
|
+
throw new Error(`${opts.checkout} has no package.json`);
|
|
159
|
+
const compat = loadCompatibility(opts.registry);
|
|
160
|
+
const appConfig = loadConfig(join(opts.checkout, 'monarch.config.json'));
|
|
161
|
+
const include = product.source.paths.filter((p) => existsSync(join(opts.checkout, p)));
|
|
162
|
+
const result = check({
|
|
163
|
+
root: opts.checkout,
|
|
164
|
+
include,
|
|
165
|
+
exclude: appConfig?.exclude ?? [],
|
|
166
|
+
rules: appConfig?.rules ?? {},
|
|
167
|
+
exceptions: product.exceptions ?? [],
|
|
168
|
+
deprecations: loadDeprecations(opts.registry),
|
|
169
|
+
product: product.id,
|
|
170
|
+
...(compat ? { compatibility: compat } : {}),
|
|
171
|
+
});
|
|
172
|
+
const framework = detectFramework(opts.checkout);
|
|
173
|
+
const deps = monarchDependencies(opts.checkout);
|
|
174
|
+
const packages = Object.fromEntries(Object.entries(deps).map(([k, v]) => [k, v.installed ?? v.spec]));
|
|
175
|
+
const status = {
|
|
176
|
+
product: product.id,
|
|
177
|
+
verifiedAt: (opts.now ?? new Date()).toISOString(),
|
|
178
|
+
verifiedBy: 'monarch registry verify',
|
|
179
|
+
tool: `${TOOL_NAME}@${VERSION}`,
|
|
180
|
+
checkout: gitState(opts.checkout),
|
|
181
|
+
framework,
|
|
182
|
+
monarch: { packages },
|
|
183
|
+
adoption: classifyAdoption(packages, result),
|
|
184
|
+
compatibility: classifyCompatibility(framework.versions, compat),
|
|
185
|
+
conformance: {
|
|
186
|
+
paths: include,
|
|
187
|
+
filesScanned: result.filesScanned,
|
|
188
|
+
linesScanned: result.linesScanned,
|
|
189
|
+
byRule: result.counts.byRule,
|
|
190
|
+
bySeverity: result.counts.bySeverity,
|
|
191
|
+
exceptions: result.suppressed.exceptions,
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
if (opts.write !== false) {
|
|
195
|
+
const out = join(opts.registry, 'status', `${product.id}.json`);
|
|
196
|
+
mkdirSync(dirname(out), { recursive: true });
|
|
197
|
+
writeFileSync(out, JSON.stringify(status, null, 2) + '\n');
|
|
198
|
+
}
|
|
199
|
+
return { status, result };
|
|
200
|
+
}
|
|
201
|
+
// ----------------------------------------------------------------- report
|
|
202
|
+
export function loadStatuses(registry) {
|
|
203
|
+
const dir = join(registry, 'status');
|
|
204
|
+
if (!existsSync(dir))
|
|
205
|
+
return [];
|
|
206
|
+
return readdirSync(dir)
|
|
207
|
+
.filter((f) => f.endsWith('.json'))
|
|
208
|
+
.sort()
|
|
209
|
+
.map((f) => readJson(join(dir, f)));
|
|
210
|
+
}
|
|
211
|
+
const A11Y = [
|
|
212
|
+
'a11y/img-alt',
|
|
213
|
+
'a11y/click-without-key',
|
|
214
|
+
'a11y/positive-tabindex',
|
|
215
|
+
'a11y/outline-none-without-ring',
|
|
216
|
+
];
|
|
217
|
+
export function statusMarkdown(registry) {
|
|
218
|
+
const products = new Map(loadProducts(registry).map((p) => [p.id, p]));
|
|
219
|
+
const statuses = loadStatuses(registry);
|
|
220
|
+
const n = (s, r) => s.conformance.byRule[r] ?? 0;
|
|
221
|
+
const rows = statuses.map((s) => {
|
|
222
|
+
const p = products.get(s.product);
|
|
223
|
+
const fw = s.framework.versions;
|
|
224
|
+
const fwText = [
|
|
225
|
+
s.framework.name,
|
|
226
|
+
fw.next && `next ${fw.next}`,
|
|
227
|
+
fw.react && `react ${fw.react}`,
|
|
228
|
+
fw.tailwindcss && `tw ${fw.tailwindcss}`,
|
|
229
|
+
]
|
|
230
|
+
.filter(Boolean)
|
|
231
|
+
.join(' · ');
|
|
232
|
+
const monarch = Object.entries(s.monarch.packages)
|
|
233
|
+
.map(([k, v]) => `${k.replace('@rookcom/monarch-', '')} ${v}`)
|
|
234
|
+
.join(', ') || '—';
|
|
235
|
+
const a11y = A11Y.reduce((acc, r) => acc + n(s, r), 0);
|
|
236
|
+
return `| ${p?.name ?? s.product} | ${p?.domain ?? '—'} | ${fwText} | ${monarch} | ${s.adoption.status} | ${s.compatibility.status} | ${s.conformance.filesScanned} | ${n(s, 'color/no-raw-palette')} | ${n(s, 'color/no-hard-coded-color')} | ${n(s, 'tokens/local-token-definitions')} | ${n(s, 'components/duplicated-primitive')} | ${a11y} | ${s.verifiedAt.slice(0, 10)} | ${s.checkout.commit ? '`' + s.checkout.commit.slice(0, 7) + '`' + (s.checkout.dirty ? ' (dirty)' : '') : '—'} |`;
|
|
237
|
+
});
|
|
238
|
+
const unverified = [...products.keys()].filter((id) => !statuses.some((s) => s.product === id));
|
|
239
|
+
return [
|
|
240
|
+
'# Monarch registry status',
|
|
241
|
+
'',
|
|
242
|
+
'<!-- Generated by `monarch registry report`. Do not edit by hand. -->',
|
|
243
|
+
'',
|
|
244
|
+
'Numbers come from a static scan of each product at the commit shown (“dirty” means the checkout had uncommitted changes). They are counts, not scores. Adoption is decided by `monarch registry verify`; see [conformance guide](../guides/conformance.md#how-registry-verify-decides-adoption).',
|
|
245
|
+
'',
|
|
246
|
+
'| Product | Domain | Framework | Monarch | Adoption | Compatibility | Files | Palette | Colour literals | Local token blocks | Duplicated components | A11y | Verified | Commit |',
|
|
247
|
+
'| --- | --- | --- | --- | --- | --- | --: | --: | --: | --: | --: | --: | --- | --- |',
|
|
248
|
+
...rows,
|
|
249
|
+
'',
|
|
250
|
+
...(unverified.length ? [`Not yet verified: ${unverified.join(', ')}.`, ''] : []),
|
|
251
|
+
'## Compatibility notes',
|
|
252
|
+
'',
|
|
253
|
+
...statuses
|
|
254
|
+
.filter((s) => s.compatibility.status !== 'compatible')
|
|
255
|
+
.map((s) => `- **${products.get(s.product)?.name ?? s.product}** (${s.compatibility.status}): ${s.compatibility.notes.join(' ')}`),
|
|
256
|
+
'',
|
|
257
|
+
].join('\n');
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,KAAK,EACL,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,QAAQ,GAET,MAAM,YAAY,CAAC;AACp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AAC,CAAC,CAAC,EAAE,CAAC;QACjF,wBAAwB;QACxB,EAAE;QACF,GAAG,QAAQ;aACR,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,MAAM,KAAK,YAAY,CAAC;aACtD,GAAG,CACF,CAAC,CAAC,EAAE,EAAE,CACJ,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,IAAI,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,aAAa,CAAC,MAAM,MAAM,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CACxH;QACH,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
package/dist/report.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CheckResult } from './check.js';
|
|
2
|
+
export declare function toJson(result: CheckResult): string;
|
|
3
|
+
export declare function toText(result: CheckResult, opts?: {
|
|
4
|
+
maxPerRule?: number;
|
|
5
|
+
}): string;
|
|
6
|
+
/** SARIF 2.1.0 for GitHub code scanning (upload-sarif). */
|
|
7
|
+
export declare function toSarif(result: CheckResult): string;
|
|
8
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAM9C,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAElD;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,IAAI,GAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,CAuDtF;AAQD,2DAA2D;AAC3D,wBAAgB,OAAO,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAyDnD"}
|
package/dist/report.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { RULES } from './rules.js';
|
|
2
|
+
const ORDER = ['error', 'warn', 'info'];
|
|
3
|
+
export function toJson(result) {
|
|
4
|
+
return JSON.stringify(result, null, 2) + '\n';
|
|
5
|
+
}
|
|
6
|
+
export function toText(result, opts = {}) {
|
|
7
|
+
const max = opts.maxPerRule ?? 5;
|
|
8
|
+
const out = [];
|
|
9
|
+
const c = result.counts;
|
|
10
|
+
out.push(`Monarch conformance ${result.tool.version}${result.product ? ` · ${result.product}` : ''}`, `${result.root}${result.git.commit ? ` @ ${result.git.commit.slice(0, 12)}${result.git.dirty ? ' (dirty)' : ''}` : ''}`, `${result.filesScanned} files, ${result.linesScanned.toLocaleString('en-US')} lines scanned`, '');
|
|
11
|
+
const rules = Object.keys(c.byRule).sort((a, b) => {
|
|
12
|
+
const sa = result.findings.find((f) => f.rule === a)?.severity ?? 'info';
|
|
13
|
+
const sb = result.findings.find((f) => f.rule === b)?.severity ?? 'info';
|
|
14
|
+
return ORDER.indexOf(sa) - ORDER.indexOf(sb) || (c.byRule[b] ?? 0) - (c.byRule[a] ?? 0);
|
|
15
|
+
});
|
|
16
|
+
for (const rule of rules) {
|
|
17
|
+
const list = result.findings.filter((f) => f.rule === rule);
|
|
18
|
+
const fresh = list.filter((f) => !f.baselined).length;
|
|
19
|
+
const sev = list[0]?.severity ?? 'info';
|
|
20
|
+
const meta = RULES[rule];
|
|
21
|
+
out.push(`${sev.toUpperCase().padEnd(5)} ${rule} ${list.length}${result.baseline ? ` (${fresh} new)` : ''} ${result.densityPer1kLines[rule] ?? 0}/1k lines`);
|
|
22
|
+
if (meta)
|
|
23
|
+
out.push(` ${meta.summary}. ${meta.help}`);
|
|
24
|
+
const show = (result.baseline ? list.filter((f) => !f.baselined) : list).slice(0, max);
|
|
25
|
+
for (const f of show)
|
|
26
|
+
out.push(` ${f.file}:${f.line}:${f.column} ${f.message}`);
|
|
27
|
+
const rest = (result.baseline ? fresh : list.length) - show.length;
|
|
28
|
+
if (rest > 0)
|
|
29
|
+
out.push(` … ${rest} more`);
|
|
30
|
+
out.push('');
|
|
31
|
+
}
|
|
32
|
+
if (result.exceptions.length) {
|
|
33
|
+
out.push('Exceptions');
|
|
34
|
+
for (const e of result.exceptions) {
|
|
35
|
+
out.push(` ${e.status.padEnd(7)} ${e.rule} on ${e.paths.join(', ')} · owner ${e.owner} · expires ${e.expires} · ${e.suppressed} suppressed`);
|
|
36
|
+
}
|
|
37
|
+
out.push('');
|
|
38
|
+
}
|
|
39
|
+
out.push(`Totals: ${c.bySeverity.error} errors, ${c.bySeverity.warn} warnings, ${c.bySeverity.info} info` +
|
|
40
|
+
(result.baseline ? ` · new vs baseline: ${c.new.error} errors, ${c.new.warn} warnings` : ''));
|
|
41
|
+
if (result.suppressed.inline || result.suppressed.exceptions) {
|
|
42
|
+
out.push(`Suppressed: ${result.suppressed.inline} inline, ${result.suppressed.exceptions} by registry exceptions`);
|
|
43
|
+
}
|
|
44
|
+
if (result.baseline?.improved) {
|
|
45
|
+
out.push(`${result.baseline.improved} file/rule groups are below baseline; run --write-baseline to lock in the improvement.`);
|
|
46
|
+
}
|
|
47
|
+
out.push(result.exitCode === 0 ? 'Result: pass' : 'Result: fail (new error-severity findings)');
|
|
48
|
+
return out.join('\n') + '\n';
|
|
49
|
+
}
|
|
50
|
+
const LEVEL = {
|
|
51
|
+
error: 'error',
|
|
52
|
+
warn: 'warning',
|
|
53
|
+
info: 'note',
|
|
54
|
+
};
|
|
55
|
+
/** SARIF 2.1.0 for GitHub code scanning (upload-sarif). */
|
|
56
|
+
export function toSarif(result) {
|
|
57
|
+
const usedRules = [...new Set(result.findings.map((f) => f.rule))].sort();
|
|
58
|
+
const sarif = {
|
|
59
|
+
$schema: 'https://json.schemastore.org/sarif-2.1.0.json',
|
|
60
|
+
version: '2.1.0',
|
|
61
|
+
runs: [
|
|
62
|
+
{
|
|
63
|
+
tool: {
|
|
64
|
+
driver: {
|
|
65
|
+
name: 'monarch',
|
|
66
|
+
fullName: result.tool.name,
|
|
67
|
+
version: result.tool.version,
|
|
68
|
+
semanticVersion: result.tool.version,
|
|
69
|
+
informationUri: 'https://github.com/RookHQ/monarch/blob/main/docs/guides/conformance.md',
|
|
70
|
+
rules: usedRules.map((id) => {
|
|
71
|
+
const meta = RULES[id];
|
|
72
|
+
return {
|
|
73
|
+
id,
|
|
74
|
+
name: id.replace(/[/-](\w)/g, (_m, ch) => ch.toUpperCase()),
|
|
75
|
+
shortDescription: { text: meta?.summary ?? id },
|
|
76
|
+
fullDescription: { text: meta?.help ?? id },
|
|
77
|
+
help: { text: meta?.help ?? id },
|
|
78
|
+
defaultConfiguration: {
|
|
79
|
+
level: LEVEL[meta?.severity ?? 'warn'],
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}),
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
...(result.git.commit
|
|
86
|
+
? {
|
|
87
|
+
versionControlProvenance: [
|
|
88
|
+
{ repositoryUri: result.root, revisionId: result.git.commit },
|
|
89
|
+
],
|
|
90
|
+
}
|
|
91
|
+
: {}),
|
|
92
|
+
results: result.findings.map((f) => ({
|
|
93
|
+
ruleId: f.rule,
|
|
94
|
+
ruleIndex: usedRules.indexOf(f.rule),
|
|
95
|
+
level: LEVEL[f.severity],
|
|
96
|
+
message: { text: f.message },
|
|
97
|
+
baselineState: result.baseline ? (f.baselined ? 'unchanged' : 'new') : undefined,
|
|
98
|
+
locations: [
|
|
99
|
+
{
|
|
100
|
+
physicalLocation: {
|
|
101
|
+
artifactLocation: { uri: f.file },
|
|
102
|
+
region: { startLine: f.line, startColumn: f.column, snippet: { text: f.snippet } },
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
partialFingerprints: { 'monarch/v1': fingerprint(`${f.rule}|${f.file}|${f.snippet}`) },
|
|
107
|
+
})),
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
};
|
|
111
|
+
return JSON.stringify(sarif, null, 2) + '\n';
|
|
112
|
+
}
|
|
113
|
+
/** FNV-1a: stable across line moves, so code scanning doesn't reopen alerts. */
|
|
114
|
+
function fingerprint(s) {
|
|
115
|
+
let h = 0x811c9dc5;
|
|
116
|
+
for (let i = 0; i < s.length; i++) {
|
|
117
|
+
h ^= s.charCodeAt(i);
|
|
118
|
+
h = Math.imul(h, 0x01000193) >>> 0;
|
|
119
|
+
}
|
|
120
|
+
return h.toString(16).padStart(8, '0');
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAe,MAAM,YAAY,CAAC;AAGhD,MAAM,KAAK,GAAe,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpD,MAAM,UAAU,MAAM,CAAC,MAAmB;IACxC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;AAChD,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,MAAmB,EAAE,OAAgC,EAAE;IAC5E,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,IAAI,CAAC,CAAC;IACjC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC;IACxB,GAAG,CAAC,IAAI,CACN,uBAAuB,MAAM,CAAC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAC3F,GAAG,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CA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6BACnF;yBACF;qBACF;oBACD,mBAAmB,EAAE,EAAE,YAAY,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE;iBACvF,CAAC,CAAC;aACJ;SACF;KACF,CAAC;IACF,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC;AAC/C,CAAC;AAED,gFAAgF;AAChF,SAAS,WAAW,CAAC,CAAS;IAC5B,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACzC,CAAC"}
|
package/dist/rules.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conformance rules. Each scanner is a pure function over one file's text, so
|
|
3
|
+
* rules are easy to test with fixtures and cheap to run across 20+ repos.
|
|
4
|
+
*
|
|
5
|
+
* Scanning is lexical (regular expressions plus a small JSX tag reader), not a
|
|
6
|
+
* full parse. Rules are written to prefer missing a case over inventing one.
|
|
7
|
+
*/
|
|
8
|
+
import type { Deprecation, Severity } from './types.js';
|
|
9
|
+
export declare const RULES: {
|
|
10
|
+
readonly 'color/no-raw-palette': {
|
|
11
|
+
readonly id: "color/no-raw-palette";
|
|
12
|
+
readonly severity: "error";
|
|
13
|
+
readonly summary: "Raw Tailwind palette colour or arbitrary colour class";
|
|
14
|
+
readonly help: "Use a semantic colour (bg-mn-surface, text-mn-fg-muted, bg-mn-danger-subtle, or the legacy bg-primary / text-muted-foreground). Palette classes ignore theme, contrast mode and product accent.";
|
|
15
|
+
};
|
|
16
|
+
readonly 'color/no-hard-coded-color': {
|
|
17
|
+
readonly id: "color/no-hard-coded-color";
|
|
18
|
+
readonly severity: "error";
|
|
19
|
+
readonly summary: "Hard-coded colour literal (hex, rgb(), hsl())";
|
|
20
|
+
readonly help: "Reference a token: var(--mn-color-…) in CSS, or a semantic class. For charts use var(--mn-color-data-1…5).";
|
|
21
|
+
};
|
|
22
|
+
readonly 'typography/no-arbitrary-type': {
|
|
23
|
+
readonly id: "typography/no-arbitrary-type";
|
|
24
|
+
readonly severity: "warn";
|
|
25
|
+
readonly summary: "Arbitrary font size, weight, family, line height or letter spacing";
|
|
26
|
+
readonly help: "Use the Monarch type scale (text-2xs…text-5xl, font-medium, leading-snug, tracking-tight) and var(--mn-font-sans|mono).";
|
|
27
|
+
};
|
|
28
|
+
readonly 'spacing/off-grid': {
|
|
29
|
+
readonly id: "spacing/off-grid";
|
|
30
|
+
readonly severity: "warn";
|
|
31
|
+
readonly summary: "Spacing value off the 4px grid";
|
|
32
|
+
readonly help: "Use the spacing scale (p-1 = 4px, p-1.5 = 6px, p-2 = 8px …). Arbitrary values must be multiples of 2px or a var(--mn-space-…).";
|
|
33
|
+
};
|
|
34
|
+
readonly 'tokens/local-token-definitions': {
|
|
35
|
+
readonly id: "tokens/local-token-definitions";
|
|
36
|
+
readonly severity: "error";
|
|
37
|
+
readonly summary: "Design tokens defined locally instead of imported from Monarch";
|
|
38
|
+
readonly help: "Import @rookcom/monarch-tokens/css (plus /css/compat during migration) and set data-mn-product on <html>. Delete the local copy.";
|
|
39
|
+
};
|
|
40
|
+
readonly 'components/duplicated-primitive': {
|
|
41
|
+
readonly id: "components/duplicated-primitive";
|
|
42
|
+
readonly severity: "warn";
|
|
43
|
+
readonly summary: "Local copy of a component Monarch provides";
|
|
44
|
+
readonly help: "Import the component from @rookcom/monarch-react and delete the local file once call sites are migrated.";
|
|
45
|
+
};
|
|
46
|
+
readonly 'a11y/img-alt': {
|
|
47
|
+
readonly id: "a11y/img-alt";
|
|
48
|
+
readonly severity: "error";
|
|
49
|
+
readonly summary: "<img> without alt";
|
|
50
|
+
readonly help: "Add alt text, or alt=\"\" for decorative images (WCAG 1.1.1).";
|
|
51
|
+
};
|
|
52
|
+
readonly 'a11y/click-without-key': {
|
|
53
|
+
readonly id: "a11y/click-without-key";
|
|
54
|
+
readonly severity: "error";
|
|
55
|
+
readonly summary: "Click handler on a non-interactive element without role and keyboard handler";
|
|
56
|
+
readonly help: "Use <button> (preferred), or add role and onKeyDown plus tabIndex={0} (WCAG 2.1.1).";
|
|
57
|
+
};
|
|
58
|
+
readonly 'a11y/positive-tabindex': {
|
|
59
|
+
readonly id: "a11y/positive-tabindex";
|
|
60
|
+
readonly severity: "error";
|
|
61
|
+
readonly summary: "Positive tabIndex";
|
|
62
|
+
readonly help: "Use tabIndex={0} or -1. Positive values break the natural focus order (WCAG 2.4.3).";
|
|
63
|
+
};
|
|
64
|
+
readonly 'a11y/outline-none-without-ring': {
|
|
65
|
+
readonly id: "a11y/outline-none-without-ring";
|
|
66
|
+
readonly severity: "error";
|
|
67
|
+
readonly summary: "Focus outline removed without a visible replacement";
|
|
68
|
+
readonly help: "Pair outline-none with focus-visible:ring-2 focus-visible:ring-ring (or a Monarch component). WCAG 2.4.7 needs a visible focus indicator.";
|
|
69
|
+
};
|
|
70
|
+
readonly 'overrides/monarch-internals': {
|
|
71
|
+
readonly id: "overrides/monarch-internals";
|
|
72
|
+
readonly severity: "error";
|
|
73
|
+
readonly summary: "Overrides Monarch internals (.mn-* selectors or --mn-* variables)";
|
|
74
|
+
readonly help: "Monarch classes and variables are not a public styling API. Use component props, or request a variant or an exception through governance.";
|
|
75
|
+
};
|
|
76
|
+
readonly 'deps/monarch-version': {
|
|
77
|
+
readonly id: "deps/monarch-version";
|
|
78
|
+
readonly severity: "error";
|
|
79
|
+
readonly summary: "Monarch package version status";
|
|
80
|
+
readonly help: "Upgrade to a supported version listed in registry/compatibility.json. See the migration guide for each release.";
|
|
81
|
+
};
|
|
82
|
+
readonly 'api/deprecated': {
|
|
83
|
+
readonly id: "api/deprecated";
|
|
84
|
+
readonly severity: "warn";
|
|
85
|
+
readonly summary: "Deprecated Monarch API";
|
|
86
|
+
readonly help: "Move to the replacement named in the message before the removal version.";
|
|
87
|
+
};
|
|
88
|
+
readonly 'icons/no-sparkles': {
|
|
89
|
+
readonly id: "icons/no-sparkles";
|
|
90
|
+
readonly severity: "error";
|
|
91
|
+
readonly summary: "Sparkle icon used";
|
|
92
|
+
readonly help: "Rook does not use sparkle icons (Sparkles, Sparkle, WandSparkles and its old name Wand2). For AI features use the lucide `Bot` icon; elsewhere use a plain icon that names the thing, such as Inbox or Bell.";
|
|
93
|
+
};
|
|
94
|
+
readonly 'legacy/bridge-variable': {
|
|
95
|
+
readonly id: "legacy/bridge-variable";
|
|
96
|
+
readonly severity: "info";
|
|
97
|
+
readonly summary: "Legacy shadcn variable used directly (var(--primary) …)";
|
|
98
|
+
readonly help: "Tracked for migration. Prefer var(--mn-color-…) so the legacy bridge can eventually be removed.";
|
|
99
|
+
};
|
|
100
|
+
readonly 'governance/suppression-without-reason': {
|
|
101
|
+
readonly id: "governance/suppression-without-reason";
|
|
102
|
+
readonly severity: "warn";
|
|
103
|
+
readonly summary: "Suppression comment without a reason";
|
|
104
|
+
readonly help: "Write `monarch-ignore-next-line <rule> -- <reason>`. Suppressions without a reason are ignored.";
|
|
105
|
+
};
|
|
106
|
+
readonly 'governance/expired-exception': {
|
|
107
|
+
readonly id: "governance/expired-exception";
|
|
108
|
+
readonly severity: "error";
|
|
109
|
+
readonly summary: "Registry exception has expired";
|
|
110
|
+
readonly help: "Fix the findings it covered, or renew it in the product registry entry with a new expiry and approver.";
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export type RuleId = keyof typeof RULES;
|
|
114
|
+
export declare const RULE_IDS: RuleId[];
|
|
115
|
+
export interface RawFinding {
|
|
116
|
+
readonly rule: RuleId;
|
|
117
|
+
readonly line: number;
|
|
118
|
+
readonly column: number;
|
|
119
|
+
readonly message: string;
|
|
120
|
+
/** Overrides the rule's default severity for this finding. */
|
|
121
|
+
readonly severity?: Severity;
|
|
122
|
+
}
|
|
123
|
+
export interface FileContext {
|
|
124
|
+
/** Path relative to scan root. */
|
|
125
|
+
readonly file: string;
|
|
126
|
+
readonly ext: string;
|
|
127
|
+
readonly text: string;
|
|
128
|
+
readonly lines: readonly string[];
|
|
129
|
+
readonly deprecations: readonly Deprecation[];
|
|
130
|
+
}
|
|
131
|
+
/** Legacy variables from the shadcn-era token copies. */
|
|
132
|
+
export declare const LEGACY_TOKEN_NAMES: Set<string>;
|
|
133
|
+
export declare function isLegacyToken(name: string): boolean;
|
|
134
|
+
export declare function kebab(stem: string): string;
|
|
135
|
+
interface Tag {
|
|
136
|
+
readonly name: string;
|
|
137
|
+
readonly start: number;
|
|
138
|
+
readonly text: string;
|
|
139
|
+
}
|
|
140
|
+
/** Reads opening JSX tags, balancing braces so arrow functions don't end a tag. */
|
|
141
|
+
export declare function readTags(text: string, names: RegExp): Tag[];
|
|
142
|
+
/** Runs every file-level rule. Package-level rules live in check.ts. */
|
|
143
|
+
export declare function scanFile(ctx: FileContext): RawFinding[];
|
|
144
|
+
export interface Suppression {
|
|
145
|
+
/** Line the suppression applies to (1-based). */
|
|
146
|
+
readonly target: number;
|
|
147
|
+
readonly rules: readonly string[];
|
|
148
|
+
readonly reason: string | null;
|
|
149
|
+
readonly line: number;
|
|
150
|
+
readonly column: number;
|
|
151
|
+
}
|
|
152
|
+
export declare function readSuppressions(lines: readonly string[]): Suppression[];
|
|
153
|
+
export declare function ruleMatches(pattern: string, rule: string): boolean;
|
|
154
|
+
export {};
|
|
155
|
+
//# sourceMappingURL=rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3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