@starci/eslint-grammar-core 0.44.0 → 0.45.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 +12 -0
- package/README.md +4 -2
- package/dist/card-content.js +8 -19
- package/dist/{single-child-card.d.ts → card-is-object.d.ts} +2 -2
- package/dist/card-is-object.js +141 -0
- package/dist/choice-controls.d.ts +1 -1
- package/dist/choice-controls.js +5 -5
- package/dist/data-table-surface.d.ts +18 -0
- package/dist/data-table-surface.js +57 -0
- package/dist/index.js +4 -2
- package/dist/lib/why.js +25 -20
- package/dist/no-card-lead-description.js +3 -3
- package/dist/rows-in-card.d.ts +1 -1
- package/dist/rows-in-card.js +13 -12
- package/dist/surface-card-list.d.ts +1 -2
- package/dist/surface-card-list.js +1 -2
- package/dist/surface-card.d.ts +1 -1
- package/dist/surface-card.js +8 -63
- package/dist/surface-depth.js +1 -1
- package/dist/surface-in-surface.js +1 -1
- package/dist/tabs.d.ts +3 -3
- package/dist/tabs.js +21 -20
- package/docs/card-content.md +5 -6
- package/docs/card-is-object.md +42 -0
- package/docs/choice-controls.md +4 -4
- package/docs/data-table-surface.md +27 -0
- package/docs/layout-two-axis.md +3 -3
- package/docs/no-card-lead-description.md +2 -2
- package/docs/no-nested-label.md +3 -3
- package/docs/rows-in-card.md +5 -4
- package/docs/surface-card-list.md +1 -2
- package/docs/surface-card.md +4 -8
- package/docs/surface-depth.md +6 -7
- package/docs/surface-in-surface.md +2 -2
- package/docs/tabs.md +4 -4
- package/package.json +3 -3
- package/runtime/knowledge/ui/presentation/grammar-laws.yaml +32 -23
- package/dist/single-child-card.js +0 -90
- package/docs/single-child-card.md +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.45.0 - 2026-11-17
|
|
4
|
+
|
|
5
|
+
- Added: `card-is-object` (`FE_CARD_IS_OBJECT`, law CARD-OBJECT): a Grammar `SurfaceCard` of the body kind (no `kind`, or `kind="body"`) whose only content, through fragments and the layout wrappers `Stack`, `Cluster`, `Inline`, `Grid` and `div`, is a `DataTable`, a `Section` of any kind, a `DescriptionList`, a `DisclosureList`, an `Accordion`, a `Form`, a `Fieldset`, a lone field (`Input`, `Textarea`, `Select`, `ComboBox`, `SearchField`, `NumberField`, `RadioGroup`, `CheckboxGroup`), an `EmptyNotice`, `Markdown`, `MarkdownArticle` or a chart (`BarChart`, `LineChart`, `Sparkline`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`) is refused. Message `collection`: "SurfaceCard holds only a `DataTable`: a card is one object (a customer, an agent, a plan, a message). Put the table flat under its Section (`<Section title ...><DataTable .../></Section>`)." with the replacement of each content (list: `Section kind="list"`, facts: `Section` + `DescriptionList isDivided`, disclosures: `Section` + `DisclosureList`, form or field: `Section` + `Form`, empty: `EmptyNotice` on its own, markdown and chart: `Section`). `measure="formCompact"`, a `kind="tile"` card and a card with more than one content are not judged. No autofix. Doc `docs/card-is-object.md`.
|
|
6
|
+
- Added: `data-table-surface` (`FE_DATA_TABLE_SURFACE`): a Grammar `DataTable` with a `surface` attribute, whatever its value, is refused ("`DataTable surface` is removed: a table has one flat look. Drop the `surface` attribute and put the table under its `Section`..."); the autofix removes the attribute and the whitespace before it. Doc `docs/data-table-surface.md`.
|
|
7
|
+
- Removed: `single-child-card` (`FE_SINGLE_CHILD_CARD`, law SINGLE-CHILD-CARD), its spec, doc, why entry and knowledge law; `card-is-object` absorbs it and its still-valid cases (a card around a lone table, chart or list).
|
|
8
|
+
- Changed: `rows-in-card` (`FE_ROWS_IN_CARD`): a `DescriptionList` or `DisclosureList` stands in a `Section` or in the body of an object `SurfaceCard`; the message and doc no longer say rows are always a card, and `DataTable` and `Accordion` no longer count as a host.
|
|
9
|
+
- Changed: `tabs-switch-zone` (`FE_TABS_SWITCH_ZONE`) lets a pill (`Tabs appearance="primary"`) stand as the `action` of a `Section` (the place of the removed `switch` zone) and as a row `control`; `tabs-in-well` no longer treats a `SurfaceCard` as a header row of its own (a card has no header zones), so loose underline tabs in a card body in a page or pane are findings; the messages of `tabs-switch-zone`, `tabs-depth`, `tabs-in-well` name `Section action` and `Section filter`.
|
|
10
|
+
- Changed: `card-one-content` speaks of one object per card (a second collection is its own `Section`, a ribbon is `Section kind="figures"`); the `ribbon` message and the `figures` header zone check are deleted.
|
|
11
|
+
- Changed: `surface-card-kind` (R355) points at `Section kind="list"`, `Section kind="figures"`, `Section filter` and the card's `actions`; the `zone` message and the check of `custom` zones of `headers` and `footers` are deleted with the zones.
|
|
12
|
+
- Changed (messages, docs and hints): `surface-in-surface`, `surface-depth`, `no-label-in-grid`, `no-card-lead-description`, `choice-controls`, `surface-card-list` and the `lib/why.ts` fixes no longer name `kind="table"`, `"details"`, `"figures"`, `"accordion"`, `"select"`, `headers`, `footers` or a `switch` zone; each names its replacement. `one-highlight-per-render` specs use `MessageBubble`.
|
|
13
|
+
- Knowledge (`runtime/knowledge/ui/presentation/grammar-laws.yaml`): CARD-OBJECT and DATA-TABLE-SURFACE added; SINGLE-CHILD-CARD removed; TABS-SWITCH-ZONE, TABS-IN-WELL, ROWS-IN-CARD, CARD-NO-DESCRIPTION and CARD-ONE-CONTENT rewritten for the flat look.
|
|
14
|
+
|
|
3
15
|
## 0.44.0 - 2026-11-17
|
|
4
16
|
|
|
5
17
|
- Changed: `navbar-control-size` (`FE_NAVBAR_CONTROL_SIZE`) reads a `Switch` by its `kind`, which the Grammar lets win over `size`: `kind="toggle"` passes alone (no `size` needed), a `Switch` with neither `kind` nor `size` passes (the toggle is the default), and `kind="compact"` is refused in the bar with its own message (`compact`: 32x18 breaks the bar's one 40px height, DNA-COMMON-BAR-ONE-HEIGHT) whatever `size` it carries; before, `size="control"` beside `kind="compact"` silenced the rule although the Grammar ignored it. Fix text and docs `docs/app-shell.md` updated.
|
package/README.md
CHANGED
|
@@ -19,13 +19,15 @@ 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
|
|
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 object per card and no description under a label (`card-one-content`, `no-label-description`), a Section head that holds one Link or one IconButton and never a Button (`section-head-action`), 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 `action` of a `Section` or the value of a row `control`, and a page stacks two underline `Tabs` layers at most (`tabs-switch-zone`, `tabs-depth`; `docs/tabs.md`). Each rule's metadata cites
|
|
23
23
|
its behavioral knowledge source and the governing ownership test. The R318 surface composition
|
|
24
24
|
rules (nested control variants, panel-list alignment, layout-only CSS) stay in the universal canon.
|
|
25
25
|
`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
26
|
`surface-card-list` (0.43.0, LIST-ONE-LOOK: a list is `Section kind="list"` of `ListRow`s, flat rows aligned with the title, never `SurfaceCard kind="list"`; `docs/surface-card-list.md`).
|
|
27
|
+
`card-is-object` (0.45.0, CARD-OBJECT: a card is one object; a card whose only content is a table, a list, facts, disclosures, a form, a field, an empty notice, markdown or a chart is refused, the message names the flat `Section` form; `docs/card-is-object.md`).
|
|
28
|
+
`data-table-surface` (0.45.0: a `DataTable` has one flat look, its `surface` prop is refused and removed by the fix; `docs/data-table-surface.md`).
|
|
27
29
|
`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`).
|
|
28
|
-
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"`) `
|
|
30
|
+
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"`) `card-is-object` (a card is one object, never a lone collection) and `page-breadcrumbs` (a console `Page` header states `breadcrumbs`, or `"root"`).
|
|
29
31
|
|
|
30
32
|
## Migrating from @starci/eslint-canon-fe 8.x
|
|
31
33
|
|
package/dist/card-content.js
CHANGED
|
@@ -2,15 +2,14 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
|
2
2
|
import { attributeOf, grammarName, stringProp } from "./lib/grammar-jsx.js";
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* ONE
|
|
6
|
-
* or
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* ONE OBJECT PER CARD (CARD-ONE-CONTENT). A `SurfaceCard` is ONE object (a customer, an agent, a plan, a message): its name, its facts and its commands
|
|
6
|
+
* (`actions`). A second collection, form or graph is not part of the object: it stands flat in its own `Section`. Items of the same kind stay in one list. A card
|
|
7
|
+
* inside a card is `no-raised-surface-in-surface` (R340); a card whose ONLY content is a collection is `card-is-object`. A label has no description under it:
|
|
8
|
+
* the description is a caption under the card (`Section caption`, `SurfaceCard note`).
|
|
9
9
|
*
|
|
10
10
|
* WHAT IT READS.
|
|
11
11
|
* - `card-one-content`: a `SurfaceCard` whose body (any depth, through layout wrappers) holds more than one content component (a list, a description
|
|
12
|
-
* list, a table, a graph, a chart, a timeline, a figures strip, a form group)
|
|
13
|
-
* (a ribbon above another content).
|
|
12
|
+
* list, a table, a graph, a chart, a timeline, a figures strip, a form group).
|
|
14
13
|
* - `no-label-description`: a `Section` with a `description`, and a labelled `SurfaceCard` (not a tile) with a `description`.
|
|
15
14
|
*
|
|
16
15
|
* WHAT IT LEAVES ALONE. A card with one content, a tile (its description is its content), other components, and non-product source.
|
|
@@ -51,22 +50,14 @@ const contentsIn = (context, root) => {
|
|
|
51
50
|
visit(root);
|
|
52
51
|
return found;
|
|
53
52
|
};
|
|
54
|
-
const hasFiguresZone = (opening) => {
|
|
55
|
-
const headers = attributeOf(opening, "headers");
|
|
56
|
-
const expression = headers?.value?.type === "JSXExpressionContainer" ? headers.value.expression : undefined;
|
|
57
|
-
if (expression === undefined || expression.type !== "ArrayExpression")
|
|
58
|
-
return false;
|
|
59
|
-
return expression.elements.some((entry) => entry !== null && entry.type === "ObjectExpression" && entry.properties.some((property) => property.type === "Property" && property.key.type === "Identifier" && property.key.name === "kind" && property.value.type === "Literal" && property.value.value === "figures"));
|
|
60
|
-
};
|
|
61
53
|
/** A card holds one content. */
|
|
62
54
|
export const cardOneContent = defineRule({
|
|
63
55
|
meta: {
|
|
64
56
|
type: "problem",
|
|
65
|
-
docs: { description: "CARD-ONE-CONTENT: a SurfaceCard
|
|
57
|
+
docs: { description: "CARD-ONE-CONTENT: a SurfaceCard is one object; a second list, form, table or graph in the same card is its own Section." },
|
|
66
58
|
schema: [],
|
|
67
59
|
messages: {
|
|
68
|
-
many: "This `SurfaceCard` holds {{count}} contents ({{names}}). A card
|
|
69
|
-
ribbon: "A `figures` header zone puts a figures ribbon above another content in one card. A ribbon is its own card (`kind=\"figures\"`), with a `Sublabel` above the cards that follow.",
|
|
60
|
+
many: "This `SurfaceCard` holds {{count}} contents ({{names}}). A card is ONE object. A second list, table, form or graph is not part of it: put each flat in its own `Section` (a ribbon is `Section kind=\"figures\"`); items of the same kind stay in one list.",
|
|
70
61
|
},
|
|
71
62
|
},
|
|
72
63
|
create(context) {
|
|
@@ -78,15 +69,13 @@ export const cardOneContent = defineRule({
|
|
|
78
69
|
if (grammarName(context, opening) !== "SurfaceCard")
|
|
79
70
|
return;
|
|
80
71
|
const kind = stringProp(opening, "kind");
|
|
81
|
-
if (kind === "
|
|
72
|
+
if (kind === "tile")
|
|
82
73
|
return;
|
|
83
74
|
const contents = contentsIn(context, { type: "Program", children: element.children });
|
|
84
75
|
if (contents.length > 1) {
|
|
85
76
|
const names = contents.map((entry) => grammarName(context, entry) ?? "?").join(", ");
|
|
86
77
|
context.report({ node: opening, messageId: "many", data: { count: String(contents.length), names } });
|
|
87
78
|
}
|
|
88
|
-
if (hasFiguresZone(opening))
|
|
89
|
-
context.report({ node: opening, messageId: "ribbon" });
|
|
90
79
|
},
|
|
91
80
|
};
|
|
92
81
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
|
-
/** A
|
|
3
|
-
export declare const
|
|
2
|
+
/** A card is one object: a collection, a form or a placeholder is never its only content. */
|
|
3
|
+
export declare const cardIsObject: Rule.RuleModule;
|
|
4
4
|
/** The rules this law contributes to the plugin. */
|
|
5
5
|
export declare const rules: Record<string, Rule.RuleModule>;
|
|
6
6
|
/** Every rule of this law is an error. */
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { attributeOf, elementNameOf, grammarName, hasSpread, nameOf, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
|
|
3
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* A card is one object (CARD-OBJECT): a customer, an agent, a provider, a plan, a message, an approval, a dialog or an overlay. A collection (a list, a
|
|
6
|
+
* table, facts, figures, disclosures, a choice), a form and a placeholder stand flat, in a `Section` or on their own, never in a card.
|
|
7
|
+
*
|
|
8
|
+
* WHAT IT READS. In product source, a Grammar `SurfaceCard` of the body kind (no `kind`, or `kind="body"`) whose ONLY content is one of:
|
|
9
|
+
* - a table: `DataTable`
|
|
10
|
+
* - a section: `Section` of any kind (a list, a region or a figures ribbon)
|
|
11
|
+
* - rows: `DescriptionList`, `DisclosureList`, `Accordion`
|
|
12
|
+
* - a form or a lone field: `Form`, `Fieldset`, `Input`, `Textarea`, `Select`, `ComboBox`, `SearchField`, `NumberField`, `RadioGroup`, `CheckboxGroup`
|
|
13
|
+
* - a placeholder: `EmptyNotice`
|
|
14
|
+
* - markdown: `Markdown`, `MarkdownArticle`
|
|
15
|
+
* - a chart: `BarChart`, `LineChart`, `Sparkline`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`
|
|
16
|
+
* The body is read through fragments, `cond && <x/>`, `cond ? <x/> : <y/>` and `.map`, and through the layout wrappers `Stack`, `Cluster`, `Inline`, `Grid`
|
|
17
|
+
* and a plain `div` that hold that one content.
|
|
18
|
+
*
|
|
19
|
+
* WHAT IT LEAVES ALONE. A card with `measure="formCompact"` (the sign-in form with no page around it), a `kind="tile"` card, a body card with more than one
|
|
20
|
+
* content (an object's name or facts beside a control is an object), a card with a JSX spread, a non-Grammar `SurfaceCard`, and non-product source.
|
|
21
|
+
*
|
|
22
|
+
* NO AUTOFIX. The move changes the structure (the card's `label` becomes the `Section` title), which the author reads.
|
|
23
|
+
*/
|
|
24
|
+
/** The layout wrappers read through, so a card holding one `Stack` of one table is a card holding a table. */
|
|
25
|
+
const WRAPPERS = new Set(["Stack", "Cluster", "Inline", "Grid"]);
|
|
26
|
+
const TABLE = {
|
|
27
|
+
content: "a `DataTable`",
|
|
28
|
+
fix: "Put the table flat under its Section (`<Section title ...><DataTable .../></Section>`).",
|
|
29
|
+
};
|
|
30
|
+
const FORM = {
|
|
31
|
+
content: "a form",
|
|
32
|
+
fix: "Put the form flat under a Section (`<Section title ...><Form .../></Section>`); a sign-in form with no page around it keeps `measure=\"formCompact\"`.",
|
|
33
|
+
};
|
|
34
|
+
const FIELD = {
|
|
35
|
+
content: "one field",
|
|
36
|
+
fix: "Put the field in a Section (`<Section title ...><Form><Input .../></Form></Section>`); a sign-in form with no page around it keeps `measure=\"formCompact\"`.",
|
|
37
|
+
};
|
|
38
|
+
const CHART = {
|
|
39
|
+
content: "a chart",
|
|
40
|
+
fix: "Put the chart flat under a Section (`<Section title ...><BarChart .../></Section>`).",
|
|
41
|
+
};
|
|
42
|
+
const DISCLOSURES = {
|
|
43
|
+
content: "disclosures",
|
|
44
|
+
fix: "Put the disclosures flat under a Section (`<Section title ...><DisclosureList items={...} /></Section>`).",
|
|
45
|
+
};
|
|
46
|
+
/** What each lone content is, in the words the message uses, and where it stands instead. */
|
|
47
|
+
const CONTENT = new Map([
|
|
48
|
+
["DataTable", TABLE],
|
|
49
|
+
["DescriptionList", { content: "a `DescriptionList`", fix: "Put the facts flat under a Section (`<Section title ...><DescriptionList isDivided items={...} /></Section>`); the facts of ONE object stay in that object's card beside its name or a control." }],
|
|
50
|
+
["DisclosureList", DISCLOSURES],
|
|
51
|
+
["Accordion", DISCLOSURES],
|
|
52
|
+
["Form", FORM],
|
|
53
|
+
["Fieldset", FORM],
|
|
54
|
+
["Input", FIELD],
|
|
55
|
+
["Textarea", FIELD],
|
|
56
|
+
["Select", FIELD],
|
|
57
|
+
["ComboBox", FIELD],
|
|
58
|
+
["SearchField", FIELD],
|
|
59
|
+
["NumberField", FIELD],
|
|
60
|
+
["RadioGroup", FIELD],
|
|
61
|
+
["CheckboxGroup", FIELD],
|
|
62
|
+
["EmptyNotice", { content: "an `EmptyNotice`", fix: "An empty state stands on its own: drop the card and keep the `EmptyNotice`." }],
|
|
63
|
+
["Markdown", { content: "`Markdown`", fix: "Put the text flat under a Section (`<Section title ...><Markdown .../></Section>`)." }],
|
|
64
|
+
["MarkdownArticle", { content: "`MarkdownArticle`", fix: "Put the text flat under a Section (`<Section title ...><MarkdownArticle .../></Section>`)." }],
|
|
65
|
+
["BarChart", CHART],
|
|
66
|
+
["LineChart", CHART],
|
|
67
|
+
["Sparkline", CHART],
|
|
68
|
+
["ProportionBar", CHART],
|
|
69
|
+
["BubbleMap", CHART],
|
|
70
|
+
["FlowGraph", CHART],
|
|
71
|
+
["MermaidDiagram", CHART],
|
|
72
|
+
]);
|
|
73
|
+
/** What a `Section` of this kind is and where it stands instead. */
|
|
74
|
+
const sectionContent = (kind) => {
|
|
75
|
+
if (kind === "list")
|
|
76
|
+
return { content: "a `Section kind=\"list\"`", fix: "A list is flat: drop the card and keep `<Section kind=\"list\" title ... items={...} />`, which titles itself." };
|
|
77
|
+
if (kind === "figures")
|
|
78
|
+
return { content: "a `Section kind=\"figures\"`", fix: "A ribbon is flat: drop the card and keep `<Section kind=\"figures\" items={...} />`." };
|
|
79
|
+
return { content: "a `Section`", fix: "A section stands flat on the page: drop the card and keep the `Section`; its title is the card's `label`." };
|
|
80
|
+
};
|
|
81
|
+
/** True when the card is a body card: no `kind`, or `kind="body"`. A `kind` that is not a literal is left to the compiler. */
|
|
82
|
+
const isBodyCard = (opening) => {
|
|
83
|
+
const attribute = attributeOf(opening, "kind");
|
|
84
|
+
return attribute === undefined || stringProp(opening, "kind") === "body";
|
|
85
|
+
};
|
|
86
|
+
/** The one content a list of rendered children holds, looked through the layout wrappers, or null when it holds none or more than one. */
|
|
87
|
+
const loneContent = (context, children) => {
|
|
88
|
+
if (children.length !== 1)
|
|
89
|
+
return null;
|
|
90
|
+
const child = children[0];
|
|
91
|
+
if (child === undefined || child.type !== "JSXElement")
|
|
92
|
+
return null;
|
|
93
|
+
const opening = child.openingElement;
|
|
94
|
+
if (elementNameOf(child) === null || hasSpread(opening))
|
|
95
|
+
return null;
|
|
96
|
+
const grammar = grammarName(context, opening);
|
|
97
|
+
if (grammar === "Section")
|
|
98
|
+
return sectionContent(stringProp(opening, "kind"));
|
|
99
|
+
if (grammar !== null && WRAPPERS.has(grammar))
|
|
100
|
+
return loneContent(context, renderedChildren(child.children));
|
|
101
|
+
if (opening.name.type === "JSXIdentifier" && opening.name.name === "div")
|
|
102
|
+
return loneContent(context, renderedChildren(child.children));
|
|
103
|
+
if (grammar === null)
|
|
104
|
+
return null;
|
|
105
|
+
return CONTENT.get(nameOf(opening.name) ?? "") ?? null;
|
|
106
|
+
};
|
|
107
|
+
/** A card is one object: a collection, a form or a placeholder is never its only content. */
|
|
108
|
+
export const cardIsObject = defineRule({
|
|
109
|
+
meta: {
|
|
110
|
+
type: "problem",
|
|
111
|
+
docs: { description: "CARD-OBJECT: a body SurfaceCard is one object; a card whose only content is a table, a list, facts, disclosures, a form, a field, an empty notice, markdown or a chart is refused." },
|
|
112
|
+
schema: [],
|
|
113
|
+
messages: {
|
|
114
|
+
collection: "SurfaceCard holds only {{content}}: a card is one object (a customer, an agent, a plan, a message). {{fix}}",
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
create(context) {
|
|
118
|
+
if (!isProductSource(context))
|
|
119
|
+
return {};
|
|
120
|
+
return {
|
|
121
|
+
JSXElement(element) {
|
|
122
|
+
const opening = element.openingElement;
|
|
123
|
+
if (grammarName(context, opening) !== "SurfaceCard" || hasSpread(opening) || !isBodyCard(opening))
|
|
124
|
+
return;
|
|
125
|
+
if (stringProp(opening, "measure") === "formCompact")
|
|
126
|
+
return;
|
|
127
|
+
const found = loneContent(context, renderedChildren(element.children));
|
|
128
|
+
if (found === null)
|
|
129
|
+
return;
|
|
130
|
+
context.report({ node: opening, messageId: "collection", data: { content: found.content, fix: found.fix } });
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
});
|
|
135
|
+
/** The rules this law contributes to the plugin. */
|
|
136
|
+
export const rules = {
|
|
137
|
+
"card-is-object": cardIsObject,
|
|
138
|
+
};
|
|
139
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#CARD-OBJECT");
|
|
140
|
+
/** Every rule of this law is an error. */
|
|
141
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -10,7 +10,7 @@ import type { Rule } from "eslint";
|
|
|
10
10
|
*
|
|
11
11
|
* A second rule holds the same law for loose buttons: two or more adjacent `Button` or `IconButton` elements (or one written in a
|
|
12
12
|
* `.map`) that carry `aria-pressed`, `isSelected` or `isActive` are joined buttons acting as tabs, a pill toggle ("This month / Last
|
|
13
|
-
* month"). A switch between views or periods of one block is `Tabs` (the primary underline) in the block's `
|
|
13
|
+
* month"). A switch between views or periods of one block is `Tabs` (the primary underline) in the `filter` row of the block's `Section` (a mode or period pill is `Section action`);
|
|
14
14
|
* `ChoiceChips` or `RadioGroup` choose a form value; a button holds a command, never a selection state.
|
|
15
15
|
*/
|
|
16
16
|
/** Each banned component with the replacement its message names. */
|
package/dist/choice-controls.js
CHANGED
|
@@ -11,14 +11,14 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
|
11
11
|
*
|
|
12
12
|
* A second rule holds the same law for loose buttons: two or more adjacent `Button` or `IconButton` elements (or one written in a
|
|
13
13
|
* `.map`) that carry `aria-pressed`, `isSelected` or `isActive` are joined buttons acting as tabs, a pill toggle ("This month / Last
|
|
14
|
-
* month"). A switch between views or periods of one block is `Tabs` (the primary underline) in the block's `
|
|
14
|
+
* month"). A switch between views or periods of one block is `Tabs` (the primary underline) in the `filter` row of the block's `Section` (a mode or period pill is `Section action`);
|
|
15
15
|
* `ChoiceChips` or `RadioGroup` choose a form value; a button holds a command, never a selection state.
|
|
16
16
|
*/
|
|
17
17
|
/** Each banned component with the replacement its message names. */
|
|
18
18
|
export const REPLACEMENTS = {
|
|
19
19
|
ButtonGroup: "separate `Button`s (one commit, the rest alternative or dismiss), or a `DropdownMenu` for the overflow",
|
|
20
20
|
FilterButtonGroup: "`Tabs kind=\"filter\"` (compact underline tabs with a `count` each, under the list's search field) to narrow a list that stays in place",
|
|
21
|
-
SegmentedControl: "`ChoiceChips` or `RadioGroup` to choose a value of a form, or `Tabs appearance=\"primary\"` (
|
|
21
|
+
SegmentedControl: "`ChoiceChips` or `RadioGroup` to choose a value of a form, or `Tabs appearance=\"primary\"` (in the `action` of its `Section`) to switch a mode or period of one block",
|
|
22
22
|
};
|
|
23
23
|
/** The element name of a JSX opening element (`ButtonGroup`, or `Grammar.ButtonGroup` as `ButtonGroup`). */
|
|
24
24
|
const elementName = (opening) => {
|
|
@@ -98,10 +98,10 @@ const selectionButtonsOf = (node, inMap = false) => {
|
|
|
98
98
|
export const noButtonViewSwitch = defineRule({
|
|
99
99
|
meta: {
|
|
100
100
|
type: "problem",
|
|
101
|
-
docs: { description: "R380: no row of Buttons carrying aria-pressed, isSelected or isActive as a view switch; a switch between views or periods is Tabs in the block's
|
|
101
|
+
docs: { description: "R380: no row of Buttons carrying aria-pressed, isSelected or isActive as a view switch; a switch between views or periods is Tabs in the `filter` row of the block's Section." },
|
|
102
102
|
schema: [],
|
|
103
103
|
messages: {
|
|
104
|
-
switch: "Buttons that carry `{{attribute}}` side by side are a view switch drawn as joined buttons or pills. Switching between views or periods of one block is `Tabs` (the primary underline) in the block's `
|
|
104
|
+
switch: "Buttons that carry `{{attribute}}` side by side are a view switch drawn as joined buttons or pills. Switching between views or periods of one block is `Tabs` (the primary underline) in the `filter` row of the block's `Section`, or a pill (`Tabs appearance=\"primary\"`) in its `action`; choosing a form value is `ChoiceChips` or `RadioGroup`; a `Button` holds a command, never a selection state.",
|
|
105
105
|
},
|
|
106
106
|
},
|
|
107
107
|
create(context) {
|
|
@@ -136,7 +136,7 @@ const hasKind = (object, literal) => object.properties.some((property) => proper
|
|
|
136
136
|
export const noPrimaryTabsMisuse = defineRule({
|
|
137
137
|
meta: {
|
|
138
138
|
type: "problem",
|
|
139
|
-
docs: { description: "R380: Tabs appearance=\"primary\" (
|
|
139
|
+
docs: { description: "R380: Tabs appearance=\"primary\" (a Section `action` or a row `control`) hold two to four short, fixed options with no count, no href and no attention mark; views, filters and navigation are the secondary underline tabs." },
|
|
140
140
|
schema: [],
|
|
141
141
|
messages: {
|
|
142
142
|
primary: "Primary tabs (a pill in a track) switch a mode or period of the same data among two to four short, fixed options: {{problem}}. Views, filters with counts and destinations are the secondary (underline) `Tabs`.",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/**
|
|
3
|
+
* ONE FLAT TABLE (DATA-TABLE-SURFACE). A `DataTable` has one flat look: no frame, no card, no fill. The Grammar family 0.45.0 deleted its `surface` prop
|
|
4
|
+
* (`card`, `frame`, `none`), so the compiler refuses it where the types are read; this rule names the fix, and applies it, where an app still writes it (a
|
|
5
|
+
* pinned older Grammar, a JavaScript file, an `any` prop).
|
|
6
|
+
*
|
|
7
|
+
* WHAT IT READS. In product source, a Grammar `DataTable` (named or `G.DataTable`) with a `surface` attribute, whatever its value.
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT LEAVES ALONE. A `surface` on another component (`Pane surface` is its own prop), a non-Grammar `DataTable` and non-product source.
|
|
10
|
+
*
|
|
11
|
+
* AUTOFIX. The attribute and the whitespace before it are removed. The table keeps its columns, rows and `footer`.
|
|
12
|
+
*/
|
|
13
|
+
/** A `surface` on a `DataTable` is refused, and removed by the fix. */
|
|
14
|
+
export declare const dataTableSurface: Rule.RuleModule;
|
|
15
|
+
/** The rules this law contributes to the plugin. */
|
|
16
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
17
|
+
/** Every rule of this law is an error. */
|
|
18
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
* ONE FLAT TABLE (DATA-TABLE-SURFACE). A `DataTable` has one flat look: no frame, no card, no fill. The Grammar family 0.45.0 deleted its `surface` prop
|
|
6
|
+
* (`card`, `frame`, `none`), so the compiler refuses it where the types are read; this rule names the fix, and applies it, where an app still writes it (a
|
|
7
|
+
* pinned older Grammar, a JavaScript file, an `any` prop).
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT READS. In product source, a Grammar `DataTable` (named or `G.DataTable`) with a `surface` attribute, whatever its value.
|
|
10
|
+
*
|
|
11
|
+
* WHAT IT LEAVES ALONE. A `surface` on another component (`Pane surface` is its own prop), a non-Grammar `DataTable` and non-product source.
|
|
12
|
+
*
|
|
13
|
+
* AUTOFIX. The attribute and the whitespace before it are removed. The table keeps its columns, rows and `footer`.
|
|
14
|
+
*/
|
|
15
|
+
/** A `surface` on a `DataTable` is refused, and removed by the fix. */
|
|
16
|
+
export const dataTableSurface = defineRule({
|
|
17
|
+
meta: {
|
|
18
|
+
type: "problem",
|
|
19
|
+
fixable: "code",
|
|
20
|
+
docs: { description: "DATA-TABLE-SURFACE: a DataTable has one flat look; its `surface` prop is removed in the Grammar family 0.45.0." },
|
|
21
|
+
schema: [],
|
|
22
|
+
messages: {
|
|
23
|
+
surface: "`DataTable surface` is removed: a table has one flat look. Drop the `surface` attribute and put the table under its `Section` (`<Section title ...><DataTable .../></Section>`).",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
create(context) {
|
|
27
|
+
if (!isProductSource(context))
|
|
28
|
+
return {};
|
|
29
|
+
return {
|
|
30
|
+
JSXOpeningElement(opening) {
|
|
31
|
+
if (grammarName(context, opening) !== "DataTable")
|
|
32
|
+
return;
|
|
33
|
+
const attribute = attributeOf(opening, "surface");
|
|
34
|
+
if (attribute === undefined)
|
|
35
|
+
return;
|
|
36
|
+
context.report({
|
|
37
|
+
node: attribute,
|
|
38
|
+
messageId: "surface",
|
|
39
|
+
fix: (fixer) => {
|
|
40
|
+
const text = context.sourceCode.text;
|
|
41
|
+
let start = attribute.range[0];
|
|
42
|
+
while (start > 0 && /\s/.test(text.charAt(start - 1)))
|
|
43
|
+
start -= 1;
|
|
44
|
+
return fixer.removeRange([start, attribute.range[1]]);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
/** The rules this law contributes to the plugin. */
|
|
52
|
+
export const rules = {
|
|
53
|
+
"data-table-surface": dataTableSurface,
|
|
54
|
+
};
|
|
55
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#DATA-TABLE-SURFACE");
|
|
56
|
+
/** Every rule of this law is an error. */
|
|
57
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,10 @@ import { SOURCE_FILES, linterOptions as canonLinterOptions, scopeToPackages } fr
|
|
|
3
3
|
import { rules as appShellRules } from "./app-shell.js";
|
|
4
4
|
import { rules as buttonArrowRules } from "./button-arrow.js";
|
|
5
5
|
import { rules as cardContentRules } from "./card-content.js";
|
|
6
|
+
import { rules as cardIsObjectRules } from "./card-is-object.js";
|
|
6
7
|
import { rules as chipLabelRules } from "./chip-label.js";
|
|
7
8
|
import { rules as choiceControlsRules } from "./choice-controls.js";
|
|
9
|
+
import { rules as dataTableSurfaceRules } from "./data-table-surface.js";
|
|
8
10
|
import { rules as drawingRules } from "./drawing.js";
|
|
9
11
|
import { rules as fieldLabelRules } from "./field-label.js";
|
|
10
12
|
import { rules as freestyleRules } from "./freestyle.js";
|
|
@@ -32,7 +34,6 @@ import { rules as statusColorsRules } from "./status-colors.js";
|
|
|
32
34
|
import { rules as surfaceCardRules } from "./surface-card.js";
|
|
33
35
|
import { rules as surfaceCardListRules } from "./surface-card-list.js";
|
|
34
36
|
import { rules as surfaceDepthRules } from "./surface-depth.js";
|
|
35
|
-
import { rules as singleChildCardRules } from "./single-child-card.js";
|
|
36
37
|
import { rules as surfaceInSurfaceRules } from "./surface-in-surface.js";
|
|
37
38
|
import { rules as suggestionButtonsRules } from "./suggestion-buttons.js";
|
|
38
39
|
import { rules as tabCountChipRules } from "./tab-count-chip.js";
|
|
@@ -46,8 +47,10 @@ const CONTRIBUTIONS = [
|
|
|
46
47
|
{ law: "app-shell", rules: appShellRules },
|
|
47
48
|
{ law: "button-arrow", rules: buttonArrowRules },
|
|
48
49
|
{ law: "card-content", rules: cardContentRules },
|
|
50
|
+
{ law: "card-is-object", rules: cardIsObjectRules },
|
|
49
51
|
{ law: "chip-label", rules: chipLabelRules },
|
|
50
52
|
{ law: "choice-controls", rules: choiceControlsRules },
|
|
53
|
+
{ law: "data-table-surface", rules: dataTableSurfaceRules },
|
|
51
54
|
{ law: "drawing", rules: drawingRules },
|
|
52
55
|
{ law: "field-label", rules: fieldLabelRules },
|
|
53
56
|
{ law: "freestyle", rules: freestyleRules },
|
|
@@ -71,7 +74,6 @@ const CONTRIBUTIONS = [
|
|
|
71
74
|
{ law: "no-card-lead-description", rules: noCardLeadDescriptionRules },
|
|
72
75
|
{ law: "no-nested-label", rules: noNestedLabelRules },
|
|
73
76
|
{ law: "section-head-action", rules: sectionHeadActionRules },
|
|
74
|
-
{ law: "single-child-card", rules: singleChildCardRules },
|
|
75
77
|
{ law: "status-colors", rules: statusColorsRules },
|
|
76
78
|
{ law: "surface-card", rules: surfaceCardRules },
|
|
77
79
|
{ law: "surface-card-list", rules: surfaceCardListRules },
|
package/dist/lib/why.js
CHANGED
|
@@ -11,23 +11,23 @@ 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 `
|
|
15
|
-
fix: "A mode or period switch of one block is the
|
|
14
|
+
en: "A pill (`Tabs appearance=\"primary\"`) is written in JSX in `<file>`, outside the `action` of a `Section` and not the value of a row `control`.",
|
|
15
|
+
fix: "A mode or period switch of one block is the `action` of its Section: `<Section title action={<Tabs appearance=\"primary\" 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",
|
|
19
19
|
en: "Underline `Tabs` in `<file>` stack past two layers.",
|
|
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
|
|
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 pill in a `Section action`, a `Section filter` row, a list, or a drawer.",
|
|
21
21
|
},
|
|
22
22
|
"tabs-in-well": {
|
|
23
23
|
code: "FE_TABS_IN_WELL",
|
|
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
|
-
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
|
|
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, to narrow a list or a region, pass `Tabs kind=\"filter\"` in the `filter` row of its `Section`.",
|
|
26
26
|
},
|
|
27
27
|
"rows-in-card": {
|
|
28
28
|
code: "FE_ROWS_IN_CARD",
|
|
29
29
|
en: "A `DescriptionList` or `DisclosureList` in `<file>` stands with no `Section` or `SurfaceCard` around it.",
|
|
30
|
-
fix: "Key-value and disclosure rows stand in a `
|
|
30
|
+
fix: "Key-value and disclosure rows stand flat in a `Section` (`<Section title ...><DescriptionList isDivided items={...} /></Section>`) or, as the facts of ONE object, in the body of that object's `SurfaceCard`; a plain list of rows is `Section kind=\"list\"`, flat.",
|
|
31
31
|
},
|
|
32
32
|
"surface-card-list": {
|
|
33
33
|
code: "FE_SURFACE_CARD_LIST",
|
|
@@ -37,7 +37,7 @@ export const why = {
|
|
|
37
37
|
"no-card-lead-description": {
|
|
38
38
|
code: "FE_NO_CARD_LEAD_DESCRIPTION",
|
|
39
39
|
en: "A muted `Text` in `<file>` stands directly above a `SurfaceCard` as its description.",
|
|
40
|
-
fix: "A card has no description. Put the line in the row subtitle (
|
|
40
|
+
fix: "A card has no description. Put the line in the row subtitle (a `ListRow` subtitle of a `Section kind=\"list\"`, or an option `description` of a `RadioGroup`), or, when it explains the card's data (a legend, a source, a period), in the card `note`.",
|
|
41
41
|
},
|
|
42
42
|
"no-nested-label": {
|
|
43
43
|
code: "FE_NO_NESTED_LABEL",
|
|
@@ -56,8 +56,8 @@ export const why = {
|
|
|
56
56
|
},
|
|
57
57
|
"card-one-content": {
|
|
58
58
|
code: "FE_CARD_ONE_CONTENT",
|
|
59
|
-
en: "A `SurfaceCard` in `<file>` holds more than one content,
|
|
60
|
-
fix: "A card
|
|
59
|
+
en: "A `SurfaceCard` in `<file>` holds more than one content (a list, facts, a table, a graph, a form).",
|
|
60
|
+
fix: "A card is ONE object. A second list, table, form or graph is not part of it: put each flat in its own `Section` (a ribbon is `Section kind=\"figures\"`); items of the same kind stay in one list.",
|
|
61
61
|
},
|
|
62
62
|
"no-label-description": {
|
|
63
63
|
code: "FE_NO_LABEL_DESCRIPTION",
|
|
@@ -76,13 +76,13 @@ export const why = {
|
|
|
76
76
|
},
|
|
77
77
|
"no-primary-tabs-misuse": {
|
|
78
78
|
code: "FE_GROUPED_CHOICE_CONTROL",
|
|
79
|
-
en: "Primary `Tabs` (or a `
|
|
79
|
+
en: "Primary `Tabs` (a `Section action` or a row `control`) in `<file>` hold a count, an href, an attention mark, one item or more than four items.",
|
|
80
80
|
fix: "Primary tabs switch a mode or period of the same data among two to four short, fixed options. Views, filters with counts and destinations are the secondary (underline) `Tabs`.",
|
|
81
81
|
},
|
|
82
82
|
"no-button-view-switch": {
|
|
83
83
|
code: "FE_GROUPED_CHOICE_CONTROL",
|
|
84
84
|
en: "Buttons carrying `aria-pressed`, `isSelected` or `isActive` stand side by side in `<file>`: joined buttons or pills acting as tabs.",
|
|
85
|
-
fix: "Switching between views or periods of one block is `Tabs` (the primary underline) in the block's `
|
|
85
|
+
fix: "Switching between views or periods of one block is `Tabs` (the primary underline) in the `filter` row of the block's `Section`, or a pill (`Tabs appearance=\"primary\"`) in its `action`; choosing a form value is `ChoiceChips` or `RadioGroup`; a `Button` holds a command, never a selection state.",
|
|
86
86
|
},
|
|
87
87
|
"no-grouped-choice-controls": {
|
|
88
88
|
code: "FE_GROUPED_CHOICE_CONTROL",
|
|
@@ -192,12 +192,12 @@ export const why = {
|
|
|
192
192
|
"no-label-in-grid": {
|
|
193
193
|
code: "FE_LABEL_IN_GRID",
|
|
194
194
|
en: "A `SurfaceCard` with a `label` is repeated in a `Grid kind=\"cards\"` in `<file>`: the label sits outside the material, so the grid reads as headings over boxes.",
|
|
195
|
-
fix: "A peer you recognise and open is a tile: `<SurfaceCard kind=\"tile\" name mark description badge action />`, named inside beside its mark. Comparing a fact across peers is one `Section kind=\"list\"` or a `
|
|
195
|
+
fix: "A peer you recognise and open is a tile: `<SurfaceCard kind=\"tile\" name mark description badge action />`, named inside beside its mark. Comparing a fact across peers is one `Section kind=\"list\"` or a `Section` holding a `DataTable`.",
|
|
196
196
|
},
|
|
197
197
|
"no-raised-surface-in-surface": {
|
|
198
198
|
code: "FE_RAISED_SURFACE_IN_SURFACE",
|
|
199
199
|
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).",
|
|
200
|
-
fix: "Give the content to the outer card's own body
|
|
200
|
+
fix: "Give the content to the outer card's own body; a list, a table or figures inside it stand flat in a `Section` (`Section kind=\"list\"`, `Section kind=\"figures\"`).",
|
|
201
201
|
},
|
|
202
202
|
"no-shell-bottom-tabs": {
|
|
203
203
|
code: "FE_APP_SHELL_BOTTOM_TABS",
|
|
@@ -207,17 +207,22 @@ export const why = {
|
|
|
207
207
|
"surface-in-surface": {
|
|
208
208
|
code: "FE_SURFACE_IN_SURFACE",
|
|
209
209
|
en: "A hand-made row list (a Stack, ul, ol or div whose rows are divided by `Divider`) in `<file>` stands inside a SurfaceCard, Drawer, Dialog, PaneSection or main-rail rail.",
|
|
210
|
-
fix: "Use `<Section kind=\"list\">` with `ListRow` rows: the Grammar draws one list wherever it stands, flat rows divided by hairlines and aligned with the title (a card around a lone list is refused by `
|
|
210
|
+
fix: "Use `<Section kind=\"list\">` with `ListRow` rows: the Grammar draws one list wherever it stands, flat rows divided by hairlines and aligned with the title (a card around a lone list is refused by `card-is-object`).",
|
|
211
211
|
},
|
|
212
|
-
"
|
|
213
|
-
code: "
|
|
214
|
-
en: "A `SurfaceCard` in `<file>`
|
|
215
|
-
fix: "Drop the card
|
|
212
|
+
"card-is-object": {
|
|
213
|
+
code: "FE_CARD_IS_OBJECT",
|
|
214
|
+
en: "A `SurfaceCard` in `<file>` holds only a collection, a form or a placeholder (a `DataTable`, a `Section`, a `DescriptionList`, a `DisclosureList`, a `Form` or a lone field, an `EmptyNotice`, `Markdown`, a chart): a card is one object.",
|
|
215
|
+
fix: "Drop the card and stand the content flat: a table is `<Section title ...><DataTable .../></Section>`, a list `Section kind=\"list\"`, facts `<Section title ...><DescriptionList isDivided items={...} /></Section>`, disclosures `<Section title ...><DisclosureList .../></Section>`, a form or field `<Section title ...><Form .../></Section>`, an empty state an `EmptyNotice` on its own, markdown or a chart a `Section`. A card keeps an object's name and facts beside a control; a sign-in form with no page around it keeps `measure=\"formCompact\"`.",
|
|
216
|
+
},
|
|
217
|
+
"data-table-surface": {
|
|
218
|
+
code: "FE_DATA_TABLE_SURFACE",
|
|
219
|
+
en: "A `DataTable` in `<file>` carries a `surface` prop: it was removed in the Grammar family 0.45.0, a table has one flat look.",
|
|
220
|
+
fix: "Delete the `surface` attribute (the rule fixes it in place) and put the table under its `Section`: `<Section title ...><DataTable .../></Section>`.",
|
|
216
221
|
},
|
|
217
222
|
"surface-card-kind": {
|
|
218
223
|
code: "FE_SURFACE_CARD_KIND",
|
|
219
|
-
en: "A `body` SurfaceCard in `<file>` holds a hand-built list, a Divider, a SectionHeader or Heading as a second title
|
|
220
|
-
fix: "Rows are a `Section kind=\"list\"` (never a card), key figures `kind=\"figures\"`,
|
|
224
|
+
en: "A `body` SurfaceCard in `<file>` holds a hand-built list, a Divider, or a SectionHeader or Heading as a second title.",
|
|
225
|
+
fix: "Rows are a `Section kind=\"list\"` (never a card), key figures `Section kind=\"figures\"`, a band of commands at the card's foot is `actions`, a filter or search row the `filter` of a `Section`; the card's title is its `label`, a second subject its own `Section`.",
|
|
221
226
|
},
|
|
222
227
|
"status-text-uses-soft-foreground": {
|
|
223
228
|
code: "FE_STYLE_TOKEN_ONLY",
|
|
@@ -262,7 +267,7 @@ export const why = {
|
|
|
262
267
|
"message-surfaces": {
|
|
263
268
|
code: "FE_MESSAGE_SURFACES",
|
|
264
269
|
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`.",
|
|
265
|
-
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 `
|
|
270
|
+
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 message card's replies are `Section kind=\"list\" layout=\"suggestions\"`.",
|
|
266
271
|
},
|
|
267
272
|
"suggestion-buttons": {
|
|
268
273
|
code: "FE_SUGGESTION_BUTTONS",
|
|
@@ -3,8 +3,8 @@ import { elementNameOf, grammarName, renderedChildren, stringProp } from "./lib/
|
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
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 (`
|
|
7
|
-
*
|
|
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 (a `ListRow` subtitle of a
|
|
7
|
+
* `Section kind="list"`, or an option `description` of a `RadioGroup`). A free-standing muted line placed directly above a card (the title + description + card pattern) is the same description drawn by hand.
|
|
8
8
|
*
|
|
9
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
10
|
*
|
|
@@ -24,7 +24,7 @@ export const noCardLeadDescription = defineRule({
|
|
|
24
24
|
docs: { description: "CARD-NO-DESCRIPTION: a card has no lead description; the line goes in a row subtitle or the card `note`." },
|
|
25
25
|
schema: [],
|
|
26
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 (`
|
|
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 (a `ListRow` subtitle of a `Section kind=\"list\"`, or an option `description` of a `RadioGroup`) or, if it explains the card's data (a legend, a source, a period), in the card `note`.",
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
create(context) {
|
package/dist/rows-in-card.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
|
-
/**
|
|
2
|
+
/** Key-value and disclosure rows stand in a `Section` or in an object card. */
|
|
3
3
|
export declare const rowsInCard: Rule.RuleModule;
|
|
4
4
|
/** The rules this law contributes to the plugin. */
|
|
5
5
|
export declare const rules: Record<string, Rule.RuleModule>;
|