basalt-ui 1.0.1 → 1.1.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/src/surfaces.ts CHANGED
@@ -82,13 +82,6 @@ type BaseSurface = {
82
82
  readonly layer: Layer
83
83
  readonly forbiddenImports: readonly ForbiddenImport[]
84
84
  readonly ruleOverrides?: readonly RuleOverride[]
85
- /**
86
- * REPLACE-not-inherit-and-add. When true, this surface's forbiddenImports are the COMPLETE ban
87
- * set for its glob — the generator MUST NOT inherit-and-add the parent (src/**) bans. Charts sets
88
- * this so the @visx/* ban from src/** does NOT leak into the charts override (which would re-ban
89
- * visx). The projection emits the full list.
90
- */
91
- readonly replaceBans?: true
92
85
  /**
93
86
  * Human-readable description of this surface — single source for llms.txt and info output.
94
87
  * Optional on tooling surfaces (they have no llms.txt row).
@@ -159,6 +152,11 @@ const vg = (spec: string, message: string, extra?: Partial<ForbiddenImport>): Fo
159
152
  ...extra,
160
153
  })
161
154
 
155
+ // Mantine-free ban for headless surfaces the `basalt/token-layer-boundary` plugin rule does NOT
156
+ // cover (it only enforces charts/tokens path segments, and is registered repo-local only — see
157
+ // oxlint-plugin.js). `./charts` and `./tokens` no longer use this: their Mantine-free boundary is
158
+ // enforced by that plugin rule instead (and their @visx/* boundary by `basalt/visx-boundary`), so
159
+ // duplicating the ban here would be redundant no-restricted-imports config.
162
160
  const MANTINE_BANS = [
163
161
  v('@mantine/core', '{ctx} must be Mantine-free — no Mantine imports allowed.'),
164
162
  v('@mantine/hooks', '{ctx} must be Mantine-free — no Mantine imports allowed.'),
@@ -201,12 +199,11 @@ export const SURFACES = {
201
199
  shipped: ['**/charts/**'],
202
200
  repo: ['packages/basalt-ui/src/charts/**'],
203
201
  },
204
- replaceBans: true, // @visx/* MUST NOT inherit from src/** (the re-allow). Full list emitted.
205
- forbiddenImports: [
206
- ...MANTINE_BANS,
207
- v('@visx/tooltip', 'Use ChartTooltip + TooltipHeader/Row/Body from {ctx}.'),
208
- // LOAD-BEARING ABSENCE: no @visx/* group ban here — charts uniquely permits @visx/*.
209
- ],
202
+ // The @visx/*-only-in-charts boundary is enforced by the `basalt/visx-boundary` oxlint plugin
203
+ // rule, and the Mantine-free boundary by `basalt/token-layer-boundary` (repo-local only — see
204
+ // that rule's file-header comment for why) — both configs/oxlint-plugin.js, not
205
+ // no-restricted-imports.
206
+ forbiddenImports: [],
210
207
  ruleOverrides: [{ rule: 'no-underscore-dangle', level: 'off', target: 'repo' }],
211
208
  },
212
209
  './tokens': {
@@ -221,10 +218,9 @@ export const SURFACES = {
221
218
  shipped: ['**/tokens/**'],
222
219
  repo: ['packages/basalt-ui/src/tokens/**'],
223
220
  },
224
- forbiddenImports: [
225
- ...MANTINE_BANS,
226
- vg('@visx/*', 'Direct @visx/* imports are only allowed inside the charts boundary ({ctx}).'),
227
- ], // shipped tokens override is MISSING today → this projection EMITS it (closes D2)
221
+ // Mantine-free boundary enforced by `basalt/token-layer-boundary`, repo-local only (see
222
+ // ./charts above and that rule's file-header comment for why).
223
+ forbiddenImports: [],
228
224
  },
229
225
  './theme-lab': {
230
226
  kind: 'tooling',
@@ -246,10 +242,8 @@ export const SURFACES = {
246
242
  shipped: [],
247
243
  repo: ['packages/basalt-ui/src/guard/**'],
248
244
  },
249
- forbiddenImports: [
250
- ...MANTINE_BANS,
251
- vg('@visx/*', 'Direct @visx/* imports are only allowed inside the charts boundary ({ctx}).'),
252
- ],
245
+ // @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
246
+ forbiddenImports: [...MANTINE_BANS],
253
247
  }, // 6th JS subpath
254
248
  './query': {
255
249
  kind: 'doctrine',
@@ -263,10 +257,8 @@ export const SURFACES = {
263
257
  shipped: [],
264
258
  repo: ['packages/basalt-ui/src/query/**'],
265
259
  },
266
- forbiddenImports: [
267
- ...MANTINE_BANS,
268
- vg('@visx/*', 'Direct @visx/* imports are only allowed inside the charts boundary ({ctx}).'),
269
- ],
260
+ // @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
261
+ forbiddenImports: [...MANTINE_BANS],
270
262
  },
271
263
  './router-tanstack': {
272
264
  kind: 'doctrine',
@@ -281,10 +273,8 @@ export const SURFACES = {
281
273
  shipped: [],
282
274
  repo: ['packages/basalt-ui/src/router-tanstack/**'],
283
275
  },
284
- forbiddenImports: [
285
- ...MANTINE_BANS,
286
- vg('@visx/*', 'Direct @visx/* imports are only allowed inside the charts boundary ({ctx}).'),
287
- ],
276
+ // @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
277
+ forbiddenImports: [...MANTINE_BANS],
288
278
  },
289
279
  './forms': {
290
280
  kind: 'doctrine',
@@ -365,10 +355,8 @@ export const SURFACES = {
365
355
  shipped: [],
366
356
  repo: ['packages/basalt-ui/src/agent/**'],
367
357
  },
368
- forbiddenImports: [
369
- ...MANTINE_BANS,
370
- vg('@visx/*', 'Direct @visx/* imports are only allowed inside the charts boundary ({ctx}).'),
371
- ],
358
+ // @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
359
+ forbiddenImports: [...MANTINE_BANS],
372
360
  },
373
361
  './content': {
374
362
  kind: 'doctrine',
@@ -405,10 +393,8 @@ export const SURFACES = {
405
393
  shipped: [],
406
394
  repo: ['packages/basalt-ui/src/state.ts'],
407
395
  },
408
- forbiddenImports: [
409
- ...MANTINE_BANS,
410
- vg('@visx/*', 'Direct @visx/* imports are only allowed inside the charts boundary ({ctx}).'),
411
- ],
396
+ // @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
397
+ forbiddenImports: [...MANTINE_BANS],
412
398
  },
413
399
 
414
400
  './connectivity': {
@@ -456,17 +442,18 @@ export const SURFACES = {
456
442
  guardKinds: [],
457
443
  globs: {
458
444
  // Shipped is a catch-all (not just src/**+app/**) so consumer code under components/, lib/,
459
- // features/, etc. is also covered — the narrower re-allow overrides (./tokens, ./charts,
460
- // ./agent) still win for their globs because oxlint overrides are last-writer-wins and
461
- // EMIT_ORDER places #app first (see projectBanList doc comment in gen-oxlint.ts).
445
+ // features/, etc. is also covered. The @visx/*-only-in-charts and Mantine-free charts/tokens
446
+ // boundaries used to live here too and need last-writer-wins EMIT_ORDER games against the
447
+ // narrower ./tokens/./charts overrides — they're now enforced by `basalt/visx-boundary` and
448
+ // `basalt/token-layer-boundary` (plugin rules, immune to that class of clobbering) instead,
449
+ // so the bans left below (antd, framer-motion) are plain global bans with no narrower
450
+ // override to out-order.
462
451
  shipped: ['**/*.{ts,tsx}'],
463
452
  repo: ['packages/basalt-ui/src/**', 'apps/playground/src/**'],
464
453
  },
465
454
  ruleOverrides: [{ rule: 'no-console', level: 'off', target: 'repo' }], // cli/bin/scripts, repo-local only
466
455
  forbiddenImports: [
467
456
  v('antd', 'Use Mantine — antd is not part of the basalt-ui stack.', { shippedOnly: true }),
468
- v('@visx/tooltip', 'Use ChartTooltip + TooltipHeader/Row/Body from {ctx}.'),
469
- vg('@visx/*', 'Direct @visx/* imports are only allowed inside the charts boundary ({ctx}).'),
470
457
  v('framer-motion', "Import from 'motion/react', not the raw framer-motion package."),
471
458
  ],
472
459
  },
@@ -506,3 +493,51 @@ export const SKILL_NAMES = [
506
493
  .flatMap((s) => [...s.skill]),
507
494
  ),
508
495
  ] as const satisfies readonly SkillName[]
496
+
497
+ // ── Token-layer-boundary-via-plugin membership ────────────────────────────────────────────────────
498
+
499
+ /**
500
+ * Headless SURFACES keys whose Mantine-free guarantee is enforced by the `basalt/token-layer-
501
+ * boundary` oxlint plugin rule (`configs/oxlint-plugin.js`) instead of a `forbiddenImports`
502
+ * no-restricted-imports ban — the rule fires on `charts`/`tokens` path segments only, so ONLY
503
+ * these two surfaces qualify (every other headless surface still carries its Mantine ban in
504
+ * `forbiddenImports`).
505
+ *
506
+ * `basalt/token-layer-boundary` is registered ONLY in the repo-local `.oxlintrc.json`, never the
507
+ * shipped consumer preset. It protects two things: layering — `tokens` is pure data that
508
+ * `cssVariablesResolver` (Mantine-coupled) reads to bind Mantine's surfaces to the same `--vx-*`
509
+ * vars `charts` reads, so an `@mantine/*` import in either would cycle back through the theme
510
+ * layer or let a chart bypass `--vx-*` and fork chrome/charts apart — and packaging: `./charts`
511
+ * and `./tokens` resolve and render with NO `@mantine/*` installed, real and CI-tested
512
+ * (`scripts/pack-test.sh`'s "charts/tokens-only (no-Mantine) resolution + render" step,
513
+ * `scripts/check-dist-layering.mjs`'s dist-graph walk). The LAYER is Mantine-free — the FRAMEWORK
514
+ * is not (`.` requires Mantine as a non-optional peer; these two subpaths don't). Both are a
515
+ * basalt-internal invariant, not a consumer contract (a consumer's own `charts/`/`tokens/`-named
516
+ * directories carry no such obligation), which is why it stays repo-local. Because
517
+ * of that, `checkCoverage()`'s assertion 7 treats membership here as a pure EXEMPTION from the
518
+ * forbiddenImports requirement — it does NOT (and, being a shipped CLI subcommand that must run
519
+ * from inside a consumer's node_modules, CANNOT) verify the rule's live registration itself. That
520
+ * "fails loudly if enforcement is removed" guarantee lives in basalt's own CI instead
521
+ * (`tests/surfaces-coverage.test.ts`, via `hasTokenLayerBoundaryRegistered` against
522
+ * `.oxlintrc.json`).
523
+ */
524
+ export const TOKEN_LAYER_BOUNDARY_SURFACES: ReadonlySet<string> = new Set(['./charts', './tokens'])
525
+
526
+ /**
527
+ * True when a parsed oxlint config's `rules` object registers `basalt/token-layer-boundary` as
528
+ * `'error'` — the live signal (not just a hardcoded assumption) that `TOKEN_LAYER_BOUNDARY_SURFACES`
529
+ * are actually enforced. Pure — callers read + JSON.parse the config file themselves (surfaces.ts
530
+ * stays dependency-free, no fs access here). Consumed only by basalt's own CI
531
+ * (`tests/surfaces-coverage.test.ts`) against the repo-local `.oxlintrc.json` — NOT by
532
+ * `checkCoverage()`, which cannot read that repo-local file from an installed package (see
533
+ * `TOKEN_LAYER_BOUNDARY_SURFACES`'s doc comment).
534
+ *
535
+ * @example
536
+ * hasTokenLayerBoundaryRegistered({ 'basalt/token-layer-boundary': 'error' }) // true
537
+ * hasTokenLayerBoundaryRegistered({}) // false
538
+ */
539
+ export function hasTokenLayerBoundaryRegistered(
540
+ rules: Record<string, unknown> | undefined,
541
+ ): boolean {
542
+ return rules?.['basalt/token-layer-boundary'] === 'error'
543
+ }