@starci/eslint-grammar-core 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +1 -1
- package/dist/button-arrow.d.ts +7 -0
- package/dist/button-arrow.js +50 -1
- package/dist/index.js +6 -0
- package/dist/layout-two-axis.d.ts +7 -0
- package/dist/layout-two-axis.js +70 -0
- package/dist/lib/why.js +25 -0
- package/dist/link-look.d.ts +7 -0
- package/dist/link-look.js +58 -0
- package/dist/no-raw-scroll.d.ts +7 -0
- package/dist/no-raw-scroll.js +48 -0
- package/dist/tabs.d.ts +6 -0
- package/dist/tabs.js +45 -0
- package/docs/button-arrow.md +28 -3
- package/docs/layout-two-axis.md +32 -0
- package/docs/no-raw-scroll.md +28 -0
- package/package.json +3 -3
- package/runtime/knowledge/ui/presentation/grammar-laws.yaml +50 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.34.0 - 2026-11-09
|
|
4
|
+
|
|
5
|
+
- Added: `tabs-in-well` (`FE_TABS_IN_WELL`, TABS-IN-WELL, error): an underline `Tabs` written in the body of a `Page`, `Pane` or `PaneSection` is refused; the second tab layer is
|
|
6
|
+
`Page header.subTabs`, in the white header band.
|
|
7
|
+
- Added: `link-look` (`FE_LINK_LOOK`, LINK-LOOK, error): a `Link` with a `size` prop or a size, underline or decoration class is refused.
|
|
8
|
+
- Changed: `button-icon-primary-only` also refuses a start icon on a `size="sm"` Button, the primary included.
|
|
9
|
+
- Changed: released with the Grammar family at 0.34.0.
|
|
10
|
+
|
|
11
|
+
## 0.33.0 - 2026-11-09
|
|
12
|
+
|
|
13
|
+
- Added: `no-raw-scroll` (`FE_NO_RAW_SCROLL`, NO-RAW-SCROLL, error): an app element whose `className` holds `overflow-auto`, `overflow-y-auto`,
|
|
14
|
+
`overflow-x-auto` or an `overflow-*-scroll` class is refused; NIVO never shows scrollbars, so a scroll area is a Grammar scroller
|
|
15
|
+
(`VerticalScrollRegion`, `HorizontalScrollRegion`) or `PaneSection scroll`. `docs/no-raw-scroll.md`.
|
|
16
|
+
- Changed: released with the Grammar family at 0.33.0.
|
|
17
|
+
- Added: `button-icon-primary-only` (`FE_BUTTON_ICON_PRIMARY_ONLY`, BUTTON-ARROW case-2, error): only a `Button` whose `intent` is the literal
|
|
18
|
+
`"commit"` (the primary, the CTA) may set `startGlyph` or `startContent`; a neutral, alternative, dismiss or destructive Button, a Button
|
|
19
|
+
with no intent and one with a computed intent are refused. `endArrow` is not an icon under the rule and `IconButton` is not judged. The
|
|
20
|
+
Button type (Grammar 0.33.0) refuses the literal cases as well. `docs/button-arrow.md`.
|
|
21
|
+
- Added: `layout-two-axis` (`FE_LAYOUT_TWO_AXIS`, LAYOUT-TWO-AXIS, error): a `Grid` or `Cluster` that puts a `SurfaceCard` beside a `Stack` of `SurfaceCard`s,
|
|
22
|
+
or `SurfaceCard`s of different `kind` side by side, is refused (a report page stacks cards in one direction). `Grid kind="main-rail"` is not judged. `docs/layout-two-axis.md`.
|
|
23
|
+
- Changed: released with the Grammar family at 0.33.0.
|
|
24
|
+
|
|
3
25
|
## 0.32.0 - 2026-11-09
|
|
4
26
|
|
|
5
27
|
- Versioned with Grammar 0.32.0 (every surface on the page ground is a card); no rule changes.
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ Family helpers and the generated runtime closure belong to this package.
|
|
|
19
19
|
|
|
20
20
|
The rule IDs remain stable when their namespace moves. Laws cover the fixed app shell and navbar,
|
|
21
21
|
Grammar-owned structural elements, glyphs and icon sizes, destructive menu entries, status inks,
|
|
22
|
-
chip labels that start uppercase, a Button that leads somewhere ending with `endArrow` (no typed or icon arrow), row type sizes in a DataTable cell or ListRow, one size per Cluster line, a row title that is plain text when the row opens (`button-arrow`, `table-cell-type`, `same-line-size`, `row-title-link`), generated art rendered through `Mascot` or `MediaFrame` with every `Mascot` naming its asset slot, the page head composed by `PageHeader`, the pane grid (a `PaneGrid` of `Pane`s, a `Pane` of `PaneSection`s that carry no padding of their own, mounted as `Page chrome="panes"`), the route page as one `Page` with its tabs in the header, heading and token scales, vendor ownership and slot-status composition, and a surface nested in another surface left subordinate (no forced `depth="top"`), and a Freestyle region that names its reason (its raw elements are exempt from the paint and raw-element laws). The pill (`Tabs appearance="primary"`) is only the `switch` header zone of a card, and a page stacks two underline `Tabs` layers at most (`tabs-switch-zone`, `tabs-depth`; `docs/tabs.md`). Each rule's metadata cites
|
|
22
|
+
chip labels that start uppercase, a Button that leads somewhere ending with `endArrow` (no typed or icon arrow), a leading icon only on the primary Button (`button-arrow`, `button-icon-primary-only`), report cards in one axis (`layout-two-axis`), no app-made scroll area (`no-raw-scroll`), underline tabs only in the header band (`tabs-in-well`), a Link that takes its look from the line (`link-look`), row type sizes in a DataTable cell or ListRow, one size per Cluster line, a row title that is plain text when the row opens (`button-arrow`, `table-cell-type`, `same-line-size`, `row-title-link`), generated art rendered through `Mascot` or `MediaFrame` with every `Mascot` naming its asset slot, the page head composed by `PageHeader`, the pane grid (a `PaneGrid` of `Pane`s, a `Pane` of `PaneSection`s that carry no padding of their own, mounted as `Page chrome="panes"`), the route page as one `Page` with its tabs in the header, heading and token scales, vendor ownership and slot-status composition, and a surface nested in another surface left subordinate (no forced `depth="top"`), and a Freestyle region that names its reason (its raw elements are exempt from the paint and raw-element laws). The pill (`Tabs appearance="primary"`) is only the `switch` header zone of a card, and a page stacks two underline `Tabs` layers at most (`tabs-switch-zone`, `tabs-depth`; `docs/tabs.md`). Each rule's metadata cites
|
|
23
23
|
its behavioral knowledge source and the governing ownership test. The R318 surface composition
|
|
24
24
|
rules (nested control variants, panel-list alignment, layout-only CSS) stay in the universal canon.
|
|
25
25
|
`suggestion-buttons` (suggestions and quick replies are a Cluster of neutral sm Buttons, never a Link row, ChoiceChips or Chip that sends; `docs/suggestion-buttons.md`).
|
package/dist/button-arrow.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
2
|
/** A Button leads somewhere with `endArrow` and does something with `startGlyph`; no typed arrow, no arrow icon, never both. */
|
|
3
3
|
export declare const buttonArrow: Rule.RuleModule;
|
|
4
|
+
/**
|
|
5
|
+
* The button-icon law (owner, 2026-11-09): only a PRIMARY Button (`intent="commit"`) carries a leading icon. The Button type already
|
|
6
|
+
* refuses `startGlyph` / `startContent` on a literal non-primary intent; this reads what a type cannot see: a Button with no `intent`
|
|
7
|
+
* (it renders the secondary step) and an `intent` computed from a variable, a conditional or a spread. A start icon is accepted only
|
|
8
|
+
* when `intent` is the literal `"commit"`. The arrow (`endArrow`) is not an icon under this law, and `IconButton` is not judged.
|
|
9
|
+
*/
|
|
10
|
+
export declare const buttonIconPrimaryOnly: Rule.RuleModule;
|
|
4
11
|
/** The rules this law contributes to the plugin. */
|
|
5
12
|
export declare const rules: Record<string, Rule.RuleModule>;
|
|
6
13
|
/** Every rule of this law is an error. */
|
package/dist/button-arrow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
2
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
|
-
import { attributeOf, descendants, elementOf, grammarBindings } from "./lib/row-context.js";
|
|
3
|
+
import { attributeOf, descendants, elementOf, grammarBindings, literalAttribute } from "./lib/row-context.js";
|
|
4
4
|
/**
|
|
5
5
|
* The button arrow law (`FE_BUTTON_ARROW`): a Button that leads somewhere ends with `endArrow`; a Button that does something
|
|
6
6
|
* starts with a `startGlyph`. The arrow of a destination is the Grammar's own (it slides toward the reading end on hover and is
|
|
@@ -11,6 +11,7 @@ import { attributeOf, descendants, elementOf, grammarBindings } from "./lib/row-
|
|
|
11
11
|
* - an `endContent` that is an arrow: an element named `Arrow*` or `ChevronRight*`, or any element whose `source` / `glyph` / `name`
|
|
12
12
|
* is such an identifier or a string that names `arrow`, `chevron-right` or `chevron-end`;
|
|
13
13
|
* - `endArrow` together with `startGlyph` or `startContent` (the Button type refuses it as well).
|
|
14
|
+
* The button-icon law (`button-icon-primary-only`) lives beside it: only a primary Button (`intent="commit"`) carries `startGlyph` or `startContent`.
|
|
14
15
|
* `Button` takes the label as its children only, so no string label prop exists to read. `IconButton` has no label to type an arrow
|
|
15
16
|
* in and no `endArrow`; `TextAction` takes `endContent` but not `endArrow`, so neither is judged.
|
|
16
17
|
*/
|
|
@@ -137,9 +138,57 @@ export const buttonArrow = defineRule({
|
|
|
137
138
|
};
|
|
138
139
|
},
|
|
139
140
|
});
|
|
141
|
+
/** The one intent that is the CTA: the primary Button. */
|
|
142
|
+
const PRIMARY_INTENT = "commit";
|
|
143
|
+
/**
|
|
144
|
+
* The button-icon law (owner, 2026-11-09): only a PRIMARY Button (`intent="commit"`) carries a leading icon. The Button type already
|
|
145
|
+
* refuses `startGlyph` / `startContent` on a literal non-primary intent; this reads what a type cannot see: a Button with no `intent`
|
|
146
|
+
* (it renders the secondary step) and an `intent` computed from a variable, a conditional or a spread. A start icon is accepted only
|
|
147
|
+
* when `intent` is the literal `"commit"`. The arrow (`endArrow`) is not an icon under this law, and `IconButton` is not judged.
|
|
148
|
+
*/
|
|
149
|
+
export const buttonIconPrimaryOnly = defineRule({
|
|
150
|
+
meta: {
|
|
151
|
+
type: "problem",
|
|
152
|
+
docs: { description: "FE_BUTTON_ICON_PRIMARY_ONLY: only a primary Button (`intent=\"commit\"`) carries a leading icon (`startGlyph`, `startContent`)." },
|
|
153
|
+
schema: [],
|
|
154
|
+
messages: {
|
|
155
|
+
icon: "The Button sets `{{start}}` but is not primary. Only the primary Button (`intent=\"commit\"`, the CTA) carries a leading icon; a neutral, alternative, dismiss or destructive Button, a suggestion pill and a row action are text only. Remove `{{start}}`, or make this the region's one primary. A Button that leads somewhere keeps `endArrow`.",
|
|
156
|
+
small: "The Button sets `{{start}}` at size `sm`. A small Button never carries an icon, not even the primary: a leading icon is for the primary at `md` or `lg`. Remove `{{start}}`, or make the Button `md`.",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
create(context) {
|
|
160
|
+
if (!isProductSource(context))
|
|
161
|
+
return {};
|
|
162
|
+
let bound = new Map();
|
|
163
|
+
return {
|
|
164
|
+
Program(program) {
|
|
165
|
+
bound = grammarBindings(program);
|
|
166
|
+
},
|
|
167
|
+
JSXOpeningElement(opening) {
|
|
168
|
+
if (elementOf(opening, bound).grammar !== "Button")
|
|
169
|
+
return;
|
|
170
|
+
const isPrimary = literalAttribute(opening, "intent") === PRIMARY_INTENT;
|
|
171
|
+
const isSmall = literalAttribute(opening, "size") === "sm";
|
|
172
|
+
if (isPrimary && !isSmall)
|
|
173
|
+
return;
|
|
174
|
+
for (const start of ["startGlyph", "startContent"]) {
|
|
175
|
+
const attribute = attributeOf(opening, start);
|
|
176
|
+
if (attribute === null)
|
|
177
|
+
continue;
|
|
178
|
+
const value = attribute.value;
|
|
179
|
+
// `startContent={undefined}` / `{null}` states no icon.
|
|
180
|
+
if (value?.type === "JSXExpressionContainer" && (value.expression.type === "JSXEmptyExpression" || (value.expression.type === "Identifier" && value.expression.name === "undefined") || (value.expression.type === "Literal" && value.expression.value === null)))
|
|
181
|
+
continue;
|
|
182
|
+
context.report({ node: attribute, messageId: isPrimary ? "small" : "icon", data: { start } });
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
});
|
|
140
188
|
/** The rules this law contributes to the plugin. */
|
|
141
189
|
export const rules = {
|
|
142
190
|
"button-arrow": buttonArrow,
|
|
191
|
+
"button-icon-primary-only": buttonIconPrimaryOnly,
|
|
143
192
|
};
|
|
144
193
|
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#BUTTON-ARROW");
|
|
145
194
|
/** Every rule of this law is an error. */
|
package/dist/index.js
CHANGED
|
@@ -10,8 +10,11 @@ import { rules as freestyleRules } from "./freestyle.js";
|
|
|
10
10
|
import { rules as gapProximityRules } from "./gap-proximity.js";
|
|
11
11
|
import { rules as grammarBoundaryRules } from "./grammar-boundary.js";
|
|
12
12
|
import { rules as iconRules } from "./icon.js";
|
|
13
|
+
import { rules as layoutTwoAxisRules } from "./layout-two-axis.js";
|
|
14
|
+
import { rules as linkLookRules } from "./link-look.js";
|
|
13
15
|
import { rules as mascotRules } from "./mascot.js";
|
|
14
16
|
import { rules as menuEntriesRules } from "./menu-entries.js";
|
|
17
|
+
import { rules as noRawScrollRules } from "./no-raw-scroll.js";
|
|
15
18
|
import { rules as pageRules } from "./page.js";
|
|
16
19
|
import { rules as pageBreadcrumbsRules } from "./page-breadcrumbs.js";
|
|
17
20
|
import { rules as pageHeaderRules } from "./page-header.js";
|
|
@@ -41,8 +44,11 @@ const CONTRIBUTIONS = [
|
|
|
41
44
|
{ law: "gap-proximity", rules: gapProximityRules },
|
|
42
45
|
{ law: "grammar-boundary", rules: grammarBoundaryRules },
|
|
43
46
|
{ law: "icon", rules: iconRules },
|
|
47
|
+
{ law: "layout-two-axis", rules: layoutTwoAxisRules },
|
|
48
|
+
{ law: "link-look", rules: linkLookRules },
|
|
44
49
|
{ law: "mascot", rules: mascotRules },
|
|
45
50
|
{ law: "menu-entries", rules: menuEntriesRules },
|
|
51
|
+
{ law: "no-raw-scroll", rules: noRawScrollRules },
|
|
46
52
|
{ law: "page", rules: pageRules },
|
|
47
53
|
{ law: "page-breadcrumbs", rules: pageBreadcrumbsRules },
|
|
48
54
|
{ law: "page-header", rules: pageHeaderRules },
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** Cards stand side by side only when they share a role and height; a card beside a column of cards is two axes. */
|
|
3
|
+
export declare const layoutTwoAxis: Rule.RuleModule;
|
|
4
|
+
/** The rules this law contributes to the plugin. */
|
|
5
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
6
|
+
/** Every rule of this law is an error. */
|
|
7
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { elementNameOf, grammarName, hasSpread, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
|
|
3
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* The two-axis layout law (owner, 2026-11-09, LAYOUT-5): a REPORT page (`Page` standard: the pink well) stacks its card surfaces in ONE
|
|
6
|
+
* direction, a vertical column 24 apart. Cards stand side by side only as siblings of the same role and height (figure cells, short
|
|
7
|
+
* equal cards). A card beside a column of other cards makes two axes in one well, and two cards of different roles side by side
|
|
8
|
+
* are unequal in height. A page that needs a persistent selection column or a full-height chat or editor is a WORKSPACE page
|
|
9
|
+
* (`Page chrome="panes"`, side panes are white surfaces at full height, never cards).
|
|
10
|
+
*
|
|
11
|
+
* WHAT IT READS. A Grammar `Grid` or `Cluster` (imported from `@starci/grammar`) and its rendered children (fragments, `cond && x`,
|
|
12
|
+
* ternaries and `.map` looked through):
|
|
13
|
+
* - `beside`: a `SurfaceCard` child together with a `Stack` child that holds two or more `SurfaceCard`s;
|
|
14
|
+
* - `unequal`: two or more `SurfaceCard` children of different `kind` (an absent `kind` is `body`).
|
|
15
|
+
*
|
|
16
|
+
* WHAT IT LEAVES ALONE. `Grid kind="main-rail"` (a task and its subordinate support), a `SurfaceCard` with a JSX spread (its kind may
|
|
17
|
+
* arrive), a card repeated by `.map` (one element, one role), a `Stack` of cards on its own (that is the column), and non-product source.
|
|
18
|
+
*
|
|
19
|
+
* WHERE IT APPLIES. Product source (`isProductSource`).
|
|
20
|
+
*/
|
|
21
|
+
/** The containers whose children stand side by side. */
|
|
22
|
+
const ROW_CONTAINERS = new Set(["Grid", "Cluster"]);
|
|
23
|
+
/** The `SurfaceCard` elements among a list of rendered nodes. */
|
|
24
|
+
const cardsOf = (context, nodes) => nodes.filter((node) => node.type === "JSXElement" && grammarName(context, node.openingElement) === "SurfaceCard");
|
|
25
|
+
/** True for a Grammar `Stack` that holds two or more cards. */
|
|
26
|
+
const isColumnOfCards = (context, node) => node.type === "JSXElement" && grammarName(context, node.openingElement) === "Stack" && cardsOf(context, renderedChildren(node.children)).length >= 2;
|
|
27
|
+
/** Cards stand side by side only when they share a role and height; a card beside a column of cards is two axes. */
|
|
28
|
+
export const layoutTwoAxis = defineRule({
|
|
29
|
+
meta: {
|
|
30
|
+
type: "problem",
|
|
31
|
+
docs: { description: "LAYOUT-5: a report page stacks cards in one direction; a card beside a column of cards, or cards of different kinds side by side, is two axes." },
|
|
32
|
+
schema: [],
|
|
33
|
+
messages: {
|
|
34
|
+
beside: "A card stands beside a column of cards ({{where}}): two axes in one well. A report page stacks its cards in one vertical column (24 apart); side by side is only for sibling cards of the same role and height. If the page needs a persistent selection column or a full-height chat or editor, it is a workspace page: `Page chrome=\"panes\"`, side panes are white surfaces, never cards.",
|
|
35
|
+
unequal: "Cards of different kinds ({{kinds}}) stand side by side in a {{where}}: they differ in role and height. Stack them in one column, or keep only sibling cards of one role in the row (figure cells, short equal cards).",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
create(context) {
|
|
39
|
+
if (!isProductSource(context))
|
|
40
|
+
return {};
|
|
41
|
+
return {
|
|
42
|
+
JSXElement(element) {
|
|
43
|
+
const opening = element.openingElement;
|
|
44
|
+
const where = grammarName(context, opening);
|
|
45
|
+
if (where === null || !ROW_CONTAINERS.has(where))
|
|
46
|
+
return;
|
|
47
|
+
if (where === "Grid" && stringProp(opening, "kind") === "main-rail")
|
|
48
|
+
return;
|
|
49
|
+
const children = renderedChildren(element.children);
|
|
50
|
+
const cards = cardsOf(context, children);
|
|
51
|
+
if (cards.length > 0 && children.some((child) => isColumnOfCards(context, child))) {
|
|
52
|
+
context.report({ node: opening, messageId: "beside", data: { where } });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const sure = cards.filter((card) => !hasSpread(card.openingElement));
|
|
56
|
+
const kinds = [...new Set(sure.map((card) => stringProp(card.openingElement, "kind") ?? "body"))];
|
|
57
|
+
if (sure.length >= 2 && kinds.length > 1 && children.every((child) => elementNameOf(child) !== null)) {
|
|
58
|
+
context.report({ node: opening, messageId: "unequal", data: { where, kinds: kinds.join(", ") } });
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
/** The rules this law contributes to the plugin. */
|
|
65
|
+
export const rules = {
|
|
66
|
+
"layout-two-axis": layoutTwoAxis,
|
|
67
|
+
};
|
|
68
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#LAYOUT-TWO-AXIS");
|
|
69
|
+
/** Every rule of this law is an error. */
|
|
70
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
package/dist/lib/why.js
CHANGED
|
@@ -19,6 +19,16 @@ export const why = {
|
|
|
19
19
|
en: "Underline `Tabs` in `<file>` stack past two layers.",
|
|
20
20
|
fix: "A page has the page tabs (`Page header.tabs`) and at most one region set in a tab's panel. Fold a third level into a `switch` zone, a filter zone of a card, a list, or a drawer.",
|
|
21
21
|
},
|
|
22
|
+
"tabs-in-well": {
|
|
23
|
+
code: "FE_TABS_IN_WELL",
|
|
24
|
+
en: "An underline `Tabs` in `<file>` is written in the body of a `Page`, `Pane` or `PaneSection`: on the pink well or in a pane.",
|
|
25
|
+
fix: "The second tab layer sits in the white header band under the page tabs: `Page header={{ tabs, subTabs }}`, on its own full-width separator and flush with the band's left inset. Or make the views a `switch` zone or a filter zone of a card.",
|
|
26
|
+
},
|
|
27
|
+
"link-look": {
|
|
28
|
+
code: "FE_LINK_LOOK",
|
|
29
|
+
en: "A `Link` in `<file>` sets a `size` or a size, underline or decoration class.",
|
|
30
|
+
fix: "A Link is HeroUI's own link: the primary colour, the underline on hover only, the anchor icon at the end, and the size of the line it stands in (14 in a body, 12 in meta). Remove the prop or class; wrap the link in a `Text` of the size you want.",
|
|
31
|
+
},
|
|
22
32
|
"no-primary-tabs-misuse": {
|
|
23
33
|
code: "FE_GROUPED_CHOICE_CONTROL",
|
|
24
34
|
en: "Primary `Tabs` (or a `switch` header zone) in `<file>` hold a count, an href, an attention mark, one item or more than four items.",
|
|
@@ -174,6 +184,21 @@ export const why = {
|
|
|
174
184
|
en: "A Button in `<file>` types an arrow in its label, passes an arrow icon as `endContent`, or sets `endArrow` together with `startGlyph` or `startContent`.",
|
|
175
185
|
fix: "A Button that leads somewhere takes `endArrow` (the Grammar arrow slides on hover and is mirrored in RTL); one that does something takes `startGlyph`; never both.",
|
|
176
186
|
},
|
|
187
|
+
"button-icon-primary-only": {
|
|
188
|
+
code: "FE_BUTTON_ICON_PRIMARY_ONLY",
|
|
189
|
+
en: "A Button in `<file>` sets `startGlyph` or `startContent` but is not the primary (`intent=\"commit\"`): it has another intent, none, or one computed; or it is `size=\"sm\"`, which never carries an icon, not even the primary.",
|
|
190
|
+
fix: "Only the primary Button (the CTA) carries a leading icon. Remove the icon from a neutral, alternative, dismiss or destructive Button, a suggestion pill, a row action or any `size=\"sm\"` Button (the primary carries an icon at `md` or `lg` only); a Button that leads somewhere keeps `endArrow`.",
|
|
191
|
+
},
|
|
192
|
+
"layout-two-axis": {
|
|
193
|
+
code: "FE_LAYOUT_TWO_AXIS",
|
|
194
|
+
en: "A Grid or Cluster in `<file>` puts a SurfaceCard beside a Stack of SurfaceCards, or two SurfaceCards of different kinds side by side.",
|
|
195
|
+
fix: "A report page stacks its cards in one vertical column (24 apart); side by side is only for sibling cards of one role and height. A page with a persistent selection column or a full-height chat or editor is a workspace: `Page chrome=\"panes\"`, whose side panes are white surfaces, never cards.",
|
|
196
|
+
},
|
|
197
|
+
"no-raw-scroll": {
|
|
198
|
+
code: "FE_NO_RAW_SCROLL",
|
|
199
|
+
en: "An element in `<file>` makes its own scroll area with an `overflow-auto`, `overflow-y-auto` or `overflow-scroll` class.",
|
|
200
|
+
fix: "NIVO never shows scrollbars. Use the Grammar scroller (`VerticalScrollRegion`, `HorizontalScrollRegion`) or `PaneSection scroll`: they fade the edge where content continues, hide the bar and keep wheel and keyboard scrolling.",
|
|
201
|
+
},
|
|
177
202
|
"table-cell-type": {
|
|
178
203
|
code: "FE_TABLE_CELL_TYPE",
|
|
179
204
|
en: "A DataTable cell or ListRow title/description in `<file>` draws a Text above 14 (`size=\"lg\"`, `\"xl\"`, `\"figure\"`), a Heading, a Label or an h1-h6.",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** A Grammar Link takes its size from the line and its underline from the vendor: no size prop, no size, underline or decoration class. */
|
|
3
|
+
export declare const linkLook: Rule.RuleModule;
|
|
4
|
+
/** The rules this law contributes to the plugin. */
|
|
5
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
6
|
+
/** Every rule of this law is an error. */
|
|
7
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { attributeOf, grammarName } from "./lib/grammar-jsx.js";
|
|
3
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* THE LINK LOOK (owner, 2026-11-09, LINK-LOOK). Grammar's `Link` is HeroUI v3's own link: the primary colour, the underline on hover only
|
|
6
|
+
* and the anchor icon at the end of its label. Its type size and leading are INHERITED from the line it stands in (14 in a body, 12 in
|
|
7
|
+
* meta or caption text). An app never restyles it.
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT READS. A Grammar `Link` (imported from `@starci/grammar`) in product source with:
|
|
10
|
+
* - a `size` prop;
|
|
11
|
+
* - a `className` / `class` attribute that holds a text-size utility (`text-sm`, `text-[13px]`), a weight or leading utility is left
|
|
12
|
+
* to the raw-class laws, or an `underline` / `no-underline` / `decoration-*` utility.
|
|
13
|
+
*
|
|
14
|
+
* WHAT IT LEAVES ALONE. A `Link` with neither, other elements, and non-product source.
|
|
15
|
+
*/
|
|
16
|
+
const TEXT_SIZE = /(?<![\w-])(?:[\w[\]&>*:-]+:)?text-(?:xs|sm|base|md|lg|[2-9]?xl|\[[^\]]+\])(?![\w-])/;
|
|
17
|
+
const UNDERLINE = /(?<![\w-])(?:[\w[\]&>*:-]+:)?(?:underline|no-underline|decoration-[\w[\]./-]+|underline-offset-[\w[\]./-]+)(?![\w-])/;
|
|
18
|
+
/** A Grammar Link takes its size from the line and its underline from the vendor: no size prop, no size, underline or decoration class. */
|
|
19
|
+
export const linkLook = defineRule({
|
|
20
|
+
meta: {
|
|
21
|
+
type: "problem",
|
|
22
|
+
docs: { description: "LINK-LOOK: a Link inherits its size from the line and keeps HeroUI's hover underline and anchor icon; no size prop, size class or underline class." },
|
|
23
|
+
schema: [],
|
|
24
|
+
messages: {
|
|
25
|
+
size: "A `Link` takes no `size`: it inherits the type size of the line it stands in (14 in a body, 12 in meta or caption text). Remove the prop and put the link in a `Text` of the size you want.",
|
|
26
|
+
class: "A `Link` is HeroUI's own link: the primary colour, the underline on hover only, the anchor icon at the end, the size of the line around it. Remove `{{token}}` from its class; the app never restyles a Link.",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
create(context) {
|
|
30
|
+
if (!isProductSource(context))
|
|
31
|
+
return {};
|
|
32
|
+
return {
|
|
33
|
+
JSXOpeningElement(opening) {
|
|
34
|
+
if (grammarName(context, opening) !== "Link")
|
|
35
|
+
return;
|
|
36
|
+
const size = attributeOf(opening, "size");
|
|
37
|
+
if (size !== undefined)
|
|
38
|
+
context.report({ node: size, messageId: "size" });
|
|
39
|
+
for (const name of ["className", "class"]) {
|
|
40
|
+
const attribute = attributeOf(opening, name);
|
|
41
|
+
if (attribute === undefined || attribute.value === null)
|
|
42
|
+
continue;
|
|
43
|
+
const text = context.sourceCode.getText(attribute.value);
|
|
44
|
+
const found = TEXT_SIZE.exec(text) ?? UNDERLINE.exec(text);
|
|
45
|
+
if (found !== null)
|
|
46
|
+
context.report({ node: attribute, messageId: "class", data: { token: found[0].replace(/^.*:/, "") } });
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
/** The rules this law contributes to the plugin. */
|
|
53
|
+
export const rules = {
|
|
54
|
+
"link-look": linkLook,
|
|
55
|
+
};
|
|
56
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#LINK-LOOK");
|
|
57
|
+
/** Every rule of this law is an error. */
|
|
58
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** An app scroll area is drawn by Grammar's scroller, never by an `overflow-*-auto` class on the app's own element. */
|
|
3
|
+
export declare const noRawScroll: Rule.RuleModule;
|
|
4
|
+
/** The rules this law contributes to the plugin. */
|
|
5
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
6
|
+
/** Every rule of this law is an error. */
|
|
7
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
|
+
/**
|
|
4
|
+
* NIVO never shows scrollbars (owner, 2026-11-09, OVERFLOW-6). Every scroll area is drawn by Grammar, which hides the bar and
|
|
5
|
+
* fades the edge where content continues (HeroUI's ScrollShadow behaviour). An app element that makes its own scroll area with
|
|
6
|
+
* an `overflow-y-auto` / `overflow-auto` class (or the `-x-`, `-scroll` forms) has no such edge and, in a browser that draws bars, shows one.
|
|
7
|
+
*
|
|
8
|
+
* WHAT IT READS. The `className` / `class` attribute of an element in product source: every string in it, a template literal's
|
|
9
|
+
* text included, with any variant prefix (`md:overflow-y-auto`).
|
|
10
|
+
*
|
|
11
|
+
* WHAT IT LEAVES ALONE. `overflow-hidden`, `overflow-clip`, `overflow-visible`, a class that only shares a prefix, and non-product source
|
|
12
|
+
* (Grammar's own sources are not product source).
|
|
13
|
+
*/
|
|
14
|
+
/** `overflow-auto`, `overflow-y-auto`, `overflow-x-scroll` and the like, not part of a longer class name. */
|
|
15
|
+
const RAW_SCROLL = /(?<![\w-])overflow-(?:[xy]-)?(?:auto|scroll)(?![\w-])/;
|
|
16
|
+
/** An app scroll area is drawn by Grammar's scroller, never by an `overflow-*-auto` class on the app's own element. */
|
|
17
|
+
export const noRawScroll = defineRule({
|
|
18
|
+
meta: {
|
|
19
|
+
type: "problem",
|
|
20
|
+
docs: { description: "OVERFLOW-6: NIVO never shows scrollbars; a scroll area is a Grammar scroller or `PaneSection scroll`, not an `overflow-y-auto` class." },
|
|
21
|
+
schema: [],
|
|
22
|
+
messages: {
|
|
23
|
+
raw: "`{{token}}` makes a scroll area outside Grammar. NIVO never shows scrollbars: every scroll area fades its edge where content continues and hides the bar. Use the Grammar scroller (`VerticalScrollRegion`, `HorizontalScrollRegion`) or `PaneSection scroll`, which keep wheel and keyboard scrolling.",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
create(context) {
|
|
27
|
+
if (!isProductSource(context))
|
|
28
|
+
return {};
|
|
29
|
+
return {
|
|
30
|
+
JSXAttribute(node) {
|
|
31
|
+
if (node.name.type !== "JSXIdentifier" || (node.name.name !== "className" && node.name.name !== "class"))
|
|
32
|
+
return;
|
|
33
|
+
if (node.value === null)
|
|
34
|
+
return;
|
|
35
|
+
const match = RAW_SCROLL.exec(context.sourceCode.getText(node.value));
|
|
36
|
+
if (match !== null)
|
|
37
|
+
context.report({ node: node, messageId: "raw", data: { token: match[0] } });
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
/** The rules this law contributes to the plugin. */
|
|
43
|
+
export const rules = {
|
|
44
|
+
"no-raw-scroll": noRawScroll,
|
|
45
|
+
};
|
|
46
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#NO-RAW-SCROLL");
|
|
47
|
+
/** Every rule of this law is an error. */
|
|
48
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
package/dist/tabs.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ import type { Rule } from "eslint";
|
|
|
3
3
|
export declare const tabsSwitchZone: Rule.RuleModule;
|
|
4
4
|
/** At most two underline layers. */
|
|
5
5
|
export declare const tabsDepth: Rule.RuleModule;
|
|
6
|
+
/**
|
|
7
|
+
* The second tab layer stands in the white header band (owner, 2026-11-09, TABS-IN-WELL): `Page header={{ tabs, subTabs }}`, on its own
|
|
8
|
+
* full-width separator, flush with the band's left inset. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection`
|
|
9
|
+
* stands on the pink well or in a pane body, so it is a finding. A drawer, dialog, modal, popover or sheet starts its own surface.
|
|
10
|
+
*/
|
|
11
|
+
export declare const tabsInWell: Rule.RuleModule;
|
|
6
12
|
/** The rules this law contributes to the plugin. */
|
|
7
13
|
export declare const rules: Record<string, Rule.RuleModule>;
|
|
8
14
|
/** Every rule of this law is an error. */
|
package/dist/tabs.js
CHANGED
|
@@ -137,10 +137,55 @@ export const tabsDepth = defineRule({
|
|
|
137
137
|
};
|
|
138
138
|
},
|
|
139
139
|
});
|
|
140
|
+
/** The pink well and the panes: underline Tabs written in their children sit on the well, not in the white header band. */
|
|
141
|
+
const WELL_HOSTS = new Set(["Page", "Pane", "PaneSection"]);
|
|
142
|
+
/**
|
|
143
|
+
* The second tab layer stands in the white header band (owner, 2026-11-09, TABS-IN-WELL): `Page header={{ tabs, subTabs }}`, on its own
|
|
144
|
+
* full-width separator, flush with the band's left inset. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection`
|
|
145
|
+
* stands on the pink well or in a pane body, so it is a finding. A drawer, dialog, modal, popover or sheet starts its own surface.
|
|
146
|
+
*/
|
|
147
|
+
export const tabsInWell = defineRule({
|
|
148
|
+
meta: {
|
|
149
|
+
type: "problem",
|
|
150
|
+
docs: {
|
|
151
|
+
description: "An underline Tabs stands in the white header band (Page header.subTabs), never in the pink well or a pane body.",
|
|
152
|
+
url: "knowledge/ui/presentation/grammar-laws.yaml#TABS-IN-WELL",
|
|
153
|
+
},
|
|
154
|
+
schema: [],
|
|
155
|
+
messages: {
|
|
156
|
+
well: "This underline `Tabs` stands in the body of a `{{host}}`, on the pink well or in a pane. The second tab layer sits in the white header band under the page tabs: `Page header` with `subTabs`, on its own full-width separator and flush with the band left inset. Move it to `header.subTabs`, or make the views a `switch` zone or a filter zone of a card.",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
create(context) {
|
|
160
|
+
if (!isProductSource(context))
|
|
161
|
+
return {};
|
|
162
|
+
return {
|
|
163
|
+
JSXOpeningElement(opening) {
|
|
164
|
+
if (elementName(opening) !== "Tabs" || isPill(opening))
|
|
165
|
+
return;
|
|
166
|
+
let child = opening.parent ?? opening;
|
|
167
|
+
for (let node = child.parent; node !== undefined && node !== null; child = node, node = node.parent) {
|
|
168
|
+
if (node.type !== "JSXElement")
|
|
169
|
+
continue;
|
|
170
|
+
const name = elementName(node.openingElement);
|
|
171
|
+
if (name === null)
|
|
172
|
+
continue;
|
|
173
|
+
if (SURFACE_BOUNDARIES.has(name) || name === "SurfaceCard")
|
|
174
|
+
return;
|
|
175
|
+
if (WELL_HOSTS.has(name) && node.children.includes(child)) {
|
|
176
|
+
context.report({ node: opening, messageId: "well", data: { host: name } });
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
});
|
|
140
184
|
/** The rules this law contributes to the plugin. */
|
|
141
185
|
export const rules = {
|
|
142
186
|
"tabs-switch-zone": tabsSwitchZone,
|
|
143
187
|
"tabs-depth": tabsDepth,
|
|
188
|
+
"tabs-in-well": tabsInWell,
|
|
144
189
|
};
|
|
145
190
|
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#TABS-SWITCH-ZONE");
|
|
146
191
|
/** Every rule of this law is an error. */
|
package/docs/button-arrow.md
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Law module: `button-arrow.ts`. Finding code: `FE_BUTTON_ARROW`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#BUTTON-ARROW`.
|
|
4
4
|
|
|
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 Button that does something
|
|
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
|
-
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
7
|
+
The same module holds `button-icon-primary-only`: only a primary Button carries a leading icon. 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
|
|
|
@@ -28,7 +28,32 @@ A `Button` bound to `@starci/grammar` is a finding when:
|
|
|
28
28
|
|
|
29
29
|
```tsx
|
|
30
30
|
<Button href="/runs" endArrow>View runs</Button>
|
|
31
|
-
<Button onPress={send} startGlyph="send">Send</Button>
|
|
31
|
+
<Button intent="commit" onPress={send} startGlyph="send">Send</Button>
|
|
32
|
+
```
|
|
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>
|
|
32
57
|
```
|
|
33
58
|
|
|
34
59
|
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Layout, one axis
|
|
2
|
+
|
|
3
|
+
Law module: `layout-two-axis.ts`. Finding code: `FE_LAYOUT_TWO_AXIS`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#LAYOUT-TWO-AXIS`.
|
|
4
|
+
|
|
5
|
+
A report page (`Page` standard: the pink well) stacks its card surfaces in ONE direction, a vertical column 24 apart. Cards stand side by side only as siblings of the same role and height (figure cells, short equal cards). A page with a persistent selection or navigation column, or a full-height chat or editor, is a workspace page (`Page chrome="panes"`): a grid of panes split by dividers whose side panes are white surfaces at full height, never cards. The page's `chrome` is the layout declaration, so one page has one frame type.
|
|
6
|
+
|
|
7
|
+
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
|
+
|
|
9
|
+
## `starci-grammar/layout-two-axis`
|
|
10
|
+
|
|
11
|
+
A Grammar `Grid` or `Cluster` is a finding when its rendered children are:
|
|
12
|
+
|
|
13
|
+
- a `SurfaceCard` together with a `Stack` that holds two or more `SurfaceCard`s (message `beside`): two axes in one well;
|
|
14
|
+
- two or more `SurfaceCard`s of different `kind` (an absent `kind` is `body`; message `unequal`): different roles are different heights.
|
|
15
|
+
|
|
16
|
+
`Grid kind="main-rail"`, a card with a JSX spread, a card repeated by `.map` and a `Stack` of cards on its own are not judged.
|
|
17
|
+
|
|
18
|
+
**Invalid**
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
<Grid><SurfaceCard label="Runs" /><Stack><SurfaceCard label="A" /><SurfaceCard label="B" /></Stack></Grid>
|
|
22
|
+
<Cluster><SurfaceCard kind="figures" /><SurfaceCard kind="details" /></Cluster>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Valid**
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
<Stack gap="section"><SurfaceCard kind="figures" /><SurfaceCard label="Runs">...</SurfaceCard></Stack>
|
|
29
|
+
<Cluster><SurfaceCard kind="figures" /><SurfaceCard kind="figures" /></Cluster>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# No raw scroll
|
|
2
|
+
|
|
3
|
+
Law module: `no-raw-scroll.ts`. Finding code: `FE_NO_RAW_SCROLL`. Knowledge: `runtime/knowledge/ui/presentation/grammar-laws.yaml#NO-RAW-SCROLL`.
|
|
4
|
+
|
|
5
|
+
NIVO never shows scrollbars (owner, 2026-11-09). Every scroll area is drawn by Grammar with HeroUI's ScrollShadow behaviour: a fading edge where content continues, the bar hidden, wheel, touch and keyboard scrolling kept. An app element that makes its own scroll area with an `overflow-y-auto` or `overflow-auto` class has no fading edge.
|
|
6
|
+
|
|
7
|
+
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
|
+
|
|
9
|
+
## `starci-grammar/no-raw-scroll`
|
|
10
|
+
|
|
11
|
+
The `className` (or `class`) of any element in product source is a finding when it holds `overflow-auto`, `overflow-scroll`, `overflow-x-auto`, `overflow-y-auto`, `overflow-x-scroll` or `overflow-y-scroll`, with or without a variant prefix. The fix is the Grammar scroller: `VerticalScrollRegion` or `HorizontalScrollRegion`, or `PaneSection` with `scroll` for a pane.
|
|
12
|
+
|
|
13
|
+
`overflow-hidden`, `overflow-clip` and `overflow-visible` are not judged.
|
|
14
|
+
|
|
15
|
+
**Invalid**
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
<div className="flex-1 overflow-y-auto">{messages}</div>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Valid**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
<PaneSection scroll={{ label: "Messages", role: "log" }}>{messages}</PaneSection>
|
|
25
|
+
<VerticalScrollRegion isScrollable aria-label="Files">{rows}</VerticalScrollRegion>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/eslint-grammar-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"description": "ESLint rules for the core Grammar's component, token and composition contracts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
69
69
|
"typescript": "^6.0.3"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
-
"starciSource": "
|
|
71
|
+
"gitHead": "7d6aab209dd341bef6661eff643292471eaa86d8",
|
|
72
|
+
"starciSource": "dbe521b7e5db61f3e40404bbbae3200b86690d7eca01063c4c856fa2d80a0970"
|
|
73
73
|
}
|
|
@@ -56,7 +56,27 @@ rules:
|
|
|
56
56
|
when: A Button leads somewhere
|
|
57
57
|
assert: |-
|
|
58
58
|
It takes `endArrow`; an arrow typed in its label or passed as end content is refused. A Button that does
|
|
59
|
-
something takes `startGlyph
|
|
59
|
+
something takes `startGlyph` (primary only, case-2); never both.
|
|
60
|
+
- id: case-2
|
|
61
|
+
when: A Button carries a leading icon (`startGlyph`, `startContent`)
|
|
62
|
+
assert: |-
|
|
63
|
+
Only the primary Button (`intent="commit"`, the CTA) does. A neutral, alternative, dismiss or destructive Button, a
|
|
64
|
+
suggestion pill and a row action are text only. The arrow (`endArrow`) is not an icon under this rule, so any intent
|
|
65
|
+
may lead somewhere; `IconButton` is unaffected.
|
|
66
|
+
- id: LAYOUT-TWO-AXIS
|
|
67
|
+
title: A report page stacks its cards in one direction
|
|
68
|
+
governs: Card surfaces placed side by side.
|
|
69
|
+
cases:
|
|
70
|
+
- id: case-1
|
|
71
|
+
when: Card surfaces stand in the pink well of a report page
|
|
72
|
+
assert: |-
|
|
73
|
+
They stack in one vertical column, 24 apart. Side by side is allowed only for sibling cards of the same role and height
|
|
74
|
+
(figure cells, short equal cards). A card beside a column of cards, or cards of different kinds in one row, is refused.
|
|
75
|
+
- id: case-2
|
|
76
|
+
when: The page has a persistent selection or navigation column, or a full-height chat or editor
|
|
77
|
+
assert: |-
|
|
78
|
+
It is a workspace page, `Page chrome="panes"`: a grid of panes split by dividers, side panes white surfaces at full
|
|
79
|
+
height, never cards. The main pane may hold a pink well that follows case-1.
|
|
60
80
|
- id: SUGGESTION-BUTTONS
|
|
61
81
|
title: Suggestions and quick replies are a Cluster of neutral sm Buttons
|
|
62
82
|
governs: Anything that suggests something to say or ask.
|
|
@@ -109,6 +129,25 @@ rules:
|
|
|
109
129
|
assert: |-
|
|
110
130
|
The page tabs (`Page header.tabs`) and one region set are the two layers; a third nested set is refused.
|
|
111
131
|
Every tab is one size, so only the count of layers is judged.
|
|
132
|
+
- id: TABS-IN-WELL
|
|
133
|
+
title: The second tab layer stands in the white header band
|
|
134
|
+
governs: Underline Tabs in the body of a page or a pane.
|
|
135
|
+
cases:
|
|
136
|
+
- id: case-1
|
|
137
|
+
when: A page has a second layer of underline tabs under its page tabs
|
|
138
|
+
assert: |-
|
|
139
|
+
It is `Page header.subTabs`: inside the white header band, under layer 1, on its own full-width separator, the same size as layer 1
|
|
140
|
+
(14, 40 high, selected weight 500, the 2px underline exactly on the separator) and flush with the band's left inset, the same x as layer 1.
|
|
141
|
+
An underline Tabs written in the body of a Page, Pane or PaneSection (the pink well, a pane body) is refused.
|
|
142
|
+
- id: LINK-LOOK
|
|
143
|
+
title: A Link is HeroUI's own link and takes its size from the line
|
|
144
|
+
governs: The look of a Grammar Link.
|
|
145
|
+
cases:
|
|
146
|
+
- id: case-1
|
|
147
|
+
when: A Link stands in a line of text, a meta line or a caption
|
|
148
|
+
assert: |-
|
|
149
|
+
It is HeroUI v3's link: the primary colour, the underline on hover only, the anchor icon at the end. Its type size and leading are
|
|
150
|
+
inherited (14 in a body, 12 in meta or caption text). A size prop, a size class and an underline or decoration class are refused.
|
|
112
151
|
- id: SINGLE-CHILD-CARD
|
|
113
152
|
title: A table, list or chart standing alone is the surface
|
|
114
153
|
governs: A SurfaceCard whose only content is a table, a list or a chart.
|
|
@@ -119,3 +158,13 @@ rules:
|
|
|
119
158
|
The Grammar draws a standalone DataTable and every Section kind="list" as ONE frame (border, card radius), so the
|
|
120
159
|
card is a second frame. The title sits above as a Section head and one caption sits below (Section caption, muted sm).
|
|
121
160
|
A card groups two or more different parts (figures + list + actions), or carries zones (tabs, search, head actions).
|
|
161
|
+
- id: NO-RAW-SCROLL
|
|
162
|
+
title: NIVO never shows scrollbars
|
|
163
|
+
governs: Scroll areas an app draws.
|
|
164
|
+
cases:
|
|
165
|
+
- id: case-1
|
|
166
|
+
when: Content scrolls in a pane, drawer, list, thread, tab strip, table or modal body
|
|
167
|
+
assert: |-
|
|
168
|
+
The scroll area is a Grammar scroller (`VerticalScrollRegion`, `HorizontalScrollRegion`, `PaneSection` with `scroll`):
|
|
169
|
+
the scrollbar is hidden, a fading edge (ScrollShadow behaviour) shows where content continues, and wheel, touch and
|
|
170
|
+
keyboard scrolling keep working. An app element with an `overflow-y-auto` or `overflow-auto` class is refused.
|