@starci/eslint-grammar-core 0.28.0 → 0.32.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.32.0 - 2026-11-09
4
+
5
+ - Versioned with Grammar 0.32.0 (every surface on the page ground is a card); no rule changes.
6
+
7
+ ## 0.31.0 - 2026-11-09
8
+
9
+ - Changed: released with the Grammar family at 0.31.0 (the final type scale).
10
+ - Changed: `same-line-size` treats `sm` and `md` (and an absent size) as the same 14 step; only 14 vs 12 (`xs`) vs display (`figure`) on one line are findings. `table-cell-type` allows only 14 (`md`, `sm`, absent) and 12 (`xs`) Text in a DataTable cell or ListRow; `lg`, `xl`, `figure`, Heading, Label and h1-h6 stay refused. Messages, docs and `why.ts` no longer name 13 or 16.
11
+
12
+ ## 0.30.0 - 2026-11-09
13
+
14
+ - Changed: released with the Grammar family at 0.30.0 (Button sm takes the pill radius).
15
+ - Added: `suggestion-buttons` (`FE_SUGGESTION_BUTTONS`, SUGGESTION-BUTTONS): suggestions and quick replies have one pattern, a `Cluster gap="inline"` of neutral `Button size="sm"` (a pill); a row of Grammar `Link`s with an inline handler that passes its own label (`href` absent or `"#"`), a `ChoiceChips` whose `onValueChange` sends the value instead of keeping it, and a HeroUI `Chip` whose `onPress` passes its own label are refused. `docs/suggestion-buttons.md`.
16
+ - Note: `suggestion-chips` was withdrawn before release with SuggestionChips.
17
+
18
+ ## 0.29.0 - 2026-11-09
19
+
20
+ - Changed: released with the Grammar family at 0.29.0 (its standalone DataTable and zone text defaults changed); the messages of `surface-card-kind` and `surface-in-surface` that named a bare list card now point at `Section kind="list"`.
21
+ - Added: `single-child-card` (`FE_SINGLE_CHILD_CARD`, SINGLE-CHILD-CARD): a Grammar `SurfaceCard` with no zones (`headers`, `footers`, `labelEnd`) whose only body child is a `DataTable`, a list (`ListBox`, `ItemList`, `DisclosureList`, `Timeline`, `Section kind="list"`) or a chart (`BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`), or that is `kind="table"` or `kind="list"`, is refused; the title is a `Section` head and one line under it is `Section caption`. `docs/single-child-card.md`.
22
+
3
23
  ## 0.28.0 - 2026-11-09
4
24
 
5
25
  - Changed: released with the Grammar family at 0.28.0; peers `@starci/hfs ~6.5.0`. The new rules below are errors, with no escape.
package/README.md CHANGED
@@ -22,7 +22,8 @@ Grammar-owned structural elements, glyphs and icon sizes, destructive menu entri
22
22
  chip labels that start uppercase, a Button that leads somewhere ending with `endArrow` (no typed or icon arrow), row type sizes in a DataTable cell or ListRow, one size per Cluster line, a row title that is plain text when the row opens (`button-arrow`, `table-cell-type`, `same-line-size`, `row-title-link`), generated art rendered through `Mascot` or `MediaFrame` with every `Mascot` naming its asset slot, the page head composed by `PageHeader`, the pane grid (a `PaneGrid` of `Pane`s, a `Pane` of `PaneSection`s that carry no padding of their own, mounted as `Page chrome="panes"`), the route page as one `Page` with its tabs in the header, heading and token scales, vendor ownership and slot-status composition, and a surface nested in another surface left subordinate (no forced `depth="top"`), and a Freestyle region that names its reason (its raw elements are exempt from the paint and raw-element laws). The pill (`Tabs appearance="primary"`) is only the `switch` header zone of a card, and a page stacks two underline `Tabs` layers at most (`tabs-switch-zone`, `tabs-depth`; `docs/tabs.md`). Each rule's metadata cites
23
23
  its behavioral knowledge source and the governing ownership test. The R318 surface composition
24
24
  rules (nested control variants, panel-list alignment, layout-only CSS) stay in the universal canon.
25
- The proximity and composition laws of 2026-11-09 each have a doc: `gap-proximity` (a layout element stands at least one gap step closer than its layout parent), `field-label` (a control is labelled by its own `label` prop), `surface-in-surface` (a hand-made divided row list in a surface is `Section kind="list"`) and `page-breadcrumbs` (a console `Page` header states `breadcrumbs`, or `"root"`).
25
+ `suggestion-buttons` (suggestions and quick replies are a Cluster of neutral sm Buttons, never a Link row, ChoiceChips or Chip that sends; `docs/suggestion-buttons.md`).
26
+ The proximity and composition laws of 2026-11-09 each have a doc: `gap-proximity` (a layout element stands at least one gap step closer than its layout parent), `field-label` (a control is labelled by its own `label` prop), `surface-in-surface` (a hand-made divided row list in a surface is `Section kind="list"`) `single-child-card` (a table, list or chart alone is the surface, not a card's only content) and `page-breadcrumbs` (a console `Page` header states `breadcrumbs`, or `"root"`).
26
27
 
27
28
  ## Migrating from @starci/eslint-canon-fe 8.x
28
29
 
package/dist/index.js CHANGED
@@ -21,7 +21,9 @@ import { rules as sameLineSizeRules } from "./same-line-size.js";
21
21
  import { rules as statusColorsRules } from "./status-colors.js";
22
22
  import { rules as surfaceCardRules } from "./surface-card.js";
23
23
  import { rules as surfaceDepthRules } from "./surface-depth.js";
24
+ import { rules as singleChildCardRules } from "./single-child-card.js";
24
25
  import { rules as surfaceInSurfaceRules } from "./surface-in-surface.js";
26
+ import { rules as suggestionButtonsRules } from "./suggestion-buttons.js";
25
27
  import { rules as tabsRules } from "./tabs.js";
26
28
  import { rules as tableCellTypeRules } from "./table-cell-type.js";
27
29
  import { rules as textRules } from "./text-rules.js";
@@ -47,9 +49,11 @@ const CONTRIBUTIONS = [
47
49
  { law: "pane", rules: paneRules },
48
50
  { law: "row-title-link", rules: rowTitleLinkRules },
49
51
  { law: "same-line-size", rules: sameLineSizeRules },
52
+ { law: "single-child-card", rules: singleChildCardRules },
50
53
  { law: "status-colors", rules: statusColorsRules },
51
54
  { law: "surface-card", rules: surfaceCardRules },
52
55
  { law: "surface-depth", rules: surfaceDepthRules },
56
+ { law: "suggestion-buttons", rules: suggestionButtonsRules },
53
57
  { law: "surface-in-surface", rules: surfaceInSurfaceRules },
54
58
  { law: "tabs", rules: tabsRules },
55
59
  { law: "table-cell-type", rules: tableCellTypeRules },
package/dist/lib/why.js CHANGED
@@ -152,7 +152,12 @@ export const why = {
152
152
  "surface-in-surface": {
153
153
  code: "FE_SURFACE_IN_SURFACE",
154
154
  en: "A hand-made row list (a Stack, ul, ol or div whose rows are divided by `Divider`) in `<file>` stands inside a SurfaceCard, Drawer, Dialog, PaneSection or main-rail rail.",
155
- fix: "Use `<Section kind=\"list\">` for rows inside a surface (the Grammar draws them as a nested surface with a border, the card radius and a clip), or `<SurfaceCard kind=\"list\">` when the list is the card.",
155
+ fix: "Use `<Section kind=\"list\">` for rows inside a surface (the Grammar draws them as a nested surface with a border, the card radius and a clip), or a `Section kind=\"list\"` standing alone (it draws its own frame; a card around a lone list is refused by `single-child-card`).",
156
+ },
157
+ "single-child-card": {
158
+ code: "FE_SINGLE_CHILD_CARD",
159
+ en: "A `SurfaceCard` in `<file>` has no zones and holds one table, list or chart (a `DataTable`, `ListBox`, `ItemList`, `DisclosureList`, `Timeline`, `Section kind=\"list\"`, `BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`, or is `kind=\"table\"` or `kind=\"list\"`): a second frame around the one the Grammar already draws.",
160
+ fix: "Drop the card: put the title in a `Section` head (`title`) and one line under it in `Section caption`. A card groups two or more different parts, or carries zones (`headers`, `footers`) or head actions (`labelEnd`).",
156
161
  },
157
162
  "surface-card-kind": {
158
163
  code: "FE_SURFACE_CARD_KIND",
@@ -171,17 +176,22 @@ export const why = {
171
176
  },
172
177
  "table-cell-type": {
173
178
  code: "FE_TABLE_CELL_TYPE",
174
- en: "A DataTable cell or ListRow title/description in `<file>` draws a heading-size Text (`size=\"figure\"`), a Heading, a Label or an h1-h6.",
175
- fix: "The primary of a row or cell is md 14 / 500 (`<Text isStrong>`), the secondary sm 13 muted (`<Text size=\"sm\" tone=\"muted\">`).",
179
+ en: "A DataTable cell or ListRow title/description in `<file>` draws a Text above 14 (`size=\"lg\"`, `\"xl\"`, `\"figure\"`), a Heading, a Label or an h1-h6.",
180
+ fix: "The primary of a row or cell is 14 / 500 (`<Text isStrong>`), the secondary the same 14 muted (`<Text tone=\"muted\">`), and a small name (meta, count, timestamp) is 12 (`<Text size=\"xs\" tone=\"muted\">`).",
176
181
  },
177
182
  "same-line-size": {
178
183
  code: "FE_SAME_LINE_SIZE",
179
184
  en: "The Text children of one Cluster line in `<file>` have different sizes.",
180
- fix: "One line, one size: give every Text of the line the size of the line's role (md primary, sm secondary). A Badge or chip may stay as it is.",
185
+ fix: "One line, one size: give every Text of the line the same step: 14 (md, sm), 12 (xs) or display (figure); sm and md are the same 14. A Badge or chip may stay as it is.",
181
186
  },
182
187
  "row-title-link": {
183
188
  code: "FE_ROW_TITLE_LINK",
184
189
  en: "A Link is the title of a row in `<file>` that already opens (onPress, onAction, href, chevron, or a DataTable with onRowAction or row hrefs).",
185
190
  fix: "The row is the one pressable: write the title as plain text (`<Text isStrong>`) and keep the destination on the row.",
186
191
  },
192
+ "suggestion-buttons": {
193
+ code: "FE_SUGGESTION_BUTTONS",
194
+ en: "A Link row, a ChoiceChips or a Chip in `<file>` runs an action or sends its own label as a suggestion.",
195
+ fix: "Suggestions and quick replies are one pattern: a `Cluster gap=\"inline\"` (with `label`) of neutral `Button size=\"sm\"` (a pill).",
196
+ },
187
197
  };
@@ -3,7 +3,7 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
3
3
  import { attributeOf, elementOf, grammarBindings, literalAttribute } from "./lib/row-context.js";
4
4
  /**
5
5
  * The same line size law (`FE_SAME_LINE_SIZE`): one line, one size. The `Text` children that stand side by side on one line,
6
- * the direct children of one `Cluster` (and of a `Text` that holds `Text` runs, whose own size starts the line), share one `size`; an absent `size` is `md`.
6
+ * the direct children of one `Cluster` (and of a `Text` that holds `Text` runs, whose own size starts the line), share one `size`; an absent `size` is `md`, and `sm` is the same 14 step as `md` (the final type scale), so only 14 vs 12 (`xs`) vs display (`figure`) mixes are findings.
7
7
  *
8
8
  * WHAT IT READS. The direct `Text` children of a `Cluster` or a `Text`, through fragments, `cond && <Text />` and ternaries. A
9
9
  * `Text` whose `size` is not a literal (a variable, a spread) is skipped. A `Badge`, `StatusDot`, `Chip` or `TagGroup` is not a
@@ -11,13 +11,14 @@ import { attributeOf, elementOf, grammarBindings, literalAttribute } from "./lib
11
11
  */
12
12
  /** The line containers: a Cluster lays its children on one line, a Text holds runs. */
13
13
  const LINES = new Set(["Cluster", "Text"]);
14
- /** The size a Text states: its literal `size`, `md` when it has none, null when it cannot be read. */
14
+ /** The size step a Text states: its literal `size` (`sm` folds into `md`, both 14), `md` when it has none, null when it cannot be read. */
15
15
  const sizeOf = (opening) => {
16
16
  if (opening.attributes.some((entry) => entry.type === "JSXSpreadAttribute"))
17
17
  return null;
18
18
  if (attributeOf(opening, "size") === null)
19
19
  return "md";
20
- return literalAttribute(opening, "size");
20
+ const size = literalAttribute(opening, "size");
21
+ return size === "sm" ? "md" : size;
21
22
  };
22
23
  export const sameLineSize = defineRule({
23
24
  meta: {
@@ -25,7 +26,7 @@ export const sameLineSize = defineRule({
25
26
  docs: { description: "FE_SAME_LINE_SIZE: the Text children of one Cluster line share one size." },
26
27
  schema: [],
27
28
  messages: {
28
- mixed: "This Text is `{{size}}` and its line's first Text is `{{first}}`. One line, one size: pick the size of the line's role (md for a primary, sm for a secondary or a meta line) and give every Text of the line that size. A Badge or a chip may stay as it is.",
29
+ mixed: "This Text is `{{size}}` and its line's first Text is `{{first}}`. One line, one size: sizes are 14 (md, sm), 12 (xs, for a small name such as a meta line, count or timestamp) and display (figure): give every Text of the line the same step. A Badge or a chip may stay as it is.",
29
30
  },
30
31
  },
31
32
  create(context) {
@@ -0,0 +1,7 @@
1
+ import type { Rule } from "eslint";
2
+ /** A table, list or chart standing alone is the surface, never wrapped in a card. */
3
+ export declare const singleChildCard: Rule.RuleModule;
4
+ /** The rules this law contributes to the plugin. */
5
+ export declare const rules: Record<string, Rule.RuleModule>;
6
+ /** Every rule of this law is an error. */
7
+ export declare const recommended: Record<string, "error">;
@@ -0,0 +1,103 @@
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): a card groups two or more different parts (figures + list +
6
+ * actions) or carries zones (tabs, search, head actions). A table, a list or a chart standing alone IS the surface: the
7
+ * title sits above it as a `Section` head and one line sits under it as `Section caption` (muted, sm). The Grammar draws a
8
+ * standalone `DataTable` (`surface="card"`) and every `Section kind="list"` as its own card (border, card radius, card shadow), so a
9
+ * `SurfaceCard` around either is a second card around the first.
10
+ *
11
+ * WHAT IT READS. A Grammar `SurfaceCard` (imported from `@starci/grammar`) with no zones: no `headers` or `footers` prop (an
12
+ * empty array literal counts as none) and no `labelEnd` (head actions). Its body is read through fragments, `cond && <x/>`,
13
+ * `cond ? <x/> : <y/>` and `.map`, ignoring blank text. It is refused when that body is ONE element and that element is:
14
+ * - a table: `DataTable`;
15
+ * - a list: `ListBox`, `ItemList`, `DisclosureList`, `Timeline`, or `Section kind="list"`;
16
+ * - a chart: `BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`.
17
+ * It is also refused when the card is the data-driven form of the same thing: `SurfaceCard kind="table"` or `kind="list"`.
18
+ *
19
+ * DECIDED. `Meter`, `Progress` and `ProgressCircle` are single values, not charts. `DescriptionList` (term/value facts of one
20
+ * record) and `Accordion` are not read as lists here: a record's facts are the `kind="details"` card. `SurfaceCard
21
+ * kind="figures"`, `details`, `accordion` and `tile` are not judged. `SurfaceCard` rules for kinds, depth and nesting stay with
22
+ * `surface-card-kind`, `no-raised-surface-in-surface` and `surface-depth`; none is read again here.
23
+ *
24
+ * 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
25
+ * prop may arrive that the source does not show), a non-Grammar `SurfaceCard`, and non-product source.
26
+ *
27
+ * WHERE IT APPLIES. Product source (`isProductSource`).
28
+ */
29
+ /** The table, list and chart components that are a surface on their own, with the word the message names them by. */
30
+ const LONE = new Map([
31
+ ["DataTable", "table"],
32
+ ["ListBox", "list"],
33
+ ["ItemList", "list"],
34
+ ["DisclosureList", "list"],
35
+ ["Timeline", "list"],
36
+ ["BarChart", "chart"],
37
+ ["ProportionBar", "chart"],
38
+ ["BubbleMap", "chart"],
39
+ ["FlowGraph", "chart"],
40
+ ["MermaidDiagram", "chart"],
41
+ ]);
42
+ /** True when an attribute is an empty array literal (`headers={[]}`), which zones nothing. */
43
+ const isEmptyArray = (attribute) => {
44
+ const value = attribute.value;
45
+ return value?.type === "JSXExpressionContainer" && value.expression.type === "ArrayExpression" && value.expression.elements.length === 0;
46
+ };
47
+ /** True when the card carries a zone or head actions: a `headers` or `footers` prop that is not an empty array, or a `labelEnd`. */
48
+ const hasZones = (opening) => {
49
+ const zoned = ["headers", "footers"].some((name) => {
50
+ const attribute = attributeOf(opening, name);
51
+ return attribute !== undefined && !isEmptyArray(attribute);
52
+ });
53
+ return zoned || attributeOf(opening, "labelEnd") !== undefined;
54
+ };
55
+ /** 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. */
56
+ const loneChild = (context, card) => {
57
+ const body = renderedChildren(card.children);
58
+ if (body.length !== 1)
59
+ return null;
60
+ const child = body[0];
61
+ if (child?.type !== "JSXElement")
62
+ return null;
63
+ const name = elementNameOf(child);
64
+ if (name === null || grammarName(context, child.openingElement) === null)
65
+ return null;
66
+ if (name === "Section")
67
+ return stringProp(child.openingElement, "kind") === "list" ? "Section kind=\"list\"" : null;
68
+ return LONE.has(name) ? name : null;
69
+ };
70
+ /** A table, list or chart standing alone is the surface, never wrapped in a card. */
71
+ export const singleChildCard = defineRule({
72
+ meta: {
73
+ type: "problem",
74
+ docs: { description: "SINGLE-CHILD-CARD: a SurfaceCard with no zones whose only content is a table, list or chart is a second frame; the title is a Section head." },
75
+ schema: [],
76
+ messages: {
77
+ 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 card groups two or more different parts, or carries zones (tabs, search, head actions).",
78
+ },
79
+ },
80
+ create(context) {
81
+ if (!isProductSource(context))
82
+ return {};
83
+ return {
84
+ JSXElement(element) {
85
+ const opening = element.openingElement;
86
+ if (grammarName(context, opening) !== "SurfaceCard" || hasSpread(opening) || hasZones(opening))
87
+ return;
88
+ const kind = stringProp(opening, "kind");
89
+ const child = kind === "table" || kind === "list" ? kind : loneChild(context, element);
90
+ if (child === null)
91
+ return;
92
+ context.report({ node: opening, messageId: "lone", data: { child: kind === child ? child : `\`${child}\`` } });
93
+ },
94
+ };
95
+ },
96
+ });
97
+ /** The rules this law contributes to the plugin. */
98
+ export const rules = {
99
+ "single-child-card": singleChildCard,
100
+ };
101
+ defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#SINGLE-CHILD-CARD");
102
+ /** Every rule of this law is an error. */
103
+ export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
@@ -0,0 +1,6 @@
1
+ import type { Rule } from "eslint";
2
+ export declare const suggestionButtons: Rule.RuleModule;
3
+ /** The rules this law contributes to the plugin. */
4
+ export declare const rules: Record<string, Rule.RuleModule>;
5
+ /** Every rule of this law is an error. */
6
+ export declare const recommended: Record<string, "error">;
@@ -0,0 +1,181 @@
1
+ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
+ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
3
+ import { renderedChildren } from "./lib/grammar-jsx.js";
4
+ import { attributeOf, elementOf, grammarBindings, literalAttribute } from "./lib/row-context.js";
5
+ /**
6
+ * The suggestion buttons law (`FE_SUGGESTION_BUTTONS`): suggestions, quick replies and empty-state shortcuts have ONE pattern,
7
+ * a `Cluster gap="inline"` of neutral `Button size="sm"` (every Button size draws a pill). The law flags the ALTERNATIVES
8
+ * drawn as suggestions, in cheap static shapes only:
9
+ * - a row (two or more siblings, or one drawn by a `.map`) of Grammar `Link`s whose `onFollow` or `onPress` is an inline arrow
10
+ * that passes the Link's own label (`{q}` and `send(q)`, `{item.label}` and `ask(item.label)`, or an equal string literal)
11
+ * and whose `href` is absent or `"#"`;
12
+ * - a Grammar `ChoiceChips` whose `onValueChange` is an inline arrow that calls something that is not a state setter with the
13
+ * value, or is a bare send-like function (`send`, `ask`, `submit`, `reply`, `post`, `dispatch`): it sends the choice instead
14
+ * of keeping it selected;
15
+ * - a HeroUI `Chip` (imported from `@heroui/react`) with an `onPress` or `onClick` that passes its own label. Grammar `Badge`
16
+ * takes no action prop and Grammar `TagGroup` only `onRemove(ids)`/`onReorder(ids)`, so neither can send its own label.
17
+ * A spread, a computed prop, a handler that is not readable, a callee named `set*`, `on*`, `handle*` or `update*` is not flagged.
18
+ */
19
+ const PARENTS = new Set(["Cluster", "Stack"]);
20
+ const SENDERS = /^(send|ask|submit|reply|post|dispatch)/;
21
+ const NOT_SENDING = /^(set[A-Z]|on[A-Z]|handle|update)/;
22
+ /** The single expression or text an element states as its label: `{q}` as the node `q`, text as its string. */
23
+ const labelOf = (element) => {
24
+ const children = element.children.filter((child) => !(child.type === "JSXText" && child.value.trim() === ""));
25
+ if (children.length !== 1)
26
+ return null;
27
+ const child = children[0];
28
+ if (child.type === "JSXText")
29
+ return { text: child.value.trim() };
30
+ if (child.type !== "JSXExpressionContainer" || child.expression.type === "JSXEmptyExpression")
31
+ return null;
32
+ if (child.expression.type === "Literal" && typeof child.expression.value === "string")
33
+ return { text: child.expression.value };
34
+ return { node: child.expression };
35
+ };
36
+ /** The one call an inline arrow makes, or null. */
37
+ const callOf = (handler) => {
38
+ let body = handler.body;
39
+ if (body.type === "BlockStatement") {
40
+ const only = body.body.length === 1 ? body.body[0] : undefined;
41
+ body = only?.type === "ExpressionStatement" ? only.expression : null;
42
+ }
43
+ return body !== null && body.type === "CallExpression" ? body : null;
44
+ };
45
+ /** The last name of a callee (`send`, `chat.send` as `send`), or null. */
46
+ const calleeName = (callee) => {
47
+ if (callee.type === "Identifier")
48
+ return callee.name;
49
+ if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier")
50
+ return callee.property.name;
51
+ return null;
52
+ };
53
+ /** The inline arrow an attribute holds, or null. */
54
+ const arrowOf = (opening, name) => {
55
+ const value = attributeOf(opening, name)?.value;
56
+ if (value == null || value.type !== "JSXExpressionContainer" || value.expression.type !== "ArrowFunctionExpression")
57
+ return null;
58
+ return value.expression;
59
+ };
60
+ /** True when an inline handler arrow of the element passes the element's own label. */
61
+ const sendsOwnLabel = (element, names, source) => {
62
+ const label = labelOf(element);
63
+ if (label === null)
64
+ return false;
65
+ return names.some((name) => {
66
+ const handler = arrowOf(element.openingElement, name);
67
+ const call = handler === null ? null : callOf(handler);
68
+ if (call === null)
69
+ return false;
70
+ return call.arguments.some((arg) => ("text" in label ? arg.type === "Literal" && arg.value === label.text : arg.type !== "Literal" && source.getText(arg) === source.getText(label.node)));
71
+ });
72
+ };
73
+ /** True when an element sits inside a `.map` callback below its parent. */
74
+ const inMap = (element, parent) => {
75
+ for (let node = element.parent; node !== undefined && node !== parent; node = node.parent) {
76
+ if (node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression")
77
+ return true;
78
+ }
79
+ return false;
80
+ };
81
+ /** The HeroUI `Chip` local names a file imports from `@heroui/react`. */
82
+ const heroChips = (program) => {
83
+ const names = new Set();
84
+ for (const statement of program.body) {
85
+ if (statement.type !== "ImportDeclaration" || statement.source.value !== "@heroui/react")
86
+ continue;
87
+ for (const specifier of statement.specifiers) {
88
+ if (specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === "Chip")
89
+ names.add(specifier.local.name);
90
+ }
91
+ }
92
+ return names;
93
+ };
94
+ export const suggestionButtons = defineRule({
95
+ meta: {
96
+ type: "problem",
97
+ docs: { description: "FE_SUGGESTION_BUTTONS: suggestions and quick replies are a Cluster of neutral sm Buttons, not Links, ChoiceChips or Chips." },
98
+ schema: [],
99
+ messages: {
100
+ element: "Suggestions and quick replies have one pattern: a `Cluster gap=\"inline\"` of neutral `Button size=\"sm\"` (a pill). {{element}} here runs an action or sends its own label; draw it as a Button.",
101
+ },
102
+ },
103
+ create(context) {
104
+ if (!isProductSource(context))
105
+ return {};
106
+ let bound = new Map();
107
+ let chips = new Set();
108
+ const source = context.sourceCode;
109
+ /** A Grammar Link that passes its own label and goes nowhere. */
110
+ const isLinkSuggestion = (node) => {
111
+ if (node.type !== "JSXElement")
112
+ return false;
113
+ const opening = node.openingElement;
114
+ if (elementOf(opening, bound).grammar !== "Link")
115
+ return false;
116
+ if (opening.attributes.some((entry) => entry.type === "JSXSpreadAttribute"))
117
+ return false;
118
+ if (attributeOf(opening, "href") !== null && literalAttribute(opening, "href") !== "#")
119
+ return false;
120
+ return sendsOwnLabel(node, ["onFollow", "onPress"], source);
121
+ };
122
+ return {
123
+ Program(program) {
124
+ bound = grammarBindings(program);
125
+ chips = heroChips(program);
126
+ },
127
+ JSXElement(element) {
128
+ const opening = element.openingElement;
129
+ const { grammar, tag } = elementOf(opening, bound);
130
+ const report = (name) => context.report({ node: opening, messageId: "element", data: { element: name } });
131
+ if (grammar === "ChoiceChips") {
132
+ if (opening.attributes.some((entry) => entry.type === "JSXSpreadAttribute"))
133
+ return;
134
+ const value = attributeOf(opening, "onValueChange")?.value;
135
+ if (value == null || value.type !== "JSXExpressionContainer")
136
+ return;
137
+ const handler = value.expression;
138
+ if (handler.type === "Identifier" || handler.type === "MemberExpression") {
139
+ const name = calleeName(handler);
140
+ if (name !== null && SENDERS.test(name) && !NOT_SENDING.test(name))
141
+ report("`ChoiceChips`");
142
+ return;
143
+ }
144
+ if (handler.type !== "ArrowFunctionExpression")
145
+ return;
146
+ const param = handler.params[0];
147
+ const call = callOf(handler);
148
+ if (param?.type !== "Identifier" || call === null)
149
+ return;
150
+ const name = calleeName(call.callee);
151
+ if (name === null || NOT_SENDING.test(name))
152
+ return;
153
+ if (call.arguments.some((arg) => arg.type === "Identifier" && arg.name === param.name))
154
+ report("`ChoiceChips`");
155
+ return;
156
+ }
157
+ if (grammar === null && tag === null && opening.name.type === "JSXIdentifier" && chips.has(opening.name.name)) {
158
+ if (opening.attributes.some((entry) => entry.type === "JSXSpreadAttribute"))
159
+ return;
160
+ if (sendsOwnLabel(element, ["onPress", "onClick"], source))
161
+ report("`Chip`");
162
+ return;
163
+ }
164
+ if (!(grammar !== null && PARENTS.has(grammar)) && tag !== "div")
165
+ return;
166
+ const found = renderedChildren(element.children).filter(isLinkSuggestion);
167
+ if (found.length < 2 && !found.some((entry) => inMap(entry, element)))
168
+ return;
169
+ for (const entry of found)
170
+ context.report({ node: entry.openingElement, messageId: "element", data: { element: "`Link`" } });
171
+ },
172
+ };
173
+ },
174
+ });
175
+ /** The rules this law contributes to the plugin. */
176
+ export const rules = {
177
+ "suggestion-buttons": suggestionButtons,
178
+ };
179
+ defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#SUGGESTION-BUTTONS");
180
+ /** Every rule of this law is an error. */
181
+ export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
@@ -161,7 +161,7 @@ export const surfaceCardKind = defineRule({
161
161
  docs: { description: "R355: a SurfaceCard of the body kind holds no hand list, no Divider and no SectionHeader or Heading." },
162
162
  schema: [],
163
163
  messages: {
164
- list: "`<{{element}}>` is a hand-built list in a `body` card. Rows are `<SurfaceCard kind=\"list\" items={...} empty={...} />`, and the card draws every row the same way.",
164
+ list: "`<{{element}}>` is a hand-built list in a `body` card. Rows are `<Section kind=\"list\" items={...} empty={...} />` (with zones: `<SurfaceCard kind=\"list\" headers={...}>`), which draws every row the same way.",
165
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
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
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.",
@@ -57,7 +57,7 @@ export const surfaceInSurface = defineRule({
57
57
  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 or a SurfaceCard kind=list." },
58
58
  schema: [],
59
59
  messages: {
60
- handMade: "This `{{element}}` is a hand-made row list inside {{host}}: its rows are divided by `Divider` elements, so it has no edge, no card radius and no clip. Use `<Section kind=\"list\">` for rows inside a surface (the Grammar draws them as a nested surface), or `<SurfaceCard kind=\"list\">` when the list is the card.",
60
+ handMade: "This `{{element}}` is a hand-made row list inside {{host}}: its rows are divided by `Divider` elements, so it has no edge, no card radius and no clip. Use `<Section kind=\"list\">` for rows inside a surface (the Grammar draws them as a nested surface), or a `Section kind=\"list\"` with its own frame when the list stands alone (a card around a lone list is refused by `single-child-card`).",
61
61
  },
62
62
  },
63
63
  create(context) {
@@ -3,26 +3,28 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
3
3
  import { attributeOf, descendants, elementOf, grammarBindings, isListRow, keyName, literalAttribute, propertyOf } from "./lib/row-context.js";
4
4
  /**
5
5
  * The table and row type law (`FE_TABLE_CELL_TYPE`): the cells of a DataTable and the copy of a ListRow take the row type sizes,
6
- * the primary at md 14 / 500 (`Text isStrong`) and the secondary at sm 13 muted (`Text size="sm" tone="muted"`). A heading-size
7
- * Text, a `Heading`, a `Label` or an `h1`-`h6` in a cell or a row is a heading drawn in a list.
6
+ * the final type scale: 14px text (`Text`, `Text size="md"`, `Text size="sm"`; the primary is 14 / 500 `Text isStrong`, the
7
+ * secondary 14 muted) and 12px for small names (`Text size="xs"`). A Text of another size (`lg`, `xl`, `figure`), a `Heading`, a `Label` or an `h1`-`h6` in a cell or a row is a heading drawn in a list.
8
8
  *
9
9
  * WHAT IT READS.
10
10
  * - the function a `DataTable` takes as `renderCell` (inline, or a function or arrow declared by name in the file), and the
11
11
  * `editor` function of a column object in its `columns` literal;
12
12
  * - the `title` and `description` of a ListRow data object: a row of the `items` of a list collection (`{ kind: "list", items }`,
13
13
  * or `Section` / `SurfaceCard` written `kind="list"`), through `.map` callbacks, or the `row` of a `<ListRow>`.
14
- * In those, `Text size="figure"`, any `Heading`, any `Label` and the tags `h1`-`h6` are findings. A row list declared elsewhere
14
+ * In those, a `Text` whose literal `size` is not `xs`, `sm` or `md`, any `Heading`, any `Label` and the tags `h1`-`h6` are findings. A row list declared elsewhere
15
15
  * and passed by name is not followed.
16
16
  */
17
+ /** The Text sizes a cell or row takes: 14 (md, sm) and 12 (xs). */
18
+ const CELL_SIZES = new Set(["xs", "sm", "md"]);
17
19
  const HEADING_TAGS = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
18
20
  const isFunction = (node) => node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration";
19
21
  export const tableCellType = defineRule({
20
22
  meta: {
21
23
  type: "problem",
22
- docs: { description: "FE_TABLE_CELL_TYPE: no heading-size Text, Heading, Label or h1-h6 in a DataTable cell or a ListRow." },
24
+ docs: { description: "FE_TABLE_CELL_TYPE: no Text above 14, Heading, Label or h1-h6 in a DataTable cell or a ListRow." },
23
25
  schema: [],
24
26
  messages: {
25
- heading: "{{what}} in {{where}} is a heading drawn in a list. The primary of a row or a cell is md 14 / 500 (`<Text isStrong>`), the secondary sm 13 muted (`<Text size=\"sm\" tone=\"muted\">`).",
27
+ heading: "{{what}} in {{where}} is a heading drawn in a list. The primary of a row or a cell is 14 / 500 (`<Text isStrong>`), the secondary 14 muted (`<Text tone=\"muted\">`), a small name (meta, count, timestamp) 12 (`<Text size=\"xs\" tone=\"muted\">`).",
26
28
  },
27
29
  },
28
30
  create(context) {
@@ -38,8 +40,9 @@ export const tableCellType = defineRule({
38
40
  continue;
39
41
  const { grammar, tag } = elementOf(node.openingElement, bound);
40
42
  let what = null;
41
- if (grammar === "Text" && literalAttribute(node.openingElement, "size") === "figure")
42
- what = "`Text size=\"figure\"`";
43
+ const size = grammar === "Text" ? literalAttribute(node.openingElement, "size") : null;
44
+ if (size !== null && !CELL_SIZES.has(size))
45
+ what = `\`Text size="${size}"\``;
43
46
  else if (grammar === "Heading" || grammar === "Label")
44
47
  what = `\`${grammar}\``;
45
48
  else if (tag !== null && HEADING_TAGS.has(tag))
@@ -2,24 +2,25 @@
2
2
 
3
3
  Law module: `same-line-size.ts`. Finding code: `FE_SAME_LINE_SIZE`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#SAME-LINE-SIZE`.
4
4
 
5
- Texts that stand side by side on one line share one size; the size is the size of the line's role (md for a primary line, sm for a secondary or meta line). A line that mixes 14px and 13px words reads as two lines glued together.
5
+ Texts that stand side by side on one line share one size; the size is the size of the line's role. The final type scale has 14px for all UI text (`md`, and `sm`, which is kept as a name and equals `md`), 12px for small names (`xs`: meta lines, badges, counts, timestamps) and display sizes (`figure`). A line that mixes 14, 12 and display words reads as several lines glued together.
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/same-line-size`
10
10
 
11
- Among the direct `Text` children of one `Cluster` (and of a `Text` that holds `Text` runs, whose own size is the line size), seen through fragments, `cond && <Text />` and ternaries, the first `Text` sets the line's size (an absent `size` is `md`) and every later `Text` of another size is a finding. A `Text` whose `size` is not a literal, or that has a spread attribute, is skipped. `Badge`, `StatusDot`, `Chip` and `TagGroup` are not `Text`, so they are exempt. Nested Clusters are separate lines.
11
+ Among the direct `Text` children of one `Cluster` (and of a `Text` that holds `Text` runs, whose own size is the line size), seen through fragments, `cond && <Text />` and ternaries, the first `Text` sets the line's size (an absent `size` is `md`, and `sm` counts as `md`: both are 14) and every later `Text` of another size is a finding. A `Text` whose `size` is not a literal, or that has a spread attribute, is skipped. `Badge`, `StatusDot`, `Chip` and `TagGroup` are not `Text`, so they are exempt. Nested Clusters are separate lines.
12
12
 
13
13
  **Invalid**
14
14
 
15
15
  ```tsx
16
- <Cluster><Text>Deploy</Text><Text size="sm" tone="muted">2 min ago</Text></Cluster>
16
+ <Cluster><Text>Deploy</Text><Text size="xs" tone="muted">2 min ago</Text></Cluster>
17
17
  ```
18
18
 
19
19
  **Valid**
20
20
 
21
21
  ```tsx
22
- <Cluster><Text size="sm">Deploy</Text><Text size="sm" tone="muted">2 min ago</Text></Cluster>
22
+ <Cluster><Text>Deploy</Text><Text size="sm" tone="muted">2 min ago</Text></Cluster>
23
+ <Cluster><Text size="xs">Deploy</Text><Text size="xs" tone="muted">2 min ago</Text></Cluster>
23
24
  <Cluster><Text>Deploy</Text><Badge>Live</Badge></Cluster>
24
25
  ```
25
26
 
@@ -0,0 +1,37 @@
1
+ # A table, list or chart standing alone is the surface
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 table, list or chart standing alone IS the surface: its title sits above it as a `Section` head and one line sits under it as `Section caption` (muted, sm). The Grammar draws a standalone `DataTable` (`surface="card"`) and every `Section kind="list"` as its own card (border, card radius, card shadow; the table keeps HeroUI's native look inside), so a card around either is a second card.
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 either:
12
+
13
+ - its only body child (looked through fragments, `cond && x`, `cond ? x : y` and `.map`; blank text ignored) is a table, a list or a chart:
14
+ - table: `DataTable`
15
+ - list: `ListBox`, `ItemList`, `DisclosureList`, `Timeline`, `Section kind="list"`
16
+ - chart: `BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`
17
+ - or it is `kind="table"` or `kind="list"` (the data-driven form of the same lone table or list).
18
+
19
+ Not flagged: 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`, `Progress` and `DescriptionList` (a record's term/value facts; its card is `kind="details"`) are not read as table, list or chart.
20
+
21
+ **Invalid**
22
+
23
+ ```tsx
24
+ <SurfaceCard label="Runs"><DataTable columns={columns} rows={runs} /></SurfaceCard>
25
+ <SurfaceCard label="Runs" kind="list" items={runs} empty={null} />
26
+ ```
27
+
28
+ **Valid**
29
+
30
+ ```tsx
31
+ <Section title="Runs" caption="Last 30 days"><DataTable columns={columns} rows={runs} /></Section>
32
+ <Section title="Runs" caption="Last 30 days" kind="list" items={runs} />
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).
@@ -0,0 +1,34 @@
1
+ # Suggestion buttons
2
+
3
+ Law module: `suggestion-buttons.ts`. Finding code: `FE_SUGGESTION_BUTTONS`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#SUGGESTION-BUTTONS`.
4
+
5
+ Suggestions, quick replies and empty-state shortcuts (the assistant drawer, chat composer suggestions) have ONE pattern: a `Cluster gap="inline"` (with a `label`) of neutral `Button size="sm"`. Every Button size draws a pill. The law refuses the alternatives drawn as suggestions: Links, ChoiceChips and Chips that run an action or send their own label.
6
+
7
+ The rule is an error in `coreGrammarConfig`; it cannot be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/suggestion-buttons`
10
+
11
+ Flagged, in cheap static shapes only:
12
+
13
+ - a row (two or more siblings in a Grammar `Cluster` or `Stack`, or a `div`, through fragments, `cond && x`, ternaries and `.map`; or one Link drawn by a `.map`) of Grammar `Link`s whose `onFollow` or `onPress` is an inline arrow passing the Link's own label (`{q}` and `send(q)`, `{item.label}` and `ask(item.label)`, or an equal string literal) and whose `href` is absent or `"#"`;
14
+ - a Grammar `ChoiceChips` whose `onValueChange` is an inline arrow calling something that is not a state setter with the value, or is a bare `send`/`ask`/`submit`/`reply`/`post`/`dispatch` function: it sends the choice instead of keeping it selected;
15
+ - a HeroUI `Chip` (imported from `@heroui/react`) whose `onPress` or `onClick` passes its own label.
16
+
17
+ Grammar `Badge` has no action prop and Grammar `TagGroup` only `onRemove(ids)` and `onReorder(ids)`, so neither is judged. A spread, a computed prop, an unreadable handler, or a callee named `set*`, `on*`, `handle*` or `update*` is not flagged.
18
+
19
+ **Invalid**
20
+
21
+ ```tsx
22
+ <Cluster>{questions.map((q) => <Link key={q} href="#" onFollow={() => send(q)}>{q}</Link>)}</Cluster>
23
+ <ChoiceChips label="Ask" options={options} onValueChange={(v) => send(v)} />
24
+ ```
25
+
26
+ **Valid**
27
+
28
+ ```tsx
29
+ <Cluster gap="inline" label="Suggested questions">
30
+ {questions.map((q) => <Button key={q} size="sm" onPress={() => send(q)}>{q}</Button>)}
31
+ </Cluster>
32
+ ```
33
+
34
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -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" kind="list" items={runs} empty={null} />
25
+ <SurfaceCard label="Runs" kind="list" headers={[{ kind: "filter", /* ... */ }]} items={runs} empty={null} />
26
26
  ```
27
27
 
28
28
  Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -2,13 +2,13 @@
2
2
 
3
3
  Law module: `table-cell-type.ts`. Finding code: `FE_TABLE_CELL_TYPE`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#TABLE-CELL-TYPE`.
4
4
 
5
- The text of a table cell or a list row is read in a column of equals, so it takes the row type sizes: the primary is md 14 / 500 (`<Text isStrong>`), the secondary is sm 13 muted (`<Text size="sm" tone="muted">`). A heading-size Text, a `Heading`, a `Label` or an `h1`-`h6` there is a heading drawn in a list.
5
+ The text of a table cell or a list row is read in a column of equals, so it takes the final type scale: 14px for the text (the primary 14 / 500 `<Text isStrong>`, the secondary 14 muted; `sm` equals `md`) and 12px only for small names (`<Text size="xs" tone="muted">`: meta, count, timestamp). A Text above 14 (`lg`, `xl`, `figure`), a `Heading`, a `Label` or an `h1`-`h6` there is a heading drawn in a list.
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/table-cell-type`
10
10
 
11
- Inside the places below, `Text size="figure"`, any `Heading`, any `Label` and the tags `h1`-`h6` are findings:
11
+ Inside the places below, a `Text` with a literal `size` other than `xs`, `sm` or `md` (`lg`, `xl`, `figure`), any `Heading`, any `Label` and the tags `h1`-`h6` are findings:
12
12
 
13
13
  - the function a `DataTable` takes as `renderCell` (inline, or a function or arrow declared by name in the file), and the `editor` function of a column object in its `columns` literal;
14
14
  - the `title` and `description` of a ListRow data object: a row of the `items` of a list collection (`{ kind: "list", items }`, or `Section` / `SurfaceCard` written `kind="list"`, also through a `.map` callback), or the `row` of a `<ListRow>`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-grammar-core",
3
- "version": "0.28.0",
3
+ "version": "0.32.0",
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": "74626bff437fb2376bf0866421379f7cfc2d4ef8",
72
- "starciSource": "1a0619aae1b449f246a08704001747b28fb0850b77649d37181e6b6c49535eac"
71
+ "gitHead": "8669bbcdf4f3cf117598da2896d5732e865b412a",
72
+ "starciSource": "89a210fd714fe385d9979b0d000234f0cc9387f56d9ba62c8d0bdf46a5475c9e"
73
73
  }
@@ -57,6 +57,15 @@ rules:
57
57
  assert: |-
58
58
  It takes `endArrow`; an arrow typed in its label or passed as end content is refused. A Button that does
59
59
  something takes `startGlyph`; never both.
60
+ - id: SUGGESTION-BUTTONS
61
+ title: Suggestions and quick replies are a Cluster of neutral sm Buttons
62
+ governs: Anything that suggests something to say or ask.
63
+ cases:
64
+ - id: case-1
65
+ when: A suggestion, quick reply or empty-state shortcut is drawn
66
+ assert: |-
67
+ It is a `Cluster gap="inline"` (with `label`) of neutral `Button size="sm"`, which every Button size draws as a
68
+ pill; a Link row, ChoiceChips, TagGroup, Badge or Chip is never a suggestion.
60
69
  - id: TABLE-CELL-TYPE
61
70
  title: Table and row cells take the row type sizes
62
71
  governs: Text inside a DataTable cell or a ListRow.
@@ -64,7 +73,7 @@ rules:
64
73
  - id: case-1
65
74
  when: Text is drawn in a DataTable cell or a ListRow
66
75
  assert: |-
67
- The primary is md 14 / 500, the secondary sm 13 muted; a heading-size Text is refused.
76
+ All text is 14 (the primary 14 / 500, the secondary 14 muted; sm equals md); only a small name (meta, count, timestamp) is 12 (xs). A larger Text, a Heading or a Label is refused.
68
77
  - id: SAME-LINE-SIZE
69
78
  title: One line, one size
70
79
  governs: Text siblings of one inline line.
@@ -72,7 +81,7 @@ rules:
72
81
  - id: case-1
73
82
  when: Texts stand side by side in one Cluster
74
83
  assert: |-
75
- They share one size; a Badge or a chip is exempt.
84
+ They share one size step (14: md and sm are the same; 12: xs; display: figure); a Badge or a chip is exempt.
76
85
  - id: ROW-TITLE-LINK
77
86
  title: A row title is never a link when the row opens
78
87
  governs: The primary of a ListRow or a DataTable row.
@@ -100,3 +109,13 @@ rules:
100
109
  assert: |-
101
110
  The page tabs (`Page header.tabs`) and one region set are the two layers; a third nested set is refused.
102
111
  Every tab is one size, so only the count of layers is judged.
112
+ - id: SINGLE-CHILD-CARD
113
+ title: A table, list or chart standing alone is the surface
114
+ governs: A SurfaceCard whose only content is a table, a list or a chart.
115
+ cases:
116
+ - id: case-1
117
+ when: A card has no zones (headers, footers, head actions) and holds one DataTable, list (ListBox, ItemList, DisclosureList, Timeline, Section kind="list") or chart (BarChart, ProportionBar, BubbleMap, FlowGraph, MermaidDiagram), or is kind="table" or kind="list"
118
+ assert: |-
119
+ The Grammar draws a standalone DataTable and every Section kind="list" as ONE frame (border, card radius), so the
120
+ card is a second frame. The title sits above as a Section head and one caption sits below (Section caption, muted sm).
121
+ A card groups two or more different parts (figures + list + actions), or carries zones (tabs, search, head actions).