@starci/eslint-grammar-core 0.30.0 → 0.34.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.
@@ -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"]));
@@ -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))
package/dist/tabs.d.ts CHANGED
@@ -3,6 +3,12 @@ import type { Rule } from "eslint";
3
3
  export declare const tabsSwitchZone: Rule.RuleModule;
4
4
  /** At most two underline layers. */
5
5
  export declare const tabsDepth: Rule.RuleModule;
6
+ /**
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
+ * 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. A drawer, dialog, modal, popover or sheet starts its own surface.
10
+ */
11
+ export declare const tabsInWell: Rule.RuleModule;
6
12
  /** The rules this law contributes to the plugin. */
7
13
  export declare const rules: Record<string, Rule.RuleModule>;
8
14
  /** Every rule of this law is an error. */
package/dist/tabs.js CHANGED
@@ -137,10 +137,55 @@ export const tabsDepth = defineRule({
137
137
  };
138
138
  },
139
139
  });
140
+ /** The pink well and the panes: underline Tabs written in their children sit on the well, not in the white header band. */
141
+ const WELL_HOSTS = new Set(["Page", "Pane", "PaneSection"]);
142
+ /**
143
+ * The second tab layer stands in the white header band (owner, 2026-11-09, TABS-IN-WELL): `Page header={{ tabs, subTabs }}`, on its own
144
+ * full-width separator, flush with the band's left inset. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection`
145
+ * stands on the pink well or in a pane body, so it is a finding. A drawer, dialog, modal, popover or sheet starts its own surface.
146
+ */
147
+ export const tabsInWell = defineRule({
148
+ meta: {
149
+ type: "problem",
150
+ docs: {
151
+ description: "An underline Tabs stands in the white header band (Page header.subTabs), never in the pink well or a pane body.",
152
+ url: "knowledge/ui/presentation/grammar-laws.yaml#TABS-IN-WELL",
153
+ },
154
+ schema: [],
155
+ messages: {
156
+ 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 make the views a `switch` zone or a filter zone of a card.",
157
+ },
158
+ },
159
+ create(context) {
160
+ if (!isProductSource(context))
161
+ return {};
162
+ return {
163
+ JSXOpeningElement(opening) {
164
+ if (elementName(opening) !== "Tabs" || isPill(opening))
165
+ return;
166
+ let child = opening.parent ?? opening;
167
+ for (let node = child.parent; node !== undefined && node !== null; child = node, node = node.parent) {
168
+ if (node.type !== "JSXElement")
169
+ continue;
170
+ const name = elementName(node.openingElement);
171
+ if (name === null)
172
+ continue;
173
+ if (SURFACE_BOUNDARIES.has(name) || name === "SurfaceCard")
174
+ return;
175
+ if (WELL_HOSTS.has(name) && node.children.includes(child)) {
176
+ context.report({ node: opening, messageId: "well", data: { host: name } });
177
+ return;
178
+ }
179
+ }
180
+ },
181
+ };
182
+ },
183
+ });
140
184
  /** The rules this law contributes to the plugin. */
141
185
  export const rules = {
142
186
  "tabs-switch-zone": tabsSwitchZone,
143
187
  "tabs-depth": tabsDepth,
188
+ "tabs-in-well": tabsInWell,
144
189
  };
145
190
  defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#TABS-SWITCH-ZONE");
146
191
  /** Every rule of this law is an error. */
@@ -2,9 +2,9 @@
2
2
 
3
3
  Law module: `button-arrow.ts`. Finding code: `FE_BUTTON_ARROW`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#BUTTON-ARROW`.
4
4
 
5
- A Button that leads somewhere (a page, a tab, a next step) ends with the Grammar arrow: `endArrow`. It slides toward the reading end on hover and focus and is mirrored in RTL. A Button that does something starts with a `startGlyph`. A typed `→` or a passed-in arrow icon does neither, so the law refuses them. Start and end keep their meaning: the start says what the action is, the end says where it goes.
5
+ A Button that leads somewhere (a page, a tab, a next step) ends with the Grammar arrow: `endArrow`. It slides toward the reading end on hover and focus and is mirrored in RTL. A primary Button that does something may start with a `startGlyph`. A typed `→` or a passed-in arrow icon does neither, so the law refuses them. Start and end keep their meaning: the start says what the action is, the end says where it goes.
6
6
 
7
- Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
7
+ The same module holds `button-icon-primary-only`: only a primary Button carries a leading icon. Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
8
 
9
9
  ## `starci-grammar/button-arrow`
10
10
 
@@ -28,7 +28,32 @@ A `Button` bound to `@starci/grammar` is a finding when:
28
28
 
29
29
  ```tsx
30
30
  <Button href="/runs" endArrow>View runs</Button>
31
- <Button onPress={send} startGlyph="send">Send</Button>
31
+ <Button intent="commit" onPress={send} startGlyph="send">Send</Button>
32
+ ```
33
+
34
+ ## `starci-grammar/button-icon-primary-only`
35
+
36
+ Code `FE_BUTTON_ICON_PRIMARY_ONLY`. Only the primary Button (`intent="commit"`, the CTA) carries a leading icon. A `Button` bound to
37
+ `@starci/grammar` that sets `startGlyph` or `startContent` is a finding unless its `intent` is the literal `"commit"` (message `icon`):
38
+ a neutral, alternative, dismiss or destructive Button, a suggestion pill and a row action are text only. A Button with no `intent`
39
+ (it renders the secondary step) and one whose `intent` is computed cannot be proven primary, so they are findings too. The Button type
40
+ already refuses a start icon on a literal non-primary intent; the rule covers what a type cannot see. `endArrow` is not an icon under
41
+ this rule (any intent may lead), and `IconButton` (icon only, named by its label) is not judged.
42
+
43
+ **Invalid**
44
+
45
+ ```tsx
46
+ <Button intent="neutral" startGlyph="plus" onPress={add}>Add</Button>
47
+ <Button startGlyph="plus" onPress={add}>Add</Button>
48
+ <Button intent={intent} startContent={<Icon source={x} />} onPress={add}>Add</Button>
49
+ ```
50
+
51
+ **Valid**
52
+
53
+ ```tsx
54
+ <Button intent="commit" startGlyph="plus" onPress={add}>Add</Button>
55
+ <Button intent="neutral" href="/runs" endArrow>View runs</Button>
56
+ <Button intent="alternative" onPress={edit}>Edit</Button>
32
57
  ```
33
58
 
34
59
  Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -0,0 +1,32 @@
1
+ # Layout, one axis
2
+
3
+ Law module: `layout-two-axis.ts`. Finding code: `FE_LAYOUT_TWO_AXIS`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#LAYOUT-TWO-AXIS`.
4
+
5
+ A report page (`Page` standard: the pink well) stacks its card surfaces in ONE direction, a vertical column 24 apart. Cards stand side by side only as siblings of the same role and height (figure cells, short equal cards). A page with a persistent selection or navigation column, or a full-height chat or editor, is a workspace page (`Page chrome="panes"`): a grid of panes split by dividers whose side panes are white surfaces at full height, never cards. The page's `chrome` is the layout declaration, so one page has one frame type.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/layout-two-axis`
10
+
11
+ A Grammar `Grid` or `Cluster` is a finding when its rendered children are:
12
+
13
+ - a `SurfaceCard` together with a `Stack` that holds two or more `SurfaceCard`s (message `beside`): two axes in one well;
14
+ - two or more `SurfaceCard`s of different `kind` (an absent `kind` is `body`; message `unequal`): different roles are different heights.
15
+
16
+ `Grid kind="main-rail"`, a card with a JSX spread, a card repeated by `.map` and a `Stack` of cards on its own are not judged.
17
+
18
+ **Invalid**
19
+
20
+ ```tsx
21
+ <Grid><SurfaceCard label="Runs" /><Stack><SurfaceCard label="A" /><SurfaceCard label="B" /></Stack></Grid>
22
+ <Cluster><SurfaceCard kind="figures" /><SurfaceCard kind="details" /></Cluster>
23
+ ```
24
+
25
+ **Valid**
26
+
27
+ ```tsx
28
+ <Stack gap="section"><SurfaceCard kind="figures" /><SurfaceCard label="Runs">...</SurfaceCard></Stack>
29
+ <Cluster><SurfaceCard kind="figures" /><SurfaceCard kind="figures" /></Cluster>
30
+ ```
31
+
32
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -0,0 +1,28 @@
1
+ # No raw scroll
2
+
3
+ Law module: `no-raw-scroll.ts`. Finding code: `FE_NO_RAW_SCROLL`. Knowledge: `runtime/knowledge/ui/presentation/grammar-laws.yaml#NO-RAW-SCROLL`.
4
+
5
+ NIVO never shows scrollbars (owner, 2026-11-09). Every scroll area is drawn by Grammar with HeroUI's ScrollShadow behaviour: a fading edge where content continues, the bar hidden, wheel, touch and keyboard scrolling kept. An app element that makes its own scroll area with an `overflow-y-auto` or `overflow-auto` class has no fading edge.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/no-raw-scroll`
10
+
11
+ The `className` (or `class`) of any element in product source is a finding when it holds `overflow-auto`, `overflow-scroll`, `overflow-x-auto`, `overflow-y-auto`, `overflow-x-scroll` or `overflow-y-scroll`, with or without a variant prefix. The fix is the Grammar scroller: `VerticalScrollRegion` or `HorizontalScrollRegion`, or `PaneSection` with `scroll` for a pane.
12
+
13
+ `overflow-hidden`, `overflow-clip` and `overflow-visible` are not judged.
14
+
15
+ **Invalid**
16
+
17
+ ```tsx
18
+ <div className="flex-1 overflow-y-auto">{messages}</div>
19
+ ```
20
+
21
+ **Valid**
22
+
23
+ ```tsx
24
+ <PaneSection scroll={{ label: "Messages", role: "log" }}>{messages}</PaneSection>
25
+ <VerticalScrollRegion isScrollable aria-label="Files">{rows}</VerticalScrollRegion>
26
+ ```
27
+
28
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -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
 
@@ -2,7 +2,7 @@
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 one frame (border, card radius), so a card around either is a second frame.
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
6
 
7
7
  Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
8
 
@@ -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).
@@ -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.30.0",
3
+ "version": "0.34.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": "60a43b01a0944d2c8252e074946b82f3ee60c988",
72
- "starciSource": "c9f0db9043d7d17e3fb8d7d1e230fde769670e27b4cf7e2c6b27fcc1901fd99f"
71
+ "gitHead": "7d6aab209dd341bef6661eff643292471eaa86d8",
72
+ "starciSource": "dbe521b7e5db61f3e40404bbbae3200b86690d7eca01063c4c856fa2d80a0970"
73
73
  }
@@ -56,16 +56,36 @@ rules:
56
56
  when: A Button leads somewhere
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
- something takes `startGlyph`; never both.
60
- - id: SUGGESTION-CHIPS
61
- title: Quick replies and suggested questions are SuggestionChips
62
- governs: A row of Buttons that suggest something to say or ask.
59
+ something takes `startGlyph` (primary only, case-2); never both.
60
+ - id: case-2
61
+ when: A Button carries a leading icon (`startGlyph`, `startContent`)
62
+ assert: |-
63
+ Only the primary Button (`intent="commit"`, the CTA) does. A neutral, alternative, dismiss or destructive Button, a
64
+ suggestion pill and a row action are text only. The arrow (`endArrow`) is not an icon under this rule, so any intent
65
+ may lead somewhere; `IconButton` is unaffected.
66
+ - id: LAYOUT-TWO-AXIS
67
+ title: A report page stacks its cards in one direction
68
+ governs: Card surfaces placed side by side.
63
69
  cases:
64
70
  - id: case-1
65
- when: A row of neutral sm Buttons each send their own label
71
+ when: Card surfaces stand in the pink well of a report page
72
+ assert: |-
73
+ They stack in one vertical column, 24 apart. Side by side is allowed only for sibling cards of the same role and height
74
+ (figure cells, short equal cards). A card beside a column of cards, or cards of different kinds in one row, is refused.
75
+ - id: case-2
76
+ when: The page has a persistent selection or navigation column, or a full-height chat or editor
66
77
  assert: |-
67
- It is `SuggestionChips` (pill chips, a labelled toolbar), not a Button row; a form value is ChoiceChips and a
68
- label is a Badge or a TagGroup.
78
+ It is a workspace page, `Page chrome="panes"`: a grid of panes split by dividers, side panes white surfaces at full
79
+ height, never cards. The main pane may hold a pink well that follows case-1.
80
+ - id: SUGGESTION-BUTTONS
81
+ title: Suggestions and quick replies are a Cluster of neutral sm Buttons
82
+ governs: Anything that suggests something to say or ask.
83
+ cases:
84
+ - id: case-1
85
+ when: A suggestion, quick reply or empty-state shortcut is drawn
86
+ assert: |-
87
+ It is a `Cluster gap="inline"` (with `label`) of neutral `Button size="sm"`, which every Button size draws as a
88
+ pill; a Link row, ChoiceChips, TagGroup, Badge or Chip is never a suggestion.
69
89
  - id: TABLE-CELL-TYPE
70
90
  title: Table and row cells take the row type sizes
71
91
  governs: Text inside a DataTable cell or a ListRow.
@@ -73,7 +93,7 @@ rules:
73
93
  - id: case-1
74
94
  when: Text is drawn in a DataTable cell or a ListRow
75
95
  assert: |-
76
- The primary is md 14 / 500, the secondary sm 13 muted; a heading-size Text is refused.
96
+ 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.
77
97
  - id: SAME-LINE-SIZE
78
98
  title: One line, one size
79
99
  governs: Text siblings of one inline line.
@@ -81,7 +101,7 @@ rules:
81
101
  - id: case-1
82
102
  when: Texts stand side by side in one Cluster
83
103
  assert: |-
84
- They share one size; a Badge or a chip is exempt.
104
+ They share one size step (14: md and sm are the same; 12: xs; display: figure); a Badge or a chip is exempt.
85
105
  - id: ROW-TITLE-LINK
86
106
  title: A row title is never a link when the row opens
87
107
  governs: The primary of a ListRow or a DataTable row.
@@ -109,6 +129,25 @@ rules:
109
129
  assert: |-
110
130
  The page tabs (`Page header.tabs`) and one region set are the two layers; a third nested set is refused.
111
131
  Every tab is one size, so only the count of layers is judged.
132
+ - id: TABS-IN-WELL
133
+ title: The second tab layer stands in the white header band
134
+ governs: Underline Tabs in the body of a page or a pane.
135
+ cases:
136
+ - id: case-1
137
+ when: A page has a second layer of underline tabs under its page tabs
138
+ assert: |-
139
+ It is `Page header.subTabs`: inside the white header band, under layer 1, on its own full-width separator, the same size as layer 1
140
+ (14, 40 high, selected weight 500, the 2px underline exactly on the separator) and flush with the band's left inset, the same x as layer 1.
141
+ An underline Tabs written in the body of a Page, Pane or PaneSection (the pink well, a pane body) is refused.
142
+ - id: LINK-LOOK
143
+ title: A Link is HeroUI's own link and takes its size from the line
144
+ governs: The look of a Grammar Link.
145
+ cases:
146
+ - id: case-1
147
+ when: A Link stands in a line of text, a meta line or a caption
148
+ assert: |-
149
+ 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
+ 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.
112
151
  - id: SINGLE-CHILD-CARD
113
152
  title: A table, list or chart standing alone is the surface
114
153
  governs: A SurfaceCard whose only content is a table, a list or a chart.
@@ -119,3 +158,13 @@ rules:
119
158
  The Grammar draws a standalone DataTable and every Section kind="list" as ONE frame (border, card radius), so the
120
159
  card is a second frame. The title sits above as a Section head and one caption sits below (Section caption, muted sm).
121
160
  A card groups two or more different parts (figures + list + actions), or carries zones (tabs, search, head actions).
161
+ - id: NO-RAW-SCROLL
162
+ title: NIVO never shows scrollbars
163
+ governs: Scroll areas an app draws.
164
+ cases:
165
+ - id: case-1
166
+ when: Content scrolls in a pane, drawer, list, thread, tab strip, table or modal body
167
+ assert: |-
168
+ The scroll area is a Grammar scroller (`VerticalScrollRegion`, `HorizontalScrollRegion`, `PaneSection` with `scroll`):
169
+ the scrollbar is hidden, a fading edge (ScrollShadow behaviour) shows where content continues, and wheel, touch and
170
+ keyboard scrolling keep working. An app element with an `overflow-y-auto` or `overflow-auto` class is refused.