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/src/cli/index.ts
CHANGED
|
@@ -35,13 +35,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
35
35
|
import { checkSource, DEFAULT_GUARD_CONFIG, GUARD_RULES } from '../guard'
|
|
36
36
|
import type { Finding, GuardConfig, GuardKind } from '../guard'
|
|
37
37
|
import { evaluateGuardHook } from '../guard/guard-hook'
|
|
38
|
-
import {
|
|
39
|
-
hasImportBoundaryRuleRegistered,
|
|
40
|
-
MANTINE_FREE_VIA_IMPORT_BOUNDARY,
|
|
41
|
-
RULE_NAMES,
|
|
42
|
-
SKILL_NAMES,
|
|
43
|
-
SURFACES,
|
|
44
|
-
} from '../surfaces'
|
|
38
|
+
import { RULE_NAMES, SKILL_NAMES, SURFACES, TOKEN_LAYER_BOUNDARY_SURFACES } from '../surfaces'
|
|
45
39
|
import type { DoctrineSpec, SurfaceSpec } from '../surfaces'
|
|
46
40
|
|
|
47
41
|
/** Shape of the optional `"basalt"` key in a consumer's package.json. */
|
|
@@ -141,27 +135,59 @@ export type BasaltConfig = {
|
|
|
141
135
|
* `sub-16-input-font` check.
|
|
142
136
|
*/
|
|
143
137
|
sub16InputFont?: boolean
|
|
144
|
-
/**
|
|
138
|
+
/**
|
|
139
|
+
* Path of the consumer's guard-exempt series file, for DESIGN.md `{{SERIES_MODULE_PATH}}`.
|
|
140
|
+
* Default: `<first basalt.root>/lib/series.ts` — see `resolveSeriesModulePath`.
|
|
141
|
+
*/
|
|
145
142
|
seriesModulePath?: string
|
|
146
143
|
}
|
|
147
144
|
|
|
148
|
-
const
|
|
145
|
+
const DEFAULT_ROOT = 'src'
|
|
146
|
+
const DEFAULT_ROOTS = [DEFAULT_ROOT]
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* The configured source roots, or the built-in default. The ONE resolution every roots-derived seed
|
|
150
|
+
* reads — an empty `roots: []` falls back rather than resolving to nothing, because a bare `??`
|
|
151
|
+
* would let `[]` through and render an empty oxfmt glob into the seeded CI, reproducing the exact
|
|
152
|
+
* "matches zero files" break this derivation exists to prevent.
|
|
153
|
+
*/
|
|
154
|
+
function resolveRoots(cfg: BasaltConfig): string[] {
|
|
155
|
+
return cfg.roots?.length ? cfg.roots : DEFAULT_ROOTS
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The one consumer series path — the DESIGN.md template's `{{SERIES_MODULE_PATH}}`, the default
|
|
160
|
+
* scan exemption, and the skills' prose all resolve through this single function.
|
|
161
|
+
*
|
|
162
|
+
* Derived from the FIRST configured root (argo's convention: `<root>/lib/series.ts`), not a fixed
|
|
163
|
+
* `src/lib/series.ts` — a monorepo that correctly sets `roots: ['apps/web/src']` has no top-level
|
|
164
|
+
* `src/`, so a hardcoded default would seed a DESIGN.md pointing at a path that cannot exist and
|
|
165
|
+
* silently exempt nothing. `seriesModulePath` still overrides for a layout that isn't `<root>/lib/`.
|
|
166
|
+
*/
|
|
167
|
+
function resolveSeriesModulePath(cfg: BasaltConfig): string {
|
|
168
|
+
if (cfg.seriesModulePath !== undefined) return cfg.seriesModulePath
|
|
169
|
+
const [firstRoot = DEFAULT_ROOT] = resolveRoots(cfg)
|
|
170
|
+
return `${firstRoot}/lib/series.ts`
|
|
171
|
+
}
|
|
149
172
|
|
|
150
173
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
174
|
+
* A root as a single-quoted oxfmt glob for the seeded CI `run:` step. POSIX-escapes any embedded
|
|
175
|
+
* quote (`'` → `'\''`) — `roots` is consumer-authored, and an unescaped apostrophe would break out
|
|
176
|
+
* of the quoting and emit a workflow that fails on a syntax error the consumer can't trace back
|
|
177
|
+
* here. Not a privilege boundary (it's their own config rendering into their own CI), just a file
|
|
178
|
+
* this CLI generates and therefore owes valid quoting.
|
|
154
179
|
*/
|
|
155
|
-
|
|
180
|
+
function toRootGlob(root: string): string {
|
|
181
|
+
return `'${root.replace(/'/g, `'\\''`)}/**'`
|
|
182
|
+
}
|
|
156
183
|
|
|
157
184
|
/**
|
|
158
|
-
* Default scan exemption — a bare consumer's only palette source is its
|
|
159
|
-
*
|
|
160
|
-
* `
|
|
161
|
-
* `{{SERIES_MODULE_PATH}}`, so overriding `seriesModulePath` keeps the exemption in sync.
|
|
185
|
+
* Default scan exemption — a bare consumer's only palette source is its series module (the doctrine
|
|
186
|
+
* directs every consumer to put raw hex series colors there). Shares `resolveSeriesModulePath` with
|
|
187
|
+
* `buildTemplateVars`'s `{{SERIES_MODULE_PATH}}`, so the seeded path and the exemption can't drift.
|
|
162
188
|
*/
|
|
163
189
|
function defaultExempt(cfg: BasaltConfig): string[] {
|
|
164
|
-
return [cfg
|
|
190
|
+
return [resolveSeriesModulePath(cfg)]
|
|
165
191
|
}
|
|
166
192
|
|
|
167
193
|
const SKIP = /\.gen\.ts$|\.test\.[tj]sx?$|\.d\.ts$/
|
|
@@ -415,6 +441,8 @@ type TemplateVars = {
|
|
|
415
441
|
BASALT_VERSION: string
|
|
416
442
|
ACCENT_HUE: string
|
|
417
443
|
SERIES_MODULE_PATH: string
|
|
444
|
+
/** The consumer's configured roots as space-separated quoted oxfmt globs, e.g. `'apps/web/src/**'`. */
|
|
445
|
+
ROOTS_GLOBS: string
|
|
418
446
|
}
|
|
419
447
|
|
|
420
448
|
// The block markers the CLAUDE.md template emits. The begin marker carries the framework version
|
|
@@ -465,7 +493,8 @@ function buildTemplateVars(pkgRoot: string, cwd: string, cfg: BasaltConfig): Tem
|
|
|
465
493
|
APP_NAME: readPackageName(cwd),
|
|
466
494
|
BASALT_VERSION: readFrameworkVersion(pkgRoot),
|
|
467
495
|
ACCENT_HUE: cfg.accentHue ?? 'blue',
|
|
468
|
-
SERIES_MODULE_PATH: cfg
|
|
496
|
+
SERIES_MODULE_PATH: resolveSeriesModulePath(cfg),
|
|
497
|
+
ROOTS_GLOBS: resolveRoots(cfg).map(toRootGlob).join(' '),
|
|
469
498
|
}
|
|
470
499
|
}
|
|
471
500
|
|
|
@@ -622,13 +651,20 @@ function managedFiles(peers: PeerFlags): ManagedFile[] {
|
|
|
622
651
|
' - node_modules/basalt-ui/configs/lefthook.yml\n',
|
|
623
652
|
}
|
|
624
653
|
|
|
625
|
-
// CI is inherently repo-shaped (a monorepo's check.yml needs its own
|
|
626
|
-
//
|
|
654
|
+
// CI is inherently repo-shaped (a monorepo's check.yml needs its own scripts), and GitHub Actions
|
|
655
|
+
// has no in-repo `extends` — so the workflow seeds as an explicit starting copy. Its oxfmt globs
|
|
656
|
+
// come from `{{ROOTS_GLOBS}}` rather than a hardcoded `src/**`: on a monorepo the latter matches
|
|
657
|
+
// nothing and oxfmt exits 2, breaking the consumer's very first CI run for a reason that reads
|
|
658
|
+
// like a basalt bug.
|
|
627
659
|
const ci: ManagedFile = {
|
|
628
660
|
dest: '.github/workflows/check.yml',
|
|
629
661
|
mode: 'seed',
|
|
630
662
|
source: 'configs/check.yml',
|
|
631
|
-
render: (ctx) =>
|
|
663
|
+
render: (ctx) => {
|
|
664
|
+
const tpl = readSource(ctx.pkgRoot, 'configs/check.yml')
|
|
665
|
+
if (tpl === null) return null
|
|
666
|
+
return fillTemplate(tpl, ctx.vars)
|
|
667
|
+
},
|
|
632
668
|
}
|
|
633
669
|
|
|
634
670
|
// Seed an `.oxlintrc.json` that extends the shipped preset (written once, then consumer-owned).
|
|
@@ -1070,8 +1106,11 @@ export function sync(opts: SyncOptions = {}, cwd: string = process.cwd()): numbe
|
|
|
1070
1106
|
* 5. Every real package.json exports key has a SURFACES entry.
|
|
1071
1107
|
* 6. Every surface with non-empty forbiddenImports has a globs field.
|
|
1072
1108
|
* 7. Every headless surface is Mantine-free — via all 3 `forbiddenImports` bans, OR (for
|
|
1073
|
-
* `
|
|
1074
|
-
*
|
|
1109
|
+
* `TOKEN_LAYER_BOUNDARY_SURFACES` members, `./charts`/`./tokens`) exemption, since their
|
|
1110
|
+
* Mantine-free guarantee is covered by the repo-local-only `basalt/token-layer-boundary`
|
|
1111
|
+
* plugin rule instead — this assertion cannot verify that rule's live registration itself (see
|
|
1112
|
+
* the assertion's own comment below for why); basalt's own CI does
|
|
1113
|
+
* (`tests/surfaces-coverage.test.ts`).
|
|
1075
1114
|
* 8. Every doctrine optionalPeers entry exists in peerDependencies AND peerDependenciesMeta.
|
|
1076
1115
|
*
|
|
1077
1116
|
* Tooling surfaces are exempt from assertions 1–3 by the discriminant.
|
|
@@ -1166,32 +1205,23 @@ export function checkCoverage(): number {
|
|
|
1166
1205
|
|
|
1167
1206
|
// ── Assertion 7: every headless surface is Mantine-free ──────────────────────
|
|
1168
1207
|
// Guarantees the Mantine-free boundary — a future headless surface without coverage fails here.
|
|
1169
|
-
// Coverage is either all 3 forbiddenImports bans, OR
|
|
1170
|
-
// `
|
|
1171
|
-
//
|
|
1172
|
-
//
|
|
1208
|
+
// Coverage is either all 3 forbiddenImports bans, OR membership in
|
|
1209
|
+
// `TOKEN_LAYER_BOUNDARY_SURFACES` (`./charts`/`./tokens`), whose Mantine-free guarantee comes
|
|
1210
|
+
// from the `basalt/token-layer-boundary` plugin rule instead — protects both layering (tokens
|
|
1211
|
+
// upstream of Mantine) and packaging (those two subpaths resolve with no `@mantine/*` installed,
|
|
1212
|
+
// CI-tested via `scripts/pack-test.sh` + `scripts/check-dist-layering.mjs`; see surfaces.ts's
|
|
1213
|
+
// `TOKEN_LAYER_BOUNDARY_SURFACES` doc comment). This assertion CANNOT also verify
|
|
1214
|
+
// that rule's live registration: `check-coverage` is a shipped CLI subcommand whose assertions
|
|
1215
|
+
// must all read pkgRoot-relative paths so it works from inside a consumer's node_modules — and a
|
|
1216
|
+
// repo-local `.oxlintrc.json` read from an installed package path-resolves to the CONSUMER's own
|
|
1217
|
+
// config, not basalt's. That "fails loudly if enforcement is removed" guarantee lives in
|
|
1218
|
+
// basalt's own CI instead (`tests/surfaces-coverage.test.ts`, via
|
|
1219
|
+
// `hasTokenLayerBoundaryRegistered` against `.oxlintrc.json`).
|
|
1173
1220
|
const REQUIRED_MANTINE_BANS = ['@mantine/core', '@mantine/hooks', '@mantine/*'] as const
|
|
1174
|
-
let shippedRules: Record<string, unknown> | undefined
|
|
1175
|
-
try {
|
|
1176
|
-
const shippedConfig = JSON.parse(
|
|
1177
|
-
readFileSync(resolve(pkgRoot, 'configs/oxlint.json'), 'utf8'),
|
|
1178
|
-
) as { rules?: Record<string, unknown> }
|
|
1179
|
-
shippedRules = shippedConfig.rules
|
|
1180
|
-
} catch {
|
|
1181
|
-
failures.push(`Cannot read configs/oxlint.json at ${pkgRoot} to verify basalt/import-boundary`)
|
|
1182
|
-
}
|
|
1183
|
-
const importBoundaryRegistered = hasImportBoundaryRuleRegistered(shippedRules)
|
|
1184
1221
|
|
|
1185
1222
|
for (const [key, spec] of allSpecs) {
|
|
1186
1223
|
if (spec.layer !== 'headless') continue
|
|
1187
|
-
if (
|
|
1188
|
-
if (importBoundaryRegistered) continue
|
|
1189
|
-
failures.push(
|
|
1190
|
-
`SURFACES['${key}'] relies on the basalt/import-boundary plugin rule for Mantine-free ` +
|
|
1191
|
-
`coverage, but that rule is not registered as 'error' in configs/oxlint.json`,
|
|
1192
|
-
)
|
|
1193
|
-
continue
|
|
1194
|
-
}
|
|
1224
|
+
if (TOKEN_LAYER_BOUNDARY_SURFACES.has(key)) continue
|
|
1195
1225
|
for (const required of REQUIRED_MANTINE_BANS) {
|
|
1196
1226
|
const hasBan = spec.forbiddenImports.some((fi) => fi.spec === required)
|
|
1197
1227
|
if (!hasBan) {
|
|
@@ -158,3 +158,71 @@ describe('init — first-run hint', () => {
|
|
|
158
158
|
expect(log.toLowerCase()).toContain('basalt.*')
|
|
159
159
|
})
|
|
160
160
|
})
|
|
161
|
+
|
|
162
|
+
describe('seeds derive from basalt.roots', () => {
|
|
163
|
+
// A monorepo sets `roots` because it has no top-level `src/`. Both the CI oxfmt globs and the
|
|
164
|
+
// DESIGN.md series path used to hardcode `src`, so a consumer that configured roots CORRECTLY
|
|
165
|
+
// still got a CI run that matched zero files (oxfmt exits 2) and a series path that can't exist.
|
|
166
|
+
const MONOREPO = { name: 'fixture', basalt: { roots: ['apps/web/src'] } }
|
|
167
|
+
|
|
168
|
+
it('renders the CI oxfmt globs from roots', () => {
|
|
169
|
+
writeFixture('package.json', JSON.stringify(MONOREPO))
|
|
170
|
+
init(dir)
|
|
171
|
+
const ci = readFileSync(resolve(dir, '.github/workflows/check.yml'), 'utf8')
|
|
172
|
+
expect(ci).toContain("bunx oxfmt 'apps/web/src/**' '!**/dist/**' --check")
|
|
173
|
+
expect(ci).not.toContain('{{ROOTS_GLOBS}}')
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('renders every root, not just the first', () => {
|
|
177
|
+
writeFixture(
|
|
178
|
+
'package.json',
|
|
179
|
+
JSON.stringify({ name: 'f', basalt: { roots: ['a/src', 'b/src'] } }),
|
|
180
|
+
)
|
|
181
|
+
init(dir)
|
|
182
|
+
const ci = readFileSync(resolve(dir, '.github/workflows/check.yml'), 'utf8')
|
|
183
|
+
expect(ci).toContain("bunx oxfmt 'a/src/**' 'b/src/**' '!**/dist/**' --check")
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it("falls back to 'src/**' when roots is unset", () => {
|
|
187
|
+
writeFixture('package.json', JSON.stringify({ name: 'fixture' }))
|
|
188
|
+
init(dir)
|
|
189
|
+
const ci = readFileSync(resolve(dir, '.github/workflows/check.yml'), 'utf8')
|
|
190
|
+
expect(ci).toContain("bunx oxfmt 'src/**' '!**/dist/**' --check")
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
it('seeds DESIGN.md with a series path under the first root', () => {
|
|
194
|
+
writeFixture('package.json', JSON.stringify(MONOREPO))
|
|
195
|
+
init(dir)
|
|
196
|
+
const design = readFileSync(resolve(dir, 'DESIGN.md'), 'utf8')
|
|
197
|
+
expect(design).toContain('apps/web/src/lib/series.ts')
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it('falls back to the default root when roots is an explicit empty array', () => {
|
|
201
|
+
// `[]` is nonsense config, but a bare `??` would let it through and render an empty oxfmt glob
|
|
202
|
+
// into CI — the exact "matches zero files" break this derivation exists to prevent.
|
|
203
|
+
writeFixture('package.json', JSON.stringify({ name: 'f', basalt: { roots: [] } }))
|
|
204
|
+
init(dir)
|
|
205
|
+
const ci = readFileSync(resolve(dir, '.github/workflows/check.yml'), 'utf8')
|
|
206
|
+
expect(ci).toContain("bunx oxfmt 'src/**' '!**/dist/**' --check")
|
|
207
|
+
expect(readFileSync(resolve(dir, 'DESIGN.md'), 'utf8')).toContain('src/lib/series.ts')
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
it('POSIX-escapes a quote in a root instead of breaking out of the CI shell quoting', () => {
|
|
211
|
+
writeFixture('package.json', JSON.stringify({ name: 'f', basalt: { roots: ["it's/src"] } }))
|
|
212
|
+
init(dir)
|
|
213
|
+
const ci = readFileSync(resolve(dir, '.github/workflows/check.yml'), 'utf8')
|
|
214
|
+
expect(ci).toContain("'it'\\''s/src/**'")
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
it('lets seriesModulePath override the roots-derived default', () => {
|
|
218
|
+
writeFixture(
|
|
219
|
+
'package.json',
|
|
220
|
+
JSON.stringify({
|
|
221
|
+
name: 'f',
|
|
222
|
+
basalt: { roots: ['apps/web/src'], seriesModulePath: 'custom/p.ts' },
|
|
223
|
+
}),
|
|
224
|
+
)
|
|
225
|
+
init(dir)
|
|
226
|
+
expect(readFileSync(resolve(dir, 'DESIGN.md'), 'utf8')).toContain('custom/p.ts')
|
|
227
|
+
})
|
|
228
|
+
})
|
package/src/surfaces.ts
CHANGED
|
@@ -152,10 +152,11 @@ const vg = (spec: string, message: string, extra?: Partial<ForbiddenImport>): Fo
|
|
|
152
152
|
...extra,
|
|
153
153
|
})
|
|
154
154
|
|
|
155
|
-
// Mantine-free ban for headless surfaces the `basalt/
|
|
156
|
-
// (it only enforces charts/tokens path segments
|
|
157
|
-
// no longer use this: their Mantine-free
|
|
158
|
-
//
|
|
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.
|
|
159
160
|
const MANTINE_BANS = [
|
|
160
161
|
v('@mantine/core', '{ctx} must be Mantine-free — no Mantine imports allowed.'),
|
|
161
162
|
v('@mantine/hooks', '{ctx} must be Mantine-free — no Mantine imports allowed.'),
|
|
@@ -198,9 +199,10 @@ export const SURFACES = {
|
|
|
198
199
|
shipped: ['**/charts/**'],
|
|
199
200
|
repo: ['packages/basalt-ui/src/charts/**'],
|
|
200
201
|
},
|
|
201
|
-
// The @visx/*-only-in-charts
|
|
202
|
-
// `basalt/
|
|
203
|
-
//
|
|
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.
|
|
204
206
|
forbiddenImports: [],
|
|
205
207
|
ruleOverrides: [{ rule: 'no-underscore-dangle', level: 'off', target: 'repo' }],
|
|
206
208
|
},
|
|
@@ -216,7 +218,8 @@ export const SURFACES = {
|
|
|
216
218
|
shipped: ['**/tokens/**'],
|
|
217
219
|
repo: ['packages/basalt-ui/src/tokens/**'],
|
|
218
220
|
},
|
|
219
|
-
// Mantine-free
|
|
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).
|
|
220
223
|
forbiddenImports: [],
|
|
221
224
|
},
|
|
222
225
|
'./theme-lab': {
|
|
@@ -239,7 +242,7 @@ export const SURFACES = {
|
|
|
239
242
|
shipped: [],
|
|
240
243
|
repo: ['packages/basalt-ui/src/guard/**'],
|
|
241
244
|
},
|
|
242
|
-
// @visx/* ban dropped — `basalt/
|
|
245
|
+
// @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
|
|
243
246
|
forbiddenImports: [...MANTINE_BANS],
|
|
244
247
|
}, // 6th JS subpath
|
|
245
248
|
'./query': {
|
|
@@ -254,7 +257,7 @@ export const SURFACES = {
|
|
|
254
257
|
shipped: [],
|
|
255
258
|
repo: ['packages/basalt-ui/src/query/**'],
|
|
256
259
|
},
|
|
257
|
-
// @visx/* ban dropped — `basalt/
|
|
260
|
+
// @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
|
|
258
261
|
forbiddenImports: [...MANTINE_BANS],
|
|
259
262
|
},
|
|
260
263
|
'./router-tanstack': {
|
|
@@ -270,7 +273,7 @@ export const SURFACES = {
|
|
|
270
273
|
shipped: [],
|
|
271
274
|
repo: ['packages/basalt-ui/src/router-tanstack/**'],
|
|
272
275
|
},
|
|
273
|
-
// @visx/* ban dropped — `basalt/
|
|
276
|
+
// @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
|
|
274
277
|
forbiddenImports: [...MANTINE_BANS],
|
|
275
278
|
},
|
|
276
279
|
'./forms': {
|
|
@@ -352,7 +355,7 @@ export const SURFACES = {
|
|
|
352
355
|
shipped: [],
|
|
353
356
|
repo: ['packages/basalt-ui/src/agent/**'],
|
|
354
357
|
},
|
|
355
|
-
// @visx/* ban dropped — `basalt/
|
|
358
|
+
// @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
|
|
356
359
|
forbiddenImports: [...MANTINE_BANS],
|
|
357
360
|
},
|
|
358
361
|
'./content': {
|
|
@@ -390,7 +393,7 @@ export const SURFACES = {
|
|
|
390
393
|
shipped: [],
|
|
391
394
|
repo: ['packages/basalt-ui/src/state.ts'],
|
|
392
395
|
},
|
|
393
|
-
// @visx/* ban dropped — `basalt/
|
|
396
|
+
// @visx/* ban dropped — `basalt/visx-boundary` now bans it universally outside charts.
|
|
394
397
|
forbiddenImports: [...MANTINE_BANS],
|
|
395
398
|
},
|
|
396
399
|
|
|
@@ -441,11 +444,19 @@ export const SURFACES = {
|
|
|
441
444
|
// Shipped is a catch-all (not just src/**+app/**) so consumer code under components/, lib/,
|
|
442
445
|
// features/, etc. is also covered. The @visx/*-only-in-charts and Mantine-free charts/tokens
|
|
443
446
|
// boundaries used to live here too and need last-writer-wins EMIT_ORDER games against the
|
|
444
|
-
// narrower ./tokens/./charts overrides — they're now enforced by `basalt/
|
|
445
|
-
// (
|
|
446
|
-
// framer-motion) are plain global bans with no narrower
|
|
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.
|
|
447
451
|
shipped: ['**/*.{ts,tsx}'],
|
|
448
|
-
|
|
452
|
+
// Repo is packages/basalt-ui/src/** ONLY. apps/playground is deliberately absent: it
|
|
453
|
+
// dogfoods the shipped consumer preset through its own apps/playground/.oxlintrc.json
|
|
454
|
+
// (`extends: ["./node_modules/basalt-ui/configs/oxlint.json"]`, resolved via the workspace
|
|
455
|
+
// symlink), which oxlint honours as a nested config — the nearest config REPLACES this one
|
|
456
|
+
// for that subtree, so listing playground here would be dead glob. That indirection is the
|
|
457
|
+
// point: the playground sees exactly what a real consumer sees, including NOT receiving
|
|
458
|
+
// `basalt/token-layer-boundary` (repo-local by design — see TOKEN_LAYER_BOUNDARY_SURFACES).
|
|
459
|
+
repo: ['packages/basalt-ui/src/**'],
|
|
449
460
|
},
|
|
450
461
|
ruleOverrides: [{ rule: 'no-console', level: 'off', target: 'repo' }], // cli/bin/scripts, repo-local only
|
|
451
462
|
forbiddenImports: [
|
|
@@ -490,35 +501,50 @@ export const SKILL_NAMES = [
|
|
|
490
501
|
),
|
|
491
502
|
] as const satisfies readonly SkillName[]
|
|
492
503
|
|
|
493
|
-
// ──
|
|
504
|
+
// ── Token-layer-boundary-via-plugin membership ────────────────────────────────────────────────────
|
|
494
505
|
|
|
495
506
|
/**
|
|
496
|
-
* Headless SURFACES keys whose Mantine-free guarantee is enforced by the `basalt/
|
|
497
|
-
* oxlint plugin rule (`configs/oxlint-plugin.js`) instead of a `forbiddenImports`
|
|
498
|
-
* imports ban — the rule fires on `charts`/`tokens` path segments only, so ONLY
|
|
499
|
-
* qualify (every other headless surface still carries its Mantine ban in
|
|
507
|
+
* Headless SURFACES keys whose Mantine-free guarantee is enforced by the `basalt/token-layer-
|
|
508
|
+
* boundary` oxlint plugin rule (`configs/oxlint-plugin.js`) instead of a `forbiddenImports`
|
|
509
|
+
* no-restricted-imports ban — the rule fires on `charts`/`tokens` path segments only, so ONLY
|
|
510
|
+
* these two surfaces qualify (every other headless surface still carries its Mantine ban in
|
|
511
|
+
* `forbiddenImports`).
|
|
500
512
|
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
*
|
|
513
|
+
* `basalt/token-layer-boundary` is registered ONLY in the repo-local `.oxlintrc.json`, never the
|
|
514
|
+
* shipped consumer preset. It protects two things: layering — `tokens` is pure data that
|
|
515
|
+
* `cssVariablesResolver` (Mantine-coupled) reads to bind Mantine's surfaces to the same `--vx-*`
|
|
516
|
+
* vars `charts` reads, so an `@mantine/*` import in either would cycle back through the theme
|
|
517
|
+
* layer or let a chart bypass `--vx-*` and fork chrome/charts apart — and packaging: `./charts`
|
|
518
|
+
* and `./tokens` resolve and render with NO `@mantine/*` installed, real and CI-tested
|
|
519
|
+
* (`scripts/pack-test.sh`'s "charts/tokens-only (no-Mantine) resolution + render" step,
|
|
520
|
+
* `scripts/check-dist-layering.mjs`'s dist-graph walk). The LAYER is Mantine-free — the FRAMEWORK
|
|
521
|
+
* is not (`.` requires Mantine as a non-optional peer; these two subpaths don't). Both are a
|
|
522
|
+
* basalt-internal invariant, not a consumer contract (a consumer's own `charts/`/`tokens/`-named
|
|
523
|
+
* directories carry no such obligation), which is why it stays repo-local. Because
|
|
524
|
+
* of that, `checkCoverage()`'s assertion 7 treats membership here as a pure EXEMPTION from the
|
|
525
|
+
* forbiddenImports requirement — it does NOT (and, being a shipped CLI subcommand that must run
|
|
526
|
+
* from inside a consumer's node_modules, CANNOT) verify the rule's live registration itself. That
|
|
527
|
+
* "fails loudly if enforcement is removed" guarantee lives in basalt's own CI instead
|
|
528
|
+
* (`tests/surfaces-coverage.test.ts`, via `hasTokenLayerBoundaryRegistered` against
|
|
529
|
+
* `.oxlintrc.json`).
|
|
504
530
|
*/
|
|
505
|
-
export const
|
|
506
|
-
'./charts',
|
|
507
|
-
'./tokens',
|
|
508
|
-
])
|
|
531
|
+
export const TOKEN_LAYER_BOUNDARY_SURFACES: ReadonlySet<string> = new Set(['./charts', './tokens'])
|
|
509
532
|
|
|
510
533
|
/**
|
|
511
|
-
* True when a parsed oxlint config's `rules` object registers `basalt/
|
|
512
|
-
* — the live signal (not just a hardcoded assumption) that `
|
|
513
|
-
*
|
|
514
|
-
*
|
|
534
|
+
* True when a parsed oxlint config's `rules` object registers `basalt/token-layer-boundary` as
|
|
535
|
+
* `'error'` — the live signal (not just a hardcoded assumption) that `TOKEN_LAYER_BOUNDARY_SURFACES`
|
|
536
|
+
* are actually enforced. Pure — callers read + JSON.parse the config file themselves (surfaces.ts
|
|
537
|
+
* stays dependency-free, no fs access here). Consumed only by basalt's own CI
|
|
538
|
+
* (`tests/surfaces-coverage.test.ts`) against the repo-local `.oxlintrc.json` — NOT by
|
|
539
|
+
* `checkCoverage()`, which cannot read that repo-local file from an installed package (see
|
|
540
|
+
* `TOKEN_LAYER_BOUNDARY_SURFACES`'s doc comment).
|
|
515
541
|
*
|
|
516
542
|
* @example
|
|
517
|
-
*
|
|
518
|
-
*
|
|
543
|
+
* hasTokenLayerBoundaryRegistered({ 'basalt/token-layer-boundary': 'error' }) // true
|
|
544
|
+
* hasTokenLayerBoundaryRegistered({}) // false
|
|
519
545
|
*/
|
|
520
|
-
export function
|
|
546
|
+
export function hasTokenLayerBoundaryRegistered(
|
|
521
547
|
rules: Record<string, unknown> | undefined,
|
|
522
548
|
): boolean {
|
|
523
|
-
return rules?.['basalt/
|
|
549
|
+
return rules?.['basalt/token-layer-boundary'] === 'error'
|
|
524
550
|
}
|