@starci/eslint-grammar-core 0.37.3 → 0.38.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +767 -614
- package/README.md +2 -1
- package/dist/index.js +8 -0
- package/dist/lib/why.js +28 -8
- package/dist/message-surfaces.d.ts +6 -0
- package/dist/message-surfaces.js +158 -0
- package/dist/no-card-lead-description.d.ts +7 -0
- package/dist/no-card-lead-description.js +55 -0
- package/dist/no-nested-label.d.ts +7 -0
- package/dist/no-nested-label.js +67 -0
- package/dist/rows-in-card.d.ts +7 -0
- package/dist/rows-in-card.js +64 -0
- package/dist/section-head-action.d.ts +1 -1
- package/dist/section-head-action.js +20 -10
- package/dist/single-child-card.d.ts +1 -1
- package/dist/single-child-card.js +16 -31
- package/dist/surface-depth.js +5 -7
- package/dist/tabs.d.ts +1 -1
- package/dist/tabs.js +30 -6
- package/docs/message-surfaces.md +37 -0
- package/docs/no-card-lead-description.md +25 -0
- package/docs/no-nested-label.md +30 -0
- package/docs/rows-in-card.md +25 -0
- package/docs/section-head-action.md +5 -3
- package/docs/single-child-card.md +9 -11
- package/docs/surface-depth.md +2 -9
- package/docs/tabs.md +2 -1
- package/package.json +5 -3
- package/runtime/knowledge/ui/presentation/grammar-laws.yaml +56 -8
package/README.md
CHANGED
|
@@ -19,10 +19,11 @@ Family helpers and the generated runtime closure belong to this package.
|
|
|
19
19
|
|
|
20
20
|
The rule IDs remain stable when their namespace moves. Laws cover the fixed app shell and navbar,
|
|
21
21
|
Grammar-owned structural elements, glyphs and icon sizes, destructive menu entries, status inks,
|
|
22
|
-
chip labels that start uppercase, a Button that leads somewhere ending with `endArrow` (no typed or icon arrow), a leading icon only on the primary Button (`button-arrow`, `button-icon-primary-only`), report cards in one axis (`layout-two-axis`), no app-made scroll area (`no-raw-scroll`), underline tabs only in the header band (`tabs-in-well`), a Link that takes its look from the line (`link-look`), outline icons only, no solid icon set (`outline-icons-only`), one content per card and no description under a label (`card-one-content`, `no-label-description`), a Section head that holds one Link or one IconButton and never a Button (`section-head-action`), a tab count passed as `count` and never as "· N" in the label (`tab-count-chip`), row type sizes in a DataTable cell or ListRow, one size per Cluster line, a row title that is plain text when the row opens (`button-arrow`, `table-cell-type`, `same-line-size`, `row-title-link`), generated art rendered through `Mascot` or `MediaFrame` with every `Mascot` naming its asset slot, the page head composed by `PageHeader`, the pane grid (a `PaneGrid` of `Pane`s, a `Pane` of `PaneSection`s that carry no padding of their own, mounted as `Page chrome="panes"`), the route page as one `Page` with its tabs in the header, heading and token scales, vendor ownership and slot-status composition, and a surface nested in another surface left subordinate (no forced `depth="top"`), and a Freestyle region that names its reason (its raw elements are exempt from the paint and raw-element laws). The pill (`Tabs appearance="primary"`) is only the `switch` header zone of a card
|
|
22
|
+
chip labels that start uppercase, a Button that leads somewhere ending with `endArrow` (no typed or icon arrow), a leading icon only on the primary Button (`button-arrow`, `button-icon-primary-only`), report cards in one axis (`layout-two-axis`), no app-made scroll area (`no-raw-scroll`), underline tabs only in the header band (`tabs-in-well`), a Link that takes its look from the line (`link-look`), outline icons only, no solid icon set (`outline-icons-only`), one content per card and no description under a label (`card-one-content`, `no-label-description`), a Section head that holds one Link or one IconButton and never a Button (`section-head-action`), a tab count passed as `count` and never as "· N" in the label (`tab-count-chip`), row type sizes in a DataTable cell or ListRow, one size per Cluster line, a row title that is plain text when the row opens (`button-arrow`, `table-cell-type`, `same-line-size`, `row-title-link`), generated art rendered through `Mascot` or `MediaFrame` with every `Mascot` naming its asset slot, the page head composed by `PageHeader`, the pane grid (a `PaneGrid` of `Pane`s, a `Pane` of `PaneSection`s that carry no padding of their own, mounted as `Page chrome="panes"`), the route page as one `Page` with its tabs in the header, heading and token scales, vendor ownership and slot-status composition, and a surface nested in another surface left subordinate (no forced `depth="top"`), and a Freestyle region that names its reason (its raw elements are exempt from the paint and raw-element laws). The pill (`Tabs appearance="primary"`) is only the `switch` header zone of a card 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
|
`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`).
|
|
26
|
+
`message-surfaces` (0.37.31: every chat draws Grammar's faces, the thread `--background`, others' messages flat `--surface`, your own `--accent`; no class or style on `MessageBubble`/`MessageCard`, no class string reaching a message part, no `tone: "surface"` on a `role: "log"` thread; `docs/message-surfaces.md`).
|
|
26
27
|
The proximity and composition laws of 2026-11-09 each have a doc: `gap-proximity` (a layout element stands at least one gap step closer than its layout parent), `field-label` (a control is labelled by its own `label` prop), `surface-in-surface` (a hand-made divided row list in a surface is `Section kind="list"`) `single-child-card` (a table, list or chart alone is the surface, not a card's only content) and `page-breadcrumbs` (a console `Page` header states `breadcrumbs`, or `"root"`).
|
|
27
28
|
|
|
28
29
|
## Migrating from @starci/eslint-canon-fe 8.x
|
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { rules as layoutTwoAxisRules } from "./layout-two-axis.js";
|
|
|
15
15
|
import { rules as linkLookRules } from "./link-look.js";
|
|
16
16
|
import { rules as mascotRules } from "./mascot.js";
|
|
17
17
|
import { rules as menuEntriesRules } from "./menu-entries.js";
|
|
18
|
+
import { rules as messageSurfacesRules } from "./message-surfaces.js";
|
|
18
19
|
import { rules as noRawScrollRules } from "./no-raw-scroll.js";
|
|
19
20
|
import { rules as outlineIconsRules } from "./outline-icons.js";
|
|
20
21
|
import { rules as pageRules } from "./page.js";
|
|
@@ -22,6 +23,9 @@ import { rules as pageBreadcrumbsRules } from "./page-breadcrumbs.js";
|
|
|
22
23
|
import { rules as pageHeaderRules } from "./page-header.js";
|
|
23
24
|
import { rules as paneRules } from "./pane.js";
|
|
24
25
|
import { rules as rowTitleLinkRules } from "./row-title-link.js";
|
|
26
|
+
import { rules as rowsInCardRules } from "./rows-in-card.js";
|
|
27
|
+
import { rules as noCardLeadDescriptionRules } from "./no-card-lead-description.js";
|
|
28
|
+
import { rules as noNestedLabelRules } from "./no-nested-label.js";
|
|
25
29
|
import { rules as sectionHeadActionRules } from "./section-head-action.js";
|
|
26
30
|
import { rules as sameLineSizeRules } from "./same-line-size.js";
|
|
27
31
|
import { rules as statusColorsRules } from "./status-colors.js";
|
|
@@ -53,6 +57,7 @@ const CONTRIBUTIONS = [
|
|
|
53
57
|
{ law: "link-look", rules: linkLookRules },
|
|
54
58
|
{ law: "mascot", rules: mascotRules },
|
|
55
59
|
{ law: "menu-entries", rules: menuEntriesRules },
|
|
60
|
+
{ law: "message-surfaces", rules: messageSurfacesRules },
|
|
56
61
|
{ law: "no-raw-scroll", rules: noRawScrollRules },
|
|
57
62
|
{ law: "outline-icons", rules: outlineIconsRules },
|
|
58
63
|
{ law: "page", rules: pageRules },
|
|
@@ -61,6 +66,9 @@ const CONTRIBUTIONS = [
|
|
|
61
66
|
{ law: "pane", rules: paneRules },
|
|
62
67
|
{ law: "row-title-link", rules: rowTitleLinkRules },
|
|
63
68
|
{ law: "same-line-size", rules: sameLineSizeRules },
|
|
69
|
+
{ law: "rows-in-card", rules: rowsInCardRules },
|
|
70
|
+
{ law: "no-card-lead-description", rules: noCardLeadDescriptionRules },
|
|
71
|
+
{ law: "no-nested-label", rules: noNestedLabelRules },
|
|
64
72
|
{ law: "section-head-action", rules: sectionHeadActionRules },
|
|
65
73
|
{ law: "single-child-card", rules: singleChildCardRules },
|
|
66
74
|
{ law: "status-colors", rules: statusColorsRules },
|
package/dist/lib/why.js
CHANGED
|
@@ -11,8 +11,8 @@ export const why = {
|
|
|
11
11
|
},
|
|
12
12
|
"tabs-switch-zone": {
|
|
13
13
|
code: "FE_TABS_SWITCH_ZONE",
|
|
14
|
-
en: "A pill (`Tabs appearance=\"primary\"`) is written in JSX in `<file>`, outside the `switch` header zone of a card
|
|
15
|
-
fix: "A mode or period switch of one block is the card's zone: `headers={[{ kind: \"switch\", label, items, selectedKey, onSelect }]}` with two to four short options. Views of a page are page tabs (`Page header.tabs`); views or filters inside a region are underline `Tabs`.",
|
|
14
|
+
en: "A pill (`Tabs appearance=\"primary\"`) is written in JSX in `<file>`, outside the `switch` header zone of a card and not the value of a row `control`.",
|
|
15
|
+
fix: "A mode or period switch of one block is the card's zone: `headers={[{ kind: \"switch\", label, items, selectedKey, onSelect }]}` with two to four short options. A row-level mode choice goes in the row's `control`. Views of a page are page tabs (`Page header.tabs`); views or filters inside a region are underline `Tabs`.",
|
|
16
16
|
},
|
|
17
17
|
"tabs-depth": {
|
|
18
18
|
code: "FE_TABS_DEPTH",
|
|
@@ -24,10 +24,25 @@ export const why = {
|
|
|
24
24
|
en: "An underline `Tabs` in `<file>` is written in the body of a `Page`, `Pane` or `PaneSection`: on the pink well or in a pane.",
|
|
25
25
|
fix: "The second tab layer sits in the white header band under the page tabs: `Page header={{ tabs, subTabs }}`, on its own full-width separator and flush with the band's left inset. Or make the views a `switch` zone or a filter zone of a card.",
|
|
26
26
|
},
|
|
27
|
+
"rows-in-card": {
|
|
28
|
+
code: "FE_ROWS_IN_CARD",
|
|
29
|
+
en: "A `DescriptionList` or `DisclosureList` in `<file>` stands with no `Section` or `SurfaceCard` around it.",
|
|
30
|
+
fix: "Rows are always a card: put them in a `Section kind=\"list\"` or a `SurfaceCard`. Grammar draws the shadow (no border) on the pink well and the 1px border (no shadow) on a white aside, pane or drawer by itself.",
|
|
31
|
+
},
|
|
32
|
+
"no-card-lead-description": {
|
|
33
|
+
code: "FE_NO_CARD_LEAD_DESCRIPTION",
|
|
34
|
+
en: "A muted `Text` in `<file>` stands directly above a `SurfaceCard` as its description.",
|
|
35
|
+
fix: "A card has no description. Put the line in the row subtitle (`SurfaceCard kind=\"select\"` or `kind=\"list\"`), or, when it explains the card's data (a legend, a source, a period), in the card `note`.",
|
|
36
|
+
},
|
|
37
|
+
"no-nested-label": {
|
|
38
|
+
code: "FE_NO_NESTED_LABEL",
|
|
39
|
+
en: "A `Section` or `SurfaceCard` in `<file>` has its own Label inside a labelled `Section` or `SurfaceCard`.",
|
|
40
|
+
fix: "A section has ONE Label. A group inside it is named by a Sublabel: use `sublabel=\"...\"` instead of `title` / `label` (Grammar draws it 12 / 500 muted, 8px above the card, groups 24px apart).",
|
|
41
|
+
},
|
|
27
42
|
"section-head-action": {
|
|
28
43
|
code: "FE_SECTION_HEAD_ACTION",
|
|
29
|
-
en: "The `Section` head `action` in `<file>` holds a
|
|
30
|
-
fix: "A section's head is one row: the label and an optional count chip at the start, at most ONE thing at the end
|
|
44
|
+
en: "The `Section` head `action` in `<file>` holds a Button that is not a neutral small text Button, or more than one command.",
|
|
45
|
+
fix: "A section's head is one row: the label and an optional count chip at the start, at most ONE thing at the end: a `Link variant=\"head\"` (the label then an arrow that slides on hover), an info `IconButton`, or a text `Button intent=\"neutral\" size=\"sm\"` (no icon, never the commit).",
|
|
31
46
|
},
|
|
32
47
|
"tab-count-chip": {
|
|
33
48
|
code: "FE_TAB_COUNT_CHIP",
|
|
@@ -176,8 +191,8 @@ export const why = {
|
|
|
176
191
|
},
|
|
177
192
|
"no-raised-surface-in-surface": {
|
|
178
193
|
code: "FE_RAISED_SURFACE_IN_SURFACE",
|
|
179
|
-
en: "A `SurfaceCard` in `<file>` stands inside another SurfaceCard
|
|
180
|
-
fix: "Give the content to the
|
|
194
|
+
en: "A `SurfaceCard` in `<file>` stands inside another SurfaceCard: a card never stands inside a card (a Pane surface, Dialog, Drawer or Popover hosts cards, bordered, since 0.37.5).",
|
|
195
|
+
fix: "Give the content to the outer card's own body, or use a kind of the outer card (`list`, `figures`) or its typed `headers` and `footers` zones for what needs its own faces.",
|
|
181
196
|
},
|
|
182
197
|
"no-shell-bottom-tabs": {
|
|
183
198
|
code: "FE_APP_SHELL_BOTTOM_TABS",
|
|
@@ -191,8 +206,8 @@ export const why = {
|
|
|
191
206
|
},
|
|
192
207
|
"single-child-card": {
|
|
193
208
|
code: "FE_SINGLE_CHILD_CARD",
|
|
194
|
-
en: "A `SurfaceCard` in `<file>` has no zones and holds one
|
|
195
|
-
fix: "Drop the card: put the title in a `Section` head (`title`) and one line under it in `Section caption`. A card groups two or more different parts, or carries zones (`headers`, `footers`) or head actions (`labelEnd`).",
|
|
209
|
+
en: "A `SurfaceCard` in `<file>` has no zones and holds one `DataTable` or chart (`BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`): a standalone table or chart is its own surface, so the card is a second frame. A card of list or key-value rows is valid.",
|
|
210
|
+
fix: "Drop the card: put the title in a `Section` head (`title`) and one line under it in `Section caption`. A card groups two or more different parts, or carries zones (`headers`, `footers`) or head actions (`labelEnd`); a list card (`kind=\"list\"`, `kind=\"table\"`) is always valid.",
|
|
196
211
|
},
|
|
197
212
|
"surface-card-kind": {
|
|
198
213
|
code: "FE_SURFACE_CARD_KIND",
|
|
@@ -239,6 +254,11 @@ export const why = {
|
|
|
239
254
|
en: "A Link is the title of a row in `<file>` that already opens (onPress, onAction, href, chevron, or a DataTable with onRowAction or row hrefs).",
|
|
240
255
|
fix: "The row is the one pressable: write the title as plain text (`<Text isStrong>`) and keep the destination on the row.",
|
|
241
256
|
},
|
|
257
|
+
"message-surfaces": {
|
|
258
|
+
code: "FE_MESSAGE_SURFACES",
|
|
259
|
+
en: "`<file>` restyles a chat face: a class or style on MessageBubble or MessageCard, a class string reaching into a Grammar message part, a chat thread asked for the surface tone, or a chat frame (`Pane content=\"chat\"`, a Pane holding a log thread) given `surface`.",
|
|
260
|
+
fix: "Remove the override: the chat frame (head, thread, composer) is `--background` (`Pane content=\"chat\"`, no `surface`, DNA-COMMON-CHAT-FRAME), others' messages the flat `--surface`, your own `--accent` (DNA-COMMON-CHAT-SURFACES); a card's replies are `SurfaceCard kind=\"list\" layout=\"suggestions\"`.",
|
|
261
|
+
},
|
|
242
262
|
"suggestion-buttons": {
|
|
243
263
|
code: "FE_SUGGESTION_BUTTONS",
|
|
244
264
|
en: "A Link row, a ChoiceChips or a Chip in `<file>` runs an action or sends its own label as a suggestion.",
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
export declare const messageSurfaces: Rule.RuleModule;
|
|
3
|
+
/** The rules this law contributes to the plugin. */
|
|
4
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
5
|
+
/** Every rule of this law is an error. */
|
|
6
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
|
+
import { attributeOf, elementOf, grammarBindings, keyName, propertyOf } from "./lib/row-context.js";
|
|
4
|
+
/**
|
|
5
|
+
* The chat surfaces law (`FE_MESSAGE_SURFACES`, Grammar 0.37.31, DNA-COMMON-CHAT-SURFACES): every chat draws the same three faces, and they are Grammar's
|
|
6
|
+
* alone. The thread is the page tone (`--background`), a message of someone else (`MessageBubble` incoming, `MessageCard`) is the flat surface (no border,
|
|
7
|
+
* no shadow), the reader's own message is `--accent` with `--accent-foreground`. An app never restyles them. The law flags, in cheap static shapes only:
|
|
8
|
+
* - a `className`, `class`, `style` or `UNSAFE_className` attribute on a Grammar `MessageBubble` or `MessageCard` (their props carry none; a cast or a
|
|
9
|
+
* spread that smuggles one past the type is still a restyle);
|
|
10
|
+
* - a static class string or a style key in product source that names a Grammar message part (`starci-core-message-bubble…`, `starci-core-message-card…`):
|
|
11
|
+
* an arbitrary-variant utility (`[&_.starci-core-message-bubble-body]:bg-white`) or a selector reaching into the bubble;
|
|
12
|
+
* - a `PaneSection` whose `scroll` object literal states `role: "log"` with `tone: "surface"`: a thread is always the page tone (the Grammar ignores the
|
|
13
|
+
* tone), so the word misleads the reader of the code;
|
|
14
|
+
* - a surface tone on a chat frame (0.37.33, DNA-COMMON-CHAT-FRAME): `surface` on a `Pane` with `content="chat"`, or on a `Pane` whose own children
|
|
15
|
+
* hold a `PaneSection` with `scroll.role: "log"`. A chat frame (head, thread, composer footer) is `--background` wherever it stands; the Grammar ignores
|
|
16
|
+
* the tone there, so the word misleads.
|
|
17
|
+
* A spread, a computed class or a tone held in a variable is not read; a thread drawn by a component of the app's own is not seen through.
|
|
18
|
+
*/
|
|
19
|
+
const MESSAGE_PARTS = /starci-core-message-(?:bubble|card)/;
|
|
20
|
+
const STYLE_ATTRIBUTES = new Set(["className", "class", "style", "UNSAFE_className", "UNSAFE_style"]);
|
|
21
|
+
const FACES = new Set(["MessageBubble", "MessageCard"]);
|
|
22
|
+
/** The static string a literal or a template without expressions holds, or null. */
|
|
23
|
+
const staticString = (node) => {
|
|
24
|
+
if (node.type === "Literal" && typeof node.value === "string")
|
|
25
|
+
return node.value;
|
|
26
|
+
if (node.type === "TemplateLiteral")
|
|
27
|
+
return node.quasis.map((quasi) => quasi.value.cooked ?? "").join(" ");
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
/** Whether a `scroll` attribute states `role: "log"` in an object literal. */
|
|
31
|
+
const isLogScroll = (opening) => {
|
|
32
|
+
const value = attributeOf(opening, "scroll")?.value;
|
|
33
|
+
if (value?.type !== "JSXExpressionContainer" || value.expression.type !== "ObjectExpression")
|
|
34
|
+
return false;
|
|
35
|
+
const role = propertyOf(value.expression, "role")?.value;
|
|
36
|
+
return role?.type === "Literal" && role.value === "log";
|
|
37
|
+
};
|
|
38
|
+
/** Whether a Pane states `content="chat"`. */
|
|
39
|
+
const isChatContent = (opening) => {
|
|
40
|
+
const value = attributeOf(opening, "content")?.value;
|
|
41
|
+
if (value == null)
|
|
42
|
+
return false;
|
|
43
|
+
if (value.type === "Literal")
|
|
44
|
+
return value.value === "chat";
|
|
45
|
+
return value.type === "JSXExpressionContainer" && value.expression.type === "Literal" && value.expression.value === "chat";
|
|
46
|
+
};
|
|
47
|
+
/** Whether a Pane's own JSX children (a fragment opened) hold a Grammar `PaneSection` thread. */
|
|
48
|
+
const holdsThread = (opening, bound) => {
|
|
49
|
+
const element = opening.parent;
|
|
50
|
+
if (element.type !== "JSXElement")
|
|
51
|
+
return false;
|
|
52
|
+
const walk = (children) => children.some((child) => {
|
|
53
|
+
if (child.type === "JSXFragment")
|
|
54
|
+
return walk(child.children);
|
|
55
|
+
if (child.type !== "JSXElement")
|
|
56
|
+
return false;
|
|
57
|
+
return elementOf(child.openingElement, bound).grammar === "PaneSection" && isLogScroll(child.openingElement);
|
|
58
|
+
});
|
|
59
|
+
return walk(element.children);
|
|
60
|
+
};
|
|
61
|
+
export const messageSurfaces = defineRule({
|
|
62
|
+
meta: {
|
|
63
|
+
type: "problem",
|
|
64
|
+
docs: { description: "FE_MESSAGE_SURFACES: chat bubbles, message cards and the thread ground are Grammar's faces; an app never restyles them." },
|
|
65
|
+
schema: [],
|
|
66
|
+
messages: {
|
|
67
|
+
attribute: "`{{component}}` takes no `{{attribute}}`: every chat draws the same faces (the thread on `--background`, others' messages flat `--surface`, your own `--accent`). Remove it.",
|
|
68
|
+
part: "This class or style reaches into a Grammar message part (`{{part}}`). Chat faces are Grammar's (DNA-COMMON-CHAT-SURFACES); remove the override.",
|
|
69
|
+
tone: "A chat thread (`scroll.role: \"log\"`) is always the page tone; `tone: \"surface\"` is ignored. Remove `tone`.",
|
|
70
|
+
frame: "A chat frame (`Pane content=\"chat\"`, or a Pane that holds a `scroll.role: \"log\"` thread) is `--background` wherever it stands (DNA-COMMON-CHAT-FRAME); `surface` is ignored there. Remove `surface` and give the pane `content=\"chat\"`.",
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
create(context) {
|
|
74
|
+
if (!isProductSource(context))
|
|
75
|
+
return {};
|
|
76
|
+
let bound = new Map();
|
|
77
|
+
const reportPart = (node, text) => {
|
|
78
|
+
const part = MESSAGE_PARTS.exec(text)?.[0];
|
|
79
|
+
if (part !== undefined)
|
|
80
|
+
context.report({ node, messageId: "part", data: { part } });
|
|
81
|
+
};
|
|
82
|
+
return {
|
|
83
|
+
Program(program) {
|
|
84
|
+
bound = grammarBindings(program);
|
|
85
|
+
},
|
|
86
|
+
JSXOpeningElement(opening) {
|
|
87
|
+
const { grammar } = elementOf(opening, bound);
|
|
88
|
+
if (grammar !== null && FACES.has(grammar)) {
|
|
89
|
+
for (const entry of opening.attributes) {
|
|
90
|
+
if (entry.type !== "JSXAttribute" || entry.name.type !== "JSXIdentifier" || !STYLE_ATTRIBUTES.has(entry.name.name))
|
|
91
|
+
continue;
|
|
92
|
+
context.report({ node: entry, messageId: "attribute", data: { component: grammar, attribute: entry.name.name } });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (grammar === "Pane") {
|
|
96
|
+
const surface = attributeOf(opening, "surface");
|
|
97
|
+
const off = surface?.value?.type === "JSXExpressionContainer" && surface.value.expression.type === "Literal" && surface.value.expression.value === false;
|
|
98
|
+
if (surface !== null && !off && (isChatContent(opening) || holdsThread(opening, bound))) {
|
|
99
|
+
context.report({ node: surface, messageId: "frame" });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (grammar === "PaneSection") {
|
|
103
|
+
const value = attributeOf(opening, "scroll")?.value;
|
|
104
|
+
if (value?.type !== "JSXExpressionContainer" || value.expression.type !== "ObjectExpression")
|
|
105
|
+
return;
|
|
106
|
+
const role = propertyOf(value.expression, "role")?.value;
|
|
107
|
+
const tone = propertyOf(value.expression, "tone");
|
|
108
|
+
if (role?.type === "Literal" && role.value === "log" && tone?.value.type === "Literal" && tone.value.value === "surface") {
|
|
109
|
+
context.report({ node: tone, messageId: "tone" });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
JSXAttribute(attribute) {
|
|
114
|
+
if (attribute.name.type !== "JSXIdentifier" || !STYLE_ATTRIBUTES.has(attribute.name.name) || attribute.value == null)
|
|
115
|
+
return;
|
|
116
|
+
if (attribute.value.type === "Literal") {
|
|
117
|
+
if (typeof attribute.value.value === "string")
|
|
118
|
+
reportPart(attribute.value, attribute.value.value);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (attribute.value.type !== "JSXExpressionContainer")
|
|
122
|
+
return;
|
|
123
|
+
const expression = attribute.value.expression;
|
|
124
|
+
const text = staticString(expression);
|
|
125
|
+
if (text !== null) {
|
|
126
|
+
reportPart(expression, text);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (expression.type === "ObjectExpression") {
|
|
130
|
+
for (const property of expression.properties) {
|
|
131
|
+
if (property.type !== "Property")
|
|
132
|
+
continue;
|
|
133
|
+
const key = keyName(property);
|
|
134
|
+
if (key !== null)
|
|
135
|
+
reportPart(property, key);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
CallExpression(call) {
|
|
140
|
+
// a class builder (`cn(...)`, `clsx(...)`): its static string arguments are class strings
|
|
141
|
+
if (call.callee.type !== "Identifier" || !/^(cn|clsx|cx|classNames|classnames|twMerge|twJoin)$/.test(call.callee.name))
|
|
142
|
+
return;
|
|
143
|
+
for (const argument of call.arguments) {
|
|
144
|
+
const text = staticString(argument);
|
|
145
|
+
if (text !== null)
|
|
146
|
+
reportPart(argument, text);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
/** The rules this law contributes to the plugin. */
|
|
153
|
+
export const rules = {
|
|
154
|
+
"message-surfaces": messageSurfaces,
|
|
155
|
+
};
|
|
156
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#MESSAGE-SURFACES");
|
|
157
|
+
/** Every rule of this law is an error. */
|
|
158
|
+
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
|
+
/** No free-standing description line directly above a SurfaceCard. */
|
|
3
|
+
export declare const noCardLeadDescription: 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,55 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { elementNameOf, grammarName, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
|
|
3
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* NO CARD LEAD DESCRIPTION (owner, 2026-11-09, CARD-NO-DESCRIPTION). A card head is its label, a count chip, one fact and one end action: it has NO description. The
|
|
6
|
+
* words that explain a card's data go in the card's `note` (a legend, a source, a period); the words that explain a row are that row's own subtitle (`kind="select"`
|
|
7
|
+
* and `kind="list"`). A free-standing muted line placed directly above a card (the title + description + card pattern) is the same description drawn by hand.
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT READS. In product source, a Grammar `Text` with `tone="muted"` that is the sibling written IMMEDIATELY BEFORE a Grammar `SurfaceCard` in the same children list.
|
|
10
|
+
*
|
|
11
|
+
* WHAT IT LEAVES ALONE. A muted `Text` anywhere else (inside a card, between two cards, below a card), a native `<p>`, and any `Text` with another tone: no static signal tells
|
|
12
|
+
* those apart from a legend or a body line, so the rule stays on the one pattern that is certain.
|
|
13
|
+
*/
|
|
14
|
+
const isMutedText = (context, node) => {
|
|
15
|
+
if (node.type !== "JSXElement")
|
|
16
|
+
return false;
|
|
17
|
+
return grammarName(context, node.openingElement) === "Text" && stringProp(node.openingElement, "tone") === "muted";
|
|
18
|
+
};
|
|
19
|
+
const isCard = (context, node) => node !== undefined && node.type === "JSXElement" && elementNameOf(node) !== null && grammarName(context, node.openingElement) === "SurfaceCard";
|
|
20
|
+
/** No free-standing description line directly above a SurfaceCard. */
|
|
21
|
+
export const noCardLeadDescription = defineRule({
|
|
22
|
+
meta: {
|
|
23
|
+
type: "problem",
|
|
24
|
+
docs: { description: "CARD-NO-DESCRIPTION: a card has no lead description; the line goes in a row subtitle or the card `note`." },
|
|
25
|
+
schema: [],
|
|
26
|
+
messages: {
|
|
27
|
+
lead: "A muted `Text` stands directly above a `SurfaceCard` as its description. A card has no description: put the line in the row subtitle (`kind=\"select\"` or `kind=\"list\"`) or, if it explains the card's data (a legend, a source, a period), in the card `note`.",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
create(context) {
|
|
31
|
+
if (!isProductSource(context))
|
|
32
|
+
return {};
|
|
33
|
+
const check = (children) => {
|
|
34
|
+
const rendered = renderedChildren(children);
|
|
35
|
+
rendered.forEach((child, index) => {
|
|
36
|
+
if (!isMutedText(context, child))
|
|
37
|
+
return;
|
|
38
|
+
if (!isCard(context, rendered[index + 1]))
|
|
39
|
+
return;
|
|
40
|
+
context.report({ node: child, messageId: "lead" });
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
JSXElement(node) { check(node.children); },
|
|
45
|
+
JSXFragment(node) { check(node.children); },
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
/** The rules this law contributes to the plugin. */
|
|
50
|
+
export const rules = {
|
|
51
|
+
"no-card-lead-description": noCardLeadDescription,
|
|
52
|
+
};
|
|
53
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#CARD-NO-DESCRIPTION");
|
|
54
|
+
/** Every rule of this law is an error. */
|
|
55
|
+
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
|
+
/** One Label per section; nested groups use a Sublabel. */
|
|
3
|
+
export declare const noNestedLabel: 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,67 @@
|
|
|
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
|
+
* NO NESTED LABEL (owner, 2026-11-09, LABEL-SUBLABEL-HIERARCHY). A section has exactly ONE Label (its head, 14/500, 12px above its content). The groups nested inside it
|
|
6
|
+
* are named by a Sublabel (12/500 muted, 8px above the card), never by a second Label: a `Section` or `SurfaceCard` inside a labelled one takes `sublabel`, not `title`/`label`.
|
|
7
|
+
*
|
|
8
|
+
* WHAT IT READS. In product source, a Grammar `Section` with a `title` or a `SurfaceCard` with a `label` whose JSX ancestor in the same file is a Grammar `Section` with a
|
|
9
|
+
* `title` or a `SurfaceCard` with a `label`. A Grammar element passed as a JSX attribute value is judged where the receiver draws it.
|
|
10
|
+
*
|
|
11
|
+
* WHAT IT LEAVES ALONE. Nesting across files (a block that returns a labelled card inside a parent's labelled section) and non-product source.
|
|
12
|
+
*/
|
|
13
|
+
const LABEL_PROP = { Section: "title", SurfaceCard: "label" };
|
|
14
|
+
/** The Grammar name of the element when it is a Section or SurfaceCard that carries its Label prop, else null. */
|
|
15
|
+
const labelOf = (context, opening) => {
|
|
16
|
+
const name = grammarName(context, opening);
|
|
17
|
+
if (name === null)
|
|
18
|
+
return null;
|
|
19
|
+
const prop = LABEL_PROP[name];
|
|
20
|
+
return prop !== undefined && attributeOf(opening, prop) !== undefined ? name : null;
|
|
21
|
+
};
|
|
22
|
+
const labelledAncestor = (context, opening) => {
|
|
23
|
+
let previous = opening;
|
|
24
|
+
for (let current = opening.parent?.parent; current !== undefined && current !== null; previous = current, current = current.parent) {
|
|
25
|
+
if (current.type === "JSXAttribute")
|
|
26
|
+
return null;
|
|
27
|
+
if (current.type !== "JSXElement" || previous === current.openingElement)
|
|
28
|
+
continue;
|
|
29
|
+
const found = labelOf(context, current.openingElement);
|
|
30
|
+
if (found !== null)
|
|
31
|
+
return found;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
/** One Label per section; nested groups use a Sublabel. */
|
|
36
|
+
export const noNestedLabel = defineRule({
|
|
37
|
+
meta: {
|
|
38
|
+
type: "problem",
|
|
39
|
+
docs: { description: "LABEL-SUBLABEL-HIERARCHY: a Section or SurfaceCard inside a labelled Section or SurfaceCard uses `sublabel`, never a second `title`/`label`." },
|
|
40
|
+
schema: [],
|
|
41
|
+
messages: {
|
|
42
|
+
nested: "A `{{name}}` with its own Label stands inside a labelled `{{parent}}`. A section has ONE Label; a group inside it is named by a Sublabel: use `sublabel=\"…\"` instead of `{{prop}}`.",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
create(context) {
|
|
46
|
+
if (!isProductSource(context))
|
|
47
|
+
return {};
|
|
48
|
+
return {
|
|
49
|
+
JSXOpeningElement(opening) {
|
|
50
|
+
const name = labelOf(context, opening);
|
|
51
|
+
if (name === null)
|
|
52
|
+
return;
|
|
53
|
+
const parent = labelledAncestor(context, opening);
|
|
54
|
+
if (parent === null)
|
|
55
|
+
return;
|
|
56
|
+
context.report({ node: opening, messageId: "nested", data: { name, parent, prop: LABEL_PROP[name] ?? "label" } });
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
/** The rules this law contributes to the plugin. */
|
|
62
|
+
export const rules = {
|
|
63
|
+
"no-nested-label": noNestedLabel,
|
|
64
|
+
};
|
|
65
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#LABEL-SUBLABEL-HIERARCHY");
|
|
66
|
+
/** Every rule of this law is an error. */
|
|
67
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** A list of rows stands in a card. */
|
|
3
|
+
export declare const rowsInCard: 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,64 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { grammarName } from "./lib/grammar-jsx.js";
|
|
3
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* ROWS IN A CARD (owner, 2026-11-09, ROWS-IN-CARD). A list of rows or key-value rows is always a card: on the pink well a card with a shadow and no border, on a white
|
|
6
|
+
* surface (aside, pane, drawer) a card with a 1px border and no shadow. Grammar draws that edge itself (the SURFACE-ELEVATION rule) when the rows stand in a
|
|
7
|
+
* `SurfaceCard` or a `Section`; a row primitive written bare on a surface is the repeated bug of a list with no edge.
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT READS. In product source, a Grammar `DescriptionList` (key-value rows) or `DisclosureList` (disclosure rows) that no `SurfaceCard`, `Section`, `DataTable`
|
|
10
|
+
* or `Accordion` of the same file encloses. A row primitive passed as a JSX attribute value (`body={<DescriptionList/>}`) is judged where the receiving component draws it.
|
|
11
|
+
*
|
|
12
|
+
* WHAT IT LEAVES ALONE. `ListBox` (a selectable list pane and a menu are navigation, not rows of data: no static signal tells them apart), a row primitive another
|
|
13
|
+
* file wraps (a file whose only job is to return the rows is flagged here: wrap it in the `Section` or card in the same file), and non-product source.
|
|
14
|
+
*/
|
|
15
|
+
const ROWS = new Set(["DescriptionList", "DisclosureList"]);
|
|
16
|
+
const CARDS = new Set(["SurfaceCard", "Section", "DataTable", "Accordion"]);
|
|
17
|
+
/** True when the element sits inside a Grammar card of this file, or inside a JSX attribute (the receiver draws it). */
|
|
18
|
+
const isHosted = (context, opening) => {
|
|
19
|
+
let previous = opening;
|
|
20
|
+
for (let current = opening.parent?.parent; current !== undefined && current !== null; previous = current, current = current.parent) {
|
|
21
|
+
if (current.type === "JSXAttribute")
|
|
22
|
+
return true;
|
|
23
|
+
if (current.type !== "JSXElement")
|
|
24
|
+
continue;
|
|
25
|
+
if (previous === current.openingElement)
|
|
26
|
+
continue;
|
|
27
|
+
const name = grammarName(context, current.openingElement);
|
|
28
|
+
if (name !== null && CARDS.has(name))
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
};
|
|
33
|
+
/** A list of rows stands in a card. */
|
|
34
|
+
export const rowsInCard = defineRule({
|
|
35
|
+
meta: {
|
|
36
|
+
type: "problem",
|
|
37
|
+
docs: { description: "ROWS-IN-CARD: a DescriptionList or DisclosureList stands in a SurfaceCard or a Section, so it is a card (shadow on the well, 1px border on a white surface)." },
|
|
38
|
+
schema: [],
|
|
39
|
+
messages: {
|
|
40
|
+
bare: "A `{{name}}` stands with no card around it. Rows are always a card: put them in a `Section` (`kind=\"list\"`) or a `SurfaceCard`; Grammar draws the shadow on the pink well and the 1px border on a white aside, pane or drawer by itself.",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
create(context) {
|
|
44
|
+
if (!isProductSource(context))
|
|
45
|
+
return {};
|
|
46
|
+
return {
|
|
47
|
+
JSXOpeningElement(opening) {
|
|
48
|
+
const name = grammarName(context, opening);
|
|
49
|
+
if (name === null || !ROWS.has(name))
|
|
50
|
+
return;
|
|
51
|
+
if (isHosted(context, opening))
|
|
52
|
+
return;
|
|
53
|
+
context.report({ node: opening, messageId: "bare", data: { name } });
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
/** The rules this law contributes to the plugin. */
|
|
59
|
+
export const rules = {
|
|
60
|
+
"rows-in-card": rowsInCard,
|
|
61
|
+
};
|
|
62
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#ROWS-IN-CARD");
|
|
63
|
+
/** Every rule of this law is an error. */
|
|
64
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
|
-
/** A section head holds one navigation Link or one
|
|
2
|
+
/** A section head holds one navigation Link, one info IconButton or one neutral small Button: no commit, 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>;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
-
import { attributeOf, grammarName } from "./lib/grammar-jsx.js";
|
|
2
|
+
import { attributeOf, grammarName, literalString } from "./lib/grammar-jsx.js";
|
|
3
3
|
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
|
-
* start, and at the end at most ONE thing: a navigation `Link variant="head"` (the label then an arrow that slides on hover)
|
|
7
|
-
*
|
|
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 neutral small `Button` ("Gắn thêm 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` (message `button
|
|
10
|
+
* - a Grammar `Button` that is not exactly `intent="neutral" size="sm"` (message `button`: a primary/commit or any other size is refused);
|
|
11
|
+
* - a `Button` that carries an icon (`startGlyph`, `startContent`, `endContent`, `icon`; message `icon`);
|
|
11
12
|
* - more than one Grammar `Button`, `Link`, `IconButton` or `TextAction` (message `many`): the head has room for one.
|
|
12
13
|
*
|
|
13
|
-
* WHAT IT LEAVES ALONE. A `Section` with no `action`, an `action` that holds one Link or one
|
|
14
|
+
* WHAT IT LEAVES ALONE. A `Section` with no `action`, an `action` that holds one Link, one IconButton or one neutral sm text Button, other components, and non-product source.
|
|
14
15
|
*/
|
|
15
16
|
const COMMANDS = new Set(["Button", "Link", "IconButton", "TextAction"]);
|
|
17
|
+
const ICON_PROPS = ["startGlyph", "startContent", "endContent", "icon", "iconSource"];
|
|
16
18
|
/** Every Grammar command element an expression holds, in source order. */
|
|
17
19
|
const commandsIn = (context, root) => {
|
|
18
20
|
const found = [];
|
|
@@ -40,14 +42,15 @@ const commandsIn = (context, root) => {
|
|
|
40
42
|
visit(root);
|
|
41
43
|
return found;
|
|
42
44
|
};
|
|
43
|
-
/** A section head holds one navigation Link or one
|
|
45
|
+
/** A section head holds one navigation Link, one info IconButton or one neutral small Button: no commit, no icon Button, no second command. */
|
|
44
46
|
export const sectionHeadAction = defineRule({
|
|
45
47
|
meta: {
|
|
46
48
|
type: "problem",
|
|
47
|
-
docs: { description: "SECTION-HEAD-ACTION: a Section's head action is one Link variant=\"head\" or one
|
|
49
|
+
docs: { description: "SECTION-HEAD-ACTION: a Section's head action is one Link variant=\"head\", one IconButton or one neutral sm Button; never a commit Button, never more than one." },
|
|
48
50
|
schema: [],
|
|
49
51
|
messages: {
|
|
50
|
-
button: "A `Button` in a `Section` head `action
|
|
52
|
+
button: "A `Button` in a `Section` head `action` must be `intent=\"neutral\" size=\"sm\"` (a small quiet pill at the end of the label row); a primary or commit 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 neutral sm Button is text only.",
|
|
51
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.",
|
|
52
55
|
},
|
|
53
56
|
},
|
|
@@ -62,9 +65,16 @@ export const sectionHeadAction = defineRule({
|
|
|
62
65
|
if (action === undefined || action.value === null)
|
|
63
66
|
return;
|
|
64
67
|
const commands = commandsIn(context, action.value);
|
|
65
|
-
for (const command of commands)
|
|
66
|
-
if (command.name
|
|
68
|
+
for (const command of commands) {
|
|
69
|
+
if (command.name !== "Button")
|
|
70
|
+
continue;
|
|
71
|
+
const isNeutralSmall = literalString(attributeOf(command.node, "intent")) === "neutral" && literalString(attributeOf(command.node, "size")) === "sm";
|
|
72
|
+
if (!isNeutralSmall)
|
|
67
73
|
context.report({ node: command.node, messageId: "button" });
|
|
74
|
+
const icon = ICON_PROPS.find((name) => attributeOf(command.node, name) !== undefined);
|
|
75
|
+
if (icon !== undefined)
|
|
76
|
+
context.report({ node: command.node, messageId: "icon", data: { prop: icon } });
|
|
77
|
+
}
|
|
68
78
|
if (commands.length > 1)
|
|
69
79
|
context.report({ node: action, messageId: "many", data: { count: String(commands.length) } });
|
|
70
80
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
|
-
/** A table
|
|
2
|
+
/** A table component or a chart standing alone is the surface, never wrapped in a card; list cards are valid. */
|
|
3
3
|
export declare const singleChildCard: Rule.RuleModule;
|
|
4
4
|
/** The rules this law contributes to the plugin. */
|
|
5
5
|
export declare const rules: Record<string, Rule.RuleModule>;
|