@starci/eslint-grammar-core 0.37.3 → 0.38.2

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.
@@ -1,38 +1,26 @@
1
1
  import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
- import { attributeOf, elementNameOf, grammarName, hasSpread, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
2
+ import { attributeOf, elementNameOf, grammarName, hasSpread, renderedChildren } from "./lib/grammar-jsx.js";
3
3
  import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
4
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.
5
+ * The lone surface law (owner, 2026-11-09, SINGLE-CHILD-CARD; aligned 0.37.8): a card groups two or more different parts or carries zones. A card holding a LIST or
6
+ * key-value rows (`SurfaceCard kind="list"`, `kind="table"`, `kind="select"`, a `ListBox`, `DisclosureList`, `Section kind="list"`, a `DescriptionList`) is valid, alone or
7
+ * not: one list card with its head and count chip, or a bordered key-value card on a white aside, is the law. What is wrong is a card wrapping ONE non-list leaf that
8
+ * is a surface on its own: a `DataTable` (standalone it draws its own card) or a chart. The title sits above it as a `Section` head.
10
9
  *
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"`.
10
+ * WHAT IT READS. A Grammar `SurfaceCard` (imported from `@starci/grammar`) with no zones: no `headers` or `footers` prop (an empty array literal counts as none) and no
11
+ * `labelEnd` (head actions). Its body is read through fragments, `cond && <x/>`, `cond ? <x/> : <y/>` and `.map`, ignoring blank text. It is refused when that body is ONE
12
+ * element and that element is a `DataTable` or a chart: `BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`.
18
13
  *
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.
14
+ * DECIDED. Lists and key-value rows are never refused here. `Meter`, `Progress` and `ProgressCircle` are single values, not charts. `SurfaceCard kind="figures"`, `details`,
15
+ * `accordion`, `list`, `table`, `select` and `tile` are not judged. Kinds, depth and nesting stay with `surface-card-kind`, `no-raised-surface-in-surface` and `surface-depth`.
23
16
  *
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.
17
+ * WHAT IT LEAVES ALONE. A card with two or more body children, a card with zones or `labelEnd`, a card with a JSX spread, a non-Grammar `SurfaceCard`, and non-product source.
26
18
  *
27
19
  * WHERE IT APPLIES. Product source (`isProductSource`).
28
20
  */
29
21
  /** The table, list and chart components that are a surface on their own, with the word the message names them by. */
30
22
  const LONE = new Map([
31
23
  ["DataTable", "table"],
32
- ["ListBox", "list"],
33
- ["ItemList", "list"],
34
- ["DisclosureList", "list"],
35
- ["Timeline", "list"],
36
24
  ["BarChart", "chart"],
37
25
  ["ProportionBar", "chart"],
38
26
  ["BubbleMap", "chart"],
@@ -63,18 +51,16 @@ const loneChild = (context, card) => {
63
51
  const name = elementNameOf(child);
64
52
  if (name === null || grammarName(context, child.openingElement) === null)
65
53
  return null;
66
- if (name === "Section")
67
- return stringProp(child.openingElement, "kind") === "list" ? "Section kind=\"list\"" : null;
68
54
  return LONE.has(name) ? name : null;
69
55
  };
70
- /** A table, list or chart standing alone is the surface, never wrapped in a card. */
56
+ /** A table component or a chart standing alone is the surface, never wrapped in a card; list cards are valid. */
71
57
  export const singleChildCard = defineRule({
72
58
  meta: {
73
59
  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." },
60
+ docs: { description: "SINGLE-CHILD-CARD: a SurfaceCard with no zones whose only content is a DataTable or a chart is a second frame; a card holding list or key-value rows is valid." },
75
61
  schema: [],
76
62
  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).",
63
+ 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); a card of list or key-value rows is always valid.",
78
64
  },
79
65
  },
80
66
  create(context) {
@@ -85,11 +71,10 @@ export const singleChildCard = defineRule({
85
71
  const opening = element.openingElement;
86
72
  if (grammarName(context, opening) !== "SurfaceCard" || hasSpread(opening) || hasZones(opening))
87
73
  return;
88
- const kind = stringProp(opening, "kind");
89
- const child = kind === "table" || kind === "list" ? kind : loneChild(context, element);
74
+ const child = loneChild(context, element);
90
75
  if (child === null)
91
76
  return;
92
- context.report({ node: opening, messageId: "lone", data: { child: kind === child ? child : `\`${child}\`` } });
77
+ context.report({ node: opening, messageId: "lone", data: { child: `\`${child}\`` } });
93
78
  },
94
79
  };
95
80
  },
@@ -3,21 +3,19 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
3
3
  import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
4
4
  /**
5
5
  * The surface nesting law (HFS R340 `FE_RAISED_SURFACE_IN_SURFACE`): a surface never stands inside another surface. A
6
- * `SurfaceCard` inside another `SurfaceCard`, inside a `Pane surface`, or inside a `Dialog`, `Drawer`, `AlertDialog` or
7
- * `Popover` is refused; the Grammar has one depth, raised, and draws no nested edge: a surface never
8
- * sits in a surface, dialogs and drawers included. The Grammar throws the same refusal in development; this is its
6
+ * `SurfaceCard` inside another `SurfaceCard` is refused (0.37.5, owner: a card inside a card is the only nesting refused; a white `Pane surface`, `Drawer`,
7
+ * `Dialog` or `Popover` hosts cards, drawn bordered with no shadow). The Grammar throws the same refusal in development; this is its
9
8
  * same-file half, and R356 closes it across files.
10
9
  *
11
10
  * WHAT IT READS. A `SurfaceCard` element (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that a `SurfaceCard`,
12
- * `Dialog`, `Drawer`, `AlertDialog`, `Popover` or `Pane` with a `surface` prop of the same file encloses. An overlay's
13
- * `trigger` is not its content, so a card written in a trigger is not enclosed by it. A surface nobody encloses in this file
11
+ * `SurfaceCard` of the same file encloses. A surface nobody encloses in this file
14
12
  * (its parent may nest it) is judged where the parent is written.
15
13
  *
16
14
  * WHERE IT APPLIES. Product source (`isProductSource`).
17
15
  */
18
16
  const GRAMMAR_SOURCE = /^@starci\/grammar(?:\/(?:common|core|offset-pop))?$/;
19
17
  /** Surfaces and overlays whose content is a surface. */
20
- const HOSTS = new Set(["SurfaceCard", "Dialog", "Drawer", "AlertDialog", "Popover", "Pane"]);
18
+ const HOSTS = new Set(["SurfaceCard"]);
21
19
  /** The element name of a JSX name: `SurfaceCard`, or `G.SurfaceCard` as `SurfaceCard`. */
22
20
  const nameOf = (name) => {
23
21
  if (name.type === "JSXIdentifier")
@@ -65,7 +63,7 @@ const enclosingHost = (context, opening) => {
65
63
  export const noRaisedSurfaceInSurface = defineRule({
66
64
  meta: {
67
65
  type: "problem",
68
- docs: { description: "R340: a SurfaceCard never stands inside another SurfaceCard, a Pane surface, or a Dialog, Drawer, AlertDialog or Popover." },
66
+ docs: { description: "R340: a SurfaceCard never stands inside another SurfaceCard." },
69
67
  schema: [],
70
68
  messages: {
71
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.",
package/dist/tabs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from "eslint";
2
- /** No pill in JSX: the pill is the `switch` header zone of a card. */
2
+ /** No pill in JSX: the pill is the `switch` header zone of a card, 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;
package/dist/tabs.js CHANGED
@@ -6,8 +6,10 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
6
6
  *
7
7
  * `tabs-switch-zone`. The pill (`Tabs appearance="primary"`) is a mode or period switch of one block. The Grammar draws it
8
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. The
10
- * item checks (two to four, no count, no href) stay in `no-primary-tabs-misuse`.
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`.
11
13
  *
12
14
  * `tabs-depth`. A page stacks at most two underline layers: the page tabs (`Page header.tabs`) and one region set. A `Tabs`
13
15
  * is nested in another when it stands in the panel the other selects: inside a conditional or `&&` whose test reads the
@@ -34,17 +36,39 @@ const literalOf = (attribute) => {
34
36
  };
35
37
  /** Whether a `Tabs` element draws the pill. */
36
38
  const isPill = (opening) => literalOf(attributeOf(opening, "appearance")) === "primary";
37
- /** No pill in JSX: the pill is the `switch` header zone of a card. */
39
+ /** Whether a node is an object property whose key is `control`. */
40
+ const isControlProperty = (node) => node.type === "Property" && !node.computed && ((node.key.type === "Identifier" && node.key.name === "control") || (node.key.type === "Literal" && node.key.value === "control"));
41
+ /**
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
44
+ * merely wraps the pill is not the slot.
45
+ */
46
+ const isRowControl = (opening) => {
47
+ let child = opening.parent ?? opening;
48
+ for (let node = child.parent; node !== undefined && node !== null; child = node, node = node.parent) {
49
+ if (node.type === "JSXFragment" || node.type === "JSXExpressionContainer")
50
+ continue;
51
+ if (node.type === "ConditionalExpression" && child !== node.test)
52
+ continue;
53
+ if (node.type === "LogicalExpression" && child === node.right)
54
+ continue;
55
+ if (node.type === "JSXAttribute")
56
+ return node.name.type === "JSXIdentifier" && node.name.name === "control";
57
+ return isControlProperty(node) && node.value === child;
58
+ }
59
+ return false;
60
+ };
61
+ /** No pill in JSX: the pill is the `switch` header zone of a card, or the value of a row `control`. */
38
62
  export const tabsSwitchZone = defineRule({
39
63
  meta: {
40
64
  type: "problem",
41
65
  docs: {
42
- description: "A pill (Tabs appearance=\"primary\") stands only as the switch header zone of a SurfaceCard; written in JSX anywhere else it is a finding.",
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.",
43
67
  url: "knowledge/ui/presentation/grammar-laws.yaml#TABS-SWITCH-ZONE",
44
68
  },
45
69
  schema: [],
46
70
  messages: {
47
- 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. 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`.",
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`.",
48
72
  },
49
73
  },
50
74
  create(context) {
@@ -52,7 +76,7 @@ export const tabsSwitchZone = defineRule({
52
76
  return {};
53
77
  return {
54
78
  JSXOpeningElement(opening) {
55
- if (elementName(opening) !== "Tabs" || !isPill(opening))
79
+ if (elementName(opening) !== "Tabs" || !isPill(opening) || isRowControl(opening))
56
80
  return;
57
81
  context.report({ node: opening, messageId: "pill" });
58
82
  },
@@ -0,0 +1,37 @@
1
+ # Message surfaces
2
+
3
+ Law module: `message-surfaces.ts`. Finding code: `FE_MESSAGE_SURFACES`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#MESSAGE-SURFACES`. Grammar laws: `DNA-COMMON-CHAT-SURFACES` (0.37.31), `DNA-COMMON-CHAT-FRAME` (0.37.33).
4
+
5
+ Every chat (team chat, an agent's chat, an inbox thread, the assistant) draws the same three faces, and they belong to the Grammar: the thread is the page tone (`--background`; a `PaneSection scroll role="log"` paints it whatever `tone` says), a message of someone else (`MessageBubble` incoming, `MessageCard`) is the flat `--surface` with no border and no shadow, and the reader's own message is `--accent` with `--accent-foreground`. The replies a message card offers are `SurfaceCard kind="list" layout="suggestions"` (one bordered list, a pressable plain-text row per reply with a chevron); the pills by the composer stay `Button size="sm"` (`suggestion-buttons`).
6
+
7
+ A chat is one frame on any page (0.37.33): its head, its thread and its composer footer are `--background`, whether it stands in a white pane, the aside, a drawer, a dialog or a popover; the rest of the page keeps its own rule. The frame is a `Pane content="chat"` (a pane whose own stack holds a thread is drawn as one too); the app gives it no tone, and a message in it is flat (no border, no shadow).
8
+
9
+ The rule is an error in `coreGrammarConfig`; it cannot be switched off or suppressed inline.
10
+
11
+ ## `starci-grammar/message-surfaces`
12
+
13
+ Flagged, in cheap static shapes only:
14
+
15
+ - a `className`, `class`, `style`, `UNSAFE_className` or `UNSAFE_style` attribute on a Grammar `MessageBubble` or `MessageCard`;
16
+ - a static class string (an attribute, a template without expressions, a `cn`/`clsx`/`cx`/`classNames`/`twMerge`/`twJoin` argument) or a style key in product source that names a Grammar message part (`starci-core-message-bubble…`, `starci-core-message-card…`);
17
+ - a `PaneSection` whose `scroll` object literal states `role: "log"` together with `tone: "surface"` (the Grammar ignores it: a thread is always the page tone);
18
+ - `surface` on a chat frame: a `Pane` with `content="chat"`, or a `Pane` whose own JSX children (fragments opened) hold a `PaneSection` with `scroll.role: "log"` (the frame is `--background`; the Grammar ignores the tone).
19
+
20
+ A spread, a computed class and a tone held in a variable are not read; a thread drawn by a component of the app's own (a `ChatThreadBand`) is not seen through, so such a pane states `content="chat"`.
21
+
22
+ **Invalid**
23
+
24
+ ```tsx
25
+ <MessageBubble className="shadow-none" body={text} />
26
+ <div className="[&_.starci-core-message-bubble-body]:bg-white">{thread}</div>
27
+ <PaneSection scroll={{ label: "Thread", role: "log", tone: "surface" }}>{thread}</PaneSection>
28
+ <Pane area="room" surface content="chat" footer={composer}>{head}{thread}</Pane>
29
+ ```
30
+
31
+ **Valid**
32
+
33
+ ```tsx
34
+ <Pane area="room" content="chat" label="Phòng" footer={composer}>{head}{thread}</Pane>
35
+ <PaneSection scroll={{ label: "Thread", role: "log", align: "end" }}>{thread}</PaneSection>
36
+ <MessageCard title="Quy trình đang dừng" body={<SurfaceCard kind="list" layout="suggestions" ariaLabel="Gợi ý" empty={null} items={replies} />} />
37
+ ```
@@ -0,0 +1,25 @@
1
+ # A card has no description
2
+
3
+ Law module: `no-card-lead-description.ts`. Finding code: `FE_NO_CARD_LEAD_DESCRIPTION`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#CARD-NO-DESCRIPTION`.
4
+
5
+ A card head is its label, a count chip, one fact and one end action. It has no description or subtitle (the `SurfaceCard` type has no such prop). A line that explains the card's data (a legend, a source, a period) is the card `note`; a line that explains a row is that row's subtitle.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/no-card-lead-description`
10
+
11
+ A Grammar `Text` with `tone="muted"` written immediately before a Grammar `SurfaceCard` in the same children list (message `lead`). A muted `Text` anywhere else, a native `<p>` and any other tone are not read.
12
+
13
+ **Invalid**
14
+
15
+ ```tsx
16
+ <Stack><Heading level={3}>Chung</Heading><Text tone="muted">Chọn cách agent làm việc.</Text><SurfaceCard kind="select" label="Chế độ" ... /></Stack>
17
+ ```
18
+
19
+ **Valid**
20
+
21
+ ```tsx
22
+ <SurfaceCard kind="select" label="Chế độ" items={[{ id: "auto", title: "Tự làm", subtitle: "Agent trả lời ngay, bạn xem lại sau." }]} ... />
23
+ ```
24
+
25
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -0,0 +1,30 @@
1
+ # One Label per section
2
+
3
+ Law module: `no-nested-label.ts`. Finding code: `FE_NO_NESTED_LABEL`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#LABEL-SUBLABEL-HIERARCHY`.
4
+
5
+ A section has exactly ONE Label (its head, 14 / 500, 12px above its content). The groups inside it are named by a Sublabel (12 / 500 muted, 8px above the card): a `Section` or `SurfaceCard` takes `sublabel` and then has no `title` / `label` (the types refuse both together). Groups stand 24px apart.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/no-nested-label`
10
+
11
+ A Grammar `Section` with `title`, or a `SurfaceCard` with `label`, whose JSX ancestor in the same file is a Grammar `Section` with `title` or `SurfaceCard` with `label` (message `nested`). Nesting across files and elements passed as attribute values are not read.
12
+
13
+ **Invalid**
14
+
15
+ ```tsx
16
+ <Section title="Agent hiểu gì về việc của bạn">
17
+ <SurfaceCard kind="select" label="Được tự làm" ... />
18
+ </Section>
19
+ ```
20
+
21
+ **Valid**
22
+
23
+ ```tsx
24
+ <Section title="Agent hiểu gì về việc của bạn">
25
+ <SurfaceCard kind="select" sublabel="Được tự làm" ... />
26
+ <SurfaceCard kind="select" sublabel="Phải hỏi bạn" ... />
27
+ </Section>
28
+ ```
29
+
30
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -0,0 +1,25 @@
1
+ # Rows of data are always a card
2
+
3
+ Law module: `rows-in-card.ts`. Finding code: `FE_ROWS_IN_CARD`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#ROWS-IN-CARD`.
4
+
5
+ A list of rows or key-value rows is a card: on the pink well a shadow and no border, on a white surface (aside, pane, drawer) a 1px border and no shadow. Grammar draws that edge itself when the rows stand in a `Section` or a `SurfaceCard`.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/rows-in-card`
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.
12
+
13
+ **Invalid**
14
+
15
+ ```tsx
16
+ <Stack><DescriptionList items={items} /></Stack>
17
+ ```
18
+
19
+ **Valid**
20
+
21
+ ```tsx
22
+ <SurfaceCard label="Details"><DescriptionList items={items} /></SurfaceCard>
23
+ ```
24
+
25
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -2,19 +2,20 @@
2
2
 
3
3
  Law module: `section-head-action.ts`. Finding code: `FE_SECTION_HEAD_ACTION`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#SECTION-HEAD-ACTION`.
4
4
 
5
- A `Section` head is ONE row: the label (14, weight 500) and an optional count chip at the start, and at the end at most ONE thing: a navigation `Link variant="head"` (the label then an arrow that slides about 3px on hover) or an info `IconButton`. A `description` is not under the label: it is a caption below the body.
5
+ A `Section` head is ONE row: the label (14, weight 500) and an optional count chip at the start, and at the end at most ONE thing: a navigation `Link variant="head"` (the label then an arrow that slides about 3px on hover), an info `IconButton`, or a neutral small text `Button` (0.37.25). A `description` is not under the label: it is a caption below the body.
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/section-head-action`
10
10
 
11
- - A Grammar `Button` inside a `Section`'s `action` prop (message `button`): navigation is a `Link`.
11
+ - A Grammar `Button` inside a `Section`'s `action` prop that is not exactly `intent="neutral" size="sm"` (message `button`), or that carries an icon prop (`startGlyph`, `startContent`, `endContent`, `icon`; message `icon`).
12
12
  - More than one Grammar `Button`, `Link`, `IconButton` or `TextAction` inside that `action` (message `many`).
13
13
 
14
14
  **Invalid**
15
15
 
16
16
  ```tsx
17
- <Section title="Runs" action={<Button size="sm" onPress={open}>Open</Button>}>...</Section>
17
+ <Section title="Runs" action={<Button intent="commit" size="sm" onPress={open}>Open</Button>}>...</Section>
18
+ <Section title="Runs" action={<Button intent="neutral" size="sm" startGlyph="plus" onPress={open}>Add</Button>}>...</Section>
18
19
  <Section title="Runs" action={<><Link href="/a">A</Link><IconButton label="About" glyph="more" /></>}>...</Section>
19
20
  ```
20
21
 
@@ -23,6 +24,7 @@ Every rule below is an error in `coreGrammarConfig`; none can be switched off or
23
24
  ```tsx
24
25
  <Section title="Runs" count={3} action={<Link variant="head" href="/runs">All runs</Link>}>...</Section>
25
26
  <Section title="Runs" action={<IconButton label="About runs" glyph="more" />}>...</Section>
27
+ <Section title="Provider" count={2} action={<Button intent="neutral" size="sm" onPress={add}>Gắn thêm provider</Button>}>...</Section>
26
28
  ```
27
29
 
28
30
  Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -1,35 +1,33 @@
1
- # A table, list or chart standing alone is the surface
1
+ # A lone DataTable or chart is the surface; a list card is always valid
2
2
 
3
3
  Law module: `single-child-card.ts`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#SINGLE-CHILD-CARD`. Finding code: `FE_SINGLE_CHILD_CARD`.
4
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.
5
+ A card (`SurfaceCard`) groups two or more different parts (figures + list + actions), or carries zones (tabs, search, head actions). A card of LIST or key-value rows (`kind="list"`, `kind="table"`, `kind="select"`, a `ListBox`, `DisclosureList`, `Timeline`, `Section kind="list"`, a `DescriptionList`) is valid alone or not (aligned in 0.37.8: one list card with its head and count chip, or a bordered key-value card on a white aside, is the law). A standalone `DataTable` (`surface="card"`) or chart IS the surface: its title sits above it as a `Section` head and one line under it as `Section caption`, so a card around it is a second card.
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/single-child-card`
10
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:
11
+ A Grammar `SurfaceCard` is refused when it has no zones (no `headers` or `footers` prop, an empty array counts as none, and no `labelEnd`) and its only body child (looked through fragments, `cond && x`, `cond ? x : y` and `.map`; blank text ignored) is:
12
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).
13
+ - table: `DataTable`
14
+ - chart: `BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`
18
15
 
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.
16
+ Not flagged: any list or key-value card (`kind="list"`, `kind="table"`, `kind="select"`, `ListBox`, `DisclosureList`, `Timeline`, `Section kind="list"`, `DescriptionList`), a card with two or more body children, a card with zones or `labelEnd`, a card with a JSX spread, `kind` `figures`, `details`, `accordion` or `tile`, a non-Grammar `SurfaceCard`, and non-product source. `Meter` and `Progress` are single values, not charts.
20
17
 
21
18
  **Invalid**
22
19
 
23
20
  ```tsx
24
21
  <SurfaceCard label="Runs"><DataTable columns={columns} rows={runs} /></SurfaceCard>
25
- <SurfaceCard label="Runs" kind="list" items={runs} empty={null} />
22
+ <SurfaceCard label="Usage"><BarChart data={usage} /></SurfaceCard>
26
23
  ```
27
24
 
28
25
  **Valid**
29
26
 
30
27
  ```tsx
31
28
  <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} />
29
+ <SurfaceCard label="Runs" kind="list" items={runs} empty={null} />
30
+ <SurfaceCard label="Runs"><ListBox items={runs} /></SurfaceCard>
33
31
  <SurfaceCard label="Runs" headers={[{ kind: "search", /* ... */ }]}><DataTable columns={columns} rows={runs} /></SurfaceCard>
34
32
  <SurfaceCard label="Runs"><Text>3 failed</Text><DataTable columns={columns} rows={runs} /></SurfaceCard>
35
33
  ```
@@ -2,10 +2,7 @@
2
2
 
3
3
  Law module: `surface-depth.ts`. Catalogue: R340 FE_RAISED_SURFACE_IN_SURFACE.
4
4
 
5
- The Grammar draws one depth, raised, and no nested edge: a `SurfaceCard` inside another `SurfaceCard`, inside a
6
- `Pane surface`, or inside a `Dialog`, `Drawer`, `AlertDialog` or `Popover` is refused: a surface
7
- never sits in a surface, dialogs and drawers included. Development throws the same refusal from the Grammar itself; this rule is
8
- its same-file half and R356 closes it across files.
5
+ A `SurfaceCard` inside another `SurfaceCard` is refused (0.37.5): a card never sits in a card. A white `Pane surface`, `Drawer`, `Dialog`, `AlertDialog` or `Popover` HOSTS cards: on a white ground a card is the group and draws a 1px border with no shadow (SURFACE-ELEVATION); on the pink well it has the shadow and no border. Development throws the card-in-card refusal from the Grammar itself; this rule is its same-file half and R356 closes it across files.
9
6
 
10
7
  Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline. It applies to product
11
8
  source (the route, feature, component, hook, foundation, module and transport tiers and the workspace packages); a script or
@@ -13,11 +10,7 @@ a file no slot owns is not judged.
13
10
 
14
11
  ## `starci-grammar/no-raised-surface-in-surface`
15
12
 
16
- A `SurfaceCard` (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that a `SurfaceCard`, `Dialog`, `Drawer`,
17
- `AlertDialog`, `Popover`, or a `Pane` with a `surface` prop of the same file encloses is a finding. An overlay's `trigger` is
18
- not its content, so a card written in a trigger is not enclosed by it. A surface no element of the file encloses is judged
19
- where its parent is written. The fix gives the content to the host's own body, or uses a kind of the outer card (`bands`,
20
- `list`, `figures`) for what needs its own faces.
13
+ A `SurfaceCard` (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that another `SurfaceCard` of the same file encloses is a finding. A card no element of the file encloses is judged where its parent is written. The fix gives the content to the outer card's own body, or uses a kind of the outer card (`bands`, `list`, `figures`) for what needs its own faces.
21
14
 
22
15
  **Invalid** (`src/components/blocks/Runs/component.tsx`)
23
16
 
package/docs/tabs.md CHANGED
@@ -6,7 +6,7 @@ Underline tabs switch panels: the page tabs (`Page header.tabs`) and, inside a t
6
6
 
7
7
  ## `starci-grammar/tabs-switch-zone`
8
8
 
9
- Finding code: `FE_TABS_SWITCH_ZONE`. A `<Tabs appearance="primary">` written in JSX is a finding wherever it stands (a page body, under the page tabs, a pane, a drawer). The pill is drawn only as the `switch` header zone of a card, which has no JSX to write. The item checks (two to four options, no `count`, `href` or `isAttention`) stay in `no-primary-tabs-misuse` (R380).
9
+ Finding code: `FE_TABS_SWITCH_ZONE`. A `<Tabs appearance="primary">` written in JSX is a finding wherever it stands (a page body, under the page tabs, a pane, a drawer). The pill is drawn as the `switch` header zone of a card, which has no JSX to write, and, since 0.37.16, as the value of a row `control` (an object property named `control` in a select item or list row literal, or a JSX attribute `control={...}`, directly or through a fragment, conditional or `&&`): a row-level mode choice such as "Auto | Ask" lives in the row. The item checks (two to four options, no `count`, `href` or `isAttention`) stay in `no-primary-tabs-misuse` (R380).
10
10
 
11
11
  **Invalid**
12
12
 
@@ -19,6 +19,7 @@ Finding code: `FE_TABS_SWITCH_ZONE`. A `<Tabs appearance="primary">` written in
19
19
  **Valid**
20
20
 
21
21
  ```tsx
22
+ <SurfaceCard kind="select" label="Agent" selectionMode="multiple" items={[{ id: "send", title: "Send", control: <Tabs appearance="primary" label="Send" items={modes} selectedKey={mode} onSelect={setMode} /> }]} value={value} onChange={setValue} />
22
23
  <SurfaceCard kind="list" label="Cash" headers={[{ kind: "switch", label: "Period", items: periods, selectedKey: period, onSelect: setPeriod }]} items={rows} empty={empty} />
23
24
  ```
24
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-grammar-core",
3
- "version": "0.37.3",
3
+ "version": "0.38.2",
4
4
  "description": "ESLint rules for the core Grammar's component, token and composition contracts.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -41,8 +41,8 @@
41
41
  "node": ">=22"
42
42
  },
43
43
  "peerDependencies": {
44
- "@starci/eslint-canon-fe": "~9.16.0",
45
- "@starci/hfs": "~6.6.0",
44
+ "@starci/eslint-canon-fe": "~9.17.0",
45
+ "@starci/hfs": "~6.9.0",
46
46
  "eslint": ">=9",
47
47
  "typescript": ">=5.9"
48
48
  },
@@ -67,5 +67,7 @@
67
67
  "eslint": "^9.18.0",
68
68
  "eslint-plugin-react-hooks": "^7.1.1",
69
69
  "typescript": "^6.0.3"
70
- }
70
+ },
71
+ "gitHead": "85b3f8e7f6c3e4d1e7eb6f0ce3d9e98bf985daf7",
72
+ "starciSource": "892760c1cfe2cf52602f7cf3ceaac2936b9019c557017e68a5ebaeaa42773713"
71
73
  }
@@ -77,6 +77,27 @@ rules:
77
77
  assert: |-
78
78
  It is a workspace page, `Page chrome="panes"`: a grid of panes split by dividers, side panes white surfaces at full
79
79
  height, never cards. The main pane may hold a pink well that follows case-1.
80
+ - id: MESSAGE-SURFACES
81
+ title: Every chat draws Grammar's three faces and an app never restyles them
82
+ governs: A chat thread, the messages in it and the replies a message card offers.
83
+ cases:
84
+ - id: case-1
85
+ when: A chat thread with messages is drawn (team chat, an agent's chat, an inbox thread, the assistant)
86
+ assert: |-
87
+ The thread is a `PaneSection scroll role="log"` on the page tone `--background`; a message of someone else
88
+ (`MessageBubble` incoming, `MessageCard`) is the flat `--surface` with no border and no shadow; the reader's own
89
+ message is `--accent` with `--accent-foreground`. No class or style reaches a bubble, a card or the thread ground.
90
+ - id: case-2
91
+ when: A message card offers replies to send
92
+ assert: |-
93
+ They are one bordered list, `SurfaceCard kind="list" layout="suggestions"`, a plain-text row per reply whose whole
94
+ row sends it, with a trailing chevron; the suggestion pills by the composer stay `Button size="sm"`.
95
+ - id: case-3
96
+ when: A chat is drawn on any page (the chat page, an inbox thread between a list and an aside, an agent's chat tab, an aside or a drawer)
97
+ assert: |-
98
+ The chat is one frame, `Pane content="chat"` (head, thread, composer `footer`), painted `--background` as a whole
99
+ whatever it stands on; it states no `surface`. The rest of the page keeps its own rule (a room list stays white).
100
+ The composer field stays white, the 1px lines between the zones stay, and every message in the frame is flat.
80
101
  - id: SUGGESTION-BUTTONS
81
102
  title: Suggestions and quick replies are a Cluster of neutral sm Buttons
82
103
  governs: Anything that suggests something to say or ask.
@@ -148,6 +169,33 @@ rules:
148
169
  assert: |-
149
170
  It is HeroUI v3's link: the primary colour, the underline on hover only, the anchor icon at the end. Its type size and leading are
150
171
  inherited (14 in a body, 12 in meta or caption text). A size prop, a size class and an underline or decoration class are refused.
172
+ - id: ROWS-IN-CARD
173
+ title: Rows of data are always a card
174
+ governs: A list of rows or key-value rows on the well or on a white surface.
175
+ cases:
176
+ - id: case-1
177
+ when: A DescriptionList or DisclosureList is drawn
178
+ assert: |-
179
+ It stands in a Section or a SurfaceCard, so it is a card: a shadow and no border on the pink well, a 1px border and no shadow on a white
180
+ surface (aside, pane, drawer); Grammar draws that edge itself. A row primitive with no card around it is refused. ListBox is a navigation list and is not read.
181
+ - id: CARD-NO-DESCRIPTION
182
+ title: A card has no description
183
+ governs: The head of a SurfaceCard and the line above it.
184
+ cases:
185
+ - id: case-1
186
+ when: A card is drawn with a label
187
+ assert: |-
188
+ The head is the label, a count chip, one fact and one end action; SurfaceCard has no description or subtitle prop. A muted Text written directly above a
189
+ SurfaceCard as its description is refused: the line is a row subtitle (select or list) or, when it explains the card's data, the card note.
190
+ - id: LABEL-SUBLABEL-HIERARCHY
191
+ title: One Label per section; nested groups use a Sublabel
192
+ governs: The Label of a Section or SurfaceCard and the Sublabel of the groups inside it.
193
+ cases:
194
+ - id: case-1
195
+ when: A labelled section holds groups of cards
196
+ assert: |-
197
+ The section has exactly one Label (14 / 500, 12px above its content). Each group inside it is a Section or SurfaceCard with `sublabel` (12 / 500 muted, 8px above its card),
198
+ never a second `title` / `label`; groups stand 24px apart. A Section or SurfaceCard with `sublabel` and a Label together is refused by the types.
151
199
  - id: SECTION-HEAD-ACTION
152
200
  title: A section head is one row with at most one thing at its end
153
201
  governs: The head of a Grammar Section.
@@ -156,8 +204,8 @@ rules:
156
204
  when: A Section head carries an action
157
205
  assert: |-
158
206
  The head is ONE row: the label (14, 500) and an optional count chip (12) at the start, at most ONE thing at the end, a navigation
159
- Link variant="head" (the label then an arrow that slides about 3px on hover) or an info IconButton. A Button is refused (navigation is a
160
- Link) and so are two commands. There is no description under the label: it is a caption (12, muted) below the card or list.
207
+ Link variant="head" (the label then an arrow that slides about 3px on hover), an info IconButton, or (0.37.25) a neutral small text Button
208
+ (intent neutral, size sm, no icon: "Gắn thêm provider"). A primary or commit Button, another size or an icon Button is refused, and so are two commands. There is no description under the label: it is a caption (12, muted) below the card or list.
161
209
  - id: TAB-COUNT-CHIP
162
210
  title: A tab count is a 12px chip, grey unless it is work waiting for the owner
163
211
  governs: The count on a Grammar tab, page layers 1 and 2 and filter tabs.
@@ -196,15 +244,15 @@ rules:
196
244
  label, a search field, a button start icon, a link arrow, meta) is a plain outline icon at text size with no tile. A status (done, running, failed, waiting,
197
245
  skipped) is a tone-coloured outline icon with no tile: outline check-circle in success, x-circle in danger, a spinning arrow for running.
198
246
  - id: SINGLE-CHILD-CARD
199
- title: A table, list or chart standing alone is the surface
200
- governs: A SurfaceCard whose only content is a table, a list or a chart.
247
+ title: A lone DataTable or chart is the surface; a list card is always valid
248
+ governs: A SurfaceCard whose only content is a DataTable or a chart (a list or key-value card is valid, 0.37.8).
201
249
  cases:
202
250
  - id: case-1
203
- 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"
251
+ when: A card has no zones (headers, footers, head actions) and holds one DataTable or chart (BarChart, ProportionBar, BubbleMap, FlowGraph, MermaidDiagram)
204
252
  assert: |-
205
- The Grammar draws a standalone DataTable and every Section kind="list" as ONE frame (border, card radius), so the
206
- card is a second frame. The title sits above as a Section head and one caption sits below (Section caption, muted sm).
207
- A card groups two or more different parts (figures + list + actions), or carries zones (tabs, search, head actions).
253
+ A standalone DataTable and chart is ONE frame (border, card radius), so the card is a second frame. The title sits above as a Section head and one caption
254
+ sits below (Section caption, muted sm). A card of list or key-value rows (SurfaceCard kind="list", "table", "select", ListBox, DisclosureList, Section kind="list",
255
+ DescriptionList) is valid alone or not (0.37.8). A card groups two or more different parts (figures + list + actions), or carries zones (tabs, search, head actions).
208
256
  - id: NO-RAW-SCROLL
209
257
  title: NIVO never shows scrollbars
210
258
  governs: Scroll areas an app draws.