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/AGENTS.md CHANGED
@@ -31,8 +31,24 @@ Toolchain: Bun runtime, oxlint + oxfmt, conventional commits (empty scope), `mas
31
31
 
32
32
  **Mantine-free boundary**: `basalt-ui/charts`, `basalt-ui/tokens`, `basalt-ui/guard`,
33
33
  `basalt-ui/query`, `basalt-ui/router-tanstack`, `basalt-ui/agent`, and `basalt-ui/state` must
34
- import zero `@mantine/*`. `@visx/*` is permitted only inside `src/charts/**`. Both rules are
35
- enforced by oxlint `no-restricted-imports` (repo-local and in the shipped consumer preset).
34
+ import zero `@mantine/*`. `@visx/*` is permitted only inside `src/charts/**`. `@visx/*`
35
+ (`basalt/visx-boundary`) is enforced by an oxlint plugin rule in both the repo and the shipped
36
+ consumer preset.
37
+
38
+ The Mantine-free boundary protects two things: **layering** (keeps the token layer upstream of
39
+ Mantine — `cssVariablesResolver` reads `--vx-*` tokens to bind Mantine's surfaces to them, so an
40
+ `@mantine/*` import here would cycle back through the theme layer or let a chart bypass `--vx-*`
41
+ and fork chrome/charts apart) and **packaging** (each of these seven dist entries resolves with
42
+ **no `@mantine/*` installed** — `scripts/check-dist-layering.mjs` walks the built dist graph of all
43
+ seven and fails if any reaches `@mantine/*`; `scripts/pack-test.sh`'s "charts/tokens-only
44
+ (no-Mantine) resolution + render" step additionally scratch-installs the tarball with only
45
+ `react`/`react-dom` and SSR-renders `basalt-ui/charts` + `basalt-ui/tokens` live). The LAYER is
46
+ Mantine-free — the FRAMEWORK is not: `.` requires Mantine (`@mantine/core`/`@mantine/hooks` are
47
+ required, non-optional peers); these seven subpaths don't.
48
+
49
+ Enforcement is repo-local ONLY for the Mantine-free side, not in the shipped preset:
50
+ `./charts`/`./tokens` via the `basalt/token-layer-boundary` plugin rule, `guard`/`query`/
51
+ `router-tanstack`/`agent`/`state` via a plain `no-restricted-imports` ban.
36
52
 
37
53
  **No raw hex or raw color functions**: route every color through `VX.*` tokens or the Mantine
38
54
  theme. Never write `#rrggbb`, `rgb(…)`, or `hsl(…)` in component or style code. Use
@@ -41,7 +57,7 @@ theme. Never write `#rrggbb`, `rgb(…)`, or `hsl(…)` in component or style co
41
57
  **Motion discipline**: import animation from `motion/react`, never the raw `framer-motion`
42
58
  package (enforced by oxlint `no-restricted-imports`). Route transition timing through the shared
43
59
  `MOTION_DURATION` / `MOTION_SPRING` / `MOTION_EASE_STANDARD` tokens — never a hardcoded
44
- duration/spring/ease literal in a `transition={{...}}` prop (enforced by `basalt check-theme`).
60
+ duration/spring/ease literal in a `transition={{...}}` prop (enforced by `basalt-ui check-theme`).
45
61
 
46
62
  ## Key commands
47
63
 
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [1.1.0](https://github.com/jkrumm/basalt-ui/compare/v1.0.2...v1.1.0) (2026-07-17)
2
+
3
+
4
+ ### Features
5
+
6
+ * split the import boundary into three independent rules ([784b673](https://github.com/jkrumm/basalt-ui/commit/784b6739367a25b9ffe379603c02322896e43658))
7
+
8
+ ## [1.0.2](https://github.com/jkrumm/basalt-ui/compare/v1.0.1...v1.0.2) (2026-07-17)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * make the import boundary unclobberable and stop false drift on sync ([98aba84](https://github.com/jkrumm/basalt-ui/commit/98aba8497eb359cbc86e3bee289d21d3e2dbd099))
14
+
1
15
  ## [1.0.1](https://github.com/jkrumm/basalt-ui/compare/v1.0.0...v1.0.1) (2026-07-17)
2
16
 
3
17
 
package/README.md CHANGED
@@ -182,9 +182,9 @@ Named exports only — no default exports.
182
182
 
183
183
  ## Mantine-free boundary
184
184
 
185
- `./charts` and `./tokens` import zero `@mantine/*`. `@visx/*` is only allowed inside `src/charts/**`. The root barrel (`.`) does not re-export `./charts` or `./tokens` — a charts/tokens-only consumer never pulls in Mantine.
185
+ `./charts` and `./tokens` import zero `@mantine/*`. `@visx/*` is only allowed inside `src/charts/**`. The root barrel (`.`) does not re-export `./charts` or `./tokens`.
186
186
 
187
- This boundary is enforced by oxlint `no-restricted-imports` in both the repo and the shipped consumer preset, so the constraint holds downstream too.
187
+ The Mantine-free part protects two things. First, layering: `tokens` is pure data that `cssVariablesResolver` reads to bind Mantine's surfaces to the same `--vx-*` vars charts use, so an `@mantine/*` import in either would cycle back through the theme layer or let a chart bypass `--vx-*` and fork chrome/charts apart. Second, packaging: `./charts` and `./tokens` resolve and render with **no `@mantine/*` installed** — a charts/tokens-only consumer never pulls Mantine into their bundle. This is real and CI-tested (`scripts/pack-test.sh`'s "charts/tokens-only (no-Mantine) resolution + render" step scratch-installs the tarball with only `react`/`react-dom` and SSR-renders `basalt-ui/charts`; `scripts/check-dist-layering.mjs` walks the built dist graph and fails if those entries reach `@mantine/*`; the root barrel not re-exporting them is the third leg). The LAYER is Mantine-free — the FRAMEWORK is not: `.` requires Mantine (`@mantine/core`/`@mantine/hooks` are required, non-optional peers); only `./charts`/`./tokens` don't. Both consequences are a basalt-internal invariant enforced by the repo-local-only `basalt/token-layer-boundary` oxlint plugin rule — not a consumer contract, so it is deliberately absent from the shipped consumer preset. The `@visx/*`-only-in-charts part (`basalt/visx-boundary`) IS shipped, so that constraint holds downstream too.
188
188
 
189
189
  ---
190
190
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  source: basalt-ui
3
- description: visx chart conventions — compose basalt-ui primitives/kinds, stay Mantine-free, and keep all color in `--vx-*` tokens. Enforced by the oxlint `@visx` ban.
3
+ description: visx chart conventions — compose basalt-ui primitives/kinds and keep all color in `--vx-*` tokens. Enforced by the oxlint `@visx` ban.
4
4
  paths:
5
5
  - 'src/**/charts/**'
6
6
  - 'apps/**/charts/**'
@@ -19,15 +19,25 @@ contract, not optional polish.**
19
19
  The shipped oxlint preset (`basalt-ui/configs/oxlint.json`) enforces two hard rules — they hold in
20
20
  downstream apps too:
21
21
 
22
- - **`@visx/*` may only be imported inside a `**/charts/**` directory.** Everywhere else, compose
23
- basalt-ui chart primitives/kinds. If you need a raw visx primitive for a bespoke chart, import it
24
- from `basalt-ui/charts` (it re-exports `Group`, `LinePath`, `Bar`, `AreaClosed`, `scaleLinear`,
25
- `curveMonotoneX`, …) — keep the dependency declared in one place.
26
- - **`@visx/tooltip` is banned everywhere.** Use `ChartTooltip` + `TooltipHeader`/`TooltipRow`/
27
- `TooltipBody` from `basalt-ui/charts`.
28
- - **The `src/charts/` tree must be Mantine-free** — no `@mantine/*` imports. Bridge the Mantine
29
- color scheme to charts in exactly one file (see basalt-mantine.md, the VxBridge pattern); route
30
- components import chart primitives directly from `basalt-ui/charts`, never from the bridge file.
22
+ - **`@visx/*` may only be imported inside a `charts/` directory** (`basalt/visx-boundary`).
23
+ Everywhere else, compose basalt-ui chart primitives/kinds. If you need a raw visx primitive for a
24
+ bespoke chart, import it from `basalt-ui/charts` (it re-exports `Group`, `LinePath`, `Bar`,
25
+ `AreaClosed`, `scaleLinear`, `curveMonotoneX`, …) — keep the dependency declared in one place, and
26
+ keep your own bespoke chart file under a `charts/` directory so it stays on the right side of the
27
+ boundary.
28
+ - **`@visx/tooltip` is banned everywhere** (`basalt/visx-tooltip`). Use `ChartTooltip` +
29
+ `TooltipHeader`/`TooltipRow`/`TooltipBody` from `basalt-ui/charts`.
30
+
31
+ `basalt-ui/charts` is itself Mantine-free (`basalt/token-layer-boundary`, enforced only inside
32
+ basalt-ui's own repo) — that keeps the token layer it reads from upstream of Mantine
33
+ (`cssVariablesResolver` reads `--vx-*` tokens to bind Mantine's surfaces to them, so a chart
34
+ importing `@mantine/*` directly would fork chrome and charts apart instead of sharing one source),
35
+ AND it means `basalt-ui/charts`/`basalt-ui/tokens` resolve and render with no `@mantine/*`
36
+ installed (real, CI-tested — `scripts/pack-test.sh`'s "charts/tokens-only (no-Mantine) resolution +
37
+ render" step). Neither is something a consumer app maintains: there is no local chart-primitives
38
+ tree to keep Mantine-free and no bridge file to own — `BasaltProvider` already bridges the Mantine
39
+ color scheme to the `--vx-*` CSS variables charts read internally. Just compose the shipped
40
+ primitives/kinds and pull color from `VX.*`/`alpha()` (`basalt-ui/tokens`).
31
41
 
32
42
  ## Every chart has
33
43
 
@@ -36,7 +46,7 @@ downstream apps too:
36
46
  shapes and optional highlight state.
37
47
  3. **ChartTooltip** + `TooltipHeader` + `TooltipRow` + `TooltipBody` — never `@visx/tooltip` directly.
38
48
  4. **AxisLeftNumeric** / **AxisRightNumeric** + **AxisBottomDate** — never raw `<AxisLeft>`/`<AxisBottom>`/`<AxisRight>`
39
- (they miss theme tokens + smart ticks). Enforced by `basalt check-theme` (`raw-visx-axis` guard
49
+ (they miss theme tokens + smart ticks). Enforced by `basalt-ui check-theme` (`raw-visx-axis` guard
40
50
  fails the build on a raw axis in a `/charts/` file; escape via `theme-allow`), not just convention.
41
51
  5. **HoverOverlay** for mouse capture, **HoverContext** for cross-chart crosshair sync,
42
52
  **useChartTooltip** for tip state, **useHoverSync** for the shared cursor. Wrap a group of
@@ -120,8 +130,8 @@ clutter). Keep stacked-area bands opaque — fading them leaks lower bands.
120
130
  ## Responsive sizing
121
131
 
122
132
  Use `ResponsiveChart` (render-prop container) or `useChartSize` (hook) from `basalt-ui/charts` —
123
- both are backed by `@visx/responsive`'s `useParentSize` and keep the `@visx/*` import inside
124
- `src/charts/**` per the boundary rule. Never reach for `@visx/responsive` directly or
133
+ both are backed by `@visx/responsive`'s `useParentSize` and keep the `@visx/*` import inside a
134
+ `charts/` directory per `basalt/visx-boundary`. Never reach for `@visx/responsive` directly or
125
135
  `useElementSize` from `@mantine/hooks` in a chart file.
126
136
 
127
137
  ```tsx
@@ -143,7 +143,7 @@ section divider, not card depth) are both fine.
143
143
  consumer code must compose Mantine layout/surface primitives — `Box`, `Flex`, `Grid`,
144
144
  `SimpleGrid`, `Stack`, `Group`, `Paper`, `Card` — instead of raw `<div>`/`<span>` with inline
145
145
  `style`. Raw HTML with inline layout/surface styling defeats the token system.
146
- - **Mechanical enforcement.** `basalt check-theme` adds five surface guard kinds (each a config knob,
146
+ - **Mechanical enforcement.** `basalt-ui check-theme` adds five surface guard kinds (each a config knob,
147
147
  default ON; `theme-allow` line-comment escape): `off-system-surface-var` (raw ramp-step vars),
148
148
  `card-with-border` (`withBorder` on a `Card`/`Paper`), `raw-html-layout` (raw `<div>`/`<span>` with
149
149
  inline layout/surface styling), `inline-spacing` (inline spacing literals), `inline-display`
@@ -188,7 +188,7 @@ shape doctrine lives here; the spacing/radius/type **tokens** are in basalt-toke
188
188
  separate `border` property). Cards must never diverge: same radius, same shadow. Never
189
189
  inline-override `border`/`borderRadius`/`boxShadow`/`backgroundColor` on a surface — use the
190
190
  radius token (`radius="md"` / `var(--vx-radius-card)`) + `VX.shadowCard` + `VX.surface.*`.
191
- Mechanically enforced by `basalt check-theme`'s `raw-surface` guard. Outer spacing comes from the
191
+ Mechanically enforced by `basalt-ui check-theme`'s `raw-surface` guard. Outer spacing comes from the
192
192
  parent `Stack`/`SimpleGrid` gap, not an intrinsic card margin.
193
193
  - **Depth = `shadow-card`, not a plain hairline** (see `docs/DESIGN-SPEC.md` in the basalt-ui repo,
194
194
  doctrine inversion #1 — this supersedes the old "never a drop shadow" rule). Elevation tiers: 0 flat (no shadow — body,
@@ -318,7 +318,7 @@ precedent as `@visx/*`: an internal implementation detail, not a peer the consum
318
318
  - **Never a hardcoded duration/spring/ease literal in a `transition={{...}}` prop.** Import
319
319
  `MOTION_DURATION` / `MOTION_SPRING` / `MOTION_EASE_STANDARD` from `basalt-ui` instead — the
320
320
  motion analog of routing color through `VX.*`. `MOTION_DURATION` is capped at 0.3s (300ms),
321
- matching the interaction-feedback ceiling above. Mechanically enforced by `basalt check-theme`'s
321
+ matching the interaction-feedback ceiling above. Mechanically enforced by `basalt-ui check-theme`'s
322
322
  `raw-motion-value` guard (default ON; `theme-allow` line-comment escape).
323
323
  - **Always branch on `useReducedMotion`** (`@mantine/hooks`) — render a real unanimated code path
324
324
  (no `motion.*` wrapper at all), not just `transition={{ duration: 0 }}`. See `ThemeToggle`'s
@@ -108,7 +108,7 @@ Install `@tanstack/react-router` as a peer, then import from `basalt-ui/router-t
108
108
  tree (`src/routeTree.gen.ts`) has been generated. In CI and after adding routes, run
109
109
  `tsr generate` (or `bun run typecheck`, which triggers it) before relying on breadcrumb or nav data.
110
110
  - The loader's `context.queryClient` requires `createRootRouteWithContext<{ queryClient: QueryClient }>()`.
111
- Run `basalt init` to scaffold a `query-client.ts` + `__root.tsx` seed that wires the TanStack
111
+ Run `basalt-ui init` to scaffold a `query-client.ts` + `__root.tsx` seed that wires the TanStack
112
112
  Router + Query context correctly — the generated `__root.tsx` uses
113
113
  `createRootRouteWithContext<{ queryClient }>()` and passes the client through `RouterProvider`.
114
114
 
@@ -9,7 +9,7 @@ paths:
9
9
  # Basalt State
10
10
 
11
11
  How to place state in a basalt-ui app. The **theme-scheme rule** below is
12
- guard-enforced (`basalt check-theme` bans `localStorage.getItem('theme')`); the rest is **advisory**.
12
+ guard-enforced (`basalt-ui check-theme` bans `localStorage.getItem('theme')`); the rest is **advisory**.
13
13
 
14
14
  ## State placement
15
15
 
@@ -21,7 +21,7 @@ Pick the right home for each kind of state — don't dump everything into one st
21
21
  might link to.
22
22
  - **Theme / color scheme** → `useMantineColorScheme()` from Mantine — **never** a client store, and
23
23
  **never** `localStorage.getItem('theme')`. The scheme persists to Mantine's own key and resolves the
24
- `--vx-*` tokens via CSS; reading it any other way breaks scheme reactivity and trips `basalt check-theme`.
24
+ `--vx-*` tokens via CSS; reading it any other way breaks scheme reactivity and trips `basalt-ui check-theme`.
25
25
  - **UI preferences that must survive navigation but aren't URL-worthy** (sidebar collapsed, panel
26
26
  layout, draft filters) → `createPersistedState` from `basalt-ui/state` — the framework's own
27
27
  versioned localStorage primitive (see below). `BasaltShell` already persists its own collapse state
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  source: basalt-ui
3
- description: Color, spacing, radius, and type discipline — route every value through the basalt-ui token system. Enforced by `basalt check-theme`.
3
+ description: Color, spacing, radius, and type discipline — route every value through the basalt-ui token system. Enforced by `basalt-ui check-theme`.
4
4
  paths:
5
5
  - 'src/**'
6
6
  - 'apps/**/src/**'
@@ -21,8 +21,8 @@ surface (60/30/10, pushed toward 90/10); the accent only points — primary CTA,
21
21
  status pops — never floods. (Blueprint/Basalt zinc-charcoal are the historical hue-tuning
22
22
  ancestors; `docs/DESIGN-SPEC.md` in the basalt-ui repo supersedes both — see its "Doctrine
23
23
  inversions" section.) This
24
- rule is the operational checklist; it is enforced mechanically by **`basalt check-theme`**
25
- (wire it into `lint`: `oxlint . && basalt check-theme`). A violation fails the build. Escape hatch: a
24
+ rule is the operational checklist; it is enforced mechanically by **`basalt-ui check-theme`**
25
+ (wire it into `lint`: `oxlint . && basalt-ui check-theme`). A violation fails the build. Escape hatch: a
26
26
  `theme-allow` line comment (diff-visible, deliberate).
27
27
 
28
28
  `check-theme` reads its config from your `package.json` `"basalt"` key
@@ -158,8 +158,14 @@ import { ChartHoverSync } from 'basalt-ui/charts'
158
158
  - **`@visx/*` may only be imported inside chart files.** The shipped consumer oxlint preset bans
159
159
  direct `@visx/*` outside `**/charts/**`. Need a raw visx primitive for a bespoke chart? Pull it
160
160
  from basalt-ui's curated re-export in `basalt-ui/charts`, or keep the chart under a charts dir.
161
- - **`./charts` and `./tokens` are Mantine-free** — zero `@mantine/*` imports. Keep new chart code
162
- free of Mantine so a charts/tokens-only consumer never pulls Mantine in.
161
+ - **basalt-ui's own `./charts` and `./tokens` are Mantine-free** — zero `@mantine/*` imports,
162
+ keeping the token layer upstream of Mantine inside the framework itself (`cssVariablesResolver`
163
+ reads `--vx-*` tokens to bind Mantine's surfaces to them; a chart importing `@mantine/*` directly
164
+ would fork chrome and charts apart), AND letting `basalt-ui/charts`/`basalt-ui/tokens` resolve and
165
+ render with no `@mantine/*` installed (real, CI-tested — `scripts/pack-test.sh`'s
166
+ "charts/tokens-only (no-Mantine) resolution + render" step). This is a basalt-internal invariant,
167
+ not a rule enforced on your own app code — compose the shipped primitives from
168
+ `basalt-ui/charts`/`basalt-ui/tokens` and you inherit it for free.
163
169
  - **No raw color literals** anywhere except the one guard-exempt series file (and a deliberate
164
170
  `theme-allow` line). `basalt-ui check-theme` is the teeth; run it before committing.
165
171
  - **No raw visx axes.** `basalt-ui check-theme`'s `raw-visx-axis` guard fails the build on a raw
@@ -234,9 +234,10 @@ or auto domain — also z-score/σ via a symmetric domain + zero refLine), **`Du
234
234
  > `--vx-*`, exposed as a `VX.*` ref — never an inline hex. The mechanics of all three live in
235
235
  > **`/basalt-charts`** — defer to it for the "how".
236
236
 
237
- The Mantine-free boundary holds here too: `./charts` and `./tokens` import zero `@mantine/*`, and
238
- `@visx/*` is only allowed under chart files. Both are oxlint-enforced in the shipped consumer
239
- preset.
237
+ The Mantine-free boundary holds here too: `./charts` and `./tokens` import zero `@mantine/*` (an
238
+ internal invariant keeping the token layer upstream of Mantine, and letting those two subpaths
239
+ resolve/render with no `@mantine/*` installed — CI-tested, repo-local only, not shipped), and
240
+ `@visx/*` is only allowed under chart files (oxlint-enforced in the shipped consumer preset too).
240
241
 
241
242
  ## Checklist before declaring a chart "done"
242
243
 
@@ -11,9 +11,9 @@ Colors come from the three-tier `--vx-*` token system — read `VX.*` / a `defin
11
11
  never a raw hex/`rgb()`/`hsl()`. Charts are visx via `basalt-ui/charts` (compose the primitives:
12
12
  `ChartCard`, `ChartLegend`, the `ChartTooltip` family, `AxisLeftNumeric`/`AxisBottomDate`); add a
13
13
  kind on the third repeat, don't loosen the primitives. `basalt-ui/charts` and `basalt-ui/tokens`
14
- are Mantine-free — never import `@mantine/*` under `**/charts/**`, never import `@visx/*` outside
15
- charts. Toolchain is oxlint + oxfmt (no ESLint/Biome/Prettier) and `basalt-ui check-theme` guards the
16
- palette. Runtime is Bun.
14
+ are Mantine-free internally (a framework invariant, not something your own app code must follow)
15
+ — never import `@visx/*` outside a `charts/` directory (oxlint-enforced). Toolchain is oxlint +
16
+ oxfmt (no ESLint/Biome/Prettier) and `basalt-ui check-theme` guards the palette. Runtime is Bun.
17
17
 
18
18
  **Before guessing an import, check the installed package's machine docs**:
19
19
  `node_modules/basalt-ui/llms.txt` (per-subpath import map), `node_modules/basalt-ui/AGENTS.md`, or
@@ -2,7 +2,7 @@
2
2
  * TanStack Router root route — wires QueryClient into the router context so
3
3
  * loader functions and components can call `Route.useRouteContext()`.
4
4
  *
5
- * Scaffold written by `basalt init`. This file is yours — `basalt sync` will not overwrite it.
5
+ * Scaffold written by `basalt-ui init`. This file is yours — `basalt-ui sync` will not overwrite it.
6
6
  */
7
7
  import { Outlet, createRootRouteWithContext } from '@tanstack/react-router'
8
8
  import type { QueryClient } from '@tanstack/react-query'
@@ -2,7 +2,7 @@
2
2
  * Basalt query client — configure once, share via router context.
3
3
  * Extend staleTime / gcTime defaults and add per-query error handling here.
4
4
  *
5
- * Scaffold written by `basalt init`. This file is yours — `basalt sync` will not overwrite it.
5
+ * Scaffold written by `basalt-ui init`. This file is yours — `basalt-ui sync` will not overwrite it.
6
6
  */
7
7
  import { createBasaltQueryClient } from 'basalt-ui/query'
8
8
 
@@ -1,15 +1,47 @@
1
1
  // oxlint-disable import/no-default-export -- oxlint's JS plugin loader requires a default export
2
2
  /**
3
3
  * basalt — the shipped oxlint JS plugin (alpha `jsPlugins`, ESLint-v9-compatible `create(context)`
4
- * API). Three design-guard AST rules steering consumers onto the token/idiom system that
5
- * `src/guard` (the regex-based `check-theme` CLI) cannot see from a raw-text scan alone.
4
+ * API). Design-guard AST rules steering consumers onto the token/idiom system that `src/guard`
5
+ * (the regex-based `check-theme` CLI) cannot see from a raw-text scan alone, plus three
6
+ * independent architecture-boundary rules (see below).
6
7
  *
7
8
  * Ships inside `configs/` so the shipped preset (`configs/oxlint.json`) can reference it as
8
9
  * `./oxlint-plugin.js` — a consumer `extends`-ing that preset inherits `jsPlugins` too, and the
9
10
  * path resolves relative to the preset file, not the consumer's own config.
10
11
  *
11
- * Every rule supports the same `theme-allow` escape as `src/guard`: skip a reported node if a line
12
- * comment containing `theme-allow` sits on the node's own line or the line immediately above it.
12
+ * The four design-guard rules below support the same `theme-allow` escape as `src/guard`: skip a
13
+ * reported node if a line comment containing `theme-allow` sits on the node's own line or the line
14
+ * immediately above it. The three boundary rules deliberately do NOT — see their own comment for
15
+ * why.
16
+ *
17
+ * ── The three boundary rules (`visx-boundary` / `visx-tooltip` / `token-layer-boundary`) ─────────
18
+ * These used to be one bundled `import-boundary` rule sharing a single on/off toggle — that meant
19
+ * a consumer disabling the one check they disagreed with silently dropped the other two as well.
20
+ * Each is now its own rule id with its own `meta`/`create`/registration, so a consumer can only
21
+ * turn one off explicitly, by name — never accidentally take out the others with it.
22
+ *
23
+ * `basalt/token-layer-boundary` is registered ONLY in the repo-local `.oxlintrc.json`, NOT in the
24
+ * shipped `configs/oxlint.json` preset — deliberately absent from what consumers inherit. It
25
+ * protects two things.
26
+ *
27
+ * 1. Layering: `src/tokens/**` is pure data (zero React, zero Mantine) that `cssVariablesResolver`
28
+ * (Mantine-coupled, `src/theme/**`) reads to bind Mantine's surfaces to the same `--vx-*` vars
29
+ * `src/charts/**` reads — chrome and charts are ONE source. If `tokens` imported `@mantine/*`
30
+ * that would cycle (`tokens → theme → tokens`); if `charts` imported `@mantine/*` a chart could
31
+ * read Mantine's theme directly instead of going through `--vx-*`, forking chrome and charts
32
+ * apart. The rule keeps that arrow pointing one way.
33
+ * 2. Packaging: `./charts` and `./tokens` resolve and render with NO `@mantine/*` installed — real
34
+ * and CI-tested, not aspirational (`scripts/pack-test.sh`'s "charts/tokens-only (no-Mantine)
35
+ * resolution + render" step scratch-installs the tarball with only react/react-dom and
36
+ * SSR-renders `basalt-ui/charts`; `scripts/check-dist-layering.mjs` walks the built dist graph
37
+ * and fails if those entries reach `@mantine/*`; the root barrel not re-exporting them is the
38
+ * third leg).
39
+ *
40
+ * The LAYER is Mantine-free — the FRAMEWORK is not: `.` requires Mantine (`@mantine/core`/
41
+ * `@mantine/hooks` are required, non-optional peers); it's just `./charts`/`./tokens` that don't.
42
+ * Both consequences govern basalt's OWN internal layering/packaging, not a consumer contract — a
43
+ * consumer's own `charts/`/`tokens/`-named directories carry no such obligation, which is why
44
+ * shipping this rule in the consumer preset would be meaningless.
13
45
  *
14
46
  * ── About the shipped `configs/oxlint.json` preset ────────────────────────────────────────────
15
47
  * Consumers extend it from their own `.oxlintrc.json` via the node_modules-relative path:
@@ -17,9 +49,14 @@
17
49
  * specifiers, so the relative `./node_modules` path is required. NOTE: oxlint `extends` is
18
50
  * per-glob last-writer-wins for `no-restricted-imports` — a base ban does NOT merge into an
19
51
  * override glob, so any ban that must also hold inside an override is duplicated into that
20
- * override. `configs/oxlint.json` is generated from `SURFACES` by `scripts/gen-oxlint.ts`
21
- * (`--check` is the CI drift gate) — its top-level keys are limited to what oxlint's own parser
22
- * accepts (see `ALLOWED_TOP_LEVEL_KEYS` in that script); do not add ad hoc keys to that file.
52
+ * override, AND a consumer's own `no-restricted-imports` override on an overlapping glob silently
53
+ * REPLACES basalt's ban rather than merging with it. That is exactly why the `@visx/*`-only-in-
54
+ * charts and token-layer charts/tokens boundaries live in plugin rules below instead of
55
+ * `no-restricted-imports`: a jsPlugin rule has its own rule id, so a consumer can only turn it off
56
+ * explicitly, by name — never silently. `configs/oxlint.json` is generated from `SURFACES` by
57
+ * `scripts/gen-oxlint.ts` (`--check` is the CI drift gate) — its top-level keys are limited to what
58
+ * oxlint's own parser accepts (see `ALLOWED_TOP_LEVEL_KEYS` in that script); do not add ad hoc keys
59
+ * to that file.
23
60
  */
24
61
 
25
62
  // ── Shared helpers ──────────────────────────────────────────────────────────────────────────────
@@ -256,6 +293,163 @@ const rawScrollContainer = {
256
293
  },
257
294
  }
258
295
 
296
+ // ── Rules 5–7 — the three architecture-boundary rules ───────────────────────────────────────────
297
+
298
+ // Message bodies mirror the wording that used to live in the shipped `no-restricted-imports`
299
+ // overrides (configs/oxlint.json) verbatim, so the DX doesn't regress.
300
+ const VISX_BOUNDARY_MESSAGE =
301
+ 'Direct @visx/* imports are only allowed inside the charts boundary (**/charts/**). ' +
302
+ '(basalt/visx-boundary)'
303
+ const VISX_TOOLTIP_MESSAGE =
304
+ 'Use ChartTooltip + TooltipHeader/Row/Body from basalt-ui charts primitives. ' +
305
+ '(basalt/visx-tooltip)'
306
+ const TOKEN_LAYER_BOUNDARY_MESSAGES = {
307
+ charts:
308
+ 'charts must stay upstream-of-Mantine (no Mantine imports) — read color via --vx-* tokens, ' +
309
+ 'not the Mantine theme directly. (basalt/token-layer-boundary)',
310
+ tokens:
311
+ 'tokens must stay upstream-of-Mantine (no Mantine imports) — importing Mantine here would ' +
312
+ 'cycle back through cssVariablesResolver. (basalt/token-layer-boundary)',
313
+ }
314
+
315
+ /** True when any path segment of `filename` equals `segment` (POSIX or Windows separators). */
316
+ function hasPathSegment(filename, segment) {
317
+ return filename.split(/[\\/]/).includes(segment)
318
+ }
319
+
320
+ /** Import specifier for an ImportDeclaration or a dynamic `import()` call; undefined otherwise. */
321
+ function importSource(node) {
322
+ if (node.type === 'ImportDeclaration') return node.source?.value
323
+ if (node.type === 'ImportExpression' && node.source?.type === 'Literal') {
324
+ return node.source.value
325
+ }
326
+ return undefined
327
+ }
328
+
329
+ /**
330
+ * Import specifier for a source-bearing export (`export { x } from '…'` / `export * from '…'`);
331
+ * undefined for a plain local `export { x }` (no `source`) or any other node shape.
332
+ */
333
+ function exportSource(node) {
334
+ if (node.type === 'ExportNamedDeclaration' || node.type === 'ExportAllDeclaration') {
335
+ return node.source?.value
336
+ }
337
+ return undefined
338
+ }
339
+
340
+ /**
341
+ * Wires a `reportFor(node, source)` boundary check into the four import/export AST handlers shared
342
+ * by all three boundary rules below.
343
+ */
344
+ function boundaryVisitor(reportFor) {
345
+ return {
346
+ ImportDeclaration(node) {
347
+ reportFor(node, importSource(node))
348
+ },
349
+ ImportExpression(node) {
350
+ reportFor(node, importSource(node))
351
+ },
352
+ ExportNamedDeclaration(node) {
353
+ reportFor(node, exportSource(node))
354
+ },
355
+ ExportAllDeclaration(node) {
356
+ reportFor(node, exportSource(node))
357
+ },
358
+ }
359
+ }
360
+
361
+ // Rule 5 — visx-boundary: @visx/* only allowed inside a `charts` path segment. Matching any path
362
+ // segment named `charts` is deliberately permissive, not restrictive — it only ever widens where
363
+ // visx is allowed, never narrows where it's flagged elsewhere. "Your visx lives in a charts/ dir"
364
+ // is the intended convention.
365
+ const visxBoundary = {
366
+ meta: {
367
+ type: 'suggestion',
368
+ docs: {
369
+ description: 'Disallow direct @visx/* imports outside a charts/ directory.',
370
+ },
371
+ schema: [],
372
+ },
373
+ create(context) {
374
+ const inCharts = hasPathSegment(getFilename(context), 'charts')
375
+
376
+ // Deliberately NO `hasThemeAllow` escape here (unlike the four design-guard rules above).
377
+ // `theme-allow` exists so the theme/palette source can opt out of DESIGN guidance (raw font
378
+ // sizes, raw colors) — it is not a license to punch through an ARCHITECTURE boundary. The whole
379
+ // point of moving this check into its own plugin rule instead of `no-restricted-imports` was
380
+ // that it can only be turned off explicitly, by rule id (see the file-header comment); a stray
381
+ // `theme-allow` comment (which also matches the line above the flagged node) must not silently
382
+ // bypass it. Do not "restore consistency" by adding it back.
383
+ function reportFor(node, source) {
384
+ if (typeof source !== 'string' || !source.startsWith('@visx/')) return
385
+ if (source === '@visx/tooltip') return // basalt/visx-tooltip owns this one, everywhere
386
+ if (!inCharts) context.report({ node, message: VISX_BOUNDARY_MESSAGE })
387
+ }
388
+
389
+ return boundaryVisitor(reportFor)
390
+ },
391
+ }
392
+
393
+ // Rule 6 — visx-tooltip: @visx/tooltip banned everywhere, including inside charts. Fires ahead of
394
+ // (and instead of) basalt/visx-boundary for that one specifier — basalt's own src/ never imports
395
+ // @visx/tooltip, so no theme-allow-style exemption is needed here either.
396
+ const visxTooltip = {
397
+ meta: {
398
+ type: 'suggestion',
399
+ docs: {
400
+ description: 'Disallow @visx/tooltip everywhere — use basalt-ui ChartTooltip instead.',
401
+ },
402
+ schema: [],
403
+ },
404
+ create(context) {
405
+ function reportFor(node, source) {
406
+ if (source !== '@visx/tooltip') return
407
+ context.report({ node, message: VISX_TOOLTIP_MESSAGE })
408
+ }
409
+
410
+ return boundaryVisitor(reportFor)
411
+ },
412
+ }
413
+
414
+ // Rule 7 — token-layer-boundary: @mantine/* banned inside `charts` OR `tokens` path segments —
415
+ // keeps the token layer upstream of Mantine AND keeps those two subpaths resolving with no
416
+ // @mantine/* installed (see the file-header comment for the cycle/fork + packaging rationale).
417
+ // Repo-local only — never registered in the shipped consumer preset, since this governs basalt's
418
+ // own internal layering/packaging, not a consumer contract.
419
+ const tokenLayerBoundary = {
420
+ meta: {
421
+ type: 'suggestion',
422
+ docs: {
423
+ description: 'Disallow @mantine/* imports inside charts/ or tokens/ directories.',
424
+ },
425
+ schema: [],
426
+ },
427
+ create(context) {
428
+ const filename = getFilename(context)
429
+ const inCharts = hasPathSegment(filename, 'charts')
430
+ const inTokens = hasPathSegment(filename, 'tokens')
431
+
432
+ // Deliberately NO `hasThemeAllow` escape — see basalt/visx-boundary's comment above for why.
433
+ function reportFor(node, source) {
434
+ if (typeof source !== 'string') return
435
+ if (
436
+ source !== '@mantine/core' &&
437
+ source !== '@mantine/hooks' &&
438
+ !source.startsWith('@mantine/')
439
+ )
440
+ return
441
+
442
+ if (inCharts) {
443
+ context.report({ node, message: TOKEN_LAYER_BOUNDARY_MESSAGES.charts })
444
+ } else if (inTokens) {
445
+ context.report({ node, message: TOKEN_LAYER_BOUNDARY_MESSAGES.tokens })
446
+ }
447
+ }
448
+
449
+ return boundaryVisitor(reportFor)
450
+ },
451
+ }
452
+
259
453
  // ── Plugin export ───────────────────────────────────────────────────────────────────────────────
260
454
 
261
455
  export default {
@@ -265,5 +459,8 @@ export default {
265
459
  'card-inset': cardInset,
266
460
  'chart-in-raw-surface': chartInRawSurface,
267
461
  'raw-scroll-container': rawScrollContainer,
462
+ 'visx-boundary': visxBoundary,
463
+ 'visx-tooltip': visxTooltip,
464
+ 'token-layer-boundary': tokenLayerBoundary,
268
465
  },
269
466
  }