@starci/eslint-grammar-core 0.20.2 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +25 -1
  2. package/README.md +5 -4
  3. package/dist/app-shell.js +1 -1
  4. package/dist/grammar-boundary.js +5 -5
  5. package/dist/icon.d.ts +0 -4
  6. package/dist/icon.js +1 -64
  7. package/dist/index.js +4 -2
  8. package/dist/lib/app-shell-cluster.js +1 -1
  9. package/dist/lib/app-shell-owner.js +1 -1
  10. package/dist/lib/app-shell-scope.js +1 -1
  11. package/dist/lib/app-shell-visible.js +0 -1
  12. package/dist/lib/app-shell.js +2 -2
  13. package/dist/lib/grammar-imports.d.ts +16 -0
  14. package/dist/lib/grammar-imports.js +37 -0
  15. package/dist/lib/why.js +31 -6
  16. package/dist/page-header.d.ts +11 -4
  17. package/dist/page-header.js +12 -42
  18. package/dist/page.d.ts +3 -3
  19. package/dist/page.js +21 -21
  20. package/dist/pane.js +3 -3
  21. package/dist/status-colors.js +2 -2
  22. package/dist/surface-card.d.ts +9 -0
  23. package/dist/surface-card.js +191 -0
  24. package/dist/surface-depth.d.ts +1 -1
  25. package/dist/surface-depth.js +53 -49
  26. package/dist/text-rules.d.ts +18 -0
  27. package/dist/text-rules.js +160 -0
  28. package/dist/tokens.d.ts +0 -2
  29. package/dist/tokens.js +0 -38
  30. package/docs/app-shell.md +3 -3
  31. package/docs/grammar-boundary.md +1 -1
  32. package/docs/page-header.md +15 -12
  33. package/docs/page.md +5 -5
  34. package/docs/status-colors.md +1 -1
  35. package/docs/surface-card.md +57 -0
  36. package/docs/surface-depth.md +16 -14
  37. package/package.json +3 -3
  38. package/runtime/bundle.json +2 -1
  39. package/runtime/knowledge/grammars/core/playbook.yaml +41 -51
  40. package/runtime/knowledge/hfs/canon-pins.yaml +7 -7
  41. package/runtime/knowledge/hfs/rules.yaml +286 -40
  42. package/runtime/knowledge/hfs/slots.yaml +5 -5
  43. package/runtime/knowledge/patterns/fe/ui.yaml +0 -1
  44. package/runtime/knowledge/ui/proof/anatomy-source.yaml +1 -1
  45. package/runtime/scripts/hfs/architecture/component-tiers.mjs +161 -0
  46. package/runtime/scripts/hfs/architecture/config.mjs +1 -1
  47. package/runtime/scripts/hfs/slot-manifest-shape.mjs +16 -1
  48. package/dist/typography.d.ts +0 -13
  49. package/dist/typography.js +0 -72
@@ -0,0 +1,160 @@
1
+ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
2
+ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
3
+ /**
4
+ * The laws of text and emphasis (HFS R357, R358, R359).
5
+ *
6
+ * text-inline-only (R357) `Text` is a run of words: a block component inside it is a layout drawn in a paragraph.
7
+ * no-text-heading (R358) a strong `Text` that only heads a group of blocks is a hand heading: use `Section`, a card
8
+ * `label` or `Heading`, which own the level, the spacing and the outline.
9
+ * one-highlight-per-render (R359) a render states one highlighted thing (G-9): a second `isHighlight` dilutes the first.
10
+ *
11
+ * WHAT THEY READ. Grammar names are resolved through the file's own imports from `@starci/grammar`, so an alias or a local
12
+ * component of the same name is not judged. A spread attribute or a computed value is not judged.
13
+ */
14
+ /** Components that lay content out as blocks: none of them belongs inside a run of text. */
15
+ export const BLOCK_COMPONENTS = new Set([
16
+ "Stack", "Cluster", "Grid", "Section", "SurfaceCard", "DataTable", "Heading", "DescriptionList",
17
+ "Divider", "Page", "Pane", "PaneGrid", "PaneSection", "Form", "Fieldset", "Quote", "Alert", "Stepper", "Timeline", "MarkdownArticle", "EmptyNotice",
18
+ "ListRow", "StaticStateRow", "SegmentedControl", "FilterButtonGroup", "Tabs",
19
+ ]);
20
+ /** Plain elements that are blocks. */
21
+ const BLOCK_TAGS = new Set(["div", "p", "ul", "ol", "li", "section", "article", "table", "form", "h1", "h2", "h3", "h4", "h5", "h6", "pre", "blockquote"]);
22
+ /** The Grammar export a file's import binds to a local name. */
23
+ const grammarImports = (program) => {
24
+ const bound = new Map();
25
+ for (const statement of program.body) {
26
+ if (statement.type !== "ImportDeclaration" || typeof statement.source.value !== "string" || !/^@starci\/grammar(?:\/|$)/.test(statement.source.value))
27
+ continue;
28
+ for (const specifier of statement.specifiers) {
29
+ if (specifier.type === "ImportSpecifier")
30
+ bound.set(specifier.local.name, specifier.imported.type === "Identifier" ? specifier.imported.name : String(specifier.imported.value));
31
+ }
32
+ }
33
+ return bound;
34
+ };
35
+ const nameOf = (opening, bound) => {
36
+ const name = opening.name;
37
+ if (name.type !== "JSXIdentifier")
38
+ return { grammar: null, tag: null };
39
+ const grammar = bound.get(name.name);
40
+ if (grammar !== undefined)
41
+ return { grammar, tag: null };
42
+ return { grammar: null, tag: name.name === name.name.toLowerCase() ? name.name : null };
43
+ };
44
+ const isBlock = (element, bound) => {
45
+ const { grammar, tag } = nameOf(element.openingElement, bound);
46
+ return (grammar !== null && BLOCK_COMPONENTS.has(grammar)) || (tag !== null && BLOCK_TAGS.has(tag));
47
+ };
48
+ /** Whether an attribute is present and not statically false; a spread or a computed value counts as unknown (false). */
49
+ const isOn = (opening, attribute) => opening.attributes.some((entry) => {
50
+ if (entry.type !== "JSXAttribute" || entry.name.type !== "JSXIdentifier" || entry.name.name !== attribute)
51
+ return false;
52
+ const value = entry.value;
53
+ if (value === null)
54
+ return true;
55
+ if (value.type === "JSXExpressionContainer")
56
+ return value.expression.type === "Literal" && value.expression.value === true;
57
+ return false;
58
+ });
59
+ const meaningful = (children) => children.filter((child) => !(child.type === "JSXText" && child.value.trim() === "") && !(child.type === "JSXExpressionContainer" && child.expression.type === "JSXEmptyExpression"));
60
+ const textInlineOnly = defineRule({
61
+ meta: {
62
+ type: "problem",
63
+ docs: { description: "R357: Text holds a run of words; a block component inside it is refused.", url: "knowledge/hfs/rules.yaml#R357" },
64
+ schema: [],
65
+ messages: { block: "`{{name}}` is a block, and `Text` is a run of words: a block inside it is a layout drawn in a paragraph. Close the `Text` and place the block beside it, or use the component that owns that layout." },
66
+ },
67
+ create(context) {
68
+ if (!isProductSource(context))
69
+ return {};
70
+ let bound = new Map();
71
+ return {
72
+ Program(node) { bound = grammarImports(node); },
73
+ JSXElement(node) {
74
+ if (nameOf(node.openingElement, bound).grammar !== "Text")
75
+ return;
76
+ for (const child of node.children) {
77
+ if (child.type !== "JSXElement" || !isBlock(child, bound))
78
+ continue;
79
+ const { grammar, tag } = nameOf(child.openingElement, bound);
80
+ context.report({ node: child.openingElement, messageId: "block", data: { name: grammar ?? tag ?? "element" } });
81
+ }
82
+ },
83
+ };
84
+ },
85
+ });
86
+ const noTextHeading = defineRule({
87
+ meta: {
88
+ type: "problem",
89
+ docs: { description: "R358: a strong Text alone heading a group of blocks is a hand heading.", url: "knowledge/hfs/rules.yaml#R358" },
90
+ schema: [],
91
+ messages: { heading: "This strong `Text` only titles the blocks that follow it, which is a heading written by hand: it has no level in the outline and each page spaces it differently. Give the group a `Section` title, a card `label`, or `Heading`." },
92
+ },
93
+ create(context) {
94
+ if (!isProductSource(context))
95
+ return {};
96
+ let bound = new Map();
97
+ const check = (parent) => {
98
+ const children = meaningful(parent.children);
99
+ const [first, ...rest] = children;
100
+ if (first === undefined || first.type !== "JSXElement" || rest.length === 0)
101
+ return;
102
+ if (nameOf(first.openingElement, bound).grammar !== "Text" || !isOn(first.openingElement, "isStrong"))
103
+ return;
104
+ if (first.children.some((child) => child.type === "JSXElement" && isBlock(child, bound)))
105
+ return;
106
+ if (rest.every((child) => child.type === "JSXElement" && isBlock(child, bound)))
107
+ context.report({ node: first.openingElement, messageId: "heading" });
108
+ };
109
+ return { Program(node) { bound = grammarImports(node); }, JSXElement: check, JSXFragment: check };
110
+ },
111
+ });
112
+ const oneHighlightPerRender = defineRule({
113
+ meta: {
114
+ type: "problem",
115
+ docs: { description: "R359: a render states one highlighted thing; a second isHighlight is refused.", url: "knowledge/hfs/rules.yaml#R359" },
116
+ schema: [],
117
+ messages: { second: "A second `isHighlight` in one render: when two things are highlighted neither is, and the eye has no first place to land. Keep the one that matters now and give the other its plain state." },
118
+ },
119
+ create(context) {
120
+ if (!isProductSource(context))
121
+ return {};
122
+ let bound = new Map();
123
+ const seen = new WeakMap();
124
+ const enclosing = (node) => {
125
+ for (let current = node.parent; current; current = current.parent) {
126
+ if (current.type === "ArrowFunctionExpression" || current.type === "FunctionDeclaration" || current.type === "FunctionExpression") {
127
+ // a callback of a map/filter is one render of many rows, not a second thing in the same render
128
+ const parent = current.parent;
129
+ if (current.type !== "FunctionDeclaration" && parent?.type === "CallExpression" && parent.callee.type === "MemberExpression")
130
+ continue;
131
+ return current;
132
+ }
133
+ }
134
+ return null;
135
+ };
136
+ return {
137
+ Program(node) { bound = grammarImports(node); },
138
+ JSXOpeningElement(node) {
139
+ if (nameOf(node, bound).grammar === null || !isOn(node, "isHighlight"))
140
+ return;
141
+ const fn = enclosing(node);
142
+ if (fn === null)
143
+ return;
144
+ const count = (seen.get(fn) ?? 0) + 1;
145
+ seen.set(fn, count);
146
+ if (count > 1)
147
+ context.report({ node, messageId: "second" });
148
+ },
149
+ };
150
+ },
151
+ });
152
+ /** The rules this law contributes to the plugin. */
153
+ export const rules = {
154
+ "text-inline-only": textInlineOnly,
155
+ "no-text-heading": noTextHeading,
156
+ "one-highlight-per-render": oneHighlightPerRender,
157
+ };
158
+ defineFamilyRules(rules, "knowledge/hfs/rules.yaml#R357");
159
+ /** Every rule of this law is an error. */
160
+ export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
package/dist/tokens.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import type { Rule } from "eslint";
2
2
  /** A fractional step is off the ladder, not between two rungs. */
3
3
  export declare const noFractionalStep: Rule.RuleModule;
4
- /** Large text plus a heavy weight is a heading, and headings come from the component that owns both. */
5
- export declare const noHandRolledHeading: Rule.RuleModule;
6
4
  /** A class naming a token the theme never defines is a class that draws nothing. */
7
5
  export declare const noUnresolvedTokenClass: Rule.RuleModule;
8
6
  /** StarCi scale rules, bound to their knowledge owner. */
package/dist/tokens.js CHANGED
@@ -12,10 +12,6 @@ import { defineFamilyRules, defineRule, exemptFreestyle } from "./lib/rule-contr
12
12
  * the ladder, and it will match nothing else on any screen.
13
13
  */
14
14
  const FRACTIONAL = /\b(?:gap|gap-x|gap-y|p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|space-x|space-y|inset|top|bottom|left|right|size|w|h)-\d+\.\d+\b/;
15
- /** Large text. Paired with a heavy weight it is a heading, whatever element carries it. */
16
- const LARGE_TEXT = /\btext-(?:xl|2xl|3xl|4xl|5xl)\b/;
17
- /** A heavy weight. */
18
- const HEAVY_WEIGHT = /\bfont-(?:bold|extrabold|black)\b/;
19
15
  /** A fractional step is off the ladder, not between two rungs. */
20
16
  export const noFractionalStep = exemptFreestyle(defineRule({
21
17
  meta: {
@@ -36,39 +32,6 @@ export const noFractionalStep = exemptFreestyle(defineRule({
36
32
  });
37
33
  },
38
34
  }));
39
- /** Large text plus a heavy weight is a heading, and headings come from the component that owns both. */
40
- export const noHandRolledHeading = defineRule({
41
- meta: {
42
- type: "problem",
43
- docs: { description: "A heading comes from the heading component, not from raw type classes." },
44
- schema: [],
45
- messages: {
46
- heading: "Large text and a heavy weight together are a heading, whatever element carries them - and assembled here it is a heading nothing else knows about: the outline a screen reader builds does not contain it, and it stays behind the day the type scale changes. Render the heading component, which owns the tag and the size as one decision.",
47
- },
48
- },
49
- create(context) {
50
- return classTextVisitors(context, (node, text) => {
51
- if (!text)
52
- return;
53
- if (LARGE_TEXT.test(text) && HEAVY_WEIGHT.test(text)) {
54
- context.report({ node, messageId: "heading" });
55
- }
56
- });
57
- },
58
- });
59
- /**
60
- * The class families whose names are PROMISES about a theme token, and the variable each needs.
61
- *
62
- * Tailwind resolves `max-w-app-lg` by looking for `--container-app-lg`. Nothing warns when that
63
- * variable does not exist: the class is emitted, the element gets no width, and the type system
64
- * is satisfied because the name IS in the union. That is the failure this rule exists for - a
65
- * class can be typesafe and mean nothing at the same time, and the union is exactly what makes
66
- * it look settled.
67
- *
68
- * Only families whose token name is DERIVABLE from the class name are listed. A colour or a
69
- * spacing step resolves through Tailwind's own scale as well as the theme, so a rule guessing at
70
- * those would report classes that work.
71
- */
72
35
  /**
73
36
  * Names Tailwind resolves ITSELF, which therefore promise nothing about this theme.
74
37
  *
@@ -158,7 +121,6 @@ export const noUnresolvedTokenClass = defineRule({
158
121
  /** StarCi scale rules, bound to their knowledge owner. */
159
122
  export const rules = {
160
123
  "no-fractional-step": noFractionalStep,
161
- "no-hand-rolled-heading": noHandRolledHeading,
162
124
  "no-unresolved-token-class": noUnresolvedTokenClass,
163
125
  };
164
126
  defineFamilyRules(rules, "knowledge/hfs/rules.yaml#R61");
package/docs/app-shell.md CHANGED
@@ -8,16 +8,16 @@ or a shell owner combining a bar and sidebar. It rejects hand-written app-frame
8
8
  workspace shells without the fixed viewport. Generic flow-based site chrome stays in its own scope.
9
9
  `no-shell-bottom-tabs` rejects bottom navigation components and the shell's `compactNavigation` slot.
10
10
 
11
- The `navbar-cluster` rule reads the visible `TopBar` or `NavigationFeatureNav` actions in source order:
11
+ The `navbar-cluster` rule reads the visible `TopBar` actions in source order:
12
12
  tertiary Language `IconButton` triggering `DropdownMenu`, theme `Switch`, notification `IconButton`
13
13
  triggering `Popover`, account `AvatarButton` triggering `DropdownMenu`. It follows
14
14
  local JSX constants and components, constant object members, imported Grammar aliases, and namespace imports. Translated
15
15
  labels may be dynamic; icon sources identify language and notifications. Menu contents and popover
16
16
  content belong to their overlays and are outside the bar's control sequence. Conditional render
17
- branches are checked separately. Grammar `TopBar` and `NavigationFeatureNav` compositions are app
17
+ branches are checked separately. Grammar `TopBar` compositions are app
18
18
  bars by default. A proven `WorkspaceShell viewport="flow"` with no workspace/sidebar evidence owns
19
19
  generic site chrome. A shell hosting an imported navbar delegates only after its owned public
20
- export and rendered Base chain prove a `TopBar` or `NavigationFeatureNav` in every alternative.
20
+ export and rendered Base chain prove a `TopBar` in every alternative.
21
21
  Workspace exports resolve back to source. Raw or unknown imported headers are red; the actual
22
22
  bar's own actions are checked where composed. Each lint source snapshot has fresh dependency proofs.
23
23
 
@@ -12,7 +12,7 @@ Page structure and text are grammar components, not raw `div`-family HTML; only
12
12
 
13
13
  Applies to app source that composes the grammar (slots `fe.feature`, `fe.components`, `fe.route`, `fe.hooks`) and to every workspace package except the `<family>-ui` package (`fe.package.ui`), whose components are the renderers. Spec files render raw HTML as a harness and are not judged; a file no slot owns is not judged.
14
14
 
15
- The refused tags are exactly those `@starci/grammar` has a component for (the twin test reads the package source): `h1-h6` (`Heading`), `p` and `span` (`Text`), `hr` (`Divider`), `label` (`Label`), `form` (`Form`), `fieldset` (`Fieldset`), `dl` `dt` `dd` (`DescriptionList`), `table` `thead` `tbody` `tr` `td` `th` (`DataTable`), `ul` `ol` `li` (`List` and `ListItem` for a plain semantic list, `SurfaceListCard`, `StaticStateRow`), `header` (`SectionHeader`, `TopBar`), `footer` (`Footer`), `nav` (`NavLandmark` for a named row of links, `Subnav`, `Breadcrumbs`, `NavigationFeatureNav`), `section` (`Region` for a named non-card region, `SurfaceCard`), `main` (`WorkspaceShell`), `figure` and `figcaption` (`MediaFrame`). `div`, `br`, `aside` and `article` are not refused: the grammar has no component for them.
15
+ The refused tags are exactly those `@starci/grammar` has a component for (the twin test reads the package source): `h1-h6` (`Heading`), `p` and `span` (`Text`), `hr` (`Divider`), `label` (`Input`, `Select`, `Textarea`), `form` (`Form`), `fieldset` (`Fieldset`), `dl` `dt` `dd` (`DescriptionList`), `table` `thead` `tbody` `tr` `td` `th` (`DataTable`), `ul` `ol` `li` (`Section` for a long list, `SurfaceListCard`, `StaticStateRow`), `header` (`Section`, `TopBar`), `footer` (`Footer`), `nav` (`NavLandmark` for a named row of links, `Page` for the breadcrumb trail, `TopBar` for the app bar), `section` (`Section` for a named non-card section, `SurfaceCard`), `main` (`WorkspaceShell`), `figure` and `figcaption` (`MediaFrame`). `div`, `br`, `aside` and `article` are not refused: the grammar has no component for them.
16
16
 
17
17
  Native `<time>` remains available for an absolute timestamp. Live relative time and countdown labels use `RelativeTime` (the universal canon's `starci-fe/no-app-relative-clock`).
18
18
 
@@ -1,32 +1,35 @@
1
- # Page heads are PageHeader
1
+ # Page heads are Page header
2
2
 
3
3
  Law module: `page-header.ts`. Catalogue: R323 FE_PAGE_HEADER_HAND_ROLLED.
4
4
 
5
- A page is headed by Grammar's `PageHeader`: the trail, the page heading with its mark, status and summary, the page's commands and the page tabs, on a surface band whose content shares the page content's edges and which ends in its own full-width separator. A head composed by hand from `Breadcrumbs` and `SectionHeader` has no band, no top inset and no separator, and every page re-decides its spacing.
5
+ A page is headed by Grammar's `Page`, whose `header` is the band: the trail, the page heading with its mark, status and summary, the page's commands and the page tabs, on a surface band whose content shares the page content's edges and which ends in its own full-width separator. `PageHeader` and `Breadcrumbs` are Page's parts and are not exported; a head composed from them has no band, no top inset and no separator, and every page re-decides its spacing. The law reduces to imports.
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/no-hand-rolled-page-header`
10
10
 
11
- Among the element children of one JSX element or fragment, a `Breadcrumbs` element followed by a `SectionHeader` element is a finding, reported on the `SectionHeader`. A trail and a heading in different parents, a heading before the trail, and either alone are not judged, so a region's `SectionHeader` under the page head stays legal.
11
+ A `PageHeader` or `Breadcrumbs` imported from `@starci/grammar` (by name, through an alias, or as a member of a namespace import) is a finding, reported on the import or the member. The types of the header's slots (`PageHeaderBreadcrumbs`, `PageHeaderTabs`) stay public and are not judged; the same names from another module are not the Grammar's.
12
12
 
13
13
  **Invalid** (`src/components/blocks/ConnectionPage/component.tsx`)
14
14
 
15
15
  ```tsx
16
- <div>
17
- <Breadcrumbs label="Breadcrumb" items={trail} />
18
- <SectionHeader title="Main account" level={1} action={<Button intent="neutral">Disconnect</Button>} />
19
- </div>
16
+ import { PageHeader } from "@starci/grammar/core"
17
+
18
+ <PageHeader title="Main account" actions={<Button intent="neutral">Disconnect</Button>} />
20
19
  ```
21
20
 
22
21
  **Valid** (`src/components/blocks/ConnectionPage/component.tsx`)
23
22
 
24
23
  ```tsx
25
- <PageHeader
26
- breadcrumbs={{ label: "Breadcrumb", items: trail }}
27
- title="Main account"
28
- actions={<Button intent="neutral">Disconnect</Button>}
29
- />
24
+ <Page
25
+ header={{
26
+ breadcrumbs: { label: "Breadcrumb", items: trail },
27
+ title: "Main account",
28
+ actions: <Button intent="neutral">Disconnect</Button>,
29
+ }}
30
+ >
31
+ <WebhookCard />
32
+ </Page>
30
33
  ```
31
34
 
32
35
  **Finding code:** `FE_PAGE_HEADER_HAND_ROLLED`
package/docs/page.md CHANGED
@@ -8,7 +8,7 @@ Every rule below is an error in `coreGrammarConfig`; none can be switched off or
8
8
 
9
9
  ## `starci-grammar/page-tabs-in-header`
10
10
 
11
- A `Tabs` element that is the first element child of a `Page`, or the next element sibling of a `PageHeader`, is a finding, reported on the `Tabs`. Whitespace text and JSX comments are not children. A `Tabs` lower in the body, or inside a body section, is region tabs and is not judged.
11
+ A `Tabs` element that is the first element child of a `Page` is a finding, reported on the `Tabs`. Whitespace text and JSX comments are not children. A `Tabs` lower in the body, or inside a body section, is region tabs and is not judged.
12
12
 
13
13
  **Invalid** (`src/features/pages/ConnectionPage/component.tsx`)
14
14
 
@@ -39,7 +39,7 @@ Findings, each reported on the element:
39
39
 
40
40
  - `sibling`: an element that draws the `Page` has an element sibling in its parent, in a page owner or a layout owner.
41
41
  - `twice`: an element that draws a `Page` sits inside another one (a `Page` in a `Page`, or a block that draws one inside a `Page` or inside the root block), or sits in a page owner mounted by a route under a segment layout that draws the `Page`; the finding names that layout.
42
- - `part`: any `PageHeader` or `PageContainer` in a page or layout owner: both are Page's own parts.
42
+ - `part`: a `PageHeader` or `PageContainer` imported from `@starci/grammar` (by name or through a namespace) in a page or layout owner: both are Page's own parts and are not exported, so this finding is the import.
43
43
  - `missing`: a page owner file draws JSX but nothing that draws the `Page`, and draws no element imported from its own pure half, reported on its first element: the page has no frame at all.
44
44
 
45
45
  A `Page` (or the root block) alone in a fragment or a provider, and one per branch of a conditional, are legal; the root block's children are the page body. Not judged for `missing`:
@@ -54,6 +54,8 @@ A workbench page is an ordinary page: it draws its `Page` like any other, usuall
54
54
  **Invalid** (`src/features/pages/ConnectionPage/component.tsx`)
55
55
 
56
56
  ```tsx
57
+ import { PageHeader, PageContainer } from "@starci/grammar/core"
58
+
57
59
  <>
58
60
  <PageHeader title="Main account" />
59
61
  <PageContainer><WebhookCard /></PageContainer>
@@ -99,9 +101,7 @@ A workbench page is an ordinary page: it draws its `Page` like any other, usuall
99
101
 
100
102
  ```tsx
101
103
  <Page chrome="bleed" header={{ breadcrumbs }}>
102
- <FillViewport minHeight="md" bottomInset="page">
103
- <SurfaceCard ariaLabel={label} composition="joined" height="fill">{rail}{thread}</SurfaceCard>
104
- </FillViewport>
104
+ <SurfaceCard ariaLabel={label} composition="joined" height="fill">{rail}{thread}</SurfaceCard>
105
105
  </Page>
106
106
  ```
107
107
 
@@ -1,6 +1,6 @@
1
1
  # Status colors: content on a tone background takes the soft pair, a lone mark takes the tone
2
2
 
3
- Law module: `status-colors.ts`. Catalogue: R61 FE_STYLE_TOKEN_ONLY (the class-name half of the status-pair contrast obligation; the brand layer's own contrast is `starci/status-contrast` of @starci/stylelint-canon).
3
+ Law module: `status-colors.ts`. Catalogue: R61 FE_STYLE_TOKEN_ONLY (the status-pair rule for class names; no gate judges the colours an app's theme gives the pair).
4
4
 
5
5
  A status tone `x` (`success`, `warning`, `danger`, `info`, read from `lib/status-tones.generated.ts`, which is generated from the grammar with the stylelint vocabulary) paints in two ways. Content that sits on a background of the tone uses the pair `x-soft` and `x-soft-foreground`, the way a HeroUI flat Chip does. A mark that stands alone, with no background of the tone behind it, uses `x` itself. A solid fill takes `x-foreground`. The owner's words: "TEXT TRÊN BG THÌ X-SOFT VÀ X-SOFT-FOREGROUND, CÒN NẾU X ĐỘC LẬP THÌ ĐỂ X LUN" (ruling `status-soft-pair-on-background`).
6
6
 
@@ -0,0 +1,57 @@
1
+ # The one card has a kind
2
+
3
+ Law module: `surface-card.ts`. Catalogue: R355 FE_SURFACE_CARD_KIND, R366 FE_LABEL_IN_GRID.
4
+
5
+ `SurfaceCard` is one component whose `kind` the compiler checks: `body` (the default), `figures`, `list`, `accordion`,
6
+ `bands` and `tile`. What a kind draws is not drawn by hand around it, and where the name sits follows the kind (ruling
7
+ `card-label-by-kind`): a card that heads a section has a `label` outside the material, a tile names itself inside.
8
+
9
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline. It applies to product
10
+ source; a script or a file no slot owns is not judged.
11
+
12
+ ## `starci-grammar/surface-card-kind`
13
+
14
+ Finding code: `FE_SURFACE_CARD_KIND` (R355). The direct children of a `SurfaceCard` of the `body` kind (no `kind`, or
15
+ `kind="body"`) are not a raw `ul`, `ol`, `li` or `dl`, not a `Divider`, and not a `SectionHeader` or `Heading` standing as a
16
+ second title. A `Section` whose only child is one `SurfaceCard` frames one subject twice. Children are read through
17
+ `cond && <x/>`, `cond ? <x/> : <y/>` and `.map`.
18
+
19
+ **Invalid** (`src/components/blocks/Runs/component.tsx`)
20
+
21
+ ```tsx
22
+ <SurfaceCard label="Runs">
23
+ <ul>{runs.map((run) => <li key={run.id}>{run.name}</li>)}</ul>
24
+ <Divider />
25
+ <SectionHeader title="Totals" />
26
+ </SurfaceCard>
27
+ ```
28
+
29
+ **Valid** (`src/components/blocks/Runs/component.tsx`)
30
+
31
+ ```tsx
32
+ <SurfaceCard kind="list" label="Runs" items={runs.map((run) => ({ id: run.id, title: run.name }))} empty={empty} />
33
+ ```
34
+
35
+ ## `starci-grammar/no-label-in-grid`
36
+
37
+ Finding code: `FE_LABEL_IN_GRID` (R366). A `SurfaceCard` with a `label` repeated in a `Grid kind="cards"` (two or more as
38
+ direct children, or one written in a `.map`) is refused. A peer you recognise and open is a tile, named inside beside its
39
+ mark; comparing a fact across peers is one `kind="list"` card.
40
+
41
+ **Invalid** (`src/components/blocks/Connectors/component.tsx`)
42
+
43
+ ```tsx
44
+ <Grid kind="cards">
45
+ {connectors.map((c) => <SurfaceCard key={c.id} label={c.name}>{c.summary}</SurfaceCard>)}
46
+ </Grid>
47
+ ```
48
+
49
+ **Valid** (`src/components/blocks/Connectors/component.tsx`)
50
+
51
+ ```tsx
52
+ <Grid kind="cards">
53
+ {connectors.map((c) => <SurfaceCard key={c.id} kind="tile" name={c.name} mark={{ icon: c.icon }} description={c.summary} />)}
54
+ </Grid>
55
+ ```
56
+
57
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -1,11 +1,11 @@
1
- # A nested surface stays subordinate
1
+ # A surface never stands inside another surface
2
2
 
3
3
  Law module: `surface-depth.ts`. Catalogue: R340 FE_RAISED_SURFACE_IN_SURFACE.
4
4
 
5
- Grammar's bounded surfaces (`SurfaceCard`, `SurfaceAccordionCard`, `SurfaceListCard`) read their depth from the surface
6
- context: raised at the top of a page (BOUNDARY-6), outlined inside another surface (BOUNDARY-5), so two raised surfaces never
7
- stack (`DNA-COMMON-NO-RAISED-SURFACE-IN-SURFACE`). `SurfaceListCard` also takes a `depth` prop that overrides the context;
8
- forcing `depth="top"` on a list that sits inside another surface raises a surface inside a surface.
5
+ The Grammar draws one depth, raised, and no nested edge: a `SurfaceCard` inside another `SurfaceCard`, inside a
6
+ `Pane surface`, or inside a `Dialog`, `Drawer`, `AlertDialog` or `Popover` is refused (owner decision: surface in surface
7
+ is banned totally, dialogs and drawers included). Development throws the same refusal from the Grammar itself; this rule is
8
+ its same-file half and R356 closes it across files.
9
9
 
10
10
  Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline. It applies to product
11
11
  source (the route, feature, component, hook, foundation, module and transport tiers and the workspace packages); a script or
@@ -13,26 +13,28 @@ a file no slot owns is not judged.
13
13
 
14
14
  ## `starci-grammar/no-raised-surface-in-surface`
15
15
 
16
- A `depth` attribute whose value is statically the string `"top"` (a literal, an expression container holding one, or a
17
- template literal without expressions) on a depth-accepting surface element (today `SurfaceListCard`, or `<ns>.SurfaceListCard`)
18
- is a finding when a `SurfaceCard`, `SurfaceListCard` or `SurfaceAccordionCard` element of the same file encloses it. A depth
19
- computed at run time, `depth="nested"`, and a surface no element of the file encloses are not judged. The fix is to drop
20
- `depth` and let the Grammar resolve it from the surface context.
16
+ A `SurfaceCard` (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that a `SurfaceCard`, `Dialog`, `Drawer`,
17
+ `AlertDialog`, `Popover`, or a `Pane` with a `surface` prop of the same file encloses is a finding. An overlay's `trigger` is
18
+ not its content, so a card written in a trigger is not enclosed by it. A surface no element of the file encloses is judged
19
+ where its parent is written. The fix gives the content to the host's own body, or uses a kind of the outer card (`bands`,
20
+ `list`, `figures`) for what needs its own faces.
21
21
 
22
22
  **Invalid** (`src/components/blocks/Runs/component.tsx`)
23
23
 
24
24
  ```tsx
25
25
  <SurfaceCard label="Run">
26
- <SurfaceListCard label="Steps" depth="top" items={steps} />
26
+ <SurfaceCard label="Steps">...</SurfaceCard>
27
27
  </SurfaceCard>
28
28
  ```
29
29
 
30
30
  **Valid** (`src/components/blocks/Runs/component.tsx`)
31
31
 
32
32
  ```tsx
33
- <SurfaceCard label="Run">
34
- <SurfaceListCard label="Steps" items={steps} />
35
- </SurfaceCard>
33
+ <SurfaceCard
34
+ kind="bands"
35
+ label="Run"
36
+ bands={[{ kind: "body", children: summary }, { kind: "list", items: steps, empty }]}
37
+ />
36
38
  ```
37
39
 
38
40
  **Finding code:** `FE_RAISED_SURFACE_IN_SURFACE`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-grammar-core",
3
- "version": "0.20.2",
3
+ "version": "0.21.2",
4
4
  "description": "ESLint rules for the core Grammar's component, token and composition contracts.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -41,7 +41,7 @@
41
41
  "node": ">=22"
42
42
  },
43
43
  "peerDependencies": {
44
- "@starci/eslint-canon-fe": "9.8.5",
44
+ "@starci/eslint-canon-fe": "9.9.2",
45
45
  "eslint": ">=9",
46
46
  "typescript": ">=5.9"
47
47
  },
@@ -55,7 +55,7 @@
55
55
  "build": "node -e \"require('node:fs').rmSync('dist', {recursive: true, force: true})\" && tsc -p tsconfig.build.json && node -e \"const fs = require('node:fs'); for (const f of fs.readdirSync('dist', {recursive: true}).filter((n) => n.endsWith('.d.ts'))) fs.writeFileSync('dist/' + f, fs.readFileSync('dist/' + f, 'utf8').replace(/((?:from |import\\()['\\x22]\\.\\.?\\/[^'\\x22]+)\\.ts(['\\x22])/g, (all, head, quote) => head + '.js' + quote))\"",
56
56
  "typecheck": "tsc -p tsconfig.json",
57
57
  "prepack": "npm run build",
58
- "test": "npm run typecheck && node --import ./fixtures/fs-audit-preload.ts --test \"src/**/*.spec.ts\""
58
+ "test": "npm run typecheck && node --import ./fixtures/canon-fe-source.ts --import ./fixtures/fs-audit-preload.ts --test \"src/**/*.spec.ts\""
59
59
  },
60
60
  "devDependencies": {
61
61
  "@starci/eslint-canon-fe": "file:../eslint-canon-fe",
@@ -14,6 +14,7 @@
14
14
  "knowledge/grammars/core/playbook.yaml",
15
15
  "knowledge/grammars/index.yaml",
16
16
  "knowledge/hfs/canon-pins.yaml",
17
+ "knowledge/hfs/rules.yaml",
17
18
  "knowledge/ui/presentation/font.yaml",
18
19
  "knowledge/ui/presentation/padding.yaml",
19
20
  "modules/kernel/removed-vocabulary.yaml",
@@ -21,6 +22,7 @@
21
22
  "modules/models/runtimes.yaml",
22
23
  "modules/models/tiers.yaml",
23
24
  "scripts/hfs/allows.mjs",
25
+ "scripts/hfs/architecture/component-tiers.mjs",
24
26
  "scripts/hfs/architecture/config.mjs",
25
27
  "scripts/hfs/architecture/side-boundary.mjs",
26
28
  "scripts/hfs/architecture/type-context.mjs",
@@ -62,7 +64,6 @@
62
64
  "own": [
63
65
  "engine/config.mjs",
64
66
  "engine/invalid-config.mjs",
65
- "knowledge/hfs/rules.yaml",
66
67
  "knowledge/hfs/slots.yaml",
67
68
  "knowledge/patterns/fe/index.yaml",
68
69
  "knowledge/patterns/fe/ui.yaml",