@starci/eslint-grammar-core 0.35.0 → 0.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.36.1 - 2026-11-09
4
+
5
+ - Changed: released with the Grammar family at 0.36.1 (the status dot is a hollow ring); no rule of this package changed.
6
+
7
+ ## 0.36.0 - 2026-11-09
8
+
9
+ - Added: `section-head-action` (`FE_SECTION_HEAD_ACTION`, SECTION-HEAD-ACTION, error): a Grammar `Button` in a `Section` head `action` is refused (navigation is a `Link variant="head"`), and so is more than one command
10
+ (`Button`, `Link`, `IconButton`, `TextAction`) in that slot. Doc: `docs/section-head-action.md`.
11
+ - Added: `tab-count-chip` (`FE_TAB_COUNT_CHIP`, TAB-COUNT-CHIP, error): a tab item (an object with `id` and `label`) whose label ends in a middle dot and a number, or a template that ends in a middle dot and an expression, is refused;
12
+ the count is the `count` prop, drawn as a chip. Doc: `docs/tab-count-chip.md`.
13
+ - Added: `card-one-content` (`FE_CARD_ONE_CONTENT`, CARD-ONE-CONTENT, error): a `SurfaceCard` with more than one content component, or a `figures` header zone above another content, is refused. A card inside a card stays
14
+ `no-raised-surface-in-surface` (R340). Doc: `docs/card-content.md`.
15
+ - Added: `no-label-description` (`FE_NO_LABEL_DESCRIPTION`, error): a `Section` `description` (use `caption`) and a labelled `SurfaceCard` `description` (use `note`) are refused.
16
+ - Added: `outline-icons-only` (`FE_OUTLINE_ICONS_ONLY`, ICONS-OUTLINE, error): an import of a solid icon set (`@heroicons/react/<size>/solid`, `@starci/heroicons/<size>/solid`) is refused anywhere. Doc: `docs/outline-icons.md`.
17
+ - Changed: released with the Grammar family at 0.36.0.
18
+
3
19
  ## 0.35.0 - 2026-11-09
4
20
 
5
21
  - Changed: released with the Grammar family at 0.35.0 (FlowGraph `layout="steps"`); no rule of this package changed.
package/README.md CHANGED
@@ -19,7 +19,7 @@ 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), 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
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`), outline icons only, no solid icon set (`outline-icons-only`), one content per card and no description under a label (`card-one-content`, `no-label-description`), a Section head that holds one Link or one IconButton and never a Button (`section-head-action`), a tab count passed as `count` and never as "· N" in the label (`tab-count-chip`), 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
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`).
@@ -0,0 +1,9 @@
1
+ import type { Rule } from "eslint";
2
+ /** A card holds one content. */
3
+ export declare const cardOneContent: Rule.RuleModule;
4
+ /** A label has no description under it: the description is a caption under the card. */
5
+ export declare const noLabelDescription: Rule.RuleModule;
6
+ /** The rules this law contributes to the plugin. */
7
+ export declare const rules: Record<string, Rule.RuleModule>;
8
+ /** Every rule of this law is an error. */
9
+ export declare const recommended: Record<string, "error">;
@@ -0,0 +1,132 @@
1
+ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
+ import { attributeOf, grammarName, stringProp } from "./lib/grammar-jsx.js";
3
+ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
4
+ /**
5
+ * ONE CONTENT PER CARD (owner, 2026-11-09, CARD-ONE-CONTENT). A `SurfaceCard` holds exactly ONE content: a list, an input group (a form), a table, a graph
6
+ * or a figures ribbon. Its own controls are allowed (a tab, search or pagination zone, a form footer with Cancel and Save). Several groups are several
7
+ * cards, each with a `Sublabel` above it; items of the same kind stay in one list. A card inside a card is `no-raised-surface-in-surface` (R340). A
8
+ * label has no description under it: the description is a caption under the card (`Section caption`, `SurfaceCard note`).
9
+ *
10
+ * WHAT IT READS.
11
+ * - `card-one-content`: a `SurfaceCard` whose body (any depth, through layout wrappers) holds more than one content component (a list, a description
12
+ * list, a table, a graph, a chart, a timeline, a figures strip, a form group), or whose kind is not `figures` and that carries a `figures` header zone
13
+ * (a ribbon above another content).
14
+ * - `no-label-description`: a `Section` with a `description`, and a labelled `SurfaceCard` (not a tile) with a `description`.
15
+ *
16
+ * WHAT IT LEAVES ALONE. A card with one content, a tile (its description is its content), other components, and non-product source.
17
+ */
18
+ /** The Grammar components that are one content of a card. */
19
+ const CONTENT = new Set([
20
+ "ListBox", "ItemList", "ListRow", "DescriptionList", "DataTable", "FlowGraph", "BarChart", "ProportionBar", "Sparkline", "Timeline", "DisclosureList",
21
+ "Accordion", "BubbleMap", "MermaidDiagram", "Form", "FormGrid", "Fieldset", "Gallery", "ScheduleGrid", "Board", "Stepper",
22
+ ]);
23
+ /** A Section that is itself one content. */
24
+ const SECTION_CONTENT = new Set(["list", "figures"]);
25
+ /** The content components a card body holds, in source order, not descending into a content component. */
26
+ const contentsIn = (context, root) => {
27
+ const found = [];
28
+ const visit = (value) => {
29
+ if (value === null || typeof value !== "object")
30
+ return;
31
+ if (Array.isArray(value)) {
32
+ for (const entry of value)
33
+ visit(entry);
34
+ return;
35
+ }
36
+ const node = value;
37
+ if (typeof node.type !== "string")
38
+ return;
39
+ if (node.type === "JSXElement") {
40
+ const element = node;
41
+ const name = grammarName(context, element.openingElement);
42
+ if (name !== null && (CONTENT.has(name) || (name === "Section" && SECTION_CONTENT.has(stringProp(element.openingElement, "kind") ?? "")))) {
43
+ found.push(element.openingElement);
44
+ return;
45
+ }
46
+ }
47
+ for (const [key, child] of Object.entries(node))
48
+ if (key !== "parent" && key !== "loc" && key !== "range")
49
+ visit(child);
50
+ };
51
+ visit(root);
52
+ return found;
53
+ };
54
+ const hasFiguresZone = (opening) => {
55
+ const headers = attributeOf(opening, "headers");
56
+ const expression = headers?.value?.type === "JSXExpressionContainer" ? headers.value.expression : undefined;
57
+ if (expression === undefined || expression.type !== "ArrayExpression")
58
+ return false;
59
+ return expression.elements.some((entry) => entry !== null && entry.type === "ObjectExpression" && entry.properties.some((property) => property.type === "Property" && property.key.type === "Identifier" && property.key.name === "kind" && property.value.type === "Literal" && property.value.value === "figures"));
60
+ };
61
+ /** A card holds one content. */
62
+ export const cardOneContent = defineRule({
63
+ meta: {
64
+ type: "problem",
65
+ docs: { description: "CARD-ONE-CONTENT: a SurfaceCard holds exactly one content (a list, a form, a table, a graph or a figures ribbon); several groups are several cards with a Sublabel above each." },
66
+ schema: [],
67
+ messages: {
68
+ many: "This `SurfaceCard` holds {{count}} contents ({{names}}). A card holds ONE: a list, an input group, a table, a graph or a figures ribbon. Several groups are several cards, each with a `Sublabel` above it; items of the same kind stay in one list.",
69
+ ribbon: "A `figures` header zone puts a figures ribbon above another content in one card. A ribbon is its own card (`kind=\"figures\"`), with a `Sublabel` above the cards that follow.",
70
+ },
71
+ },
72
+ create(context) {
73
+ if (!isProductSource(context))
74
+ return {};
75
+ return {
76
+ JSXElement(element) {
77
+ const opening = element.openingElement;
78
+ if (grammarName(context, opening) !== "SurfaceCard")
79
+ return;
80
+ const kind = stringProp(opening, "kind");
81
+ if (kind === "figures" || kind === "tile")
82
+ return;
83
+ const contents = contentsIn(context, { type: "Program", children: element.children });
84
+ if (contents.length > 1) {
85
+ const names = contents.map((entry) => grammarName(context, entry) ?? "?").join(", ");
86
+ context.report({ node: opening, messageId: "many", data: { count: String(contents.length), names } });
87
+ }
88
+ if (hasFiguresZone(opening))
89
+ context.report({ node: opening, messageId: "ribbon" });
90
+ },
91
+ };
92
+ },
93
+ });
94
+ /** A label has no description under it: the description is a caption under the card. */
95
+ export const noLabelDescription = defineRule({
96
+ meta: {
97
+ type: "problem",
98
+ docs: { description: "CARD-ONE-CONTENT: a Section or a card label has no description under it; the description is a caption under the card or list." },
99
+ schema: [],
100
+ messages: {
101
+ section: "A `Section` with a `description`: a head is one row and holds no description. Write the line as `caption`, drawn under the card or list.",
102
+ card: "A labelled `SurfaceCard` with a `description`: the label has no description under it. Put the line under the card as its `note`.",
103
+ },
104
+ },
105
+ create(context) {
106
+ if (!isProductSource(context))
107
+ return {};
108
+ return {
109
+ JSXOpeningElement(opening) {
110
+ const name = grammarName(context, opening);
111
+ if (name === "Section") {
112
+ const description = attributeOf(opening, "description");
113
+ if (description !== undefined)
114
+ context.report({ node: description, messageId: "section" });
115
+ }
116
+ else if (name === "SurfaceCard" && stringProp(opening, "kind") !== "tile") {
117
+ const description = attributeOf(opening, "description");
118
+ if (description !== undefined && attributeOf(opening, "label") !== undefined)
119
+ context.report({ node: description, messageId: "card" });
120
+ }
121
+ },
122
+ };
123
+ },
124
+ });
125
+ /** The rules this law contributes to the plugin. */
126
+ export const rules = {
127
+ "card-one-content": cardOneContent,
128
+ "no-label-description": noLabelDescription,
129
+ };
130
+ defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#CARD-ONE-CONTENT");
131
+ /** Every rule of this law is an error. */
132
+ export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import tsParser from "@typescript-eslint/parser";
2
2
  import { SOURCE_FILES, linterOptions as canonLinterOptions, scopeToPackages } from "@starci/eslint-canon-fe/lib/config.mjs";
3
3
  import { rules as appShellRules } from "./app-shell.js";
4
4
  import { rules as buttonArrowRules } from "./button-arrow.js";
5
+ import { rules as cardContentRules } from "./card-content.js";
5
6
  import { rules as chipLabelRules } from "./chip-label.js";
6
7
  import { rules as choiceControlsRules } from "./choice-controls.js";
7
8
  import { rules as drawingRules } from "./drawing.js";
@@ -15,11 +16,13 @@ import { rules as linkLookRules } from "./link-look.js";
15
16
  import { rules as mascotRules } from "./mascot.js";
16
17
  import { rules as menuEntriesRules } from "./menu-entries.js";
17
18
  import { rules as noRawScrollRules } from "./no-raw-scroll.js";
19
+ import { rules as outlineIconsRules } from "./outline-icons.js";
18
20
  import { rules as pageRules } from "./page.js";
19
21
  import { rules as pageBreadcrumbsRules } from "./page-breadcrumbs.js";
20
22
  import { rules as pageHeaderRules } from "./page-header.js";
21
23
  import { rules as paneRules } from "./pane.js";
22
24
  import { rules as rowTitleLinkRules } from "./row-title-link.js";
25
+ import { rules as sectionHeadActionRules } from "./section-head-action.js";
23
26
  import { rules as sameLineSizeRules } from "./same-line-size.js";
24
27
  import { rules as statusColorsRules } from "./status-colors.js";
25
28
  import { rules as surfaceCardRules } from "./surface-card.js";
@@ -27,6 +30,7 @@ import { rules as surfaceDepthRules } from "./surface-depth.js";
27
30
  import { rules as singleChildCardRules } from "./single-child-card.js";
28
31
  import { rules as surfaceInSurfaceRules } from "./surface-in-surface.js";
29
32
  import { rules as suggestionButtonsRules } from "./suggestion-buttons.js";
33
+ import { rules as tabCountChipRules } from "./tab-count-chip.js";
30
34
  import { rules as tabsRules } from "./tabs.js";
31
35
  import { rules as tableCellTypeRules } from "./table-cell-type.js";
32
36
  import { rules as textRules } from "./text-rules.js";
@@ -36,6 +40,7 @@ import { why as familyWhy } from "./lib/why.js";
36
40
  const CONTRIBUTIONS = [
37
41
  { law: "app-shell", rules: appShellRules },
38
42
  { law: "button-arrow", rules: buttonArrowRules },
43
+ { law: "card-content", rules: cardContentRules },
39
44
  { law: "chip-label", rules: chipLabelRules },
40
45
  { law: "choice-controls", rules: choiceControlsRules },
41
46
  { law: "drawing", rules: drawingRules },
@@ -49,18 +54,21 @@ const CONTRIBUTIONS = [
49
54
  { law: "mascot", rules: mascotRules },
50
55
  { law: "menu-entries", rules: menuEntriesRules },
51
56
  { law: "no-raw-scroll", rules: noRawScrollRules },
57
+ { law: "outline-icons", rules: outlineIconsRules },
52
58
  { law: "page", rules: pageRules },
53
59
  { law: "page-breadcrumbs", rules: pageBreadcrumbsRules },
54
60
  { law: "page-header", rules: pageHeaderRules },
55
61
  { law: "pane", rules: paneRules },
56
62
  { law: "row-title-link", rules: rowTitleLinkRules },
57
63
  { law: "same-line-size", rules: sameLineSizeRules },
64
+ { law: "section-head-action", rules: sectionHeadActionRules },
58
65
  { law: "single-child-card", rules: singleChildCardRules },
59
66
  { law: "status-colors", rules: statusColorsRules },
60
67
  { law: "surface-card", rules: surfaceCardRules },
61
68
  { law: "surface-depth", rules: surfaceDepthRules },
62
69
  { law: "suggestion-buttons", rules: suggestionButtonsRules },
63
70
  { law: "surface-in-surface", rules: surfaceInSurfaceRules },
71
+ { law: "tab-count-chip", rules: tabCountChipRules },
64
72
  { law: "tabs", rules: tabsRules },
65
73
  { law: "table-cell-type", rules: tableCellTypeRules },
66
74
  { law: "text-rules", rules: textRules },
package/dist/lib/why.js CHANGED
@@ -24,6 +24,31 @@ export const why = {
24
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
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
26
  },
27
+ "section-head-action": {
28
+ code: "FE_SECTION_HEAD_ACTION",
29
+ en: "The `Section` head `action` in `<file>` holds a `Button` or more than one command.",
30
+ fix: "A section's head is one row: the label and an optional count chip at the start, at most ONE thing at the end. Navigation is a `Link variant=\"head\"` (the label then an arrow that slides on hover), an info is an `IconButton`. A command that does not navigate goes in the card or the page header.",
31
+ },
32
+ "tab-count-chip": {
33
+ code: "FE_TAB_COUNT_CHIP",
34
+ en: "A tab label in `<file>` carries its count as text (\"label \u00b7 N\").",
35
+ fix: "Give the tab item `count: N`; the tab draws a 12px chip, grey for a quantity. Add `isAttention: true` only when the number is work waiting for the owner (to handle, to approve, an error): that chip is pink.",
36
+ },
37
+ "card-one-content": {
38
+ code: "FE_CARD_ONE_CONTENT",
39
+ en: "A `SurfaceCard` in `<file>` holds more than one content, or a figures ribbon above another content.",
40
+ fix: "A card holds ONE content: a list, an input group, a table, a graph or a figures ribbon (with its own tab, search, pagination zones or a form footer). Several groups are several cards, each with a `Sublabel` above it; items of the same kind stay in one list.",
41
+ },
42
+ "no-label-description": {
43
+ code: "FE_NO_LABEL_DESCRIPTION",
44
+ en: "A `Section` or a labelled `SurfaceCard` in `<file>` has a `description` under its label.",
45
+ fix: "A label has no description under it. A section's line is its `caption`; a card's line is its `note`: both stand under the card or list, muted 12.",
46
+ },
47
+ "outline-icons-only": {
48
+ code: "FE_OUTLINE_ICONS_ONLY",
49
+ en: "`<file>` imports a solid icon set (`@heroicons/react/<size>/solid`).",
50
+ fix: "Icons are OUTLINE only: import the same name from `@heroicons/react/24/outline`. A standalone mark of a row, card, empty state or graph step sits in an `IconTile`; an icon inline with text is a plain outline icon, and a status is a tone-coloured outline icon with no tile.",
51
+ },
27
52
  "link-look": {
28
53
  code: "FE_LINK_LOOK",
29
54
  en: "A `Link` in `<file>` sets a `size` or a size, underline or decoration class.",
@@ -0,0 +1,7 @@
1
+ import type { Rule } from "eslint";
2
+ /** An icon is outline: a solid icon set is never imported. */
3
+ export declare const outlineIconsOnly: 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,56 @@
1
+ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
2
+ /**
3
+ * ICONS ARE OUTLINE ONLY (owner, 2026-11-09, ICONS-OUTLINE). Never a filled or solid icon: no `@heroicons/react/16/solid`, `/20/solid` or `/24/solid`
4
+ * (and the same for `@starci/heroicons`' solid sets), no filled glyph, no filled-circle status mark. An icon that STANDS ALONE as the mark of a row, a
5
+ * card, an empty state or a graph step sits in an icon tile (a soft-tone square holding an outline icon); an icon INLINE with text (a status beside a
6
+ * 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 is a tone-coloured outline
7
+ * icon, never a tile.
8
+ *
9
+ * WHAT IT READS. Every import (and `require` of a literal) whose source is a solid icon set: `@heroicons/react/<size>/solid`, `@heroicons/react/solid`, or
10
+ * `@starci/heroicons/<size>/solid`. It applies anywhere, in product source and in packages alike.
11
+ *
12
+ * WHAT IT LEAVES ALONE. The outline sets (`/24/outline`) and any other import.
13
+ */
14
+ const SOLID = /^@(?:heroicons\/react|starci\/heroicons)(?:\/(?:16|20|24))?\/solid(?:\/|$)/;
15
+ /** An icon is outline: a solid icon set is never imported. */
16
+ export const outlineIconsOnly = defineRule({
17
+ meta: {
18
+ type: "problem",
19
+ docs: { description: "ICONS-OUTLINE: icons are outline only; no import from a solid icon set (`@heroicons/react/<size>/solid`)." },
20
+ schema: [],
21
+ messages: {
22
+ solid: "`{{source}}` is a solid icon set. Icons are OUTLINE only: import the same name from `@heroicons/react/24/outline`. A standalone mark of a row, card, empty state or graph step sits in an `IconTile`; an icon inline with text is a plain outline icon, and a status is a tone-coloured outline icon with no tile.",
23
+ },
24
+ },
25
+ create(context) {
26
+ const check = (node, source) => {
27
+ if (typeof source === "string" && SOLID.test(source))
28
+ context.report({ node: node, messageId: "solid", data: { source } });
29
+ };
30
+ return {
31
+ ImportDeclaration(node) {
32
+ check(node.source, node.source.value);
33
+ },
34
+ ExportNamedDeclaration(node) {
35
+ if (node.source !== null && node.source !== undefined)
36
+ check(node.source, node.source.value);
37
+ },
38
+ ImportExpression(node) {
39
+ if (node.source.type === "Literal")
40
+ check(node.source, node.source.value);
41
+ },
42
+ CallExpression(node) {
43
+ const [argument] = node.arguments;
44
+ if (node.callee.type === "Identifier" && node.callee.name === "require" && argument?.type === "Literal")
45
+ check(argument, argument.value);
46
+ },
47
+ };
48
+ },
49
+ });
50
+ /** The rules this law contributes to the plugin. */
51
+ export const rules = {
52
+ "outline-icons-only": outlineIconsOnly,
53
+ };
54
+ defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#ICONS-OUTLINE");
55
+ /** Every rule of this law is an error. */
56
+ 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
+ /** A section head holds one navigation Link or one info IconButton: no Button, no second command. */
3
+ export declare const sectionHeadAction: 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,80 @@
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 SECTION HEAD (owner, 2026-11-09, SECTION-HEAD-ACTION). A section's head is ONE row: the label (14, 500) and an optional count chip at the
6
+ * start, and at the end at most ONE thing: a navigation `Link variant="head"` (the label then an arrow that slides on hover) or an info
7
+ * `IconButton`. Navigation is a Link, never a Button, and the head never holds two commands.
8
+ *
9
+ * WHAT IT READS. A Grammar `Section` in product source whose `action` prop holds:
10
+ * - a Grammar `Button` (message `button`): navigation is a `Link variant="head"`;
11
+ * - more than one Grammar `Button`, `Link`, `IconButton` or `TextAction` (message `many`): the head has room for one.
12
+ *
13
+ * WHAT IT LEAVES ALONE. A `Section` with no `action`, an `action` that holds one Link or one IconButton, other components, and non-product source.
14
+ */
15
+ const COMMANDS = new Set(["Button", "Link", "IconButton", "TextAction"]);
16
+ /** Every Grammar command element an expression holds, in source order. */
17
+ const commandsIn = (context, root) => {
18
+ const found = [];
19
+ const visit = (value) => {
20
+ if (value === null || typeof value !== "object")
21
+ return;
22
+ if (Array.isArray(value)) {
23
+ for (const entry of value)
24
+ visit(entry);
25
+ return;
26
+ }
27
+ const node = value;
28
+ if (typeof node.type !== "string")
29
+ return;
30
+ if (node.type === "JSXOpeningElement") {
31
+ const opening = node;
32
+ const name = grammarName(context, opening);
33
+ if (name !== null && COMMANDS.has(name))
34
+ found.push({ name, node: opening });
35
+ }
36
+ for (const [key, child] of Object.entries(node))
37
+ if (key !== "parent" && key !== "loc" && key !== "range")
38
+ visit(child);
39
+ };
40
+ visit(root);
41
+ return found;
42
+ };
43
+ /** A section head holds one navigation Link or one info IconButton: no Button, no second command. */
44
+ export const sectionHeadAction = defineRule({
45
+ meta: {
46
+ type: "problem",
47
+ docs: { description: "SECTION-HEAD-ACTION: a Section's head action is one Link variant=\"head\" or one IconButton; never a Button, never more than one." },
48
+ schema: [],
49
+ messages: {
50
+ button: "A `Button` in a `Section` head `action`: the head's navigation is a `Link variant=\"head\"` (the label then a sliding arrow). A command that is not navigation belongs in the card or the page header.",
51
+ many: "A `Section` head holds at most ONE thing at its end (a `Link variant=\"head\"` or an info `IconButton`); this `action` holds {{count}} commands. Keep the one that navigates and move the rest into the body.",
52
+ },
53
+ },
54
+ create(context) {
55
+ if (!isProductSource(context))
56
+ return {};
57
+ return {
58
+ JSXOpeningElement(opening) {
59
+ if (grammarName(context, opening) !== "Section")
60
+ return;
61
+ const action = attributeOf(opening, "action");
62
+ if (action === undefined || action.value === null)
63
+ return;
64
+ const commands = commandsIn(context, action.value);
65
+ for (const command of commands)
66
+ if (command.name === "Button")
67
+ context.report({ node: command.node, messageId: "button" });
68
+ if (commands.length > 1)
69
+ context.report({ node: action, messageId: "many", data: { count: String(commands.length) } });
70
+ },
71
+ };
72
+ },
73
+ });
74
+ /** The rules this law contributes to the plugin. */
75
+ export const rules = {
76
+ "section-head-action": sectionHeadAction,
77
+ };
78
+ defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#SECTION-HEAD-ACTION");
79
+ /** Every rule of this law is an error. */
80
+ 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
+ /** A tab label never carries its count as text: the count is the tab's `count`, drawn as a chip. */
3
+ export declare const tabCountChip: 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,65 @@
1
+ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
+ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
3
+ /**
4
+ * THE TAB COUNT CHIP (owner, 2026-11-09, TAB-COUNT-CHIP). A count on any tab (page layer 1 or 2, a filter tab) is a 12px chip drawn by the tab from its
5
+ * `count`, never "· N" text in the label. The chip is grey; it is pink only when the number is work waiting for the owner (`isAttention`).
6
+ *
7
+ * WHAT IT READS. In product source that imports `@starci/grammar`, an object that carries `id` and `label` (a tab item, a filter option) whose `label`
8
+ * is a string ending in a middle dot and a number (`"All · 5"`), or a template literal that ends in a middle dot and an expression (`` `All · ${n}` ``).
9
+ *
10
+ * WHAT IT LEAVES ALONE. A label with no trailing "· N", objects without `id`, files that do not import Grammar, and non-product source.
11
+ */
12
+ const TRAILING_COUNT = /·\s*\d+$/;
13
+ const TRAILING_SLOT = /·\s*$/;
14
+ const keyName = (property) => property.key.type === "Identifier" && !property.computed ? property.key.name : property.key.type === "Literal" && typeof property.key.value === "string" ? property.key.value : null;
15
+ /** A tab label never carries its count as text: the count is the tab's `count`, drawn as a chip. */
16
+ export const tabCountChip = defineRule({
17
+ meta: {
18
+ type: "problem",
19
+ docs: { description: "TAB-COUNT-CHIP: a tab count is the `count` prop drawn as a 12px chip, never \"· N\" text in the label." },
20
+ schema: [],
21
+ messages: {
22
+ label: "The tab label `{{label}}` carries its count as text. Pass `count` (and `isAttention` only when the number is work waiting for the owner): the tab draws the 12px chip.",
23
+ },
24
+ },
25
+ create(context) {
26
+ if (!isProductSource(context))
27
+ return {};
28
+ let importsGrammar = false;
29
+ return {
30
+ ImportDeclaration(node) {
31
+ if (typeof node.source.value === "string" && /^@starci\/grammar(?:\/|$)/.test(node.source.value))
32
+ importsGrammar = true;
33
+ },
34
+ ObjectExpression(node) {
35
+ if (!importsGrammar)
36
+ return;
37
+ const properties = node.properties.filter((entry) => entry.type === "Property");
38
+ if (!properties.some((entry) => keyName(entry) === "id"))
39
+ return;
40
+ const label = properties.find((entry) => keyName(entry) === "label");
41
+ if (label === undefined)
42
+ return;
43
+ const value = label.value;
44
+ if (value.type === "Literal" && typeof value.value === "string" && TRAILING_COUNT.test(value.value)) {
45
+ context.report({ node: label, messageId: "label", data: { label: value.value } });
46
+ return;
47
+ }
48
+ if (value.type === "TemplateLiteral" && value.expressions.length > 0) {
49
+ const lastQuasi = value.quasis[value.quasis.length - 1];
50
+ const before = value.quasis[value.quasis.length - 2];
51
+ if (lastQuasi !== undefined && before !== undefined && lastQuasi.value.cooked === "" && TRAILING_SLOT.test(before.value.cooked ?? "")) {
52
+ context.report({ node: label, messageId: "label", data: { label: context.sourceCode.getText(value) } });
53
+ }
54
+ }
55
+ },
56
+ };
57
+ },
58
+ });
59
+ /** The rules this law contributes to the plugin. */
60
+ export const rules = {
61
+ "tab-count-chip": tabCountChip,
62
+ };
63
+ defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#TAB-COUNT-CHIP");
64
+ /** Every rule of this law is an error. */
65
+ export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
@@ -0,0 +1,34 @@
1
+ # One content per card
2
+
3
+ Law module: `card-content.ts`. Finding codes: `FE_CARD_ONE_CONTENT`, `FE_NO_LABEL_DESCRIPTION`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#CARD-ONE-CONTENT`.
4
+
5
+ A `SurfaceCard` holds exactly ONE content: a list, an input group (a form), a table, a graph or a figures ribbon, with its own controls (a tab, search or pagination zone, a form footer with Cancel and Save). Several groups are several cards, each with a `Sublabel` above it; items of the same kind stay in one list. A card inside a card is `no-raised-surface-in-surface` (R340). A label has no description under it.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/card-one-content`
10
+
11
+ - A `SurfaceCard` (not `figures`, not `tile`) whose body holds more than one content component (`ListBox`, `ItemList`, `DescriptionList`, `DataTable`, `FlowGraph`, `BarChart`, `Timeline`, `Form`, `FormGrid`, a `Section kind="list"` or `"figures"`, ...), looked through layout wrappers (message `many`).
12
+ - A card that carries a `figures` header zone while it is not itself `kind="figures"`: a ribbon above another content (message `ribbon`).
13
+
14
+ ## `starci-grammar/no-label-description`
15
+
16
+ - A `Section` with a `description` prop (message `section`): write `caption`.
17
+ - A labelled `SurfaceCard` (not a tile) with a `description` prop (message `card`): write `note`.
18
+
19
+ **Invalid**
20
+
21
+ ```tsx
22
+ <SurfaceCard label="Order"><ListBox label="Lines" .../><DescriptionList items={facts} /></SurfaceCard>
23
+ <Section title="Runs" description="Everyone on the team">...</Section>
24
+ ```
25
+
26
+ **Valid**
27
+
28
+ ```tsx
29
+ <Sublabel>Lines</Sublabel><SurfaceCard kind="list" label="Lines" items={lines} empty="-" />
30
+ <Sublabel>Facts</Sublabel><SurfaceCard kind="details" label="Facts" items={facts} />
31
+ <Section title="Runs" caption="Everyone on the team">...</Section>
32
+ ```
33
+
34
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -0,0 +1,25 @@
1
+ # Icons are outline only
2
+
3
+ Law module: `outline-icons.ts`. Finding code: `FE_OUTLINE_ICONS_ONLY`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#ICONS-OUTLINE`.
4
+
5
+ Never a filled or solid icon. An icon that stands alone as the mark of a row, a card, an empty state or a graph step sits in an icon tile (a soft-tone square holding an outline icon); an icon inline with text (a status beside a 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 is a tone-coloured outline icon with no tile.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/outline-icons-only`
10
+
11
+ - An import, re-export, dynamic import or `require` of `@heroicons/react/16/solid`, `/20/solid`, `/24/solid` (or `@starci/heroicons/<size>/solid`), in any source file (message `solid`).
12
+
13
+ **Invalid**
14
+
15
+ ```tsx
16
+ import { CheckIcon } from "@heroicons/react/16/solid"
17
+ ```
18
+
19
+ **Valid**
20
+
21
+ ```tsx
22
+ import { CheckCircleIcon } from "@heroicons/react/24/outline"
23
+ ```
24
+
25
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -0,0 +1,28 @@
1
+ # A section head is one row with at most one thing at its end
2
+
3
+ Law module: `section-head-action.ts`. Finding code: `FE_SECTION_HEAD_ACTION`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#SECTION-HEAD-ACTION`.
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.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/section-head-action`
10
+
11
+ - A Grammar `Button` inside a `Section`'s `action` prop (message `button`): navigation is a `Link`.
12
+ - More than one Grammar `Button`, `Link`, `IconButton` or `TextAction` inside that `action` (message `many`).
13
+
14
+ **Invalid**
15
+
16
+ ```tsx
17
+ <Section title="Runs" action={<Button size="sm" onPress={open}>Open</Button>}>...</Section>
18
+ <Section title="Runs" action={<><Link href="/a">A</Link><IconButton label="About" glyph="more" /></>}>...</Section>
19
+ ```
20
+
21
+ **Valid**
22
+
23
+ ```tsx
24
+ <Section title="Runs" count={3} action={<Link variant="head" href="/runs">All runs</Link>}>...</Section>
25
+ <Section title="Runs" action={<IconButton label="About runs" glyph="more" />}>...</Section>
26
+ ```
27
+
28
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -0,0 +1,26 @@
1
+ # A tab count is a chip
2
+
3
+ Law module: `tab-count-chip.ts`. Finding code: `FE_TAB_COUNT_CHIP`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#TAB-COUNT-CHIP`.
4
+
5
+ A count on any tab (page layer 1 or 2, a filter tab) is a 12px chip the tab draws from `count`, never "\· N" text in the label. The chip is grey; it is pink only when the number is work waiting for the owner (`isAttention`). Page tabs hide the chip at 0; filter tabs keep a grey 0.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/tab-count-chip`
10
+
11
+ - An object with `id` and `label` (a tab item) in a file that imports `@starci/grammar`, whose string `label` ends in `\· <digits>`, or whose template label ends in `\· ${expression}` (message `label`).
12
+
13
+ **Invalid**
14
+
15
+ ```tsx
16
+ { id: "all", label: "All \· 5" }
17
+ ```
18
+
19
+ **Valid**
20
+
21
+ ```tsx
22
+ { id: "all", label: "All", count: 5 }
23
+ { id: "todo", label: "To approve", count: 3, isAttention: true }
24
+ ```
25
+
26
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-grammar-core",
3
- "version": "0.35.0",
3
+ "version": "0.36.1",
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": "54a3d0a7543b01bb24a0b936762e9c31e28ecd52",
72
- "starciSource": "e017e47252926b5e3ef802ec6ef8b01f0002c4d9b8717d030606a866f34d5bc1"
71
+ "gitHead": "7056bd68fcd2ade7e4a84bbf2dddf5b74ed5292b",
72
+ "starciSource": "c68cfee17772da97b2fadaddb52f74907c7a57d504624e59ea2009dc0ee64c69"
73
73
  }
@@ -148,6 +148,53 @@ rules:
148
148
  assert: |-
149
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
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.
151
+ - id: SECTION-HEAD-ACTION
152
+ title: A section head is one row with at most one thing at its end
153
+ governs: The head of a Grammar Section.
154
+ cases:
155
+ - id: case-1
156
+ when: A Section head carries an action
157
+ assert: |-
158
+ 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.
161
+ - id: TAB-COUNT-CHIP
162
+ title: A tab count is a 12px chip, grey unless it is work waiting for the owner
163
+ governs: The count on a Grammar tab, page layers 1 and 2 and filter tabs.
164
+ cases:
165
+ - id: case-1
166
+ when: A tab shows how many items its view holds
167
+ assert: |-
168
+ The count is the tab's `count`, drawn as a 12px chip, never "· N" text in the label (a label ending in a middle dot and a number is refused).
169
+ The chip is grey; it is pink only when the number is work waiting for the owner (`isAttention`: to handle, to approve, an error). Page tabs
170
+ (layers 1 and 2) hide the chip when the count is 0; filter tabs inside a table or list show a grey 0.
171
+ - id: CARD-ONE-CONTENT
172
+ title: One content per card, a surface on the well has a shadow and a surface on white has a border
173
+ governs: A SurfaceCard's content and its edge.
174
+ cases:
175
+ - id: case-1
176
+ when: A card is written
177
+ assert: |-
178
+ A card holds exactly ONE content: a list, an input group (form), a table, a graph or a figures ribbon, with its own controls (a tab, search or pagination
179
+ zone, a form footer with Cancel and Save). Several groups are several cards, each with a Sublabel above it; items of the same kind stay in one list. A card
180
+ inside a card is refused. A label has no description under it: the description is a caption under the card (Section caption, SurfaceCard note), and a legend
181
+ (a FlowGraph's kinds) stands under the card as chips.
182
+ - id: case-2
183
+ when: A surface is painted
184
+ assert: |-
185
+ A card on the pink well has the card shadow and NO border; a surface on a white surface (a Pane surface, the aside, a Drawer, a Dialog, a Popover) has the
186
+ 1px separator border and no shadow. The Grammar decides from context; an app never chooses. A FlowGraph inside a card draws no frame of its own.
187
+ - id: ICONS-OUTLINE
188
+ title: Icons are outline only; a tile marks a standalone icon
189
+ governs: Every icon Grammar and an app draw.
190
+ cases:
191
+ - id: case-1
192
+ when: An icon is drawn
193
+ assert: |-
194
+ Never filled or solid: no @heroicons/react 16/20/24 solid import, no filled glyph, no filled-circle status mark. An icon that STANDS ALONE as the mark of a
195
+ row, a card, an empty state or a graph step gets an icon tile (a soft-tone square holding an outline icon). An icon INLINE with text (a status beside a
196
+ 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
+ skipped) is a tone-coloured outline icon with no tile: outline check-circle in success, x-circle in danger, a spinning arrow for running.
151
198
  - id: SINGLE-CHILD-CARD
152
199
  title: A table, list or chart standing alone is the surface
153
200
  governs: A SurfaceCard whose only content is a table, a list or a chart.