@hirobius/design-system 0.20.0 → 0.22.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 +125 -0
- package/CHANGELOG.md +969 -0
- package/CONSUMING.md +27 -11
- package/DESIGN.md +28 -17
- package/MIGRATIONS.md +603 -0
- package/NOTICE.md +1 -1
- package/README.md +39 -5
- package/UPGRADING.md +222 -0
- package/codemods/hds-prefix.mjs +28 -13
- package/codemods/jsx-fold.mjs +28 -13
- package/codemods/lib/atomic-write.mjs +28 -0
- package/codemods/lib/installed-version.mjs +354 -0
- package/codemods/lib/project.mjs +395 -0
- package/codemods/lib/record.mjs +110 -0
- package/codemods/lib/scan.mjs +323 -0
- package/codemods/lib/semver.mjs +57 -0
- package/codemods/not-found-pattern.mjs +3 -3
- package/codemods/patterns-subpath.mjs +28 -12
- package/codemods/registry.mjs +67 -0
- package/codemods/tile-grid.mjs +3 -3
- package/codemods/upgrade.mjs +909 -0
- package/dist/chunks/empty-state-DNoThgfV.js +1227 -0
- package/dist/chunks/form-By82qZcC.js +66 -0
- package/dist/fonts/geist-mono-400.woff2 +0 -0
- package/dist/fonts/satoshi-400.woff2 +0 -0
- package/dist/fonts/satoshi-500.woff2 +0 -0
- package/dist/fonts/satoshi-700.woff2 +0 -0
- package/dist/fonts.css +53 -0
- package/dist/form.js +1 -1
- package/dist/hirobius-ui.js +876 -877
- package/dist/manifest.js +3 -3
- package/dist/patterns.js +189 -170
- package/dist/styles.css +2 -2
- package/dist/tokens.css +1 -1
- package/dist/tokens.js +136 -57
- package/dist/types/src/app/components/alert-dialog.d.ts +5 -0
- package/dist/types/src/app/components/alert.d.ts +1 -1
- package/dist/types/src/app/components/asset-img.d.ts +1 -0
- package/dist/types/src/app/components/avatar-group.d.ts +1 -0
- package/dist/types/src/app/components/avatar.d.ts +1 -1
- package/dist/types/src/app/components/badge.d.ts +2 -2
- package/dist/types/src/app/components/blockquote.d.ts +1 -0
- package/dist/types/src/app/components/breadcrumb.d.ts +1 -1
- package/dist/types/src/app/components/button.d.ts +3 -1
- package/dist/types/src/app/components/callout.d.ts +1 -1
- package/dist/types/src/app/components/card.d.ts +4 -3
- package/dist/types/src/app/components/checkbox.d.ts +1 -1
- package/dist/types/src/app/components/code-block.d.ts +1 -1
- package/dist/types/src/app/components/combobox.d.ts +1 -1
- package/dist/types/src/app/components/data-table-section.d.ts +1 -0
- package/dist/types/src/app/components/destructive-section.d.ts +1 -0
- package/dist/types/src/app/components/dialog.d.ts +2 -1
- package/dist/types/src/app/components/disclosure.d.ts +1 -1
- package/dist/types/src/app/components/divider.d.ts +1 -1
- package/dist/types/src/app/components/empty-state.d.ts +1 -1
- package/dist/types/src/app/components/error-pattern.d.ts +6 -1
- package/dist/types/src/app/components/field.d.ts +1 -1
- package/dist/types/src/app/components/form-actions.d.ts +1 -0
- package/dist/types/src/app/components/form-control.d.ts +10 -0
- package/dist/types/src/app/components/form.d.ts +1 -1
- package/dist/types/src/app/components/grid.d.ts +5 -0
- package/dist/types/src/app/components/hds-tooltip.d.ts +1 -1
- package/dist/types/src/app/components/icon.d.ts +1 -0
- package/dist/types/src/app/components/inline-link.d.ts +1 -1
- package/dist/types/src/app/components/input.d.ts +1 -1
- package/dist/types/src/app/components/kbd.d.ts +1 -0
- package/dist/types/src/app/components/menu.d.ts +1 -1
- package/dist/types/src/app/components/metadata-list.d.ts +1 -0
- package/dist/types/src/app/components/metric-tiles.d.ts +1 -0
- package/dist/types/src/app/components/pagination.d.ts +1 -1
- package/dist/types/src/app/components/popover.d.ts +1 -1
- package/dist/types/src/app/components/progress.d.ts +2 -2
- package/dist/types/src/app/components/radio.d.ts +1 -1
- package/dist/types/src/app/components/select.d.ts +1 -1
- package/dist/types/src/app/components/skeleton.d.ts +2 -2
- package/dist/types/src/app/components/slider.d.ts +1 -1
- package/dist/types/src/app/components/spinner.d.ts +1 -1
- package/dist/types/src/app/components/stat.d.ts +5 -4
- package/dist/types/src/app/components/status-list-item.d.ts +1 -1
- package/dist/types/src/app/components/status-tile.d.ts +4 -3
- package/dist/types/src/app/components/table.d.ts +6 -1
- package/dist/types/src/app/components/tabs.d.ts +1 -1
- package/dist/types/src/app/components/tag.d.ts +1 -1
- package/dist/types/src/app/components/text.d.ts +53 -6
- package/dist/types/src/app/components/textarea.d.ts +1 -1
- package/dist/types/src/app/components/timestamp.d.ts +1 -0
- package/dist/types/src/app/components/toast.d.ts +1 -1
- package/dist/types/src/app/components/toggle.d.ts +1 -1
- package/dist/types/src/app/data/manifest-types.d.ts +4 -0
- package/dist/types/src/app/design-system/generated-token-refs.d.ts +37 -28
- package/dist/types/src/app/design-system/generated-token-values.d.ts +3 -0
- package/dist/types/src/app/design-system/tokens.d.ts +117 -15
- package/dist/types/src/index.d.ts +122 -72
- package/dist/variables.css +41 -33
- package/docs/CONSUMING.md +63 -39
- package/hirobius.tokens.json +163 -112
- package/llms.txt +158 -50
- package/mcp/catalog.mjs +369 -0
- package/mcp/core-set.mjs +66 -0
- package/mcp/guide.mjs +272 -0
- package/mcp/hds-mcp.mjs +49 -0
- package/mcp/server.mjs +94 -0
- package/package.json +53 -11
- package/public/hds-manifest.json +430 -336
- package/public/llms/components.txt +4 -3
- package/public/llms/layout.txt +1 -1
- package/public/llms-full.txt +190 -70
- package/public/llms.txt +158 -50
- package/scripts/eslint-plugin-hds/index.d.mts +29 -0
- package/scripts/eslint-plugin-hds/index.mjs +55 -0
- package/scripts/eslint-plugin-hds/package.json +30 -0
- package/scripts/eslint-plugin-hds/rules/no-raw-controls.mjs +47 -0
- package/scripts/eslint-plugin-hds/rules/no-raw-hex.mjs +70 -0
- package/scripts/eslint-plugin-hds/rules/no-raw-px-spacing.mjs +125 -0
- package/scripts/eslint-plugin-hds/rules/prefer-hds-layout-primitive.mjs +54 -0
- package/scripts/eslint-plugin-hds/rules/sx-token-first.mjs +111 -0
- package/scripts/eslint-plugin-hds/rules/utils.mjs +66 -0
- package/src/app/data/component-api.json +154 -93
- package/upgrade/index.json +208 -0
- package/upgrade/releases/0.17.0.json +962 -0
- package/upgrade/releases/0.18.0.json +8 -0
- package/upgrade/releases/0.19.0.json +233 -0
- package/upgrade/releases/0.19.1.json +8 -0
- package/upgrade/releases/0.20.0.json +5108 -0
- package/upgrade/releases/0.21.0.json +538 -0
- package/upgrade/releases/0.22.0.json +94 -0
- package/upgrade/schema.json +989 -0
- package/dist/chunks/empty-state-BBqhCx0S.js +0 -1217
- package/dist/chunks/form-COP3vK9_.js +0 -66
- package/dist/types/src/app/components/status-dot.d.ts +0 -39
package/public/llms.txt
CHANGED
|
@@ -1,8 +1,67 @@
|
|
|
1
1
|
# Hirobius Design System
|
|
2
2
|
|
|
3
|
-
Generated: 2026-10-
|
|
3
|
+
Generated: 2026-10-07T16:09:09.631Z
|
|
4
4
|
Primary sources: `public/hds-manifest.json`, `src/app/data/component-api.json`, `hirobius.tokens.json`
|
|
5
5
|
|
|
6
|
+
## Agents Using The Package: Start Here
|
|
7
|
+
|
|
8
|
+
- Read `AGENTS.md` (package root, `node_modules/@hirobius/design-system/AGENTS.md`) first: which component to use for each screen need, the imports, and the rules.
|
|
9
|
+
- MCP server `hds` ships in the package: run `npx hds-mcp` (stdio). Tools: `list_core`, `search_components`, `get_component`, `search_tokens`; each answer is under 2 KB.
|
|
10
|
+
- Lint before you finish: `import hds from '@hirobius/design-system/eslint-plugin'` and spread `hds.configs.recommended` into `eslint.config.mjs`.
|
|
11
|
+
|
|
12
|
+
## Pick By Need
|
|
13
|
+
|
|
14
|
+
One answer per need. Use the components after the arrow; what follows "Not:" is what agents reached for instead, which is the wrong answer for that need even where it has a purpose of its own. Generated from `mcp/guide.mjs`, the same list as `AGENTS.md`.
|
|
15
|
+
|
|
16
|
+
- **Outermost wrapper of a screen** → `Page`, `Stack`. Not: `Container`, `Box`, a bare Stack as the root.
|
|
17
|
+
`<Page><Stack gap="spacious">…one child per section…</Stack></Page>`. `Container` is for a full-bleed surface that is not a page.
|
|
18
|
+
- **Screen title with breadcrumb, status and actions** → `PageHeader`, `Breadcrumb`, `Badge`. Not: Text as the page title, a Stack row of Text and Badge.
|
|
19
|
+
Exactly one per screen: `<PageHeader breadcrumb={<Breadcrumb items={[{ label, href }, { label }]} />} title="…" status={<Badge tone="success">Active</Badge>} />`.
|
|
20
|
+
- **Row of headline numbers (stats, KPIs, counts, totals)** → `MetricTiles`, `MetricTile`. Not: `Stat`, `StatusTile`, `CardMetric`, Card with Text.
|
|
21
|
+
`<MetricTiles><MetricTile label="Open projects" value="5" />…</MetricTiles>`; one MetricTile per number. `Stat` is for a number inside prose or a dense list, `Card.Metric` for one inside an existing `Card`, `StatusTile` for a state with notes (never a number).
|
|
22
|
+
- **Table of records with row actions** → `DataTableSection`, `Badge`, `Button`. Not: Table on its own, Card around a Table.
|
|
23
|
+
`<DataTableSection title="Projects" columns={[{ key, label }]} rows={[{ key, cells: [...], actions: <Stack direction="row" gap="tight">…</Stack> }]} />`; leave the actions column out of `columns`.
|
|
24
|
+
- **Switch between panels of related content** → `Tabs`, `TabsList`, `TabsTrigger`, `TabsContent`. Not: `SegmentedControl`, Button rows.
|
|
25
|
+
`<Tabs defaultValue="a"><TabsList><TabsTrigger value="a">A</TabsTrigger></TabsList><TabsContent value="a">…</TabsContent></Tabs>`.
|
|
26
|
+
- **Status label in a header or table cell** → `Badge`. Not: `Tag`, `Text`.
|
|
27
|
+
`<Badge tone="success|info|warning|danger|neutral|inProgress">…</Badge>`; tone is the only styling input.
|
|
28
|
+
- **Form with fields and a submit button** → `Form`, `Textarea`, `Input`, `FormActions`, `Button`. Not: a raw `<form>`, a Stack of Buttons as the footer.
|
|
29
|
+
`<Form onSubmit={…}><Textarea label="Notes" … /><FormActions primary={<Button type="submit">Save note</Button>} /></Form>`; every field takes its own `label`.
|
|
30
|
+
- **Confirm a destructive or irreversible action (delete, archive, remove)** → `AlertDialog`, `Button`. Not: `Dialog`, `window.confirm`.
|
|
31
|
+
Trigger, title, description, Cancel and Action parts: `<AlertDialog><AlertDialog.Trigger asChild><Button …>Archive</Button></AlertDialog.Trigger><AlertDialog.Content><AlertDialog.Header><AlertDialog.Title>…</AlertDialog.Title><AlertDialog.Description>…</AlertDialog.Description></AlertDialog.Header><AlertDialog.Footer><AlertDialog.Cancel asChild><Button variant="secondary">Cancel</Button></AlertDialog.Cancel><AlertDialog.Action asChild><Button tone="danger" onClick={…}>Archive</Button></AlertDialog.Action></AlertDialog.Footer></AlertDialog.Content></AlertDialog>`. Focus moves in and returns to the trigger for you.
|
|
32
|
+
- **Brief confirmation after an action (saved, archived, sent)** → `ToastProvider`, `useToast`. Not: `Badge`, `Alert`, `Text`.
|
|
33
|
+
Wrap the app root once in `<ToastProvider>`, then `toast({ title: "Note saved", tone: "success" })` from `useToast()`.
|
|
34
|
+
- **Message that stays next to its content (error, warning, info)** → `Alert`. Not: Text in a coloured Surface.
|
|
35
|
+
`<Alert tone="warning">…</Alert>`.
|
|
36
|
+
- **Button or row action** → `Button`. Not: a raw `<button>`, InlineLink for an action.
|
|
37
|
+
Row actions: `<Button variant="tertiary" size="sm" aria-label="View Brand refresh">View</Button>`; the destructive one adds `tone="danger"`.
|
|
38
|
+
- **Space between sections or items** → `Stack`, `Grid`. Not: margins on children, raw px gaps such as px8.
|
|
39
|
+
Stack `gap`: `spacious` between page sections, `normal` inside a section, `tight` between buttons. `Grid` for two-dimensional layout.
|
|
40
|
+
- **Padded background or a titled content object** → `Surface`, `Card`. Not: a Box with background and padding.
|
|
41
|
+
`Surface` for a plain padded background; `Card` only when the content has a title or can be pressed.
|
|
42
|
+
- **Progress bar or ring** → `Progress`. Not: a hand-built bar.
|
|
43
|
+
`<Progress value={60} label="Upload" />`; inside an existing `Card`, `CardProgress`.
|
|
44
|
+
- **Body copy** → `Text`. Not: Text as a section heading.
|
|
45
|
+
Section headings come from the pattern that owns the section (`PageHeader` `title`, `DataTableSection` `title`), not from extra Text.
|
|
46
|
+
- **Empty state for a list or section** → `EmptyState`. Not: Text saying "No items".
|
|
47
|
+
`DataTableSection` shows its own through `emptyTitle`; use `EmptyState` elsewhere.
|
|
48
|
+
- **The one irreversible action of a screen (delete the client, close the account)** → `DestructiveSection`. Not: a danger Button that acts without a confirm.
|
|
49
|
+
Last on the screen: `<DestructiveSection title="Delete client" description="…" actionLabel="Delete" onConfirm={…} />`; it opens its own AlertDialog. A per-row destructive action uses AlertDialog directly.
|
|
50
|
+
- **Read-only details as label and value pairs** → `MetadataList`, `Field`. Not: a Table with two columns, Text pairs in a Stack.
|
|
51
|
+
`<MetadataList items={[{ term: "Owner", description: "Ada" }]} />` for a set; `Field` for one pair.
|
|
52
|
+
- **A person, or a group of people** → `Avatar`, `AvatarGroup`. Not: an image in a rounded Box.
|
|
53
|
+
`<Avatar src alt initials />`; several in a row: `<AvatarGroup max={3}>…Avatars…</AvatarGroup>`.
|
|
54
|
+
- **A date or time** → `Timestamp`. Not: a formatted string in Text.
|
|
55
|
+
`<Timestamp date="2026-10-14" />` renders a `<time dateTime>`; a date in a table cell may stay plain text.
|
|
56
|
+
- **A keyboard key or shortcut hint** → `Kbd`. Not: `InlineCode`, Text in a Box.
|
|
57
|
+
`<Kbd>⌘K</Kbd>`.
|
|
58
|
+
- **A quotation with attribution** → `Blockquote`. Not: Callout for a quote, italic Text.
|
|
59
|
+
`<Blockquote attribution="Ada Lovelace">…</Blockquote>`.
|
|
60
|
+
- **A fixed-width side rail beside fluid content, or a row that stacks when narrow** → `Sidebar`, `Switcher`. Not: a Grid with media queries.
|
|
61
|
+
`Sidebar` (`side`, `sideWidth`) for rail + content; `Switcher` (`threshold`) for a row that flips to a column. Neither needs a media query.
|
|
62
|
+
- **Keep an element stuck while its region scrolls** → `Pin`. Not: position: sticky in style.
|
|
63
|
+
`<Pin top="…">…</Pin>` inside the scrolling region.
|
|
64
|
+
|
|
6
65
|
## System Architecture
|
|
7
66
|
|
|
8
67
|
- Engine: React + TypeScript
|
|
@@ -36,56 +95,105 @@ This file intentionally does not embed prop tables or long-form API docs.
|
|
|
36
95
|
- Detailed prop types, unions, defaults, and descriptions: read `src/app/data/component-api.json`.
|
|
37
96
|
- Runtime behavior: read the actual component source under `src/app/components/` (and associated styles).
|
|
38
97
|
|
|
98
|
+
## Core set
|
|
99
|
+
|
|
100
|
+
The 43 components of the ratified core set (hds#254, ADR-031): brand-neutral, composable, imported from the package root. Build a screen from these first. Each has `core: true` in `public/hds-manifest.json` and is marked `[core]` under "Which one when". Composed pattern modules (page shells, forms, code blocks, page sections) are imported from `@hirobius/design-system/patterns`.
|
|
101
|
+
|
|
102
|
+
- Button (Actions)
|
|
103
|
+
- Avatar (Display)
|
|
104
|
+
- Card (Display)
|
|
105
|
+
- EmptyState (Display)
|
|
106
|
+
- Field (Display)
|
|
107
|
+
- Icon (Display)
|
|
108
|
+
- Kbd (Display)
|
|
109
|
+
- Table (Display)
|
|
110
|
+
- Alert (Feedback)
|
|
111
|
+
- Badge (Feedback)
|
|
112
|
+
- Progress (Feedback)
|
|
113
|
+
- Skeleton (Feedback)
|
|
114
|
+
- Spinner (Feedback)
|
|
115
|
+
- ToastProvider (Feedback)
|
|
116
|
+
- Checkbox (Inputs)
|
|
117
|
+
- Combobox (Inputs)
|
|
118
|
+
- Input (Inputs)
|
|
119
|
+
- Radio (Inputs)
|
|
120
|
+
- SegmentedControl (Inputs)
|
|
121
|
+
- Select (Inputs)
|
|
122
|
+
- Slider (Inputs)
|
|
123
|
+
- Tag (Inputs)
|
|
124
|
+
- Textarea (Inputs)
|
|
125
|
+
- Toggle (Inputs)
|
|
126
|
+
- Box (Layout)
|
|
127
|
+
- Container (Layout)
|
|
128
|
+
- Disclosure (Layout)
|
|
129
|
+
- Divider (Layout)
|
|
130
|
+
- Grid (Layout)
|
|
131
|
+
- Stack (Layout)
|
|
132
|
+
- Surface (Layout)
|
|
133
|
+
- Breadcrumb (Navigation)
|
|
134
|
+
- InlineLink (Navigation)
|
|
135
|
+
- Pagination (Navigation)
|
|
136
|
+
- Tabs (Navigation)
|
|
137
|
+
- Dialog (Overlays)
|
|
138
|
+
- Menu (Overlays)
|
|
139
|
+
- Popover (Overlays)
|
|
140
|
+
- Tooltip (Overlays)
|
|
141
|
+
- HdsRouterProvider (Theming)
|
|
142
|
+
- HdsThemeProvider (Theming)
|
|
143
|
+
- Text (Typography)
|
|
144
|
+
- VisuallyHidden (Utility)
|
|
145
|
+
|
|
39
146
|
## Which one when
|
|
40
147
|
|
|
41
|
-
One line per component that declares when to use it (`@usage` / `@useInstead` in its JSDoc). Full detail, including `usage.whenNot`, `keyboard` and `aiRules`, is in `public/hds-manifest.json` and `src/app/data/component-api.json`.
|
|
42
|
-
|
|
43
|
-
Alert: Show a persistent inline message with a severity, next to the content it concerns. Use instead: ToastProvider, Badge
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
148
|
+
One line per component that declares when to use it (`@usage` / `@useInstead` in its JSDoc); `[core]` marks the core set. Full detail, including `usage.whenNot`, `keyboard` and `aiRules`, is in `public/hds-manifest.json` and `src/app/data/component-api.json`.
|
|
149
|
+
|
|
150
|
+
Alert: [core] Show a persistent inline message with a severity, next to the content it concerns. Use instead: ToastProvider, Badge
|
|
151
|
+
AlertDialog: Confirm a destructive or irreversible action (delete, archive, remove) before it runs, with Cancel and Action buttons. Use instead: Dialog, ToastProvider
|
|
152
|
+
Avatar: [core] Show a person or entity as an image with an initials fallback. Use instead: Icon, Badge
|
|
153
|
+
Badge: [core] Label a status, state or count with a compact neutral or semantic chip, or a dot. Use instead: Tag, Alert
|
|
154
|
+
Box: [core] Build one-off layout that no named layout primitive covers, using token keys through `sx`. Use instead: Stack, Grid, Container
|
|
155
|
+
Breadcrumb: [core] Show where the current page sits in a hierarchy and link back up it. Use instead: Tabs, Pagination
|
|
156
|
+
Button: [core] Trigger an action (submit, save, open a dialog) with a text label and optional icons; for an icon-only control pass iconOnly with iconLeft and label; for an on/off toggle pass pressed. Use instead: InlineLink
|
|
157
|
+
Card: [core] Group related content on a raised surface with header, body, footer and metric slots, or as one selectable option. Use instead: Surface, Card.Metric
|
|
158
|
+
CardMetric: Show one headline figure (a KPI, a count, a total) with its label inside a Card. Use instead: MetricTiles
|
|
159
|
+
Checkbox: [core] Let people tick one or more independent options, or a parent choice that is partly selected. Use instead: Toggle, Radio
|
|
160
|
+
Combobox: [core] Pick one value, or several with `multiple`, from a long list of options, with a search field that filters as you type. Use instead: Select, Menu
|
|
161
|
+
Container: [core] Constrain a page region to the content or maximum width and centre it. Use instead: Stack, Grid, Box
|
|
162
|
+
Dialog: [core] Interrupt the page with a modal that needs a decision or focused input before people continue. Use instead: Tooltip, Alert, ToastProvider, AlertDialog
|
|
163
|
+
Disclosure: [core] Hide optional explanatory content behind a heading that people can expand. Use instead: Tabs
|
|
164
|
+
Divider: [core] Separate two regions of content with a thin semantic rule. Use instead: Stack, Surface
|
|
165
|
+
EmptyState: [core] Say that a list, grid or section has no data yet, with a title and an optional description. Use instead: Skeleton, Alert
|
|
166
|
+
Field: [core] Show a labelled read-only value, such as a name and its value in a detail view. Use instead: Input, Card.Metric
|
|
167
|
+
Grid: [core] Lay out content in responsive columns with token-governed gaps, or align nested content with subgrid. Use instead: Stack, Box
|
|
168
|
+
HdsRouterProvider: [core] Wrap the app root once so HDS links and navigation use your client router; with no provider they stay plain anchors.
|
|
169
|
+
HdsThemeProvider: [core] Wrap an app or region once to set theme, density and other root attributes for everything inside it. Use instead: Surface
|
|
170
|
+
Icon: [core] Draw a Lucide glyph at a size and colour from the design tokens. Use instead: Button, Avatar
|
|
171
|
+
InlineLink: [core] Link to a route or external URL from inside body copy. Use instead: Button, Text
|
|
172
|
+
Input: [core] Collect a single line of text, a number, an email, a password, a date or a time, with label, helper and error slots. Use instead: Textarea, Select, Combobox
|
|
173
|
+
Kbd: [core] Show a keyboard key or shortcut hint inline, as a native kbd element. Use instead: Text
|
|
174
|
+
Menu: [core] Offer a list of actions from a trigger, closed until opened. Use instead: Select
|
|
175
|
+
Pagination: [core] Move between pages of a long result set, with truncated page numbers. Use instead: Breadcrumb
|
|
176
|
+
Popover: [core] Anchor interactive content, such as a short form, a filter set or a picker, to a trigger people click to open. Use instead: Tooltip, Menu, Dialog
|
|
177
|
+
Progress: [core] Show how far a task has got, as a bar or ring that is determinate or indeterminate. Use instead: Spinner, Skeleton
|
|
178
|
+
Radio: [core] Choose exactly one option from a small set that should stay visible together. Use instead: Checkbox, Select, SegmentedControl
|
|
179
|
+
SegmentedControl: [core] Switch between two to five mutually exclusive views or modes in a compact row. Use instead: Radio, Tabs, Select
|
|
180
|
+
Select: [core] Choose one value from a short list of options in a form field. Use instead: Menu, Combobox
|
|
181
|
+
Skeleton: [core] Reserve the shape of content that is still loading, so the layout does not jump. Use instead: Progress, Spinner
|
|
182
|
+
Slider: [core] Pick a number within a known range by dragging, when the exact value matters less than the position. Use instead: Input
|
|
183
|
+
Spinner: [core] Show that something is loading when the wait is short or has no measurable end. Use instead: Progress, Skeleton
|
|
184
|
+
Stack: [core] Space a row or column of content with token gaps and simple flex alignment. Use instead: Grid, Surface
|
|
185
|
+
Stat: Show one headline figure inline, inside prose or a dense list, with its label and an optional sub-line. Use instead: MetricTiles, Card.Metric, StatusTile
|
|
186
|
+
StatusTile: Show a titled status block with optional notes and a trailing badge or affordance. Use instead: MetricTiles, Card.Metric, StatusListItem
|
|
187
|
+
Surface: [core] Wrap content in a padded, background-bearing inset surface with no header or footer anatomy. Use instead: Card, Stack
|
|
188
|
+
Table: [core] Show rows of structured data in aligned columns, with optional sorting. Use instead: Field, Stack
|
|
189
|
+
Tabs: [core] Switch between panels of related content in the same place, one visible at a time. Use instead: SegmentedControl, Disclosure
|
|
190
|
+
Tag: [core] Show an interactive filter or category chip that people can toggle. Use instead: Badge
|
|
191
|
+
Text: [core] Set any text on the type ramp, with the element chosen by `as`. Use instead: InlineLink, Kbd
|
|
192
|
+
Textarea: [core] Collect multi-line free text such as a message, note or description. Use instead: Input
|
|
193
|
+
ToastProvider: [core] Confirm an action with a brief message that appears and dismisses itself, through useToast. Use instead: Alert, Dialog
|
|
194
|
+
Toggle: [core] Switch one setting on or off, with the effect applying immediately. Use instead: Checkbox, Radio
|
|
195
|
+
Tooltip: [core] Name an icon-only control, or add a short hint that appears on hover and keyboard focus. Use instead: Popover, Text
|
|
196
|
+
VisuallyHidden: [core] Give assistive technology a label or description that sighted people do not need to see. Use instead: Text
|
|
89
197
|
|
|
90
198
|
## Tokens (Primary Source Of Truth)
|
|
91
199
|
|
|
@@ -114,7 +222,7 @@ Canonical skeleton, outermost to innermost:
|
|
|
114
222
|
2. `Stack` (vertical rhythm between sections) or `Grid` (two-dimensional/column layout) for the structural skeleton. One section = one Section/Stack — never add a second wrapper to fake a section boundary.
|
|
115
223
|
3. Reach for a named layout primitive before hand-rolling flex/grid math for a common intent: `Stack direction="row" wrap="wrap"` (wrapping row of same-ish things), `Sidebar` (fixed-width rail + fluid content, no media query), `Switcher` (row that flips to a column below a threshold, no media query). A full-height shell with a centered main region, an aspect-ratio-locked media box or a negative margin that escapes a parent padding is a `Box` with `style` (not `sx`, which applies on the client only).
|
|
116
224
|
4. `Surface` for any background-bearing, padded wrapper (card, panel, inset). Never a raw element with backgroundColor + padding hand-rolled inline.
|
|
117
|
-
5. Use the screen patterns (`@hirobius/design-system/patterns`) for the parts every screen repeats: `PageHeader` once at the top (breadcrumb, `heading2` title, status, actions), `MetricTiles` for any row of headline numbers, `FormActions` for a form footer (primary right-most and last in DOM order, destructive on the far left), `DataTableSection` for a titled table (toolbar slot, consumer row actions, empty state, scrolls on narrow widths without a caller `minWidth`), and `DestructiveSection` last for an irreversible action (danger button, then an `AlertDialog` confirm).
|
|
225
|
+
5. Use the screen patterns (`@hirobius/design-system/patterns`) for the parts every screen repeats: `PageHeader` once at the top (breadcrumb, `heading2` title, status, actions), `MetricTiles` for any row of headline numbers, `FormActions` for a form footer (primary right-most and last in DOM order, destructive on the far left), `DataTableSection` for a titled table (toolbar slot, consumer row actions, empty state, scrolls on narrow widths without a caller `minWidth`), and `DestructiveSection` last for an irreversible action (danger button, then an `AlertDialog` confirm). A row of headline numbers is always `MetricTiles`; `Stat`, `Card.Metric` and `StatusTile` answer other needs (see "Pick By Need" in `llms.txt`). Pick between `Card` and `Surface` with the "Which one, when" table in `DESIGN.md`.
|
|
118
226
|
6. `Box` `sx` LAST — only for genuinely one-off layout that no named primitive covers. `sx` spacing/color keys MUST be HDS token keys, never raw hex/px.
|
|
119
227
|
|
|
120
228
|
Negative rules (apply everywhere, checked by `scripts/audit-tokens.mjs --full`, `check-hardcoded-spacing.mjs`, `check-hardcoded-colors.mjs`):
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for `@hirobius/design-system/eslint-plugin` (scripts/eslint-plugin-hds/index.mjs).
|
|
3
|
+
* Self-contained on purpose: the shapes are structural, so a consumer's own
|
|
4
|
+
* `eslint` types accept them without this file importing `eslint`.
|
|
5
|
+
*/
|
|
6
|
+
type RuleLevel = 'off' | 'warn' | 'error';
|
|
7
|
+
|
|
8
|
+
interface HdsPlugin {
|
|
9
|
+
meta: { name: string; version: string };
|
|
10
|
+
rules: Record<
|
|
11
|
+
| 'no-raw-controls'
|
|
12
|
+
| 'no-raw-hex'
|
|
13
|
+
| 'no-raw-px-spacing'
|
|
14
|
+
| 'prefer-hds-layout-primitive'
|
|
15
|
+
| 'sx-token-first',
|
|
16
|
+
unknown
|
|
17
|
+
>;
|
|
18
|
+
configs: {
|
|
19
|
+
/** Flat config array: spread it into eslint.config.mjs. */
|
|
20
|
+
recommended: Array<{
|
|
21
|
+
name: string;
|
|
22
|
+
plugins: { hds: HdsPlugin };
|
|
23
|
+
rules: Record<string, RuleLevel>;
|
|
24
|
+
}>;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare const plugin: HdsPlugin;
|
|
29
|
+
export default plugin;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hirobius/eslint-plugin-hds
|
|
3
|
+
*
|
|
4
|
+
* Consumer-facing ESLint plugin for apps built on @hirobius/design-system.
|
|
5
|
+
* Complements the repo-internal scripts/check-*.mjs guardrails (which only
|
|
6
|
+
* run inside this repo) by shipping the same layout/token discipline as an
|
|
7
|
+
* installable plugin for downstream consumers. See README.md for install +
|
|
8
|
+
* usage. Ships inside @hirobius/design-system as the `./eslint-plugin`
|
|
9
|
+
* subpath (`import hds from '@hirobius/design-system/eslint-plugin'`).
|
|
10
|
+
*
|
|
11
|
+
* Flat-config only (ESLint 9+) — exports a self-referencing `recommended`
|
|
12
|
+
* config array, the standard pattern for ESLint 9/10 plugins.
|
|
13
|
+
*/
|
|
14
|
+
import { readFileSync } from 'node:fs';
|
|
15
|
+
import noRawControls from './rules/no-raw-controls.mjs';
|
|
16
|
+
import noRawHex from './rules/no-raw-hex.mjs';
|
|
17
|
+
import noRawPxSpacing from './rules/no-raw-px-spacing.mjs';
|
|
18
|
+
import preferHdsLayoutPrimitive from './rules/prefer-hds-layout-primitive.mjs';
|
|
19
|
+
import sxTokenFirst from './rules/sx-token-first.mjs';
|
|
20
|
+
|
|
21
|
+
// One source for name and version: the plugin's own package.json (shipped with it).
|
|
22
|
+
const { name, version } = JSON.parse(
|
|
23
|
+
readFileSync(new URL('./package.json', import.meta.url), 'utf8'),
|
|
24
|
+
);
|
|
25
|
+
const packageMeta = { name, version };
|
|
26
|
+
|
|
27
|
+
/** @type {import('eslint').ESLint.Plugin} */
|
|
28
|
+
const plugin = {
|
|
29
|
+
meta: packageMeta,
|
|
30
|
+
rules: {
|
|
31
|
+
'no-raw-controls': noRawControls,
|
|
32
|
+
'no-raw-hex': noRawHex,
|
|
33
|
+
'no-raw-px-spacing': noRawPxSpacing,
|
|
34
|
+
'prefer-hds-layout-primitive': preferHdsLayoutPrimitive,
|
|
35
|
+
'sx-token-first': sxTokenFirst,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
plugin.configs = {
|
|
40
|
+
recommended: [
|
|
41
|
+
{
|
|
42
|
+
name: 'hds/recommended',
|
|
43
|
+
plugins: { hds: plugin },
|
|
44
|
+
rules: {
|
|
45
|
+
'hds/no-raw-controls': 'error',
|
|
46
|
+
'hds/no-raw-hex': 'error',
|
|
47
|
+
'hds/no-raw-px-spacing': 'error',
|
|
48
|
+
'hds/prefer-hds-layout-primitive': 'warn',
|
|
49
|
+
'hds/sx-token-first': 'error',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default plugin;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hirobius/eslint-plugin-hds",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Consumer ESLint plugin for the Hirobius Design System — flags raw hex/px values in style, className and Box sx, and raw HTML form controls.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.mjs",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.mjs",
|
|
9
|
+
"index.d.mts",
|
|
10
|
+
"rules",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"keywords": [
|
|
14
|
+
"eslint",
|
|
15
|
+
"eslintplugin",
|
|
16
|
+
"eslint-plugin",
|
|
17
|
+
"hirobius",
|
|
18
|
+
"design-system"
|
|
19
|
+
],
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"eslint": "^9.0.0 || ^10.0.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "pnpm --dir ../.. exec vitest run scripts/eslint-plugin-hds"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"types": "index.d.mts"
|
|
30
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hds/no-raw-controls
|
|
3
|
+
*
|
|
4
|
+
* Errors on the raw HTML form controls an HDS component replaces: <button>,
|
|
5
|
+
* <input>, <select>, <textarea> and <form>. The HDS versions carry the label,
|
|
6
|
+
* focus ring, error slot and field rhythm, so a raw element is a control that
|
|
7
|
+
* looks and behaves unlike the rest of the screen. Only lowercase intrinsic
|
|
8
|
+
* JSX names are checked; `<Button>` and `<AlertDialog.Action>` are components.
|
|
9
|
+
*/
|
|
10
|
+
const REPLACEMENT = {
|
|
11
|
+
button: 'Button',
|
|
12
|
+
input: 'Input',
|
|
13
|
+
select: 'Select',
|
|
14
|
+
textarea: 'Textarea',
|
|
15
|
+
form: 'Form',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
meta: {
|
|
20
|
+
type: 'problem',
|
|
21
|
+
docs: {
|
|
22
|
+
description:
|
|
23
|
+
'Disallow raw <button>, <input>, <select>, <textarea> and <form>; use the HDS component.',
|
|
24
|
+
recommended: true,
|
|
25
|
+
url: 'https://github.com/hirobius/hds/blob/main/scripts/eslint-plugin-hds/README.md#hdsno-raw-controls',
|
|
26
|
+
},
|
|
27
|
+
schema: [],
|
|
28
|
+
messages: {
|
|
29
|
+
rawControl:
|
|
30
|
+
'Raw <{{element}}> — use the HDS `{{component}}` instead (Form, FormActions and the field components import from @hirobius/design-system or its /patterns subpath).',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
create(context) {
|
|
34
|
+
return {
|
|
35
|
+
JSXOpeningElement(node) {
|
|
36
|
+
if (node.name.type !== 'JSXIdentifier') return;
|
|
37
|
+
const component = REPLACEMENT[node.name.name];
|
|
38
|
+
if (!component) return;
|
|
39
|
+
context.report({
|
|
40
|
+
node: node.name,
|
|
41
|
+
messageId: 'rawControl',
|
|
42
|
+
data: { element: node.name.name, component },
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hds/no-raw-hex
|
|
3
|
+
*
|
|
4
|
+
* Disallows raw hex color literals (#rgb, #rrggbb, #rrggbbaa) in a JSX
|
|
5
|
+
* `style={{ ... }}` object or a `className` string/template literal.
|
|
6
|
+
* Mirrors the intent of the internal scripts/check-hardcoded-colors.mjs
|
|
7
|
+
* gate, scoped down to the two contexts a consumer app actually authors:
|
|
8
|
+
* inline style objects and Tailwind-style arbitrary-value classNames.
|
|
9
|
+
*/
|
|
10
|
+
import { attrName, jsxObjectExpression, propName, stringLiteralValue } from './utils.mjs';
|
|
11
|
+
|
|
12
|
+
const HEX_RE = /#[0-9a-fA-F]{3,4}\b|#[0-9a-fA-F]{6}\b|#[0-9a-fA-F]{8}\b/;
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
meta: {
|
|
16
|
+
type: 'problem',
|
|
17
|
+
docs: {
|
|
18
|
+
description:
|
|
19
|
+
'Disallow raw hex color literals in style or className — use an HDS color token instead.',
|
|
20
|
+
recommended: true,
|
|
21
|
+
url: 'https://github.com/hirobius/hds/blob/main/scripts/eslint-plugin-hds/README.md#hdsno-raw-hex',
|
|
22
|
+
},
|
|
23
|
+
schema: [],
|
|
24
|
+
messages: {
|
|
25
|
+
rawHexStyle:
|
|
26
|
+
'Raw hex color "{{value}}" in style prop "{{prop}}" bypasses HDS color tokens. Use a token reference — Box sx prop color: "content.primary", or var(--semantic-color-...).',
|
|
27
|
+
rawHexClassName:
|
|
28
|
+
'Raw hex color "{{value}}" in className bypasses HDS color tokens. Use a token-backed utility class or Box sx instead of an arbitrary hex value.',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
create(context) {
|
|
32
|
+
return {
|
|
33
|
+
JSXAttribute(node) {
|
|
34
|
+
const name = attrName(node);
|
|
35
|
+
if (name === 'style') {
|
|
36
|
+
const obj = jsxObjectExpression(node.value);
|
|
37
|
+
if (!obj) return;
|
|
38
|
+
for (const prop of obj.properties) {
|
|
39
|
+
if (prop.type !== 'Property') continue;
|
|
40
|
+
const value = stringLiteralValue(prop.value);
|
|
41
|
+
if (value != null && HEX_RE.test(value)) {
|
|
42
|
+
context.report({
|
|
43
|
+
node: prop.value,
|
|
44
|
+
messageId: 'rawHexStyle',
|
|
45
|
+
data: { value, prop: propName(prop.key) ?? '?' },
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (name === 'className') {
|
|
53
|
+
let value = null;
|
|
54
|
+
if (node.value && node.value.type === 'Literal' && typeof node.value.value === 'string') {
|
|
55
|
+
value = node.value.value;
|
|
56
|
+
} else if (node.value && node.value.type === 'JSXExpressionContainer') {
|
|
57
|
+
value = stringLiteralValue(node.value.expression);
|
|
58
|
+
}
|
|
59
|
+
if (typeof value === 'string' && HEX_RE.test(value)) {
|
|
60
|
+
context.report({
|
|
61
|
+
node: node.value,
|
|
62
|
+
messageId: 'rawHexClassName',
|
|
63
|
+
data: { value: value.match(HEX_RE)[0] },
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hds/no-raw-px-spacing
|
|
3
|
+
*
|
|
4
|
+
* Disallows raw pixel strings (`'16px'`) or bare numeric literals (`16`) on
|
|
5
|
+
* margin/padding/gap family properties inside a JSX `style={{ ... }}`
|
|
6
|
+
* object. Zero is exempt (a reset has no scale to violate). Mirrors the
|
|
7
|
+
* intent of scripts/check-hardcoded-spacing.mjs for consumer app code.
|
|
8
|
+
*
|
|
9
|
+
* The fix it offers is the t-shirt scale token, and, where Box `sx` has a
|
|
10
|
+
* key for the same CSS property, that key with a step name. Box `sx` resolves
|
|
11
|
+
* step names on its spacing keys only (`mb: 'md'`); a long-hand key
|
|
12
|
+
* (`marginBottom: 'md'`) passes through as invalid CSS and renders no
|
|
13
|
+
* spacing, so the message names the shorthand, never the flagged prop.
|
|
14
|
+
*/
|
|
15
|
+
import {
|
|
16
|
+
attrName,
|
|
17
|
+
jsxObjectExpression,
|
|
18
|
+
numberLiteralValue,
|
|
19
|
+
propName,
|
|
20
|
+
stringLiteralValue,
|
|
21
|
+
} from './utils.mjs';
|
|
22
|
+
|
|
23
|
+
const SPACING_PROPS = new Set([
|
|
24
|
+
'margin',
|
|
25
|
+
'marginTop',
|
|
26
|
+
'marginBottom',
|
|
27
|
+
'marginLeft',
|
|
28
|
+
'marginRight',
|
|
29
|
+
'marginBlock',
|
|
30
|
+
'marginInline',
|
|
31
|
+
'marginBlockStart',
|
|
32
|
+
'marginBlockEnd',
|
|
33
|
+
'marginInlineStart',
|
|
34
|
+
'marginInlineEnd',
|
|
35
|
+
'padding',
|
|
36
|
+
'paddingTop',
|
|
37
|
+
'paddingBottom',
|
|
38
|
+
'paddingLeft',
|
|
39
|
+
'paddingRight',
|
|
40
|
+
'paddingBlock',
|
|
41
|
+
'paddingInline',
|
|
42
|
+
'paddingBlockStart',
|
|
43
|
+
'paddingBlockEnd',
|
|
44
|
+
'paddingInlineStart',
|
|
45
|
+
'paddingInlineEnd',
|
|
46
|
+
'gap',
|
|
47
|
+
'rowGap',
|
|
48
|
+
'columnGap',
|
|
49
|
+
]);
|
|
50
|
+
|
|
51
|
+
// Long-hand style prop → the Box sx key that sets the same CSS property and
|
|
52
|
+
// resolves t-shirt steps (src/app/components/box-sx.ts SPACING_PROP_MAP).
|
|
53
|
+
// Logical props have none: sx `mx`/`my`/`px`/`py` set physical sides, which
|
|
54
|
+
// match `*Inline`/`*Block` only in horizontal writing modes.
|
|
55
|
+
const SX_SHORTHAND = {
|
|
56
|
+
margin: 'm',
|
|
57
|
+
marginTop: 'mt',
|
|
58
|
+
marginBottom: 'mb',
|
|
59
|
+
marginLeft: 'ml',
|
|
60
|
+
marginRight: 'mr',
|
|
61
|
+
padding: 'p',
|
|
62
|
+
paddingTop: 'pt',
|
|
63
|
+
paddingBottom: 'pb',
|
|
64
|
+
paddingLeft: 'pl',
|
|
65
|
+
paddingRight: 'pr',
|
|
66
|
+
gap: 'gap',
|
|
67
|
+
rowGap: 'rowGap',
|
|
68
|
+
columnGap: 'columnGap',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const PX_STRING_RE = /^-?\d+(?:\.\d+)?px$/;
|
|
72
|
+
|
|
73
|
+
export default {
|
|
74
|
+
meta: {
|
|
75
|
+
type: 'problem',
|
|
76
|
+
docs: {
|
|
77
|
+
description:
|
|
78
|
+
'Disallow raw px strings or bare numbers on margin/padding/gap in inline style — use an HDS spacing token.',
|
|
79
|
+
recommended: true,
|
|
80
|
+
url: 'https://github.com/hirobius/hds/blob/main/scripts/eslint-plugin-hds/README.md#hdsno-raw-px-spacing',
|
|
81
|
+
},
|
|
82
|
+
schema: [],
|
|
83
|
+
messages: {
|
|
84
|
+
rawPxSpacing:
|
|
85
|
+
'Raw spacing value "{{value}}" on "{{prop}}" bypasses the HDS spacing scale. Use hds.semantic.space.scale.* (var(--semantic-space-scale-*)), or Box sx prop "{{sxProp}}" with a t-shirt step such as "md".',
|
|
86
|
+
rawPxSpacingNoSxShorthand:
|
|
87
|
+
'Raw spacing value "{{value}}" on "{{prop}}" bypasses the HDS spacing scale. Use hds.semantic.space.scale.* (var(--semantic-space-scale-*)). Box sx has no shorthand for "{{prop}}", so its t-shirt steps do not apply.',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
create(context) {
|
|
91
|
+
function report(node, prop, value) {
|
|
92
|
+
const sxProp = Object.hasOwn(SX_SHORTHAND, prop) ? SX_SHORTHAND[prop] : undefined;
|
|
93
|
+
context.report(
|
|
94
|
+
sxProp
|
|
95
|
+
? { node, messageId: 'rawPxSpacing', data: { prop, value, sxProp } }
|
|
96
|
+
: { node, messageId: 'rawPxSpacingNoSxShorthand', data: { prop, value } },
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
JSXAttribute(node) {
|
|
102
|
+
if (attrName(node) !== 'style') return;
|
|
103
|
+
const obj = jsxObjectExpression(node.value);
|
|
104
|
+
if (!obj) return;
|
|
105
|
+
|
|
106
|
+
for (const prop of obj.properties) {
|
|
107
|
+
if (prop.type !== 'Property') continue;
|
|
108
|
+
const name = propName(prop.key);
|
|
109
|
+
if (!name || !SPACING_PROPS.has(name)) continue;
|
|
110
|
+
|
|
111
|
+
const strVal = stringLiteralValue(prop.value);
|
|
112
|
+
if (strVal != null && PX_STRING_RE.test(strVal)) {
|
|
113
|
+
report(prop.value, name, strVal);
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const numVal = numberLiteralValue(prop.value);
|
|
118
|
+
if (numVal != null && numVal !== 0) {
|
|
119
|
+
report(prop.value, name, String(numVal));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
};
|