basalt-ui 1.0.2 → 1.1.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/AGENTS.md +18 -2
- package/CHANGELOG.md +14 -0
- package/README.md +2 -2
- package/agent/rules/basalt-charts.md +22 -12
- package/agent/skills/basalt-app/SKILL.md +4 -3
- package/agent/skills/basalt-charts/SKILL.md +8 -2
- package/agent/skills/basalt-design/SKILL.md +4 -3
- package/agent/templates/CLAUDE-block.md.tpl +3 -3
- package/configs/check.yml +3 -1
- package/configs/oxlint-plugin.js +144 -59
- package/configs/oxlint-plugin.test.ts +88 -31
- package/configs/oxlint.json +3 -2
- package/dist/cli/index.d.ts +11 -3
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +23 -29
- package/dist/surfaces.d.ts +34 -16
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +28 -21
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/src/cli/index.ts +76 -46
- package/src/cli/init-sync.test.ts +68 -0
- package/src/surfaces.ts +63 -37
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/**`.
|
|
35
|
-
enforced by oxlint
|
|
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
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.1.1](https://github.com/jkrumm/basalt-ui/compare/v1.1.0...v1.1.1) (2026-07-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* derive consumer seeds from basalt.roots, relax eqeqeq to smart ([b598112](https://github.com/jkrumm/basalt-ui/commit/b5981124b5758cca421164037d4f320ed65af362))
|
|
7
|
+
|
|
8
|
+
# [1.1.0](https://github.com/jkrumm/basalt-ui/compare/v1.0.2...v1.1.0) (2026-07-17)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* split the import boundary into three independent rules ([784b673](https://github.com/jkrumm/basalt-ui/commit/784b6739367a25b9ffe379603c02322896e43658))
|
|
14
|
+
|
|
1
15
|
## [1.0.2](https://github.com/jkrumm/basalt-ui/compare/v1.0.1...v1.0.2) (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
|
|
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
|
-
|
|
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
|
|
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
|
|
23
|
-
basalt-ui chart primitives/kinds. If you need a raw visx primitive for a
|
|
24
|
-
from `basalt-ui/charts` (it re-exports `Group`, `LinePath`, `Bar`,
|
|
25
|
-
`curveMonotoneX`, …) — keep the dependency declared in one place
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
|
@@ -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
|
-
`
|
|
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
|
|
@@ -84,8 +84,9 @@ import 'basalt-ui/styles.css' // @layer basalt base styles, iOS input safety net
|
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
Lint wires as `oxlint . && basalt-ui check-theme` — the theme guard is the teeth behind the token
|
|
87
|
-
doctrine. The consumer series file (
|
|
88
|
-
`
|
|
87
|
+
doctrine. The consumer series file (`<first basalt.root>/lib/series.ts` by default — so `src/lib/series.ts`
|
|
88
|
+
on a plain app, `apps/web/src/lib/series.ts` on a monorepo; override via `basalt.seriesModulePath`) is the
|
|
89
|
+
single guard-exempt palette source — see `/basalt-charts`.
|
|
89
90
|
|
|
90
91
|
## Refresh: `bunx basalt-ui sync`
|
|
91
92
|
|
|
@@ -120,7 +121,7 @@ both.
|
|
|
120
121
|
imported.
|
|
121
122
|
- `basaltViteConfig` adopted; `oxlint . && basalt-ui check-theme` is the lint command.
|
|
122
123
|
- A thin `DESIGN.md` (deltas) + the twelve `basalt-*` rules + the managed CLAUDE block are present.
|
|
123
|
-
-
|
|
124
|
+
- `<first basalt.root>/lib/series.ts` exists as the one guard-exempt series source (for any app metric colors).
|
|
124
125
|
- `basalt-ui sync --check` wired in CI (recommended) to catch drift on future upgrades.
|
|
125
126
|
|
|
126
127
|
## Notes
|
|
@@ -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
|
-
-
|
|
162
|
-
|
|
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
|
|
238
|
-
|
|
239
|
-
|
|
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
|
|
15
|
-
|
|
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
|
package/configs/check.yml
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
# color literals / off-identity accents that bypass the --vx-* token system).
|
|
6
6
|
# `basalt-ui sync --check` fails when the basalt-managed files (rules, skills, the
|
|
7
7
|
# CLAUDE block) have drifted from the installed basalt-ui version.
|
|
8
|
+
# The oxfmt globs below are rendered from `basalt.roots` at init time — this file is a
|
|
9
|
+
# template, not a raw copy, so a monorepo doesn't seed a `src/**` that matches nothing.
|
|
8
10
|
name: check
|
|
9
11
|
on:
|
|
10
12
|
pull_request:
|
|
@@ -23,7 +25,7 @@ jobs:
|
|
|
23
25
|
- run: bunx oxlint .
|
|
24
26
|
- run: bunx basalt-ui check-theme
|
|
25
27
|
- run: bunx basalt-ui sync --check
|
|
26
|
-
- run: bunx oxfmt
|
|
28
|
+
- run: bunx oxfmt {{ROOTS_GLOBS}} '!**/dist/**' --check
|
|
27
29
|
# Enable once your app defines these package.json scripts:
|
|
28
30
|
# - run: bun run typecheck
|
|
29
31
|
# - run: bun run test
|
package/configs/oxlint-plugin.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* basalt — the shipped oxlint JS plugin (alpha `jsPlugins`, ESLint-v9-compatible `create(context)`
|
|
4
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
|
|
6
|
-
*
|
|
5
|
+
* (the regex-based `check-theme` CLI) cannot see from a raw-text scan alone, plus three
|
|
6
|
+
* independent architecture-boundary rules (see below).
|
|
7
7
|
*
|
|
8
8
|
* Ships inside `configs/` so the shipped preset (`configs/oxlint.json`) can reference it as
|
|
9
9
|
* `./oxlint-plugin.js` — a consumer `extends`-ing that preset inherits `jsPlugins` too, and the
|
|
@@ -11,7 +11,37 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The four design-guard rules below support the same `theme-allow` escape as `src/guard`: skip a
|
|
13
13
|
* reported node if a line comment containing `theme-allow` sits on the node's own line or the line
|
|
14
|
-
* immediately above it.
|
|
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.
|
|
15
45
|
*
|
|
16
46
|
* ── About the shipped `configs/oxlint.json` preset ────────────────────────────────────────────
|
|
17
47
|
* Consumers extend it from their own `.oxlintrc.json` via the node_modules-relative path:
|
|
@@ -21,9 +51,9 @@
|
|
|
21
51
|
* override glob, so any ban that must also hold inside an override is duplicated into that
|
|
22
52
|
* override, AND a consumer's own `no-restricted-imports` override on an overlapping glob silently
|
|
23
53
|
* REPLACES basalt's ban rather than merging with it. That is exactly why the `@visx/*`-only-in-
|
|
24
|
-
* charts and
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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
|
|
27
57
|
* `scripts/gen-oxlint.ts` (`--check` is the CI drift gate) — its top-level keys are limited to what
|
|
28
58
|
* oxlint's own parser accepts (see `ALLOWED_TOP_LEVEL_KEYS` in that script); do not add ad hoc keys
|
|
29
59
|
* to that file.
|
|
@@ -263,21 +293,23 @@ const rawScrollContainer = {
|
|
|
263
293
|
},
|
|
264
294
|
}
|
|
265
295
|
|
|
266
|
-
// ──
|
|
296
|
+
// ── Rules 5–7 — the three architecture-boundary rules ───────────────────────────────────────────
|
|
267
297
|
|
|
268
298
|
// Message bodies mirror the wording that used to live in the shipped `no-restricted-imports`
|
|
269
299
|
// overrides (configs/oxlint.json) verbatim, so the DX doesn't regress.
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
'charts must
|
|
279
|
-
|
|
280
|
-
|
|
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)',
|
|
281
313
|
}
|
|
282
314
|
|
|
283
315
|
/** True when any path segment of `filename` equals `segment` (POSIX or Windows separators). */
|
|
@@ -305,65 +337,116 @@ function exportSource(node) {
|
|
|
305
337
|
return undefined
|
|
306
338
|
}
|
|
307
339
|
|
|
308
|
-
|
|
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 = {
|
|
309
366
|
meta: {
|
|
310
367
|
type: 'suggestion',
|
|
311
368
|
docs: {
|
|
312
|
-
description:
|
|
313
|
-
'Enforce the @visx/*-only-in-charts and Mantine-free charts/tokens import boundaries.',
|
|
369
|
+
description: 'Disallow direct @visx/* imports outside a charts/ directory.',
|
|
314
370
|
},
|
|
315
371
|
schema: [],
|
|
316
372
|
},
|
|
317
373
|
create(context) {
|
|
318
|
-
const
|
|
319
|
-
const inCharts = hasPathSegment(filename, 'charts')
|
|
320
|
-
const inTokens = hasPathSegment(filename, 'tokens')
|
|
374
|
+
const inCharts = hasPathSegment(getFilename(context), 'charts')
|
|
321
375
|
|
|
322
376
|
// Deliberately NO `hasThemeAllow` escape here (unlike the four design-guard rules above).
|
|
323
377
|
// `theme-allow` exists so the theme/palette source can opt out of DESIGN guidance (raw font
|
|
324
378
|
// sizes, raw colors) — it is not a license to punch through an ARCHITECTURE boundary. The whole
|
|
325
|
-
// point of moving this check into
|
|
326
|
-
// can only be turned off explicitly, by rule id (see the file-header comment); a stray
|
|
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
|
|
327
381
|
// `theme-allow` comment (which also matches the line above the flagged node) must not silently
|
|
328
382
|
// bypass it. Do not "restore consistency" by adding it back.
|
|
329
383
|
function reportFor(node, source) {
|
|
330
|
-
if (typeof source !== 'string') return
|
|
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
|
+
}
|
|
331
388
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
|
340
435
|
if (
|
|
341
|
-
source
|
|
342
|
-
source
|
|
343
|
-
source.startsWith('@mantine/')
|
|
344
|
-
)
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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 })
|
|
350
446
|
}
|
|
351
447
|
}
|
|
352
448
|
|
|
353
|
-
return
|
|
354
|
-
ImportDeclaration(node) {
|
|
355
|
-
reportFor(node, importSource(node))
|
|
356
|
-
},
|
|
357
|
-
ImportExpression(node) {
|
|
358
|
-
reportFor(node, importSource(node))
|
|
359
|
-
},
|
|
360
|
-
ExportNamedDeclaration(node) {
|
|
361
|
-
reportFor(node, exportSource(node))
|
|
362
|
-
},
|
|
363
|
-
ExportAllDeclaration(node) {
|
|
364
|
-
reportFor(node, exportSource(node))
|
|
365
|
-
},
|
|
366
|
-
}
|
|
449
|
+
return boundaryVisitor(reportFor)
|
|
367
450
|
},
|
|
368
451
|
}
|
|
369
452
|
|
|
@@ -376,6 +459,8 @@ export default {
|
|
|
376
459
|
'card-inset': cardInset,
|
|
377
460
|
'chart-in-raw-surface': chartInRawSurface,
|
|
378
461
|
'raw-scroll-container': rawScrollContainer,
|
|
379
|
-
'
|
|
462
|
+
'visx-boundary': visxBoundary,
|
|
463
|
+
'visx-tooltip': visxTooltip,
|
|
464
|
+
'token-layer-boundary': tokenLayerBoundary,
|
|
380
465
|
},
|
|
381
466
|
}
|