@behavioral-agentic-design-system/core 0.38.0 → 0.39.1
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/package.json +2 -2
- package/scripts/a11y-lint.cjs +47 -34
- package/scripts/a11y-ratchet.mjs +10 -23
- package/scripts/build-tokens.cjs +42 -5
- package/scripts/health-report.mjs +52 -10
- package/scripts/lib/scan-roots.cjs +143 -0
- package/scripts/lint-slop.mjs +21 -28
- package/scripts/lint-token-intent.mjs +10 -16
- package/scripts/size-audit.cjs +15 -27
- package/src/api/layers/file.ts +1 -0
- package/src/app/preview/components/page.tsx +366 -0
- package/src/app/preview/health/page.tsx +8 -5
- package/src/app/preview/history/page.tsx +11 -0
- package/src/app/shell.tsx +262 -86
- package/src/components/Foundations/Typography.stories.tsx +82 -21
- package/src/components/customize/discipline-section.tsx +94 -0
- package/src/components/customize-tab.tsx +2 -0
- package/src/components/ui/accordion.tsx +67 -5
- package/src/components/ui/alert.tsx +20 -7
- package/src/components/ui/avatar.tsx +18 -4
- package/src/components/ui/breadcrumb.tsx +47 -0
- package/src/components/ui/checkbox-card.tsx +48 -8
- package/src/components/ui/checkbox.tsx +17 -8
- package/src/components/ui/format-date.tsx +107 -0
- package/src/components/ui/progress.tsx +6 -5
- package/src/components/ui/sparkline.tsx +210 -0
- package/src/components/ui/tag.tsx +17 -1
- package/src/components/ui/tags-input.tsx +84 -11
- package/src/components/ui/toggle-group.tsx +13 -0
- package/src/components/ui/week-picker.tsx +463 -0
- package/src/data/docs-index.ts +11 -0
- package/src/data/history.json +269 -0
- package/src/stories/Accordion.stories.tsx +59 -1
- package/src/stories/ActionBar.stories.tsx +1 -1
- package/src/stories/Affix.stories.tsx +1 -1
- package/src/stories/AiBadge.stories.tsx +1 -1
- package/src/stories/Alert.stories.tsx +36 -1
- package/src/stories/AlertDialog.stories.tsx +1 -1
- package/src/stories/Anchor.stories.tsx +1 -1
- package/src/stories/AngleSlider.stories.tsx +1 -1
- package/src/stories/AspectRatio.stories.tsx +1 -1
- package/src/stories/Autocomplete.stories.tsx +1 -1
- package/src/stories/Avatar.stories.tsx +41 -1
- package/src/stories/Badge.stories.tsx +1 -1
- package/src/stories/Blockquote.stories.tsx +1 -1
- package/src/stories/BottomNavigation.stories.tsx +1 -1
- package/src/stories/Breadcrumb.stories.tsx +38 -5
- package/src/stories/Burger.stories.tsx +1 -1
- package/src/stories/Button.stories.tsx +9 -1
- package/src/stories/ButtonGroup.stories.tsx +1 -1
- package/src/stories/Calendar.stories.tsx +1 -1
- package/src/stories/Card.stories.tsx +1 -1
- package/src/stories/Carousel.stories.tsx +1 -1
- package/src/stories/Cascader.stories.tsx +1 -1
- package/src/stories/Chart.stories.tsx +1 -1
- package/src/stories/ChatBubble.stories.tsx +1 -1
- package/src/stories/ChatMarker.stories.tsx +1 -1
- package/src/stories/Checkbox.stories.tsx +36 -5
- package/src/stories/CheckboxCard.stories.tsx +37 -2
- package/src/stories/CheckboxGroup.stories.tsx +1 -1
- package/src/stories/Chip.stories.tsx +1 -1
- package/src/stories/CircularProgress.stories.tsx +17 -1
- package/src/stories/Clipboard.stories.tsx +1 -1
- package/src/stories/CloseButton.stories.tsx +1 -1
- package/src/stories/Code.stories.tsx +1 -1
- package/src/stories/Collapsible.stories.tsx +1 -1
- package/src/stories/ColorPicker.stories.tsx +1 -1
- package/src/stories/ColorSwatch.stories.tsx +1 -1
- package/src/stories/Combobox.stories.tsx +1 -1
- package/src/stories/Command.stories.tsx +1 -1
- package/src/stories/Container.stories.tsx +1 -1
- package/src/stories/ContextMenu.stories.tsx +1 -1
- package/src/stories/CopyButton.stories.tsx +9 -1
- package/src/stories/DataList.stories.tsx +1 -1
- package/src/stories/DataTable.stories.tsx +1 -1
- package/src/stories/DateField.stories.tsx +1 -1
- package/src/stories/DatePicker.stories.tsx +1 -1
- package/src/stories/DateRangePicker.stories.tsx +1 -1
- package/src/stories/Dialog.stories.tsx +1 -1
- package/src/stories/Drawer.stories.tsx +1 -1
- package/src/stories/DropdownMenu.stories.tsx +1 -1
- package/src/stories/Editable.stories.tsx +1 -1
- package/src/stories/EmptyState.stories.tsx +1 -1
- package/src/stories/Field.stories.tsx +1 -1
- package/src/stories/Fieldset.stories.tsx +1 -1
- package/src/stories/FileButton.stories.tsx +1 -1
- package/src/stories/FileUpload.stories.tsx +1 -1
- package/src/stories/FloatLabel.stories.tsx +1 -1
- package/src/stories/FloatingActionButton.stories.tsx +1 -1
- package/src/stories/FloatingIndicator.stories.tsx +1 -1
- package/src/stories/FloatingPanel.stories.tsx +9 -1
- package/src/stories/FocusTrap.stories.tsx +1 -1
- package/src/stories/FormatByte.stories.tsx +1 -1
- package/src/stories/FormatDate.stories.tsx +174 -0
- package/src/stories/FormatNumber.stories.tsx +1 -1
- package/src/stories/Highlight.stories.tsx +1 -1
- package/src/stories/HoverCard.stories.tsx +1 -1
- package/src/stories/Image.stories.tsx +1 -1
- package/src/stories/Indicator.stories.tsx +17 -1
- package/src/stories/Input.stories.tsx +1 -1
- package/src/stories/InputClearButton.stories.tsx +1 -1
- package/src/stories/InputGroup.stories.tsx +1 -1
- package/src/stories/Kbd.stories.tsx +1 -1
- package/src/stories/KeyboardShortcut.stories.tsx +1 -1
- package/src/stories/Label.stories.tsx +1 -1
- package/src/stories/Link.stories.tsx +1 -1
- package/src/stories/List.stories.tsx +1 -1
- package/src/stories/Listbox.stories.tsx +1 -1
- package/src/stories/LoadingDots.stories.tsx +1 -1
- package/src/stories/LoadingOverlay.stories.tsx +1 -1
- package/src/stories/Mark.stories.tsx +1 -1
- package/src/stories/Marquee.stories.tsx +1 -1
- package/src/stories/Masonry.stories.tsx +1 -1
- package/src/stories/Menubar.stories.tsx +1 -1
- package/src/stories/Meter.stories.tsx +1 -1
- package/src/stories/MonthPicker.stories.tsx +1 -1
- package/src/stories/MotionToggle.stories.tsx +1 -1
- package/src/stories/MultiSelect.stories.tsx +1 -1
- package/src/stories/NativeSelect.stories.tsx +1 -1
- package/src/stories/NavLink.stories.tsx +1 -1
- package/src/stories/NavigationMenu.stories.tsx +1 -1
- package/src/stories/NavigationRail.stories.tsx +9 -1
- package/src/stories/Notification.stories.tsx +1 -1
- package/src/stories/NumberInput.stories.tsx +1 -1
- package/src/stories/Overlay.stories.tsx +1 -1
- package/src/stories/Pagination.stories.tsx +1 -1
- package/src/stories/PasswordInput.stories.tsx +1 -1
- package/src/stories/PinInput.stories.tsx +1 -1
- package/src/stories/Popover.stories.tsx +1 -1
- package/src/stories/Progress.stories.tsx +11 -1
- package/src/stories/Prose.stories.tsx +1 -1
- package/src/stories/QrCode.stories.tsx +1 -1
- package/src/stories/Questionnaire.stories.tsx +1 -1
- package/src/stories/RadioGroup.stories.tsx +1 -1
- package/src/stories/RatingGroup.stories.tsx +1 -1
- package/src/stories/Resizable.stories.tsx +1 -1
- package/src/stories/Result.stories.tsx +1 -1
- package/src/stories/Reveal.stories.tsx +1 -1
- package/src/stories/RollingNumber.stories.tsx +1 -1
- package/src/stories/ScrollArea.stories.tsx +1 -1
- package/src/stories/SearchInput.stories.tsx +1 -1
- package/src/stories/SegmentedControl.stories.tsx +1 -1
- package/src/stories/Select.stories.tsx +1 -1
- package/src/stories/Separator.stories.tsx +1 -1
- package/src/stories/Sheet.stories.tsx +10 -4
- package/src/stories/Sidebar.stories.tsx +1 -1
- package/src/stories/SignaturePad.stories.tsx +1 -1
- package/src/stories/SimpleGrid.stories.tsx +1 -1
- package/src/stories/Skeleton.stories.tsx +1 -1
- package/src/stories/SkeletonTable.stories.tsx +1 -1
- package/src/stories/SkipLink.stories.tsx +1 -1
- package/src/stories/Slider.stories.tsx +1 -1
- package/src/stories/Sonner.stories.tsx +1 -1
- package/src/stories/Sparkline.stories.tsx +244 -0
- package/src/stories/Spinner.stories.tsx +9 -1
- package/src/stories/Spoiler.stories.tsx +1 -1
- package/src/stories/Squircle.stories.tsx +1 -1
- package/src/stories/Stack.stories.tsx +1 -1
- package/src/stories/StatusBadge.stories.tsx +1 -1
- package/src/stories/Stepper.stories.tsx +1 -1
- package/src/stories/Switch.stories.tsx +1 -1
- package/src/stories/Table.stories.tsx +1 -1
- package/src/stories/Tabs.stories.tsx +1 -1
- package/src/stories/Tag.stories.tsx +23 -1
- package/src/stories/TagsInput.stories.tsx +46 -1
- package/src/stories/Text.stories.tsx +1 -1
- package/src/stories/Textarea.stories.tsx +1 -1
- package/src/stories/ThemeIcon.stories.tsx +1 -1
- package/src/stories/TimePicker.stories.tsx +1 -1
- package/src/stories/Timeline.stories.tsx +9 -1
- package/src/stories/Timer.stories.tsx +1 -1
- package/src/stories/Toggle.stories.tsx +1 -1
- package/src/stories/ToggleGroup.stories.tsx +21 -1
- package/src/stories/ToggleTip.stories.tsx +1 -1
- package/src/stories/Toolbar.stories.tsx +1 -1
- package/src/stories/Tooltip.stories.tsx +1 -1
- package/src/stories/Tour.stories.tsx +1 -1
- package/src/stories/TransferList.stories.tsx +1 -1
- package/src/stories/TreeSelect.stories.tsx +1 -1
- package/src/stories/TreeView.stories.tsx +1 -1
- package/src/stories/TypingIndicator.stories.tsx +1 -1
- package/src/stories/VisuallyHidden.stories.tsx +1 -1
- package/src/stories/Watermark.stories.tsx +1 -1
- package/src/stories/WeekPicker.stories.tsx +90 -0
- package/src/stories/WordRotate.stories.tsx +1 -1
- package/src/stories/YearPicker.stories.tsx +1 -1
- package/src/stories/story-groups.json +199 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.1",
|
|
4
4
|
"description": "BADS core — tokens, shadcn/ui components, and the BADS template shell (app routes, customize tab, theme hooks). Forks consume this and re-export, keeping client repos to ~30 lines of glue.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
|
|
@@ -261,6 +261,6 @@
|
|
|
261
261
|
}
|
|
262
262
|
},
|
|
263
263
|
"devDependencies": {
|
|
264
|
-
"@types/react-dom": "^19.2.
|
|
264
|
+
"@types/react-dom": "^19.2.7"
|
|
265
265
|
}
|
|
266
266
|
}
|
package/scripts/a11y-lint.cjs
CHANGED
|
@@ -20,47 +20,31 @@
|
|
|
20
20
|
* SADS-1 Font weight floor — text-xs/text-sm must be font-medium (500) or heavier
|
|
21
21
|
*
|
|
22
22
|
* Run:
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* bads-a11y-lint # report violations, exit 1 on fail
|
|
24
|
+
* bads-a11y-lint --warn # report but exit 0 (advisory)
|
|
25
|
+
* bads-a11y-lint path/to.tsx # scan a specific file
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
'use strict';
|
|
29
29
|
|
|
30
30
|
const fs = require('fs');
|
|
31
31
|
const path = require('path');
|
|
32
|
+
const { resolveScanFiles, guardEmptyScan } = require('./lib/scan-roots.cjs');
|
|
32
33
|
|
|
33
34
|
// Shipped as the `bads-a11y-lint` bin. process.cwd() means the same script
|
|
34
35
|
// scans the right tree whether it runs in upstream BADS (CWD = repo root) or
|
|
35
|
-
// in a client fork (CWD = fork root).
|
|
36
|
-
//
|
|
36
|
+
// in a client fork (CWD = fork root). Scan roots (and the "did this actually
|
|
37
|
+
// scan anything" guard) live in ./lib/scan-roots.cjs, shared with
|
|
38
|
+
// size-audit.cjs, lint-slop.mjs, a11y-ratchet.mjs and lint-token-intent.mjs —
|
|
39
|
+
// see that file for why: these five used to carry drifted copies of the same
|
|
40
|
+
// list, and a consumer repo whose tree matched none of them got a silent
|
|
41
|
+
// false "no violations found" instead of an error. Set BADS_LINT_ROOTS to
|
|
42
|
+
// point this at a non-standard tree.
|
|
37
43
|
const ROOT = process.cwd();
|
|
38
44
|
const advisory = process.argv.includes('--warn');
|
|
39
|
-
const explicitPaths = process.argv.slice(2).filter((a) => !a.startsWith('--'));
|
|
40
|
-
|
|
41
|
-
const SCAN_ROOTS = [
|
|
42
|
-
'app',
|
|
43
|
-
'components',
|
|
44
|
-
'packages/core/src/components',
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
function walk(dir, out = []) {
|
|
48
|
-
if (!fs.existsSync(dir)) return out;
|
|
49
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
50
|
-
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;
|
|
51
|
-
const full = path.join(dir, entry.name);
|
|
52
|
-
if (entry.isDirectory()) {
|
|
53
|
-
walk(full, out);
|
|
54
|
-
} else if (/\.tsx?$/.test(entry.name)) {
|
|
55
|
-
out.push(full);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return out;
|
|
59
|
-
}
|
|
60
45
|
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
: SCAN_ROOTS.flatMap((r) => walk(path.join(ROOT, r)));
|
|
46
|
+
const scan = resolveScanFiles({ root: ROOT, argv: process.argv.slice(2) });
|
|
47
|
+
const files = scan.files;
|
|
64
48
|
|
|
65
49
|
const issues = [];
|
|
66
50
|
|
|
@@ -146,6 +130,17 @@ const ON_CLICK_NON_INTERACTIVE = /<(?:div|span|p)\b[^>]*onClick=/;
|
|
|
146
130
|
|
|
147
131
|
const VAGUE_LINK_TEXT = /^(?:click here|here|read more|learn more|more|click)\.?$/i;
|
|
148
132
|
|
|
133
|
+
// next/og's ImageResponse (Satori) renders through its own layout engine
|
|
134
|
+
// with no access to computed CSS custom properties or a Tailwind stylesheet
|
|
135
|
+
// — only literal inline style values reach it. hex-literal and
|
|
136
|
+
// inline-px-font are structurally impossible to satisfy in that file, not a
|
|
137
|
+
// lapse (found 2026-09-09, expanding scan roots to include
|
|
138
|
+
// packages/core/src/app surfaced these for the first time — they were never
|
|
139
|
+
// scanned before). Skip just those two rules for the route, not the whole
|
|
140
|
+
// file. Forks only ever re-export this route (see the file's own header
|
|
141
|
+
// comment), so the violation only ever exists in this one upstream copy.
|
|
142
|
+
const SATORI_TOKEN_EXEMPT_FILE = /\bopengraph-image\.tsx$/;
|
|
143
|
+
|
|
149
144
|
for (const file of files) {
|
|
150
145
|
let src;
|
|
151
146
|
try { src = fs.readFileSync(file, 'utf8'); } catch { continue; }
|
|
@@ -155,6 +150,7 @@ for (const file of files) {
|
|
|
155
150
|
if (file.includes('/e2e/') || file.endsWith('.spec.ts') || file.endsWith('.test.ts')) continue;
|
|
156
151
|
// Skip story files except for headline checks (they're fine to be terse).
|
|
157
152
|
const isStory = file.endsWith('.stories.tsx');
|
|
153
|
+
const skipTokenRules = SATORI_TOKEN_EXEMPT_FILE.test(file);
|
|
158
154
|
|
|
159
155
|
const TS = scaleFor(file);
|
|
160
156
|
|
|
@@ -163,14 +159,26 @@ for (const file of files) {
|
|
|
163
159
|
const line = lines[i];
|
|
164
160
|
const lineNum = i + 1;
|
|
165
161
|
|
|
166
|
-
|
|
162
|
+
// Escape hatch, same convention as allow-small-text below: same line or
|
|
163
|
+
// the line directly above. Added 2026-09-09 alongside the Satori file
|
|
164
|
+
// exemption — until now these two rules had no bypass at all, unlike
|
|
165
|
+
// every other check in this file. Legitimate use: a hex value shown as
|
|
166
|
+
// literal TEXT CONTENT describing a color (e.g. the Customize tab's own
|
|
167
|
+
// "#171717 · selected" picker label) is data, not an uncontrolled style
|
|
168
|
+
// decision — the thing SC 1.4.6 actually cares about.
|
|
169
|
+
const allowHex = /\/\/\s*allow-hex-literal/.test(line)
|
|
170
|
+
|| (i > 0 && /allow-hex-literal/.test(lines[i - 1]));
|
|
171
|
+
const allowInlinePx = /\/\/\s*allow-inline-px-font/.test(line)
|
|
172
|
+
|| (i > 0 && /allow-inline-px-font/.test(lines[i - 1]));
|
|
173
|
+
|
|
174
|
+
if (HARDCODED_HEX.test(line) && !skipTokenRules && !allowHex) {
|
|
167
175
|
flag(file, lineNum, '1.4.6', 'hex-literal',
|
|
168
|
-
'Hardcoded hex color. Use a semantic token or @theme variable instead.');
|
|
176
|
+
'Hardcoded hex color. Use a semantic token or @theme variable instead, or add "// allow-hex-literal" if this is a hex value shown as text content, not a style.');
|
|
169
177
|
}
|
|
170
178
|
|
|
171
|
-
if (INLINE_PX_FONT.test(line)) {
|
|
179
|
+
if (INLINE_PX_FONT.test(line) && !skipTokenRules && !allowInlinePx) {
|
|
172
180
|
flag(file, lineNum, '1.4.4', 'inline-px-font',
|
|
173
|
-
'Inline pixel font size. Use a text-* utility or rem-based value so 200% zoom still works.');
|
|
181
|
+
'Inline pixel font size. Use a text-* utility or rem-based value so 200% zoom still works, or add "// allow-inline-px-font" with a reason (e.g. Satori/next-og cannot resolve tokens).');
|
|
174
182
|
}
|
|
175
183
|
|
|
176
184
|
// Same escape hatch as the named-step check below. A vendored component that ships
|
|
@@ -283,7 +291,12 @@ for (const file of files) {
|
|
|
283
291
|
// ---- output ------------------------------------------------------------
|
|
284
292
|
|
|
285
293
|
if (issues.length === 0) {
|
|
286
|
-
|
|
294
|
+
if (guardEmptyScan(scan, 'a11y-lint')) { /* exited */ }
|
|
295
|
+
console.log(
|
|
296
|
+
scan.files.length
|
|
297
|
+
? '✓ a11y-lint: no AAA violations found.'
|
|
298
|
+
: '✓ a11y-lint: no AAA violations found (0 files matched under existing scan roots).'
|
|
299
|
+
);
|
|
287
300
|
process.exit(0);
|
|
288
301
|
}
|
|
289
302
|
|
package/scripts/a11y-ratchet.mjs
CHANGED
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
* gate exists to prevent.
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
|
-
import fs from "node:fs";
|
|
37
36
|
import path from "node:path";
|
|
38
37
|
import { fileURLToPath } from "node:url";
|
|
39
38
|
import { execFileSync } from "node:child_process";
|
|
@@ -44,6 +43,8 @@ import {
|
|
|
44
43
|
BASELINE_FILE,
|
|
45
44
|
SCHEMA_VERSION,
|
|
46
45
|
} from "./ratchet.mjs";
|
|
46
|
+
import scanRootsLib from "./lib/scan-roots.cjs";
|
|
47
|
+
const { resolveScanFiles, guardEmptyScan } = scanRootsLib;
|
|
47
48
|
|
|
48
49
|
const ROOT = process.cwd();
|
|
49
50
|
// The lint is resolved relative to THIS file, not to cwd, so a fork running the
|
|
@@ -61,32 +62,12 @@ const INIT = argv.includes("--init");
|
|
|
61
62
|
const ADVISORY = argv.includes("--warn");
|
|
62
63
|
const RULE_ID = `a11y:${RULE}`;
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
// (`npx bads-a11y-ratchet app/_content app/shell`) the way size-audit does.
|
|
66
|
-
const argRoots = argv.filter((a, i) => !a.startsWith("--") && !argv[i - 1]?.startsWith("--"));
|
|
67
|
-
const SCAN_ROOTS = argRoots.length
|
|
68
|
-
? argRoots
|
|
69
|
-
: ["app", "components", "packages/core/src/components", "packages/core/src/app"];
|
|
65
|
+
const scan = resolveScanFiles({ root: ROOT, argv: process.argv.slice(2), allowDirArgs: true });
|
|
70
66
|
|
|
71
67
|
// ---------------------------------------------------------------------------
|
|
72
68
|
// Measurement
|
|
73
69
|
// ---------------------------------------------------------------------------
|
|
74
70
|
|
|
75
|
-
function scanFiles() {
|
|
76
|
-
const out = [];
|
|
77
|
-
const walk = (dir) => {
|
|
78
|
-
if (!fs.existsSync(dir)) return;
|
|
79
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
80
|
-
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
81
|
-
const full = path.join(dir, entry.name);
|
|
82
|
-
if (entry.isDirectory()) walk(full);
|
|
83
|
-
else if (/\.tsx$/.test(entry.name) && !/\.stories\.tsx$/.test(entry.name)) out.push(full);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
for (const r of SCAN_ROOTS) walk(path.join(ROOT, r));
|
|
87
|
-
return out.map((f) => path.relative(ROOT, f));
|
|
88
|
-
}
|
|
89
|
-
|
|
90
71
|
/**
|
|
91
72
|
* `{ relativePath: count }` for one a11y-lint rule.
|
|
92
73
|
*
|
|
@@ -131,7 +112,13 @@ function measure(files) {
|
|
|
131
112
|
// Run
|
|
132
113
|
// ---------------------------------------------------------------------------
|
|
133
114
|
|
|
134
|
-
const files =
|
|
115
|
+
const files = scan.files;
|
|
116
|
+
// Guard BEFORE measuring, not just before printing: with 0 files, `measure`
|
|
117
|
+
// returns an all-zero count for every rule, which reads as "no violations,
|
|
118
|
+
// no growth" — indistinguishable from a genuinely clean scan. That's the
|
|
119
|
+
// exact false-green class this shares with a11y-lint/size-audit/lint-slop
|
|
120
|
+
// (see ./lib/scan-roots.cjs). Refuse before any ratchet comparison runs.
|
|
121
|
+
if (guardEmptyScan(scan, 'a11y-ratchet')) { /* exited */ }
|
|
135
122
|
const current = measure(files);
|
|
136
123
|
|
|
137
124
|
if (INIT) {
|
package/scripts/build-tokens.cjs
CHANGED
|
@@ -31,9 +31,42 @@ const path = require('path');
|
|
|
31
31
|
// process.cwd() means the same script works for upstream BADS (CWD = repo
|
|
32
32
|
// root) and for client forks alike.
|
|
33
33
|
const ROOT = process.cwd();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
|
|
35
|
+
// Same candidate resolution wcag-audit.cjs uses. The old single hardcoded
|
|
36
|
+
// `packages/core/src/tokens.json` assumed the consumer was a *fork* (which has
|
|
37
|
+
// that directory). A repo that merely installed the package and keeps
|
|
38
|
+
// tokens.json at its root got ENOENT before printing anything — the identical
|
|
39
|
+
// bug fixed in wcag-audit on 2026-08-24, missed here. Found again 2026-09-09
|
|
40
|
+
// from a standalone consumer, so the resolution now lives in one shared helper
|
|
41
|
+
// (see resolveTokens below) rather than being copied a third time.
|
|
42
|
+
const TOKEN_CANDIDATES = [
|
|
43
|
+
process.env.BADS_TOKENS,
|
|
44
|
+
path.join(ROOT, 'packages/core/src/tokens.json'),
|
|
45
|
+
path.join(ROOT, 'tokens.json'),
|
|
46
|
+
].filter(Boolean);
|
|
47
|
+
|
|
48
|
+
const TOKENS = TOKEN_CANDIDATES.find((p) => fs.existsSync(p));
|
|
49
|
+
if (!TOKENS) {
|
|
50
|
+
console.error(
|
|
51
|
+
'build-tokens: no tokens.json found. Looked in:\n' +
|
|
52
|
+
TOKEN_CANDIDATES.map((p) => ` ${p}`).join('\n') +
|
|
53
|
+
'\n\nSet BADS_TOKENS=/path/to/tokens.json to point at it explicitly.'
|
|
54
|
+
);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Generated CSS lands beside whichever tokens.json we actually read, so a
|
|
59
|
+
// consumer with tokens.json at its root gets ./styles.css rather than a write
|
|
60
|
+
// into a packages/core path it doesn't have. BADS_CSS_OUT overrides the dir.
|
|
61
|
+
const CSS_OUT_DIR = process.env.BADS_CSS_OUT
|
|
62
|
+
? path.resolve(process.env.BADS_CSS_OUT)
|
|
63
|
+
: path.dirname(TOKENS);
|
|
64
|
+
const PKG_CSS = path.join(CSS_OUT_DIR, 'styles.css');
|
|
65
|
+
const PKG_FONTS_CDN_CSS = path.join(CSS_OUT_DIR, 'fonts-cdn.css');
|
|
66
|
+
|
|
67
|
+
// The preview app's globals.css only exists in upstream BADS and in forks that
|
|
68
|
+
// ship the showcase. A package consumer has no styles/ dir, so writing there
|
|
69
|
+
// would either fail or scatter files — skip it unless the dir is already there.
|
|
37
70
|
const APP_CSS = path.join(ROOT, 'styles/globals.css');
|
|
38
71
|
const CLIENT_EXTRAS = path.join(ROOT, 'styles/client-extras.css');
|
|
39
72
|
|
|
@@ -1307,5 +1340,9 @@ ${borderColorUtilities}
|
|
|
1307
1340
|
}
|
|
1308
1341
|
${clientExtras}`;
|
|
1309
1342
|
|
|
1310
|
-
fs.
|
|
1311
|
-
|
|
1343
|
+
if (fs.existsSync(path.dirname(APP_CSS))) {
|
|
1344
|
+
fs.writeFileSync(APP_CSS, appCss);
|
|
1345
|
+
console.log(`✓ wrote ${path.relative(ROOT, APP_CSS)}${clientExtras ? ' (with client-extras)' : ''}`);
|
|
1346
|
+
} else {
|
|
1347
|
+
console.log('· skipped styles/globals.css (no styles/ dir — package consumer, not a fork)');
|
|
1348
|
+
}
|
|
@@ -50,6 +50,47 @@ function resolvePackageOwned(relPath) {
|
|
|
50
50
|
return fs.existsSync(resolved) ? resolved : null;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// ---- signal counting ------------------------------------------------------
|
|
54
|
+
//
|
|
55
|
+
// Three ways the v1 counters measured something other than what their penalty
|
|
56
|
+
// says, found 2026-09-11 by reading the rows behind every component flagged
|
|
57
|
+
// on the September report:
|
|
58
|
+
//
|
|
59
|
+
// - corrections: every word occurrence counted as a "recurrence", so one
|
|
60
|
+
// long entry naming Command seven times scored as seven, and entries
|
|
61
|
+
// moved to the Archive (which corrections.md defines as no longer
|
|
62
|
+
// actively recurring) kept penalizing forever. A recurrence is an active
|
|
63
|
+
// entry, so that is what is counted.
|
|
64
|
+
// - ux rows: a finding penalized forever, even after the fix landed,
|
|
65
|
+
// because ux-tests.jsonl had no way to say "resolved". It now carries the
|
|
66
|
+
// same status field as drift.jsonl and research.jsonl.
|
|
67
|
+
// - build rows: newer rows name the component in `component` or `name`,
|
|
68
|
+
// not `candidate`, and were silently skipped.
|
|
69
|
+
|
|
70
|
+
/** Number of active (non-archived) corrections entries that name `name`. */
|
|
71
|
+
function activeCorrectionsNaming(md, name) {
|
|
72
|
+
const archiveAt = md.search(/^## Archive\b/m);
|
|
73
|
+
const active = archiveAt === -1 ? md : md.slice(0, archiveAt);
|
|
74
|
+
const bodies = active.split(/^### \d{3}\./m).slice(1);
|
|
75
|
+
const re = new RegExp(`\\b${name}\\b`);
|
|
76
|
+
return bodies.filter((b) => re.test(b)).length;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The component a component-builds.jsonl row is about, across row shapes. */
|
|
80
|
+
function buildRowComponent(row) {
|
|
81
|
+
return ((row.candidate || "").split(" ")[0] || row.component || row.name || "").trim();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Whether a ux-tests.jsonl row still counts against the component. */
|
|
85
|
+
function uxRowPenalizes(row) {
|
|
86
|
+
return row.status !== "resolved" && row.status !== "accepted";
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The human-readable text of a ux-tests.jsonl row (older rows use summary). */
|
|
90
|
+
function uxRowText(row) {
|
|
91
|
+
return String(row.finding ?? row.summary ?? "");
|
|
92
|
+
}
|
|
93
|
+
|
|
53
94
|
function main() {
|
|
54
95
|
// Repo-root resolution is cwd-based (not file-relative) so this works both in
|
|
55
96
|
// upstream BADS (scripts/ -> repo root) and after shipping as a package bin
|
|
@@ -117,22 +158,23 @@ function main() {
|
|
|
117
158
|
const penalties = [];
|
|
118
159
|
let dataPoints = 0;
|
|
119
160
|
|
|
120
|
-
// signal: ux-test findings (rows match on the component field)
|
|
161
|
+
// signal: ux-test findings (rows match on the component field). A resolved
|
|
162
|
+
// or accepted row is still a data point, it just no longer penalizes.
|
|
121
163
|
for (const r of uxRows.filter((r) => r.component === name)) {
|
|
122
164
|
dataPoints++;
|
|
123
|
-
const p = UX_PENALTY[r.severity] ?? 0;
|
|
124
|
-
if (p) penalties.push({ source: "ux-test", points: p, why: `${r.severity}: ${
|
|
165
|
+
const p = uxRowPenalizes(r) ? UX_PENALTY[r.severity] ?? 0 : 0;
|
|
166
|
+
if (p) penalties.push({ source: "ux-test", points: p, why: `${r.severity}: ${uxRowText(r).slice(0, 100)}` });
|
|
125
167
|
}
|
|
126
168
|
|
|
127
|
-
// signal: corrections recurrences (
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
dataPoints +=
|
|
131
|
-
penalties.push({ source: "corrections", points: Math.min(
|
|
169
|
+
// signal: corrections recurrences (active entries naming it, capped)
|
|
170
|
+
const entries = activeCorrectionsNaming(corrections, name);
|
|
171
|
+
if (entries) {
|
|
172
|
+
dataPoints += entries;
|
|
173
|
+
penalties.push({ source: "corrections", points: Math.min(entries * 5, 15), why: `named in ${entries} active correction(s)` });
|
|
132
174
|
}
|
|
133
175
|
|
|
134
176
|
// signal: build-ledger outcome (latest row for this component)
|
|
135
|
-
const builds = buildRows.filter((r) => (r
|
|
177
|
+
const builds = buildRows.filter((r) => buildRowComponent(r) === name);
|
|
136
178
|
if (builds.length) {
|
|
137
179
|
dataPoints += builds.length;
|
|
138
180
|
const last = builds[builds.length - 1];
|
|
@@ -244,4 +286,4 @@ function isMainModule() {
|
|
|
244
286
|
|
|
245
287
|
if (isMainModule()) main();
|
|
246
288
|
|
|
247
|
-
export { resolvePackageOwned, isMainModule, main };
|
|
289
|
+
export { resolvePackageOwned, isMainModule, main, activeCorrectionsNaming, buildRowComponent, uxRowPenalizes, uxRowText };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* scan-roots — the file-discovery logic shared by every static scanner
|
|
4
|
+
* shipped as a bin (a11y-lint, size-audit, lint-slop, a11y-ratchet,
|
|
5
|
+
* lint-token-intent).
|
|
6
|
+
*
|
|
7
|
+
* Why this exists: each of those five scripts carried its own near-duplicate
|
|
8
|
+
* SCAN_ROOTS list and its own walk(), and they'd drifted — a11y-lint and
|
|
9
|
+
* size-audit disagreed on whether `src` was a root, lint-slop scanned
|
|
10
|
+
* `packages/core/src/app` and the other two didn't. One list now, imported by
|
|
11
|
+
* all five, so a root added for one scanner is a root for all of them.
|
|
12
|
+
*
|
|
13
|
+
* The bug this was written to fix (found 2026-09-09, from a standalone
|
|
14
|
+
* consumer that installed @core but kept its own tree shape): when NONE of
|
|
15
|
+
* the default scan roots exist — which is the normal case for a consumer
|
|
16
|
+
* repo, not a BADS fork — `files` resolves to `[]`, `issues` stays `[]`, and
|
|
17
|
+
* every one of the five scripts printed a "✓ clean" message and exited 0.
|
|
18
|
+
* That is not "no violations." It is "the scanner never ran," and it looked
|
|
19
|
+
* identical to success. `resolveScanFiles` below returns enough information
|
|
20
|
+
* for the caller to tell the two apart and refuse to report a false pass.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const fs = require('fs');
|
|
24
|
+
const path = require('path');
|
|
25
|
+
|
|
26
|
+
const DEFAULT_SCAN_ROOTS = [
|
|
27
|
+
'app',
|
|
28
|
+
'components',
|
|
29
|
+
'src',
|
|
30
|
+
'packages/core/src/components',
|
|
31
|
+
'packages/core/src/app',
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
function walk(dir, out, opts) {
|
|
35
|
+
out = out || [];
|
|
36
|
+
opts = opts || {};
|
|
37
|
+
if (!fs.existsSync(dir)) return out;
|
|
38
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
39
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;
|
|
40
|
+
const full = path.join(dir, entry.name);
|
|
41
|
+
if (entry.isDirectory()) {
|
|
42
|
+
walk(full, out, opts);
|
|
43
|
+
} else if (/\.tsx?$/.test(entry.name)) {
|
|
44
|
+
if (opts.excludeStories && /\.stories\.tsx?$/.test(entry.name)) continue;
|
|
45
|
+
out.push(full);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Resolve the file list a scanner should run against.
|
|
53
|
+
*
|
|
54
|
+
* Precedence: explicit file paths on the CLI > explicit directory args (only
|
|
55
|
+
* when `allowDirArgs` is set — size-audit and a11y-ratchet support
|
|
56
|
+
* `bads-size-audit app components`; a11y-lint and lint-slop only ever took
|
|
57
|
+
* file paths, so leave them off) > BADS_LINT_ROOTS env override > the
|
|
58
|
+
* built-in default list, each filtered by existsSync.
|
|
59
|
+
*
|
|
60
|
+
* @param {object} opts
|
|
61
|
+
* @param {string} opts.root - process.cwd() of the invoking script
|
|
62
|
+
* @param {string[]} opts.argv - process.argv.slice(2)
|
|
63
|
+
* @param {string[]} [opts.scanRoots] - override the default root list
|
|
64
|
+
* (still subject to BADS_LINT_ROOTS taking precedence)
|
|
65
|
+
* @param {boolean} [opts.excludeStories]
|
|
66
|
+
* @param {boolean} [opts.allowDirArgs]
|
|
67
|
+
* @returns {{files: string[], mode: 'explicit'|'dir-args'|'default',
|
|
68
|
+
* rootsChecked: string[], rootsFound: string[]}}
|
|
69
|
+
*/
|
|
70
|
+
function resolveScanFiles(opts) {
|
|
71
|
+
const root = opts.root;
|
|
72
|
+
const argv = opts.argv || [];
|
|
73
|
+
const scanRoots = opts.scanRoots || DEFAULT_SCAN_ROOTS;
|
|
74
|
+
const excludeStories = !!opts.excludeStories;
|
|
75
|
+
const allowDirArgs = !!opts.allowDirArgs;
|
|
76
|
+
|
|
77
|
+
const positional = argv.filter((a) => !a.startsWith('--'));
|
|
78
|
+
|
|
79
|
+
let explicitPaths = positional;
|
|
80
|
+
let dirArgs = [];
|
|
81
|
+
if (allowDirArgs) {
|
|
82
|
+
dirArgs = positional.filter((p) => fs.existsSync(p) && fs.statSync(p).isDirectory());
|
|
83
|
+
explicitPaths = positional.filter((p) => !dirArgs.includes(p));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (explicitPaths.length) {
|
|
87
|
+
return {
|
|
88
|
+
files: explicitPaths.map((p) => path.resolve(p)),
|
|
89
|
+
mode: 'explicit',
|
|
90
|
+
rootsChecked: [],
|
|
91
|
+
rootsFound: [],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let roots = dirArgs.length ? dirArgs : scanRoots;
|
|
96
|
+
let mode = dirArgs.length ? 'dir-args' : 'default';
|
|
97
|
+
|
|
98
|
+
if (!dirArgs.length && process.env.BADS_LINT_ROOTS) {
|
|
99
|
+
roots = process.env.BADS_LINT_ROOTS.split(',').map((s) => s.trim()).filter(Boolean);
|
|
100
|
+
mode = 'env';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const rootsChecked = roots.map((r) => (path.isAbsolute(r) ? r : path.join(root, r)));
|
|
104
|
+
const rootsFound = rootsChecked.filter((r) => fs.existsSync(r));
|
|
105
|
+
const files = rootsFound.flatMap((r) => walk(r, [], { excludeStories }));
|
|
106
|
+
|
|
107
|
+
return { files, mode, rootsChecked, rootsFound };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Print the shared "did this scan actually run" diagnostic and, when the
|
|
112
|
+
* scan silently found nothing to look at, exit loudly instead of letting the
|
|
113
|
+
* caller print a "✓ clean" message over zero evidence.
|
|
114
|
+
*
|
|
115
|
+
* A scanner calls this once it has `files` and `issues.length === 0`. It is a
|
|
116
|
+
* no-op (returns false) when there's real signal that the scan ran — either
|
|
117
|
+
* files were found, or the caller passed explicit paths, or at least one
|
|
118
|
+
* default root existed on disk and simply held no matching files. It exits
|
|
119
|
+
* the process when NONE of the scan roots exist: that's the case that used to
|
|
120
|
+
* print "no violations found" while having read nothing.
|
|
121
|
+
*
|
|
122
|
+
* @param {ReturnType<typeof resolveScanFiles>} scan
|
|
123
|
+
* @param {string} binName - e.g. 'a11y-lint', for the error message
|
|
124
|
+
* @returns {boolean} true if it exited (caller code after this is dead)
|
|
125
|
+
*/
|
|
126
|
+
function guardEmptyScan(scan, binName) {
|
|
127
|
+
if (scan.files.length > 0) return false;
|
|
128
|
+
if (scan.mode === 'explicit') return false; // caller pointed at specific files; empty is on them
|
|
129
|
+
if (scan.rootsFound.length > 0) return false; // roots exist, they're just clean — real signal
|
|
130
|
+
|
|
131
|
+
console.error(
|
|
132
|
+
`${binName}: 0 files found — none of the scan roots exist in this repo, so nothing was ` +
|
|
133
|
+
`checked. This is NOT "no violations."\n\n` +
|
|
134
|
+
`Looked for:\n` +
|
|
135
|
+
scan.rootsChecked.map((r) => ` ${r}`).join('\n') +
|
|
136
|
+
`\n\nPass file or directory paths explicitly, or set BADS_LINT_ROOTS=` +
|
|
137
|
+
`"path/one,path/two" to point at your actual source tree.`
|
|
138
|
+
);
|
|
139
|
+
process.exit(1);
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = { DEFAULT_SCAN_ROOTS, walk, resolveScanFiles, guardEmptyScan };
|
package/scripts/lint-slop.mjs
CHANGED
|
@@ -79,38 +79,26 @@ import path from "node:path";
|
|
|
79
79
|
// repo root.
|
|
80
80
|
const ROOT = process.cwd();
|
|
81
81
|
import { RULES, FILE_RULES } from "./slop-rules.mjs";
|
|
82
|
+
// scan-roots.cjs is CommonJS (shared with the three .cjs bins); the default
|
|
83
|
+
// import is Node's CJS→ESM interop and always carries the full
|
|
84
|
+
// module.exports object, unlike named imports off an arbitrary CJS module.
|
|
85
|
+
import scanRootsLib from "./lib/scan-roots.cjs";
|
|
86
|
+
const { resolveScanFiles, guardEmptyScan } = scanRootsLib;
|
|
82
87
|
|
|
83
88
|
const advisory = process.argv.includes("--warn");
|
|
84
|
-
const explicitPaths = process.argv.slice(2).filter((a) => !a.startsWith("--"));
|
|
85
89
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// (those live in scripts/, out of scan scope).
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
function walk(dir, out = []) {
|
|
100
|
-
if (!fs.existsSync(dir)) return out;
|
|
101
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
102
|
-
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
103
|
-
const full = path.join(dir, entry.name);
|
|
104
|
-
if (entry.isDirectory()) walk(full, out);
|
|
105
|
-
else if (/\.tsx?$/.test(entry.name) && !/\.stories\.tsx?$/.test(entry.name))
|
|
106
|
-
out.push(full);
|
|
107
|
-
}
|
|
108
|
-
return out;
|
|
109
|
-
}
|
|
90
|
+
// Centralized in ./lib/scan-roots.cjs — see that file for why: this script,
|
|
91
|
+
// a11y-lint.cjs, size-audit.cjs, a11y-ratchet.mjs and lint-token-intent.mjs
|
|
92
|
+
// used to each keep a drifted copy of the same root list. Set
|
|
93
|
+
// BADS_LINT_ROOTS to point this at a non-standard tree.
|
|
94
|
+
const scan = resolveScanFiles({
|
|
95
|
+
root: ROOT,
|
|
96
|
+
argv: process.argv.slice(2),
|
|
97
|
+
excludeStories: true,
|
|
98
|
+
});
|
|
110
99
|
|
|
111
100
|
function fileList() {
|
|
112
|
-
|
|
113
|
-
return SCAN_ROOTS.flatMap((r) => walk(path.join(ROOT, r)));
|
|
101
|
+
return scan.files;
|
|
114
102
|
}
|
|
115
103
|
|
|
116
104
|
const findings = [];
|
|
@@ -184,7 +172,12 @@ for (const file of fileList()) {
|
|
|
184
172
|
}
|
|
185
173
|
|
|
186
174
|
if (findings.length === 0) {
|
|
187
|
-
|
|
175
|
+
if (guardEmptyScan(scan, "lint-slop")) { /* exited */ }
|
|
176
|
+
console.log(
|
|
177
|
+
scan.files.length
|
|
178
|
+
? "✓ lint-slop: no AI-slop signals found."
|
|
179
|
+
: "✓ lint-slop: no AI-slop signals found (0 files matched under existing scan roots)."
|
|
180
|
+
);
|
|
188
181
|
process.exit(0);
|
|
189
182
|
}
|
|
190
183
|
|
|
@@ -30,6 +30,8 @@
|
|
|
30
30
|
*/
|
|
31
31
|
import fs from "node:fs";
|
|
32
32
|
import path from "node:path";
|
|
33
|
+
import scanRootsLib from "./lib/scan-roots.cjs";
|
|
34
|
+
const { resolveScanFiles, guardEmptyScan } = scanRootsLib;
|
|
33
35
|
|
|
34
36
|
// Repo-root resolution is cwd-based (not file-relative) so this works both in
|
|
35
37
|
// upstream BADS (scripts/ -> repo root) and after shipping as a package bin
|
|
@@ -39,22 +41,9 @@ const ROOT = process.cwd();
|
|
|
39
41
|
const argv = process.argv.slice(2);
|
|
40
42
|
const STRICT = argv.includes("--strict");
|
|
41
43
|
const LOG = argv.includes("--log");
|
|
42
|
-
const fileArgs = argv.filter((a) => !a.startsWith("--"));
|
|
43
44
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const tsxFiles = [];
|
|
47
|
-
const walk = (dir) => {
|
|
48
|
-
if (!fs.existsSync(dir)) return;
|
|
49
|
-
for (const d of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
50
|
-
if (d.name === "node_modules" || d.name.startsWith(".")) continue;
|
|
51
|
-
const p = path.join(dir, d.name);
|
|
52
|
-
if (d.isDirectory()) walk(p);
|
|
53
|
-
else if (/\.tsx$/.test(d.name)) tsxFiles.push(p);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
if (fileArgs.length) tsxFiles.push(...fileArgs.map((f) => path.resolve(f)));
|
|
57
|
-
else SCAN_DIRS.forEach((d) => walk(path.join(ROOT, d)));
|
|
45
|
+
const scan = resolveScanFiles({ root: ROOT, argv: process.argv.slice(2) });
|
|
46
|
+
const tsxFiles = scan.files;
|
|
58
47
|
|
|
59
48
|
// status vocabulary that indicates the copy's semantic register
|
|
60
49
|
const VOCAB = {
|
|
@@ -107,7 +96,12 @@ for (const file of tsxFiles) {
|
|
|
107
96
|
}
|
|
108
97
|
|
|
109
98
|
if (!findings.length) {
|
|
110
|
-
|
|
99
|
+
if (guardEmptyScan(scan, 'lint-token-intent')) { /* exited */ }
|
|
100
|
+
console.log(
|
|
101
|
+
scan.files.length
|
|
102
|
+
? `✓ token-intent: no intent mismatches across ${scan.files.length} files (2 rule families)`
|
|
103
|
+
: '✓ token-intent: no intent mismatches (0 files matched under existing scan roots)'
|
|
104
|
+
);
|
|
111
105
|
process.exit(0);
|
|
112
106
|
}
|
|
113
107
|
console.log(`token-intent: ${findings.length} candidate mismatch(es) across ${tsxFiles.length} files ${STRICT ? "" : "(advisory)"}\n`);
|