@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
@@ -2,19 +2,20 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
2
  import { grammarName } from "./lib/grammar-jsx.js";
3
3
  import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
4
4
  /**
5
- * ROWS IN A CARD (owner, 2026-11-09, ROWS-IN-CARD). A list of rows or key-value rows is always a card: on the pink well a card with a shadow and no border, on a white
6
- * surface (aside, pane, drawer) a card with a 1px border and no shadow. Grammar draws that edge itself (the SURFACE-ELEVATION rule) when the rows stand in a
7
- * `SurfaceCard` or a `Section`; a row primitive written bare on a surface is the repeated bug of a list with no edge.
5
+ * ROWS IN A SECTION OR AN OBJECT CARD (ROWS-IN-CARD). Key-value rows (`DescriptionList`) and disclosure rows (`DisclosureList`) stand in a `Section`
6
+ * (the facts or the disclosures of a collection, flat on the surface) or in the body of an object card (a `SurfaceCard` of body kind: the facts of ONE
7
+ * object beside its name or a control). A row primitive written bare, with neither around it, is the repeated bug of rows with no head and no place.
8
8
  *
9
- * WHAT IT READS. In product source, a Grammar `DescriptionList` (key-value rows) or `DisclosureList` (disclosure rows) that no `SurfaceCard`, `Section`, `DataTable`
10
- * or `Accordion` of the same file encloses. A row primitive passed as a JSX attribute value (`body={<DescriptionList/>}`) is judged where the receiving component draws it.
9
+ * WHAT IT READS. In product source, a Grammar `DescriptionList` or `DisclosureList` that no `SurfaceCard` or `Section` of the same file encloses. A row
10
+ * primitive passed as a JSX attribute value (`body={<DescriptionList/>}`) is judged where the receiving component draws it.
11
11
  *
12
12
  * WHAT IT LEAVES ALONE. `ListBox` (a selectable list pane and a menu are navigation, not rows of data: no static signal tells them apart), a row primitive another
13
- * file wraps (a file whose only job is to return the rows is flagged here: wrap it in the `Section` or card in the same file), and non-product source.
13
+ * file wraps (a file whose only job is to return the rows is flagged here: wrap it in the `Section` or the object card in the same file), and non-product source.
14
+ * A card whose ONLY content is the rows is `card-is-object`.
14
15
  */
15
16
  const ROWS = new Set(["DescriptionList", "DisclosureList"]);
16
- const CARDS = new Set(["SurfaceCard", "Section", "DataTable", "Accordion"]);
17
- /** True when the element sits inside a Grammar card of this file, or inside a JSX attribute (the receiver draws it). */
17
+ const HOSTS = new Set(["SurfaceCard", "Section"]);
18
+ /** True when the element sits inside a Grammar `Section` or `SurfaceCard` of this file, or inside a JSX attribute (the receiver draws it). */
18
19
  const isHosted = (context, opening) => {
19
20
  let previous = opening;
20
21
  for (let current = opening.parent?.parent; current !== undefined && current !== null; previous = current, current = current.parent) {
@@ -25,19 +26,19 @@ const isHosted = (context, opening) => {
25
26
  if (previous === current.openingElement)
26
27
  continue;
27
28
  const name = grammarName(context, current.openingElement);
28
- if (name !== null && CARDS.has(name))
29
+ if (name !== null && HOSTS.has(name))
29
30
  return true;
30
31
  }
31
32
  return false;
32
33
  };
33
- /** A list of rows stands in a card. */
34
+ /** Key-value and disclosure rows stand in a `Section` or in an object card. */
34
35
  export const rowsInCard = defineRule({
35
36
  meta: {
36
37
  type: "problem",
37
- docs: { description: "ROWS-IN-CARD: a DescriptionList or DisclosureList stands in a SurfaceCard or a Section, so it is a card (shadow on the well, 1px border on a white surface)." },
38
+ docs: { description: "ROWS-IN-CARD: a DescriptionList or DisclosureList stands in a Section or in the body of an object SurfaceCard." },
38
39
  schema: [],
39
40
  messages: {
40
- bare: "A `{{name}}` stands with no card around it. Key-value and disclosure rows stand in a `SurfaceCard` (Grammar draws the shadow on the pink well and the 1px border on a white aside, pane or drawer by itself) or a `Section`; a plain list of rows is `Section kind=\"list\"`, flat.",
41
+ bare: "A `{{name}}` stands with no `Section` or object card around it. Key-value and disclosure rows stand flat in a `Section` (`<Section title ...><DescriptionList isDivided items={...} /></Section>`), or, as the facts of ONE object, in the body of that object's `SurfaceCard`; a plain list of rows is `Section kind=\"list\"`.",
41
42
  },
42
43
  },
43
44
  create(context) {
@@ -9,8 +9,7 @@ import type { Rule } from "eslint";
9
9
  *
10
10
  * WHAT IT LEAVES ALONE. A `kind` that is not a literal, another source's `SurfaceCard`, and non-product source.
11
11
  *
12
- * NO AUTOFIX. The move is not one rename: `label` becomes `title`, `labelEnd` becomes `action`, the card's zones (`headers`,
13
- * `footers`) have no list form (a filter or search is the list's `filter`; figures and a list together are a body card holding both),
12
+ * NO AUTOFIX. The move is not one rename: `label` becomes `title`, `labelEnd` becomes `action`, a card's filter or search is the list's `filter`,
14
13
  * the import changes, and the look changes from a card to flat rows, which the author should see.
15
14
  */
16
15
  /** `SurfaceCard kind="list"` is refused: the list is `Section kind="list"`. */
@@ -11,8 +11,7 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
11
11
  *
12
12
  * WHAT IT LEAVES ALONE. A `kind` that is not a literal, another source's `SurfaceCard`, and non-product source.
13
13
  *
14
- * NO AUTOFIX. The move is not one rename: `label` becomes `title`, `labelEnd` becomes `action`, the card's zones (`headers`,
15
- * `footers`) have no list form (a filter or search is the list's `filter`; figures and a list together are a body card holding both),
14
+ * NO AUTOFIX. The move is not one rename: `label` becomes `title`, `labelEnd` becomes `action`, a card's filter or search is the list's `filter`,
16
15
  * the import changes, and the look changes from a card to flat rows, which the author should see.
17
16
  */
18
17
  /** `SurfaceCard kind="list"` is refused: the list is `Section kind="list"`. */
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from "eslint";
2
- /** A body card does not hold what a kind draws: hand rows, a divider, a second title; a custom zone holds none of the typed zones' parts. */
2
+ /** A body card does not hold what a `Section` draws: hand rows, a divider, a second title. */
3
3
  export declare const surfaceCardKind: Rule.RuleModule;
4
4
  /** A labelled card repeated in a card grid is a tile. */
5
5
  export declare const noLabelInGrid: Rule.RuleModule;
@@ -5,13 +5,10 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
5
5
  * The card laws (HFS R355 `FE_SURFACE_CARD_KIND`, R366 `FE_LABEL_IN_GRID`): a `SurfaceCard` is one component with a `kind`,
6
6
  * and what a kind draws is not drawn by hand around it.
7
7
  *
8
- * R355. A card of the default `body` kind holds copy and controls. It does not hold the things a kind draws for it: a
9
- * hand-built list (`ul`, `ol`, `li`), a divider, a `SectionHeader` or a `Heading` standing as a second title (the card has a
10
- * `label`). Rows are a `Section kind="list"` (a list is never a card), key figures
11
- * `kind="figures"`, bands divided by seams are the typed `headers` and `footers` zones.
12
- *
13
- * R355 (zones). A `custom` zone of a card (`headers` or `footers`) holds no `Tabs`, `SearchField` or `Divider`: filter and search are
14
- * the typed `filter`, `search` and `toolbar` zones, and the card draws its own seams.
8
+ * R355. A card of the default `body` kind holds copy and controls: one object. It does not hold the things a kind draws for it or a
9
+ * `Section` draws around a collection: a hand-built list (`ul`, `ol`, `li`), a divider, a `SectionHeader` or a `Heading` standing as a second title
10
+ * (the card has a `label`). Rows are a `Section kind="list"` (a list is never a card), key figures `Section kind="figures"`, a filter or search row
11
+ * the `filter` of a `Section`, a band of commands the card's `actions`.
15
12
  *
16
13
  * R366. A card with a `label` heads a section; a peer you recognise and open is a `kind="tile"` and names itself inside. A
17
14
  * labelled card repeated in a `Grid kind="cards"` (two or more, or one written in a `.map`) is a tile drawn with the wrong
@@ -112,49 +109,7 @@ const HAND_COMPONENTS = new Map([
112
109
  ["SectionHeader", "title"],
113
110
  ["Heading", "title"],
114
111
  ]);
115
- /** The Grammar components a `custom` zone never holds: the typed zones draw them. */
116
- const ZONE_COMPONENTS = new Set(["Tabs", "SearchField", "Divider"]);
117
- /** Every JSX element below a node, whatever holds it (an object property, a fragment, a call). */
118
- const jsxBelow = (node, seen = new Set()) => {
119
- if (typeof node !== "object" || node === null || seen.has(node))
120
- return [];
121
- seen.add(node);
122
- const found = [];
123
- if ("type" in node && node.type === "JSXElement")
124
- found.push(node);
125
- for (const [key, value] of Object.entries(node)) {
126
- if (key === "parent" || key === "loc" || key === "range")
127
- continue;
128
- if (Array.isArray(value))
129
- for (const item of value)
130
- found.push(...jsxBelow(item, seen));
131
- else
132
- found.push(...jsxBelow(value, seen));
133
- }
134
- return found;
135
- };
136
- /** The `children` of every `{ kind: "custom" }` object of a `headers` or `footers` array. */
137
- const customZoneChildren = (opening) => {
138
- const zones = [];
139
- for (const name of ["headers", "footers"]) {
140
- const value = attributeOf(opening, name)?.value;
141
- if (value === null || value === undefined || value.type !== "JSXExpressionContainer" || value.expression.type !== "ArrayExpression")
142
- continue;
143
- for (const zone of value.expression.elements) {
144
- if (zone === null || zone.type !== "ObjectExpression")
145
- continue;
146
- const props = zone.properties.filter((property) => property.type === "Property" && property.key.type === "Identifier");
147
- const kind = props.find((property) => property.key.type === "Identifier" && property.key.name === "kind");
148
- if (kind === undefined || kind.value.type !== "Literal" || kind.value.value !== "custom")
149
- continue;
150
- const children = props.find((property) => property.key.type === "Identifier" && property.key.name === "children");
151
- if (children !== undefined)
152
- zones.push(children.value);
153
- }
154
- }
155
- return zones;
156
- };
157
- /** A body card does not hold what a kind draws: hand rows, a divider, a second title; a custom zone holds none of the typed zones' parts. */
112
+ /** A body card does not hold what a `Section` draws: hand rows, a divider, a second title. */
158
113
  export const surfaceCardKind = defineRule({
159
114
  meta: {
160
115
  type: "problem",
@@ -162,9 +117,8 @@ export const surfaceCardKind = defineRule({
162
117
  schema: [],
163
118
  messages: {
164
119
  list: "`<{{element}}>` is a hand-built list in a `body` card. Rows are `<Section kind=\"list\" items={...} empty={...} />` (its `filter` holds a filter or search), which draws every row the same way, flat.",
165
- divider: "A `Divider` in a card is refused: the card draws its own seams. Bands divided by a line are the typed `headers` and `footers` zones: `<SurfaceCard headers={[{ kind: \"figures\", items }]} />`.",
166
- zone: "`<{{element}}>` stands in a `custom` zone of a card. Filter and search are the typed zones (`{ kind: \"filter\" | \"search\" | \"toolbar\" }`) and the card draws its own seams, so a `custom` zone holds no `Tabs`, `SearchField` or `Divider`.",
167
- title: "`<{{element}}>` stands as a second title inside a card. The card has a `label` (and `fact`, `labelEnd`, `note`); a sub-section of one subject is a typed header or footer zone.",
120
+ divider: "A `Divider` in a card is refused: the card draws its own seams. A band of commands at the card's foot is `actions` (`<SurfaceCard actions={<Button>Pause</Button>} />`); rows divided by a line are a flat `Section kind=\"list\"`.",
121
+ title: "`<{{element}}>` stands as a second title inside a card. The card has a `label` (and `fact`, `labelEnd`, `note`); a second subject is its own `Section` (`<Section title ...>`), flat beside the card.",
168
122
  },
169
123
  },
170
124
  create(context) {
@@ -174,15 +128,6 @@ export const surfaceCardKind = defineRule({
174
128
  JSXElement(element) {
175
129
  const opening = element.openingElement;
176
130
  const component = grammarComponent(context, opening);
177
- if (component === "SurfaceCard" || component === "Board") {
178
- for (const content of customZoneChildren(opening)) {
179
- for (const node of jsxBelow(content)) {
180
- const inner = grammarComponent(context, node.openingElement);
181
- if (inner !== null && ZONE_COMPONENTS.has(inner))
182
- context.report({ node: node.openingElement, messageId: "zone", data: { element: inner } });
183
- }
184
- }
185
- }
186
131
  if (component === "SurfaceCard" && isBodyCard(opening)) {
187
132
  for (const { node } of childElements(element)) {
188
133
  const child = node.openingElement;
@@ -209,7 +154,7 @@ export const noLabelInGrid = defineRule({
209
154
  docs: { description: "R366: a labelled SurfaceCard repeated in a Grid kind=\"cards\" is a tile: it names itself inside." },
210
155
  schema: [],
211
156
  messages: {
212
- tile: "A card with a `label` repeated in a `Grid kind=\"cards\"`: the label sits outside the material, so the grid reads as headings over boxes. A peer you recognise and open is `<SurfaceCard kind=\"tile\" name mark description badge action />`, named inside beside its mark. Comparing a fact across peers is a `Section kind=\"list\"` or a `kind=\"table\"` card.",
157
+ tile: "A card with a `label` repeated in a `Grid kind=\"cards\"`: the label sits outside the material, so the grid reads as headings over boxes. A peer you recognise and open is `<SurfaceCard kind=\"tile\" name mark description badge action />`, named inside beside its mark. Comparing a fact across peers is a `Section kind=\"list\"` or a `Section` holding a `DataTable`.",
213
158
  },
214
159
  },
215
160
  create(context) {
@@ -66,7 +66,7 @@ export const noRaisedSurfaceInSurface = defineRule({
66
66
  docs: { description: "R340: a SurfaceCard never stands inside another SurfaceCard." },
67
67
  schema: [],
68
68
  messages: {
69
- nested: "This `SurfaceCard` stands inside {{host}}: a surface never stands inside a surface (the Grammar has one depth and draws no nested edge). Give the content to the host's own body, or use a kind of the outer card (`bands`, `list`, `figures`) for what needs its own faces.",
69
+ nested: "This `SurfaceCard` stands inside {{host}}: a surface never stands inside a surface (the Grammar has one depth and draws no nested edge). Give the content to the host's own body; a list, a table or figures inside it stand flat in a `Section` (`Section kind=\"list\"`, `Section kind=\"figures\"`), never in a card of their own.",
70
70
  },
71
71
  },
72
72
  create(context) {
@@ -56,7 +56,7 @@ export const surfaceInSurface = defineRule({
56
56
  docs: { description: "SURFACE-IN-SURFACE: a row list divided by Dividers inside a card, drawer, dialog, pane band or rail is a Section kind=list." },
57
57
  schema: [],
58
58
  messages: {
59
- handMade: "This `{{element}}` is a hand-made row list inside {{host}}: its rows are divided by `Divider` elements by hand. Use `<Section kind=\"list\">` with `ListRow` rows: the Grammar draws one list wherever it stands, flat rows divided by hairlines and aligned with the title (a card around a lone list is refused by `single-child-card`).",
59
+ handMade: "This `{{element}}` is a hand-made row list inside {{host}}: its rows are divided by `Divider` elements by hand. Use `<Section kind=\"list\">` with `ListRow` rows: the Grammar draws one list wherever it stands, flat rows divided by hairlines and aligned with the title (a card around a lone list is refused by `card-is-object`).",
60
60
  },
61
61
  },
62
62
  create(context) {
package/dist/tabs.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import type { Rule } from "eslint";
2
- /** No pill in JSX: the pill is the `switch` header zone of a card, or the value of a row `control`. */
2
+ /** No pill in JSX: the pill is the `action` of a `Section`, or the value of a row `control`. */
3
3
  export declare const tabsSwitchZone: Rule.RuleModule;
4
4
  /** At most two underline layers. */
5
5
  export declare const tabsDepth: Rule.RuleModule;
6
6
  /**
7
7
  * The second tab layer stands in the white header band (owner, 2026-11-09, TABS-IN-WELL): `Page header={{ tabs, subTabs }}`, on its own
8
8
  * full-width separator, flush with the band's left inset. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection`
9
- * stands on the pink well or in a pane body, so it is a finding, unless it narrows a list from a header row of its own: a card (its header
10
- * zones) or a `Tabs kind="filter"` in a `Section`'s `filter` row (0.43.1). A drawer, dialog, modal, popover or sheet starts its own surface.
9
+ * stands on the pink well or in a pane body, so it is a finding, unless it narrows a list or a region from the header row of its own: a
10
+ * `Tabs kind="filter"` in a `Section`'s `filter` row (0.43.1). A drawer, dialog, modal, popover or sheet starts its own surface.
11
11
  */
12
12
  export declare const tabsInWell: Rule.RuleModule;
13
13
  /** The rules this law contributes to the plugin. */
package/dist/tabs.js CHANGED
@@ -4,12 +4,11 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
4
4
  * The Tabs laws (`contexts/ui/components/tabs.md`, owner-approved 2026-11-09): where the pill stands, and how many
5
5
  * underline layers a page stacks.
6
6
  *
7
- * `tabs-switch-zone`. The pill (`Tabs appearance="primary"`) is a mode or period switch of one block. The Grammar draws it
8
- * only as the `switch` header zone of a `SurfaceCard` (`headers={[{ kind: "switch", label, items, selectedKey, onSelect }]}`);
9
- * a `<Tabs appearance="primary">` written in JSX (a page body, under the page tabs, a pane, a drawer) is a finding. One
10
- * exception (0.37.16, owner 2026-11-10): a row-level mode choice ("Tu dong | Hoi" on an agent's ability row) lives in the row's
11
- * `control` slot, so a pill that is the value of a `control` (an object property named `control` in a select item or list row
12
- * literal, or a JSX attribute `control={...}`) is allowed. The item checks (two to four, no count, no href) stay in `no-primary-tabs-misuse`.
7
+ * `tabs-switch-zone`. The pill (`Tabs appearance="primary"`) is a mode or period switch of one block. It stands as the `action` of the block's
8
+ * `Section` (`<Section title action={<Tabs appearance="primary" label items selectedKey onSelect />} />`); a `<Tabs appearance="primary">` written in JSX
9
+ * anywhere else (a page body, under the page tabs, a pane, a drawer) is a finding. One more place (0.37.16, owner 2026-11-10): a row-level mode choice
10
+ * ("Tu dong | Hoi" on an agent's ability row) lives in the row's `control` slot, so a pill that is the value of a `control` (an object property named
11
+ * `control` in a list row literal, or a JSX attribute `control={...}`) is allowed. The item checks (two to four, no count, no href) stay in `no-primary-tabs-misuse`.
13
12
  *
14
13
  * `tabs-depth`. A page stacks at most two underline layers: the page tabs (`Page header.tabs`) and one region set. A `Tabs`
15
14
  * is nested in another when it stands in the panel the other selects: inside a conditional or `&&` whose test reads the
@@ -38,12 +37,14 @@ const literalOf = (attribute) => {
38
37
  const isPill = (opening) => literalOf(attributeOf(opening, "appearance")) === "primary";
39
38
  /** Whether a node is an object property whose key is `control`. */
40
39
  const isControlProperty = (node) => node.type === "Property" && !node.computed && ((node.key.type === "Identifier" && node.key.name === "control") || (node.key.type === "Literal" && node.key.value === "control"));
40
+ /** Whether a JSX attribute is the `action` of a `Section`. */
41
+ const isSectionAction = (node) => node.name.type === "JSXIdentifier" && node.name.name === "action" && node.parent.type === "JSXOpeningElement" && elementName(node.parent) === "Section";
41
42
  /**
42
- * Whether the pill stands as the value of a row `control`: climbing through fragments, expression containers, conditionals and
43
- * `&&`/`||`/`??` it reaches an object property named `control` or a JSX attribute `control={...}`. A component or element that
43
+ * Whether the pill stands in a slot made for it: climbing through fragments, expression containers, conditionals and `&&`/`||`/`??` it reaches an
44
+ * object property named `control`, a JSX attribute `control={...}` or the `action={...}` of a `Section`. A component or element that
44
45
  * merely wraps the pill is not the slot.
45
46
  */
46
- const isRowControl = (opening) => {
47
+ const isPillSlot = (opening) => {
47
48
  let child = opening.parent ?? opening;
48
49
  for (let node = child.parent; node !== undefined && node !== null; child = node, node = node.parent) {
49
50
  if (node.type === "JSXFragment" || node.type === "JSXExpressionContainer")
@@ -53,22 +54,22 @@ const isRowControl = (opening) => {
53
54
  if (node.type === "LogicalExpression" && child === node.right)
54
55
  continue;
55
56
  if (node.type === "JSXAttribute")
56
- return node.name.type === "JSXIdentifier" && node.name.name === "control";
57
+ return node.name.type === "JSXIdentifier" && (node.name.name === "control" || isSectionAction(node));
57
58
  return isControlProperty(node) && node.value === child;
58
59
  }
59
60
  return false;
60
61
  };
61
- /** No pill in JSX: the pill is the `switch` header zone of a card, or the value of a row `control`. */
62
+ /** No pill in JSX: the pill is the `action` of a `Section`, or the value of a row `control`. */
62
63
  export const tabsSwitchZone = defineRule({
63
64
  meta: {
64
65
  type: "problem",
65
66
  docs: {
66
- description: "A pill (Tabs appearance=\"primary\") stands only as the switch header zone of a SurfaceCard or as the value of a row `control`; written in JSX anywhere else it is a finding.",
67
+ description: "A pill (Tabs appearance=\"primary\") stands only as the `action` of a Section or as the value of a row `control`; written in JSX anywhere else it is a finding.",
67
68
  url: "knowledge/ui/presentation/grammar-laws.yaml#TABS-SWITCH-ZONE",
68
69
  },
69
70
  schema: [],
70
71
  messages: {
71
- pill: "A pill (`Tabs appearance=\"primary\"`) switches a mode or period of one block and is drawn only as the `switch` header zone of its card: `headers={[{ kind: \"switch\", label, items, selectedKey, onSelect }]}`, two to four short options with no count and no href. A row-level mode choice is the one other place: the row's `control` (`items={[{ id, title, control: <Tabs appearance=\"primary\" ... /> }]}`). Written here it stands loose in the page. Views of a page are page tabs (`Page header.tabs`); views or filters inside a region are underline `Tabs`.",
72
+ pill: "A pill (`Tabs appearance=\"primary\"`) switches a mode or period of one block and stands as the `action` of that block's `Section`: `<Section title ... action={<Tabs appearance=\"primary\" label items selectedKey onSelect />} />`, two to four short options with no count and no href. A row-level mode choice is the one other place: the row's `control` (`items={[{ id, title, control: <Tabs appearance=\"primary\" ... /> }]}`). Written here it stands loose in the page. Views of a page are page tabs (`Page header.tabs`); views or filters inside a region are underline `Tabs`.",
72
73
  },
73
74
  },
74
75
  create(context) {
@@ -76,7 +77,7 @@ export const tabsSwitchZone = defineRule({
76
77
  return {};
77
78
  return {
78
79
  JSXOpeningElement(opening) {
79
- if (elementName(opening) !== "Tabs" || !isPill(opening) || isRowControl(opening))
80
+ if (elementName(opening) !== "Tabs" || !isPill(opening) || isPillSlot(opening))
80
81
  return;
81
82
  context.report({ node: opening, messageId: "pill" });
82
83
  },
@@ -106,7 +107,7 @@ export const tabsDepth = defineRule({
106
107
  },
107
108
  schema: [],
108
109
  messages: {
109
- depth: "This underline `Tabs` is layer {{layers}} ({{chain}}). A page stacks at most two underline layers: the page tabs (`Page header.tabs`) and one region set inside a tab's panel. Fold the third level into a `switch` zone, a filter zone of a card, a list, or a drawer.",
110
+ depth: "This underline `Tabs` is layer {{layers}} ({{chain}}). A page stacks at most two underline layers: the page tabs (`Page header.tabs`) and one region set inside a tab's panel. Fold the third level into a pill in a `Section action`, a `Section filter` row, a list, or a drawer.",
110
111
  },
111
112
  },
112
113
  create(context) {
@@ -168,19 +169,19 @@ const isSectionFilter = (node) => node.name.type === "JSXIdentifier" && node.nam
168
169
  /**
169
170
  * The second tab layer stands in the white header band (owner, 2026-11-09, TABS-IN-WELL): `Page header={{ tabs, subTabs }}`, on its own
170
171
  * full-width separator, flush with the band's left inset. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection`
171
- * stands on the pink well or in a pane body, so it is a finding, unless it narrows a list from a header row of its own: a card (its header
172
- * zones) or a `Tabs kind="filter"` in a `Section`'s `filter` row (0.43.1). A drawer, dialog, modal, popover or sheet starts its own surface.
172
+ * stands on the pink well or in a pane body, so it is a finding, unless it narrows a list or a region from the header row of its own: a
173
+ * `Tabs kind="filter"` in a `Section`'s `filter` row (0.43.1). A drawer, dialog, modal, popover or sheet starts its own surface.
173
174
  */
174
175
  export const tabsInWell = defineRule({
175
176
  meta: {
176
177
  type: "problem",
177
178
  docs: {
178
- description: "An underline Tabs stands in the white header band (Page header.subTabs), a card's header zone or, kind=\"filter\", a Section's filter row; never loose in the pink well or a pane body.",
179
+ description: "An underline Tabs stands in the white header band (Page header.subTabs) or, kind=\"filter\", a Section's filter row; never loose in the pink well or a pane body.",
179
180
  url: "knowledge/ui/presentation/grammar-laws.yaml#TABS-IN-WELL",
180
181
  },
181
182
  schema: [],
182
183
  messages: {
183
- well: "This underline `Tabs` stands in the body of a `{{host}}`, on the pink well or in a pane. The second tab layer sits in the white header band under the page tabs: `Page header` with `subTabs`, on its own full-width separator and flush with the band left inset. Move it to `header.subTabs`, make the views a `switch` zone or a filter zone of a card, or, to narrow a list, pass it as `Tabs kind=\"filter\"` in the `filter` row of its `Section`.",
184
+ well: "This underline `Tabs` stands in the body of a `{{host}}`, on the pink well or in a pane. The second tab layer sits in the white header band under the page tabs: `Page header` with `subTabs`, on its own full-width separator and flush with the band left inset. Move it to `header.subTabs`, or, to narrow a list or a region, pass it as `Tabs kind=\"filter\"` in the `filter` row of its `Section`.",
184
185
  },
185
186
  },
186
187
  create(context) {
@@ -200,7 +201,7 @@ export const tabsInWell = defineRule({
200
201
  const name = elementName(node.openingElement);
201
202
  if (name === null)
202
203
  continue;
203
- if (SURFACE_BOUNDARIES.has(name) || name === "SurfaceCard")
204
+ if (SURFACE_BOUNDARIES.has(name))
204
205
  return;
205
206
  if (WELL_HOSTS.has(name) && node.children.includes(child)) {
206
207
  context.report({ node: opening, messageId: "well", data: { host: name } });
@@ -1,15 +1,14 @@
1
- # One content per card
1
+ # One object per card
2
2
 
3
3
  Law module: `card-content.ts`. Finding codes: `FE_CARD_ONE_CONTENT`, `FE_NO_LABEL_DESCRIPTION`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#CARD-ONE-CONTENT`.
4
4
 
5
- A `SurfaceCard` holds exactly ONE content: a list, an input group (a form), a table, a graph or a figures ribbon, with its own controls (a tab, search or pagination 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 inside a card is `no-raised-surface-in-surface` (R340). A label has no description under it.
5
+ A `SurfaceCard` is ONE object: its name, its facts and its commands (`actions`). A second list, table, form or graph is not part of the object: it stands 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 `no-raised-surface-in-surface` (R340); a card whose only content is a collection is `card-is-object`. A label has no description under it.
6
6
 
7
7
  Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
8
 
9
9
  ## `starci-grammar/card-one-content`
10
10
 
11
- - A `SurfaceCard` (not `figures`, not `tile`) whose body holds more than one content component (`ListBox`, `ItemList`, `DescriptionList`, `DataTable`, `FlowGraph`, `BarChart`, `Timeline`, `Form`, `FormGrid`, a `Section kind="list"` or `"figures"`, ...), looked through layout wrappers (message `many`).
12
- - A card that carries a `figures` header zone while it is not itself `kind="figures"`: a ribbon above another content (message `ribbon`).
11
+ - A `SurfaceCard` (not `tile`) whose body holds more than one content component (`ListBox`, `ItemList`, `DescriptionList`, `DataTable`, `FlowGraph`, `BarChart`, `Timeline`, `Form`, `FormGrid`, a `Section kind="list"` or `"figures"`, ...), looked through layout wrappers (message `many`).
13
12
 
14
13
  ## `starci-grammar/no-label-description`
15
14
 
@@ -26,8 +25,8 @@ Every rule below is an error in `coreGrammarConfig`; none can be switched off or
26
25
  **Valid**
27
26
 
28
27
  ```tsx
29
- <Sublabel>Lines</Sublabel><SurfaceCard kind="table" label="Lines" columns={columns} rows={lines} empty="-" />
30
- <Sublabel>Facts</Sublabel><SurfaceCard kind="details" label="Facts" items={facts} />
28
+ <Section title="Lines"><DataTable label="Lines" columns={columns} rows={lines} renderCell={renderCell} emptyContent="-" /></Section>
29
+ <Section title="Facts"><DescriptionList isDivided items={facts} /></Section>
31
30
  <Section title="Runs" caption="Everyone on the team">...</Section>
32
31
  ```
33
32
 
@@ -0,0 +1,42 @@
1
+ # A card is one object
2
+
3
+ Law module: `card-is-object.ts`. Finding code: `FE_CARD_IS_OBJECT`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#CARD-OBJECT`.
4
+
5
+ A `SurfaceCard` is ONE object: a customer, an agent, a provider, a plan, a message, an approval, a dialog or an overlay. Its body holds the object's name, its facts and a control. A collection (a list, a table, facts, figures, disclosures, a choice), a form and a placeholder stand flat: in a `Section`, or on their own. The Grammar family 0.45.0 removed the card kinds `table`, `details`, `figures`, `accordion` and `select`; this rule refuses the same shapes written as the body of a card.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/card-is-object`
10
+
11
+ A Grammar `SurfaceCard` of the body kind (no `kind`, or `kind="body"`) whose ONLY content is one of the following, looked through fragments, `cond && x`, `cond ? x : y`, `.map`, and the layout wrappers `Stack`, `Cluster`, `Inline`, `Grid` and a plain `div` (message `collection`, which names the replacement):
12
+
13
+ | Only content | Stands instead |
14
+ |---|---|
15
+ | `DataTable` | `<Section title ...><DataTable .../></Section>` |
16
+ | `Section` of any kind | the `Section` alone, no card around it |
17
+ | `DescriptionList` | `<Section title ...><DescriptionList isDivided items={...} /></Section>` |
18
+ | `DisclosureList`, `Accordion` | `<Section title ...><DisclosureList items={...} /></Section>` |
19
+ | `Form`, `Fieldset`, `Input`, `Textarea`, `Select`, `ComboBox`, `SearchField`, `NumberField`, `RadioGroup`, `CheckboxGroup` | `<Section title ...><Form .../></Section>` |
20
+ | `EmptyNotice` | the `EmptyNotice` on its own |
21
+ | `Markdown`, `MarkdownArticle` | `<Section title ...><Markdown .../></Section>` |
22
+ | `BarChart`, `LineChart`, `Sparkline`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram` | `<Section title ...><BarChart .../></Section>` |
23
+
24
+ Not flagged: a card with `measure="formCompact"` (the sign-in form with no page around it), a `kind="tile"` card, a body card with more than one content (an object's name or facts beside a control is an object), a card with a JSX spread, a `kind` that is not a literal, a non-Grammar `SurfaceCard`, and non-product source. `Meter`, `Progress`, `Timeline` and `ListBox` are not in the table. There is no autofix: the card's `label` becomes the `Section` title, which the author reads.
25
+
26
+ **Invalid**
27
+
28
+ ```tsx
29
+ <SurfaceCard label="Runs"><DataTable columns={columns} rows={runs} /></SurfaceCard>
30
+ <SurfaceCard label="Profile"><Form onSubmit={save}><Input label="Name" /></Form></SurfaceCard>
31
+ <SurfaceCard><EmptyNotice title="No runs" /></SurfaceCard>
32
+ ```
33
+
34
+ **Valid**
35
+
36
+ ```tsx
37
+ <Section title="Runs"><DataTable columns={columns} rows={runs} /></Section>
38
+ <SurfaceCard label="Agent"><DescriptionList items={facts} /><Button>Pause</Button></SurfaceCard>
39
+ <SurfaceCard measure="formCompact" label="Sign in"><Form onSubmit={signIn}><Input label="Email" /></Form></SurfaceCard>
40
+ ```
41
+
42
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -8,10 +8,10 @@ Every rule below is an error in `coreGrammarConfig`; none can be switched off or
8
8
 
9
9
  ## Which component switches what
10
10
 
11
- - `Tabs` switches the views or periods of one block, or filters its list: the primary underline, `kind="filter"` in the block's `filter` (or `toolbar`) header zone of a `SurfaceCard`, one line under the strip.
11
+ - `Tabs` switches the views or periods of one block, or filters its list: the primary underline, `kind="filter"` in the `filter` row of the block's `Section`, one line under the strip.
12
12
  - `ChoiceChips` or `RadioGroup` chooses a value of a form.
13
13
  - A `Button` holds a command, never a selection state; a `ButtonGroup` holds commands only.
14
- - A switch between modes or periods of one block ("This month / Last month", "Day / Week / Month", "List / Board") is `Tabs appearance="primary"` in the card's `switch` header zone.
14
+ - A switch between modes or periods of one block ("This month / Last month", "Day / Week / Month", "List / Board") is `Tabs appearance="primary"` in the `action` of the block's `Section`.
15
15
  - Two joined buttons or pills acting as tabs are banned. `SegmentedControl` is removed.
16
16
 
17
17
  ## `starci-grammar/no-button-view-switch`
@@ -30,12 +30,12 @@ Finding code: `FE_GROUPED_CHOICE_CONTROL` (R380). Two or more adjacent `Button`
30
30
  **Valid**
31
31
 
32
32
  ```tsx
33
- <SurfaceCard kind="table" label="Cash" columns={columns} headers={[{ kind: "filter", label: "Period", items, selectedKey: period, onSelect: setPeriod }]} rows={rows} empty={empty} />
33
+ <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>
34
34
  ```
35
35
 
36
36
  ## `starci-grammar/no-primary-tabs-misuse`
37
37
 
38
- Finding code: `FE_GROUPED_CHOICE_CONTROL` (R380). `Tabs appearance="primary"` (HeroUI's primary variant, a pill in a track) and a card's `{ kind: "switch" }` header zone switch a mode or period of the same data among two to four short, fixed options. An `items` array literal with an item carrying `count`, `href` or `isAttention`, with one item, or with more than four items is a finding; views, filters with counts and destinations are the secondary (underline) `Tabs`. Grammar also refuses these at run time in development, and its types refuse them.
38
+ Finding code: `FE_GROUPED_CHOICE_CONTROL` (R380). `Tabs appearance="primary"` (HeroUI's primary variant, a pill in a track) in a `Section action` switch a mode or period of the same data among two to four short, fixed options. An `items` array literal with an item carrying `count`, `href` or `isAttention`, with one item, or with more than four items is a finding; views, filters with counts and destinations are the secondary (underline) `Tabs`. Grammar also refuses these at run time in development, and its types refuse them.
39
39
 
40
40
  ## `starci-grammar/no-grouped-choice-controls`
41
41
 
@@ -0,0 +1,27 @@
1
+ # A table has one flat look
2
+
3
+ Law module: `data-table-surface.ts`. Finding code: `FE_DATA_TABLE_SURFACE`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#DATA-TABLE-SURFACE`.
4
+
5
+ A `DataTable` has one flat look: no frame, no card, no fill; its title is the `Section` it stands under. The Grammar family 0.45.0 removed its `surface` prop (`card`, `frame`, `none`), so the compiler refuses it where the types are read; this rule names the fix, and applies it, where an app still writes it (a pinned older Grammar, a JavaScript file, an `any` prop).
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/data-table-surface`
10
+
11
+ A Grammar `DataTable` (named or `G.DataTable`) with a `surface` attribute, whatever its value (message `surface`). A `surface` on another component (`Pane surface`), a non-Grammar `DataTable` and non-product source are not read.
12
+
13
+ AUTOFIX (`fixable: "code"`): the attribute and the whitespace before it are removed; the table keeps its columns, rows and `footer`.
14
+
15
+ **Invalid**
16
+
17
+ ```tsx
18
+ <DataTable label="Runs" surface="card" columns={columns} rows={runs} />
19
+ ```
20
+
21
+ **Valid**
22
+
23
+ ```tsx
24
+ <Section title="Runs"><DataTable label="Runs" columns={columns} rows={runs} /></Section>
25
+ ```
26
+
27
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -19,14 +19,14 @@ A Grammar `Grid` or `Cluster` is a finding when its rendered children are:
19
19
 
20
20
  ```tsx
21
21
  <Grid><SurfaceCard label="Runs" /><Stack><SurfaceCard label="A" /><SurfaceCard label="B" /></Stack></Grid>
22
- <Cluster><SurfaceCard kind="figures" /><SurfaceCard kind="details" /></Cluster>
22
+ <Cluster><SurfaceCard label="Plan" /><SurfaceCard label="Usage" /></Cluster>
23
23
  ```
24
24
 
25
25
  **Valid**
26
26
 
27
27
  ```tsx
28
- <Stack gap="section"><SurfaceCard kind="figures" /><SurfaceCard label="Runs">...</SurfaceCard></Stack>
29
- <Cluster><SurfaceCard kind="figures" /><SurfaceCard kind="figures" /></Cluster>
28
+ <Stack gap="section"><SurfaceCard label="Plan">...</SurfaceCard><SurfaceCard label="Runs">...</SurfaceCard></Stack>
29
+ <Cluster><SurfaceCard kind="tile" name="Mail" mark={mail} /><SurfaceCard kind="tile" name="Chat" mark={chat} /></Cluster>
30
30
  ```
31
31
 
32
32
  Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -13,13 +13,13 @@ A Grammar `Text` with `tone="muted"` written immediately before a Grammar `Surfa
13
13
  **Invalid**
14
14
 
15
15
  ```tsx
16
- <Stack><Heading level={3}>General</Heading><Text tone="muted">Choose how the agent works.</Text><SurfaceCard kind="select" label="Mode" ... /></Stack>
16
+ <Stack><Heading level={3}>General</Heading><Text tone="muted">Choose how the agent works.</Text><SurfaceCard label="Mode" ... /></Stack>
17
17
  ```
18
18
 
19
19
  **Valid**
20
20
 
21
21
  ```tsx
22
- <SurfaceCard kind="select" label="Mode" items={[{ id: "auto", title: "Automatic", subtitle: "The agent answers at once; you review later." }]} ... />
22
+ <Section title="Mode"><RadioGroup label="Mode" isLabelHidden options={[{ value: "auto", label: "Automatic", description: "The agent answers at once; you review later." }]} ... /></Section>
23
23
  ```
24
24
 
25
25
  Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -14,7 +14,7 @@ A Grammar `Section` with `title`, or a `SurfaceCard` with `label`, whose JSX anc
14
14
 
15
15
  ```tsx
16
16
  <Section title="What the assistant knows">
17
- <SurfaceCard kind="select" label="Allowed" ... />
17
+ <SurfaceCard label="Allowed">...</SurfaceCard>
18
18
  </Section>
19
19
  ```
20
20
 
@@ -22,8 +22,8 @@ A Grammar `Section` with `title`, or a `SurfaceCard` with `label`, whose JSX anc
22
22
 
23
23
  ```tsx
24
24
  <Section title="What the assistant knows">
25
- <SurfaceCard kind="select" sublabel="Allowed" ... />
26
- <SurfaceCard kind="select" sublabel="Ask first" ... />
25
+ <SurfaceCard sublabel="Allowed">...</SurfaceCard>
26
+ <SurfaceCard sublabel="Ask first">...</SurfaceCard>
27
27
  </Section>
28
28
  ```
29
29
 
@@ -1,14 +1,14 @@
1
- # Key-value and disclosure rows stand in a card or a section
1
+ # Key-value and disclosure rows stand in a section or an object card
2
2
 
3
3
  Law module: `rows-in-card.ts`. Finding code: `FE_ROWS_IN_CARD`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#ROWS-IN-CARD`.
4
4
 
5
- Key-value rows (`DescriptionList`) and disclosure rows (`DisclosureList`) stand in a `SurfaceCard` or a `Section`. In a card they take the card's edge: on the pink well a shadow and no border, on a white surface (aside, pane, drawer) a 1px border and no shadow, which Grammar draws itself. A plain list of rows is a flat `Section kind="list"` (LIST-ONE-LOOK, `surface-card-list`).
5
+ Key-value rows (`DescriptionList`) and disclosure rows (`DisclosureList`) stand in a `Section` (the facts or the disclosures of a collection, flat on the surface: `<Section title ...><DescriptionList isDivided items={...} /></Section>`) or in the body of an object card (the facts of ONE object beside its name or a control). A plain list of rows is a flat `Section kind="list"` (LIST-ONE-LOOK, `surface-card-list`). A card whose only content is the rows is `card-is-object`.
6
6
 
7
7
  Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
8
 
9
9
  ## `starci-grammar/rows-in-card`
10
10
 
11
- A Grammar `DescriptionList` or `DisclosureList` that no `SurfaceCard`, `Section`, `DataTable` or `Accordion` of the same file encloses (message `bare`). A row primitive passed as a JSX attribute value is judged where the receiver draws it. `ListBox` (a navigation list or menu) is not read.
11
+ A Grammar `DescriptionList` or `DisclosureList` that no `SurfaceCard` or `Section` of the same file encloses (message `bare`). A row primitive passed as a JSX attribute value is judged where the receiver draws it. `ListBox` (a navigation list or menu) is not read.
12
12
 
13
13
  **Invalid**
14
14
 
@@ -19,7 +19,8 @@ A Grammar `DescriptionList` or `DisclosureList` that no `SurfaceCard`, `Section`
19
19
  **Valid**
20
20
 
21
21
  ```tsx
22
- <SurfaceCard label="Details"><DescriptionList items={items} /></SurfaceCard>
22
+ <Section title="Details"><DescriptionList isDivided items={items} /></Section>
23
+ <SurfaceCard label="Agent"><DescriptionList items={items} /><Button>Pause</Button></SurfaceCard>
23
24
  ```
24
25
 
25
26
  Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -13,8 +13,7 @@ Every rule below is an error in `coreGrammarConfig`; none can be switched off or
13
13
 
14
14
  A Grammar `SurfaceCard` whose `kind` is the literal `"list"` (message `list`). A `kind` that is not a literal is left to the compiler.
15
15
 
16
- There is no autofix: `label` becomes `title` and `labelEnd` becomes `action`, the card's zones have no list form (a filter or search
17
- is the list's `filter`; figures and a list together are a body card holding both), the import changes, and the look changes from a
16
+ There is no autofix: `label` becomes `title` and `labelEnd` becomes `action`, a filter or search is the list's `filter`, the import changes, and the look changes from a
18
17
  card to flat rows.
19
18
 
20
19
  **Invalid**