@starci/eslint-grammar-core 0.53.0 → 0.54.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 +5 -0
- package/README.md +8 -14
- package/dist/app-shell.d.ts +0 -11
- package/dist/app-shell.js +2 -190
- package/dist/button-arrow.d.ts +0 -7
- package/dist/button-arrow.js +1 -50
- package/dist/index.d.ts +13 -3
- package/dist/index.js +18 -19
- package/dist/lib/app-shell-scope.d.ts +0 -2
- package/dist/lib/app-shell-scope.js +0 -19
- package/dist/lib/app-shell.d.ts +0 -4
- package/dist/lib/app-shell.js +0 -25
- package/dist/lib/cross-file-inputs.js +2 -3
- package/dist/lib/why.js +5 -65
- package/dist/mascot.d.ts +0 -21
- package/dist/mascot.js +4 -69
- package/dist/no-raw-type-size.d.ts +27 -0
- package/dist/no-raw-type-size.js +107 -0
- package/dist/same-line-size.js +9 -0
- package/dist/table-cell-type.js +4 -0
- package/docs/app-shell.md +1 -37
- package/docs/button-arrow.md +1 -26
- package/docs/mascot.md +6 -34
- package/docs/no-raw-type-size.md +35 -0
- package/docs/rows-in-card.md +1 -1
- package/package.json +3 -3
- package/runtime/knowledge/patterns/fe/ui.yaml +0 -7
- package/runtime/knowledge/ui/composition/app-shell.yaml +4 -4
- package/runtime/knowledge/ui/presentation/grammar-laws.yaml +11 -0
- package/runtime/modules/goal/source-phrases.yaml +0 -4
- package/dist/chip-label.d.ts +0 -14
- package/dist/chip-label.js +0 -117
- package/dist/data-table-surface.d.ts +0 -18
- package/dist/data-table-surface.js +0 -57
- package/dist/lib/app-shell-cluster.d.ts +0 -6
- package/dist/lib/app-shell-cluster.js +0 -75
- package/dist/lib/app-shell-create.d.ts +0 -5
- package/dist/lib/app-shell-create.js +0 -37
- package/dist/lib/app-shell-owner.d.ts +0 -7
- package/dist/lib/app-shell-owner.js +0 -97
- package/dist/lib/status-tones.generated.d.ts +0 -2
- package/dist/lib/status-tones.generated.js +0 -8
- package/dist/message-surfaces.d.ts +0 -6
- package/dist/message-surfaces.js +0 -158
- package/dist/status-colors.d.ts +0 -19
- package/dist/status-colors.js +0 -217
- package/dist/suggestion-buttons.d.ts +0 -6
- package/dist/suggestion-buttons.js +0 -181
- package/dist/surface-card-list.d.ts +0 -20
- package/dist/surface-card-list.js +0 -47
- package/dist/tab-count-chip.d.ts +0 -7
- package/dist/tab-count-chip.js +0 -65
- package/docs/chip-label.md +0 -30
- package/docs/data-table-surface.md +0 -27
- package/docs/message-surfaces.md +0 -37
- package/docs/status-colors.md +0 -43
- package/docs/suggestion-buttons.md +0 -34
- package/docs/surface-card-list.md +0 -33
- package/docs/tab-count-chip.md +0 -26
|
@@ -18,9 +18,8 @@
|
|
|
18
18
|
*/
|
|
19
19
|
/** Every disk read of this canon's rules beyond the import graph. */
|
|
20
20
|
export const crossFileInputs = [
|
|
21
|
-
// the header
|
|
22
|
-
{ rule: "
|
|
23
|
-
{ rule: "navbar-cluster", kind: "content", relativeTo: "side", globs: ["packages/*/package.json", "packages/*/src/**/*.{ts,tsx}"], appliesTo: ["**/*.{ts,tsx}"], reader: "lib/app-shell-owner-source.ts" },
|
|
21
|
+
// the header or block a page owner imports is followed into the workspace packages by their manifests and entries
|
|
22
|
+
{ rule: "route-page-is-one-page", kind: "content", relativeTo: "side", globs: ["packages/*/package.json", "packages/*/src/**/*.{ts,tsx}"], appliesTo: ["**/*.{ts,tsx}"], reader: "lib/app-shell-owner-source.ts" },
|
|
24
23
|
// a page owner is judged by the route files of its app that mount it and the layouts above them
|
|
25
24
|
{ rule: "page-tabs-in-header", kind: "content", relativeTo: "side", globs: ["**/src/app/**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts}"], appliesTo: ["**/src/features/pages/**/*.{ts,tsx}"], reader: "lib/page-frame.ts" },
|
|
26
25
|
{ rule: "page-tabs-in-header", kind: "exists", relativeTo: "side", globs: ["**/src/app", "**/src/app/**"], appliesTo: ["**/src/features/pages/**/*.{ts,tsx}"], reader: "lib/page-frame.ts" },
|
package/dist/lib/why.js
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
export const why = {
|
|
2
|
-
"app-shell-frame": {
|
|
3
|
-
code: "FE_APP_SHELL_FRAME",
|
|
4
|
-
en: "The app frame must use Grammar WorkspaceShell with its fixed viewport.",
|
|
5
|
-
fix: "Compose WorkspaceShell viewport=\"fixed\" and supply its header, navigation and primary slots.",
|
|
6
|
-
},
|
|
7
|
-
"chip-label-starts-uppercase": {
|
|
8
|
-
code: "FE_CHIP_LABEL_CASE",
|
|
9
|
-
en: "A StatusDot or Badge label in `<file>` starts with a lowercase letter.",
|
|
10
|
-
fix: "Start the label with an uppercase letter (`Running`, not `running`); the rule fixes a literal label in place.",
|
|
11
|
-
},
|
|
12
2
|
"tabs-switch-zone": {
|
|
13
3
|
code: "FE_TABS_SWITCH_ZONE",
|
|
14
4
|
en: "A pill (`Tabs appearance=\"primary\"`) is written in JSX in `<file>`, outside the `action` of a `Section` and not the value of a row `control`.",
|
|
@@ -29,11 +19,6 @@ export const why = {
|
|
|
29
19
|
en: "A `DescriptionList` or `DisclosureList` in `<file>` stands with no `Section` or `SurfaceCard` around it.",
|
|
30
20
|
fix: "Key-value and disclosure rows stand flat in a `Section` (`<Section title ...><DescriptionList isDivided items={...} /></Section>`) or, as the facts of ONE object, in the body of that object's `SurfaceCard`; a plain list of rows is `Section kind=\"list\"`, flat.",
|
|
31
21
|
},
|
|
32
|
-
"surface-card-list": {
|
|
33
|
-
code: "FE_SURFACE_CARD_LIST",
|
|
34
|
-
en: "A `SurfaceCard kind=\"list\"` in `<file>`: the list card was removed in the Grammar family 0.43.0, a list is never a card.",
|
|
35
|
-
fix: "Write the list as `<Section kind=\"list\" title items empty />` with `ListRow` rows: flat rows on the surface, divided by hairlines, aligned with the title. `label` becomes `title`, `labelEnd` becomes `action`, a filter or search goes in the list's `filter`, and `layout=\"keyValue\" | \"suggestions\"` stays on the Section.",
|
|
36
|
-
},
|
|
37
22
|
"no-card-lead-description": {
|
|
38
23
|
code: "FE_NO_CARD_LEAD_DESCRIPTION",
|
|
39
24
|
en: "A muted `Text` in `<file>` stands directly above a `SurfaceCard` as its description.",
|
|
@@ -49,11 +34,6 @@ export const why = {
|
|
|
49
34
|
en: "The `Section` head `action` in `<file>` holds a Button that is not a neutral small text Button, or more than one command.",
|
|
50
35
|
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: a `Link variant=\"head\"` (the label then an arrow that slides on hover), an info `IconButton`, or a text `Button intent=\"neutral\" size=\"sm\"` (no icon, never the commit).",
|
|
51
36
|
},
|
|
52
|
-
"tab-count-chip": {
|
|
53
|
-
code: "FE_TAB_COUNT_CHIP",
|
|
54
|
-
en: "A tab label in `<file>` carries its count as text (\"label \u00b7 N\").",
|
|
55
|
-
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.",
|
|
56
|
-
},
|
|
57
37
|
"card-one-content": {
|
|
58
38
|
code: "FE_CARD_ONE_CONTENT",
|
|
59
39
|
en: "A `SurfaceCard` in `<file>` holds more than one content (a list, facts, a table, a graph, a form).",
|
|
@@ -99,11 +79,6 @@ export const why = {
|
|
|
99
79
|
en: "A Grammar layout element in `<file>` (Stack, Cluster, PaneSection, Section, Grid, Form, Fieldset) stands directly inside another whose gap role is not wider: the child's gap is not at least one step closer than its container's.",
|
|
100
80
|
fix: "Step the child down one role (region -> section -> row -> inline -> identity), or step the parent up. Section is always row and Grid and Form fix their own role: do not nest them where the parent is as close. A field stack of controls inside a Form or Fieldset is exempt.",
|
|
101
81
|
},
|
|
102
|
-
"generated-art-in-mascot-or-media-frame": {
|
|
103
|
-
code: "FE_GENERATED_ART_OUTSIDE_FRAME",
|
|
104
|
-
en: "Generated art (a `.webp` or `.png` under `/images/`) in `<file>` is drawn outside Grammar's `Mascot` and `MediaFrame`, so it takes whatever box the page gives it.",
|
|
105
|
-
fix: "Render a character with `<Mascot src size assetSlot />` (sm, md, lg or hero), or frame a scene or illustration in `<MediaFrame assetSlot>`.",
|
|
106
|
-
},
|
|
107
82
|
"mascot-asset-slot-required": {
|
|
108
83
|
code: "FE_MASCOT_ASSET_SLOT_MISSING",
|
|
109
84
|
en: "A `Mascot` in `<file>` names no `assetSlot`, so nothing ties the art it draws to the asset workflow's request.",
|
|
@@ -114,21 +89,11 @@ export const why = {
|
|
|
114
89
|
en: "A raw `<img>`, `<video>` or `<picture>` in `<file>`: it reserves no ratio, loads at once and carries none of the Grammar's alt, rendition, caption, track or stream contract.",
|
|
115
90
|
fix: "Use `Image` (a picture with content: `alt` is required, `ratio`, `renditions` and `sizes`, `caption`, `zoom`), `Illustration` (decorative art: `compact` for art direction) or `Video` (`sources` of MP4, WebM, HLS or DASH, `poster`, `tracks`); a `staticsKey` names an asset of the app's statics.",
|
|
116
91
|
},
|
|
117
|
-
"navbar-cluster": {
|
|
118
|
-
code: "FE_NAVBAR_CLUSTER",
|
|
119
|
-
en: "Navbar action component kinds or order differ from the app-shell canon.",
|
|
120
|
-
fix: "Compose Language IconButton, theme Switch, notification IconButton and account AvatarButton in that order.",
|
|
121
|
-
},
|
|
122
92
|
"navbar-control-size": {
|
|
123
93
|
code: "FE_NAVBAR_CONTROL_SIZE",
|
|
124
94
|
en: "A navbar control does not use Grammar's shared control height.",
|
|
125
95
|
fix: "Give every visible bar control the shared height: Button and IconButton at md (the default), Switch kind=\"toggle\" (never compact), the other controls size=\"control\".",
|
|
126
96
|
},
|
|
127
|
-
"no-navbar-create": {
|
|
128
|
-
code: "FE_NAVBAR_CREATE",
|
|
129
|
-
en: "A create action is composed into the global navbar.",
|
|
130
|
-
fix: "Move the create action to the page that owns it.",
|
|
131
|
-
},
|
|
132
97
|
"no-raw-structural-element": {
|
|
133
98
|
code: "FE_NATIVE_FORM_CONTROL",
|
|
134
99
|
en: "Raw `<tag>` in `<file>`. Page structure and text are composed from grammar components, not hand-written HTML.",
|
|
@@ -204,11 +169,6 @@ export const why = {
|
|
|
204
169
|
en: "A `SurfaceCard` in `<file>` stands inside another SurfaceCard: a card never stands inside a card (a Pane surface, Dialog, Drawer or Popover hosts cards, bordered, since 0.37.5).",
|
|
205
170
|
fix: "Give the content to the outer card's own body; a list, a table or figures inside it stand flat in a `Section` (`Section kind=\"list\"`, `Section kind=\"figures\"`).",
|
|
206
171
|
},
|
|
207
|
-
"no-shell-bottom-tabs": {
|
|
208
|
-
code: "FE_APP_SHELL_BOTTOM_TABS",
|
|
209
|
-
en: "A hand-made bottom tab bar, or a BottomNav outside WorkspaceShell compactNavigation, replaces the required mobile sidebar drawer.",
|
|
210
|
-
fix: "Use WorkspaceShell navigationDrawer and Sidebar presentation=\"drawer\", or the Grammar BottomNav as the compactNavigation of the WorkspaceShell.",
|
|
211
|
-
},
|
|
212
172
|
"surface-in-surface": {
|
|
213
173
|
code: "FE_SURFACE_IN_SURFACE",
|
|
214
174
|
en: "A hand-made row list (a Stack, ul, ol or div whose rows are divided by `Divider`) in `<file>` stands inside a SurfaceCard, Drawer, Dialog, PaneSection or main-rail rail.",
|
|
@@ -219,31 +179,16 @@ export const why = {
|
|
|
219
179
|
en: "A `SurfaceCard` in `<file>` holds only a collection, a form or a placeholder (a `DataTable`, a `Section`, a `DescriptionList`, a `DisclosureList`, a `Form` or a lone field, an `EmptyNotice`, `Markdown`, a chart): a card is one object.",
|
|
220
180
|
fix: "Drop the card and stand the content flat: a table is `<Section title ...><DataTable .../></Section>`, a list `Section kind=\"list\"`, facts `<Section title ...><DescriptionList isDivided items={...} /></Section>`, disclosures `<Section title ...><DisclosureList .../></Section>`, a form or field `<Section title ...><Form .../></Section>`, an empty state an `EmptyNotice` on its own, markdown or a chart a `Section`. A card keeps an object's name and facts beside a control; a sign-in form with no page around it keeps `measure=\"formCompact\"`.",
|
|
221
181
|
},
|
|
222
|
-
"data-table-surface": {
|
|
223
|
-
code: "FE_DATA_TABLE_SURFACE",
|
|
224
|
-
en: "A `DataTable` in `<file>` carries a `surface` prop: it was removed in the Grammar family 0.45.0, a table has one flat look.",
|
|
225
|
-
fix: "Delete the `surface` attribute (the rule fixes it in place) and put the table under its `Section`: `<Section title ...><DataTable .../></Section>`.",
|
|
226
|
-
},
|
|
227
182
|
"surface-card-kind": {
|
|
228
183
|
code: "FE_SURFACE_CARD_KIND",
|
|
229
184
|
en: "A `body` SurfaceCard in `<file>` holds a hand-built list, a Divider, or a SectionHeader or Heading as a second title.",
|
|
230
185
|
fix: "Rows are a `Section kind=\"list\"` (never a card), key figures `Section kind=\"figures\"`, a band of commands at the card's foot is `actions`, a filter or search row the `filter` of a `Section`; the card's title is its `label`, a second subject its own `Section`.",
|
|
231
186
|
},
|
|
232
|
-
"status-text-uses-soft-foreground": {
|
|
233
|
-
code: "FE_STYLE_TOKEN_ONLY",
|
|
234
|
-
en: "`<file>` colours status content against the status pair rule (`<what>`): content on a `bg-<tone>-soft` tint paints with the solid tone (e.g. `bg-success-soft text-success`), or a mark with no tint behind it paints with the soft foreground (e.g. `text-success-soft-foreground` alone).",
|
|
235
|
-
fix: "Content on a background of the tone takes the pair: `bg-<tone>-soft` with `text-<tone>-soft-foreground`. A mark that stands alone, with no background of the tone, takes the tone itself: `text-<tone>`. A solid fill takes `bg-<tone>` with `text-<tone>-foreground`.",
|
|
236
|
-
},
|
|
237
187
|
"button-arrow": {
|
|
238
188
|
code: "FE_BUTTON_ARROW",
|
|
239
189
|
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`.",
|
|
240
190
|
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.",
|
|
241
191
|
},
|
|
242
|
-
"button-icon-primary-only": {
|
|
243
|
-
code: "FE_BUTTON_ICON_PRIMARY_ONLY",
|
|
244
|
-
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.",
|
|
245
|
-
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`.",
|
|
246
|
-
},
|
|
247
192
|
"layout-two-axis": {
|
|
248
193
|
code: "FE_LAYOUT_TWO_AXIS",
|
|
249
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.",
|
|
@@ -254,6 +199,11 @@ export const why = {
|
|
|
254
199
|
en: "An element in `<file>` makes its own scroll area with an `overflow-auto`, `overflow-y-auto` or `overflow-scroll` class.",
|
|
255
200
|
fix: "Grammar 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.",
|
|
256
201
|
},
|
|
202
|
+
"no-raw-type-size": {
|
|
203
|
+
code: "FE_RAW_TYPE_SIZE",
|
|
204
|
+
en: "`<file>` sets a type size of its own: a Tailwind text-size utility (`text-sm`, `text-[13px]`), a `fontSize` or a CSS `font-size`.",
|
|
205
|
+
fix: "Type is a Grammar role (owner 2026-11-21): use `<Text role=\"label.item\">` or the class of the role, `starci-type-<role>` with dots as dashes (`starci-type-label-item`). The roles: figure, title.page, title.section, label.item, body, label.field, label.group, caption, badge, code.",
|
|
206
|
+
},
|
|
257
207
|
"table-cell-type": {
|
|
258
208
|
code: "FE_TABLE_CELL_TYPE",
|
|
259
209
|
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.",
|
|
@@ -269,14 +219,4 @@ export const why = {
|
|
|
269
219
|
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).",
|
|
270
220
|
fix: "The row is the one pressable: write the title as plain text (`<Text isStrong>`) and keep the destination on the row.",
|
|
271
221
|
},
|
|
272
|
-
"message-surfaces": {
|
|
273
|
-
code: "FE_MESSAGE_SURFACES",
|
|
274
|
-
en: "`<file>` restyles a chat face: a class or style on MessageBubble or MessageCard, a class string reaching into a Grammar message part, a chat thread asked for the surface tone, or a chat frame (`Pane content=\"chat\"`, a Pane holding a log thread) given `surface`.",
|
|
275
|
-
fix: "Remove the override: the chat frame (head, thread, composer) is `--background` (`Pane content=\"chat\"`, no `surface`, DNA-COMMON-CHAT-FRAME), others' messages outlined (the 1px `--border` edge, no fill), your own `--accent` (DNA-COMMON-CHAT-SURFACES); a message card's replies are `Section kind=\"list\" layout=\"suggestions\"`.",
|
|
276
|
-
},
|
|
277
|
-
"suggestion-buttons": {
|
|
278
|
-
code: "FE_SUGGESTION_BUTTONS",
|
|
279
|
-
en: "A Link row, a ChoiceChips, a ChoiceButtons or a Chip in `<file>` runs an action or sends its own label as a suggestion.",
|
|
280
|
-
fix: "Suggestions and quick replies are one pattern: a `Cluster gap=\"inline\"` (with `label`) of neutral `Button size=\"sm\"` (a pill).",
|
|
281
|
-
},
|
|
282
222
|
};
|
package/dist/mascot.d.ts
CHANGED
|
@@ -1,25 +1,4 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
|
-
/**
|
|
3
|
-
* The mascot law (HFS R338 `FE_GENERATED_ART_OUTSIDE_FRAME`, R339 `FE_MASCOT_ASSET_SLOT_MISSING`): generated art renders
|
|
4
|
-
* at the Grammar's size scale and stays tied to the asset workflow's request.
|
|
5
|
-
*
|
|
6
|
-
* Generated art is a raster the asset workflow delivers under the public `/images/` tree, as `.webp` or `.png`. Drawn
|
|
7
|
-
* through a bare `Image` or `<img>` it takes whatever box its page gives it, so one mascot comes out at a different size on
|
|
8
|
-
* every screen and nothing ties the bytes to the slot that requested them. Grammar's `Mascot` owns the character scale
|
|
9
|
-
* (sm, md, lg, hero), `Illustration` owns decorative art (a ratio and an art-directed crop) and `MediaFrame` frames a scene; those three are its renderers.
|
|
10
|
-
*
|
|
11
|
-
* WHAT IT READS. A JSX `src` attribute whose value is statically a string (a literal, an expression container holding one,
|
|
12
|
-
* a template literal without expressions, or a `const` of the file initialised with one). A source computed at run time is
|
|
13
|
-
* not judged: the rule never guesses. `assetSlot` is read on every `Mascot` element (`Mascot` or `<ns>.Mascot`); a spread
|
|
14
|
-
* attribute may carry it, so an element with a spread is not judged.
|
|
15
|
-
*
|
|
16
|
-
* WHERE IT APPLIES. Product source (`isProductSource`: the route, feature, component, hook, foundation, module and transport
|
|
17
|
-
* tiers and the workspace packages). A script or a file no slot owns is not judged.
|
|
18
|
-
*/
|
|
19
|
-
/** A generated raster under the public `/images/` tree: `.webp` or `.png`, any case, an optional query or fragment. */
|
|
20
|
-
export declare const GENERATED_ART: RegExp;
|
|
21
|
-
/** Generated art under `/images/` renders only through `Mascot` or inside a `MediaFrame`. */
|
|
22
|
-
export declare const generatedArtInMascotOrMediaFrame: Rule.RuleModule;
|
|
23
2
|
/** Every `Mascot` names the asset slot its art was requested under. */
|
|
24
3
|
export declare const mascotAssetSlotRequired: Rule.RuleModule;
|
|
25
4
|
/** The rules this law contributes to the plugin. */
|
package/dist/mascot.js
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
-
import { defineFamilyRules, defineRule
|
|
2
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
3
|
/**
|
|
4
|
-
* The mascot law (HFS
|
|
5
|
-
* at the Grammar's size scale and stays tied to the asset workflow's request.
|
|
4
|
+
* The mascot law (HFS R339 `FE_MASCOT_ASSET_SLOT_MISSING`): every `Mascot` stays tied to the asset workflow's request.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* every screen and nothing ties the bytes to the slot that requested them. Grammar's `Mascot` owns the character scale
|
|
10
|
-
* (sm, md, lg, hero), `Illustration` owns decorative art (a ratio and an art-directed crop) and `MediaFrame` frames a scene; those three are its renderers.
|
|
11
|
-
*
|
|
12
|
-
* WHAT IT READS. A JSX `src` attribute whose value is statically a string (a literal, an expression container holding one,
|
|
13
|
-
* a template literal without expressions, or a `const` of the file initialised with one). A source computed at run time is
|
|
14
|
-
* not judged: the rule never guesses. `assetSlot` is read on every `Mascot` element (`Mascot` or `<ns>.Mascot`); a spread
|
|
15
|
-
* attribute may carry it, so an element with a spread is not judged.
|
|
6
|
+
* WHAT IT READS. `assetSlot` on every `Mascot` element (`Mascot` or `<ns>.Mascot`); a spread attribute may carry it, so an
|
|
7
|
+
* element with a spread is not judged.
|
|
16
8
|
*
|
|
17
9
|
* WHERE IT APPLIES. Product source (`isProductSource`: the route, feature, component, hook, foundation, module and transport
|
|
18
10
|
* tiers and the workspace packages). A script or a file no slot owns is not judged.
|
|
19
11
|
*/
|
|
20
|
-
/** A generated raster under the public `/images/` tree: `.webp` or `.png`, any case, an optional query or fragment. */
|
|
21
|
-
export const GENERATED_ART = /^\/images\/.+\.(?:webp|png)(?:[?#].*)?$/i;
|
|
22
12
|
/** The components that render generated art: the element itself, or an ancestor that frames it. */
|
|
23
13
|
const RENDERER = "Mascot";
|
|
24
|
-
const ART_RENDERERS = new Set([RENDERER, "Illustration"]);
|
|
25
|
-
const FRAME = "MediaFrame";
|
|
26
14
|
/** The element name of a JSX name: `Mascot`, or `G.Mascot` as `Mascot`. */
|
|
27
15
|
const nameOf = (name) => {
|
|
28
16
|
if (name.type === "JSXIdentifier")
|
|
@@ -59,57 +47,6 @@ const staticString = (expression, scopeOf) => {
|
|
|
59
47
|
}
|
|
60
48
|
return null;
|
|
61
49
|
};
|
|
62
|
-
/** The string a JSX attribute value statically is, or null. */
|
|
63
|
-
const attributeString = (value, scopeOf) => {
|
|
64
|
-
if (value === null)
|
|
65
|
-
return null;
|
|
66
|
-
if (value.type === "Literal")
|
|
67
|
-
return typeof value.value === "string" ? value.value : null;
|
|
68
|
-
if (value.type === "JSXExpressionContainer" && value.expression.type !== "JSXEmptyExpression")
|
|
69
|
-
return staticString(value.expression, scopeOf);
|
|
70
|
-
return null;
|
|
71
|
-
};
|
|
72
|
-
/** True when a `MediaFrame` element encloses the node. */
|
|
73
|
-
const insideFrame = (node) => {
|
|
74
|
-
// The Program's parent is null at run time though the tree's types say a node always has one.
|
|
75
|
-
for (let current = node.parent; current !== undefined && current !== null; current = current.parent) {
|
|
76
|
-
if (current.type === "JSXElement" && nameOf(current.openingElement.name) === FRAME)
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
};
|
|
81
|
-
/** Generated art under `/images/` renders only through `Mascot` or inside a `MediaFrame`. */
|
|
82
|
-
export const generatedArtInMascotOrMediaFrame = exemptFreestyle(defineRule({
|
|
83
|
-
meta: {
|
|
84
|
-
type: "problem",
|
|
85
|
-
docs: { description: "R338: generated art (a .webp or .png under /images/) renders only through Grammar's Mascot or inside a MediaFrame." },
|
|
86
|
-
schema: [],
|
|
87
|
-
messages: {
|
|
88
|
-
outside: "`{{src}}` is generated art drawn by `<{{element}}>`, outside Grammar's `Mascot`, `Illustration` and `MediaFrame`: it takes whatever box this page gives it, so the same art comes out at a different size on every screen. Render a character with `<Mascot src size assetSlot />` (sm, md, lg or hero), decorative art with `<Illustration src ratio />`, or frame a scene in `<MediaFrame assetSlot>`.",
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
create(context) {
|
|
92
|
-
if (!isProductSource(context))
|
|
93
|
-
return {};
|
|
94
|
-
const scopeOf = (node) => context.sourceCode.getScope(node);
|
|
95
|
-
return {
|
|
96
|
-
JSXAttribute(attribute) {
|
|
97
|
-
if (attribute.name.type !== "JSXIdentifier" || attribute.name.name !== "src")
|
|
98
|
-
return;
|
|
99
|
-
const src = attributeString(attribute.value, scopeOf);
|
|
100
|
-
if (src === null || !GENERATED_ART.test(src))
|
|
101
|
-
return;
|
|
102
|
-
const opening = attribute.parent;
|
|
103
|
-
if (opening.type !== "JSXOpeningElement")
|
|
104
|
-
return;
|
|
105
|
-
const element = nameOf(opening.name);
|
|
106
|
-
if ((element !== null && ART_RENDERERS.has(element)) || insideFrame(opening))
|
|
107
|
-
return;
|
|
108
|
-
context.report({ node: attribute, messageId: "outside", data: { src, element: element ?? "element" } });
|
|
109
|
-
},
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
}));
|
|
113
50
|
/** True when an attribute names nothing: no value, an empty string, or `undefined`. */
|
|
114
51
|
const namesNothing = (attribute) => {
|
|
115
52
|
const value = attribute.value;
|
|
@@ -158,10 +95,8 @@ export const mascotAssetSlotRequired = defineRule({
|
|
|
158
95
|
});
|
|
159
96
|
/** The rules this law contributes to the plugin. */
|
|
160
97
|
export const rules = {
|
|
161
|
-
"generated-art-in-mascot-or-media-frame": generatedArtInMascotOrMediaFrame,
|
|
162
98
|
"mascot-asset-slot-required": mascotAssetSlotRequired,
|
|
163
99
|
};
|
|
164
|
-
defineFamilyRules({ "generated-art-in-mascot-or-media-frame": generatedArtInMascotOrMediaFrame }, "knowledge/hfs/rules.yaml#R338");
|
|
165
100
|
defineFamilyRules({ "mascot-asset-slot-required": mascotAssetSlotRequired }, "knowledge/hfs/rules.yaml#R339");
|
|
166
101
|
/** Every rule of this law is an error. */
|
|
167
102
|
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* THE TYPE ROLES (owner, 2026-11-21, TYPE-ROLES). Type in an app is a role the Grammar draws: `<Text role="label.item">`, or the
|
|
4
|
+
* public class of the role (`starci-type-label-item`) on an element of the app's own. A raw size is a second type scale.
|
|
5
|
+
*
|
|
6
|
+
* WHAT IT READS, in product source (Grammar's own sources are not product source):
|
|
7
|
+
* - a class string (`className`, a class constant, a `classes` array) that holds a Tailwind text-size utility: `text-xs`, `text-sm`,
|
|
8
|
+
* `text-base`, `text-lg`, `text-xl`, `text-2xl` and larger, an arbitrary length (`text-[13px]`, `text-[0.8rem]`), with any variant
|
|
9
|
+
* prefix or line-height suffix (`md:text-sm/6`);
|
|
10
|
+
* - a `fontSize` key of an object (a JSX `style`, a style constant, a chart option) and a `fontSize` JSX attribute (SVG text);
|
|
11
|
+
* - a CSS `font-size` declaration written in a string or template literal (CSS-in-JS).
|
|
12
|
+
*
|
|
13
|
+
* WHAT IT LEAVES ALONE. A colour utility (`text-muted`, `text-[var(--accent)]`), the role classes, the theme layer of the app
|
|
14
|
+
* (`modules/brand/`, where the tokens live), Freestyle regions, Fragment regions and non-product source.
|
|
15
|
+
*
|
|
16
|
+
* It is a counting rule (`COUNTING` in index.ts): reported and counted at warn until both apps have migrated, then blocking.
|
|
17
|
+
* The CSS half is the stylesheet canon: `starci/token-only` refuses a `font-size` that is not a token in an app stylesheet, and
|
|
18
|
+
* `starci/no-grammar-private-token` the Grammar's private type tokens.
|
|
19
|
+
*/
|
|
20
|
+
/** A Tailwind text-size utility: the named steps and an arbitrary length, any variant prefix, an optional `/leading` suffix. */
|
|
21
|
+
export declare const TEXT_SIZE_UTILITY: RegExp;
|
|
22
|
+
/** No raw type size in app source: a text role (`<Text role>` or `starci-type-<role>`) carries every size. */
|
|
23
|
+
export declare const noRawTypeSize: Rule.RuleModule;
|
|
24
|
+
/** The rules this law contributes to the plugin. */
|
|
25
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
26
|
+
/** The rule runs in the counting cohort (index.ts `COUNTING`): a warning until both apps migrate. */
|
|
27
|
+
export declare const recommended: Record<string, "warn">;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { classTextVisitors } from "@starci/eslint-canon-fe/lib/class-text.mjs";
|
|
2
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
3
|
+
import { defineFamilyRules, defineRule, exemptFreestyle } from "./lib/rule-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* THE TYPE ROLES (owner, 2026-11-21, TYPE-ROLES). Type in an app is a role the Grammar draws: `<Text role="label.item">`, or the
|
|
6
|
+
* public class of the role (`starci-type-label-item`) on an element of the app's own. A raw size is a second type scale.
|
|
7
|
+
*
|
|
8
|
+
* WHAT IT READS, in product source (Grammar's own sources are not product source):
|
|
9
|
+
* - a class string (`className`, a class constant, a `classes` array) that holds a Tailwind text-size utility: `text-xs`, `text-sm`,
|
|
10
|
+
* `text-base`, `text-lg`, `text-xl`, `text-2xl` and larger, an arbitrary length (`text-[13px]`, `text-[0.8rem]`), with any variant
|
|
11
|
+
* prefix or line-height suffix (`md:text-sm/6`);
|
|
12
|
+
* - a `fontSize` key of an object (a JSX `style`, a style constant, a chart option) and a `fontSize` JSX attribute (SVG text);
|
|
13
|
+
* - a CSS `font-size` declaration written in a string or template literal (CSS-in-JS).
|
|
14
|
+
*
|
|
15
|
+
* WHAT IT LEAVES ALONE. A colour utility (`text-muted`, `text-[var(--accent)]`), the role classes, the theme layer of the app
|
|
16
|
+
* (`modules/brand/`, where the tokens live), Freestyle regions, Fragment regions and non-product source.
|
|
17
|
+
*
|
|
18
|
+
* It is a counting rule (`COUNTING` in index.ts): reported and counted at warn until both apps have migrated, then blocking.
|
|
19
|
+
* The CSS half is the stylesheet canon: `starci/token-only` refuses a `font-size` that is not a token in an app stylesheet, and
|
|
20
|
+
* `starci/no-grammar-private-token` the Grammar's private type tokens.
|
|
21
|
+
*/
|
|
22
|
+
/** A Tailwind text-size utility: the named steps and an arbitrary length, any variant prefix, an optional `/leading` suffix. */
|
|
23
|
+
export const TEXT_SIZE_UTILITY = /(?<![\w-])(?:[\w[\]&>*:.-]+:)?!?text-(?:xs|sm|base|lg|[2-9]?xl|\[\d*\.?\d+(?:px|rem|em|pt|%|vw|vh)\])(?:\/[\w.[\]-]+)?!?(?![\w-])/;
|
|
24
|
+
/** A CSS `font-size` declaration inside a string. */
|
|
25
|
+
const CSS_FONT_SIZE = /(?:^|[\s;{])font-size\s*:/;
|
|
26
|
+
/** The theme layer of an app: its tokens, never judged here. */
|
|
27
|
+
const TOKEN_FILE = /(?:^|\/)modules\/brand\//;
|
|
28
|
+
const ROLES = "figure, title.page, title.section, label.item, body, label.field, label.group, caption, badge, code";
|
|
29
|
+
const isTokenFile = (context) => TOKEN_FILE.test(context.filename.replaceAll("\\", "/"));
|
|
30
|
+
const keyName = (node) => {
|
|
31
|
+
if (node.computed)
|
|
32
|
+
return null;
|
|
33
|
+
if (node.key.type === "Identifier")
|
|
34
|
+
return node.key.name;
|
|
35
|
+
return node.key.type === "Literal" && typeof node.key.value === "string" ? node.key.value : null;
|
|
36
|
+
};
|
|
37
|
+
/** No raw type size in app source: a text role (`<Text role>` or `starci-type-<role>`) carries every size. */
|
|
38
|
+
export const noRawTypeSize = exemptFreestyle(defineRule({
|
|
39
|
+
meta: {
|
|
40
|
+
type: "suggestion",
|
|
41
|
+
docs: { description: "TYPE-ROLES: type is a Grammar role (`<Text role>`, `starci-type-<role>`); no text-size utility, fontSize or font-size in app source." },
|
|
42
|
+
schema: [],
|
|
43
|
+
messages: {
|
|
44
|
+
utility: "`{{token}}` sets a type size the Grammar owns. Use the role: `<Text role=\"…\">` or the class `starci-type-<role>` (dots as dashes, e.g. `starci-type-label-item`). Roles: " + ROLES + ".",
|
|
45
|
+
fontSize: "`fontSize` sets a type size the Grammar owns. Use `<Text role=\"…\">` or the class `starci-type-<role>`. Roles: " + ROLES + ".",
|
|
46
|
+
css: "A `font-size` declaration sets a type size the Grammar owns. Use the class `starci-type-<role>` on the element. Roles: " + ROLES + ".",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
create(context) {
|
|
50
|
+
if (!isProductSource(context) || isTokenFile(context))
|
|
51
|
+
return {};
|
|
52
|
+
const reported = new Set();
|
|
53
|
+
const report = (node, messageId, token) => {
|
|
54
|
+
if (reported.has(node))
|
|
55
|
+
return;
|
|
56
|
+
reported.add(node);
|
|
57
|
+
context.report({ node: node, messageId, data: token === undefined ? {} : { token } });
|
|
58
|
+
};
|
|
59
|
+
const classes = classTextVisitors(context, (node, text) => {
|
|
60
|
+
if (!text)
|
|
61
|
+
return;
|
|
62
|
+
const found = TEXT_SIZE_UTILITY.exec(text);
|
|
63
|
+
if (found !== null)
|
|
64
|
+
report(node, "utility", found[0]);
|
|
65
|
+
});
|
|
66
|
+
const strings = (node, text) => {
|
|
67
|
+
if (CSS_FONT_SIZE.test(text))
|
|
68
|
+
report(node, "css");
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
...classes,
|
|
72
|
+
Property(node) {
|
|
73
|
+
classes.Property?.(node);
|
|
74
|
+
const name = keyName(node);
|
|
75
|
+
if (name === "fontSize" || name === "font-size")
|
|
76
|
+
report(node, "fontSize");
|
|
77
|
+
},
|
|
78
|
+
JSXAttribute(node) {
|
|
79
|
+
classes.JSXAttribute?.(node);
|
|
80
|
+
if (node.name.type !== "JSXIdentifier")
|
|
81
|
+
return;
|
|
82
|
+
if (node.name.name === "fontSize")
|
|
83
|
+
report(node, "fontSize");
|
|
84
|
+
// A class expression the static reader cannot follow (`cn("flex", big && "text-sm")`) is read as its source text.
|
|
85
|
+
if ((node.name.name === "className" || node.name.name === "class") && node.value !== null) {
|
|
86
|
+
const found = TEXT_SIZE_UTILITY.exec(context.sourceCode.getText(node.value));
|
|
87
|
+
if (found !== null)
|
|
88
|
+
report(node, "utility", found[0]);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
Literal(node) {
|
|
92
|
+
if (typeof node.value === "string")
|
|
93
|
+
strings(node, node.value);
|
|
94
|
+
},
|
|
95
|
+
TemplateElement(node) {
|
|
96
|
+
strings(node, node.value.cooked ?? node.value.raw);
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
}));
|
|
101
|
+
/** The rules this law contributes to the plugin. */
|
|
102
|
+
export const rules = {
|
|
103
|
+
"no-raw-type-size": noRawTypeSize,
|
|
104
|
+
};
|
|
105
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#TYPE-ROLES");
|
|
106
|
+
/** The rule runs in the counting cohort (index.ts `COUNTING`): a warning until both apps migrate. */
|
|
107
|
+
export const recommended = { "starci-grammar/no-raw-type-size": "warn" };
|
package/dist/same-line-size.js
CHANGED
|
@@ -12,9 +12,18 @@ import { attributeOf, elementOf, grammarBindings, literalAttribute } from "./lib
|
|
|
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
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
|
+
/** The size step of each type role (0.54.0), in the names of the `size` steps where one is the same size. */
|
|
16
|
+
const ROLE_STEP = {
|
|
17
|
+
figure: "figure", "title.page": "title.page", "title.section": "title.section", "label.item": "md", body: "md",
|
|
18
|
+
"label.field": "label.field", "label.group": "xs", caption: "xs", badge: "xs", code: "xs",
|
|
19
|
+
};
|
|
15
20
|
const sizeOf = (opening) => {
|
|
16
21
|
if (opening.attributes.some((entry) => entry.type === "JSXSpreadAttribute"))
|
|
17
22
|
return null;
|
|
23
|
+
if (attributeOf(opening, "role") !== null) {
|
|
24
|
+
const role = literalAttribute(opening, "role");
|
|
25
|
+
return role === null ? null : ROLE_STEP[role] ?? null;
|
|
26
|
+
}
|
|
18
27
|
if (attributeOf(opening, "size") === null)
|
|
19
28
|
return "md";
|
|
20
29
|
const size = literalAttribute(opening, "size");
|
package/dist/table-cell-type.js
CHANGED
|
@@ -16,6 +16,8 @@ import { attributeOf, descendants, elementOf, grammarBindings, isListRow, keyNam
|
|
|
16
16
|
*/
|
|
17
17
|
/** The Text sizes a cell or row takes: 14 (md, sm) and 12 (xs). */
|
|
18
18
|
const CELL_SIZES = new Set(["xs", "sm", "md"]);
|
|
19
|
+
/** The type roles above the row sizes (0.54.0): a figure or a title in a cell or a row is a heading drawn in a list. */
|
|
20
|
+
const HEADING_ROLES = new Set(["figure", "title.page", "title.section"]);
|
|
19
21
|
const HEADING_TAGS = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
20
22
|
const isFunction = (node) => node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration";
|
|
21
23
|
export const tableCellType = defineRule({
|
|
@@ -43,6 +45,8 @@ export const tableCellType = defineRule({
|
|
|
43
45
|
const size = grammar === "Text" ? literalAttribute(node.openingElement, "size") : null;
|
|
44
46
|
if (size !== null && !CELL_SIZES.has(size))
|
|
45
47
|
what = `\`Text size="${size}"\``;
|
|
48
|
+
else if (grammar === "Text" && HEADING_ROLES.has(literalAttribute(node.openingElement, "role") ?? ""))
|
|
49
|
+
what = `\`Text role="${literalAttribute(node.openingElement, "role") ?? ""}"\``;
|
|
46
50
|
else if (grammar === "Heading" || grammar === "Label")
|
|
47
51
|
what = `\`${grammar}\``;
|
|
48
52
|
else if (tag !== null && HEADING_TAGS.has(tag))
|
package/docs/app-shell.md
CHANGED
|
@@ -2,25 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Owner: contexts/ui/composition.md
|
|
4
4
|
|
|
5
|
-
The application composes `WorkspaceShell viewport="fixed"`. The `app-shell-frame` rule identifies
|
|
6
|
-
workspace chrome from a fixed shell, sidebar/navigation slot, workspace identity, HFS layout owner,
|
|
7
|
-
or a shell owner combining a bar and sidebar. It rejects hand-written app-frame landmarks and
|
|
8
|
-
workspace shells without the fixed viewport. Generic flow-based site chrome stays in its own scope.
|
|
9
|
-
`no-shell-bottom-tabs` rejects bottom navigation components and the shell's `compactNavigation` slot.
|
|
10
|
-
|
|
11
|
-
The `navbar-cluster` rule reads the visible `TopBar` actions in source order:
|
|
12
|
-
tertiary Language `IconButton` triggering `DropdownMenu`, theme `Switch`, notification `IconButton`
|
|
13
|
-
triggering `Popover`, account `AvatarButton` triggering `DropdownMenu`. It follows
|
|
14
|
-
local JSX constants and components, constant object members, imported Grammar aliases, and namespace imports. Translated
|
|
15
|
-
labels may be dynamic; icon sources identify language and notifications. Menu contents and popover
|
|
16
|
-
content belong to their overlays and are outside the bar's control sequence. Conditional render
|
|
17
|
-
branches are checked separately. Grammar `TopBar` compositions are app
|
|
18
|
-
bars by default. A proven `WorkspaceShell viewport="flow"` with no workspace/sidebar evidence owns
|
|
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` in every alternative.
|
|
21
|
-
Workspace exports resolve back to source. Raw or unknown imported headers are red; the actual
|
|
22
|
-
bar's own actions are checked where composed. Each lint source snapshot has fresh dependency proofs.
|
|
23
|
-
|
|
24
5
|
`navbar-control-size` requires the shared 40px height of each bar control through its published API: `Button` and
|
|
25
6
|
`IconButton` at `md` (their default), `Switch` as `kind="toggle"` (a stated `kind` wins and the Grammar ignores `size` beside it;
|
|
26
7
|
with no `kind`, the toggle unless `size` says `md` or `lg`), every other control at `size="control"`. A `Switch kind="compact"`
|
|
@@ -28,28 +9,11 @@ with no `kind`, the toggle unless `size` says `md` or `lg`), every other control
|
|
|
28
9
|
cannot prove a size; put the explicit size after a spread. A left `Drawer` containing
|
|
29
10
|
`Sidebar presentation="drawer"` also identifies a mobile bar opener when composed in a separate
|
|
30
11
|
client owner. Its trigger is checked; drawer bodies and footers retain their normal field sizes.
|
|
31
|
-
`no-navbar-create` places creation on its
|
|
32
|
-
own page and rejects create controls in the navbar and its attached menus or popovers. Static
|
|
33
|
-
evidence includes literal labels, translated keys with create semantics, and conventional create
|
|
34
|
-
handlers. Runtime-generated labels and arbitrary handler behavior need semantic review; the rule
|
|
35
|
-
does not execute application code.
|
|
36
12
|
|
|
37
13
|
| Rule | Invalid composition | Valid composition |
|
|
38
14
|
| --- | --- | --- |
|
|
39
|
-
| `app-shell-frame` | An app `Shell` returns a hand-written `<header>` and `<nav>`. | `WorkspaceShell viewport="fixed"` owns the app frame. |
|
|
40
|
-
| `no-shell-bottom-tabs` | The shell supplies `compactNavigation={<BottomNav />}`. | The shell supplies `navigationDrawer` with a drawer `Sidebar`. |
|
|
41
15
|
| `navbar-control-size` | A navbar `IconButton` uses `size="sm"`; the theme `Switch` is `kind="compact"`. | The `IconButton` keeps `md`; the theme `Switch` is `kind="toggle"`. |
|
|
42
|
-
| `navbar-cluster` | Account precedes notifications, or a language trigger uses a regular `Button`. | Language menu, theme switch, notification popover, account menu use their stated Grammar trigger kinds in that order. |
|
|
43
|
-
| `no-navbar-create` | A navbar button or attached menu item creates a record. | The page owns its create action. |
|
|
44
|
-
|
|
45
|
-
```tsx
|
|
46
|
-
// Invalid: the navbar action creates a page record and has a different height.
|
|
47
|
-
<TopBar actions={<Button onPress={on.create}>Create</Button>} />
|
|
48
|
-
|
|
49
|
-
// Valid: a page action belongs to page content.
|
|
50
|
-
<SurfaceCard><Button onPress={on.create}>Create</Button></SurfaceCard>
|
|
51
|
-
```
|
|
52
16
|
|
|
53
|
-
|
|
17
|
+
The rule is an error in the gathered FE canon and runs through the ordinary application gate.
|
|
54
18
|
|
|
55
19
|
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/docs/button-arrow.md
CHANGED
|
@@ -4,7 +4,7 @@ Law module: `button-arrow.ts`. Finding code: `FE_BUTTON_ARROW`. Knowledge: `know
|
|
|
4
4
|
|
|
5
5
|
A Button that leads somewhere (a page, a tab, a next step) ends with the Grammar arrow: `endArrow`. It slides toward the reading end on hover and focus and is mirrored in RTL. A primary Button that does something may start with a `startGlyph`. A typed `→` or a passed-in arrow icon does neither, so the law refuses them. Start and end keep their meaning: the start says what the action is, the end says where it goes.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
8
|
|
|
9
9
|
## `starci-grammar/button-arrow`
|
|
10
10
|
|
|
@@ -31,29 +31,4 @@ A `Button` bound to `@starci/grammar` is a finding when:
|
|
|
31
31
|
<Button intent="commit" onPress={send} startGlyph="send">Send</Button>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
## `starci-grammar/button-icon-primary-only`
|
|
35
|
-
|
|
36
|
-
Code `FE_BUTTON_ICON_PRIMARY_ONLY`. Only the primary Button (`intent="commit"`, the CTA) carries a leading icon. A `Button` bound to
|
|
37
|
-
`@starci/grammar` that sets `startGlyph` or `startContent` is a finding unless its `intent` is the literal `"commit"` (message `icon`):
|
|
38
|
-
a neutral, alternative, dismiss or destructive Button, a suggestion pill and a row action are text only. A Button with no `intent`
|
|
39
|
-
(it renders the secondary step) and one whose `intent` is computed cannot be proven primary, so they are findings too. The Button type
|
|
40
|
-
already refuses a start icon on a literal non-primary intent; the rule covers what a type cannot see. `endArrow` is not an icon under
|
|
41
|
-
this rule (any intent may lead), and `IconButton` (icon only, named by its label) is not judged.
|
|
42
|
-
|
|
43
|
-
**Invalid**
|
|
44
|
-
|
|
45
|
-
```tsx
|
|
46
|
-
<Button intent="neutral" startGlyph="plus" onPress={add}>Add</Button>
|
|
47
|
-
<Button startGlyph="plus" onPress={add}>Add</Button>
|
|
48
|
-
<Button intent={intent} startContent={<Icon source={x} />} onPress={add}>Add</Button>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
**Valid**
|
|
52
|
-
|
|
53
|
-
```tsx
|
|
54
|
-
<Button intent="commit" startGlyph="plus" onPress={add}>Add</Button>
|
|
55
|
-
<Button intent="neutral" href="/runs" endArrow>View runs</Button>
|
|
56
|
-
<Button intent="alternative" onPress={edit}>Edit</Button>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
34
|
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/docs/mascot.md
CHANGED
|
@@ -1,43 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# A Mascot names its asset slot
|
|
2
2
|
|
|
3
|
-
Law module: `mascot.ts`. Catalogue:
|
|
3
|
+
Law module: `mascot.ts`. Catalogue: R339 FE_MASCOT_ASSET_SLOT_MISSING.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
the asset-slot props (`assetSlot`, `assetSha256`, `assetPrompt`) that tie the render to the request. Drawn through a bare
|
|
9
|
-
`Image` or `<img>`, the same art takes whatever box each page gives it.
|
|
5
|
+
Grammar's `Mascot` renders a character at one size scale (`sm` 96px, `md` 160px, `lg` 240px square, `hero` filling its host's
|
|
6
|
+
height up to its cap), always contained on a transparent ground. It carries the asset-slot props (`assetSlot`, `assetSha256`,
|
|
7
|
+
`assetPrompt`) that tie the render to the request.
|
|
10
8
|
|
|
11
|
-
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
9
|
+
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline. It applies to
|
|
12
10
|
product source (the route, feature, component, hook, foundation, module and transport tiers and the workspace packages);
|
|
13
11
|
a script or a file no slot owns is not judged.
|
|
14
12
|
|
|
15
|
-
## `starci-grammar/generated-art-in-mascot-or-media-frame`
|
|
16
|
-
|
|
17
|
-
A JSX `src` attribute whose value is statically a path under `/images/` ending in `.webp` or `.png` (any case, an
|
|
18
|
-
optional query or fragment) is a finding unless its element is a `Mascot` (`Mascot` or `<ns>.Mascot`) or a `MediaFrame`
|
|
19
|
-
element encloses it. The value is read from a string literal, an expression container holding one, a template literal
|
|
20
|
-
without expressions, or a `const` of the file initialised with one; a source computed at run time is not judged.
|
|
21
|
-
`.svg`, `.jpg` and paths outside `/images/` are not generated art here.
|
|
22
|
-
|
|
23
|
-
**Invalid** (`src/components/blocks/Onboarding/component.tsx`)
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
<Image src="/images/mascot/welcome.webp" alt="" />
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
**Valid** (`src/components/blocks/Onboarding/component.tsx`)
|
|
30
|
-
|
|
31
|
-
```tsx
|
|
32
|
-
<Mascot src="/images/mascot/welcome.webp" size="lg" assetSlot="onboarding.welcome" />
|
|
33
|
-
|
|
34
|
-
<MediaFrame assetSlot="landing.scene">
|
|
35
|
-
<Image src="/images/scene/landing.webp" alt="" />
|
|
36
|
-
</MediaFrame>
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**Finding code:** `FE_GENERATED_ART_OUTSIDE_FRAME`
|
|
40
|
-
|
|
41
13
|
## `starci-grammar/mascot-asset-slot-required`
|
|
42
14
|
|
|
43
15
|
A `Mascot` element with no `assetSlot`, or with one that names nothing (`""`, `{undefined}`), is a finding, reported on
|