basalt-ui 0.3.0 → 1.0.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 +70 -0
- package/CHANGELOG.md +216 -26
- package/LICENSE +201 -0
- package/README.md +434 -160
- package/agent/rules/basalt-agent.md +395 -0
- package/agent/rules/basalt-charts.md +170 -0
- package/agent/rules/basalt-commands.md +320 -0
- package/agent/rules/basalt-content.md +390 -0
- package/agent/rules/basalt-data.md +237 -0
- package/agent/rules/basalt-forms.md +186 -0
- package/agent/rules/basalt-mantine.md +327 -0
- package/agent/rules/basalt-notifications.md +264 -0
- package/agent/rules/basalt-query.md +130 -0
- package/agent/rules/basalt-router.md +173 -0
- package/agent/rules/basalt-state.md +99 -0
- package/agent/rules/basalt-tokens.md +148 -0
- package/agent/templates/CLAUDE-block.md.tpl +35 -0
- package/agent/templates/DESIGN.md.tpl +71 -0
- package/agent/templates/__root.tpl +31 -0
- package/agent/templates/query-client.ts.tpl +12 -0
- package/bin/basalt.mjs +14 -0
- package/configs/check.yml +29 -0
- package/configs/lefthook.yml +21 -0
- package/configs/oxfmt.json +8 -0
- package/configs/oxlint-plugin.js +269 -0
- package/configs/oxlint-plugin.test.ts +107 -0
- package/configs/oxlint.json +116 -0
- package/configs/tsconfig.base.json +20 -0
- package/configs/tsconfig.node.json +8 -0
- package/configs/tsconfig.react-app.json +8 -0
- package/dist/agent/ai-sdk-transport.d.ts +85 -0
- package/dist/agent/ai-sdk-transport.d.ts.map +1 -0
- package/dist/agent/ai-sdk-transport.js +109 -0
- package/dist/agent/history.d.ts +55 -0
- package/dist/agent/history.d.ts.map +1 -0
- package/dist/agent/history.js +32 -0
- package/dist/agent/index.d.ts +53 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +23 -0
- package/dist/agent/outcome.d.ts +71 -0
- package/dist/agent/outcome.d.ts.map +1 -0
- package/dist/agent/outcome.js +30 -0
- package/dist/agent/part-list.d.ts +75 -0
- package/dist/agent/part-list.d.ts.map +1 -0
- package/dist/agent/part-list.js +127 -0
- package/dist/agent/parts.d.ts +91 -0
- package/dist/agent/parts.d.ts.map +1 -0
- package/dist/agent/parts.js +49 -0
- package/dist/agent/stick-to-bottom.d.ts +23 -0
- package/dist/agent/stick-to-bottom.d.ts.map +1 -0
- package/dist/agent/stick-to-bottom.js +73 -0
- package/dist/agent/thread.d.ts +124 -0
- package/dist/agent/thread.d.ts.map +1 -0
- package/dist/agent/thread.js +131 -0
- package/dist/agent/transport.d.ts +87 -0
- package/dist/agent/transport.d.ts.map +1 -0
- package/dist/agent/transport.js +21 -0
- package/dist/agent/use-agent-stream.d.ts +34 -0
- package/dist/agent/use-agent-stream.d.ts.map +1 -0
- package/dist/agent/use-agent-stream.js +56 -0
- package/dist/agent/use-agent-thread-runs.d.ts +72 -0
- package/dist/agent/use-agent-thread-runs.d.ts.map +1 -0
- package/dist/agent/use-agent-thread-runs.js +217 -0
- package/dist/agent-chat/composer.d.ts +18 -0
- package/dist/agent-chat/composer.d.ts.map +1 -0
- package/dist/agent-chat/composer.js +86 -0
- package/dist/agent-chat/index.d.ts +24 -0
- package/dist/agent-chat/index.d.ts.map +1 -0
- package/dist/agent-chat/index.js +15 -0
- package/dist/agent-chat/thread-detail-panel.d.ts +27 -0
- package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -0
- package/dist/agent-chat/thread-detail-panel.js +108 -0
- package/dist/agent-chat/thread-feed.d.ts +18 -0
- package/dist/agent-chat/thread-feed.d.ts.map +1 -0
- package/dist/agent-chat/thread-feed.js +42 -0
- package/dist/agent-chat/thread-message.d.ts +31 -0
- package/dist/agent-chat/thread-message.d.ts.map +1 -0
- package/dist/agent-chat/thread-message.js +128 -0
- package/dist/agent-chat/thread-outcome-card.d.ts +19 -0
- package/dist/agent-chat/thread-outcome-card.d.ts.map +1 -0
- package/dist/agent-chat/thread-outcome-card.js +120 -0
- package/dist/agent-chat/thread-workspace.d.ts +27 -0
- package/dist/agent-chat/thread-workspace.d.ts.map +1 -0
- package/dist/agent-chat/thread-workspace.js +95 -0
- package/dist/charts/hooks/useChartSize.d.ts +25 -0
- package/dist/charts/hooks/useChartSize.d.ts.map +1 -0
- package/dist/charts/hooks/useChartSize.js +8 -0
- package/dist/charts/hooks/useChartTooltip.d.ts +13 -0
- package/dist/charts/hooks/useChartTooltip.d.ts.map +1 -0
- package/dist/charts/hooks/useChartTooltip.js +26 -0
- package/dist/charts/hooks/useHoverSync.d.ts +30 -0
- package/dist/charts/hooks/useHoverSync.d.ts.map +1 -0
- package/dist/charts/hooks/useHoverSync.js +70 -0
- package/dist/charts/hover-context.d.ts +21 -0
- package/dist/charts/hover-context.d.ts.map +1 -0
- package/dist/charts/hover-context.js +12 -0
- package/dist/charts/hover-sync.d.ts +14 -0
- package/dist/charts/hover-sync.d.ts.map +1 -0
- package/dist/charts/hover-sync.js +17 -0
- package/dist/charts/index.d.ts +47 -0
- package/dist/charts/index.d.ts.map +1 -0
- package/dist/charts/index.js +129 -0
- package/dist/charts/kinds/Bars.d.ts +129 -0
- package/dist/charts/kinds/Bars.d.ts.map +1 -0
- package/dist/charts/kinds/Bars.js +467 -0
- package/dist/charts/kinds/Donut.d.ts +65 -0
- package/dist/charts/kinds/Donut.d.ts.map +1 -0
- package/dist/charts/kinds/Donut.js +158 -0
- package/dist/charts/kinds/DualPanel.d.ts +67 -0
- package/dist/charts/kinds/DualPanel.d.ts.map +1 -0
- package/dist/charts/kinds/DualPanel.js +326 -0
- package/dist/charts/kinds/Heatmap.d.ts +59 -0
- package/dist/charts/kinds/Heatmap.d.ts.map +1 -0
- package/dist/charts/kinds/Heatmap.js +175 -0
- package/dist/charts/kinds/MultiLine.d.ts +73 -0
- package/dist/charts/kinds/MultiLine.d.ts.map +1 -0
- package/dist/charts/kinds/MultiLine.js +275 -0
- package/dist/charts/kinds/StackedArea.d.ts +35 -0
- package/dist/charts/kinds/StackedArea.d.ts.map +1 -0
- package/dist/charts/kinds/StackedArea.js +151 -0
- package/dist/charts/kinds/ZonedLine.d.ts +94 -0
- package/dist/charts/kinds/ZonedLine.d.ts.map +1 -0
- package/dist/charts/kinds/ZonedLine.js +218 -0
- package/dist/charts/primitives/AreaGradient.d.ts +18 -0
- package/dist/charts/primitives/AreaGradient.d.ts.map +1 -0
- package/dist/charts/primitives/AreaGradient.js +13 -0
- package/dist/charts/primitives/Axes.d.ts +22 -0
- package/dist/charts/primitives/Axes.d.ts.map +1 -0
- package/dist/charts/primitives/Axes.js +79 -0
- package/dist/charts/primitives/ChartCard.d.ts +14 -0
- package/dist/charts/primitives/ChartCard.d.ts.map +1 -0
- package/dist/charts/primitives/ChartCard.js +144 -0
- package/dist/charts/primitives/ChartFrame.d.ts +70 -0
- package/dist/charts/primitives/ChartFrame.d.ts.map +1 -0
- package/dist/charts/primitives/ChartFrame.js +77 -0
- package/dist/charts/primitives/ChartLegend.d.ts +36 -0
- package/dist/charts/primitives/ChartLegend.d.ts.map +1 -0
- package/dist/charts/primitives/ChartLegend.js +234 -0
- package/dist/charts/primitives/ChartTooltip.d.ts +34 -0
- package/dist/charts/primitives/ChartTooltip.d.ts.map +1 -0
- package/dist/charts/primitives/ChartTooltip.js +134 -0
- package/dist/charts/primitives/Crosshair.d.ts +23 -0
- package/dist/charts/primitives/Crosshair.d.ts.map +1 -0
- package/dist/charts/primitives/Crosshair.js +21 -0
- package/dist/charts/primitives/HoverOverlay.d.ts +9 -0
- package/dist/charts/primitives/HoverOverlay.d.ts.map +1 -0
- package/dist/charts/primitives/HoverOverlay.js +21 -0
- package/dist/charts/primitives/ResponsiveChart.d.ts +45 -0
- package/dist/charts/primitives/ResponsiveChart.d.ts.map +1 -0
- package/dist/charts/primitives/ResponsiveChart.js +24 -0
- package/dist/charts/primitives/ZoneRects.d.ts +38 -0
- package/dist/charts/primitives/ZoneRects.d.ts.map +1 -0
- package/dist/charts/primitives/ZoneRects.js +30 -0
- package/dist/charts/series.d.ts +99 -0
- package/dist/charts/series.d.ts.map +1 -0
- package/dist/charts/series.js +55 -0
- package/dist/charts/sparklines/BarSparkline.d.ts +13 -0
- package/dist/charts/sparklines/BarSparkline.d.ts.map +1 -0
- package/dist/charts/sparklines/BarSparkline.js +33 -0
- package/dist/charts/sparklines/LineSparkline.d.ts +15 -0
- package/dist/charts/sparklines/LineSparkline.d.ts.map +1 -0
- package/dist/charts/sparklines/LineSparkline.js +39 -0
- package/dist/charts/sparklines/index.d.ts +3 -0
- package/dist/charts/sparklines/index.d.ts.map +1 -0
- package/dist/charts/sparklines/index.js +6 -0
- package/dist/charts/theme.d.ts +21 -0
- package/dist/charts/theme.d.ts.map +1 -0
- package/dist/charts/theme.js +30 -0
- package/dist/charts/utils/domain.d.ts +20 -0
- package/dist/charts/utils/domain.d.ts.map +1 -0
- package/dist/charts/utils/domain.js +7 -0
- package/dist/charts/utils/format.d.ts +5 -0
- package/dist/charts/utils/format.d.ts.map +1 -0
- package/dist/charts/utils/format.js +27 -0
- package/dist/charts/utils/ticks.d.ts +5 -0
- package/dist/charts/utils/ticks.d.ts.map +1 -0
- package/dist/charts/utils/ticks.js +18 -0
- package/dist/cli/index.d.ts +273 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +907 -0
- package/dist/commands/ShortcutsHelp.d.ts +17 -0
- package/dist/commands/ShortcutsHelp.d.ts.map +1 -0
- package/dist/commands/ShortcutsHelp.js +64 -0
- package/dist/commands/define-commands.d.ts +140 -0
- package/dist/commands/define-commands.d.ts.map +1 -0
- package/dist/commands/define-commands.js +26 -0
- package/dist/commands/define-overlays.d.ts +134 -0
- package/dist/commands/define-overlays.d.ts.map +1 -0
- package/dist/commands/define-overlays.js +53 -0
- package/dist/commands/index.d.ts +42 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +46 -0
- package/dist/commands/overlays-mount.d.ts +117 -0
- package/dist/commands/overlays-mount.d.ts.map +1 -0
- package/dist/commands/overlays-mount.js +116 -0
- package/dist/commands/projectors.d.ts +152 -0
- package/dist/commands/projectors.d.ts.map +1 -0
- package/dist/commands/projectors.js +87 -0
- package/dist/commands/shortcut-format.d.ts +48 -0
- package/dist/commands/shortcut-format.d.ts.map +1 -0
- package/dist/commands/shortcut-format.js +33 -0
- package/dist/commands/useCommandHotkeys.d.ts +14 -0
- package/dist/commands/useCommandHotkeys.d.ts.map +1 -0
- package/dist/commands/useCommandHotkeys.js +45 -0
- package/dist/connectivity/connectivity-indicator.d.ts +8 -0
- package/dist/connectivity/connectivity-indicator.d.ts.map +1 -0
- package/dist/connectivity/connectivity-indicator.js +203 -0
- package/dist/connectivity/connectivity-provider.d.ts +7 -0
- package/dist/connectivity/connectivity-provider.d.ts.map +1 -0
- package/dist/connectivity/connectivity-provider.js +125 -0
- package/dist/connectivity/index.d.ts +13 -0
- package/dist/connectivity/index.d.ts.map +1 -0
- package/dist/connectivity/index.js +8 -0
- package/dist/connectivity/types.d.ts +36 -0
- package/dist/connectivity/types.d.ts.map +1 -0
- package/dist/connectivity/types.js +0 -0
- package/dist/connectivity/use-connectivity.d.ts +3 -0
- package/dist/connectivity/use-connectivity.d.ts.map +1 -0
- package/dist/connectivity/use-connectivity.js +14 -0
- package/dist/content/article-actions.d.ts +39 -0
- package/dist/content/article-actions.d.ts.map +1 -0
- package/dist/content/article-actions.js +28 -0
- package/dist/content/article-card.d.ts +58 -0
- package/dist/content/article-card.d.ts.map +1 -0
- package/dist/content/article-card.js +76 -0
- package/dist/content/article-card.module.css +109 -0
- package/dist/content/article-card.module.css.d.ts +16 -0
- package/dist/content/article-filter-bar.d.ts +40 -0
- package/dist/content/article-filter-bar.d.ts.map +1 -0
- package/dist/content/article-filter-bar.js +56 -0
- package/dist/content/article-layout.d.ts +61 -0
- package/dist/content/article-layout.d.ts.map +1 -0
- package/dist/content/article-layout.js +71 -0
- package/dist/content/article-layout.module.css +131 -0
- package/dist/content/article-layout.module.css.d.ts +20 -0
- package/dist/content/article-model.d.ts +62 -0
- package/dist/content/article-model.d.ts.map +1 -0
- package/dist/content/article-model.js +41 -0
- package/dist/content/block-split.d.ts +24 -0
- package/dist/content/block-split.d.ts.map +1 -0
- package/dist/content/block-split.js +63 -0
- package/dist/content/callout-alert.d.ts +27 -0
- package/dist/content/callout-alert.d.ts.map +1 -0
- package/dist/content/callout-alert.js +59 -0
- package/dist/content/callout.d.ts +24 -0
- package/dist/content/callout.d.ts.map +1 -0
- package/dist/content/callout.js +59 -0
- package/dist/content/callout.module.css +77 -0
- package/dist/content/callout.module.css.d.ts +16 -0
- package/dist/content/code-block.d.ts +26 -0
- package/dist/content/code-block.d.ts.map +1 -0
- package/dist/content/code-block.js +41 -0
- package/dist/content/code-block.module.css +86 -0
- package/dist/content/code-block.module.css.d.ts +14 -0
- package/dist/content/copy-action.d.ts +29 -0
- package/dist/content/copy-action.d.ts.map +1 -0
- package/dist/content/copy-action.js +46 -0
- package/dist/content/fence-block.d.ts +19 -0
- package/dist/content/fence-block.d.ts.map +1 -0
- package/dist/content/fence-block.js +23 -0
- package/dist/content/glyphs.d.ts +18 -0
- package/dist/content/glyphs.d.ts.map +1 -0
- package/dist/content/glyphs.js +43 -0
- package/dist/content/guide.d.ts +47 -0
- package/dist/content/guide.d.ts.map +1 -0
- package/dist/content/guide.js +110 -0
- package/dist/content/guide.module.css +62 -0
- package/dist/content/guide.module.css.d.ts +13 -0
- package/dist/content/heading-anchor.d.ts +8 -0
- package/dist/content/heading-anchor.d.ts.map +1 -0
- package/dist/content/heading-anchor.js +23 -0
- package/dist/content/heading-components.d.ts +5 -0
- package/dist/content/heading-components.d.ts.map +1 -0
- package/dist/content/heading-components.js +41 -0
- package/dist/content/highlighter.d.ts +8 -0
- package/dist/content/highlighter.d.ts.map +1 -0
- package/dist/content/highlighter.js +85 -0
- package/dist/content/index.d.ts +45 -0
- package/dist/content/index.d.ts.map +1 -0
- package/dist/content/index.js +43 -0
- package/dist/content/markdown-hast.d.ts +23 -0
- package/dist/content/markdown-hast.d.ts.map +1 -0
- package/dist/content/markdown-hast.js +48 -0
- package/dist/content/markdown.d.ts +68 -0
- package/dist/content/markdown.d.ts.map +1 -0
- package/dist/content/markdown.js +180 -0
- package/dist/content/mdx.d.ts +20 -0
- package/dist/content/mdx.d.ts.map +1 -0
- package/dist/content/mdx.js +64 -0
- package/dist/content/mermaid.d.ts +32 -0
- package/dist/content/mermaid.d.ts.map +1 -0
- package/dist/content/mermaid.js +70 -0
- package/dist/content/mermaid.module.css +20 -0
- package/dist/content/mermaid.module.css.d.ts +8 -0
- package/dist/content/prose.d.ts +29 -0
- package/dist/content/prose.d.ts.map +1 -0
- package/dist/content/prose.js +24 -0
- package/dist/content/prose.module.css +330 -0
- package/dist/content/prose.module.css.d.ts +12 -0
- package/dist/content/reading-progress.d.ts +20 -0
- package/dist/content/reading-progress.d.ts.map +1 -0
- package/dist/content/reading-progress.js +38 -0
- package/dist/content/reading-progress.module.css +22 -0
- package/dist/content/reading-progress.module.css.d.ts +9 -0
- package/dist/content/slug.d.ts +28 -0
- package/dist/content/slug.d.ts.map +1 -0
- package/dist/content/slug.js +28 -0
- package/dist/content/toc.d.ts +37 -0
- package/dist/content/toc.d.ts.map +1 -0
- package/dist/content/toc.js +134 -0
- package/dist/content/toc.module.css +51 -0
- package/dist/content/toc.module.css.d.ts +13 -0
- package/dist/content/url-hardening.d.ts +23 -0
- package/dist/content/url-hardening.d.ts.map +1 -0
- package/dist/content/url-hardening.js +23 -0
- package/dist/dashboard/delta-badge.d.ts +13 -0
- package/dist/dashboard/delta-badge.d.ts.map +1 -0
- package/dist/dashboard/delta-badge.js +45 -0
- package/dist/dashboard/empty-state.d.ts +15 -0
- package/dist/dashboard/empty-state.d.ts.map +1 -0
- package/dist/dashboard/empty-state.js +56 -0
- package/dist/dashboard/index.d.ts +5 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +16 -0
- package/dist/dashboard/settings-section.d.ts +24 -0
- package/dist/dashboard/settings-section.d.ts.map +1 -0
- package/dist/dashboard/settings-section.js +61 -0
- package/dist/dashboard/settings-section.module.css +23 -0
- package/dist/dashboard/settings-section.module.css.d.ts +10 -0
- package/dist/dashboard/stat-card.d.ts +18 -0
- package/dist/dashboard/stat-card.d.ts.map +1 -0
- package/dist/dashboard/stat-card.js +74 -0
- package/dist/data/data-table.d.ts +198 -0
- package/dist/data/data-table.d.ts.map +1 -0
- package/dist/data/data-table.js +342 -0
- package/dist/data/index.d.ts +34 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +2 -0
- package/dist/data/table.d.ts +24 -0
- package/dist/data/table.d.ts.map +1 -0
- package/dist/data/table.js +20 -0
- package/dist/data/virtual-list.d.ts +74 -0
- package/dist/data/virtual-list.d.ts.map +1 -0
- package/dist/data/virtual-list.js +86 -0
- package/dist/data/virtual.d.ts +20 -0
- package/dist/data/virtual.d.ts.map +1 -0
- package/dist/data/virtual.js +4 -0
- package/dist/forms/FormErrorSummary.d.ts +29 -0
- package/dist/forms/FormErrorSummary.d.ts.map +1 -0
- package/dist/forms/FormErrorSummary.js +28 -0
- package/dist/forms/create-form.d.ts +31 -0
- package/dist/forms/create-form.d.ts.map +1 -0
- package/dist/forms/create-form.js +18 -0
- package/dist/forms/field.d.ts +22 -0
- package/dist/forms/field.d.ts.map +1 -0
- package/dist/forms/field.js +9 -0
- package/dist/forms/index.d.ts +17 -0
- package/dist/forms/index.d.ts.map +1 -0
- package/dist/forms/index.js +13 -0
- package/dist/forms/use-form-draft.d.ts +61 -0
- package/dist/forms/use-form-draft.d.ts.map +1 -0
- package/dist/forms/use-form-draft.js +55 -0
- package/dist/guard/guard-hook.d.ts +40 -0
- package/dist/guard/guard-hook.d.ts.map +1 -0
- package/dist/guard/guard-hook.js +55 -0
- package/dist/guard/index.d.ts +144 -0
- package/dist/guard/index.d.ts.map +1 -0
- package/dist/guard/index.js +315 -0
- package/dist/guard/types.d.ts +97 -0
- package/dist/guard/types.d.ts.map +1 -0
- package/dist/guard/types.js +0 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +90 -0
- package/dist/motion/index.d.ts +29 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +12 -0
- package/dist/notifications/bell.d.ts +12 -0
- package/dist/notifications/bell.d.ts.map +1 -0
- package/dist/notifications/bell.js +84 -0
- package/dist/notifications/center.d.ts +20 -0
- package/dist/notifications/center.d.ts.map +1 -0
- package/dist/notifications/center.js +144 -0
- package/dist/notifications/define-notifications.d.ts +97 -0
- package/dist/notifications/define-notifications.d.ts.map +1 -0
- package/dist/notifications/define-notifications.js +27 -0
- package/dist/notifications/index.d.ts +36 -0
- package/dist/notifications/index.d.ts.map +1 -0
- package/dist/notifications/index.js +52 -0
- package/dist/notifications/notify.d.ts +92 -0
- package/dist/notifications/notify.d.ts.map +1 -0
- package/dist/notifications/notify.js +127 -0
- package/dist/notifications/overlay.d.ts +20 -0
- package/dist/notifications/overlay.d.ts.map +1 -0
- package/dist/notifications/overlay.js +12 -0
- package/dist/notifications/store.d.ts +120 -0
- package/dist/notifications/store.d.ts.map +1 -0
- package/dist/notifications/store.js +113 -0
- package/dist/provider/index.d.ts +93 -0
- package/dist/provider/index.d.ts.map +1 -0
- package/dist/provider/index.js +106 -0
- package/dist/query/devtools.d.ts +21 -0
- package/dist/query/devtools.d.ts.map +1 -0
- package/dist/query/devtools.js +12 -0
- package/dist/query/index.d.ts +65 -0
- package/dist/query/index.d.ts.map +1 -0
- package/dist/query/index.js +68 -0
- package/dist/register.d.ts +139 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/register.js +6 -0
- package/dist/router-tanstack/index.d.ts +74 -0
- package/dist/router-tanstack/index.d.ts.map +1 -0
- package/dist/router-tanstack/index.js +29 -0
- package/dist/router-tanstack/multi-search-param-store.d.ts +78 -0
- package/dist/router-tanstack/multi-search-param-store.d.ts.map +1 -0
- package/dist/router-tanstack/multi-search-param-store.js +35 -0
- package/dist/router-tanstack/search-param-store.d.ts +92 -0
- package/dist/router-tanstack/search-param-store.d.ts.map +1 -0
- package/dist/router-tanstack/search-param-store.js +26 -0
- package/dist/shell/account-types.d.ts +118 -0
- package/dist/shell/account-types.d.ts.map +1 -0
- package/dist/shell/account-types.js +0 -0
- package/dist/shell/app-breadcrumbs.d.ts +17 -0
- package/dist/shell/app-breadcrumbs.d.ts.map +1 -0
- package/dist/shell/app-breadcrumbs.js +39 -0
- package/dist/shell/app-header.module.css +73 -0
- package/dist/shell/app-header.module.css.d.ts +11 -0
- package/dist/shell/app-mobile-nav.d.ts +26 -0
- package/dist/shell/app-mobile-nav.d.ts.map +1 -0
- package/dist/shell/app-mobile-nav.js +106 -0
- package/dist/shell/app-mobile-nav.module.css +100 -0
- package/dist/shell/app-mobile-nav.module.css.d.ts +14 -0
- package/dist/shell/app-sidebar-account.d.ts +3 -0
- package/dist/shell/app-sidebar-account.d.ts.map +1 -0
- package/dist/shell/app-sidebar-account.js +84 -0
- package/dist/shell/app-sidebar.d.ts +56 -0
- package/dist/shell/app-sidebar.d.ts.map +1 -0
- package/dist/shell/app-sidebar.js +455 -0
- package/dist/shell/app-sidebar.module.css +414 -0
- package/dist/shell/app-sidebar.module.css.d.ts +34 -0
- package/dist/shell/index.d.ts +123 -0
- package/dist/shell/index.d.ts.map +1 -0
- package/dist/shell/index.js +179 -0
- package/dist/shell/page-header.d.ts +13 -0
- package/dist/shell/page-header.d.ts.map +1 -0
- package/dist/shell/page-header.js +23 -0
- package/dist/shell/sidebar-search.d.ts +12 -0
- package/dist/shell/sidebar-search.d.ts.map +1 -0
- package/dist/shell/sidebar-search.js +62 -0
- package/dist/shell/sidebar-search.module.css +62 -0
- package/dist/shell/sidebar-search.module.css.d.ts +11 -0
- package/dist/state.d.ts +62 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +124 -0
- package/dist/styles.css +166 -0
- package/dist/surfaces.d.ts +376 -0
- package/dist/surfaces.d.ts.map +1 -0
- package/dist/surfaces.js +306 -0
- package/dist/theme/controls.module.css +143 -0
- package/dist/theme/controls.module.css.d.ts +17 -0
- package/dist/theme/floating.module.css +35 -0
- package/dist/theme/floating.module.css.d.ts +9 -0
- package/dist/theme/index.d.ts +22 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +733 -0
- package/dist/theme/nav-link.module.css +67 -0
- package/dist/theme/nav-link.module.css.d.ts +8 -0
- package/dist/theme/segmented-control.module.css +14 -0
- package/dist/theme/segmented-control.module.css.d.ts +8 -0
- package/dist/theme/timeline.module.css +29 -0
- package/dist/theme/timeline.module.css.d.ts +9 -0
- package/dist/theme-lab/index.d.ts +59 -0
- package/dist/theme-lab/index.d.ts.map +1 -0
- package/dist/theme-lab/index.js +263 -0
- package/dist/theme-toggle/index.d.ts +8 -0
- package/dist/theme-toggle/index.d.ts.map +1 -0
- package/dist/theme-toggle/index.js +155 -0
- package/dist/tokens/index.d.ts +151 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +246 -0
- package/dist/tokens/palette.d.ts +304 -0
- package/dist/tokens/palette.d.ts.map +1 -0
- package/dist/tokens/palette.js +186 -0
- package/dist/vite.d.ts +30 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +68 -0
- package/llms.txt +149 -0
- package/package.json +246 -37
- package/src/agent/ai-sdk-transport.ts +280 -0
- package/src/agent/history.ts +128 -0
- package/src/agent/index.ts +92 -0
- package/src/agent/outcome.ts +120 -0
- package/src/agent/part-list.tsx +292 -0
- package/src/agent/parts.ts +136 -0
- package/src/agent/stick-to-bottom.tsx +154 -0
- package/src/agent/thread.ts +312 -0
- package/src/agent/transport.ts +114 -0
- package/src/agent/use-agent-stream.ts +141 -0
- package/src/agent/use-agent-thread-runs.ts +440 -0
- package/src/agent-chat/composer.tsx +131 -0
- package/src/agent-chat/index.ts +35 -0
- package/src/agent-chat/thread-detail-panel.tsx +192 -0
- package/src/agent-chat/thread-feed.tsx +81 -0
- package/src/agent-chat/thread-message.tsx +251 -0
- package/src/agent-chat/thread-outcome-card.tsx +196 -0
- package/src/agent-chat/thread-workspace.tsx +179 -0
- package/src/charts/hooks/useChartSize.ts +31 -0
- package/src/charts/hooks/useChartTooltip.ts +31 -0
- package/src/charts/hooks/useHoverSync.ts +116 -0
- package/src/charts/hover-context.ts +28 -0
- package/src/charts/hover-sync.tsx +37 -0
- package/src/charts/index.ts +118 -0
- package/src/charts/kinds/Bars.tsx +634 -0
- package/src/charts/kinds/Donut.tsx +233 -0
- package/src/charts/kinds/DualPanel.tsx +432 -0
- package/src/charts/kinds/Heatmap.tsx +255 -0
- package/src/charts/kinds/MultiLine.tsx +376 -0
- package/src/charts/kinds/StackedArea.tsx +218 -0
- package/src/charts/kinds/ZonedLine.tsx +346 -0
- package/src/charts/primitives/AreaGradient.tsx +26 -0
- package/src/charts/primitives/Axes.tsx +97 -0
- package/src/charts/primitives/ChartCard.tsx +180 -0
- package/src/charts/primitives/ChartFrame.tsx +157 -0
- package/src/charts/primitives/ChartLegend.tsx +302 -0
- package/src/charts/primitives/ChartTooltip.tsx +158 -0
- package/src/charts/primitives/Crosshair.tsx +40 -0
- package/src/charts/primitives/HoverOverlay.tsx +24 -0
- package/src/charts/primitives/ResponsiveChart.tsx +64 -0
- package/src/charts/primitives/ZoneRects.tsx +67 -0
- package/src/charts/series.ts +163 -0
- package/src/charts/sparklines/BarSparkline.tsx +48 -0
- package/src/charts/sparklines/LineSparkline.tsx +57 -0
- package/src/charts/sparklines/index.ts +2 -0
- package/src/charts/theme.tsx +53 -0
- package/src/charts/utils/domain.test.ts +24 -0
- package/src/charts/utils/domain.ts +22 -0
- package/src/charts/utils/format.ts +27 -0
- package/src/charts/utils/ticks.ts +18 -0
- package/src/cli/check-theme.test.ts +658 -0
- package/src/cli/index.ts +1497 -0
- package/src/cli/init-sync.test.ts +160 -0
- package/src/commands/ShortcutsHelp.tsx +129 -0
- package/src/commands/define-commands.ts +184 -0
- package/src/commands/define-overlays.ts +197 -0
- package/src/commands/index.ts +86 -0
- package/src/commands/overlays-mount.tsx +301 -0
- package/src/commands/projectors.ts +267 -0
- package/src/commands/shortcut-format.ts +83 -0
- package/src/commands/useCommandHotkeys.ts +114 -0
- package/src/connectivity/connectivity-indicator.tsx +249 -0
- package/src/connectivity/connectivity-provider.tsx +186 -0
- package/src/connectivity/index.ts +18 -0
- package/src/connectivity/types.ts +39 -0
- package/src/connectivity/use-connectivity.ts +25 -0
- package/src/content/article-actions.test.ts +78 -0
- package/src/content/article-actions.ts +72 -0
- package/src/content/article-card.module.css +109 -0
- package/src/content/article-card.module.css.d.ts +16 -0
- package/src/content/article-card.tsx +173 -0
- package/src/content/article-filter-bar.tsx +88 -0
- package/src/content/article-layout.module.css +131 -0
- package/src/content/article-layout.module.css.d.ts +20 -0
- package/src/content/article-layout.tsx +167 -0
- package/src/content/article-model.test.ts +119 -0
- package/src/content/article-model.ts +110 -0
- package/src/content/block-split.test.ts +75 -0
- package/src/content/block-split.ts +102 -0
- package/src/content/callout-alert.ts +88 -0
- package/src/content/callout.module.css +77 -0
- package/src/content/callout.module.css.d.ts +16 -0
- package/src/content/callout.tsx +96 -0
- package/src/content/code-block.module.css +86 -0
- package/src/content/code-block.module.css.d.ts +14 -0
- package/src/content/code-block.tsx +82 -0
- package/src/content/copy-action.tsx +79 -0
- package/src/content/fence-block.tsx +39 -0
- package/src/content/glyphs.tsx +53 -0
- package/src/content/guide.module.css +62 -0
- package/src/content/guide.module.css.d.ts +13 -0
- package/src/content/guide.tsx +174 -0
- package/src/content/heading-anchor.tsx +54 -0
- package/src/content/heading-components.tsx +62 -0
- package/src/content/highlighter.ts +123 -0
- package/src/content/index.ts +60 -0
- package/src/content/markdown-hast.ts +80 -0
- package/src/content/markdown.tsx +346 -0
- package/src/content/mdx.tsx +127 -0
- package/src/content/mermaid.module.css +20 -0
- package/src/content/mermaid.module.css.d.ts +8 -0
- package/src/content/mermaid.tsx +124 -0
- package/src/content/prose.module.css +330 -0
- package/src/content/prose.module.css.d.ts +12 -0
- package/src/content/prose.tsx +53 -0
- package/src/content/reading-progress.module.css +22 -0
- package/src/content/reading-progress.module.css.d.ts +9 -0
- package/src/content/reading-progress.tsx +67 -0
- package/src/content/slug.test.ts +62 -0
- package/src/content/slug.ts +57 -0
- package/src/content/toc.module.css +51 -0
- package/src/content/toc.module.css.d.ts +13 -0
- package/src/content/toc.tsx +226 -0
- package/src/content/url-hardening.ts +46 -0
- package/src/dashboard/delta-badge.tsx +70 -0
- package/src/dashboard/empty-state.tsx +80 -0
- package/src/dashboard/index.ts +11 -0
- package/src/dashboard/settings-section.module.css +23 -0
- package/src/dashboard/settings-section.module.css.d.ts +10 -0
- package/src/dashboard/settings-section.tsx +118 -0
- package/src/dashboard/stat-card.tsx +105 -0
- package/src/data/data-table.tsx +695 -0
- package/src/data/index.ts +37 -0
- package/src/data/table.ts +46 -0
- package/src/data/virtual-list.tsx +180 -0
- package/src/data/virtual.ts +21 -0
- package/src/forms/FormErrorSummary.tsx +64 -0
- package/src/forms/create-form.ts +57 -0
- package/src/forms/field.ts +30 -0
- package/src/forms/index.ts +26 -0
- package/src/forms/use-form-draft.ts +170 -0
- package/src/guard/check-source.test.ts +834 -0
- package/src/guard/guard-hook.test.ts +173 -0
- package/src/guard/guard-hook.ts +122 -0
- package/src/guard/index.ts +510 -0
- package/src/guard/types.ts +117 -0
- package/src/index.ts +139 -0
- package/src/motion/index.ts +26 -0
- package/src/notifications/bell.tsx +108 -0
- package/src/notifications/center.tsx +245 -0
- package/src/notifications/define-notifications.ts +162 -0
- package/src/notifications/index.ts +79 -0
- package/src/notifications/notify.tsx +260 -0
- package/src/notifications/overlay.tsx +64 -0
- package/src/notifications/store.ts +287 -0
- package/src/provider/index.tsx +234 -0
- package/src/query/devtools.tsx +38 -0
- package/src/query/index.ts +129 -0
- package/src/register.ts +158 -0
- package/src/router-tanstack/index.ts +111 -0
- package/src/router-tanstack/multi-search-param-store.test.ts +56 -0
- package/src/router-tanstack/multi-search-param-store.ts +122 -0
- package/src/router-tanstack/search-param-store.ts +125 -0
- package/src/shell/account-types.ts +119 -0
- package/src/shell/app-breadcrumbs.tsx +90 -0
- package/src/shell/app-header.module.css +73 -0
- package/src/shell/app-header.module.css.d.ts +11 -0
- package/src/shell/app-mobile-nav.module.css +100 -0
- package/src/shell/app-mobile-nav.module.css.d.ts +14 -0
- package/src/shell/app-mobile-nav.tsx +146 -0
- package/src/shell/app-sidebar-account.tsx +142 -0
- package/src/shell/app-sidebar.module.css +414 -0
- package/src/shell/app-sidebar.module.css.d.ts +34 -0
- package/src/shell/app-sidebar.tsx +632 -0
- package/src/shell/index.tsx +343 -0
- package/src/shell/page-header.tsx +35 -0
- package/src/shell/sidebar-search.module.css +62 -0
- package/src/shell/sidebar-search.module.css.d.ts +11 -0
- package/src/shell/sidebar-search.tsx +80 -0
- package/src/state.ts +246 -0
- package/src/styles.css +166 -0
- package/src/styles.floor.test.ts +36 -0
- package/src/surfaces.ts +489 -0
- package/src/theme/border-coverage.test.ts +272 -0
- package/src/theme/contrast.test.ts +306 -0
- package/src/theme/controls.module.css +143 -0
- package/src/theme/controls.module.css.d.ts +17 -0
- package/src/theme/floating.module.css +35 -0
- package/src/theme/floating.module.css.d.ts +9 -0
- package/src/theme/index.ts +933 -0
- package/src/theme/nav-link.module.css +67 -0
- package/src/theme/nav-link.module.css.d.ts +8 -0
- package/src/theme/segmented-control.module.css +14 -0
- package/src/theme/segmented-control.module.css.d.ts +8 -0
- package/src/theme/shadow-surfaces.test.ts +421 -0
- package/src/theme/timeline.module.css +29 -0
- package/src/theme/timeline.module.css.d.ts +9 -0
- package/src/theme-lab/index.tsx +359 -0
- package/src/theme-lab/theme-lab.test.ts +60 -0
- package/src/theme-toggle/index.tsx +180 -0
- package/src/tokens/index.ts +363 -0
- package/src/tokens/palette.ts +288 -0
- package/src/vite.ts +122 -0
- package/src/index.css +0 -986
- package/src/starlight.css +0 -308
- package/tailwind.config.js +0 -78
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ./guard — headless policy core. Mantine-free, dependency-free.
|
|
3
|
+
*
|
|
4
|
+
* GUARD_RULES: the closed registry of all 18 violation kinds.
|
|
5
|
+
* checkSource: pure (text, relPath, cfg) → Finding[]. No FS, no walk, no console.
|
|
6
|
+
*/
|
|
7
|
+
import type { Finding, GuardConfig, GuardKind } from './types'
|
|
8
|
+
|
|
9
|
+
export type { Finding, GuardConfig, GuardKind }
|
|
10
|
+
|
|
11
|
+
// ── Static regex consts ──────────────────────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
const HEX = /#[0-9a-fA-F]{3,8}\b/g
|
|
14
|
+
const FUNC = /\b(?:rgba?|hsla?)\(/g
|
|
15
|
+
const LOCALSTORAGE_THEME = /localStorage\s*\.\s*getItem\s*\(\s*['"]theme['"]\s*\)/g
|
|
16
|
+
|
|
17
|
+
// Ad-hoc inline surface styling — border* / borderRadius / boxShadow with literal values.
|
|
18
|
+
// A var(--…) reference inside the quoted value passes (the system itself).
|
|
19
|
+
const SURFACE_BORDER =
|
|
20
|
+
/\bborder(?:Top|Bottom|Left|Right)?\s*:\s*(?!['"`]?[^'"`]*var\()['"`][^'"`]+['"`]/g
|
|
21
|
+
const SURFACE_RADIUS = /\bborderRadius\s*:\s*(?:[0-9]+|['"`](?!\s*var\()[^'"`]*[0-9])/g
|
|
22
|
+
const SURFACE_SHADOW = /\bboxShadow\s*:\s*(?!['"`]?[^'"`]*var\()['"`][^'"`]+['"`]/g
|
|
23
|
+
|
|
24
|
+
// A `Card` / `Paper` opening tag carrying `withBorder`. Card depth is `--vx-shadow-card`, whose 1px
|
|
25
|
+
// ring lives INSIDE the shadow value; `withBorder` therefore adds a SECOND, real `border` property
|
|
26
|
+
// on top of it (the theme's `styles.root` pins bg/shadow/radius but never clears `border`), and the
|
|
27
|
+
// card reads heavy/boxed. Bounded full-text tag scan, same shape as CHART_ENTRY_POINT_TAG below, so
|
|
28
|
+
// a multi-line-formatted tag still resolves to one match.
|
|
29
|
+
//
|
|
30
|
+
// Two deliberate non-matches:
|
|
31
|
+
// • `<Card.Section withBorder>` — a section DIVIDER, not card depth. Excluded by the `(?![\w.])`
|
|
32
|
+
// lookahead, which also rejects `<CardHeader>`-style names.
|
|
33
|
+
// • `withBorder={false}` — an explicit opt-out (what the shell's AppShell parts do). Excluded by
|
|
34
|
+
// the lookahead on WITH_BORDER_PROP.
|
|
35
|
+
const CARD_SURFACE_TAG = /<(?:Card|Paper)(?![\w.])(?:=>|[^>])*?>/g
|
|
36
|
+
const WITH_BORDER_PROP = /\bwithBorder\b(?!\s*=\s*\{\s*false\s*\})/
|
|
37
|
+
|
|
38
|
+
// Raw Mantine ramp step used for surface color — gray/dark + a step digit.
|
|
39
|
+
const OFF_SYSTEM_SURFACE_VAR = /var\(--mantine-color-(gray|dark)-\d/g
|
|
40
|
+
|
|
41
|
+
// Raw lowercase JSX layout/surface element with inline style and layout/surface prop — line-scoped.
|
|
42
|
+
const RAW_HTML_TAG = /<(?:div|span|section|header|nav|footer|aside|main|article|ul|ol)\b/
|
|
43
|
+
const INLINE_STYLE = /style=\{\{/
|
|
44
|
+
const LAYOUT_SURFACE_PROP =
|
|
45
|
+
/\b(?:display|padding|margin|gap|flex|grid|border|background|width|height)\b/
|
|
46
|
+
|
|
47
|
+
// Spacing/sizing literals in inline style={{}} — anchored on property name; var() or 0 pass.
|
|
48
|
+
const INLINE_SPACING =
|
|
49
|
+
/\b(?:padding(?:Top|Bottom|Left|Right)?|margin(?:Top|Bottom|Left|Right)?|gap|rowGap|columnGap)\s*:\s*(?!var\()['"]?-?(?!0\b)\d/g
|
|
50
|
+
|
|
51
|
+
// display:flex/grid/inline-flex/inline-grid in an inline style.
|
|
52
|
+
const INLINE_DISPLAY = /\bdisplay\s*:\s*['"](?:inline-)?(?:flex|grid)['"]/g
|
|
53
|
+
|
|
54
|
+
// Raw visx axis JSX — only inside chart files, not in the Axes.tsx wrapper.
|
|
55
|
+
const RAW_VISX_AXIS = /<Axis(?:Left|Bottom|Right)\b/g
|
|
56
|
+
const AXIS_WRAPPER_FILE = /(?:^|\/)Axes\.tsx$/
|
|
57
|
+
|
|
58
|
+
// radius prop with a numeric literal (module-level so it is not re-created per call).
|
|
59
|
+
const RADIUS_PROP_RE = /\bradius=(?:\{[0-9]+\}|"[0-9]+")/g
|
|
60
|
+
|
|
61
|
+
// Hardcoded motion transition params — a duration/spring/ease literal inline in `transition={{}}`
|
|
62
|
+
// instead of the shared MOTION_DURATION / MOTION_SPRING / MOTION_EASE_STANDARD tokens.
|
|
63
|
+
const MOTION_TRANSITION_NUMERIC =
|
|
64
|
+
/\btransition\s*=\s*\{\{[^}]*\b(?:duration|stiffness|damping|mass)\s*:\s*-?\d/g
|
|
65
|
+
const MOTION_TRANSITION_EASE_ARRAY = /\btransition\s*=\s*\{\{[^}]*\bease\s*:\s*\[/g
|
|
66
|
+
|
|
67
|
+
// A hand-rolled <ChartLegend items={[ …array literal… ]}> — legend entries authored inline
|
|
68
|
+
// instead of derived (`items={deriveLegend(series)}`, a call expression, which must NOT match).
|
|
69
|
+
// Scoped to the JSX tag itself ([^>]* is bounded by the tag's own closing `>`, which also makes
|
|
70
|
+
// this a full-text scan rather than the per-line style every other kind uses — a multi-line-
|
|
71
|
+
// formatted <ChartLegend ...\n items={[...\n/> still resolves to one match). Bounded scans over
|
|
72
|
+
// text this small are not a performance concern.
|
|
73
|
+
const RAW_CHART_LEGEND_ARRAY = /<ChartLegend\b[^>]*?\bitems\s*=\s*\{\s*\[/g
|
|
74
|
+
|
|
75
|
+
// A chart entry-point JSX tag (the 7 kinds + 2 sparklines) — full opening/self-closing tag,
|
|
76
|
+
// scanned for a missing `ariaLabel` prop (an accessible text alternative for the SVG graphic).
|
|
77
|
+
// Bounded, full-text scan (like RAW_CHART_LEGEND_ARRAY above) so a multi-line-formatted tag still
|
|
78
|
+
// resolves to one match. The scan must survive two `>` decoys inside an opening tag: an explicit
|
|
79
|
+
// JSX generic argument (`<MultiLine<Point>`) — consumed by the optional `<[^<>]*>` group — and
|
|
80
|
+
// arrow functions in prop expressions (`getX={(d) => d.date}`) — consumed atomically by the `=>`
|
|
81
|
+
// alternative so their `>` never terminates the tag early. A bare `>` comparison inside a prop
|
|
82
|
+
// expression still ends the match (accepted limitation of the bounded scan).
|
|
83
|
+
const CHART_ENTRY_POINT_TAG =
|
|
84
|
+
/<(?:MultiLine|Bars|Donut|DualPanel|Heatmap|ZonedLine|StackedArea|LineSparkline|BarSparkline)\b(?:<[^<>]*>)?(?:=>|[^>])*?>/g
|
|
85
|
+
const HAS_ARIA_LABEL_PROP = /\bariaLabel\s*=/
|
|
86
|
+
|
|
87
|
+
// Raw lowercase form-control element — line-scoped, same shape as RAW_VISX_AXIS. `\b` after the
|
|
88
|
+
// tag name rejects a same-prefixed custom component (`<inputRef`, `<selectAll`).
|
|
89
|
+
const RAW_FORM_CONTROL = /<(?:input|select|textarea)\b/g
|
|
90
|
+
|
|
91
|
+
// A raw form-control's own opening tag — bounded full-text scan (same shape as CARD_SURFACE_TAG /
|
|
92
|
+
// CHART_ENTRY_POINT_TAG), used ONLY by sub-16-input-font to search the tag's own inline `style`
|
|
93
|
+
// for a sub-floor fontSize.
|
|
94
|
+
const RAW_FORM_CONTROL_TAG = /<(?:input|select|textarea)\b(?:=>|[^>])*?>/g
|
|
95
|
+
|
|
96
|
+
// A Mantine `styles={{ input: {...} }}` per-part style — the `input` key specifically targets the
|
|
97
|
+
// rendered <input>/<textarea> part of TextInput/Select/Textarea/etc. Requires `input` be the FIRST
|
|
98
|
+
// key in the styles object (see the sub-16-input-font doc comment for the scoping trade-off this
|
|
99
|
+
// implies) so an unrelated object that happens to carry an `input` key elsewhere in consumer code
|
|
100
|
+
// is never mistaken for a Mantine per-part style. `[^}]*` stops at the first `}`, i.e. the close of
|
|
101
|
+
// the `input` sub-object (or its first nested object) — either way any fontSize inside is still
|
|
102
|
+
// genuinely part of the input's own styling.
|
|
103
|
+
const STYLES_INPUT_PART = /\bstyles\s*=\s*\{\{\s*input\s*:\s*\{([^}]*)\}/g
|
|
104
|
+
|
|
105
|
+
// A fontSize/font-size value below the 16px floor. Unitless numbers and an explicit `px` suffix
|
|
106
|
+
// both count as px (React inline-style convention); any other unit (rem/em/%) is deliberately NOT
|
|
107
|
+
// matched — ambiguous relative to a *px* floor, and matching it would risk a false positive.
|
|
108
|
+
const SUB_16_FONT_SIZE = /font-?[Ss]ize\s*:\s*['"]?(-?\d+(?:\.\d+)?)(?:px)?['"]?(?=[,\s}]|$)/g
|
|
109
|
+
|
|
110
|
+
// ── Defaults ─────────────────────────────────────────────────────────────────────────────────────
|
|
111
|
+
|
|
112
|
+
/** Default spacing steps (px) flagged as raw spacing props. */
|
|
113
|
+
const DEFAULT_SPACING_STEPS: readonly number[] = [10, 12, 16, 20, 32]
|
|
114
|
+
/** Default off-identity Mantine accent families. */
|
|
115
|
+
const DEFAULT_FORBIDDEN_ACCENTS: readonly string[] = ['teal', 'violet', 'grape', 'indigo', 'pink']
|
|
116
|
+
|
|
117
|
+
/** Shared default config — CLI and tests import this to avoid duplication. */
|
|
118
|
+
export const DEFAULT_GUARD_CONFIG: GuardConfig = {
|
|
119
|
+
spacingSteps: DEFAULT_SPACING_STEPS,
|
|
120
|
+
rawRadius: true,
|
|
121
|
+
forbiddenAccents: DEFAULT_FORBIDDEN_ACCENTS,
|
|
122
|
+
rawSurface: true,
|
|
123
|
+
cardWithBorder: true,
|
|
124
|
+
offSystemSurfaceVar: true,
|
|
125
|
+
rawHtmlLayout: true,
|
|
126
|
+
inlineSpacing: true,
|
|
127
|
+
inlineDisplay: true,
|
|
128
|
+
rawVisxAxis: true,
|
|
129
|
+
rawMotionValue: true,
|
|
130
|
+
unframedChart: true,
|
|
131
|
+
chartMissingAriaLabel: true,
|
|
132
|
+
rawFormControl: true,
|
|
133
|
+
sub16InputFont: true,
|
|
134
|
+
allowComment: 'theme-allow',
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// ── Path predicate ────────────────────────────────────────────────────────────────────────────────
|
|
138
|
+
|
|
139
|
+
function isChartFile(relPath: string): boolean {
|
|
140
|
+
return relPath.includes('/charts/') && !AXIS_WRAPPER_FILE.test(relPath)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The skip policy the per-line loop applies inline, reused by the full-text tag-scoped scans
|
|
145
|
+
* (which resolve their own report line and so must re-check it): a line carrying the allow-comment,
|
|
146
|
+
* or a pure-comment line, is never a violation.
|
|
147
|
+
*/
|
|
148
|
+
function isSkippedLine(line: string, cfg: GuardConfig): boolean {
|
|
149
|
+
if (line.includes(cfg.allowComment)) return true
|
|
150
|
+
const trimmed = line.trimStart()
|
|
151
|
+
return trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*')
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// ── GUARD_RULES registry ─────────────────────────────────────────────────────────────────────────
|
|
155
|
+
|
|
156
|
+
type GuardRule = {
|
|
157
|
+
readonly kind: GuardKind
|
|
158
|
+
/** Static regex, or a builder over cfg for the 3 dynamic kinds (forbiddenAccent/spacing/radius). */
|
|
159
|
+
readonly pattern: RegExp | ((cfg: GuardConfig) => RegExp)
|
|
160
|
+
/** Path-applicability: raw-visx-axis only fires in chart files. */
|
|
161
|
+
readonly appliesTo?: (relPath: string) => boolean
|
|
162
|
+
/** Knob gating; always-on kinds omit this. */
|
|
163
|
+
readonly enabled?: (cfg: GuardConfig) => boolean
|
|
164
|
+
/** Per-kind fix-hint message. */
|
|
165
|
+
readonly message: string
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The closed registry of all 18 guard kinds. The triad test asserts
|
|
170
|
+
* `surface.guardKinds ⊆ keyof GUARD_RULES` at runtime.
|
|
171
|
+
*
|
|
172
|
+
* raw-surface, raw-html-layout, and sub-16-input-font are handled inline in checkSource
|
|
173
|
+
* (multi-regex / multi-condition / full-text tag-scoped); all other kinds map to a single pattern
|
|
174
|
+
* entry.
|
|
175
|
+
*
|
|
176
|
+
* This file and `src/cli/index.ts` are `exempt` in the package's own `basalt` config, and must
|
|
177
|
+
* stay that way: a rule's `pattern` and its `message` both spell the anti-pattern out literally
|
|
178
|
+
* (`'Raw <input>/<select>/<textarea> …'`), so the guard flags its own definitions when the package
|
|
179
|
+
* self-scans. Any kind matching a literal tag hits this — `raw-visx-axis` only escaped it by
|
|
180
|
+
* accident, via an `appliesTo` that happens to exclude non-chart files. Fixture files are already
|
|
181
|
+
* covered by the scanner's own `SKIP` (`*.test.ts`), for the same reason.
|
|
182
|
+
*/
|
|
183
|
+
export const GUARD_RULES = {
|
|
184
|
+
'raw-hex': {
|
|
185
|
+
kind: 'raw-hex',
|
|
186
|
+
pattern: HEX,
|
|
187
|
+
message: 'Route color through VX.* / the Mantine theme.',
|
|
188
|
+
},
|
|
189
|
+
'raw-color-fn': {
|
|
190
|
+
kind: 'raw-color-fn',
|
|
191
|
+
pattern: FUNC,
|
|
192
|
+
message: 'Route color through VX.* / the Mantine theme; for opacity use alpha(token, a).',
|
|
193
|
+
},
|
|
194
|
+
'localstorage-theme': {
|
|
195
|
+
kind: 'localstorage-theme',
|
|
196
|
+
pattern: LOCALSTORAGE_THEME,
|
|
197
|
+
message: 'Theme must resolve via the Mantine color scheme + --vx-* vars.',
|
|
198
|
+
},
|
|
199
|
+
'off-identity-accent': {
|
|
200
|
+
kind: 'off-identity-accent',
|
|
201
|
+
pattern: (cfg: GuardConfig) =>
|
|
202
|
+
new RegExp(
|
|
203
|
+
`\\b(?:color|c|bg|backgroundColor)\\s*=\\s*\\{?\\s*['"](${cfg.forbiddenAccents.join('|')})['"]`,
|
|
204
|
+
'g',
|
|
205
|
+
),
|
|
206
|
+
message: 'For an off-identity accent use blue/gray or a status hue (red/green/orange/yellow).',
|
|
207
|
+
},
|
|
208
|
+
'raw-spacing': {
|
|
209
|
+
kind: 'raw-spacing',
|
|
210
|
+
pattern: (cfg: GuardConfig) =>
|
|
211
|
+
new RegExp(
|
|
212
|
+
`\\b(?:p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|gap)=\\{(?:${cfg.spacingSteps.join('|')})\\}`,
|
|
213
|
+
'g',
|
|
214
|
+
),
|
|
215
|
+
message: 'Use the Mantine spacing prop/token (p/m/gap with xs..xl).',
|
|
216
|
+
},
|
|
217
|
+
'raw-radius': {
|
|
218
|
+
kind: 'raw-radius',
|
|
219
|
+
pattern: RADIUS_PROP_RE,
|
|
220
|
+
enabled: (cfg: GuardConfig) => cfg.rawRadius,
|
|
221
|
+
message: 'Use the radius token (radius="md") instead of a numeric literal.',
|
|
222
|
+
},
|
|
223
|
+
'raw-surface': {
|
|
224
|
+
kind: 'raw-surface',
|
|
225
|
+
pattern: SURFACE_BORDER, // handled inline; this entry exists so the registry is complete
|
|
226
|
+
enabled: (cfg: GuardConfig) => cfg.rawSurface,
|
|
227
|
+
message:
|
|
228
|
+
'Inline border/radius/shadow on a surface — a card already carries its depth (VX.shadowCard) and shape (var(--vx-radius-card)) from the theme; use VX.surface.* / a radius token instead.',
|
|
229
|
+
},
|
|
230
|
+
'card-with-border': {
|
|
231
|
+
kind: 'card-with-border',
|
|
232
|
+
pattern: CARD_SURFACE_TAG, // handled inline (full-text tag-scoped scan); entry keeps registry complete
|
|
233
|
+
enabled: (cfg: GuardConfig) => cfg.cardWithBorder,
|
|
234
|
+
message:
|
|
235
|
+
'withBorder on a Card/Paper double-draws the edge — card depth is --vx-shadow-card, which already bakes a 1px ring into the shadow. Drop the prop (docs/DESIGN-SPEC.md doctrine inversion #1).',
|
|
236
|
+
},
|
|
237
|
+
'off-system-surface-var': {
|
|
238
|
+
kind: 'off-system-surface-var',
|
|
239
|
+
pattern: OFF_SYSTEM_SURFACE_VAR,
|
|
240
|
+
enabled: (cfg: GuardConfig) => cfg.offSystemSurfaceVar,
|
|
241
|
+
message:
|
|
242
|
+
'Raw Mantine ramp step bypasses the basalt surface tokens — use VX.surface.* / --vx-surface-* instead.',
|
|
243
|
+
},
|
|
244
|
+
'raw-html-layout': {
|
|
245
|
+
kind: 'raw-html-layout',
|
|
246
|
+
pattern: RAW_HTML_TAG, // handled inline (3-condition conjunction); entry keeps registry complete
|
|
247
|
+
enabled: (cfg: GuardConfig) => cfg.rawHtmlLayout,
|
|
248
|
+
message:
|
|
249
|
+
'Raw HTML element with inline layout/surface styling — use a Mantine layout primitive (Box/Flex/Grid/Stack/Group).',
|
|
250
|
+
},
|
|
251
|
+
'inline-spacing': {
|
|
252
|
+
kind: 'inline-spacing',
|
|
253
|
+
pattern: INLINE_SPACING,
|
|
254
|
+
enabled: (cfg: GuardConfig) => cfg.inlineSpacing,
|
|
255
|
+
message: 'Inline spacing literal — use the Mantine spacing prop/token (p/m/gap with xs..xl).',
|
|
256
|
+
},
|
|
257
|
+
'inline-display': {
|
|
258
|
+
kind: 'inline-display',
|
|
259
|
+
pattern: INLINE_DISPLAY,
|
|
260
|
+
enabled: (cfg: GuardConfig) => cfg.inlineDisplay,
|
|
261
|
+
message: 'Use <Flex>/<Grid>/<Group> instead of an inline display:flex/grid.',
|
|
262
|
+
},
|
|
263
|
+
'raw-visx-axis': {
|
|
264
|
+
kind: 'raw-visx-axis',
|
|
265
|
+
pattern: RAW_VISX_AXIS,
|
|
266
|
+
enabled: (cfg: GuardConfig) => cfg.rawVisxAxis,
|
|
267
|
+
appliesTo: isChartFile,
|
|
268
|
+
message:
|
|
269
|
+
'Raw <AxisLeft>/<AxisBottom>/<AxisRight> in a chart file — use AxisLeftNumeric / AxisBottomDate / AxisRightNumeric.',
|
|
270
|
+
},
|
|
271
|
+
'raw-motion-value': {
|
|
272
|
+
kind: 'raw-motion-value',
|
|
273
|
+
pattern: MOTION_TRANSITION_NUMERIC, // handled inline (2-regex kind); entry keeps registry complete
|
|
274
|
+
enabled: (cfg: GuardConfig) => cfg.rawMotionValue,
|
|
275
|
+
message:
|
|
276
|
+
'Route animation timing through MOTION_DURATION / MOTION_SPRING / MOTION_EASE_STANDARD (basalt-ui motion tokens) instead of a hardcoded duration/spring/ease.',
|
|
277
|
+
},
|
|
278
|
+
'unframed-chart': {
|
|
279
|
+
kind: 'unframed-chart',
|
|
280
|
+
pattern: RAW_CHART_LEGEND_ARRAY, // handled inline (full-text tag-scoped scan); entry keeps registry complete
|
|
281
|
+
enabled: (cfg: GuardConfig) => cfg.unframedChart,
|
|
282
|
+
message:
|
|
283
|
+
'Hand-rolled ChartLegend built from an inline array literal — pass a derived legend (deriveLegend(series)), or compose ChartFrame, which derives it for you.',
|
|
284
|
+
},
|
|
285
|
+
'chart-missing-aria-label': {
|
|
286
|
+
kind: 'chart-missing-aria-label',
|
|
287
|
+
pattern: CHART_ENTRY_POINT_TAG, // handled inline (full-text tag-scoped scan); entry keeps registry complete
|
|
288
|
+
enabled: (cfg: GuardConfig) => cfg.chartMissingAriaLabel,
|
|
289
|
+
message:
|
|
290
|
+
'Chart has no accessible text alternative — pass ariaLabel="…" so screen readers get more than an unlabeled graphic.',
|
|
291
|
+
},
|
|
292
|
+
'raw-form-control': {
|
|
293
|
+
kind: 'raw-form-control',
|
|
294
|
+
pattern: RAW_FORM_CONTROL,
|
|
295
|
+
enabled: (cfg: GuardConfig) => cfg.rawFormControl,
|
|
296
|
+
message:
|
|
297
|
+
'Raw <input>/<select>/<textarea> bypasses the ENTIRE theme, not just the font-size floor — no field surface, no shadow-card depth, no focus ring, no --input-* vars. Use TextInput / NumberInput / Select / Textarea from @mantine/core, or variant="unstyled" for a genuinely borderless/bespoke look.',
|
|
298
|
+
},
|
|
299
|
+
'sub-16-input-font': {
|
|
300
|
+
kind: 'sub-16-input-font',
|
|
301
|
+
pattern: SUB_16_FONT_SIZE, // handled inline (full-text tag-scoped scan); entry keeps registry complete
|
|
302
|
+
enabled: (cfg: GuardConfig) => cfg.sub16InputFont,
|
|
303
|
+
message:
|
|
304
|
+
'fontSize below 16 on a form control is dead code — the styles.css iOS floor is `!important` and always wins. Either drop the override, or be honest about 16px in the design.',
|
|
305
|
+
},
|
|
306
|
+
} as const satisfies Record<GuardKind, GuardRule>
|
|
307
|
+
|
|
308
|
+
// ── checkSource ───────────────────────────────────────────────────────────────────────────────────
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Scan ONE file's text for theme-guard violations. Pure: same (text, relPath, cfg) → same Finding[].
|
|
312
|
+
* No FS, no walk, no console. The 3 dynamic regexes (forbiddenAccent, spacing, radius) are derived
|
|
313
|
+
* INTERNALLY from cfg. isChartFile(relPath) is applied internally so the oxlint-plugin /
|
|
314
|
+
* PreToolUse-hook adapters get correct kind-applicability for free.
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* const findings = checkSource(src, 'src/Dashboard.tsx', DEFAULT_GUARD_CONFIG)
|
|
318
|
+
* if (findings.some((f) => f.kind === 'raw-hex')) { ... }
|
|
319
|
+
*/
|
|
320
|
+
export function checkSource(text: string, relPath: string, cfg: GuardConfig): Finding[] {
|
|
321
|
+
const findings: Finding[] = []
|
|
322
|
+
|
|
323
|
+
// Derive the 3 dynamic regexes via GUARD_RULES pattern builders.
|
|
324
|
+
const forbiddenAccentRe = (
|
|
325
|
+
GUARD_RULES['off-identity-accent'].pattern as (cfg: GuardConfig) => RegExp
|
|
326
|
+
)(cfg)
|
|
327
|
+
const spacingPropRe = (GUARD_RULES['raw-spacing'].pattern as (cfg: GuardConfig) => RegExp)(cfg)
|
|
328
|
+
// raw-radius uses a static pattern (module const) — clone via source + flags to reset lastIndex.
|
|
329
|
+
const radiusPropRe = new RegExp(
|
|
330
|
+
(GUARD_RULES['raw-radius'].pattern as RegExp).source,
|
|
331
|
+
(GUARD_RULES['raw-radius'].pattern as RegExp).flags,
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
const lines = text.split('\n')
|
|
335
|
+
for (let i = 0; i < lines.length; i++) {
|
|
336
|
+
const line = lines[i] ?? ''
|
|
337
|
+
|
|
338
|
+
// Skip lines with the allow-comment or pure-comment lines.
|
|
339
|
+
if (line.includes(cfg.allowComment)) continue
|
|
340
|
+
const trimmed = line.trimStart()
|
|
341
|
+
if (trimmed.startsWith('//') || trimmed.startsWith('*') || trimmed.startsWith('/*')) continue
|
|
342
|
+
|
|
343
|
+
// Always-on kinds (raw-hex, raw-color-fn, localstorage-theme) — patterns from GUARD_RULES.
|
|
344
|
+
for (const m of line.matchAll(GUARD_RULES['raw-hex'].pattern as RegExp)) {
|
|
345
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-hex' })
|
|
346
|
+
}
|
|
347
|
+
for (const m of line.matchAll(GUARD_RULES['raw-color-fn'].pattern as RegExp)) {
|
|
348
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-color-fn' })
|
|
349
|
+
}
|
|
350
|
+
for (const m of line.matchAll(GUARD_RULES['localstorage-theme'].pattern as RegExp)) {
|
|
351
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'localstorage-theme' })
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// Dynamic-regex kinds — patterns already resolved above.
|
|
355
|
+
for (const m of line.matchAll(forbiddenAccentRe)) {
|
|
356
|
+
findings.push({ relPath, line: i + 1, token: m[1] ?? '', kind: 'off-identity-accent' })
|
|
357
|
+
}
|
|
358
|
+
for (const m of line.matchAll(spacingPropRe)) {
|
|
359
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-spacing' })
|
|
360
|
+
}
|
|
361
|
+
if (GUARD_RULES['raw-radius'].enabled!(cfg)) {
|
|
362
|
+
for (const m of line.matchAll(radiusPropRe)) {
|
|
363
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-radius' })
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// raw-surface: 3 separate regex checks, one kind — gated via GUARD_RULES entry.
|
|
368
|
+
if (GUARD_RULES['raw-surface'].enabled!(cfg)) {
|
|
369
|
+
for (const m of line.matchAll(SURFACE_BORDER)) {
|
|
370
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-surface' })
|
|
371
|
+
}
|
|
372
|
+
for (const m of line.matchAll(SURFACE_RADIUS)) {
|
|
373
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-surface' })
|
|
374
|
+
}
|
|
375
|
+
for (const m of line.matchAll(SURFACE_SHADOW)) {
|
|
376
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-surface' })
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// off-system-surface-var — pattern + gating from GUARD_RULES.
|
|
381
|
+
if (GUARD_RULES['off-system-surface-var'].enabled!(cfg)) {
|
|
382
|
+
for (const m of line.matchAll(GUARD_RULES['off-system-surface-var'].pattern as RegExp)) {
|
|
383
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'off-system-surface-var' })
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// raw-html-layout: 3-condition conjunction on the same line — gated via GUARD_RULES entry.
|
|
388
|
+
if (
|
|
389
|
+
GUARD_RULES['raw-html-layout'].enabled!(cfg) &&
|
|
390
|
+
RAW_HTML_TAG.test(line) &&
|
|
391
|
+
INLINE_STYLE.test(line) &&
|
|
392
|
+
LAYOUT_SURFACE_PROP.test(line)
|
|
393
|
+
) {
|
|
394
|
+
findings.push({ relPath, line: i + 1, token: '<raw-html style>', kind: 'raw-html-layout' })
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// inline-spacing — pattern + gating from GUARD_RULES.
|
|
398
|
+
if (GUARD_RULES['inline-spacing'].enabled!(cfg)) {
|
|
399
|
+
for (const m of line.matchAll(GUARD_RULES['inline-spacing'].pattern as RegExp)) {
|
|
400
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'inline-spacing' })
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// inline-display — pattern + gating from GUARD_RULES.
|
|
405
|
+
if (GUARD_RULES['inline-display'].enabled!(cfg)) {
|
|
406
|
+
for (const m of line.matchAll(GUARD_RULES['inline-display'].pattern as RegExp)) {
|
|
407
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'inline-display' })
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
// raw-visx-axis — pattern + gating + path applicability from GUARD_RULES.
|
|
412
|
+
if (
|
|
413
|
+
GUARD_RULES['raw-visx-axis'].enabled!(cfg) &&
|
|
414
|
+
GUARD_RULES['raw-visx-axis'].appliesTo!(relPath)
|
|
415
|
+
) {
|
|
416
|
+
for (const m of line.matchAll(GUARD_RULES['raw-visx-axis'].pattern as RegExp)) {
|
|
417
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-visx-axis' })
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// raw-motion-value: 2 separate regex checks, one kind — gated via GUARD_RULES entry.
|
|
422
|
+
if (GUARD_RULES['raw-motion-value'].enabled!(cfg)) {
|
|
423
|
+
for (const m of line.matchAll(MOTION_TRANSITION_NUMERIC)) {
|
|
424
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-motion-value' })
|
|
425
|
+
}
|
|
426
|
+
for (const m of line.matchAll(MOTION_TRANSITION_EASE_ARRAY)) {
|
|
427
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-motion-value' })
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// raw-form-control — pattern + gating from GUARD_RULES.
|
|
432
|
+
if (GUARD_RULES['raw-form-control'].enabled!(cfg)) {
|
|
433
|
+
for (const m of line.matchAll(GUARD_RULES['raw-form-control'].pattern as RegExp)) {
|
|
434
|
+
findings.push({ relPath, line: i + 1, token: m[0], kind: 'raw-form-control' })
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// unframed-chart — full-text tag-scoped scan (not per-line, see RAW_CHART_LEGEND_ARRAY comment).
|
|
440
|
+
// Reports at the line of the `items={[` token itself; honors the same theme-allow / pure-comment
|
|
441
|
+
// skip as every per-line kind by checking that reported line directly.
|
|
442
|
+
if (GUARD_RULES['unframed-chart'].enabled!(cfg)) {
|
|
443
|
+
for (const m of text.matchAll(RAW_CHART_LEGEND_ARRAY)) {
|
|
444
|
+
const lineNo = text.slice(0, (m.index ?? 0) + m[0].length).split('\n').length
|
|
445
|
+
if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
|
|
446
|
+
findings.push({ relPath, line: lineNo, token: 'items={[', kind: 'unframed-chart' })
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// chart-missing-aria-label — full-text tag-scoped scan (same shape as unframed-chart above).
|
|
451
|
+
// A tag is a violation only when its own (possibly multi-line) prop list has no `ariaLabel=`.
|
|
452
|
+
if (GUARD_RULES['chart-missing-aria-label'].enabled!(cfg)) {
|
|
453
|
+
for (const m of text.matchAll(CHART_ENTRY_POINT_TAG)) {
|
|
454
|
+
const tagText = m[0]
|
|
455
|
+
if (HAS_ARIA_LABEL_PROP.test(tagText)) continue
|
|
456
|
+
const lineNo = text.slice(0, (m.index ?? 0) + tagText.length).split('\n').length
|
|
457
|
+
if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
|
|
458
|
+
findings.push({
|
|
459
|
+
relPath,
|
|
460
|
+
line: lineNo,
|
|
461
|
+
token: tagText.slice(0, 40),
|
|
462
|
+
kind: 'chart-missing-aria-label',
|
|
463
|
+
})
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// card-with-border — full-text tag-scoped scan (same shape as the two above). Reports at the line
|
|
468
|
+
// of the `withBorder` token itself (not the end of the tag) so a multi-line-formatted Card points
|
|
469
|
+
// the fix at the prop to delete.
|
|
470
|
+
if (GUARD_RULES['card-with-border'].enabled!(cfg)) {
|
|
471
|
+
for (const m of text.matchAll(CARD_SURFACE_TAG)) {
|
|
472
|
+
const withBorder = WITH_BORDER_PROP.exec(m[0])
|
|
473
|
+
if (withBorder === null) continue
|
|
474
|
+
const lineNo = text.slice(0, (m.index ?? 0) + withBorder.index).split('\n').length
|
|
475
|
+
if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
|
|
476
|
+
findings.push({ relPath, line: lineNo, token: 'withBorder', kind: 'card-with-border' })
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// sub-16-input-font — two full-text scans (same shape as the tag-scoped scans above): (a) a raw
|
|
481
|
+
// form-control's own inline `style={{ fontSize: N }}`, (b) a Mantine `styles={{ input: { fontSize:
|
|
482
|
+
// N } }}` per-part style. Either shape is now DEAD CODE against the `!important` floor in
|
|
483
|
+
// styles.css — see the guard's doc comment for exactly which shapes this covers.
|
|
484
|
+
if (GUARD_RULES['sub-16-input-font'].enabled!(cfg)) {
|
|
485
|
+
for (const m of text.matchAll(RAW_FORM_CONTROL_TAG)) {
|
|
486
|
+
const tagText = m[0]
|
|
487
|
+
if (!INLINE_STYLE.test(tagText)) continue
|
|
488
|
+
const fontSizeMatch = [...tagText.matchAll(SUB_16_FONT_SIZE)][0]
|
|
489
|
+
if (fontSizeMatch === undefined) continue
|
|
490
|
+
const value = Number.parseFloat(fontSizeMatch[1] ?? '')
|
|
491
|
+
if (!Number.isFinite(value) || value >= 16) continue
|
|
492
|
+
const lineNo = text.slice(0, (m.index ?? 0) + tagText.length).split('\n').length
|
|
493
|
+
if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
|
|
494
|
+
findings.push({ relPath, line: lineNo, token: fontSizeMatch[0], kind: 'sub-16-input-font' })
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
for (const m of text.matchAll(STYLES_INPUT_PART)) {
|
|
498
|
+
const inputBody = m[1] ?? ''
|
|
499
|
+
const fontSizeMatch = [...inputBody.matchAll(SUB_16_FONT_SIZE)][0]
|
|
500
|
+
if (fontSizeMatch === undefined) continue
|
|
501
|
+
const value = Number.parseFloat(fontSizeMatch[1] ?? '')
|
|
502
|
+
if (!Number.isFinite(value) || value >= 16) continue
|
|
503
|
+
const lineNo = text.slice(0, (m.index ?? 0) + m[0].length).split('\n').length
|
|
504
|
+
if (isSkippedLine(lines[lineNo - 1] ?? '', cfg)) continue
|
|
505
|
+
findings.push({ relPath, line: lineNo, token: fontSizeMatch[0], kind: 'sub-16-input-font' })
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
return findings
|
|
510
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guard types — Mantine-free, dependency-free (zero imports beyond TS types).
|
|
3
|
+
*
|
|
4
|
+
* GuardKind is the closed set of 18 violation kinds the theme guard can emit.
|
|
5
|
+
* Finding is the structured result per violation, replacing the old `Violation` shape.
|
|
6
|
+
* GuardConfig is the per-run configuration that drives checkSource.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** The 18 theme-guard violation kinds. */
|
|
10
|
+
export type GuardKind =
|
|
11
|
+
| 'raw-hex'
|
|
12
|
+
| 'raw-color-fn'
|
|
13
|
+
| 'localstorage-theme'
|
|
14
|
+
| 'off-identity-accent'
|
|
15
|
+
| 'raw-spacing'
|
|
16
|
+
| 'raw-radius'
|
|
17
|
+
| 'raw-surface'
|
|
18
|
+
| 'card-with-border'
|
|
19
|
+
| 'off-system-surface-var'
|
|
20
|
+
| 'raw-html-layout'
|
|
21
|
+
| 'inline-spacing'
|
|
22
|
+
| 'inline-display'
|
|
23
|
+
| 'raw-visx-axis'
|
|
24
|
+
| 'raw-motion-value'
|
|
25
|
+
| 'unframed-chart'
|
|
26
|
+
| 'chart-missing-aria-label'
|
|
27
|
+
| 'raw-form-control'
|
|
28
|
+
| 'sub-16-input-font'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* A structured finding — the chosen testable surface (§C.4). Replaces the old `Violation` type.
|
|
32
|
+
* `relPath` + `line` + `token` + `kind` uniquely identify the violation.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const findings = checkSource(src, 'src/Dashboard.tsx', DEFAULT_GUARD_CONFIG)
|
|
36
|
+
* findings.filter((f) => f.kind === 'raw-hex')
|
|
37
|
+
*/
|
|
38
|
+
export type Finding = {
|
|
39
|
+
readonly relPath: string
|
|
40
|
+
readonly line: number
|
|
41
|
+
readonly token: string
|
|
42
|
+
readonly kind: GuardKind
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Everything a single-file scan needs — no walk, no FS. The 3 dynamic regexes (forbiddenAccent,
|
|
47
|
+
* spacingProp, radiusProp) are DERIVED inside checkSource from cfg, never passed in directly.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* const cfg: GuardConfig = { ...DEFAULT_GUARD_CONFIG, rawSurface: false }
|
|
51
|
+
* const findings = checkSource(text, 'src/Foo.tsx', cfg)
|
|
52
|
+
*/
|
|
53
|
+
export type GuardConfig = {
|
|
54
|
+
/** Named spacing-scale steps (px) flagged when used as a raw spacing prop. Default [10,12,16,20,32]. */
|
|
55
|
+
readonly spacingSteps: readonly number[]
|
|
56
|
+
/** Flag any numeric radius prop literal (radius={6}). Default true. */
|
|
57
|
+
readonly rawRadius: boolean
|
|
58
|
+
/** Off-identity Mantine accent families forbidden as chrome accents. */
|
|
59
|
+
readonly forbiddenAccents: readonly string[]
|
|
60
|
+
/** Flag ad-hoc inline surface styling (border/borderRadius/boxShadow literals). Default true. */
|
|
61
|
+
readonly rawSurface: boolean
|
|
62
|
+
/**
|
|
63
|
+
* Flag `withBorder` on a `Card` / `Paper` — card depth is `--vx-shadow-card` (a whisper shadow
|
|
64
|
+
* with the 1px ring baked into the SAME value), so `withBorder` lands a SECOND, real border on
|
|
65
|
+
* top of that ring and the card reads heavy/boxed (docs/DESIGN-SPEC.md doctrine inversion #1).
|
|
66
|
+
* `withBorder={false}` and `Card.Section withBorder` (a legitimate section divider) both pass.
|
|
67
|
+
* Default true.
|
|
68
|
+
*/
|
|
69
|
+
readonly cardWithBorder: boolean
|
|
70
|
+
/** Flag raw Mantine ramp steps used for surface color (var(--mantine-color-gray|dark-N)). Default true. */
|
|
71
|
+
readonly offSystemSurfaceVar: boolean
|
|
72
|
+
/** Flag raw lowercase JSX layout/surface elements with inline layout/surface styles. Default true. */
|
|
73
|
+
readonly rawHtmlLayout: boolean
|
|
74
|
+
/** Flag spacing/sizing literals inside an inline style={{}}. Default true. */
|
|
75
|
+
readonly inlineSpacing: boolean
|
|
76
|
+
/** Flag display:flex|grid|inline-flex|inline-grid in an inline style={{}}. Default true. */
|
|
77
|
+
readonly inlineDisplay: boolean
|
|
78
|
+
/** Flag raw <AxisLeft>/<AxisBottom>/<AxisRight> JSX inside chart files. Default true. */
|
|
79
|
+
readonly rawVisxAxis: boolean
|
|
80
|
+
/** Flag a hardcoded duration/spring/ease literal in a `transition={{...}}` prop. Default true. */
|
|
81
|
+
readonly rawMotionValue: boolean
|
|
82
|
+
/**
|
|
83
|
+
* Flag a hand-rolled `<ChartLegend items={[...]}>` array literal — legend entries must be
|
|
84
|
+
* derived (e.g. `items={deriveLegend(series)}`), never authored inline, so a bespoke chart
|
|
85
|
+
* can't silently drift from the shared legend. Default `true` (ON). Set `false` to disable the
|
|
86
|
+
* `unframed-chart` check.
|
|
87
|
+
*/
|
|
88
|
+
readonly unframedChart: boolean
|
|
89
|
+
/**
|
|
90
|
+
* Flag a chart-kind JSX usage (`<MultiLine>`, `<Bars>`, `<Donut>`, `<DualPanel>`, `<Heatmap>`,
|
|
91
|
+
* `<ZonedLine>`, `<StackedArea>`, `<LineSparkline>`, `<BarSparkline>`) missing an `ariaLabel`
|
|
92
|
+
* prop — screen readers otherwise get an unlabeled empty graphic. Default `true` (ON). Set
|
|
93
|
+
* `false` to disable the `chart-missing-aria-label` check.
|
|
94
|
+
*/
|
|
95
|
+
readonly chartMissingAriaLabel: boolean
|
|
96
|
+
/**
|
|
97
|
+
* Flag a raw lowercase `<input>` / `<select>` / `<textarea>` JSX element — it bypasses the
|
|
98
|
+
* ENTIRE theme (no field surface, no `shadow-card` depth, no focus ring, no `--input-*` vars),
|
|
99
|
+
* not just the iOS font-size floor. Use the Mantine equivalents (`TextInput`, `NumberInput`,
|
|
100
|
+
* `Select`, `Textarea`, …) — or `variant="unstyled"` for a genuinely bespoke/borderless look.
|
|
101
|
+
* Default `true` (ON). Set `false` to disable the `raw-form-control` check.
|
|
102
|
+
*/
|
|
103
|
+
readonly rawFormControl: boolean
|
|
104
|
+
/**
|
|
105
|
+
* Flag a `fontSize`/`font-size` literal below 16 inside a `style={{…}}` on a raw form control,
|
|
106
|
+
* or a `styles={{ input: {…} }}` Mantine per-part style — the `styles.css` iOS floor is
|
|
107
|
+
* `!important`, so such a declaration is now DEAD CODE that silently does nothing. Scoped to
|
|
108
|
+
* form controls only (a `<Text>`/`<span>`/chart-label `fontSize` below 16 is legitimate and
|
|
109
|
+
* never flagged). Default `true` (ON). Set `false` to disable the `sub-16-input-font` check.
|
|
110
|
+
*/
|
|
111
|
+
readonly sub16InputFont: boolean
|
|
112
|
+
/**
|
|
113
|
+
* Allow-comment policy: a line containing this substring is skipped entirely.
|
|
114
|
+
* Default 'theme-allow'. Pure-comment lines (// * /\*) are always skipped.
|
|
115
|
+
*/
|
|
116
|
+
readonly allowComment: string
|
|
117
|
+
}
|