@starci/eslint-grammar-core 0.43.1 → 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 +17 -0
- package/README.md +4 -2
- package/dist/app-shell.js +30 -10
- 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 +26 -21
- 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 -2
- package/dist/tabs.js +26 -19
- package/docs/app-shell.md +5 -2
- 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 +26 -5
- package/package.json +3 -3
- package/runtime/knowledge/ui/presentation/grammar-laws.yaml +33 -23
- package/dist/single-child-card.js +0 -90
- package/docs/single-child-card.md +0 -37
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# A card is one object
|
|
2
|
+
|
|
3
|
+
Law module: `card-is-object.ts`. Finding code: `FE_CARD_IS_OBJECT`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#CARD-OBJECT`.
|
|
4
|
+
|
|
5
|
+
A `SurfaceCard` is ONE object: a customer, an agent, a provider, a plan, a message, an approval, a dialog or an overlay. Its body holds the object's name, its facts and a control. A collection (a list, a table, facts, figures, disclosures, a choice), a form and a placeholder stand flat: in a `Section`, or on their own. The Grammar family 0.45.0 removed the card kinds `table`, `details`, `figures`, `accordion` and `select`; this rule refuses the same shapes written as the body of a card.
|
|
6
|
+
|
|
7
|
+
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
|
+
|
|
9
|
+
## `starci-grammar/card-is-object`
|
|
10
|
+
|
|
11
|
+
A Grammar `SurfaceCard` of the body kind (no `kind`, or `kind="body"`) whose ONLY content is one of the following, looked through fragments, `cond && x`, `cond ? x : y`, `.map`, and the layout wrappers `Stack`, `Cluster`, `Inline`, `Grid` and a plain `div` (message `collection`, which names the replacement):
|
|
12
|
+
|
|
13
|
+
| Only content | Stands instead |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `DataTable` | `<Section title ...><DataTable .../></Section>` |
|
|
16
|
+
| `Section` of any kind | the `Section` alone, no card around it |
|
|
17
|
+
| `DescriptionList` | `<Section title ...><DescriptionList isDivided items={...} /></Section>` |
|
|
18
|
+
| `DisclosureList`, `Accordion` | `<Section title ...><DisclosureList items={...} /></Section>` |
|
|
19
|
+
| `Form`, `Fieldset`, `Input`, `Textarea`, `Select`, `ComboBox`, `SearchField`, `NumberField`, `RadioGroup`, `CheckboxGroup` | `<Section title ...><Form .../></Section>` |
|
|
20
|
+
| `EmptyNotice` | the `EmptyNotice` on its own |
|
|
21
|
+
| `Markdown`, `MarkdownArticle` | `<Section title ...><Markdown .../></Section>` |
|
|
22
|
+
| `BarChart`, `LineChart`, `Sparkline`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram` | `<Section title ...><BarChart .../></Section>` |
|
|
23
|
+
|
|
24
|
+
Not flagged: 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 content (an object's name or facts beside a control is an object), a card with a JSX spread, a `kind` that is not a literal, a non-Grammar `SurfaceCard`, and non-product source. `Meter`, `Progress`, `Timeline` and `ListBox` are not in the table. There is no autofix: the card's `label` becomes the `Section` title, which the author reads.
|
|
25
|
+
|
|
26
|
+
**Invalid**
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
<SurfaceCard label="Runs"><DataTable columns={columns} rows={runs} /></SurfaceCard>
|
|
30
|
+
<SurfaceCard label="Profile"><Form onSubmit={save}><Input label="Name" /></Form></SurfaceCard>
|
|
31
|
+
<SurfaceCard><EmptyNotice title="No runs" /></SurfaceCard>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Valid**
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<Section title="Runs"><DataTable columns={columns} rows={runs} /></Section>
|
|
38
|
+
<SurfaceCard label="Agent"><DescriptionList items={facts} /><Button>Pause</Button></SurfaceCard>
|
|
39
|
+
<SurfaceCard measure="formCompact" label="Sign in"><Form onSubmit={signIn}><Input label="Email" /></Form></SurfaceCard>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/docs/choice-controls.md
CHANGED
|
@@ -8,10 +8,10 @@ Every rule below is an error in `coreGrammarConfig`; none can be switched off or
|
|
|
8
8
|
|
|
9
9
|
## Which component switches what
|
|
10
10
|
|
|
11
|
-
- `Tabs` switches the views or periods of one block, or filters its list: the primary underline, `kind="filter"` in the
|
|
11
|
+
- `Tabs` switches the views or periods of one block, or filters its list: the primary underline, `kind="filter"` in the `filter` row of the block's `Section`, one line under the strip.
|
|
12
12
|
- `ChoiceChips` or `RadioGroup` chooses a value of a form.
|
|
13
13
|
- A `Button` holds a command, never a selection state; a `ButtonGroup` holds commands only.
|
|
14
|
-
- A switch between modes or periods of one block ("This month / Last month", "Day / Week / Month", "List / Board") is `Tabs appearance="primary"` in the
|
|
14
|
+
- A switch between modes or periods of one block ("This month / Last month", "Day / Week / Month", "List / Board") is `Tabs appearance="primary"` in the `action` of the block's `Section`.
|
|
15
15
|
- Two joined buttons or pills acting as tabs are banned. `SegmentedControl` is removed.
|
|
16
16
|
|
|
17
17
|
## `starci-grammar/no-button-view-switch`
|
|
@@ -30,12 +30,12 @@ Finding code: `FE_GROUPED_CHOICE_CONTROL` (R380). Two or more adjacent `Button`
|
|
|
30
30
|
**Valid**
|
|
31
31
|
|
|
32
32
|
```tsx
|
|
33
|
-
<
|
|
33
|
+
<Section title="Cash" action={<Tabs appearance="primary" label="Period" items={periods} selectedKey={period} onSelect={setPeriod} />}><DataTable label="Cash" columns={columns} rows={rows} renderCell={renderCell} emptyContent={empty} /></Section>
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
## `starci-grammar/no-primary-tabs-misuse`
|
|
37
37
|
|
|
38
|
-
Finding code: `FE_GROUPED_CHOICE_CONTROL` (R380). `Tabs appearance="primary"` (HeroUI's primary variant, a pill in a track)
|
|
38
|
+
Finding code: `FE_GROUPED_CHOICE_CONTROL` (R380). `Tabs appearance="primary"` (HeroUI's primary variant, a pill in a track) in a `Section action` switch a mode or period of the same data among two to four short, fixed options. An `items` array literal with an item carrying `count`, `href` or `isAttention`, with one item, or with more than four items is a finding; views, filters with counts and destinations are the secondary (underline) `Tabs`. Grammar also refuses these at run time in development, and its types refuse them.
|
|
39
39
|
|
|
40
40
|
## `starci-grammar/no-grouped-choice-controls`
|
|
41
41
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# A table has one flat look
|
|
2
|
+
|
|
3
|
+
Law module: `data-table-surface.ts`. Finding code: `FE_DATA_TABLE_SURFACE`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#DATA-TABLE-SURFACE`.
|
|
4
|
+
|
|
5
|
+
A `DataTable` has one flat look: no frame, no card, no fill; its title is the `Section` it stands under. The Grammar family 0.45.0 removed its `surface` prop (`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 pinned older Grammar, a JavaScript file, an `any` prop).
|
|
6
|
+
|
|
7
|
+
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
|
+
|
|
9
|
+
## `starci-grammar/data-table-surface`
|
|
10
|
+
|
|
11
|
+
A Grammar `DataTable` (named or `G.DataTable`) with a `surface` attribute, whatever its value (message `surface`). A `surface` on another component (`Pane surface`), a non-Grammar `DataTable` and non-product source are not read.
|
|
12
|
+
|
|
13
|
+
AUTOFIX (`fixable: "code"`): the attribute and the whitespace before it are removed; the table keeps its columns, rows and `footer`.
|
|
14
|
+
|
|
15
|
+
**Invalid**
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
<DataTable label="Runs" surface="card" columns={columns} rows={runs} />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Valid**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
<Section title="Runs"><DataTable label="Runs" columns={columns} rows={runs} /></Section>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/docs/layout-two-axis.md
CHANGED
|
@@ -19,14 +19,14 @@ A Grammar `Grid` or `Cluster` is a finding when its rendered children are:
|
|
|
19
19
|
|
|
20
20
|
```tsx
|
|
21
21
|
<Grid><SurfaceCard label="Runs" /><Stack><SurfaceCard label="A" /><SurfaceCard label="B" /></Stack></Grid>
|
|
22
|
-
<Cluster><SurfaceCard
|
|
22
|
+
<Cluster><SurfaceCard label="Plan" /><SurfaceCard label="Usage" /></Cluster>
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
**Valid**
|
|
26
26
|
|
|
27
27
|
```tsx
|
|
28
|
-
<Stack gap="section"><SurfaceCard
|
|
29
|
-
<Cluster><SurfaceCard kind="
|
|
28
|
+
<Stack gap="section"><SurfaceCard label="Plan">...</SurfaceCard><SurfaceCard label="Runs">...</SurfaceCard></Stack>
|
|
29
|
+
<Cluster><SurfaceCard kind="tile" name="Mail" mark={mail} /><SurfaceCard kind="tile" name="Chat" mark={chat} /></Cluster>
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
|
@@ -13,13 +13,13 @@ A Grammar `Text` with `tone="muted"` written immediately before a Grammar `Surfa
|
|
|
13
13
|
**Invalid**
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
|
-
<Stack><Heading level={3}>General</Heading><Text tone="muted">Choose how the agent works.</Text><SurfaceCard
|
|
16
|
+
<Stack><Heading level={3}>General</Heading><Text tone="muted">Choose how the agent works.</Text><SurfaceCard label="Mode" ... /></Stack>
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
**Valid**
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
<
|
|
22
|
+
<Section title="Mode"><RadioGroup label="Mode" isLabelHidden options={[{ value: "auto", label: "Automatic", description: "The agent answers at once; you review later." }]} ... /></Section>
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/docs/no-nested-label.md
CHANGED
|
@@ -14,7 +14,7 @@ A Grammar `Section` with `title`, or a `SurfaceCard` with `label`, whose JSX anc
|
|
|
14
14
|
|
|
15
15
|
```tsx
|
|
16
16
|
<Section title="What the assistant knows">
|
|
17
|
-
<SurfaceCard
|
|
17
|
+
<SurfaceCard label="Allowed">...</SurfaceCard>
|
|
18
18
|
</Section>
|
|
19
19
|
```
|
|
20
20
|
|
|
@@ -22,8 +22,8 @@ A Grammar `Section` with `title`, or a `SurfaceCard` with `label`, whose JSX anc
|
|
|
22
22
|
|
|
23
23
|
```tsx
|
|
24
24
|
<Section title="What the assistant knows">
|
|
25
|
-
<SurfaceCard
|
|
26
|
-
<SurfaceCard
|
|
25
|
+
<SurfaceCard sublabel="Allowed">...</SurfaceCard>
|
|
26
|
+
<SurfaceCard sublabel="Ask first">...</SurfaceCard>
|
|
27
27
|
</Section>
|
|
28
28
|
```
|
|
29
29
|
|
package/docs/rows-in-card.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
# Key-value and disclosure rows stand in a
|
|
1
|
+
# Key-value and disclosure rows stand in a section or an object card
|
|
2
2
|
|
|
3
3
|
Law module: `rows-in-card.ts`. Finding code: `FE_ROWS_IN_CARD`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#ROWS-IN-CARD`.
|
|
4
4
|
|
|
5
|
-
Key-value rows (`DescriptionList`) and disclosure rows (`DisclosureList`) stand in a `
|
|
5
|
+
Key-value rows (`DescriptionList`) and disclosure rows (`DisclosureList`) stand in a `Section` (the facts or the disclosures of a collection, flat on the surface: `<Section title ...><DescriptionList isDivided items={...} /></Section>`) or in the body of an object card (the facts of ONE object beside its name or a control). A plain list of rows is a flat `Section kind="list"` (LIST-ONE-LOOK, `surface-card-list`). A card whose only content is the rows is `card-is-object`.
|
|
6
6
|
|
|
7
7
|
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
8
|
|
|
9
9
|
## `starci-grammar/rows-in-card`
|
|
10
10
|
|
|
11
|
-
A Grammar `DescriptionList` or `DisclosureList` that no `SurfaceCard
|
|
11
|
+
A Grammar `DescriptionList` or `DisclosureList` that no `SurfaceCard` or `Section` of the same file encloses (message `bare`). A row primitive passed as a JSX attribute value is judged where the receiver draws it. `ListBox` (a navigation list or menu) is not read.
|
|
12
12
|
|
|
13
13
|
**Invalid**
|
|
14
14
|
|
|
@@ -19,7 +19,8 @@ A Grammar `DescriptionList` or `DisclosureList` that no `SurfaceCard`, `Section`
|
|
|
19
19
|
**Valid**
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
<
|
|
22
|
+
<Section title="Details"><DescriptionList isDivided items={items} /></Section>
|
|
23
|
+
<SurfaceCard label="Agent"><DescriptionList items={items} /><Button>Pause</Button></SurfaceCard>
|
|
23
24
|
```
|
|
24
25
|
|
|
25
26
|
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
|
@@ -13,8 +13,7 @@ Every rule below is an error in `coreGrammarConfig`; none can be switched off or
|
|
|
13
13
|
|
|
14
14
|
A Grammar `SurfaceCard` whose `kind` is the literal `"list"` (message `list`). A `kind` that is not a literal is left to the compiler.
|
|
15
15
|
|
|
16
|
-
There is no autofix: `label` becomes `title` and `labelEnd` becomes `action`, the
|
|
17
|
-
is the list's `filter`; figures and a list together are a body card holding both), the import changes, and the look changes from a
|
|
16
|
+
There is no autofix: `label` becomes `title` and `labelEnd` becomes `action`, a filter or search is the list's `filter`, the import changes, and the look changes from a
|
|
18
17
|
card to flat rows.
|
|
19
18
|
|
|
20
19
|
**Invalid**
|
package/docs/surface-card.md
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# A card is one object
|
|
2
2
|
|
|
3
3
|
Law module: `surface-card.ts`. Catalogue: R355 FE_SURFACE_CARD_KIND, R366 FE_LABEL_IN_GRID.
|
|
4
4
|
|
|
5
|
-
`SurfaceCard` is one component whose `kind` the compiler checks: `body` (the default), `
|
|
6
|
-
and `tile`; any kind may carry typed `headers` and `footers` zones. What a kind draws is not drawn by hand around it, and where the name sits follows the kind: a card that heads a section has a `label` outside the material, a tile names itself inside.
|
|
5
|
+
`SurfaceCard` is one component whose `kind` the compiler checks: `body` (the default) and `tile`. A card is ONE object (a customer, an agent, a plan, a message), a dialog or an overlay; a body card holds the object's name, facts and commands (`actions`). A collection stands flat in a `Section`: a list is `Section kind="list"`, figures `Section kind="figures"`, a filter or search row the `filter` of a `Section`. What a `Section` draws is not drawn by hand in a card, and where the name sits follows the kind: a body card has a `label` outside the material, a tile names itself inside.
|
|
7
6
|
|
|
8
7
|
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline. It applies to product
|
|
9
8
|
source; a script or a file no slot owns is not judged.
|
|
@@ -12,11 +11,8 @@ source; a script or a file no slot owns is not judged.
|
|
|
12
11
|
|
|
13
12
|
Finding code: `FE_SURFACE_CARD_KIND` (R355). The direct children of a `SurfaceCard` of the `body` kind (no `kind`, or
|
|
14
13
|
`kind="body"`) are not a raw `ul`, `ol`, `li` or `dl`, not a `Divider`, and not a `SectionHeader` or `Heading` standing as a
|
|
15
|
-
second title.
|
|
14
|
+
second title. Children are read through
|
|
16
15
|
`cond && <x/>`, `cond ? <x/> : <y/>` and `.map`.
|
|
17
|
-
On a `SurfaceCard` or a `Board`, the `children` of a `{ kind: "custom" }` zone written in a `headers` or `footers` array literal hold no
|
|
18
|
-
`Tabs`, `SearchField` or `Divider` (`zone`): filter and search are the typed `filter`, `search` and `toolbar` zones and the card draws
|
|
19
|
-
its own seams. Grammar also refuses them at run time in development.
|
|
20
16
|
|
|
21
17
|
**Invalid** (`src/components/blocks/Runs/component.tsx`)
|
|
22
18
|
|
|
@@ -38,7 +34,7 @@ its own seams. Grammar also refuses them at run time in development.
|
|
|
38
34
|
|
|
39
35
|
Finding code: `FE_LABEL_IN_GRID` (R366). A `SurfaceCard` with a `label` repeated in a `Grid kind="cards"` (two or more as
|
|
40
36
|
direct children, or one written in a `.map`) is refused. A peer you recognise and open is a tile, named inside beside its
|
|
41
|
-
mark; comparing a fact across peers is one `Section kind="list"` or a `
|
|
37
|
+
mark; comparing a fact across peers is one `Section kind="list"` or a `Section` holding a `DataTable`.
|
|
42
38
|
|
|
43
39
|
**Invalid** (`src/components/blocks/Connectors/component.tsx`)
|
|
44
40
|
|
package/docs/surface-depth.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Law module: `surface-depth.ts`. Catalogue: R340 FE_RAISED_SURFACE_IN_SURFACE.
|
|
4
4
|
|
|
5
|
-
A `SurfaceCard` inside another `SurfaceCard` is refused
|
|
5
|
+
A `SurfaceCard` inside another `SurfaceCard` is refused: a card never sits in a card. A white `Pane surface`, `Drawer`, `Dialog`, `AlertDialog` or `Popover` may hold an object card, drawn as everywhere: a 1px `--border` edge and no shadow (BOUNDARY-6). Development throws the card-in-card refusal from the Grammar itself; this rule is its same-file half and R356 closes it across files.
|
|
6
6
|
|
|
7
7
|
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline. It applies to product
|
|
8
8
|
source (the route, feature, component, hook, foundation, module and transport tiers and the workspace packages); a script or
|
|
@@ -10,7 +10,7 @@ a file no slot owns is not judged.
|
|
|
10
10
|
|
|
11
11
|
## `starci-grammar/no-raised-surface-in-surface`
|
|
12
12
|
|
|
13
|
-
A `SurfaceCard` (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that another `SurfaceCard` of the same file encloses is a finding. A card no element of the file encloses is judged where its parent is written. The fix gives the content to the outer card's own body, or
|
|
13
|
+
A `SurfaceCard` (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that another `SurfaceCard` of the same file encloses is a finding. A card no element of the file encloses is judged where its parent is written. The fix gives 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"`).
|
|
14
14
|
|
|
15
15
|
**Invalid** (`src/components/blocks/Runs/component.tsx`)
|
|
16
16
|
|
|
@@ -23,11 +23,10 @@ A `SurfaceCard` (or `<ns>.SurfaceCard`) imported from `@starci/grammar` that ano
|
|
|
23
23
|
**Valid** (`src/components/blocks/Runs/component.tsx`)
|
|
24
24
|
|
|
25
25
|
```tsx
|
|
26
|
-
<SurfaceCard
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/>
|
|
26
|
+
<SurfaceCard label="Run">
|
|
27
|
+
<Text>{summary}</Text>
|
|
28
|
+
<Section kind="list" ariaLabel="Steps" items={steps} empty={empty} />
|
|
29
|
+
</SurfaceCard>
|
|
31
30
|
```
|
|
32
31
|
|
|
33
32
|
**Finding code:** `FE_RAISED_SURFACE_IN_SURFACE`
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Law module: `surface-in-surface.ts`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#SURFACE-IN-SURFACE`. Finding code: `FE_SURFACE_IN_SURFACE`.
|
|
4
4
|
|
|
5
|
-
Rows inside a
|
|
5
|
+
Rows inside a drawer, a dialog, a pane band or a rail are a `Section kind="list"`, drawn as everywhere else: flat rows divided by hairlines, aligned with the title (LIST-ONE-LOOK). A hand-made row list is the bare form.
|
|
6
6
|
|
|
7
7
|
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
8
|
|
|
@@ -22,7 +22,7 @@ A Grammar `Stack`, or a `ul`, `ol` or `div`, whose rendered children include a G
|
|
|
22
22
|
|
|
23
23
|
```tsx
|
|
24
24
|
<Drawer title="Runs"><Section kind="list" items={runs} /></Drawer>
|
|
25
|
-
<
|
|
25
|
+
<Stack><Section kind="figures" ariaLabel="Totals" items={totals} /><Section kind="list" title="Runs" items={runs} empty={null} /></Stack>
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/docs/tabs.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Tabs: where the pill stands, and how many layers
|
|
2
2
|
|
|
3
|
-
Law module: `tabs.ts`. Knowledge: `grammar-laws.yaml` `TABS-SWITCH-ZONE`, `TABS-DEPTH`. Component law: `contexts/ui/components/tabs.md`.
|
|
3
|
+
Law module: `tabs.ts`. Knowledge: `grammar-laws.yaml` `TABS-SWITCH-ZONE`, `TABS-DEPTH`, `TABS-IN-WELL`. Component law: `contexts/ui/components/tabs.md`.
|
|
4
4
|
|
|
5
|
-
Underline tabs switch panels: the page tabs (`Page header.tabs`) and, inside a tab's panel, a region set. The pill (`appearance="primary"`) is a different thing: a mode or period switch of one block's data.
|
|
5
|
+
Underline tabs switch panels: the page tabs (`Page header.tabs`) and, inside a tab's panel, a region set. The pill (`appearance="primary"`) is a different thing: a mode or period switch of one block's data. The three rules are errors in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
6
6
|
|
|
7
7
|
## `starci-grammar/tabs-switch-zone`
|
|
8
8
|
|
|
9
|
-
Finding code: `FE_TABS_SWITCH_ZONE`. A `<Tabs appearance="primary">` written in JSX is a finding wherever it stands (a page body, under the page tabs, a pane, a drawer). The pill
|
|
9
|
+
Finding code: `FE_TABS_SWITCH_ZONE`. A `<Tabs appearance="primary">` written in JSX is a finding wherever it stands (a page body, under the page tabs, a pane, a drawer). The pill stands as the `action` of the block's `Section` (`action={<Tabs appearance="primary" ... />}`) and, since 0.37.16, as the value of a row `control` (an object property named `control` in a list row literal, or a JSX attribute `control={...}`, directly or through a fragment, conditional or `&&`): a row-level mode choice such as "Auto | Ask" lives in the row. The item checks (two to four options, no `count`, `href` or `isAttention`) stay in `no-primary-tabs-misuse` (R380).
|
|
10
10
|
|
|
11
11
|
**Invalid**
|
|
12
12
|
|
|
@@ -19,8 +19,8 @@ Finding code: `FE_TABS_SWITCH_ZONE`. A `<Tabs appearance="primary">` written in
|
|
|
19
19
|
**Valid**
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
<
|
|
23
|
-
<
|
|
22
|
+
<Section kind="list" title="Agent" items={[{ id: "send", title: "Send", control: <Tabs appearance="primary" label="Send" items={modes} selectedKey={mode} onSelect={setMode} /> }]} empty={null} />
|
|
23
|
+
<Section title="Cash" action={<Tabs appearance="primary" label="Period" items={periods} selectedKey={period} onSelect={setPeriod} />}><DataTable label="Cash" columns={columns} rows={rows} renderCell={renderCell} emptyContent={empty} /></Section>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
## `starci-grammar/tabs-depth`
|
|
@@ -47,3 +47,24 @@ Finding code: `FE_TABS_DEPTH`. Over the underline `Tabs` of one file. Every tab
|
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
The rule reads one file. A set whose page tabs are drawn by another file (a layout, or a frame component such as a renderer package) is not judged against them: that link is runtime composition, not an import the rule can follow.
|
|
50
|
+
|
|
51
|
+
## `starci-grammar/tabs-in-well`
|
|
52
|
+
|
|
53
|
+
Finding code: `FE_TABS_IN_WELL`. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection` stands loose on the pink well or in a pane body: the second layer is `Page header.subTabs`. A `Tabs` stands in a header row of its own, and passes, as `kind="filter"`, in the `filter` row of a `Section` (a list's or a region's alike, 0.43.1, `contexts/ui/components/list-table.md` "Filter row"), directly or through a fragment, conditional or `&&`. A `Drawer`, `Dialog`, `Modal`, `Popover` or `Sheet` starts its own surface and ends the climb.
|
|
54
|
+
|
|
55
|
+
**Invalid**
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<Page header={{ title, tabs }}>
|
|
59
|
+
<Tabs label="Status" items={statuses} selectedKey={status} onSelect={setStatus} />
|
|
60
|
+
<Section title="Catalog" filter={<Tabs label="Views" items={views} selectedKey={view} onSelect={setView} />}>{body}</Section>
|
|
61
|
+
</Page>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Valid**
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
<Page header={{ title }}>
|
|
68
|
+
<Section kind="list" title="Topics" items={rows} empty={empty} filter={<><Tabs label="Level" kind="filter" items={levels} selectedKey={level} onSelect={setLevel} /><SearchField label="Search" /></>} />
|
|
69
|
+
</Page>
|
|
70
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/eslint-grammar-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "ESLint rules for the core Grammar's component, token and composition contracts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
69
69
|
"typescript": "^6.0.3"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
72
|
-
"starciSource": "
|
|
71
|
+
"gitHead": "fe7bc440d0a16a1065ce25e74a37928c826ca7ed",
|
|
72
|
+
"starciSource": "bdee448048ec6c2a121a4b6da7f4838fa0fae3bda7165468b4794a8439f5f4fe"
|
|
73
73
|
}
|
|
@@ -142,14 +142,14 @@ rules:
|
|
|
142
142
|
assert: |-
|
|
143
143
|
Its title is plain text; the row is the one pressable.
|
|
144
144
|
- id: TABS-SWITCH-ZONE
|
|
145
|
-
title: The pill is the
|
|
145
|
+
title: The pill is the action of a Section
|
|
146
146
|
governs: Tabs appearance="primary".
|
|
147
147
|
cases:
|
|
148
148
|
- id: case-1
|
|
149
149
|
when: A mode or period of one block's data is switched among two to four short options
|
|
150
150
|
assert: |-
|
|
151
|
-
It is the
|
|
152
|
-
with no count and no href. A pill written in JSX in a page body, under the page tabs, in a pane or in a drawer
|
|
151
|
+
It is the `action` of the block's `Section` (`<Section title action={<Tabs appearance="primary" label items selectedKey onSelect />} />`),
|
|
152
|
+
with no count and no href; a row-level mode choice is the `control` of its row. A pill written in JSX in a page body, under the page tabs, in a pane or in a drawer
|
|
153
153
|
is refused: views of a page are page tabs, views or filters inside a region are underline `Tabs`.
|
|
154
154
|
- id: TABS-DEPTH
|
|
155
155
|
title: A page stacks two underline layers at most
|
|
@@ -169,7 +169,8 @@ rules:
|
|
|
169
169
|
assert: |-
|
|
170
170
|
It is `Page header.subTabs`: inside the white header band, under layer 1, on its own full-width separator, the same size as layer 1
|
|
171
171
|
(14, 40 high, selected weight 500, the 2px underline exactly on the separator) and flush with the band's left inset, the same x as layer 1.
|
|
172
|
-
An underline Tabs written in the body of a Page, Pane or PaneSection (the pink well, a pane body) is refused
|
|
172
|
+
An underline Tabs written loose in the body of a Page, Pane or PaneSection (the pink well, a pane body) is refused; one in a header row of
|
|
173
|
+
its own, kind="filter" in a Section's filter row, is not loose.
|
|
173
174
|
- id: LINK-LOOK
|
|
174
175
|
title: A Link is HeroUI's own link and takes its size from the line
|
|
175
176
|
governs: The look of a Grammar Link.
|
|
@@ -180,14 +181,14 @@ rules:
|
|
|
180
181
|
It is HeroUI v3's link: the primary colour, the underline on hover only, the anchor icon at the end. Its type size and leading are
|
|
181
182
|
inherited (14 in a body, 12 in meta or caption text). A size prop, a size class and an underline or decoration class are refused.
|
|
182
183
|
- id: ROWS-IN-CARD
|
|
183
|
-
title: Key-value and disclosure rows stand in a
|
|
184
|
-
governs: Key-value and disclosure rows
|
|
184
|
+
title: Key-value and disclosure rows stand in a section or an object card
|
|
185
|
+
governs: Key-value and disclosure rows (a plain list of rows is LIST-ONE-LOOK).
|
|
185
186
|
cases:
|
|
186
187
|
- id: case-1
|
|
187
188
|
when: A DescriptionList or DisclosureList is drawn
|
|
188
189
|
assert: |-
|
|
189
|
-
It stands in a Section
|
|
190
|
-
|
|
190
|
+
It stands flat in a Section (`<Section title ...><DescriptionList isDivided items={...} /></Section>`) or, as the facts of ONE object, in the body of that object's
|
|
191
|
+
SurfaceCard. A row primitive with neither around it is refused. ListBox is a navigation list and is not read.
|
|
191
192
|
- id: CARD-NO-DESCRIPTION
|
|
192
193
|
title: A card has no description
|
|
193
194
|
governs: The head of a SurfaceCard and the line above it.
|
|
@@ -196,7 +197,7 @@ rules:
|
|
|
196
197
|
when: A card is drawn with a label
|
|
197
198
|
assert: |-
|
|
198
199
|
The head is the label, a count chip, one fact and one end action; SurfaceCard has no description or subtitle prop. A muted Text written directly above a
|
|
199
|
-
SurfaceCard as its description is refused: the line is a row subtitle (a
|
|
200
|
+
SurfaceCard as its description is refused: the line is a row subtitle (a ListRow subtitle of a Section list, or an option description of a RadioGroup) or, when it explains the card's data, the card note.
|
|
200
201
|
- id: LABEL-SUBLABEL-HIERARCHY
|
|
201
202
|
title: One Label per section; nested groups use a Sublabel
|
|
202
203
|
governs: The Label of a Section or SurfaceCard and the Sublabel of the groups inside it.
|
|
@@ -227,21 +228,20 @@ rules:
|
|
|
227
228
|
The chip is grey; it is pink only when the number is work waiting for the owner (`isAttention`: to handle, to approve, an error). Page tabs
|
|
228
229
|
(layers 1 and 2) hide the chip when the count is 0; filter tabs inside a table or list show a grey 0.
|
|
229
230
|
- id: CARD-ONE-CONTENT
|
|
230
|
-
title: One
|
|
231
|
+
title: One object per card; every card is white with a 1px border
|
|
231
232
|
governs: A SurfaceCard's content and its edge.
|
|
232
233
|
cases:
|
|
233
234
|
- id: case-1
|
|
234
235
|
when: A card is written
|
|
235
236
|
assert: |-
|
|
236
|
-
A card
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
(a FlowGraph's kinds) stands under the card as chips.
|
|
237
|
+
A card is ONE object (a customer, an agent, a plan, a message): its name, its facts and its commands (`actions`). A second list, table, form or graph is not part of it: it stands
|
|
238
|
+
flat in its own Section (a ribbon is `Section kind="figures"`); items of the same kind stay in one list. A card inside a card is refused. A label has no description under it:
|
|
239
|
+
the description is a caption under the card (Section caption, SurfaceCard note), and a legend (a FlowGraph's kinds) stands under the card as chips.
|
|
240
240
|
- id: case-2
|
|
241
241
|
when: A surface is painted
|
|
242
242
|
assert: |-
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
Every card is white with a 1px `--border` edge, the card radius and no shadow, on every ground (the pink well, a Pane surface, the aside, a Drawer, a Dialog, a Popover). The Grammar
|
|
244
|
+
draws it; an app never chooses. A FlowGraph inside a card draws no frame of its own.
|
|
245
245
|
- id: ICONS-OUTLINE
|
|
246
246
|
title: Icons are outline only; a tile marks a standalone icon
|
|
247
247
|
governs: Every icon Grammar and an app draw.
|
|
@@ -253,16 +253,26 @@ rules:
|
|
|
253
253
|
row, a card, an empty state or a graph step gets an icon tile (a soft-tone square holding an outline icon). An icon INLINE with text (a status beside a
|
|
254
254
|
label, a search field, a button start icon, a link arrow, meta) is a plain outline icon at text size with no tile. A status (done, running, failed, waiting,
|
|
255
255
|
skipped) is a tone-coloured outline icon with no tile: outline check-circle in success, x-circle in danger, a spinning arrow for running.
|
|
256
|
-
- id:
|
|
257
|
-
title: A
|
|
258
|
-
governs: A SurfaceCard
|
|
256
|
+
- id: CARD-OBJECT
|
|
257
|
+
title: A card is one object; a collection, a form or a placeholder stands flat
|
|
258
|
+
governs: A SurfaceCard of the body kind and what it holds.
|
|
259
259
|
cases:
|
|
260
260
|
- id: case-1
|
|
261
|
-
when: A
|
|
261
|
+
when: A body SurfaceCard holds ONE content and that content is a DataTable, a Section (any kind), a DescriptionList, a DisclosureList or Accordion, a Form, Fieldset or lone field, an EmptyNotice, Markdown or MarkdownArticle, or a chart (BarChart, LineChart, Sparkline, ProportionBar, BubbleMap, FlowGraph, MermaidDiagram)
|
|
262
262
|
assert: |-
|
|
263
|
-
A
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
A card is ONE object (a customer, an agent, a provider, a plan, a message, an approval), a dialog or an overlay; a collection, a form and a placeholder are never in a card.
|
|
264
|
+
A table is `<Section title ...><DataTable .../></Section>`, a list `Section kind="list"`, facts `<Section title ...><DescriptionList isDivided items={...} /></Section>`,
|
|
265
|
+
disclosures `<Section title ...><DisclosureList .../></Section>`, a form or field `<Section title ...><Form .../></Section>`, an empty state an `EmptyNotice` on its own,
|
|
266
|
+
markdown or a chart a `Section`. A body card with more than one content (an object's name or facts beside a control) is an object. A card with `measure="formCompact"`
|
|
267
|
+
(the sign-in form with no page around it) and a `kind="tile"` card are not judged.
|
|
268
|
+
- id: DATA-TABLE-SURFACE
|
|
269
|
+
title: A table has one flat look
|
|
270
|
+
governs: The `surface` prop of a DataTable (removed in the Grammar family 0.45.0).
|
|
271
|
+
cases:
|
|
272
|
+
- id: case-1
|
|
273
|
+
when: A DataTable is written with a `surface` attribute
|
|
274
|
+
assert: |-
|
|
275
|
+
The attribute is refused whatever its value and the fix removes it. A table is flat, with no frame or card of its own, under the `Section` that titles it.
|
|
266
276
|
- id: NO-RAW-SCROLL
|
|
267
277
|
title: Grammar never shows scrollbars
|
|
268
278
|
governs: Scroll areas an app draws.
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
-
import { attributeOf, elementNameOf, grammarName, hasSpread, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
|
|
3
|
-
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
|
-
/**
|
|
5
|
-
* The lone surface law (owner, 2026-11-09, SINGLE-CHILD-CARD; aligned 0.37.8 and 0.43.0): a card groups two or more different parts or carries zones. A card of
|
|
6
|
-
* key-value or choice rows (`kind="table"`, `kind="select"`, `kind="details"`, a `ListBox`, `DisclosureList`, a `DescriptionList`) is valid, alone or not. What is
|
|
7
|
-
* wrong is a card wrapping ONE leaf that stands on its own: a `DataTable` (standalone it draws its own frame), a chart, or a `Section kind="list"` (a list is flat
|
|
8
|
-
* and never a card, LIST-ONE-LOOK). The title sits above it as a `Section` head; a list's own `title` is that head.
|
|
9
|
-
*
|
|
10
|
-
* WHAT IT READS. A Grammar `SurfaceCard` (imported from `@starci/grammar`) with no zones: no `headers` or `footers` prop (an empty array literal counts as none) and no
|
|
11
|
-
* `labelEnd` (head actions). Its body is read through fragments, `cond && <x/>`, `cond ? <x/> : <y/>` and `.map`, ignoring blank text. It is refused when that body is ONE
|
|
12
|
-
* element and that element is a `DataTable`, a chart (`BarChart`, `ProportionBar`, `BubbleMap`, `FlowGraph`, `MermaidDiagram`) or a `Section kind="list"`.
|
|
13
|
-
*
|
|
14
|
-
* DECIDED. Key-value and choice rows are never refused here. `Meter`, `Progress` and `ProgressCircle` are single values, not charts. `SurfaceCard kind="figures"`, `details`,
|
|
15
|
-
* `accordion`, `table`, `select` and `tile` are not judged; `SurfaceCard kind="list"` is `surface-card-list`. Kinds, depth and nesting stay with `surface-card-kind`, `no-raised-surface-in-surface` and `surface-depth`.
|
|
16
|
-
*
|
|
17
|
-
* WHAT IT LEAVES ALONE. A card with two or more body children, a card with zones or `labelEnd`, a card with a JSX spread, a non-Grammar `SurfaceCard`, and non-product source.
|
|
18
|
-
*
|
|
19
|
-
* WHERE IT APPLIES. Product source (`isProductSource`).
|
|
20
|
-
*/
|
|
21
|
-
/** The table, list and chart components that are a surface on their own, with the word the message names them by. */
|
|
22
|
-
const LONE = new Map([
|
|
23
|
-
["DataTable", "table"],
|
|
24
|
-
["BarChart", "chart"],
|
|
25
|
-
["ProportionBar", "chart"],
|
|
26
|
-
["BubbleMap", "chart"],
|
|
27
|
-
["FlowGraph", "chart"],
|
|
28
|
-
["MermaidDiagram", "chart"],
|
|
29
|
-
]);
|
|
30
|
-
/** True when an attribute is an empty array literal (`headers={[]}`), which zones nothing. */
|
|
31
|
-
const isEmptyArray = (attribute) => {
|
|
32
|
-
const value = attribute.value;
|
|
33
|
-
return value?.type === "JSXExpressionContainer" && value.expression.type === "ArrayExpression" && value.expression.elements.length === 0;
|
|
34
|
-
};
|
|
35
|
-
/** True when the card carries a zone or head actions: a `headers` or `footers` prop that is not an empty array, or a `labelEnd`. */
|
|
36
|
-
const hasZones = (opening) => {
|
|
37
|
-
const zoned = ["headers", "footers"].some((name) => {
|
|
38
|
-
const attribute = attributeOf(opening, name);
|
|
39
|
-
return attribute !== undefined && !isEmptyArray(attribute);
|
|
40
|
-
});
|
|
41
|
-
return zoned || attributeOf(opening, "labelEnd") !== undefined;
|
|
42
|
-
};
|
|
43
|
-
/** What the lone child is, as the message names it (`DataTable`, `Section kind="list"`), or null when it is not a surface on its own. */
|
|
44
|
-
const loneChild = (context, card) => {
|
|
45
|
-
const body = renderedChildren(card.children);
|
|
46
|
-
if (body.length !== 1)
|
|
47
|
-
return null;
|
|
48
|
-
const child = body[0];
|
|
49
|
-
if (child?.type !== "JSXElement")
|
|
50
|
-
return null;
|
|
51
|
-
const name = elementNameOf(child);
|
|
52
|
-
if (name === null || grammarName(context, child.openingElement) === null)
|
|
53
|
-
return null;
|
|
54
|
-
if (name === "Section" && stringProp(child.openingElement, "kind") === "list")
|
|
55
|
-
return "Section kind=\"list\"";
|
|
56
|
-
return LONE.has(name) ? name : null;
|
|
57
|
-
};
|
|
58
|
-
/** A table component, a chart or a list standing alone is the surface, never wrapped in a card. */
|
|
59
|
-
export const singleChildCard = defineRule({
|
|
60
|
-
meta: {
|
|
61
|
-
type: "problem",
|
|
62
|
-
docs: { description: "SINGLE-CHILD-CARD: a SurfaceCard with no zones whose only content is a DataTable, a chart or a Section kind=\"list\" is a second frame; a card of key-value or choice rows is valid." },
|
|
63
|
-
schema: [],
|
|
64
|
-
messages: {
|
|
65
|
-
lone: "A {{child}} standing alone is the surface: drop the SurfaceCard, put its title in a `Section` head (`title`) and one line under it in `Section caption`. A list is a flat `Section kind=\"list\"` that titles itself. A card groups two or more different parts, or carries zones (tabs, search, head actions); a card of key-value or choice rows (`kind=\"details\"`, `\"select\"`, `\"table\"`) is valid.",
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
create(context) {
|
|
69
|
-
if (!isProductSource(context))
|
|
70
|
-
return {};
|
|
71
|
-
return {
|
|
72
|
-
JSXElement(element) {
|
|
73
|
-
const opening = element.openingElement;
|
|
74
|
-
if (grammarName(context, opening) !== "SurfaceCard" || hasSpread(opening) || hasZones(opening))
|
|
75
|
-
return;
|
|
76
|
-
const child = loneChild(context, element);
|
|
77
|
-
if (child === null)
|
|
78
|
-
return;
|
|
79
|
-
context.report({ node: opening, messageId: "lone", data: { child: `\`${child}\`` } });
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
/** The rules this law contributes to the plugin. */
|
|
85
|
-
export const rules = {
|
|
86
|
-
"single-child-card": singleChildCard,
|
|
87
|
-
};
|
|
88
|
-
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#SINGLE-CHILD-CARD");
|
|
89
|
-
/** Every rule of this law is an error. */
|
|
90
|
-
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|