@starci/eslint-grammar-core 0.44.0 → 0.45.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +4 -2
  3. package/dist/card-content.js +8 -19
  4. package/dist/{single-child-card.d.ts → card-is-object.d.ts} +2 -2
  5. package/dist/card-is-object.js +141 -0
  6. package/dist/choice-controls.d.ts +1 -1
  7. package/dist/choice-controls.js +5 -5
  8. package/dist/data-table-surface.d.ts +18 -0
  9. package/dist/data-table-surface.js +57 -0
  10. package/dist/index.js +4 -2
  11. package/dist/lib/why.js +25 -20
  12. package/dist/no-card-lead-description.js +3 -3
  13. package/dist/rows-in-card.d.ts +1 -1
  14. package/dist/rows-in-card.js +13 -12
  15. package/dist/surface-card-list.d.ts +1 -2
  16. package/dist/surface-card-list.js +1 -2
  17. package/dist/surface-card.d.ts +1 -1
  18. package/dist/surface-card.js +8 -63
  19. package/dist/surface-depth.js +1 -1
  20. package/dist/surface-in-surface.js +1 -1
  21. package/dist/tabs.d.ts +3 -3
  22. package/dist/tabs.js +21 -20
  23. package/docs/card-content.md +5 -6
  24. package/docs/card-is-object.md +42 -0
  25. package/docs/choice-controls.md +4 -4
  26. package/docs/data-table-surface.md +27 -0
  27. package/docs/layout-two-axis.md +3 -3
  28. package/docs/no-card-lead-description.md +2 -2
  29. package/docs/no-nested-label.md +3 -3
  30. package/docs/rows-in-card.md +5 -4
  31. package/docs/surface-card-list.md +1 -2
  32. package/docs/surface-card.md +4 -8
  33. package/docs/surface-depth.md +6 -7
  34. package/docs/surface-in-surface.md +2 -2
  35. package/docs/tabs.md +4 -4
  36. package/package.json +3 -3
  37. package/runtime/knowledge/ui/presentation/grammar-laws.yaml +32 -23
  38. package/dist/single-child-card.js +0 -90
  39. package/docs/single-child-card.md +0 -37
@@ -1,9 +1,8 @@
1
- # The one card has a kind
1
+ # A card is one object
2
2
 
3
3
  Law module: `surface-card.ts`. Catalogue: R355 FE_SURFACE_CARD_KIND, R366 FE_LABEL_IN_GRID.
4
4
 
5
- `SurfaceCard` is one component whose `kind` the compiler checks: `body` (the default), `figures`, `list`, `accordion`
6
- and `tile`; any kind may carry typed `headers` and `footers` zones. What a kind draws is not drawn by hand around it, and where the name sits follows the kind: a card that heads a section has a `label` outside the material, a tile names itself inside.
5
+ `SurfaceCard` is one component whose `kind` the compiler checks: `body` (the default) and `tile`. A card is ONE object (a customer, an agent, a plan, a message), a dialog or an overlay; a body card holds the object's name, facts and commands (`actions`). A collection stands flat in a `Section`: a list is `Section kind="list"`, figures `Section kind="figures"`, a filter or search row the `filter` of a `Section`. What a `Section` draws is not drawn by hand in a card, and where the name sits follows the kind: a body card has a `label` outside the material, a tile names itself inside.
7
6
 
8
7
  Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline. It applies to product
9
8
  source; a script or a file no slot owns is not judged.
@@ -12,11 +11,8 @@ source; a script or a file no slot owns is not judged.
12
11
 
13
12
  Finding code: `FE_SURFACE_CARD_KIND` (R355). The direct children of a `SurfaceCard` of the `body` kind (no `kind`, or
14
13
  `kind="body"`) are not a raw `ul`, `ol`, `li` or `dl`, not a `Divider`, and not a `SectionHeader` or `Heading` standing as a
15
- second title. A `Section` whose only child is one `SurfaceCard` frames one subject twice. Children are read through
14
+ second title. Children are read through
16
15
  `cond && <x/>`, `cond ? <x/> : <y/>` and `.map`.
17
- On a `SurfaceCard` or a `Board`, the `children` of a `{ kind: "custom" }` zone written in a `headers` or `footers` array literal hold no
18
- `Tabs`, `SearchField` or `Divider` (`zone`): filter and search are the typed `filter`, `search` and `toolbar` zones and the card draws
19
- its own seams. Grammar also refuses them at run time in development.
20
16
 
21
17
  **Invalid** (`src/components/blocks/Runs/component.tsx`)
22
18
 
@@ -38,7 +34,7 @@ its own seams. Grammar also refuses them at run time in development.
38
34
 
39
35
  Finding code: `FE_LABEL_IN_GRID` (R366). A `SurfaceCard` with a `label` repeated in a `Grid kind="cards"` (two or more as
40
36
  direct children, or one written in a `.map`) is refused. A peer you recognise and open is a tile, named inside beside its
41
- mark; comparing a fact across peers is one `Section kind="list"` or a `kind="table"` card.
37
+ mark; comparing a fact across peers is one `Section kind="list"` or a `Section` holding a `DataTable`.
42
38
 
43
39
  **Invalid** (`src/components/blocks/Connectors/component.tsx`)
44
40
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Law module: `surface-depth.ts`. Catalogue: R340 FE_RAISED_SURFACE_IN_SURFACE.
4
4
 
5
- A `SurfaceCard` inside another `SurfaceCard` is refused (0.37.5): a card never sits in a card. A white `Pane surface`, `Drawer`, `Dialog`, `AlertDialog` or `Popover` HOSTS cards: on a white ground a card is the group and draws a 1px border with no shadow (SURFACE-ELEVATION); on the pink well it has the shadow and no border. Development throws the card-in-card refusal from the Grammar itself; this rule is its same-file half and R356 closes it across files.
5
+ A `SurfaceCard` inside another `SurfaceCard` is refused: a card never sits in a card. A white `Pane surface`, `Drawer`, `Dialog`, `AlertDialog` or `Popover` may hold an object card, drawn as everywhere: a 1px `--border` edge and no shadow (BOUNDARY-6). Development throws the card-in-card refusal from the Grammar itself; this rule is its same-file half and R356 closes it across files.
6
6
 
7
7
  Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline. It applies to product
8
8
  source (the route, feature, component, hook, foundation, module and transport tiers and the workspace packages); a script or
@@ -10,7 +10,7 @@ a file no slot owns is not judged.
10
10
 
11
11
  ## `starci-grammar/no-raised-surface-in-surface`
12
12
 
13
- A `SurfaceCard` (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that another `SurfaceCard` of the same file encloses is a finding. A card no element of the file encloses is judged where its parent is written. The fix gives the content to the outer card's own body, or uses a kind of the outer card (`bands`, `list`, `figures`) for what needs its own faces.
13
+ A `SurfaceCard` (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that another `SurfaceCard` of the same file encloses is a finding. A card no element of the file encloses is judged where its parent is written. The fix gives the content to the outer card's own body; a list, a table or figures inside it stand flat in a `Section` (`Section kind="list"`, `Section kind="figures"`).
14
14
 
15
15
  **Invalid** (`src/components/blocks/Runs/component.tsx`)
16
16
 
@@ -23,11 +23,10 @@ A `SurfaceCard` (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that ano
23
23
  **Valid** (`src/components/blocks/Runs/component.tsx`)
24
24
 
25
25
  ```tsx
26
- <SurfaceCard
27
- kind="bands"
28
- label="Run"
29
- bands={[{ kind: "body", children: summary }, { kind: "list", items: steps, empty }]}
30
- />
26
+ <SurfaceCard label="Run">
27
+ <Text>{summary}</Text>
28
+ <Section kind="list" ariaLabel="Steps" items={steps} empty={empty} />
29
+ </SurfaceCard>
31
30
  ```
32
31
 
33
32
  **Finding code:** `FE_RAISED_SURFACE_IN_SURFACE`
@@ -2,7 +2,7 @@
2
2
 
3
3
  Law module: `surface-in-surface.ts`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#SURFACE-IN-SURFACE`. Finding code: `FE_SURFACE_IN_SURFACE`.
4
4
 
5
- Rows inside a card body, a drawer, a dialog, a pane band or a rail are a `Section kind="list"`, drawn as everywhere else: flat rows divided by hairlines, aligned with the title (LIST-ONE-LOOK). A hand-made row list is the bare form.
5
+ Rows inside a drawer, a dialog, a pane band or a rail are a `Section kind="list"`, drawn as everywhere else: flat rows divided by hairlines, aligned with the title (LIST-ONE-LOOK). A hand-made row list is the bare form.
6
6
 
7
7
  Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
8
 
@@ -22,7 +22,7 @@ A Grammar `Stack`, or a `ul`, `ol` or `div`, whose rendered children include a G
22
22
 
23
23
  ```tsx
24
24
  <Drawer title="Runs"><Section kind="list" items={runs} /></Drawer>
25
- <SurfaceCard label="Runs" headers={[{ kind: "figures", /* ... */ }]}><Section kind="list" ariaLabel="Runs" items={runs} empty={null} /></SurfaceCard>
25
+ <Stack><Section kind="figures" ariaLabel="Totals" items={totals} /><Section kind="list" title="Runs" items={runs} empty={null} /></Stack>
26
26
  ```
27
27
 
28
28
  Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
package/docs/tabs.md CHANGED
@@ -6,7 +6,7 @@ Underline tabs switch panels: the page tabs (`Page header.tabs`) and, inside a t
6
6
 
7
7
  ## `starci-grammar/tabs-switch-zone`
8
8
 
9
- Finding code: `FE_TABS_SWITCH_ZONE`. A `<Tabs appearance="primary">` written in JSX is a finding wherever it stands (a page body, under the page tabs, a pane, a drawer). The pill is drawn as the `switch` header zone of a card, which has no JSX to write, and, since 0.37.16, as the value of a row `control` (an object property named `control` in a select item or list row literal, or a JSX attribute `control={...}`, directly or through a fragment, conditional or `&&`): a row-level mode choice such as "Auto | Ask" lives in the row. The item checks (two to four options, no `count`, `href` or `isAttention`) stay in `no-primary-tabs-misuse` (R380).
9
+ Finding code: `FE_TABS_SWITCH_ZONE`. A `<Tabs appearance="primary">` written in JSX is a finding wherever it stands (a page body, under the page tabs, a pane, a drawer). The pill stands as the `action` of the block's `Section` (`action={<Tabs appearance="primary" ... />}`) and, since 0.37.16, as the value of a row `control` (an object property named `control` in a list row literal, or a JSX attribute `control={...}`, directly or through a fragment, conditional or `&&`): a row-level mode choice such as "Auto | Ask" lives in the row. The item checks (two to four options, no `count`, `href` or `isAttention`) stay in `no-primary-tabs-misuse` (R380).
10
10
 
11
11
  **Invalid**
12
12
 
@@ -19,8 +19,8 @@ Finding code: `FE_TABS_SWITCH_ZONE`. A `<Tabs appearance="primary">` written in
19
19
  **Valid**
20
20
 
21
21
  ```tsx
22
- <SurfaceCard kind="select" label="Agent" selectionMode="multiple" items={[{ id: "send", title: "Send", control: <Tabs appearance="primary" label="Send" items={modes} selectedKey={mode} onSelect={setMode} /> }]} value={value} onChange={setValue} />
23
- <SurfaceCard kind="table" label="Cash" columns={columns} headers={[{ kind: "switch", label: "Period", items: periods, selectedKey: period, onSelect: setPeriod }]} rows={rows} empty={empty} />
22
+ <Section kind="list" title="Agent" items={[{ id: "send", title: "Send", control: <Tabs appearance="primary" label="Send" items={modes} selectedKey={mode} onSelect={setMode} /> }]} empty={null} />
23
+ <Section title="Cash" action={<Tabs appearance="primary" label="Period" items={periods} selectedKey={period} onSelect={setPeriod} />}><DataTable label="Cash" columns={columns} rows={rows} renderCell={renderCell} emptyContent={empty} /></Section>
24
24
  ```
25
25
 
26
26
  ## `starci-grammar/tabs-depth`
@@ -50,7 +50,7 @@ The rule reads one file. A set whose page tabs are drawn by another file (a layo
50
50
 
51
51
  ## `starci-grammar/tabs-in-well`
52
52
 
53
- Finding code: `FE_TABS_IN_WELL`. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection` stands loose on the pink well or in a pane body: the second layer is `Page header.subTabs`. A `Tabs` stands in a header row of its own, and passes, inside a `SurfaceCard` (its header zones) or, as `kind="filter"`, in the `filter` row of a `Section` (a list's or a region's alike, 0.43.1, `contexts/ui/components/list-table.md` "Filter row"), directly or through a fragment, conditional or `&&`. A `Drawer`, `Dialog`, `Modal`, `Popover` or `Sheet` starts its own surface and ends the climb.
53
+ Finding code: `FE_TABS_IN_WELL`. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection` stands loose on the pink well or in a pane body: the second layer is `Page header.subTabs`. A `Tabs` stands in a header row of its own, and passes, as `kind="filter"`, in the `filter` row of a `Section` (a list's or a region's alike, 0.43.1, `contexts/ui/components/list-table.md` "Filter row"), directly or through a fragment, conditional or `&&`. A `Drawer`, `Dialog`, `Modal`, `Popover` or `Sheet` starts its own surface and ends the climb.
54
54
 
55
55
  **Invalid**
56
56
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-grammar-core",
3
- "version": "0.44.0",
3
+ "version": "0.45.1",
4
4
  "description": "ESLint rules for the core Grammar's component, token and composition contracts.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -68,6 +68,6 @@
68
68
  "eslint-plugin-react-hooks": "^7.1.1",
69
69
  "typescript": "^6.0.3"
70
70
  },
71
- "gitHead": "27ffff1f56448d21ffcf7595166ab3fc74c8536f",
72
- "starciSource": "36975198cdfd758aecce3eb5234f1201b939c53dbf66f46f42b8fd240c223974"
71
+ "gitHead": "49d93772597ef22ea73bece30b6258a1c94384cc",
72
+ "starciSource": "7c8c0ec8a1fd637dbda00a21e51b380738bf61ad8f8502c843ebada0ff0e8a9c"
73
73
  }
@@ -142,14 +142,14 @@ rules:
142
142
  assert: |-
143
143
  Its title is plain text; the row is the one pressable.
144
144
  - id: TABS-SWITCH-ZONE
145
- title: The pill is the switch zone of a card
145
+ title: The pill is the action of a Section
146
146
  governs: Tabs appearance="primary".
147
147
  cases:
148
148
  - id: case-1
149
149
  when: A mode or period of one block's data is switched among two to four short options
150
150
  assert: |-
151
- It is the card's `switch` header zone (`headers={[{ kind: "switch", label, items, selectedKey, onSelect }]}`),
152
- with no count and no href. A pill written in JSX in a page body, under the page tabs, in a pane or in a drawer
151
+ It is the `action` of the block's `Section` (`<Section title action={<Tabs appearance="primary" label items selectedKey onSelect />} />`),
152
+ with no count and no href; a row-level mode choice is the `control` of its row. A pill written in JSX in a page body, under the page tabs, in a pane or in a drawer
153
153
  is refused: views of a page are page tabs, views or filters inside a region are underline `Tabs`.
154
154
  - id: TABS-DEPTH
155
155
  title: A page stacks two underline layers at most
@@ -170,7 +170,7 @@ rules:
170
170
  It is `Page header.subTabs`: inside the white header band, under layer 1, on its own full-width separator, the same size as layer 1
171
171
  (14, 40 high, selected weight 500, the 2px underline exactly on the separator) and flush with the band's left inset, the same x as layer 1.
172
172
  An underline Tabs written loose in the body of a Page, Pane or PaneSection (the pink well, a pane body) is refused; one in a header row of
173
- its own, a card's header zone or, kind="filter", a Section's filter row, is not loose.
173
+ its own, kind="filter" in a Section's filter row, is not loose.
174
174
  - id: LINK-LOOK
175
175
  title: A Link is HeroUI's own link and takes its size from the line
176
176
  governs: The look of a Grammar Link.
@@ -181,14 +181,14 @@ rules:
181
181
  It is HeroUI v3's link: the primary colour, the underline on hover only, the anchor icon at the end. Its type size and leading are
182
182
  inherited (14 in a body, 12 in meta or caption text). A size prop, a size class and an underline or decoration class are refused.
183
183
  - id: ROWS-IN-CARD
184
- title: Key-value and disclosure rows stand in a card or a section
185
- governs: Key-value and disclosure rows on the well or on a white surface (a plain list of rows is LIST-ONE-LOOK).
184
+ title: Key-value and disclosure rows stand in a section or an object card
185
+ governs: Key-value and disclosure rows (a plain list of rows is LIST-ONE-LOOK).
186
186
  cases:
187
187
  - id: case-1
188
188
  when: A DescriptionList or DisclosureList is drawn
189
189
  assert: |-
190
- It stands in a Section or a SurfaceCard; in a card it takes the card's edge, a shadow and no border on the pink well, a 1px border and no
191
- shadow on a white surface (aside, pane, drawer), which Grammar draws itself. A row primitive with neither around it is refused. ListBox is a navigation list and is not read.
190
+ It stands flat in a Section (`<Section title ...><DescriptionList isDivided items={...} /></Section>`) or, as the facts of ONE object, in the body of that object's
191
+ SurfaceCard. A row primitive with neither around it is refused. ListBox is a navigation list and is not read.
192
192
  - id: CARD-NO-DESCRIPTION
193
193
  title: A card has no description
194
194
  governs: The head of a SurfaceCard and the line above it.
@@ -197,7 +197,7 @@ rules:
197
197
  when: A card is drawn with a label
198
198
  assert: |-
199
199
  The head is the label, a count chip, one fact and one end action; SurfaceCard has no description or subtitle prop. A muted Text written directly above a
200
- SurfaceCard as its description is refused: the line is a row subtitle (a select card or a Section list) or, when it explains the card's data, the card note.
200
+ SurfaceCard as its description is refused: the line is a row subtitle (a ListRow subtitle of a Section list, or an option description of a RadioGroup) or, when it explains the card's data, the card note.
201
201
  - id: LABEL-SUBLABEL-HIERARCHY
202
202
  title: One Label per section; nested groups use a Sublabel
203
203
  governs: The Label of a Section or SurfaceCard and the Sublabel of the groups inside it.
@@ -228,21 +228,20 @@ rules:
228
228
  The chip is grey; it is pink only when the number is work waiting for the owner (`isAttention`: to handle, to approve, an error). Page tabs
229
229
  (layers 1 and 2) hide the chip when the count is 0; filter tabs inside a table or list show a grey 0.
230
230
  - id: CARD-ONE-CONTENT
231
- title: One content per card, a surface on the well has a shadow and a surface on white has a border
231
+ title: One object per card; every card is white with a 1px border
232
232
  governs: A SurfaceCard's content and its edge.
233
233
  cases:
234
234
  - id: case-1
235
235
  when: A card is written
236
236
  assert: |-
237
- A card holds exactly ONE content: a list, an input group (form), a table, a graph or a figures ribbon, with its own controls (a tab, search or pagination
238
- zone, a form footer with Cancel and Save). Several groups are several cards, each with a Sublabel above it; items of the same kind stay in one list. A card
239
- inside a card is refused. A label has no description under it: the description is a caption under the card (Section caption, SurfaceCard note), and a legend
240
- (a FlowGraph's kinds) stands under the card as chips.
237
+ A card is ONE object (a customer, an agent, a plan, a message): its name, its facts and its commands (`actions`). A second list, table, form or graph is not part of it: it stands
238
+ flat in its own Section (a ribbon is `Section kind="figures"`); items of the same kind stay in one list. A card inside a card is refused. A label has no description under it:
239
+ the description is a caption under the card (Section caption, SurfaceCard note), and a legend (a FlowGraph's kinds) stands under the card as chips.
241
240
  - id: case-2
242
241
  when: A surface is painted
243
242
  assert: |-
244
- A card on the pink well has the card shadow and NO border; a surface on a white surface (a Pane surface, the aside, a Drawer, a Dialog, a Popover) has the
245
- 1px separator border and no shadow. The Grammar decides from context; an app never chooses. A FlowGraph inside a card draws no frame of its own.
243
+ Every card is white with a 1px `--border` edge, the card radius and no shadow, on every ground (the pink well, a Pane surface, the aside, a Drawer, a Dialog, a Popover). The Grammar
244
+ draws it; an app never chooses. A FlowGraph inside a card draws no frame of its own.
246
245
  - id: ICONS-OUTLINE
247
246
  title: Icons are outline only; a tile marks a standalone icon
248
247
  governs: Every icon Grammar and an app draw.
@@ -254,16 +253,26 @@ rules:
254
253
  row, a card, an empty state or a graph step gets an icon tile (a soft-tone square holding an outline icon). An icon INLINE with text (a status beside a
255
254
  label, a search field, a button start icon, a link arrow, meta) is a plain outline icon at text size with no tile. A status (done, running, failed, waiting,
256
255
  skipped) is a tone-coloured outline icon with no tile: outline check-circle in success, x-circle in danger, a spinning arrow for running.
257
- - id: SINGLE-CHILD-CARD
258
- title: A lone DataTable, chart or list is the surface, never a card
259
- governs: A SurfaceCard whose only content is a DataTable, a chart or a Section kind="list" (a key-value or choice card is valid, 0.37.8).
256
+ - id: CARD-OBJECT
257
+ title: A card is one object; a collection, a form or a placeholder stands flat
258
+ governs: A SurfaceCard of the body kind and what it holds.
260
259
  cases:
261
260
  - id: case-1
262
- when: A card has no zones (headers, footers, head actions) and holds one DataTable, chart (BarChart, ProportionBar, BubbleMap, FlowGraph, MermaidDiagram) or Section kind="list"
261
+ when: A body SurfaceCard holds ONE content and that content is a DataTable, a Section (any kind), a DescriptionList, a DisclosureList or Accordion, a Form, Fieldset or lone field, an EmptyNotice, Markdown or MarkdownArticle, or a chart (BarChart, LineChart, Sparkline, ProportionBar, BubbleMap, FlowGraph, MermaidDiagram)
263
262
  assert: |-
264
- A standalone DataTable and chart is ONE frame (border, card radius), so the card is a second frame. The title sits above as a Section head and one caption
265
- sits below (Section caption, muted sm); a list is a flat Section kind="list" that titles itself (LIST-ONE-LOOK). A card of key-value or choice rows
266
- (SurfaceCard kind="table", "select", "details", ListBox, DisclosureList, DescriptionList) is valid alone or not (0.37.8). A card groups two or more different parts (figures + list + actions), or carries zones (tabs, search, head actions).
263
+ A card is ONE object (a customer, an agent, a provider, a plan, a message, an approval), a dialog or an overlay; a collection, a form and a placeholder are never in a card.
264
+ A table is `<Section title ...><DataTable .../></Section>`, a list `Section kind="list"`, facts `<Section title ...><DescriptionList isDivided items={...} /></Section>`,
265
+ disclosures `<Section title ...><DisclosureList .../></Section>`, a form or field `<Section title ...><Form .../></Section>`, an empty state an `EmptyNotice` on its own,
266
+ markdown or a chart a `Section`. A body card with more than one content (an object's name or facts beside a control) is an object. A card with `measure="formCompact"`
267
+ (the sign-in form with no page around it) and a `kind="tile"` card are not judged.
268
+ - id: DATA-TABLE-SURFACE
269
+ title: A table has one flat look
270
+ governs: The `surface` prop of a DataTable (removed in the Grammar family 0.45.0).
271
+ cases:
272
+ - id: case-1
273
+ when: A DataTable is written with a `surface` attribute
274
+ assert: |-
275
+ The attribute is refused whatever its value and the fix removes it. A table is flat, with no frame or card of its own, under the `Section` that titles it.
267
276
  - id: NO-RAW-SCROLL
268
277
  title: Grammar never shows scrollbars
269
278
  governs: Scroll areas an app draws.
@@ -1,90 +0,0 @@
1
- import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
- import { attributeOf, elementNameOf, grammarName, hasSpread, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
3
- import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
4
- /**
5
- * The lone surface law (owner, 2026-11-09, SINGLE-CHILD-CARD; aligned 0.37.8 and 0.43.0): a card groups two or more different parts or carries zones. A card of
6
- * key-value or choice rows (`kind="table"`, `kind="select"`, `kind="details"`, a `ListBox`, `DisclosureList`, a `DescriptionList`) is valid, alone or not. What is
7
- * wrong is a card wrapping ONE leaf that stands on its own: a `DataTable` (standalone it draws its own frame), a chart, or a `Section kind="list"` (a list is flat
8
- * and never a card, LIST-ONE-LOOK). The title sits above it as a `Section` head; a list's own `title` is that head.
9
- *
10
- * WHAT IT READS. A Grammar `SurfaceCard` (imported from `@starci/grammar`) with no zones: no `headers` or `footers` prop (an empty array literal counts as none) and no
11
- * `labelEnd` (head actions). Its body is read through fragments, `cond && <x/>`, `cond ? <x/> : <y/>` and `.map`, ignoring blank text. It is refused when that body is ONE
12
- * element and that element is a `DataTable`, a chart (`BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`) or a `Section kind="list"`.
13
- *
14
- * DECIDED. Key-value and choice rows are never refused here. `Meter`, `Progress` and `ProgressCircle` are single values, not charts. `SurfaceCard kind="figures"`, `details`,
15
- * `accordion`, `table`, `select` and `tile` are not judged; `SurfaceCard kind="list"` is `surface-card-list`. Kinds, depth and nesting stay with `surface-card-kind`, `no-raised-surface-in-surface` and `surface-depth`.
16
- *
17
- * WHAT IT LEAVES ALONE. A card with two or more body children, a card with zones or `labelEnd`, a card with a JSX spread, a non-Grammar `SurfaceCard`, and non-product source.
18
- *
19
- * WHERE IT APPLIES. Product source (`isProductSource`).
20
- */
21
- /** The table, list and chart components that are a surface on their own, with the word the message names them by. */
22
- const LONE = new Map([
23
- ["DataTable", "table"],
24
- ["BarChart", "chart"],
25
- ["ProportionBar", "chart"],
26
- ["BubbleMap", "chart"],
27
- ["FlowGraph", "chart"],
28
- ["MermaidDiagram", "chart"],
29
- ]);
30
- /** True when an attribute is an empty array literal (`headers={[]}`), which zones nothing. */
31
- const isEmptyArray = (attribute) => {
32
- const value = attribute.value;
33
- return value?.type === "JSXExpressionContainer" && value.expression.type === "ArrayExpression" && value.expression.elements.length === 0;
34
- };
35
- /** True when the card carries a zone or head actions: a `headers` or `footers` prop that is not an empty array, or a `labelEnd`. */
36
- const hasZones = (opening) => {
37
- const zoned = ["headers", "footers"].some((name) => {
38
- const attribute = attributeOf(opening, name);
39
- return attribute !== undefined && !isEmptyArray(attribute);
40
- });
41
- return zoned || attributeOf(opening, "labelEnd") !== undefined;
42
- };
43
- /** What the lone child is, as the message names it (`DataTable`, `Section kind="list"`), or null when it is not a surface on its own. */
44
- const loneChild = (context, card) => {
45
- const body = renderedChildren(card.children);
46
- if (body.length !== 1)
47
- return null;
48
- const child = body[0];
49
- if (child?.type !== "JSXElement")
50
- return null;
51
- const name = elementNameOf(child);
52
- if (name === null || grammarName(context, child.openingElement) === null)
53
- return null;
54
- if (name === "Section" && stringProp(child.openingElement, "kind") === "list")
55
- return "Section kind=\"list\"";
56
- return LONE.has(name) ? name : null;
57
- };
58
- /** A table component, a chart or a list standing alone is the surface, never wrapped in a card. */
59
- export const singleChildCard = defineRule({
60
- meta: {
61
- type: "problem",
62
- docs: { description: "SINGLE-CHILD-CARD: a SurfaceCard with no zones whose only content is a DataTable, a chart or a Section kind=\"list\" is a second frame; a card of key-value or choice rows is valid." },
63
- schema: [],
64
- messages: {
65
- lone: "A {{child}} standing alone is the surface: drop the SurfaceCard, put its title in a `Section` head (`title`) and one line under it in `Section caption`. A list is a flat `Section kind=\"list\"` that titles itself. A card groups two or more different parts, or carries zones (tabs, search, head actions); a card of key-value or choice rows (`kind=\"details\"`, `\"select\"`, `\"table\"`) is valid.",
66
- },
67
- },
68
- create(context) {
69
- if (!isProductSource(context))
70
- return {};
71
- return {
72
- JSXElement(element) {
73
- const opening = element.openingElement;
74
- if (grammarName(context, opening) !== "SurfaceCard" || hasSpread(opening) || hasZones(opening))
75
- return;
76
- const child = loneChild(context, element);
77
- if (child === null)
78
- return;
79
- context.report({ node: opening, messageId: "lone", data: { child: `\`${child}\`` } });
80
- },
81
- };
82
- },
83
- });
84
- /** The rules this law contributes to the plugin. */
85
- export const rules = {
86
- "single-child-card": singleChildCard,
87
- };
88
- defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#SINGLE-CHILD-CARD");
89
- /** Every rule of this law is an error. */
90
- export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
@@ -1,37 +0,0 @@
1
- # A lone DataTable, chart or list is the surface, never a card
2
-
3
- Law module: `single-child-card.ts`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#SINGLE-CHILD-CARD`. Finding code: `FE_SINGLE_CHILD_CARD`.
4
-
5
- A card (`SurfaceCard`) groups two or more different parts (figures + list + actions), or carries zones (tabs, search, head actions). A card of key-value or choice rows (`kind="table"`, `kind="select"`, `kind="details"`, a `ListBox`, `DisclosureList`, `Timeline`, a `DescriptionList`) is valid alone or not (0.37.8). A standalone `DataTable` (`surface="card"`) or chart IS the surface: its title sits above it as a `Section` head and one line under it as `Section caption`, so a card around it is a second card. A list is a flat `Section kind="list"` that titles itself (0.43.0, LIST-ONE-LOOK), so a card around a lone list is refused the same way.
6
-
7
- Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
-
9
- ## `starci-grammar/single-child-card`
10
-
11
- A Grammar `SurfaceCard` is refused when it has no zones (no `headers` or `footers` prop, an empty array counts as none, and no `labelEnd`) and its only body child (looked through fragments, `cond && x`, `cond ? x : y` and `.map`; blank text ignored) is:
12
-
13
- - table: `DataTable`
14
- - chart: `BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`
15
- - list: `Section kind="list"`
16
-
17
- Not flagged: any key-value or choice card (`kind="table"`, `kind="select"`, `ListBox`, `DisclosureList`, `Timeline`, `DescriptionList`), a card with two or more body children, a card with zones or `labelEnd`, a card with a JSX spread, `kind` `figures`, `details`, `accordion` or `tile`, a non-Grammar `SurfaceCard`, and non-product source. `Meter` and `Progress` are single values, not charts.
18
-
19
- **Invalid**
20
-
21
- ```tsx
22
- <SurfaceCard label="Runs"><DataTable columns={columns} rows={runs} /></SurfaceCard>
23
- <SurfaceCard label="Usage"><BarChart data={usage} /></SurfaceCard>
24
- <SurfaceCard label="Runs"><Section kind="list" ariaLabel="Runs" items={runs} empty={null} /></SurfaceCard>
25
- ```
26
-
27
- **Valid**
28
-
29
- ```tsx
30
- <Section title="Runs" caption="Last 30 days"><DataTable columns={columns} rows={runs} /></Section>
31
- <Section kind="list" title="Runs" items={runs} empty={null} />
32
- <SurfaceCard label="Runs"><ListBox items={runs} /></SurfaceCard>
33
- <SurfaceCard label="Runs" headers={[{ kind: "search", /* ... */ }]}><DataTable columns={columns} rows={runs} /></SurfaceCard>
34
- <SurfaceCard label="Runs"><Text>3 failed</Text><DataTable columns={columns} rows={runs} /></SurfaceCard>
35
- ```
36
-
37
- Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).