@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.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,41 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.34.0 - 2026-11-09
4
+
5
+ - Added: `tabs-in-well` (`FE_TABS_IN_WELL`, TABS-IN-WELL, error): an underline `Tabs` written in the body of a `Page`, `Pane` or `PaneSection` is refused; the second tab layer is
6
+ `Page header.subTabs`, in the white header band.
7
+ - Added: `link-look` (`FE_LINK_LOOK`, LINK-LOOK, error): a `Link` with a `size` prop or a size, underline or decoration class is refused.
8
+ - Changed: `button-icon-primary-only` also refuses a start icon on a `size="sm"` Button, the primary included.
9
+ - Changed: released with the Grammar family at 0.34.0.
10
+
11
+ ## 0.33.0 - 2026-11-09
12
+
13
+ - Added: `no-raw-scroll` (`FE_NO_RAW_SCROLL`, NO-RAW-SCROLL, error): an app element whose `className` holds `overflow-auto`, `overflow-y-auto`,
14
+ `overflow-x-auto` or an `overflow-*-scroll` class is refused; NIVO never shows scrollbars, so a scroll area is a Grammar scroller
15
+ (`VerticalScrollRegion`, `HorizontalScrollRegion`) or `PaneSection scroll`. `docs/no-raw-scroll.md`.
16
+ - Changed: released with the Grammar family at 0.33.0.
17
+ - Added: `button-icon-primary-only` (`FE_BUTTON_ICON_PRIMARY_ONLY`, BUTTON-ARROW case-2, error): only a `Button` whose `intent` is the literal
18
+ `"commit"` (the primary, the CTA) may set `startGlyph` or `startContent`; a neutral, alternative, dismiss or destructive Button, a Button
19
+ with no intent and one with a computed intent are refused. `endArrow` is not an icon under the rule and `IconButton` is not judged. The
20
+ Button type (Grammar 0.33.0) refuses the literal cases as well. `docs/button-arrow.md`.
21
+ - Added: `layout-two-axis` (`FE_LAYOUT_TWO_AXIS`, LAYOUT-TWO-AXIS, error): a `Grid` or `Cluster` that puts a `SurfaceCard` beside a `Stack` of `SurfaceCard`s,
22
+ or `SurfaceCard`s of different `kind` side by side, is refused (a report page stacks cards in one direction). `Grid kind="main-rail"` is not judged. `docs/layout-two-axis.md`.
23
+ - Changed: released with the Grammar family at 0.33.0.
24
+
25
+ ## 0.32.0 - 2026-11-09
26
+
27
+ - Versioned with Grammar 0.32.0 (every surface on the page ground is a card); no rule changes.
28
+
29
+ ## 0.31.0 - 2026-11-09
30
+
31
+ - Changed: released with the Grammar family at 0.31.0 (the final type scale).
32
+ - 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.
33
+
3
34
  ## 0.30.0 - 2026-11-09
4
35
 
5
- - Changed: released with the Grammar family at 0.30.0 (Button sm takes the pill radius; SuggestionChips).
6
- - Added: `suggestion-chips` (`FE_SUGGESTION_CHIPS`, SUGGESTION-CHIPS): two or more Grammar `Button`s that are siblings in a Cluster, Stack or div (or one in a `.map`), each `size="sm"` with no intent or a neutral/alternative one and an `onPress` that sends its own label, are refused; use `SuggestionChips`. `docs/suggestion-chips.md`.
36
+ - Changed: released with the Grammar family at 0.30.0 (Button sm takes the pill radius).
37
+ - 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`.
38
+ - Note: `suggestion-chips` was withdrawn before release with SuggestionChips.
7
39
 
8
40
  ## 0.29.0 - 2026-11-09
9
41
 
package/README.md CHANGED
@@ -19,10 +19,10 @@ Family helpers and the generated runtime closure belong to this package.
19
19
 
20
20
  The rule IDs remain stable when their namespace moves. Laws cover the fixed app shell and navbar,
21
21
  Grammar-owned structural elements, glyphs and icon sizes, destructive menu entries, status inks,
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
22
+ chip labels that start uppercase, a Button that leads somewhere ending with `endArrow` (no typed or icon arrow), a leading icon only on the primary Button (`button-arrow`, `button-icon-primary-only`), report cards in one axis (`layout-two-axis`), no app-made scroll area (`no-raw-scroll`), underline tabs only in the header band (`tabs-in-well`), a Link that takes its look from the line (`link-look`), 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
- `suggestion-chips` (a row of neutral sm Buttons that send their own label is `SuggestionChips`; `docs/suggestion-chips.md`).
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
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"`).
27
27
 
28
28
  ## Migrating from @starci/eslint-canon-fe 8.x
@@ -1,6 +1,13 @@
1
1
  import type { Rule } from "eslint";
2
2
  /** A Button leads somewhere with `endArrow` and does something with `startGlyph`; no typed arrow, no arrow icon, never both. */
3
3
  export declare const buttonArrow: Rule.RuleModule;
4
+ /**
5
+ * The button-icon law (owner, 2026-11-09): only a PRIMARY Button (`intent="commit"`) carries a leading icon. The Button type already
6
+ * refuses `startGlyph` / `startContent` on a literal non-primary intent; this reads what a type cannot see: a Button with no `intent`
7
+ * (it renders the secondary step) and an `intent` computed from a variable, a conditional or a spread. A start icon is accepted only
8
+ * when `intent` is the literal `"commit"`. The arrow (`endArrow`) is not an icon under this law, and `IconButton` is not judged.
9
+ */
10
+ export declare const buttonIconPrimaryOnly: Rule.RuleModule;
4
11
  /** The rules this law contributes to the plugin. */
5
12
  export declare const rules: Record<string, Rule.RuleModule>;
6
13
  /** Every rule of this law is an error. */
@@ -1,6 +1,6 @@
1
1
  import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
2
  import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
3
- import { attributeOf, descendants, elementOf, grammarBindings } from "./lib/row-context.js";
3
+ import { attributeOf, descendants, elementOf, grammarBindings, literalAttribute } from "./lib/row-context.js";
4
4
  /**
5
5
  * The button arrow law (`FE_BUTTON_ARROW`): a Button that leads somewhere ends with `endArrow`; a Button that does something
6
6
  * starts with a `startGlyph`. The arrow of a destination is the Grammar's own (it slides toward the reading end on hover and is
@@ -11,6 +11,7 @@ import { attributeOf, descendants, elementOf, grammarBindings } from "./lib/row-
11
11
  * - an `endContent` that is an arrow: an element named `Arrow*` or `ChevronRight*`, or any element whose `source` / `glyph` / `name`
12
12
  * is such an identifier or a string that names `arrow`, `chevron-right` or `chevron-end`;
13
13
  * - `endArrow` together with `startGlyph` or `startContent` (the Button type refuses it as well).
14
+ * The button-icon law (`button-icon-primary-only`) lives beside it: only a primary Button (`intent="commit"`) carries `startGlyph` or `startContent`.
14
15
  * `Button` takes the label as its children only, so no string label prop exists to read. `IconButton` has no label to type an arrow
15
16
  * in and no `endArrow`; `TextAction` takes `endContent` but not `endArrow`, so neither is judged.
16
17
  */
@@ -137,9 +138,57 @@ export const buttonArrow = defineRule({
137
138
  };
138
139
  },
139
140
  });
141
+ /** The one intent that is the CTA: the primary Button. */
142
+ const PRIMARY_INTENT = "commit";
143
+ /**
144
+ * The button-icon law (owner, 2026-11-09): only a PRIMARY Button (`intent="commit"`) carries a leading icon. The Button type already
145
+ * refuses `startGlyph` / `startContent` on a literal non-primary intent; this reads what a type cannot see: a Button with no `intent`
146
+ * (it renders the secondary step) and an `intent` computed from a variable, a conditional or a spread. A start icon is accepted only
147
+ * when `intent` is the literal `"commit"`. The arrow (`endArrow`) is not an icon under this law, and `IconButton` is not judged.
148
+ */
149
+ export const buttonIconPrimaryOnly = defineRule({
150
+ meta: {
151
+ type: "problem",
152
+ docs: { description: "FE_BUTTON_ICON_PRIMARY_ONLY: only a primary Button (`intent=\"commit\"`) carries a leading icon (`startGlyph`, `startContent`)." },
153
+ schema: [],
154
+ messages: {
155
+ icon: "The Button sets `{{start}}` but is not primary. Only the primary Button (`intent=\"commit\"`, the CTA) carries a leading icon; a neutral, alternative, dismiss or destructive Button, a suggestion pill and a row action are text only. Remove `{{start}}`, or make this the region's one primary. A Button that leads somewhere keeps `endArrow`.",
156
+ small: "The Button sets `{{start}}` at size `sm`. A small Button never carries an icon, not even the primary: a leading icon is for the primary at `md` or `lg`. Remove `{{start}}`, or make the Button `md`.",
157
+ },
158
+ },
159
+ create(context) {
160
+ if (!isProductSource(context))
161
+ return {};
162
+ let bound = new Map();
163
+ return {
164
+ Program(program) {
165
+ bound = grammarBindings(program);
166
+ },
167
+ JSXOpeningElement(opening) {
168
+ if (elementOf(opening, bound).grammar !== "Button")
169
+ return;
170
+ const isPrimary = literalAttribute(opening, "intent") === PRIMARY_INTENT;
171
+ const isSmall = literalAttribute(opening, "size") === "sm";
172
+ if (isPrimary && !isSmall)
173
+ return;
174
+ for (const start of ["startGlyph", "startContent"]) {
175
+ const attribute = attributeOf(opening, start);
176
+ if (attribute === null)
177
+ continue;
178
+ const value = attribute.value;
179
+ // `startContent={undefined}` / `{null}` states no icon.
180
+ if (value?.type === "JSXExpressionContainer" && (value.expression.type === "JSXEmptyExpression" || (value.expression.type === "Identifier" && value.expression.name === "undefined") || (value.expression.type === "Literal" && value.expression.value === null)))
181
+ continue;
182
+ context.report({ node: attribute, messageId: isPrimary ? "small" : "icon", data: { start } });
183
+ }
184
+ },
185
+ };
186
+ },
187
+ });
140
188
  /** The rules this law contributes to the plugin. */
141
189
  export const rules = {
142
190
  "button-arrow": buttonArrow,
191
+ "button-icon-primary-only": buttonIconPrimaryOnly,
143
192
  };
144
193
  defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#BUTTON-ARROW");
145
194
  /** Every rule of this law is an error. */
package/dist/index.js CHANGED
@@ -10,8 +10,11 @@ import { rules as freestyleRules } from "./freestyle.js";
10
10
  import { rules as gapProximityRules } from "./gap-proximity.js";
11
11
  import { rules as grammarBoundaryRules } from "./grammar-boundary.js";
12
12
  import { rules as iconRules } from "./icon.js";
13
+ import { rules as layoutTwoAxisRules } from "./layout-two-axis.js";
14
+ import { rules as linkLookRules } from "./link-look.js";
13
15
  import { rules as mascotRules } from "./mascot.js";
14
16
  import { rules as menuEntriesRules } from "./menu-entries.js";
17
+ import { rules as noRawScrollRules } from "./no-raw-scroll.js";
15
18
  import { rules as pageRules } from "./page.js";
16
19
  import { rules as pageBreadcrumbsRules } from "./page-breadcrumbs.js";
17
20
  import { rules as pageHeaderRules } from "./page-header.js";
@@ -23,7 +26,7 @@ import { rules as surfaceCardRules } from "./surface-card.js";
23
26
  import { rules as surfaceDepthRules } from "./surface-depth.js";
24
27
  import { rules as singleChildCardRules } from "./single-child-card.js";
25
28
  import { rules as surfaceInSurfaceRules } from "./surface-in-surface.js";
26
- import { rules as suggestionChipsRules } from "./suggestion-chips.js";
29
+ import { rules as suggestionButtonsRules } from "./suggestion-buttons.js";
27
30
  import { rules as tabsRules } from "./tabs.js";
28
31
  import { rules as tableCellTypeRules } from "./table-cell-type.js";
29
32
  import { rules as textRules } from "./text-rules.js";
@@ -41,8 +44,11 @@ const CONTRIBUTIONS = [
41
44
  { law: "gap-proximity", rules: gapProximityRules },
42
45
  { law: "grammar-boundary", rules: grammarBoundaryRules },
43
46
  { law: "icon", rules: iconRules },
47
+ { law: "layout-two-axis", rules: layoutTwoAxisRules },
48
+ { law: "link-look", rules: linkLookRules },
44
49
  { law: "mascot", rules: mascotRules },
45
50
  { law: "menu-entries", rules: menuEntriesRules },
51
+ { law: "no-raw-scroll", rules: noRawScrollRules },
46
52
  { law: "page", rules: pageRules },
47
53
  { law: "page-breadcrumbs", rules: pageBreadcrumbsRules },
48
54
  { law: "page-header", rules: pageHeaderRules },
@@ -53,7 +59,7 @@ const CONTRIBUTIONS = [
53
59
  { law: "status-colors", rules: statusColorsRules },
54
60
  { law: "surface-card", rules: surfaceCardRules },
55
61
  { law: "surface-depth", rules: surfaceDepthRules },
56
- { law: "suggestion-chips", rules: suggestionChipsRules },
62
+ { law: "suggestion-buttons", rules: suggestionButtonsRules },
57
63
  { law: "surface-in-surface", rules: surfaceInSurfaceRules },
58
64
  { law: "tabs", rules: tabsRules },
59
65
  { law: "table-cell-type", rules: tableCellTypeRules },
@@ -0,0 +1,7 @@
1
+ import type { Rule } from "eslint";
2
+ /** Cards stand side by side only when they share a role and height; a card beside a column of cards is two axes. */
3
+ export declare const layoutTwoAxis: 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,70 @@
1
+ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
+ import { elementNameOf, grammarName, hasSpread, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
3
+ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
4
+ /**
5
+ * The two-axis layout law (owner, 2026-11-09, LAYOUT-5): a REPORT page (`Page` standard: the pink well) stacks its card surfaces in ONE
6
+ * direction, a vertical column 24 apart. Cards stand side by side only as siblings of the same role and height (figure cells, short
7
+ * equal cards). A card beside a column of other cards makes two axes in one well, and two cards of different roles side by side
8
+ * are unequal in height. A page that needs a persistent selection column or a full-height chat or editor is a WORKSPACE page
9
+ * (`Page chrome="panes"`, side panes are white surfaces at full height, never cards).
10
+ *
11
+ * WHAT IT READS. A Grammar `Grid` or `Cluster` (imported from `@starci/grammar`) and its rendered children (fragments, `cond && x`,
12
+ * ternaries and `.map` looked through):
13
+ * - `beside`: a `SurfaceCard` child together with a `Stack` child that holds two or more `SurfaceCard`s;
14
+ * - `unequal`: two or more `SurfaceCard` children of different `kind` (an absent `kind` is `body`).
15
+ *
16
+ * WHAT IT LEAVES ALONE. `Grid kind="main-rail"` (a task and its subordinate support), a `SurfaceCard` with a JSX spread (its kind may
17
+ * arrive), a card repeated by `.map` (one element, one role), a `Stack` of cards on its own (that is the column), and non-product source.
18
+ *
19
+ * WHERE IT APPLIES. Product source (`isProductSource`).
20
+ */
21
+ /** The containers whose children stand side by side. */
22
+ const ROW_CONTAINERS = new Set(["Grid", "Cluster"]);
23
+ /** The `SurfaceCard` elements among a list of rendered nodes. */
24
+ const cardsOf = (context, nodes) => nodes.filter((node) => node.type === "JSXElement" && grammarName(context, node.openingElement) === "SurfaceCard");
25
+ /** True for a Grammar `Stack` that holds two or more cards. */
26
+ const isColumnOfCards = (context, node) => node.type === "JSXElement" && grammarName(context, node.openingElement) === "Stack" && cardsOf(context, renderedChildren(node.children)).length >= 2;
27
+ /** Cards stand side by side only when they share a role and height; a card beside a column of cards is two axes. */
28
+ export const layoutTwoAxis = defineRule({
29
+ meta: {
30
+ type: "problem",
31
+ docs: { description: "LAYOUT-5: a report page stacks cards in one direction; a card beside a column of cards, or cards of different kinds side by side, is two axes." },
32
+ schema: [],
33
+ messages: {
34
+ beside: "A card stands beside a column of cards ({{where}}): two axes in one well. A report page stacks its cards in one vertical column (24 apart); side by side is only for sibling cards of the same role and height. If the page needs a persistent selection column or a full-height chat or editor, it is a workspace page: `Page chrome=\"panes\"`, side panes are white surfaces, never cards.",
35
+ unequal: "Cards of different kinds ({{kinds}}) stand side by side in a {{where}}: they differ in role and height. Stack them in one column, or keep only sibling cards of one role in the row (figure cells, short equal cards).",
36
+ },
37
+ },
38
+ create(context) {
39
+ if (!isProductSource(context))
40
+ return {};
41
+ return {
42
+ JSXElement(element) {
43
+ const opening = element.openingElement;
44
+ const where = grammarName(context, opening);
45
+ if (where === null || !ROW_CONTAINERS.has(where))
46
+ return;
47
+ if (where === "Grid" && stringProp(opening, "kind") === "main-rail")
48
+ return;
49
+ const children = renderedChildren(element.children);
50
+ const cards = cardsOf(context, children);
51
+ if (cards.length > 0 && children.some((child) => isColumnOfCards(context, child))) {
52
+ context.report({ node: opening, messageId: "beside", data: { where } });
53
+ return;
54
+ }
55
+ const sure = cards.filter((card) => !hasSpread(card.openingElement));
56
+ const kinds = [...new Set(sure.map((card) => stringProp(card.openingElement, "kind") ?? "body"))];
57
+ if (sure.length >= 2 && kinds.length > 1 && children.every((child) => elementNameOf(child) !== null)) {
58
+ context.report({ node: opening, messageId: "unequal", data: { where, kinds: kinds.join(", ") } });
59
+ }
60
+ },
61
+ };
62
+ },
63
+ });
64
+ /** The rules this law contributes to the plugin. */
65
+ export const rules = {
66
+ "layout-two-axis": layoutTwoAxis,
67
+ };
68
+ defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#LAYOUT-TWO-AXIS");
69
+ /** Every rule of this law is an error. */
70
+ export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
package/dist/lib/why.js CHANGED
@@ -19,6 +19,16 @@ export const why = {
19
19
  en: "Underline `Tabs` in `<file>` stack past two layers.",
20
20
  fix: "A page has the page tabs (`Page header.tabs`) and at most one region set in a tab's panel. Fold a third level into a `switch` zone, a filter zone of a card, a list, or a drawer.",
21
21
  },
22
+ "tabs-in-well": {
23
+ code: "FE_TABS_IN_WELL",
24
+ en: "An underline `Tabs` in `<file>` is written in the body of a `Page`, `Pane` or `PaneSection`: on the pink well or in a pane.",
25
+ fix: "The second tab layer sits in the white header band under the page tabs: `Page header={{ tabs, subTabs }}`, on its own full-width separator and flush with the band's left inset. Or make the views a `switch` zone or a filter zone of a card.",
26
+ },
27
+ "link-look": {
28
+ code: "FE_LINK_LOOK",
29
+ en: "A `Link` in `<file>` sets a `size` or a size, underline or decoration class.",
30
+ fix: "A Link is HeroUI's own link: the primary colour, the underline on hover only, the anchor icon at the end, and the size of the line it stands in (14 in a body, 12 in meta). Remove the prop or class; wrap the link in a `Text` of the size you want.",
31
+ },
22
32
  "no-primary-tabs-misuse": {
23
33
  code: "FE_GROUPED_CHOICE_CONTROL",
24
34
  en: "Primary `Tabs` (or a `switch` header zone) in `<file>` hold a count, an href, an attention mark, one item or more than four items.",
@@ -174,24 +184,39 @@ export const why = {
174
184
  en: "A Button in `<file>` types an arrow in its label, passes an arrow icon as `endContent`, or sets `endArrow` together with `startGlyph` or `startContent`.",
175
185
  fix: "A Button that leads somewhere takes `endArrow` (the Grammar arrow slides on hover and is mirrored in RTL); one that does something takes `startGlyph`; never both.",
176
186
  },
187
+ "button-icon-primary-only": {
188
+ code: "FE_BUTTON_ICON_PRIMARY_ONLY",
189
+ en: "A Button in `<file>` sets `startGlyph` or `startContent` but is not the primary (`intent=\"commit\"`): it has another intent, none, or one computed; or it is `size=\"sm\"`, which never carries an icon, not even the primary.",
190
+ fix: "Only the primary Button (the CTA) carries a leading icon. Remove the icon from a neutral, alternative, dismiss or destructive Button, a suggestion pill, a row action or any `size=\"sm\"` Button (the primary carries an icon at `md` or `lg` only); a Button that leads somewhere keeps `endArrow`.",
191
+ },
192
+ "layout-two-axis": {
193
+ code: "FE_LAYOUT_TWO_AXIS",
194
+ en: "A Grid or Cluster in `<file>` puts a SurfaceCard beside a Stack of SurfaceCards, or two SurfaceCards of different kinds side by side.",
195
+ fix: "A report page stacks its cards in one vertical column (24 apart); side by side is only for sibling cards of one role and height. A page with a persistent selection column or a full-height chat or editor is a workspace: `Page chrome=\"panes\"`, whose side panes are white surfaces, never cards.",
196
+ },
197
+ "no-raw-scroll": {
198
+ code: "FE_NO_RAW_SCROLL",
199
+ en: "An element in `<file>` makes its own scroll area with an `overflow-auto`, `overflow-y-auto` or `overflow-scroll` class.",
200
+ fix: "NIVO never shows scrollbars. Use the Grammar scroller (`VerticalScrollRegion`, `HorizontalScrollRegion`) or `PaneSection scroll`: they fade the edge where content continues, hide the bar and keep wheel and keyboard scrolling.",
201
+ },
177
202
  "table-cell-type": {
178
203
  code: "FE_TABLE_CELL_TYPE",
179
- 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.",
180
- fix: "The primary of a row or cell is md 14 / 500 (`<Text isStrong>`), the secondary sm 13 muted (`<Text size=\"sm\" tone=\"muted\">`).",
204
+ 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.",
205
+ 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\">`).",
181
206
  },
182
207
  "same-line-size": {
183
208
  code: "FE_SAME_LINE_SIZE",
184
209
  en: "The Text children of one Cluster line in `<file>` have different sizes.",
185
- 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.",
210
+ 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.",
186
211
  },
187
212
  "row-title-link": {
188
213
  code: "FE_ROW_TITLE_LINK",
189
214
  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).",
190
215
  fix: "The row is the one pressable: write the title as plain text (`<Text isStrong>`) and keep the destination on the row.",
191
216
  },
192
- "suggestion-chips": {
193
- code: "FE_SUGGESTION_CHIPS",
194
- en: "Two or more neutral `size=\"sm\"` Buttons in `<file>` sit in one row (or one in a `.map`) and each press sends its own label.",
195
- fix: "Quick replies and suggested questions are `SuggestionChips` (pill chips in a labelled toolbar): `<SuggestionChips label items={[{ id, label }]} onSelect={(id) => ...} />`.",
217
+ "suggestion-buttons": {
218
+ code: "FE_SUGGESTION_BUTTONS",
219
+ en: "A Link row, a ChoiceChips or a Chip in `<file>` runs an action or sends its own label as a suggestion.",
220
+ fix: "Suggestions and quick replies are one pattern: a `Cluster gap=\"inline\"` (with `label`) of neutral `Button size=\"sm\"` (a pill).",
196
221
  },
197
222
  };
@@ -0,0 +1,7 @@
1
+ import type { Rule } from "eslint";
2
+ /** A Grammar Link takes its size from the line and its underline from the vendor: no size prop, no size, underline or decoration class. */
3
+ export declare const linkLook: 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,58 @@
1
+ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
+ import { attributeOf, grammarName } from "./lib/grammar-jsx.js";
3
+ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
4
+ /**
5
+ * THE LINK LOOK (owner, 2026-11-09, LINK-LOOK). Grammar's `Link` is HeroUI v3's own link: the primary colour, the underline on hover only
6
+ * and the anchor icon at the end of its label. Its type size and leading are INHERITED from the line it stands in (14 in a body, 12 in
7
+ * meta or caption text). An app never restyles it.
8
+ *
9
+ * WHAT IT READS. A Grammar `Link` (imported from `@starci/grammar`) in product source with:
10
+ * - a `size` prop;
11
+ * - a `className` / `class` attribute that holds a text-size utility (`text-sm`, `text-[13px]`), a weight or leading utility is left
12
+ * to the raw-class laws, or an `underline` / `no-underline` / `decoration-*` utility.
13
+ *
14
+ * WHAT IT LEAVES ALONE. A `Link` with neither, other elements, and non-product source.
15
+ */
16
+ const TEXT_SIZE = /(?<![\w-])(?:[\w[\]&>*:-]+:)?text-(?:xs|sm|base|md|lg|[2-9]?xl|\[[^\]]+\])(?![\w-])/;
17
+ const UNDERLINE = /(?<![\w-])(?:[\w[\]&>*:-]+:)?(?:underline|no-underline|decoration-[\w[\]./-]+|underline-offset-[\w[\]./-]+)(?![\w-])/;
18
+ /** A Grammar Link takes its size from the line and its underline from the vendor: no size prop, no size, underline or decoration class. */
19
+ export const linkLook = defineRule({
20
+ meta: {
21
+ type: "problem",
22
+ docs: { description: "LINK-LOOK: a Link inherits its size from the line and keeps HeroUI's hover underline and anchor icon; no size prop, size class or underline class." },
23
+ schema: [],
24
+ messages: {
25
+ size: "A `Link` takes no `size`: it inherits the type size of the line it stands in (14 in a body, 12 in meta or caption text). Remove the prop and put the link in a `Text` of the size you want.",
26
+ class: "A `Link` is HeroUI's own link: the primary colour, the underline on hover only, the anchor icon at the end, the size of the line around it. Remove `{{token}}` from its class; the app never restyles a Link.",
27
+ },
28
+ },
29
+ create(context) {
30
+ if (!isProductSource(context))
31
+ return {};
32
+ return {
33
+ JSXOpeningElement(opening) {
34
+ if (grammarName(context, opening) !== "Link")
35
+ return;
36
+ const size = attributeOf(opening, "size");
37
+ if (size !== undefined)
38
+ context.report({ node: size, messageId: "size" });
39
+ for (const name of ["className", "class"]) {
40
+ const attribute = attributeOf(opening, name);
41
+ if (attribute === undefined || attribute.value === null)
42
+ continue;
43
+ const text = context.sourceCode.getText(attribute.value);
44
+ const found = TEXT_SIZE.exec(text) ?? UNDERLINE.exec(text);
45
+ if (found !== null)
46
+ context.report({ node: attribute, messageId: "class", data: { token: found[0].replace(/^.*:/, "") } });
47
+ }
48
+ },
49
+ };
50
+ },
51
+ });
52
+ /** The rules this law contributes to the plugin. */
53
+ export const rules = {
54
+ "link-look": linkLook,
55
+ };
56
+ defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#LINK-LOOK");
57
+ /** Every rule of this law is an error. */
58
+ export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
@@ -0,0 +1,7 @@
1
+ import type { Rule } from "eslint";
2
+ /** An app scroll area is drawn by Grammar's scroller, never by an `overflow-*-auto` class on the app's own element. */
3
+ export declare const noRawScroll: 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,48 @@
1
+ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
+ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
3
+ /**
4
+ * NIVO never shows scrollbars (owner, 2026-11-09, OVERFLOW-6). Every scroll area is drawn by Grammar, which hides the bar and
5
+ * fades the edge where content continues (HeroUI's ScrollShadow behaviour). An app element that makes its own scroll area with
6
+ * an `overflow-y-auto` / `overflow-auto` class (or the `-x-`, `-scroll` forms) has no such edge and, in a browser that draws bars, shows one.
7
+ *
8
+ * WHAT IT READS. The `className` / `class` attribute of an element in product source: every string in it, a template literal's
9
+ * text included, with any variant prefix (`md:overflow-y-auto`).
10
+ *
11
+ * WHAT IT LEAVES ALONE. `overflow-hidden`, `overflow-clip`, `overflow-visible`, a class that only shares a prefix, and non-product source
12
+ * (Grammar's own sources are not product source).
13
+ */
14
+ /** `overflow-auto`, `overflow-y-auto`, `overflow-x-scroll` and the like, not part of a longer class name. */
15
+ const RAW_SCROLL = /(?<![\w-])overflow-(?:[xy]-)?(?:auto|scroll)(?![\w-])/;
16
+ /** An app scroll area is drawn by Grammar's scroller, never by an `overflow-*-auto` class on the app's own element. */
17
+ export const noRawScroll = defineRule({
18
+ meta: {
19
+ type: "problem",
20
+ docs: { description: "OVERFLOW-6: NIVO never shows scrollbars; a scroll area is a Grammar scroller or `PaneSection scroll`, not an `overflow-y-auto` class." },
21
+ schema: [],
22
+ messages: {
23
+ raw: "`{{token}}` makes a scroll area outside Grammar. NIVO never shows scrollbars: every scroll area fades its edge where content continues and hides the bar. Use the Grammar scroller (`VerticalScrollRegion`, `HorizontalScrollRegion`) or `PaneSection scroll`, which keep wheel and keyboard scrolling.",
24
+ },
25
+ },
26
+ create(context) {
27
+ if (!isProductSource(context))
28
+ return {};
29
+ return {
30
+ JSXAttribute(node) {
31
+ if (node.name.type !== "JSXIdentifier" || (node.name.name !== "className" && node.name.name !== "class"))
32
+ return;
33
+ if (node.value === null)
34
+ return;
35
+ const match = RAW_SCROLL.exec(context.sourceCode.getText(node.value));
36
+ if (match !== null)
37
+ context.report({ node: node, messageId: "raw", data: { token: match[0] } });
38
+ },
39
+ };
40
+ },
41
+ });
42
+ /** The rules this law contributes to the plugin. */
43
+ export const rules = {
44
+ "no-raw-scroll": noRawScroll,
45
+ };
46
+ defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#NO-RAW-SCROLL");
47
+ /** Every rule of this law is an error. */
48
+ export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
@@ -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) {
@@ -5,8 +5,8 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
5
5
  * The lone surface law (owner, 2026-11-09, SINGLE-CHILD-CARD): a card groups two or more different parts (figures + list +
6
6
  * actions) or carries zones (tabs, search, head actions). A table, a list or a chart standing alone IS the surface: the
7
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 ONE frame (border, card radius), so a
9
- * `SurfaceCard` around either is a second frame around the first.
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
10
  *
11
11
  * WHAT IT READS. A Grammar `SurfaceCard` (imported from `@starci/grammar`) with no zones: no `headers` or `footers` prop (an
12
12
  * empty array literal counts as none) and no `labelEnd` (head actions). Its body is read through fragments, `cond && <x/>`,
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from "eslint";
2
- export declare const suggestionChips: Rule.RuleModule;
2
+ export declare const suggestionButtons: Rule.RuleModule;
3
3
  /** The rules this law contributes to the plugin. */
4
4
  export declare const rules: Record<string, Rule.RuleModule>;
5
5
  /** Every rule of this law is an error. */