@starci/eslint-grammar-core 0.54.1 → 0.57.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 +20 -0
- package/README.md +1 -1
- package/dist/app-shell.js +5 -4
- package/dist/avatar-row-uses-group.d.ts +7 -0
- package/dist/avatar-row-uses-group.js +98 -0
- package/dist/button-arrow.d.ts +12 -0
- package/dist/button-arrow.js +55 -4
- package/dist/choice-controls.d.ts +1 -1
- package/dist/choice-controls.js +1 -1
- package/dist/icon.js +2 -2
- package/dist/index.js +7 -0
- package/dist/lib/site-scope.d.ts +12 -0
- package/dist/lib/site-scope.js +27 -0
- package/dist/lib/why.js +19 -4
- package/dist/no-raw-spacing-style.d.ts +22 -0
- package/dist/no-raw-spacing-style.js +65 -0
- package/dist/no-raw-type-size.js +1 -1
- package/dist/same-line-size.js +1 -0
- package/dist/section-head-action.d.ts +1 -1
- package/dist/section-head-action.js +10 -9
- package/dist/site-type-role.d.ts +20 -0
- package/dist/site-type-role.js +81 -0
- package/dist/table-cell-type.js +2 -2
- package/docs/avatar-row-uses-group.md +35 -0
- package/docs/button-arrow.md +19 -2
- package/docs/page-header.md +2 -2
- package/docs/section-head-action.md +4 -4
- package/docs/site-type-role.md +34 -0
- package/package.json +4 -4
- package/runtime/knowledge/patterns/fe/ui.yaml +3 -5
- package/runtime/knowledge/ui/composition/app-shell.yaml +2 -2
- package/runtime/knowledge/ui/presentation/grammar-laws.yaml +39 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.57.0 - 2026-11-23
|
|
4
|
+
|
|
5
|
+
- Added (`no-raw-spacing-style`, law SPACING-ROLES, owner 2026-11-23): a gap, padding or margin key in a JSX `style` object in product source is reported; the distance is a Grammar spacing role (a Stack, Cluster or Grid `gap`, the inset of a Grammar box). A counting rule at warn until both apps migrate. The class-string half stays the canon's `starci-fe/no-spacing-utility` (R350).
|
|
6
|
+
- Changed (`no-icon-size-class`, wording only; Grammar 0.57.0's icon table): the message names the roles, `control` 16, `row` 20, `head` 24, `text` 1em.
|
|
7
|
+
|
|
8
|
+
## 0.56.0 - 2026-11-23
|
|
9
|
+
|
|
10
|
+
- Changed (`no-icon-size-class`, wording only; Grammar 0.55.1's icon size table, owner 2026-11-23): the message names the table: 24 for a navigation entry or a heading lead (`heading`, `leading`), 20 beside text and in a chip, badge or field (`chip`), 1em of its text for a caret or an inline status mark (`text`). The rule reads the same calls as before.
|
|
11
|
+
|
|
12
|
+
## 0.55.0 - 2026-11-22
|
|
13
|
+
|
|
14
|
+
- Changed (`navbar-control-size`, with Grammar 0.55.0's two round-mark sizes): an `AvatarButton` with no `size` or `size="md"` (40px) has the bar's control height; its `control` size is deleted.
|
|
15
|
+
- Changed (`no-icon-size-class`, wording only): the message names the two icon sizes, 24px before 14px text (`heading`, `leading`) and 20px in a chip or badge and before 12px text (`chip`).
|
|
16
|
+
- Added: `no-typed-arrow` (`FE_NO_TYPED_ARROW`, BUTTON-ARROW case-3, error). Owner 2026-11-22: "Không dùng ký tự mũi tên gõ tay; hướng đi là icon của Grammar". In product source, an arrow character (U+2190-U+21FF, U+2794-U+27BF, U+27F0-U+27FF, or ASCII `->`) in ANY rendered text is refused: JSX text, a string or template literal child, the branches of a conditional, and a string attribute that is rendered text (`label`, `title`, `aria-label`, ...). i18n JSON is not read (an accepted gap). Enabled at error in the published `recommended` set and `coreGrammarConfig` (owner 2026-11-22: "duyệt hết").
|
|
17
|
+
- Changed: `button-arrow` keeps the Button's own law (a `›` or `»` in its label, an arrow icon as `endContent`, `endArrow` with a start mark); the typed arrow characters moved to `no-typed-arrow`.
|
|
18
|
+
- No rule changed: versioned with @starci/grammar 0.55.0 (the Alert's final soft-pair look).
|
|
19
|
+
- Added: `site-type-role` (SITE-TYPE-ROLES, `FE_SITE_TYPE_ROLE`), at error. Outside the public site it reports `<Text role>` and the class `starci-type-<role>` of the site group (display.hero, display.section, display.figure, lead, title.card). No hfs slot marks the site yet, and the proposed one is `fe.site`. Until it exists, a file is the site when `classify` places it as a `Site…` or `Marketing…` owner of fe.components or fe.feature, a route under `(site)` or `(marketing)`, or a `site…` capability of fe.modules (`src/lib/site-scope.ts`).
|
|
20
|
+
- Changed: `same-line-size` gives each site role its own step, and `table-cell-type` reads a site role in a cell or row as a heading drawn in a list. Versioned with @starci/grammar 0.55.0.
|
|
21
|
+
|
|
3
22
|
## 0.54.1 - 2026-11-21
|
|
4
23
|
|
|
5
24
|
- No rule changed: versioned with @starci/grammar 0.54.1 (the Switch track is its press target).
|
|
@@ -613,6 +632,7 @@
|
|
|
613
632
|
|
|
614
633
|
## Unreleased
|
|
615
634
|
|
|
635
|
+
- Added: `avatar-row-uses-group` (DNA-COMMON-AVATAR-ROW-GROUP, `FE_AVATAR_ROW_USES_GROUP`, error). Owner 2026-11-22: "với providers phải render AvatarGroup với nhiều hơn 5 thì +2 đồ chứ?? .claude sao k ép tụi này render sáng tạo nhỉ". In product source, two or more Grammar `Avatar` siblings, or an `Avatar` returned from a `.map()` callback, with no `AvatarGroup` among its JSX ancestors is an error; the message points to `<AvatarGroup items max>`. A single `Avatar`, an `AvatarButton`, an `Avatar` inside an `AvatarGroup` and Grammar's own `AvatarGroup` (not product source) pass. Versioned with @starci/grammar 0.55.0.
|
|
616
636
|
## 0.21.5 - 2026-11-02
|
|
617
637
|
|
|
618
638
|
- Changed: requires canon FE 9.9.5 and follows the HFS 5.0.1 canon-pin cohort; the Grammar component runtime stays at 0.21.3.
|
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 navbar control height,
|
|
21
21
|
Grammar-owned structural elements, glyphs and icon sizes, destructive menu entries,
|
|
22
|
-
a Button that leads somewhere ending with `endArrow` (no
|
|
22
|
+
a Button that leads somewhere ending with `endArrow` (no icon arrow; `button-arrow`), no typed arrow character in any rendered text (`no-typed-arrow`), report cards in one axis (`layout-two-axis`), no app-made scroll area (`no-raw-scroll`), no raw type size in app source, only the type roles (`no-raw-type-size`, the counting rule: a warning until its `COUNTING` entry is deleted), 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 object 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`), 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`), 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 `action` of a `Section` or the value of a row `control`, 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
|
`card-is-object` (0.45.0, CARD-OBJECT: a card is one object; a card whose only content is a table, a list, facts, disclosures, a form, a field, an empty notice, markdown or a chart is refused, the message names the flat `Section` form; `docs/card-is-object.md`).
|
package/dist/app-shell.js
CHANGED
|
@@ -39,7 +39,7 @@ const everyLiteral = (context, expression, allowed) => everyValue(context, expre
|
|
|
39
39
|
const TOGGLE = new Set(["toggle"]);
|
|
40
40
|
const SWITCH_KINDS = new Set(["toggle", "compact"]);
|
|
41
41
|
/**
|
|
42
|
-
* A bar control's height comes from its published API. Buttons publish the shared 40px height as `md` (their default). A `Switch` publishes it
|
|
42
|
+
* A bar control's height comes from its published API. Buttons and the AvatarButton publish the shared 40px height as `md` (their default). A `Switch` publishes it
|
|
43
43
|
* as `kind="toggle"`: a stated `kind` wins and the Grammar ignores `size` beside it, so the kind alone decides, and a Switch with no `kind` is
|
|
44
44
|
* the toggle unless `size` says `md` or `lg`. The other bar controls publish `control`.
|
|
45
45
|
*/
|
|
@@ -54,16 +54,17 @@ const barControlHeight = (context, control, name) => {
|
|
|
54
54
|
const size = propOf(context, control, "size");
|
|
55
55
|
if (!size.known)
|
|
56
56
|
return "other";
|
|
57
|
-
if ((name === "Button" || name === "IconButton" || name === "Switch") && size.value === null)
|
|
57
|
+
if ((name === "Button" || name === "IconButton" || name === "Switch" || name === "AvatarButton") && size.value === null)
|
|
58
58
|
return "control";
|
|
59
|
-
|
|
59
|
+
// An AvatarButton's md is the 40px round mark, the control height (Grammar 0.55.0: round marks are sm 24 or md 40).
|
|
60
|
+
if ((name === "Button" || name === "IconButton" || name === "AvatarButton") && everyLiteral(context, size.value, new Set(["md"])))
|
|
60
61
|
return "control";
|
|
61
62
|
return textProp(context, control, "size") === "control" ? "control" : "other";
|
|
62
63
|
};
|
|
63
64
|
/** Every visible control in a navbar band uses the shared control height through its published size API. */
|
|
64
65
|
export const navbarControlSize = defineRule({
|
|
65
66
|
meta: meta("FE_NAVBAR_CONTROL_SIZE", "FE-APP-SHELL-2 requires the shared control height on bar controls.", {
|
|
66
|
-
control: "FE_NAVBAR_CONTROL_SIZE: {{name}} in the navbar band needs Grammar's shared control height: omit size or use md for Button/IconButton, kind=\"toggle\" (or no kind and no size) for Switch, and size=\"control\" for the other bar controls.",
|
|
67
|
+
control: "FE_NAVBAR_CONTROL_SIZE: {{name}} in the navbar band needs Grammar's shared control height: omit size or use md for Button/IconButton/AvatarButton, kind=\"toggle\" (or no kind and no size) for Switch, and size=\"control\" for the other bar controls.",
|
|
67
68
|
compact: "FE_NAVBAR_CONTROL_SIZE: a Switch kind=\"compact\" (32x18, no thumb glyph) in the navbar band breaks the bar's one 40px height; the bar's switch is kind=\"toggle\" (72x40, the theme switch). Compact is for a setting in a row, a list, a table cell or a toolbar.",
|
|
68
69
|
}),
|
|
69
70
|
create(context) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** Avatars as siblings, or an Avatar from a map, stand in an `AvatarGroup`. */
|
|
3
|
+
export declare const avatarRowUsesGroup: 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,98 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { elementNameOf, grammarName, renderedChildren } from "./lib/grammar-jsx.js";
|
|
3
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* AVATARS IN A ROW ARE ONE AVATARGROUP (DNA-COMMON-AVATAR-ROW-GROUP; owner, 2026-11-22: "với providers phải render AvatarGroup với nhiều hơn 5 thì +2 đồ chứ?? .claude sao k ép
|
|
6
|
+
* tụi này render sáng tạo nhỉ"). Avatars that stand side by side, or that come out of a list, are `<AvatarGroup items max>`: it overlaps them, shows `max - 1` and the "+N" tile,
|
|
7
|
+
* names every member on hover, and takes people and provider or channel marks alike. A hand-made row of `Avatar` has none of that and every app draws its own overflow.
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT READS. In product source, a Grammar `Avatar` that (a) shares its parent with another Grammar `Avatar` (siblings, looked through fragments, conditions and `&&`), or
|
|
10
|
+
* (b) is returned from a `.map()` callback, and that has no Grammar `AvatarGroup` among its JSX ancestors in the same file. An element passed as a JSX attribute value is judged
|
|
11
|
+
* where the receiver draws it.
|
|
12
|
+
*
|
|
13
|
+
* WHAT IT LEAVES ALONE. A single `Avatar`, an `AvatarButton`, an `Avatar` inside an `AvatarGroup`, and non-product source; Grammar's own `AvatarGroup` is not product source.
|
|
14
|
+
*/
|
|
15
|
+
const AVATAR = "Avatar";
|
|
16
|
+
const GROUP = "AvatarGroup";
|
|
17
|
+
const isAvatar = (context, node) => node.type === "JSXElement" && elementNameOf(node) === AVATAR && grammarName(context, node.openingElement) === AVATAR;
|
|
18
|
+
/** True when a Grammar `AvatarGroup` encloses the element in this file. */
|
|
19
|
+
const hasGroupAncestor = (context, opening) => {
|
|
20
|
+
let previous = opening;
|
|
21
|
+
for (let current = opening.parent?.parent; current !== undefined && current !== null; previous = current, current = current.parent) {
|
|
22
|
+
if (current.type !== "JSXElement" || previous === current.openingElement)
|
|
23
|
+
continue;
|
|
24
|
+
if (grammarName(context, current.openingElement) === GROUP)
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
};
|
|
29
|
+
/** True when the element is returned from a `.map()` callback: through the JSX, conditions and the callback's `return`, up to the callback itself. */
|
|
30
|
+
const isMapped = (opening) => {
|
|
31
|
+
for (let current = opening.parent; current !== undefined && current !== null; current = current.parent) {
|
|
32
|
+
if (current.type === "JSXAttribute")
|
|
33
|
+
return false;
|
|
34
|
+
if (current.type !== "ArrowFunctionExpression" && current.type !== "FunctionExpression")
|
|
35
|
+
continue;
|
|
36
|
+
const call = current.parent;
|
|
37
|
+
if (call?.type !== "CallExpression" || call.arguments[0] !== current)
|
|
38
|
+
return false;
|
|
39
|
+
const callee = call.callee;
|
|
40
|
+
return callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && callee.property.name === "map";
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
};
|
|
44
|
+
/** The JSX element or fragment whose children hold this element (expression wrappers looked through), or null when it is not a child. */
|
|
45
|
+
const hostOf = (element) => {
|
|
46
|
+
for (let current = element.parent; current !== undefined && current !== null; current = current.parent) {
|
|
47
|
+
if (current.type === "JSXElement" || current.type === "JSXFragment")
|
|
48
|
+
return current;
|
|
49
|
+
if (current.type === "JSXAttribute")
|
|
50
|
+
return null;
|
|
51
|
+
if (current.type === "ArrowFunctionExpression" || current.type === "FunctionExpression" || current.type === "ReturnStatement" || current.type === "BlockStatement")
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
56
|
+
/** Avatars as siblings, or an Avatar from a map, stand in an `AvatarGroup`. */
|
|
57
|
+
export const avatarRowUsesGroup = defineRule({
|
|
58
|
+
meta: {
|
|
59
|
+
type: "problem",
|
|
60
|
+
docs: { description: "DNA-COMMON-AVATAR-ROW-GROUP: two or more `Avatar` siblings, or an `Avatar` returned from `.map()`, outside an `AvatarGroup` are refused; use `<AvatarGroup items max>`." },
|
|
61
|
+
schema: [],
|
|
62
|
+
messages: {
|
|
63
|
+
siblings: "This `Avatar` stands beside another `Avatar`. Avatars in a row are ONE group: `<AvatarGroup label items={[{ id, name, seed } or { id, name, mark }]} max overflowLabel />` overlaps them, shows `max - 1` and a \"+N\" tile, and names every member on hover.",
|
|
64
|
+
mapped: "This `Avatar` is returned from `.map()`. A list of avatars is ONE group: `<AvatarGroup label items={…} max overflowLabel />` (people by `name` and `seed`, providers and channels by `mark`) draws the overlap and the \"+N\" tile; do not map `Avatar`.",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
create(context) {
|
|
68
|
+
if (!isProductSource(context))
|
|
69
|
+
return {};
|
|
70
|
+
return {
|
|
71
|
+
JSXOpeningElement(opening) {
|
|
72
|
+
if (grammarName(context, opening) !== AVATAR)
|
|
73
|
+
return;
|
|
74
|
+
const element = opening.parent;
|
|
75
|
+
if (element?.type !== "JSXElement" || hasGroupAncestor(context, opening))
|
|
76
|
+
return;
|
|
77
|
+
if (isMapped(opening)) {
|
|
78
|
+
context.report({ node: opening, messageId: "mapped" });
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const host = hostOf(element);
|
|
82
|
+
if (host === null)
|
|
83
|
+
return;
|
|
84
|
+
const avatars = renderedChildren(host.children).filter((child) => isAvatar(context, child));
|
|
85
|
+
// The first stands alone as far as this rule goes; each one after it is the second that makes a row.
|
|
86
|
+
if (avatars.length >= 2 && avatars[0] !== element)
|
|
87
|
+
context.report({ node: opening, messageId: "siblings" });
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
/** The rules this law contributes to the plugin. */
|
|
93
|
+
export const rules = {
|
|
94
|
+
"avatar-row-uses-group": avatarRowUsesGroup,
|
|
95
|
+
};
|
|
96
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#AVATAR-ROW-GROUP");
|
|
97
|
+
/** Every rule of this law is an error. */
|
|
98
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
package/dist/button-arrow.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* A typed arrow (owner 2026-11-22: no arrow characters in ANY rendered text; "Không dùng ký tự mũi tên gõ tay; hướng đi là icon của Grammar"):
|
|
4
|
+
* the Unicode Arrows block U+2190-U+21FF, the dingbat arrows U+2794-U+27BF, the long arrows U+27F0-U+27FF, and the ASCII `->`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const TYPED_ARROW: RegExp;
|
|
2
7
|
/** A Button leads somewhere with `endArrow` and does something with `startGlyph`; no typed arrow, no arrow icon, never both. */
|
|
3
8
|
export declare const buttonArrow: Rule.RuleModule;
|
|
9
|
+
/**
|
|
10
|
+
* No typed arrow in ANY rendered text (`FE_NO_TYPED_ARROW`, owner 2026-11-22). In product source, JSX text, a string or template literal
|
|
11
|
+
* rendered as a child (and the branches of a conditional), and a string attribute that is rendered text (`label`, `title`, `aria-label`,
|
|
12
|
+
* `description`, ...) holding an arrow character is an error: direction is the Grammar's arrow or link icon, `Link`'s own arrow or
|
|
13
|
+
* `Button endArrow`. i18n message values are JSON the lint does not read; the content concept (contexts/ui/content.md) holds them.
|
|
14
|
+
*/
|
|
15
|
+
export declare const noTypedArrow: Rule.RuleModule;
|
|
4
16
|
/** The rules this law contributes to the plugin. */
|
|
5
17
|
export declare const rules: Record<string, Rule.RuleModule>;
|
|
6
18
|
/** Every rule of this law is an error. */
|
package/dist/button-arrow.js
CHANGED
|
@@ -7,15 +7,22 @@ import { attributeOf, descendants, elementOf, grammarBindings } from "./lib/row-
|
|
|
7
7
|
* mirrored in RTL); a typed `→` or a passed-in arrow icon does neither.
|
|
8
8
|
*
|
|
9
9
|
* WHAT IT READS. A `Button` bound to `@starci/grammar`:
|
|
10
|
-
* - a label (children) that states
|
|
10
|
+
* - a label (children) that states `›` or `»` (a typed arrow anywhere is `no-typed-arrow`, below);
|
|
11
11
|
* - an `endContent` that is an arrow: an element named `Arrow*` or `ChevronRight*`, or any element whose `source` / `glyph` / `name`
|
|
12
12
|
* is such an identifier or a string that names `arrow`, `chevron-right` or `chevron-end`;
|
|
13
13
|
* - `endArrow` together with `startGlyph` or `startContent` (the Button type refuses it as well).
|
|
14
14
|
* `Button` takes the label as its children only, so no string label prop exists to read. `IconButton` has no label to type an arrow
|
|
15
15
|
* in and no `endArrow`; `TextAction` takes `endContent` but not `endArrow`, so neither is judged.
|
|
16
16
|
*/
|
|
17
|
-
/** A label
|
|
18
|
-
const LABEL_ARROW = /[
|
|
17
|
+
/** A Button label's pointing quote marks: `›` and `»` (a typed arrow character is `no-typed-arrow`, for every element). */
|
|
18
|
+
const LABEL_ARROW = /[›»]/u;
|
|
19
|
+
/**
|
|
20
|
+
* A typed arrow (owner 2026-11-22: no arrow characters in ANY rendered text; "Không dùng ký tự mũi tên gõ tay; hướng đi là icon của Grammar"):
|
|
21
|
+
* the Unicode Arrows block U+2190-U+21FF, the dingbat arrows U+2794-U+27BF, the long arrows U+27F0-U+27FF, and the ASCII `->`.
|
|
22
|
+
*/
|
|
23
|
+
export const TYPED_ARROW = /[\u2190-\u21FF\u2794-\u27BF\u27F0-\u27FF]|->/u;
|
|
24
|
+
/** JSX attributes whose string value is never rendered text: a class, a URL, an id, a key, a role, a data or style hook, a handler. */
|
|
25
|
+
const NOT_TEXT_ATTRIBUTE = /^(?:className|class|href|src|srcSet|id|key|htmlFor|role|type|name|value|style|target|rel|data-.*|on[A-Z].*)$/u;
|
|
19
26
|
/** A glyph or icon name that is an arrow or an end-pointing chevron, whatever its case and separators. */
|
|
20
27
|
const isArrowName = (name) => {
|
|
21
28
|
const flat = name.toLowerCase().replace(/[^a-z0-9]/gu, "");
|
|
@@ -95,7 +102,7 @@ export const buttonArrow = defineRule({
|
|
|
95
102
|
docs: { description: "FE_BUTTON_ARROW: a Button that leads somewhere ends with `endArrow`; one that does something starts with `startGlyph`." },
|
|
96
103
|
schema: [],
|
|
97
104
|
messages: {
|
|
98
|
-
label: "The Button label types
|
|
105
|
+
label: "The Button label types a pointing mark (`{{text}}`). A Button that leads somewhere takes `endArrow`: the Grammar arrow slides toward the reading end on hover and is mirrored in RTL. Remove the character from the label and add `endArrow`; keep the start side (`startGlyph`) for what the action does and the end side for where it goes.",
|
|
99
106
|
endContent: "The Button passes an arrow icon as `endContent`. A Button that leads somewhere takes `endArrow` (the Grammar arrow that slides on hover and is mirrored in RTL). Replace the `endContent` arrow with `endArrow`.",
|
|
100
107
|
both: "The Button sets `endArrow` and `{{start}}`. A Button either leads somewhere (`endArrow`) or does something (`startGlyph`), never both. Keep the one that says what the Button is.",
|
|
101
108
|
},
|
|
@@ -137,9 +144,53 @@ export const buttonArrow = defineRule({
|
|
|
137
144
|
};
|
|
138
145
|
},
|
|
139
146
|
});
|
|
147
|
+
/**
|
|
148
|
+
* No typed arrow in ANY rendered text (`FE_NO_TYPED_ARROW`, owner 2026-11-22). In product source, JSX text, a string or template literal
|
|
149
|
+
* rendered as a child (and the branches of a conditional), and a string attribute that is rendered text (`label`, `title`, `aria-label`,
|
|
150
|
+
* `description`, ...) holding an arrow character is an error: direction is the Grammar's arrow or link icon, `Link`'s own arrow or
|
|
151
|
+
* `Button endArrow`. i18n message values are JSON the lint does not read; the content concept (contexts/ui/content.md) holds them.
|
|
152
|
+
*/
|
|
153
|
+
export const noTypedArrow = defineRule({
|
|
154
|
+
meta: {
|
|
155
|
+
type: "problem",
|
|
156
|
+
docs: { description: "FE_NO_TYPED_ARROW: no typed arrow character in rendered text; direction is a Grammar icon, Link's arrow or Button endArrow." },
|
|
157
|
+
schema: [],
|
|
158
|
+
messages: {
|
|
159
|
+
typed: "Rendered text types an arrow (`{{text}}`). Direction is shown by the Grammar: `Button endArrow`, `Link`'s own arrow, or the Grammar arrow or chevron icon; they slide on hover and mirror in RTL. Remove the character.",
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
create(context) {
|
|
163
|
+
if (!isProductSource(context))
|
|
164
|
+
return {};
|
|
165
|
+
const report = (node, text) => {
|
|
166
|
+
const found = TYPED_ARROW.exec(text);
|
|
167
|
+
if (found)
|
|
168
|
+
context.report({ node, messageId: "typed", data: { text: found[0] } });
|
|
169
|
+
};
|
|
170
|
+
return {
|
|
171
|
+
JSXElement(element) {
|
|
172
|
+
for (const child of element.children)
|
|
173
|
+
for (const { node, text } of literalTexts(child))
|
|
174
|
+
report(node, text);
|
|
175
|
+
},
|
|
176
|
+
JSXFragment(fragment) {
|
|
177
|
+
for (const child of fragment.children)
|
|
178
|
+
for (const { node, text } of literalTexts(child))
|
|
179
|
+
report(node, text);
|
|
180
|
+
},
|
|
181
|
+
JSXAttribute(attribute) {
|
|
182
|
+
if (attribute.name.type !== "JSXIdentifier" || NOT_TEXT_ATTRIBUTE.test(attribute.name.name))
|
|
183
|
+
return;
|
|
184
|
+
for (const { node, text } of literalTexts(attribute.value))
|
|
185
|
+
report(node, text);
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
});
|
|
140
190
|
/** The rules this law contributes to the plugin. */
|
|
141
191
|
export const rules = {
|
|
142
192
|
"button-arrow": buttonArrow,
|
|
193
|
+
"no-typed-arrow": noTypedArrow,
|
|
143
194
|
};
|
|
144
195
|
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#BUTTON-ARROW");
|
|
145
196
|
/** Every rule of this law is an error. */
|
|
@@ -6,7 +6,7 @@ import type { Rule } from "eslint";
|
|
|
6
6
|
* `ChoiceChips` for a date and a time.
|
|
7
7
|
*
|
|
8
8
|
* WHAT IT READS. A JSX element named `ButtonGroup`, `FilterButtonGroup` or `SegmentedControl` in product source, written
|
|
9
|
-
* bare or as a member (`Grammar.ButtonGroup`).
|
|
9
|
+
* bare or as a member (`Grammar.ButtonGroup`). ButtonGroup and FilterButtonGroup were deleted in Grammar 0.55.0; the rule still names the replacement.
|
|
10
10
|
*
|
|
11
11
|
* A second rule holds the same law for loose buttons: two or more adjacent `Button` or `IconButton` elements (or one written in a
|
|
12
12
|
* `.map`) that carry `aria-pressed`, `isSelected` or `isActive` are joined buttons acting as tabs, a pill toggle ("This month / Last
|
package/dist/choice-controls.js
CHANGED
|
@@ -7,7 +7,7 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
|
7
7
|
* `ChoiceChips` for a date and a time.
|
|
8
8
|
*
|
|
9
9
|
* WHAT IT READS. A JSX element named `ButtonGroup`, `FilterButtonGroup` or `SegmentedControl` in product source, written
|
|
10
|
-
* bare or as a member (`Grammar.ButtonGroup`).
|
|
10
|
+
* bare or as a member (`Grammar.ButtonGroup`). ButtonGroup and FilterButtonGroup were deleted in Grammar 0.55.0; the rule still names the replacement.
|
|
11
11
|
*
|
|
12
12
|
* A second rule holds the same law for loose buttons: two or more adjacent `Button` or `IconButton` elements (or one written in a
|
|
13
13
|
* `.map`) that carry `aria-pressed`, `isSelected` or `isActive` are joined buttons acting as tabs, a pill toggle ("This month / Last
|
package/dist/icon.js
CHANGED
|
@@ -126,10 +126,10 @@ const SIZE_UTILITY = /(?:^|\s)(?:size|w|h|min-w|min-h|max-w|max-h)-\S+/;
|
|
|
126
126
|
export const noIconSizeClass = defineRule({
|
|
127
127
|
meta: {
|
|
128
128
|
type: "problem",
|
|
129
|
-
docs: { description: "A glyph component takes its size from its
|
|
129
|
+
docs: { description: "A glyph component takes its size from its role (the icon table: `control` 16 beside 14px words and in every labelled control, `row` 20 in the 40 tile, `head` 24 in the 48 tile, `text` 1em for a caret or a status glyph), never from a size class at the call site." },
|
|
130
130
|
schema: [],
|
|
131
131
|
messages: {
|
|
132
|
-
size: "`{{cls}}` sizes a glyph at the call site. The size of a glyph is its
|
|
132
|
+
size: "`{{cls}}` sizes a glyph at the call site. The size of a glyph is its role's (`Icon usage` and the Grammar components that draw one; the icon table: `control` 16 beside 14px words and in every labelled control, `row` 20 in the 40 tile, `head` 24 in the 48 tile, `text` 1em of its words for a caret or a status glyph), so the app passes the glyph and no size class; a size written here is a third step nobody applies the same way twice.",
|
|
133
133
|
},
|
|
134
134
|
},
|
|
135
135
|
create(context) {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import { rules as avatarRowUsesGroupRules } from "./avatar-row-uses-group.js";
|
|
4
5
|
import { rules as buttonArrowRules } from "./button-arrow.js";
|
|
5
6
|
import { rules as cardContentRules } from "./card-content.js";
|
|
6
7
|
import { rules as cardIsObjectRules } from "./card-is-object.js";
|
|
@@ -18,6 +19,7 @@ import { rules as mascotRules } from "./mascot.js";
|
|
|
18
19
|
import { rules as mediaRules } from "./media.js";
|
|
19
20
|
import { rules as menuEntriesRules } from "./menu-entries.js";
|
|
20
21
|
import { rules as noRawScrollRules } from "./no-raw-scroll.js";
|
|
22
|
+
import { rules as noRawSpacingStyleRules } from "./no-raw-spacing-style.js";
|
|
21
23
|
import { rules as noRawTypeSizeRules } from "./no-raw-type-size.js";
|
|
22
24
|
import { rules as outlineIconsRules } from "./outline-icons.js";
|
|
23
25
|
import { rules as pageRules } from "./page.js";
|
|
@@ -29,6 +31,7 @@ import { rules as rowsInCardRules } from "./rows-in-card.js";
|
|
|
29
31
|
import { rules as noCardLeadDescriptionRules } from "./no-card-lead-description.js";
|
|
30
32
|
import { rules as noNestedLabelRules } from "./no-nested-label.js";
|
|
31
33
|
import { rules as sectionHeadActionRules } from "./section-head-action.js";
|
|
34
|
+
import { rules as siteTypeRoleRules } from "./site-type-role.js";
|
|
32
35
|
import { rules as sameLineSizeRules } from "./same-line-size.js";
|
|
33
36
|
import { rules as surfaceCardRules } from "./surface-card.js";
|
|
34
37
|
import { rules as surfaceDepthRules } from "./surface-depth.js";
|
|
@@ -55,6 +58,7 @@ const JUDGES_FRAGMENT_ITSELF = new Set(["fragment"]);
|
|
|
55
58
|
const DECLARED = [
|
|
56
59
|
{ law: "fragment", rules: fragmentRules },
|
|
57
60
|
{ law: "app-shell", rules: appShellRules },
|
|
61
|
+
{ law: "avatar-row-uses-group", rules: avatarRowUsesGroupRules },
|
|
58
62
|
{ law: "button-arrow", rules: buttonArrowRules },
|
|
59
63
|
{ law: "card-content", rules: cardContentRules },
|
|
60
64
|
{ law: "card-is-object", rules: cardIsObjectRules },
|
|
@@ -71,6 +75,7 @@ const DECLARED = [
|
|
|
71
75
|
{ law: "media", rules: mediaRules },
|
|
72
76
|
{ law: "menu-entries", rules: menuEntriesRules },
|
|
73
77
|
{ law: "no-raw-scroll", rules: noRawScrollRules },
|
|
78
|
+
{ law: "no-raw-spacing-style", rules: noRawSpacingStyleRules },
|
|
74
79
|
{ law: "no-raw-type-size", rules: noRawTypeSizeRules },
|
|
75
80
|
{ law: "outline-icons", rules: outlineIconsRules },
|
|
76
81
|
{ law: "page", rules: pageRules },
|
|
@@ -83,6 +88,7 @@ const DECLARED = [
|
|
|
83
88
|
{ law: "no-card-lead-description", rules: noCardLeadDescriptionRules },
|
|
84
89
|
{ law: "no-nested-label", rules: noNestedLabelRules },
|
|
85
90
|
{ law: "section-head-action", rules: sectionHeadActionRules },
|
|
91
|
+
{ law: "site-type-role", rules: siteTypeRoleRules },
|
|
86
92
|
{ law: "surface-card", rules: surfaceCardRules },
|
|
87
93
|
{ law: "surface-depth", rules: surfaceDepthRules },
|
|
88
94
|
{ law: "surface-in-surface", rules: surfaceInSurfaceRules },
|
|
@@ -116,6 +122,7 @@ export const rules = Object.fromEntries(CONTRIBUTIONS.flatMap(({ rules }) => Obj
|
|
|
116
122
|
*/
|
|
117
123
|
export const COUNTING = Object.freeze({
|
|
118
124
|
"starci-grammar/no-raw-type-size": { law: "TYPE-ROLES", until: "both apps have moved their raw type sizes onto the type roles" },
|
|
125
|
+
"starci-grammar/no-raw-spacing-style": { law: "SPACING-ROLES", until: "both apps have moved their raw style spacing onto the spacing roles" },
|
|
119
126
|
});
|
|
120
127
|
/** The level of one published rule: warn in the counting cohort, error otherwise. */
|
|
121
128
|
const levelOf = (name) => (`starci-grammar/${name}` in COUNTING ? "warn" : "error");
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReaderContext } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* THE PUBLIC SITE (0.55.0). No hfs slot marks an app's public marketing site yet; the proposed one is `fe.site`, and a file it owns is
|
|
4
|
+
* the site at once. Until it exists the site is read from the slots the manifest already has, through `classify`, never a raw path test:
|
|
5
|
+
* - an owner of `fe.components` or `fe.feature` named `Site…` or `Marketing…` (its `<name>` binding: `SiteHead`, `SiteBrandPage`);
|
|
6
|
+
* - a route file of `fe.route` under the `(site)` or `(marketing)` route group (FE-CSS-2 names the marketing `(site)` group);
|
|
7
|
+
* - a capability of `fe.modules` named `site…` or `marketing…` (`modules/site-home`).
|
|
8
|
+
* The codemod v0550 mirrors this as `isSitePath` (packages/grammar/codemods/v0550).
|
|
9
|
+
*/
|
|
10
|
+
export declare const SITE_SLOT = "fe.site";
|
|
11
|
+
/** True for a file of the app's public marketing site. */
|
|
12
|
+
export declare const isSiteFile: (context: ReaderContext, file: string) => boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { hfsOf } from "@starci/eslint-canon-fe/lib/hfs.mjs";
|
|
2
|
+
/**
|
|
3
|
+
* THE PUBLIC SITE (0.55.0). No hfs slot marks an app's public marketing site yet; the proposed one is `fe.site`, and a file it owns is
|
|
4
|
+
* the site at once. Until it exists the site is read from the slots the manifest already has, through `classify`, never a raw path test:
|
|
5
|
+
* - an owner of `fe.components` or `fe.feature` named `Site…` or `Marketing…` (its `<name>` binding: `SiteHead`, `SiteBrandPage`);
|
|
6
|
+
* - a route file of `fe.route` under the `(site)` or `(marketing)` route group (FE-CSS-2 names the marketing `(site)` group);
|
|
7
|
+
* - a capability of `fe.modules` named `site…` or `marketing…` (`modules/site-home`).
|
|
8
|
+
* The codemod v0550 mirrors this as `isSitePath` (packages/grammar/codemods/v0550).
|
|
9
|
+
*/
|
|
10
|
+
export const SITE_SLOT = "fe.site";
|
|
11
|
+
const SITE_OWNER = /^(?:Site|Marketing)[A-Z0-9]/;
|
|
12
|
+
const SITE_CAPABILITY = /^(?:site|marketing)(?:$|[-_A-Z])/;
|
|
13
|
+
const SITE_GROUP = /^\((?:site|marketing)\)$/;
|
|
14
|
+
/** True for a file of the app's public marketing site. */
|
|
15
|
+
export const isSiteFile = (context, file) => {
|
|
16
|
+
const found = hfsOf(context).classify(file);
|
|
17
|
+
if (found.slot === SITE_SLOT)
|
|
18
|
+
return true;
|
|
19
|
+
const name = found.bindings?.["name"];
|
|
20
|
+
if ((found.slot === "fe.components" || found.slot === "fe.feature") && name !== undefined)
|
|
21
|
+
return SITE_OWNER.test(name);
|
|
22
|
+
if (found.slot === "fe.modules")
|
|
23
|
+
return SITE_CAPABILITY.test(found.bindings?.["capability"] ?? "");
|
|
24
|
+
if (found.slot === "fe.route" && found.root !== undefined)
|
|
25
|
+
return found.path.slice(found.root.length + 1).split("/").some((segment) => SITE_GROUP.test(segment));
|
|
26
|
+
return false;
|
|
27
|
+
};
|
package/dist/lib/why.js
CHANGED
|
@@ -24,6 +24,11 @@ export const why = {
|
|
|
24
24
|
en: "A muted `Text` in `<file>` stands directly above a `SurfaceCard` as its description.",
|
|
25
25
|
fix: "A card has no description. Put the line in the row subtitle (a `ListRow` subtitle of a `Section kind=\"list\"`, or an option `description` of a `RadioGroup`), or, when it explains the card's data (a legend, a source, a period), in the card `note`.",
|
|
26
26
|
},
|
|
27
|
+
"avatar-row-uses-group": {
|
|
28
|
+
code: "FE_AVATAR_ROW_USES_GROUP",
|
|
29
|
+
en: "`<file>` draws two or more `Avatar` elements side by side, or returns an `Avatar` from `.map()`, with no `AvatarGroup` around them.",
|
|
30
|
+
fix: "Avatars in a row or from a list are ONE `AvatarGroup`: `<AvatarGroup label items={[{ id, name, seed }, { id, name, mark }]} max overflowLabel />`. It overlaps the items, shows `max - 1` and a \"+N\" tile, rings a broken account (`tone: \"danger\"`) and names every member on hover; a person is `name` and `seed`, a provider or channel is a `mark`. Never hand-place or map `Avatar`.",
|
|
31
|
+
},
|
|
27
32
|
"no-nested-label": {
|
|
28
33
|
code: "FE_NO_NESTED_LABEL",
|
|
29
34
|
en: "A `Section` or `SurfaceCard` in `<file>` has its own Label inside a labelled `Section` or `SurfaceCard`.",
|
|
@@ -31,8 +36,8 @@ export const why = {
|
|
|
31
36
|
},
|
|
32
37
|
"section-head-action": {
|
|
33
38
|
code: "FE_SECTION_HEAD_ACTION",
|
|
34
|
-
en: "The `Section` head `action` in `<file>` holds a Button that is not a
|
|
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
|
|
39
|
+
en: "The `Section` head `action` in `<file>` holds a Button that is not a border small text Button, or more than one command.",
|
|
40
|
+
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 size=\"sm\"` in the border look (no icon, never the primary).",
|
|
36
41
|
},
|
|
37
42
|
"card-one-content": {
|
|
38
43
|
code: "FE_CARD_ONE_CONTENT",
|
|
@@ -184,9 +189,14 @@ export const why = {
|
|
|
184
189
|
en: "A `body` SurfaceCard in `<file>` holds a hand-built list, a Divider, or a SectionHeader or Heading as a second title.",
|
|
185
190
|
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`.",
|
|
186
191
|
},
|
|
192
|
+
"no-typed-arrow": {
|
|
193
|
+
code: "FE_NO_TYPED_ARROW",
|
|
194
|
+
en: "Rendered text in `<file>` types an arrow character (→ ← ↑ ↓ ⇒ ➜ ➔, the Unicode arrow blocks, or `->`).",
|
|
195
|
+
fix: "Không dùng ký tự mũi tên gõ tay; hướng đi là icon của Grammar: `Button endArrow`, `Link`'s own arrow, or the Grammar arrow or chevron icon. Remove the character.",
|
|
196
|
+
},
|
|
187
197
|
"button-arrow": {
|
|
188
198
|
code: "FE_BUTTON_ARROW",
|
|
189
|
-
en: "A Button in `<file>` types
|
|
199
|
+
en: "A Button in `<file>` types a pointing mark (› ») in its label, passes an arrow icon as `endContent`, or sets `endArrow` together with `startGlyph` or `startContent`.",
|
|
190
200
|
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.",
|
|
191
201
|
},
|
|
192
202
|
"layout-two-axis": {
|
|
@@ -202,7 +212,12 @@ export const why = {
|
|
|
202
212
|
"no-raw-type-size": {
|
|
203
213
|
code: "FE_RAW_TYPE_SIZE",
|
|
204
214
|
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.",
|
|
215
|
+
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; on the public site also display.hero, display.section, display.figure, lead and title.card.",
|
|
216
|
+
},
|
|
217
|
+
"site-type-role": {
|
|
218
|
+
code: "FE_SITE_TYPE_ROLE",
|
|
219
|
+
en: "`<file>` is not the public site, and it draws a role of the site group: `display.hero`, `display.section`, `display.figure`, `lead` or `title.card` (`<Text role>` or `starci-type-<role>`).",
|
|
220
|
+
fix: "The site group (Grammar 0.55.0, owner 2026-11-21) is the public marketing site's alone. A console draws with the ten roles: title.page for a page heading, title.section for a section or card title, figure for a value, body for copy. A file of the site is a `Site…` or `Marketing…` owner, a route under `(site)`, or `modules/site…`.",
|
|
206
221
|
},
|
|
207
222
|
"table-cell-type": {
|
|
208
223
|
code: "FE_TABLE_CELL_TYPE",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* THE SPACING ROLES (owner, 2026-11-23, SPACING-ROLES; contexts/ui/scale.md "The spacing roles"). A distance between two things an app
|
|
4
|
+
* places is a ROLE the Grammar resolves (`Stack gap`, `Cluster gap`, `Grid`, `PaneSection`, `Page`, the inset of a Grammar box), never
|
|
5
|
+
* a raw value. The class-string half is the canon's `starci-fe/no-spacing-utility` (R350); this rule is the `style` half.
|
|
6
|
+
*
|
|
7
|
+
* WHAT IT READS, in product source: a key of the object a JSX `style` attribute holds that writes a gap, a padding or a margin
|
|
8
|
+
* (`gap`, `rowGap`, `columnGap`, `padding`, `paddingInline`, `paddingTop`, …, `margin`, `marginBlockStart`, …), whatever its value.
|
|
9
|
+
*
|
|
10
|
+
* WHAT IT LEAVES ALONE. Every other style key (a width, a transform, a colour variable), an object that is not a JSX `style` (a chart
|
|
11
|
+
* option, a canvas measure), Freestyle and Fragment regions and non-product source.
|
|
12
|
+
*
|
|
13
|
+
* It is a counting rule (`COUNTING` in index.ts): reported and counted at warn until both apps have moved onto the roles, then blocking.
|
|
14
|
+
*/
|
|
15
|
+
/** A style key that writes a gap, a padding or a margin, on any side or axis. */
|
|
16
|
+
export declare const SPACING_KEY: RegExp;
|
|
17
|
+
/** No raw gap, padding or margin in a JSX `style`: the relation is a Grammar spacing role. */
|
|
18
|
+
export declare const noRawSpacingStyle: Rule.RuleModule;
|
|
19
|
+
/** The rules this law contributes to the plugin. */
|
|
20
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
21
|
+
/** The rule runs in the counting cohort (index.ts `COUNTING`): a warning until both apps migrate. */
|
|
22
|
+
export declare const recommended: Record<string, "warn">;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { defineFamilyRules, defineRule, exemptFreestyle } from "./lib/rule-contract.js";
|
|
3
|
+
/**
|
|
4
|
+
* THE SPACING ROLES (owner, 2026-11-23, SPACING-ROLES; contexts/ui/scale.md "The spacing roles"). A distance between two things an app
|
|
5
|
+
* places is a ROLE the Grammar resolves (`Stack gap`, `Cluster gap`, `Grid`, `PaneSection`, `Page`, the inset of a Grammar box), never
|
|
6
|
+
* a raw value. The class-string half is the canon's `starci-fe/no-spacing-utility` (R350); this rule is the `style` half.
|
|
7
|
+
*
|
|
8
|
+
* WHAT IT READS, in product source: a key of the object a JSX `style` attribute holds that writes a gap, a padding or a margin
|
|
9
|
+
* (`gap`, `rowGap`, `columnGap`, `padding`, `paddingInline`, `paddingTop`, …, `margin`, `marginBlockStart`, …), whatever its value.
|
|
10
|
+
*
|
|
11
|
+
* WHAT IT LEAVES ALONE. Every other style key (a width, a transform, a colour variable), an object that is not a JSX `style` (a chart
|
|
12
|
+
* option, a canvas measure), Freestyle and Fragment regions and non-product source.
|
|
13
|
+
*
|
|
14
|
+
* It is a counting rule (`COUNTING` in index.ts): reported and counted at warn until both apps have moved onto the roles, then blocking.
|
|
15
|
+
*/
|
|
16
|
+
/** A style key that writes a gap, a padding or a margin, on any side or axis. */
|
|
17
|
+
export const SPACING_KEY = /^(?:gap|rowGap|columnGap|row-gap|column-gap|(?:padding|margin)(?:Inline|Block|Top|Bottom|Left|Right)?(?:Start|End)?|(?:padding|margin)(?:-(?:inline|block|top|bottom|left|right)(?:-(?:start|end))?)?)$/;
|
|
18
|
+
const keyName = (node) => {
|
|
19
|
+
if (node.computed)
|
|
20
|
+
return null;
|
|
21
|
+
if (node.key.type === "Identifier")
|
|
22
|
+
return node.key.name;
|
|
23
|
+
return node.key.type === "Literal" && typeof node.key.value === "string" ? node.key.value : null;
|
|
24
|
+
};
|
|
25
|
+
/** The object literal a JSX `style={{ … }}` attribute holds, when the property belongs to it. */
|
|
26
|
+
const inStyleAttribute = (node) => {
|
|
27
|
+
const object = node.parent;
|
|
28
|
+
if (object?.type !== "ObjectExpression")
|
|
29
|
+
return false;
|
|
30
|
+
const container = object.parent;
|
|
31
|
+
if (container?.type !== "JSXExpressionContainer")
|
|
32
|
+
return false;
|
|
33
|
+
const attribute = container.parent;
|
|
34
|
+
return attribute?.type === "JSXAttribute" && attribute.name.type === "JSXIdentifier" && attribute.name.name === "style";
|
|
35
|
+
};
|
|
36
|
+
/** No raw gap, padding or margin in a JSX `style`: the relation is a Grammar spacing role. */
|
|
37
|
+
export const noRawSpacingStyle = exemptFreestyle(defineRule({
|
|
38
|
+
meta: {
|
|
39
|
+
type: "suggestion",
|
|
40
|
+
docs: { description: "SPACING-ROLES: spacing is a Grammar role (Stack or Cluster `gap`, the inset of a Grammar box); no gap, padding or margin in a JSX style." },
|
|
41
|
+
schema: [],
|
|
42
|
+
messages: {
|
|
43
|
+
raw: "`{{key}}` in a style writes a distance the Grammar owns. Name the relation: `gap` on the Stack, Cluster or Grid that holds the siblings (identity 4, inline 8, row 12, section 24, region 32), or the inset of the Grammar box that holds the content (SurfaceCard, PaneSection, Page, Dialog).",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
create(context) {
|
|
47
|
+
if (!isProductSource(context))
|
|
48
|
+
return {};
|
|
49
|
+
return {
|
|
50
|
+
Property(node) {
|
|
51
|
+
const key = keyName(node);
|
|
52
|
+
if (key === null || !SPACING_KEY.test(key) || !inStyleAttribute(node))
|
|
53
|
+
return;
|
|
54
|
+
context.report({ node: node, messageId: "raw", data: { key } });
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
}));
|
|
59
|
+
/** The rules this law contributes to the plugin. */
|
|
60
|
+
export const rules = {
|
|
61
|
+
"no-raw-spacing-style": noRawSpacingStyle,
|
|
62
|
+
};
|
|
63
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#SPACING-ROLES");
|
|
64
|
+
/** The rule runs in the counting cohort (index.ts `COUNTING`): a warning until both apps migrate. */
|
|
65
|
+
export const recommended = { "starci-grammar/no-raw-spacing-style": "warn" };
|
package/dist/no-raw-type-size.js
CHANGED
|
@@ -25,7 +25,7 @@ export const TEXT_SIZE_UTILITY = /(?<![\w-])(?:[\w[\]&>*:.-]+:)?!?text-(?:xs|sm|
|
|
|
25
25
|
const CSS_FONT_SIZE = /(?:^|[\s;{])font-size\s*:/;
|
|
26
26
|
/** The theme layer of an app: its tokens, never judged here. */
|
|
27
27
|
const TOKEN_FILE = /(?:^|\/)modules\/brand\//;
|
|
28
|
-
const ROLES = "figure, title.page, title.section, label.item, body, label.field, label.group, caption, badge, code";
|
|
28
|
+
const ROLES = "figure, title.page, title.section, label.item, body, label.field, label.group, caption, badge, code (the public site also has display.hero, display.section, display.figure, lead, title.card)";
|
|
29
29
|
const isTokenFile = (context) => TOKEN_FILE.test(context.filename.replaceAll("\\", "/"));
|
|
30
30
|
const keyName = (node) => {
|
|
31
31
|
if (node.computed)
|
package/dist/same-line-size.js
CHANGED
|
@@ -16,6 +16,7 @@ const LINES = new Set(["Cluster", "Text"]);
|
|
|
16
16
|
const ROLE_STEP = {
|
|
17
17
|
figure: "figure", "title.page": "title.page", "title.section": "title.section", "label.item": "md", body: "md",
|
|
18
18
|
"label.field": "label.field", "label.group": "xs", caption: "xs", badge: "xs", code: "xs",
|
|
19
|
+
"display.hero": "display.hero", "display.section": "display.section", "display.figure": "display.figure", lead: "lead", "title.card": "title.card",
|
|
19
20
|
};
|
|
20
21
|
const sizeOf = (opening) => {
|
|
21
22
|
if (opening.attributes.some((entry) => entry.type === "JSXSpreadAttribute"))
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
|
-
/** A section head holds one navigation Link, one info IconButton or one
|
|
2
|
+
/** A section head holds one navigation Link, one info IconButton or one border small Button: no primary, no icon Button, no second command. */
|
|
3
3
|
export declare const sectionHeadAction: Rule.RuleModule;
|
|
4
4
|
/** The rules this law contributes to the plugin. */
|
|
5
5
|
export declare const rules: Record<string, Rule.RuleModule>;
|
|
@@ -4,14 +4,14 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
|
4
4
|
/**
|
|
5
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
6
|
* start, and at the end at most ONE thing: a navigation `Link variant="head"` (the label then an arrow that slides on hover), an info `IconButton`,
|
|
7
|
-
* or (0.37.25) a
|
|
7
|
+
* or (0.37.25) a border small `Button` ("Add provider"). The head never holds two commands.
|
|
8
8
|
*
|
|
9
9
|
* WHAT IT READS. A Grammar `Section` in product source whose `action` prop holds:
|
|
10
|
-
* - a Grammar `Button` that is not
|
|
10
|
+
* - a Grammar `Button` that is not a `border` (the default look, or `variant="border"`) at `size="sm"` (message `button`: a primary, a danger or any other size is refused);
|
|
11
11
|
* - a `Button` that carries an icon (`startGlyph`, `startContent`, `endContent`, `icon`; message `icon`);
|
|
12
12
|
* - more than one Grammar `Button`, `Link`, `IconButton` or `TextAction` (message `many`): the head has room for one.
|
|
13
13
|
*
|
|
14
|
-
* WHAT IT LEAVES ALONE. A `Section` with no `action`, an `action` that holds one Link, one IconButton or one
|
|
14
|
+
* WHAT IT LEAVES ALONE. A `Section` with no `action`, an `action` that holds one Link, one IconButton or one border sm text Button, other components, and non-product source.
|
|
15
15
|
*/
|
|
16
16
|
const COMMANDS = new Set(["Button", "Link", "IconButton", "TextAction"]);
|
|
17
17
|
const ICON_PROPS = ["startGlyph", "startContent", "endContent", "icon", "iconSource"];
|
|
@@ -42,15 +42,15 @@ const commandsIn = (context, root) => {
|
|
|
42
42
|
visit(root);
|
|
43
43
|
return found;
|
|
44
44
|
};
|
|
45
|
-
/** A section head holds one navigation Link, one info IconButton or one
|
|
45
|
+
/** A section head holds one navigation Link, one info IconButton or one border small Button: no primary, no icon Button, no second command. */
|
|
46
46
|
export const sectionHeadAction = defineRule({
|
|
47
47
|
meta: {
|
|
48
48
|
type: "problem",
|
|
49
|
-
docs: { description: "SECTION-HEAD-ACTION: a Section's head action is one Link variant=\"head\", one IconButton or one
|
|
49
|
+
docs: { description: "SECTION-HEAD-ACTION: a Section's head action is one Link variant=\"head\", one IconButton or one border sm Button; never a primary Button, never more than one." },
|
|
50
50
|
schema: [],
|
|
51
51
|
messages: {
|
|
52
|
-
button: "A `Button` in a `Section` head `action` must be `
|
|
53
|
-
icon: "A `Button` in a `Section` head `action` has no icon (`{{prop}}`): the head's
|
|
52
|
+
button: "A `Button` in a `Section` head `action` must be a `border` (the default, or `variant=\"border\"`) at `size=\"sm\"` (a small outlined pill at the end of the label row); a primary Button spends the view's one CTA, and another size breaks the head's 32px row. Navigation can also be a `Link variant=\"head\"`.",
|
|
53
|
+
icon: "A `Button` in a `Section` head `action` has no icon (`{{prop}}`): the head's border sm Button is text only.",
|
|
54
54
|
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.",
|
|
55
55
|
},
|
|
56
56
|
},
|
|
@@ -68,8 +68,9 @@ export const sectionHeadAction = defineRule({
|
|
|
68
68
|
for (const command of commands) {
|
|
69
69
|
if (command.name !== "Button")
|
|
70
70
|
continue;
|
|
71
|
-
const
|
|
72
|
-
|
|
71
|
+
const variant = attributeOf(command.node, "variant");
|
|
72
|
+
const isBorderSmall = (variant === undefined || literalString(variant) === "border") && literalString(attributeOf(command.node, "size")) === "sm";
|
|
73
|
+
if (!isBorderSmall)
|
|
73
74
|
context.report({ node: command.node, messageId: "button" });
|
|
74
75
|
const icon = ICON_PROPS.find((name) => attributeOf(command.node, name) !== undefined);
|
|
75
76
|
if (icon !== undefined)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* THE SITE GROUP (owner 2026-11-21, "3. THÊM NHÓM", then "cook"; SITE-TYPE-ROLES). Grammar 0.55.0 adds five type roles for the public
|
|
4
|
+
* marketing site: `display.hero`, `display.section`, `display.figure`, `lead` and `title.card`. They are the site's and never the
|
|
5
|
+
* console's: a console draws with the ten roles of 0.54.0, so a display size there is a second, louder type scale.
|
|
6
|
+
*
|
|
7
|
+
* WHAT IT READS, in product source outside the site (`isSiteFile`: the `Site…`/`Marketing…` owners, the `(site)` route group,
|
|
8
|
+
* `modules/site…`, or the proposed `fe.site` slot):
|
|
9
|
+
* - `<Text role="display.hero">` (and the other four) with a literal role;
|
|
10
|
+
* - the public class of one of them in a class string (`starci-type-display-hero`, `starci-type-lead`, `starci-type-title-card`, …).
|
|
11
|
+
*
|
|
12
|
+
* It is one general rule, approved with the group. Unlike `no-raw-type-size` it is not a counting rule: no console uses the group yet.
|
|
13
|
+
* Freestyle regions are not exempt: a display role is a Grammar role, not a raw style.
|
|
14
|
+
*/
|
|
15
|
+
/** The site group's roles and their public classes (dots as dashes). */
|
|
16
|
+
export declare const SITE_ROLES: readonly string[];
|
|
17
|
+
/** A site role (`display.*`, `lead`, `title.card`) is drawn on the public site only. */
|
|
18
|
+
export declare const siteTypeRole: Rule.RuleModule;
|
|
19
|
+
/** The rules this law contributes to the plugin. */
|
|
20
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
@@ -0,0 +1,81 @@
|
|
|
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 } from "./lib/rule-contract.js";
|
|
4
|
+
import { isSiteFile } from "./lib/site-scope.js";
|
|
5
|
+
/**
|
|
6
|
+
* THE SITE GROUP (owner 2026-11-21, "3. THÊM NHÓM", then "cook"; SITE-TYPE-ROLES). Grammar 0.55.0 adds five type roles for the public
|
|
7
|
+
* marketing site: `display.hero`, `display.section`, `display.figure`, `lead` and `title.card`. They are the site's and never the
|
|
8
|
+
* console's: a console draws with the ten roles of 0.54.0, so a display size there is a second, louder type scale.
|
|
9
|
+
*
|
|
10
|
+
* WHAT IT READS, in product source outside the site (`isSiteFile`: the `Site…`/`Marketing…` owners, the `(site)` route group,
|
|
11
|
+
* `modules/site…`, or the proposed `fe.site` slot):
|
|
12
|
+
* - `<Text role="display.hero">` (and the other four) with a literal role;
|
|
13
|
+
* - the public class of one of them in a class string (`starci-type-display-hero`, `starci-type-lead`, `starci-type-title-card`, …).
|
|
14
|
+
*
|
|
15
|
+
* It is one general rule, approved with the group. Unlike `no-raw-type-size` it is not a counting rule: no console uses the group yet.
|
|
16
|
+
* Freestyle regions are not exempt: a display role is a Grammar role, not a raw style.
|
|
17
|
+
*/
|
|
18
|
+
/** The site group's roles and their public classes (dots as dashes). */
|
|
19
|
+
export const SITE_ROLES = Object.freeze(["display.hero", "display.section", "display.figure", "lead", "title.card"]);
|
|
20
|
+
const SITE_CLASSES = new Set(SITE_ROLES.map((role) => `starci-type-${role.replace(".", "-")}`));
|
|
21
|
+
const SITE_CLASS = new RegExp(`(?<![\\w-])(${[...SITE_CLASSES].join("|")})(?![\\w-])`);
|
|
22
|
+
const literalRole = (node) => {
|
|
23
|
+
const value = node.value;
|
|
24
|
+
if (value?.type === "Literal" && typeof value.value === "string")
|
|
25
|
+
return value.value;
|
|
26
|
+
if (value?.type === "JSXExpressionContainer" && value.expression.type === "Literal" && typeof value.expression.value === "string")
|
|
27
|
+
return value.expression.value;
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
/** A site role (`display.*`, `lead`, `title.card`) is drawn on the public site only. */
|
|
31
|
+
export const siteTypeRole = defineRule({
|
|
32
|
+
meta: {
|
|
33
|
+
type: "problem",
|
|
34
|
+
docs: { description: "SITE-TYPE-ROLES: display.hero, display.section, display.figure, lead and title.card are the public site's roles, never the console's." },
|
|
35
|
+
schema: [],
|
|
36
|
+
messages: {
|
|
37
|
+
role: "`{{role}}` is a role of the public marketing site (Grammar 0.55.0, the site group), and this file is not the site. A console draws with the ten roles: title.page for a page heading, title.section for a section or card title, figure for a value, body for copy.",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
create(context) {
|
|
41
|
+
const file = context.filename || context.getFilename();
|
|
42
|
+
if (!isProductSource(context) || isSiteFile(context, file))
|
|
43
|
+
return {};
|
|
44
|
+
const reported = new Set();
|
|
45
|
+
const report = (node, role) => {
|
|
46
|
+
if (reported.has(node))
|
|
47
|
+
return;
|
|
48
|
+
reported.add(node);
|
|
49
|
+
context.report({ node: node, messageId: "role", data: { role } });
|
|
50
|
+
};
|
|
51
|
+
const classes = classTextVisitors(context, (node, text) => {
|
|
52
|
+
const found = text === null ? null : SITE_CLASS.exec(text);
|
|
53
|
+
if (found?.[1] !== undefined)
|
|
54
|
+
report(node, found[1]);
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
...classes,
|
|
58
|
+
JSXAttribute(node) {
|
|
59
|
+
classes.JSXAttribute?.(node);
|
|
60
|
+
if (node.name.type !== "JSXIdentifier")
|
|
61
|
+
return;
|
|
62
|
+
if (node.name.name === "role" && node.parent.name.type === "JSXIdentifier" && node.parent.name.name === "Text") {
|
|
63
|
+
const role = literalRole(node);
|
|
64
|
+
if (role !== null && SITE_ROLES.includes(role))
|
|
65
|
+
report(node, role);
|
|
66
|
+
}
|
|
67
|
+
// A class expression the static reader cannot follow (`cn("flex", big && "starci-type-lead")`) is read as its source text.
|
|
68
|
+
if ((node.name.name === "className" || node.name.name === "class") && node.value !== null) {
|
|
69
|
+
const found = SITE_CLASS.exec(context.sourceCode.getText(node.value));
|
|
70
|
+
if (found?.[1] !== undefined)
|
|
71
|
+
report(node, found[1]);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
/** The rules this law contributes to the plugin. */
|
|
78
|
+
export const rules = {
|
|
79
|
+
"site-type-role": siteTypeRole,
|
|
80
|
+
};
|
|
81
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#SITE-TYPE-ROLES");
|
package/dist/table-cell-type.js
CHANGED
|
@@ -16,8 +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
|
+
/** The type roles above the row sizes (0.54.0, and the site group of 0.55.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", "display.hero", "display.section", "display.figure", "lead", "title.card"]);
|
|
21
21
|
const HEADING_TAGS = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
22
22
|
const isFunction = (node) => node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration";
|
|
23
23
|
export const tableCellType = defineRule({
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Avatars in a row are one AvatarGroup
|
|
2
|
+
|
|
3
|
+
Law module: `avatar-row-uses-group.ts`. Finding code: `FE_AVATAR_ROW_USES_GROUP`. Law: `contexts/grammars/contract.yaml#DNA-COMMON-AVATAR-ROW-GROUP`.
|
|
4
|
+
|
|
5
|
+
Owner, 2026-11-22: "với providers phải render AvatarGroup với nhiều hơn 5 thì +2 đồ chứ?? .claude sao k ép tụi này render sáng tạo nhỉ". Avatars that stand side by side, or come out of a list, are one `AvatarGroup`: it overlaps them, shows `max - 1` items and a "+N" tile, rings a broken account (`tone: "danger"`), names every member on hover (`memberNames`), and takes people (`name`, `seed`) and provider or channel marks (`mark`) alike. A hand-made row of `Avatar` has none of that and every app draws its own overflow.
|
|
6
|
+
|
|
7
|
+
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
|
+
|
|
9
|
+
## `starci-grammar/avatar-row-uses-group`
|
|
10
|
+
|
|
11
|
+
In product source, a Grammar `Avatar` with no Grammar `AvatarGroup` among its JSX ancestors in the same file that either shares its parent with another Grammar `Avatar` (message `siblings`; fragments, conditions and `&&` are looked through; reported on each one after the first) or is returned from a `.map()` callback (message `mapped`). An element passed as a JSX attribute value, a single `Avatar`, an `AvatarButton`, and Grammar's own `AvatarGroup` (not product source) are left alone.
|
|
12
|
+
|
|
13
|
+
**Invalid**
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<Stack>{providers.map((p) => <Avatar key={p.id} name={p.name} />)}</Stack>
|
|
17
|
+
|
|
18
|
+
<Stack><Avatar name="Zalo" /><Avatar name="Email" /></Stack>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Valid**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
<AvatarGroup
|
|
25
|
+
label="Providers"
|
|
26
|
+
items={providers.map((p) => ({ id: p.id, name: p.name, mark: { icon: <p.Icon />, color: p.brand }, tone: p.broken ? "danger" : "default" }))}
|
|
27
|
+
max={6}
|
|
28
|
+
overflowLabel={(hidden) => t("moreProviders", { count: hidden })}
|
|
29
|
+
memberNames={(names) => names.join(", ")}
|
|
30
|
+
/>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`max` is the number of slots, "+N" included: seven providers with `max={6}` show five and "+2".
|
|
34
|
+
|
|
35
|
+
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/docs/button-arrow.md
CHANGED
|
@@ -6,11 +6,28 @@ A Button that leads somewhere (a page, a tab, a next step) ends with the Grammar
|
|
|
6
6
|
|
|
7
7
|
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
8
|
|
|
9
|
+
## `starci-grammar/no-typed-arrow`
|
|
10
|
+
|
|
11
|
+
Owner 2026-11-22: "Không dùng ký tự mũi tên gõ tay; hướng đi là icon của Grammar" (no typed arrow characters; a direction is a Grammar icon).
|
|
12
|
+
In product source, an arrow character in rendered text is a finding (`FE_NO_TYPED_ARROW`, message `typed`) on ANY element, not only a Button:
|
|
13
|
+
|
|
14
|
+
- JSX text, a string or template literal rendered as a child, and the branches of a conditional;
|
|
15
|
+
- a string attribute that is rendered text (`label`, `title`, `aria-label`, `description`, ...); `className`, `href`, `src`, `id`, `key`, `role`, `data-*` and event handlers are not text.
|
|
16
|
+
|
|
17
|
+
The characters: the Unicode Arrows block U+2190-U+21FF (→ ← ↑ ↓ ↗ ⇒ …), the dingbat arrows U+2794-U+27BF (➔ ➜ …), the long arrows U+27F0-U+27FF (⟶),
|
|
18
|
+
and ASCII `->`. i18n message values are JSON the lint does not read; contexts/ui/content.md holds them. That gap is accepted for now (owner 2026-11-22, "duyệt hết").
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
<Text>Xem đơn →</Text> // refused
|
|
22
|
+
<Link href="/orders">Xem đơn</Link> // Link draws its own arrow
|
|
23
|
+
<Button href="/runs" endArrow>Xem lượt</Button>
|
|
24
|
+
```
|
|
25
|
+
|
|
9
26
|
## `starci-grammar/button-arrow`
|
|
10
27
|
|
|
11
28
|
A `Button` bound to `@starci/grammar` is a finding when:
|
|
12
29
|
|
|
13
|
-
- its label (children text, a string, a template, the branches of a conditional) states
|
|
30
|
+
- its label (children text, a string, a template, the branches of a conditional) states a pointing mark `›` or `»` (message `label`; an arrow character anywhere is `no-typed-arrow`);
|
|
14
31
|
- its `endContent` is an arrow: an element named `Arrow*` or `ChevronRight*`, or an element whose `source`, `glyph` or `name` is such an identifier or a string naming `arrow`, `chevron-right` or `chevron-end` (message `endContent`);
|
|
15
32
|
- it sets `endArrow` together with `startGlyph` or `startContent` (message `both`; the Button type refuses the pair as well).
|
|
16
33
|
|
|
@@ -28,7 +45,7 @@ A `Button` bound to `@starci/grammar` is a finding when:
|
|
|
28
45
|
|
|
29
46
|
```tsx
|
|
30
47
|
<Button href="/runs" endArrow>View runs</Button>
|
|
31
|
-
<Button
|
|
48
|
+
<Button variant="primary" onPress={send} startGlyph="send">Send</Button>
|
|
32
49
|
```
|
|
33
50
|
|
|
34
51
|
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/docs/page-header.md
CHANGED
|
@@ -15,7 +15,7 @@ A `PageHeader` or `Breadcrumbs` imported from `@starci/grammar` (by name, throug
|
|
|
15
15
|
```tsx
|
|
16
16
|
import { PageHeader } from "@starci/grammar/core"
|
|
17
17
|
|
|
18
|
-
<PageHeader title="Main account" actions={<Button
|
|
18
|
+
<PageHeader title="Main account" actions={<Button>Disconnect</Button>} />
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
**Valid** (`src/components/blocks/ConnectionPage/component.tsx`)
|
|
@@ -25,7 +25,7 @@ import { PageHeader } from "@starci/grammar/core"
|
|
|
25
25
|
header={{
|
|
26
26
|
breadcrumbs: { label: "Breadcrumb", items: trail },
|
|
27
27
|
title: "Main account",
|
|
28
|
-
actions: <Button
|
|
28
|
+
actions: <Button>Disconnect</Button>,
|
|
29
29
|
}}
|
|
30
30
|
>
|
|
31
31
|
<WebhookCard />
|
|
@@ -8,14 +8,14 @@ Every rule below is an error in `coreGrammarConfig`; none can be switched off or
|
|
|
8
8
|
|
|
9
9
|
## `starci-grammar/section-head-action`
|
|
10
10
|
|
|
11
|
-
- A Grammar `Button` inside a `Section`'s `action` prop that is not exactly `
|
|
11
|
+
- A Grammar `Button` inside a `Section`'s `action` prop that is not exactly a border `size="sm"` Button (no `variant`, or `variant="border"`) (message `button`), or that carries an icon prop (`startGlyph`, `startContent`, `endContent`, `icon`; message `icon`).
|
|
12
12
|
- More than one Grammar `Button`, `Link`, `IconButton` or `TextAction` inside that `action` (message `many`).
|
|
13
13
|
|
|
14
14
|
**Invalid**
|
|
15
15
|
|
|
16
16
|
```tsx
|
|
17
|
-
<Section title="Runs" action={<Button
|
|
18
|
-
<Section title="Runs" action={<Button
|
|
17
|
+
<Section title="Runs" action={<Button variant="primary" size="sm" onPress={open}>Open</Button>}>...</Section>
|
|
18
|
+
<Section title="Runs" action={<Button size="sm" startGlyph="plus" onPress={open}>Add</Button>}>...</Section>
|
|
19
19
|
<Section title="Runs" action={<><Link href="/a">A</Link><IconButton label="About" glyph="more" /></>}>...</Section>
|
|
20
20
|
```
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ Every rule below is an error in `coreGrammarConfig`; none can be switched off or
|
|
|
24
24
|
```tsx
|
|
25
25
|
<Section title="Runs" count={3} action={<Link variant="head" href="/runs">All runs</Link>}>...</Section>
|
|
26
26
|
<Section title="Runs" action={<IconButton label="About runs" glyph="more" />}>...</Section>
|
|
27
|
-
<Section title="Provider" count={2} action={<Button
|
|
27
|
+
<Section title="Provider" count={2} action={<Button size="sm" onPress={add}>Add provider</Button>}>...</Section>
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Site type role
|
|
2
|
+
|
|
3
|
+
Law module: `site-type-role.ts`. Finding code: `FE_SITE_TYPE_ROLE`. Knowledge: `runtime/knowledge/ui/presentation/grammar-laws.yaml#SITE-TYPE-ROLES`.
|
|
4
|
+
|
|
5
|
+
Grammar 0.55.0 adds the site group, five type roles for the public marketing site: `display.hero`, `display.section`, `display.figure`, `lead` and `title.card` ([presentation](../../../contexts/ui/presentation.md) "The site group"). The owner approved the group for the public site only, never the console: "3. THÊM NHÓM".
|
|
6
|
+
|
|
7
|
+
## `starci-grammar/site-type-role`
|
|
8
|
+
|
|
9
|
+
Outside the public site, in product source, it reports:
|
|
10
|
+
|
|
11
|
+
- `<Text role="display.hero">`, and the other four roles of the group, with a literal role;
|
|
12
|
+
- the public class of one of them in a class string: `starci-type-display-hero`, `starci-type-display-section`, `starci-type-display-figure`, `starci-type-lead`, `starci-type-title-card`.
|
|
13
|
+
|
|
14
|
+
**The site.** No hfs slot marks the public site yet. The proposed slot is `fe.site`, and a file it owns counts as the site from the day it exists. Until then the rule reads the slots the manifest already has, through `classify`:
|
|
15
|
+
|
|
16
|
+
- an owner of `fe.components` or `fe.feature` named `Site…` or `Marketing…` (`SiteHead`, `SiteBrandPage`);
|
|
17
|
+
- a route file of `fe.route` under the `(site)` or `(marketing)` route group;
|
|
18
|
+
- a capability of `fe.modules` named `site…` or `marketing…` (`modules/site-home`).
|
|
19
|
+
|
|
20
|
+
It runs at error. It is not a counting rule, because no console uses the group.
|
|
21
|
+
|
|
22
|
+
**Invalid** (in `components/blocks/Overview/component.tsx`)
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
<Text role="display.hero">{title}</Text>
|
|
26
|
+
<h3 className="starci-type-title-card">{name}</h3>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Valid** (in `components/composites/SiteHead/classNames.ts`, and the ten roles anywhere)
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
export const DISPLAY = "starci-type-display-hero mt-5 text-balance"
|
|
33
|
+
<Text role="title.page">{title}</Text>
|
|
34
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/eslint-grammar-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
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.
|
|
44
|
+
"@starci/eslint-canon-fe": "~9.22.0",
|
|
45
45
|
"@starci/hfs": "~6.17.0",
|
|
46
46
|
"eslint": ">=9",
|
|
47
47
|
"typescript": ">=5.9"
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
69
69
|
"typescript": "^6.0.3"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
-
"starciSource": "
|
|
71
|
+
"gitHead": "6ce0eb156923148987737412368af3948c2179f1",
|
|
72
|
+
"starciSource": "f2b83d274b02b076a04cd6d741fd2e3b59504780d565b97b5a3efeae4b67cf09"
|
|
73
73
|
}
|
|
@@ -47,9 +47,9 @@ rules:
|
|
|
47
47
|
when: A person or identity needs an avatar
|
|
48
48
|
write: |-
|
|
49
49
|
Pass the uploaded image when one exists; otherwise the selected Grammar's identity renderer uses
|
|
50
|
-
|
|
51
|
-
user or identity id when present and by the name otherwise.
|
|
52
|
-
Agent names follow the same free-text rule and
|
|
50
|
+
two initials (the first letter of the first and of the last word of the name, diacritics kept) in
|
|
51
|
+
DiceBear's Initials style drawn locally, on a colour from the Grammar's tone palette seeded by the user or identity id when present and by the name otherwise.
|
|
52
|
+
Agent names follow the same free-text rule; the avatar stays initials, and the "AI" is the Grammar's small neutral Chip after the name (`isAgent` on the name slot of a row, a card head, a message or a members list), never placed by hand.
|
|
53
53
|
Apps neither declare nor import an avatar-generation
|
|
54
54
|
library and draw no avatar visuals; the family owns the renderer API (the StarCi recipe is
|
|
55
55
|
groupIdentity in its playbook).
|
|
@@ -77,8 +77,6 @@ rules:
|
|
|
77
77
|
- FE_NESTED_VARIANT
|
|
78
78
|
- FE_GRAMMAR_LAYOUT_ONLY
|
|
79
79
|
- FE_BUTTON_INTENT
|
|
80
|
-
- FE_BUTTON_INTENT_REQUIRED
|
|
81
|
-
- FE_DESTRUCTIVE_CONFIRM_IN_DIALOG
|
|
82
80
|
- FE_SINGLE_COMMIT_PER_RENDER
|
|
83
81
|
- FE_NO_COMMIT_IN_COLLECTION_ITEM
|
|
84
82
|
- FE_CONTROL_HEIGHT
|
|
@@ -76,8 +76,8 @@ rules:
|
|
|
76
76
|
The order is language, theme, notifications, account. The language menu makes the current
|
|
77
77
|
choice clear and names each supported language by its autonym. The theme control exposes its
|
|
78
78
|
current setting accessibly. Notifications expose an unread count and open their own region.
|
|
79
|
-
The account control shows the user's uploaded identity or the selected Grammar's
|
|
80
|
-
|
|
79
|
+
The account control shows the user's uploaded identity or the selected Grammar's initials
|
|
80
|
+
fallback: the first letters of the first and last words of the name
|
|
81
81
|
supply its letters, and the user id seeds its colour, falling back to the name when no id exists.
|
|
82
82
|
- id: case-2
|
|
83
83
|
when: The account control opens its menu
|
|
@@ -70,9 +70,15 @@ rules:
|
|
|
70
70
|
- id: case-2
|
|
71
71
|
when: A Button carries a leading icon (`startGlyph`, `startContent`)
|
|
72
72
|
assert: |-
|
|
73
|
-
Only the primary Button (`
|
|
73
|
+
Only the primary Button (`variant="primary"`, the CTA) does. A border or danger Button, a
|
|
74
74
|
suggestion pill and a row action are text only. The arrow (`endArrow`) is not an icon under this rule, so any intent
|
|
75
75
|
may lead somewhere; `IconButton` is unaffected.
|
|
76
|
+
- id: case-3
|
|
77
|
+
when: Any rendered text (JSX text, a literal child, a text attribute) would show a direction
|
|
78
|
+
assert: |-
|
|
79
|
+
No typed arrow character (U+2190-U+21FF, U+2794-U+27BF, U+27F0-U+27FF, `->`) appears in it (owner 2026-11-22: "Không dùng ký tự
|
|
80
|
+
mũi tên gõ tay; hướng đi là icon của Grammar"). Direction is `Button endArrow`, `Link`'s own arrow or the Grammar arrow or chevron
|
|
81
|
+
icon (lint `no-typed-arrow`).
|
|
76
82
|
- id: LAYOUT-TWO-AXIS
|
|
77
83
|
title: A report page stacks its cards in one direction
|
|
78
84
|
governs: Card surfaces placed side by side.
|
|
@@ -207,6 +213,16 @@ rules:
|
|
|
207
213
|
assert: |-
|
|
208
214
|
The section has exactly one Label (14 / 500, 12px above its content). Each group inside it is a Section or SurfaceCard with `sublabel` (12 / 500 muted, 8px above its card),
|
|
209
215
|
never a second `title` / `label`; groups stand 24px apart. A Section or SurfaceCard with `sublabel` and a Label together is refused by the types.
|
|
216
|
+
- id: AVATAR-ROW-GROUP
|
|
217
|
+
title: Avatars in a row or from a list are one AvatarGroup
|
|
218
|
+
governs: Grammar `Avatar` elements that stand side by side or are returned from a `.map()` (contract DNA-COMMON-AVATAR-ROW-GROUP; owner, 2026-11-22).
|
|
219
|
+
cases:
|
|
220
|
+
- id: case-1
|
|
221
|
+
when: Two or more `Avatar` elements are siblings, or an `Avatar` is returned from a `.map()`, with no `AvatarGroup` around them
|
|
222
|
+
assert: |-
|
|
223
|
+
They are refused. The owner (2026-11-22): "với providers phải render AvatarGroup với nhiều hơn 5 thì +2 đồ chứ?? .claude sao k ép tụi này render sáng tạo nhỉ".
|
|
224
|
+
A row of people, providers or channels is `<AvatarGroup items max>`: it overlaps the items, shows `max - 1` and a "+N" tile, rings a broken account
|
|
225
|
+
(`tone: "danger"`) and lists every name on hover (`memberNames`); a person is `name` and `seed`, a provider or channel is a `mark`.
|
|
210
226
|
- id: SECTION-HEAD-ACTION
|
|
211
227
|
title: A section head is one row with at most one thing at its end
|
|
212
228
|
governs: The head of a Grammar Section.
|
|
@@ -216,7 +232,7 @@ rules:
|
|
|
216
232
|
assert: |-
|
|
217
233
|
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
|
|
218
234
|
Link variant="head" (the label then an arrow that slides about 3px on hover), an info IconButton, or (0.37.25) a neutral small text Button
|
|
219
|
-
(
|
|
235
|
+
(border, size sm, no icon: "Add provider"). A primary or commit Button, another size or an icon Button is refused, and so are two commands. There is no description under the label: it is a caption (12, muted) below the card or list.
|
|
220
236
|
- id: TAB-COUNT-CHIP
|
|
221
237
|
title: A tab count is a 12px chip, grey unless it is work waiting for the owner
|
|
222
238
|
governs: The count on a Grammar tab, page layers 1 and 2 and filter tabs.
|
|
@@ -284,6 +300,16 @@ rules:
|
|
|
284
300
|
title.section, label.item, body, label.field, label.group, caption, badge, code; dots as dashes in the class). A Tailwind
|
|
285
301
|
text-size utility, a `fontSize` or a CSS `font-size` in app source is reported (`starci-grammar/no-raw-type-size`, a
|
|
286
302
|
counting rule at warn until both apps migrate, then blocking).
|
|
303
|
+
- id: SITE-TYPE-ROLES
|
|
304
|
+
title: The site group is the public site's
|
|
305
|
+
governs: Where the five site type roles are drawn.
|
|
306
|
+
cases:
|
|
307
|
+
- id: case-1
|
|
308
|
+
when: A file draws display.hero, display.section, display.figure, lead or title.card
|
|
309
|
+
assert: |-
|
|
310
|
+
The file is the public marketing site (owner 2026-11-21, "3. THÊM NHÓM"): a `Site…` or `Marketing…` owner of fe.components or
|
|
311
|
+
fe.feature, a route under the `(site)` or `(marketing)` group, a `site…` capability of fe.modules, or the proposed fe.site slot.
|
|
312
|
+
In any other file `<Text role>` or the class `starci-type-<role>` of the group is refused (`starci-grammar/site-type-role`).
|
|
287
313
|
- id: NO-RAW-SCROLL
|
|
288
314
|
title: Grammar never shows scrollbars
|
|
289
315
|
governs: Scroll areas an app draws.
|
|
@@ -294,3 +320,14 @@ rules:
|
|
|
294
320
|
The scroll area is a Grammar scroller (`VerticalScrollRegion`, `HorizontalScrollRegion`, `PaneSection` with `scroll`):
|
|
295
321
|
the scrollbar is hidden, a fading edge (ScrollShadow behaviour) shows where content continues, and wheel, touch and
|
|
296
322
|
keyboard scrolling keep working. An app element with an `overflow-y-auto` or `overflow-auto` class is refused.
|
|
323
|
+
- id: SPACING-ROLES
|
|
324
|
+
title: Spacing is a Grammar role
|
|
325
|
+
governs: The gaps, paddings and margins an app writes.
|
|
326
|
+
cases:
|
|
327
|
+
- id: case-1
|
|
328
|
+
when: An app separates two things it places, or pads content inside a box
|
|
329
|
+
assert: |-
|
|
330
|
+
The distance is a role the Grammar resolves (owner 2026-11-23; contexts/ui/scale.md "The spacing roles"): identity 4, inline 8,
|
|
331
|
+
row 12, section 24 and region 32 on a Stack, Cluster or Grid `gap`, and the inset of the Grammar box that holds the content.
|
|
332
|
+
A spacing utility in a class string is `starci-fe/no-spacing-utility` (R350); a gap, padding or margin key in a JSX `style`
|
|
333
|
+
is reported (`starci-grammar/no-raw-spacing-style`, a counting rule at warn until both apps migrate, then blocking).
|