basalt-ui 1.3.0 → 1.4.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/CHANGELOG.md CHANGED
@@ -1,3 +1,25 @@
1
+ ## [1.4.1](https://github.com/jkrumm/basalt-ui/compare/v1.4.0...v1.4.1) (2026-07-28)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * tell a spacing length apart from a dimensionless ratio ([d7629e5](https://github.com/jkrumm/basalt-ui/commit/d7629e5ec4b5d224accb31ac00a2e40d89de6dca))
7
+
8
+ # [1.4.0](https://github.com/jkrumm/basalt-ui/compare/v1.3.0...v1.4.0) (2026-07-28)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * let the shipped pre-commit hook see CSS ([fd3341f](https://github.com/jkrumm/basalt-ui/commit/fd3341fd9e648ee30e512f38d47596c4d67b2d00))
14
+ * make inline-spacing read the CSS a consumer actually writes ([77c930d](https://github.com/jkrumm/basalt-ui/commit/77c930d16fe27b0e98bb0ac05c92e8e0653df723)), closes [#25](https://github.com/jkrumm/basalt-ui/issues/25)
15
+ * widen this repo's own pre-commit formatter to match its CI ([b25455e](https://github.com/jkrumm/basalt-ui/commit/b25455ef918b2953c10c996f468eb1fd41f91dae))
16
+
17
+
18
+ ### Features
19
+
20
+ * give guard findings a severity so new rules can land soft ([1142ded](https://github.com/jkrumm/basalt-ui/commit/1142ded3f049054d316b3a8857c3fedc98a2fe46))
21
+ * have doctor report a spacing scale that moved under the app ([1e0ee4f](https://github.com/jkrumm/basalt-ui/commit/1e0ee4f1726fa4c358ec9bf6c22f075d1aebb665))
22
+
1
23
  # [1.3.0](https://github.com/jkrumm/basalt-ui/compare/v1.2.0...v1.3.0) (2026-07-27)
2
24
 
3
25
 
@@ -111,11 +111,13 @@ Popover, Accordion, cards) renders one border shade, one card background, and on
111
111
  micro-tokens or pepper `theme-allow`. One-off layout dims (`h={36}`, `w={64}`) are also fine raw.
112
112
  **The same permission holds in CSS modules**, where it has to be enforced differently: there is no
113
113
  prop form to prefer, so `inline-spacing` simply does not fire on a declaration whose every literal
114
- is ≤ 10px (`gap: 2px`, `padding: 4px 8px`). A `var()` component is dropped before that judgement;
115
- one non-micro value makes the whole declaration a finding (`padding: 4px 16px` flags). Other units
116
- are out — the doctrine is px, so `padding: 1.5rem` still flags. An inline style OBJECT in TSX
117
- (`style={{ padding: 4 }}`) also still flags: there the Mantine prop exists and should have been
118
- used.
114
+ is ≤ 10px (`gap: 2px`, `padding: 4px 8px`). It reads longhands and logical properties too
115
+ (`padding-top`, `margin-inline`, `row-gap`, `padding-inline-start`), not just the shorthands.
116
+ `rem` resolves against the 16px root, so `0.25rem` and `4px` get the same answer; units that need
117
+ layout context (`em`, `%`, `ch`, `vw`) are not micro-spacing claims and flag. A `var()` component
118
+ is dropped before that judgement; one non-micro value makes the whole declaration a finding
119
+ (`padding: 4px 16px` flags). An inline style OBJECT in TSX (`style={{ padding: 4 }}`) also still
120
+ flags: there the Mantine prop exists and should have been used.
119
121
  - **Icons** size via the icon's own `size` prop (`size={16}`), not spacing tokens — that's not spacing.
120
122
 
121
123
  ## Type
@@ -12,14 +12,21 @@ pre-commit:
12
12
  oxlint:
13
13
  glob: '*.{ts,tsx,js,jsx}'
14
14
  run: bunx oxlint {staged_files}
15
+ # `css` is load-bearing, not tidiness: oxfmt formats stylesheets, so without it a CSS-only
16
+ # commit passes the hook and then fails the same check in CI. `oxlint` above deliberately
17
+ # stops at JS — it has nothing to say about CSS.
15
18
  oxfmt:
16
- glob: '*.{ts,tsx,js,jsx,json,md,yml,yaml}'
19
+ glob: '*.{ts,tsx,js,jsx,css,json,md,yml,yaml}'
17
20
  run: bunx oxfmt --check {staged_files}
18
21
 
19
- # Scans the configured `basalt.roots`, not {staged_files}. A guard that only runs when
20
- # someone remembers to run it is not a guard: without this, a consumer can accumulate
21
- # violations indefinitely while `check-theme` is never invoked, and the kinds it never
22
- # ran are indistinguishable from the kinds that found nothing.
22
+ # NO glob, deliberately. This command scans the configured `basalt.roots` — it never reads
23
+ # {staged_files} — so any glob here is a gate on WHETHER the guard runs, decided by the file
24
+ # extensions that happen to be in one commit. It shipped as `*.{ts,tsx}`, which meant a commit
25
+ # touching only CSS modules skipped the guard entirely; the guard reads CSS (raw-hex,
26
+ # inline-spacing, raw-font-family and the surface kinds all fire there), so the rule was
27
+ # invisible to the hook meant to enforce it. That is precisely the failure the next sentence
28
+ # was written against: a guard that only runs when someone remembers to run it is not a guard.
29
+ # Without this, a consumer accumulates violations indefinitely while `check-theme` is never
30
+ # invoked, and the kinds it never ran are indistinguishable from the kinds that found nothing.
23
31
  check-theme:
24
- glob: '*.{ts,tsx}'
25
32
  run: bunx basalt-ui check-theme
@@ -1,4 +1,4 @@
1
- import type { GuardKind } from '../guard/index.js';
1
+ import type { GuardKind, GuardSeverity } from '../guard/index.js';
2
2
  import { RULE_NAMES, SKILL_NAMES } from '../surfaces.js';
3
3
  /** Shape of the optional `"basalt"` key in a consumer's package.json. */
4
4
  export type BasaltConfig = {
@@ -8,6 +8,9 @@ export type BasaltConfig = {
8
8
  exempt?: string[];
9
9
  /** Named spacing-scale steps (px) flagged when used as a raw spacing prop. Default: 10/12/16/20/32. */
10
10
  spacingSteps?: number[];
11
+ /** Per-kind severity override — `'warn'` reports without failing, `'error'` fails the build.
12
+ * See `GuardSeverity` in ../guard/types for the grace-minor doctrine behind it. */
13
+ severity?: Partial<Record<GuardKind, GuardSeverity>>;
11
14
  /** Off-identity Mantine accent families forbidden as chrome accents. Default: argo's set. */
12
15
  forbiddenAccents?: string[];
13
16
  /** Earned accent hue recorded in DESIGN.md `{{ACCENT_HUE}}`. Default: `blue`. */
@@ -201,6 +204,19 @@ type Manifest = {
201
204
  basaltVersion?: string;
202
205
  /** dest path → sha256 of the managed unit (file bytes, block body, or stanza) at last write. */
203
206
  files: Record<string, string>;
207
+ /**
208
+ * The resolved level-0 spacing scale (`xs`..`xl`, px) at last write — `doctor`'s second
209
+ * reconciliation axis, and the only one that reports a change in RENDERED OUTPUT rather than in
210
+ * placed files.
211
+ *
212
+ * A retune of the spacing bases moves every surface in every consumer calling
213
+ * `createBasaltTheme()` bare. basalt-ui bans majors by design, so the changelog is the only
214
+ * channel that carries that, and a one-line `feat:` subject cannot convey blast radius: the
215
+ * 1.2.0 retune shipped as "tighten the sidebar, open up components" and went unverified in
216
+ * production for a day because nothing said "every padding moved". Recording the scale makes the
217
+ * move mechanically visible on the next `doctor` run instead of depending on a subject line.
218
+ */
219
+ spacingScale?: Record<string, number>;
204
220
  };
205
221
  /**
206
222
  * Normalize a managed unit's rendered bytes for the ledger comparison below — makes a delta that is
@@ -283,9 +299,11 @@ type DoctorResult = {
283
299
  * 2. The installed node_modules/basalt-ui version matches the manifest's basaltVersion
284
300
  * (a mismatch means the package was upgraded but `sync` never ran — the placed doctrine is
285
301
  * stale).
286
- * 3. The running CLI's own version matches the installed basalt-ui (catches a stale
302
+ * 3. The spacing scale still matches the one stamped into the manifest at the last init/sync
303
+ * (skipped when this CLI is demonstrably not the installed package — see the check).
304
+ * 4. The running CLI's own version matches the installed basalt-ui (catches a stale
287
305
  * `bunx basalt-ui` npm fetch; best-effort, skipped if node_modules is absent).
288
- * 4. `basaltAppPlugin`'s (basalt-ui/vite) default icon filenames exist under public/ (only when
306
+ * 5. `basaltAppPlugin`'s (basalt-ui/vite) default icon filenames exist under public/ (only when
289
307
  * a public/ dir exists at all — skipped otherwise).
290
308
  *
291
309
  * Returns the exit code: 0 = all good, 1 = one or more hard failures.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAAwB,SAAS,EAAE,MAAM,UAAU,CAAA;AAE/D,OAAO,EAAE,UAAU,EAAE,WAAW,EAA2C,MAAM,aAAa,CAAA;AAI9F,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG;IACzB,sFAAsF;IACtF,KAAK,CAAC,EAAE,MAAM,EAAE,CAA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BAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,GAAE,MAAsB,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoCzF;AAKD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,UAAU,EAAE,WAAW,EAAE,CAAA;AACnF,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,CAAA"}
package/dist/cli/index.js CHANGED
@@ -13,7 +13,7 @@ import { fileURLToPath } from "node:url";
13
13
  import { checkSource, DEFAULT_GUARD_CONFIG, GUARD_RULES } from "../guard/index.js";
14
14
  import { evaluateGuardHook } from "../guard/guard-hook.js";
15
15
  import { RULE_NAMES, SKILL_NAMES, SURFACES, TOKEN_LAYER_BOUNDARY_SURFACES } from "../surfaces.js";
16
- import { buildPaletteCss } from "../tokens/index.js";
16
+ import { buildPaletteCss, deriveSpacing } from "../tokens/index.js";
17
17
  const DEFAULT_ROOT = "src";
18
18
  const DEFAULT_ROOTS = [DEFAULT_ROOT];
19
19
  function resolveRoots(cfg) {
@@ -32,10 +32,31 @@ function defaultExempt(cfg) {
32
32
  }
33
33
  const SKIP = /\.gen\.ts$|\.test\.[tj]sx?$|\.d\.ts$/;
34
34
  const SERIES_MODULE_HINT_RE = /(series|palette)\.tsx?$/i;
35
+ const SEVERITY_VALUES = ["warn", "error"];
36
+ function sanitizeSeverity(cfg) {
37
+ const raw = cfg.severity;
38
+ if (raw === void 0) return cfg;
39
+ if (raw === null || typeof raw !== "object" || Array.isArray(raw)) {
40
+ console.error("\u26A0 basalt.severity is not an object \u2014 ignoring it; every kind keeps its default.");
41
+ const { severity: _dropped, ...rest } = cfg;
42
+ return rest;
43
+ }
44
+ const kept = {};
45
+ for (const [kind, value] of Object.entries(raw)) {
46
+ if (typeof value === "string" && SEVERITY_VALUES.includes(value)) {
47
+ kept[kind] = value;
48
+ continue;
49
+ }
50
+ console.error(
51
+ `\u26A0 basalt.severity["${kind}"] is ${JSON.stringify(value)}, not 'warn' or 'error' \u2014 ignoring it; that kind keeps its default severity.`
52
+ );
53
+ }
54
+ return { ...cfg, severity: kept };
55
+ }
35
56
  function readBasaltConfig(cwd) {
36
57
  try {
37
58
  const pkg = JSON.parse(readFileSync(resolve(cwd, "package.json"), "utf8"));
38
- return pkg.basalt ?? {};
59
+ return sanitizeSeverity(pkg.basalt ?? {});
39
60
  } catch {
40
61
  return {};
41
62
  }
@@ -101,7 +122,8 @@ function checkTheme(cwd = process.cwd()) {
101
122
  rawFormControl: cfg.rawFormControl ?? DEFAULT_GUARD_CONFIG.rawFormControl,
102
123
  sub16InputFont: cfg.sub16InputFont ?? DEFAULT_GUARD_CONFIG.sub16InputFont,
103
124
  allowComment: "theme-allow",
104
- exemptRules: cfg.exemptRules ?? DEFAULT_GUARD_CONFIG.exemptRules
125
+ exemptRules: cfg.exemptRules ?? DEFAULT_GUARD_CONFIG.exemptRules,
126
+ severity: cfg.severity ?? DEFAULT_GUARD_CONFIG.severity
105
127
  };
106
128
  const findings = [];
107
129
  let scannedCount = 0;
@@ -130,20 +152,37 @@ function checkTheme(cwd = process.cwd()) {
130
152
  console.log("\u2713 Theme guard: no off-palette colors.");
131
153
  return 0;
132
154
  }
133
- const byFile = /* @__PURE__ */ new Map();
134
- for (const f of findings) {
135
- const list = byFile.get(f.relPath) ?? [];
136
- list.push(f);
137
- byFile.set(f.relPath, list);
155
+ const errors = findings.filter((f) => f.severity === "error");
156
+ const warnings = findings.filter((f) => f.severity === "warn");
157
+ const report = (group, heading) => {
158
+ const byFile = /* @__PURE__ */ new Map();
159
+ for (const f of group) {
160
+ const list = byFile.get(f.relPath) ?? [];
161
+ list.push(f);
162
+ byFile.set(f.relPath, list);
163
+ }
164
+ console.error(heading);
165
+ for (const [file, vs] of [...byFile].toSorted()) {
166
+ console.error(file);
167
+ for (const v of vs.toSorted((a, b) => a.line - b.line)) {
168
+ console.error(` ${String(v.line).padStart(4)} ${v.kind.padEnd(22)} ${v.token}`);
169
+ }
170
+ console.error("");
171
+ }
172
+ };
173
+ if (warnings.length > 0) {
174
+ report(
175
+ warnings,
176
+ // Deliberately neutral about WHY a kind is a warning. Two origins reach this block — a kind
177
+ // in its grace minor, and a consumer's own `basalt.severity` override — and the finding
178
+ // doesn't carry which. Promising promotion next minor would be wrong for the second.
179
+ `\u26A0 Theme guard: ${warnings.length} warning(s) \u2014 reported, not fatal. A kind warns while it is in its grace minor, or because \`basalt.severity\` turned it down; fix on your own schedule.
180
+ `
181
+ );
138
182
  }
139
- console.error(`\u2716 Theme guard: ${findings.length} off-palette / off-identity violation(s)
183
+ if (errors.length > 0) {
184
+ report(errors, `\u2716 Theme guard: ${errors.length} off-palette / off-identity violation(s)
140
185
  `);
141
- for (const [file, vs] of [...byFile].toSorted()) {
142
- console.error(file);
143
- for (const v of vs.toSorted((a, b) => a.line - b.line)) {
144
- console.error(` ${String(v.line).padStart(4)} ${v.kind.padEnd(22)} ${v.token}`);
145
- }
146
- console.error("");
147
186
  }
148
187
  const presentKinds = new Set(findings.map((f) => f.kind));
149
188
  const explanations = Object.keys(GUARD_KIND_EXPLANATIONS).filter((kind) => presentKinds.has(kind)).map((kind) => GUARD_KIND_EXPLANATIONS[kind]);
@@ -153,12 +192,12 @@ function checkTheme(cwd = process.cwd()) {
153
192
  "Add a `theme-allow` comment for a deliberate exception."
154
193
  ];
155
194
  console.error(fixLine.join(" "));
156
- if ([...byFile.keys()].some((f) => SERIES_MODULE_HINT_RE.test(f))) {
195
+ if (findings.some((f) => SERIES_MODULE_HINT_RE.test(f.relPath))) {
157
196
  console.error(
158
197
  'Hint: if a flagged file IS your palette/series source, exempt it via "basalt": { "exempt": ["<path>"] } in package.json.'
159
198
  );
160
199
  }
161
- return 1;
200
+ return errors.length > 0 ? 1 : 0;
162
201
  }
163
202
  const BLOCK_BEGIN_PREFIX = "<!-- basalt:begin";
164
203
  const BLOCK_END = "<!-- basalt:end -->";
@@ -341,6 +380,10 @@ function readManifest(cwd) {
341
380
  const parsed = JSON.parse(raw);
342
381
  const manifest = { version: 1, files: parsed.files ?? {} };
343
382
  if (typeof parsed.basaltVersion === "string") manifest.basaltVersion = parsed.basaltVersion;
383
+ const scale = parsed.spacingScale;
384
+ if (scale !== null && scale !== void 0 && typeof scale === "object" && !Array.isArray(scale) && Object.values(scale).every((v) => typeof v === "number")) {
385
+ manifest.spacingScale = scale;
386
+ }
344
387
  return manifest;
345
388
  } catch {
346
389
  return { version: 1, files: {} };
@@ -439,6 +482,7 @@ function init(cwd = process.cwd(), scaffoldFlags = {}) {
439
482
  written++;
440
483
  }
441
484
  manifest.basaltVersion = ctx.vars.BASALT_VERSION;
485
+ manifest.spacingScale = { ...deriveSpacing(0).scale };
442
486
  writeFileEnsuringDir(resolve(cwd, MANIFEST_PATH), `${JSON.stringify(manifest, null, 2)}
443
487
  `);
444
488
  console.log(`basalt-ui init: ${written} written, ${skipped} kept, manifest at ${MANIFEST_PATH}`);
@@ -529,6 +573,7 @@ function sync(opts = {}, cwd = process.cwd()) {
529
573
  return 0;
530
574
  }
531
575
  manifest.basaltVersion = ctx.vars.BASALT_VERSION;
576
+ manifest.spacingScale = { ...deriveSpacing(0).scale };
532
577
  writeFileEnsuringDir(resolve(cwd, MANIFEST_PATH), `${JSON.stringify(manifest, null, 2)}
533
578
  `);
534
579
  console.log(
@@ -704,6 +749,28 @@ basalt-ui doctor \u2014 ${cwd}
704
749
  }
705
750
  }
706
751
  const cliVersion = readFrameworkVersion(packageRoot());
752
+ const cliIsTheInstall = installedVersion === null || installedVersion === cliVersion;
753
+ if (manifestExists && !cliIsTheInstall) {
754
+ pass(
755
+ `spacing scale not compared \u2014 this CLI (${cliVersion}) is not the installed basalt-ui (${installedVersion}), so its scale is not the one the app renders with`
756
+ );
757
+ } else if (manifestExists) {
758
+ const recorded = readManifest(cwd).spacingScale;
759
+ const current = deriveSpacing(0).scale;
760
+ if (recorded === void 0) {
761
+ pass("spacing scale not yet recorded \u2014 `basalt-ui sync` will stamp it");
762
+ } else {
763
+ const steps = [.../* @__PURE__ */ new Set([...Object.keys(current), ...Object.keys(recorded)])].toSorted();
764
+ const moved = steps.filter((step) => recorded[step] !== current[step]).map((step) => `${step} ${recorded[step] ?? "(none)"}\u2192${current[step] ?? "(removed)"}`);
765
+ if (moved.length > 0) {
766
+ warn(
767
+ `the spacing scale moved since the last sync (${moved.join(", ")}) \u2014 every surface in an app calling createBasaltTheme() bare shifts with it. Review the app visually, then run \`basalt-ui sync\` to record the new scale.`
768
+ );
769
+ } else {
770
+ pass("spacing scale matches the last sync");
771
+ }
772
+ }
773
+ }
707
774
  if (installedVersion !== null) {
708
775
  if (installedVersion !== cliVersion) {
709
776
  warn(
@@ -903,7 +970,8 @@ async function guardHook(cwd = process.cwd()) {
903
970
  rawFormControl: cfg.rawFormControl ?? DEFAULT_GUARD_CONFIG.rawFormControl,
904
971
  sub16InputFont: cfg.sub16InputFont ?? DEFAULT_GUARD_CONFIG.sub16InputFont,
905
972
  allowComment: "theme-allow",
906
- exemptRules: cfg.exemptRules ?? DEFAULT_GUARD_CONFIG.exemptRules
973
+ exemptRules: cfg.exemptRules ?? DEFAULT_GUARD_CONFIG.exemptRules,
974
+ severity: cfg.severity ?? DEFAULT_GUARD_CONFIG.severity
907
975
  };
908
976
  const roots = cfg.roots ?? DEFAULT_ROOTS;
909
977
  const exempt = new Set(cfg.exempt ?? defaultExempt(cfg));
@@ -1 +1 @@
1
- {"version":3,"file":"guard-hook.d.ts","sourceRoot":"","sources":["../../src/guard/guard-hook.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAmDrE;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,EAAE,OAAO,GAAG,MAAM,CAAA;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,qCAAqC;AACrC,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAA;CACzC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,WAAW,EAChB,IAAI,CAAC,EAAE,wBAAwB,GAC9B,eAAe,CAqBjB"}
1
+ {"version":3,"file":"guard-hook.d.ts","sourceRoot":"","sources":["../../src/guard/guard-hook.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE1C,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1D;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAmDrE;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,kBAAkB,EAAE,OAAO,GAAG,MAAM,CAAA;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,qCAAqC;AACrC,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;OAIG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAA;CACzC,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,WAAW,EAChB,IAAI,CAAC,EAAE,wBAAwB,GAC9B,eAAe,CA0BjB"}
@@ -40,7 +40,9 @@ function evaluateGuardHook(payload, cfg, opts) {
40
40
  if (opts?.isInScope !== void 0 && !opts.isInScope(target.relPath)) {
41
41
  return { permissionDecision: "allow" };
42
42
  }
43
- const findings = checkSource(target.text, target.relPath, cfg);
43
+ const findings = checkSource(target.text, target.relPath, cfg).filter(
44
+ (f) => f.severity === "error"
45
+ );
44
46
  if (findings.length === 0) return { permissionDecision: "allow" };
45
47
  const shown = findings.slice(0, 10);
46
48
  const lines = shown.map((f) => `${f.kind} @ ${f.line}: ${f.token}`);
@@ -4,8 +4,8 @@
4
4
  * GUARD_RULES: the closed registry of all 19 violation kinds.
5
5
  * checkSource: pure (text, relPath, cfg) → Finding[]. No FS, no walk, no console.
6
6
  */
7
- import type { Finding, GuardConfig, GuardKind } from './types.js';
8
- export type { Finding, GuardConfig, GuardKind };
7
+ import type { Finding, GuardConfig, GuardKind, GuardSeverity } from './types.js';
8
+ export type { Finding, GuardConfig, GuardKind, GuardSeverity };
9
9
  /** Shared default config — CLI and tests import this to avoid duplication. */
10
10
  export declare const DEFAULT_GUARD_CONFIG: GuardConfig;
11
11
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAE9D,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,CAAA;AAuL/C,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,EAAE,WAkBlC,CAAA;AA0QD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;gCA0BL,WAAW;;;;;;gCAaX,WAAW;;;;;;;gCAaX,WAAW;;;;;;;gCAQX,WAAW;;;;;;gCAOX,WAAW;;;;;;;gCASX,WAAW;;;;;;gCAOX,WAAW;;;;;;;gCASX,WAAW;;;;;;gCAMX,WAAW;;;;;;;gCASX,WAAW;;;;;;;gCAUX,WAAW;;;;;;;gCAUX,WAAW;;;;;;;gCASX,WAAW;;;;;;;gCASX,WAAW;;;;;;;gCAUX,WAAW;;;;CAOmB,CAAA;AAUjD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,EAAE,CAuNtF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE7E,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,CAAA;AAsO9D,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,EAAE,WAmBlC,CAAA;AAgSD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;gCA0BL,WAAW;;;;;;gCAaX,WAAW;;;;;;;gCAaX,WAAW;;;;;;;gCAQX,WAAW;;;;;;gCAOX,WAAW;;;;;;;gCASX,WAAW;;;;;;gCAOX,WAAW;;;;;;;gCASX,WAAW;;;;;;gCAMX,WAAW;;;;;;;gCASX,WAAW;;;;;;;gCAUX,WAAW;;;;;;;gCAUX,WAAW;;;;;;;gCASX,WAAW;;;;;;;gCASX,WAAW;;;;;;;gCAUX,WAAW;;;;CAOmB,CAAA;AAUjD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,EAAE,CA2NtF"}
@@ -16,8 +16,16 @@ const OFF_SYSTEM_SURFACE_VAR = /var\(--mantine-color-(gray|dark)-\d/g;
16
16
  const RAW_HTML_TAG = /<(?:div|span|section|header|nav|footer|aside|main|article|ul|ol)\b/;
17
17
  const INLINE_STYLE = /style=\{\{/;
18
18
  const LAYOUT_SURFACE_PROP = /\b(?:display|padding|margin|gap|flex|grid|border|background|width|height)\b/;
19
- const INLINE_SPACING = /\b(?:padding(?:Top|Bottom|Left|Right)?|margin(?:Top|Bottom|Left|Right)?|gap|rowGap|columnGap)\s*:\s*(?!var\()['"]?-?(?!0\b)\d/g;
19
+ const BOX_SIDE = "(?:Top|Bottom|Left|Right|Block|Inline)(?:Start|End)?";
20
+ const BOX_SIDE_KEBAB = "(?:top|bottom|left|right|block|inline)(?:-(?:start|end))?";
21
+ const SPACING_PROP = `(?:padding|margin)(?:${BOX_SIDE}|-${BOX_SIDE_KEBAB})?|gap|rowGap|columnGap|row-gap|column-gap`;
22
+ const SPACING_NUMBER = "(?:\\d*\\.\\d+(?=[a-z%])|\\d+(?!\\.\\d))";
23
+ const INLINE_SPACING = new RegExp(
24
+ `(?<![\\w-])(?:${SPACING_PROP})\\s*:\\s*(?!var\\()['"]?[-+]?(?!0(?![.\\d]))${SPACING_NUMBER}`,
25
+ "g"
26
+ );
20
27
  const MICRO_SPACING_CEILING_PX = 10;
28
+ const ROOT_FONT_SIZE_PX = 16;
21
29
  function isSubScaleCssSpacing(line, matchIndex) {
22
30
  const colon = line.indexOf(":", matchIndex);
23
31
  if (colon === -1) return false;
@@ -26,8 +34,10 @@ function isSubScaleCssSpacing(line, matchIndex) {
26
34
  const value = (end === -1 ? rest : rest.slice(0, end)).replace(/var\([^)]*\)/g, " ").trim();
27
35
  if (value === "") return true;
28
36
  return value.split(/\s+/).every((part) => {
29
- const literal = /^-?(\d+(?:\.\d+)?)(?:px)?$/.exec(part);
30
- return literal !== null && Number(literal[1]) <= MICRO_SPACING_CEILING_PX;
37
+ const literal = /^[-+]?(\d+(?:\.\d+)?|\.\d+)(px|rem)?$/.exec(part);
38
+ if (literal === null) return false;
39
+ const px = literal[2] === "rem" ? Number(literal[1]) * ROOT_FONT_SIZE_PX : Number(literal[1]);
40
+ return px <= MICRO_SPACING_CEILING_PX;
31
41
  });
32
42
  }
33
43
  const INLINE_DISPLAY = /\bdisplay\s*:\s*['"](?:inline-)?(?:flex|grid)['"]/g;
@@ -62,8 +72,13 @@ const DEFAULT_GUARD_CONFIG = {
62
72
  rawFormControl: true,
63
73
  sub16InputFont: true,
64
74
  allowComment: "theme-allow",
65
- exemptRules: {}
75
+ exemptRules: {},
76
+ severity: {}
66
77
  };
78
+ const GRACE_PERIOD_KINDS = {};
79
+ function severityOf(kind, cfg) {
80
+ return cfg.severity?.[kind] ?? (kind in GRACE_PERIOD_KINDS ? "warn" : "error");
81
+ }
67
82
  function isChartFile(relPath) {
68
83
  return relPath.includes("/charts/") && !AXIS_WRAPPER_FILE.test(relPath);
69
84
  }
@@ -534,7 +549,7 @@ function checkSource(text, relPath, cfg) {
534
549
  findings.push({ relPath, line: lineNo, token: fontSizeMatch[0], kind: "sub-16-input-font" });
535
550
  }
536
551
  }
537
- return findings.filter((f) => !isRuleExempt(f.kind, f.relPath, cfg.exemptRules));
552
+ return findings.filter((f) => !isRuleExempt(f.kind, f.relPath, cfg.exemptRules)).map((f) => ({ ...f, severity: severityOf(f.kind, cfg) }));
538
553
  }
539
554
  export {
540
555
  DEFAULT_GUARD_CONFIG,
@@ -7,6 +7,21 @@
7
7
  */
8
8
  /** The 19 theme-guard violation kinds. */
9
9
  export type GuardKind = 'raw-hex' | 'raw-color-fn' | 'localstorage-theme' | 'off-identity-accent' | 'raw-spacing' | 'raw-radius' | 'raw-surface' | 'card-with-border' | 'off-system-surface-var' | 'raw-html-layout' | 'inline-spacing' | 'inline-display' | 'raw-visx-axis' | 'raw-motion-value' | 'unframed-chart' | 'chart-missing-aria-label' | 'raw-form-control' | 'sub-16-input-font' | 'raw-font-family';
10
+ /**
11
+ * How hard a finding lands. `error` fails the build; `warn` reports and passes.
12
+ *
13
+ * The point of `warn` is the LANDING of a new rule, not a permanent tier. basalt-ui bans majors by
14
+ * design — 1.x absorbs breaks — so a consumer has no semver channel telling them enforcement got
15
+ * stricter, and the guard is the part of the framework that can hard-fail their build. A kind that
16
+ * arrives as an error therefore turns a routine minor upgrade into an unplanned refactor: 1.2.0
17
+ * cost the one real consumer eleven `theme-allow` comments, and 1.3.0 had them delete all eleven
18
+ * again — net zero source change, two commits, two production deploys.
19
+ *
20
+ * So: a change that makes the guard reject code it previously accepted — a new kind, or an existing
21
+ * kind reaching a new file type — ships `warn` for one minor, then promotes. The consumer sees it,
22
+ * schedules it, and upgrades on a green build.
23
+ */
24
+ export type GuardSeverity = 'warn' | 'error';
10
25
  /**
11
26
  * A structured finding — the chosen testable surface (§C.4). Replaces the old `Violation` type.
12
27
  * `relPath` + `line` + `token` + `kind` uniquely identify the violation.
@@ -20,6 +35,8 @@ export type Finding = {
20
35
  readonly line: number;
21
36
  readonly token: string;
22
37
  readonly kind: GuardKind;
38
+ /** Resolved per kind from {@link GuardConfig.severity} over the shipped default. */
39
+ readonly severity: GuardSeverity;
23
40
  };
24
41
  /**
25
42
  * Everything a single-file scan needs — no walk, no FS. The 3 dynamic regexes (forbiddenAccent,
@@ -114,5 +131,22 @@ export type GuardConfig = {
114
131
  * { exemptRules: { 'inline-display': ['agent'] } } // inline-display never fires under src/agent/**
115
132
  */
116
133
  readonly exemptRules: Partial<Record<GuardKind, string[]>>;
134
+ /**
135
+ * Per-kind severity override. A kind absent here takes the shipped default, which is `error`
136
+ * for every kind past its grace minor — see {@link GuardSeverity} for why a grace minor exists.
137
+ *
138
+ * Two directions, both legitimate:
139
+ * • `'warn'` on an `error` kind — a consumer who wants to upgrade now and fix later, on their
140
+ * own schedule rather than the release's.
141
+ * • `'error'` on a grace-period kind — a consumer who would rather take the enforcement
142
+ * immediately than carry a warning for a minor.
143
+ *
144
+ * This is severity, NOT an off switch: every kind already has its own boolean in this config,
145
+ * and `exemptRules` scopes a kind to paths. A kind turned down to `warn` still reports.
146
+ *
147
+ * @example
148
+ * { severity: { 'inline-spacing': 'warn' } } // report, don't fail, while we migrate
149
+ */
150
+ readonly severity: Partial<Record<GuardKind, GuardSeverity>>;
117
151
  };
118
152
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/guard/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,0CAA0C;AAC1C,MAAM,MAAM,SAAS,GACjB,SAAS,GACT,cAAc,GACd,oBAAoB,GACpB,qBAAqB,GACrB,aAAa,GACb,YAAY,GACZ,aAAa,GACb,kBAAkB,GAClB,wBAAwB,GACxB,iBAAiB,GACjB,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,kBAAkB,GAClB,gBAAgB,GAChB,0BAA0B,GAC1B,kBAAkB,GAClB,mBAAmB,GACnB,iBAAiB,CAAA;AAErB;;;;;;;GAOG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAA;CACzB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,wGAAwG;IACxG,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;IACxC,uEAAuE;IACvE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAA;IAC3B,wEAAwE;IACxE,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAA;IAC5C,iGAAiG;IACjG,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAA;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAA;IAChC,2GAA2G;IAC3G,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAA;IACrC,sGAAsG;IACtG,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,EAAE,OAAO,CAA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C,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;IAC1D;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAA;CAC7D,CAAA"}
package/llms.txt CHANGED
@@ -1,4 +1,4 @@
1
- # basalt-ui v1.3.0
1
+ # basalt-ui v1.4.1
2
2
  # Opinionated framework for Mantine-based React apps — theme, app shell, visx charts, toolchain presets
3
3
  #
4
4
  # basalt-ui is an opinionated framework for Mantine-based React apps.
@@ -19,7 +19,7 @@
19
19
  # ./tokens.css subpath. Guide: docs/FRAMEWORK-FREE.md in the repo.
20
20
 
21
21
  Package: basalt-ui
22
- Version: 1.3.0
22
+ Version: 1.4.1
23
23
 
24
24
  ## basalt-ui
25
25
  Import: import { ... } from 'basalt-ui'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "basalt-ui",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "Opinionated framework for Mantine-based React apps — theme, app shell, visx charts, toolchain presets",
5
5
  "keywords": [
6
6
  "charts",
@@ -684,3 +684,61 @@ describe('check-theme comment skipping', () => {
684
684
  expect(err).toContain('raw-visx-axis')
685
685
  })
686
686
  })
687
+
688
+ describe('severity — warnings report, errors fail', () => {
689
+ const RAW_HEX = `export const C = () => <div style={{ color: '#ff0000' }} />`
690
+
691
+ it('exits 1 on an error kind (the default)', () => {
692
+ fixture(RAW_HEX)
693
+ const { code, err } = run()
694
+ expect(code).toBe(1)
695
+ expect(err).toContain('✖ Theme guard')
696
+ expect(err).toContain('raw-hex')
697
+ })
698
+
699
+ it('exits 0 when the only findings are warnings, and still prints them', () => {
700
+ // The whole point of the grace minor: the consumer takes the upgrade on a green build and
701
+ // schedules the fix, rather than the release scheduling it for them. This case is the OTHER
702
+ // origin of a warning — a consumer override — so the heading must not promise promotion.
703
+ fixture(RAW_HEX, { roots: ['src'], severity: { 'raw-hex': 'warn' } })
704
+ const { code, err } = run()
705
+ expect(code).toBe(0)
706
+ expect(err).toContain('⚠ Theme guard')
707
+ expect(err).toContain('reported, not fatal')
708
+ expect(err).toContain('raw-hex')
709
+ expect(err).not.toContain('✖ Theme guard')
710
+ })
711
+
712
+ it('still fails when errors accompany warnings, and reports both blocks', () => {
713
+ fixture(`export const C = () => <div style={{ color: '#ff0000' }} p={18} />`, {
714
+ roots: ['src'],
715
+ spacingSteps: [18],
716
+ severity: { 'raw-hex': 'warn' },
717
+ })
718
+ const { code, err } = run()
719
+ expect(code).toBe(1)
720
+ expect(err).toContain('⚠ Theme guard')
721
+ expect(err).toContain('✖ Theme guard')
722
+ // Warnings first — "what will break later" is the less urgent read.
723
+ expect(err.indexOf('⚠ Theme guard')).toBeLessThan(err.indexOf('✖ Theme guard'))
724
+ })
725
+
726
+ it('ignores an unrecognized severity value instead of silently unguarding the kind', () => {
727
+ // The one config typo that would REMOVE enforcement: 'warning' matches neither bucket, so the
728
+ // finding would vanish and the command would exit 0 on a tree that is not clean.
729
+ fixture(RAW_HEX, { roots: ['src'], severity: { 'raw-hex': 'warning' } })
730
+ const { code, err } = run()
731
+ expect(code).toBe(1)
732
+ expect(err).toContain("not 'warn' or 'error'")
733
+ expect(err).toContain('✖ Theme guard')
734
+ expect(err).toContain('raw-hex')
735
+ })
736
+
737
+ it('ignores a severity block that is not an object', () => {
738
+ fixture(RAW_HEX, { roots: ['src'], severity: 'warn' })
739
+ const { code, err } = run()
740
+ expect(code).toBe(1)
741
+ expect(err).toContain('basalt.severity is not an object')
742
+ expect(err).toContain('✖ Theme guard')
743
+ })
744
+ })