@starci/eslint-grammar-core 0.43.1 → 0.44.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 +5 -0
- package/dist/app-shell.js +30 -10
- package/dist/lib/why.js +1 -1
- package/dist/tabs.d.ts +2 -1
- package/dist/tabs.js +9 -3
- package/docs/app-shell.md +5 -2
- package/docs/tabs.md +23 -2
- package/package.json +3 -3
- package/runtime/knowledge/ui/presentation/grammar-laws.yaml +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.44.0 - 2026-11-17
|
|
4
|
+
|
|
5
|
+
- 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.
|
|
6
|
+
- Changed: `tabs-in-well` (`FE_TABS_IN_WELL`) passes a `Tabs kind="filter"` in the `filter` row of a `Section` (list and region alike, directly or through a fragment, conditional or `&&`), the filter row of 0.43.1; a views `Tabs` there, a filter `Tabs` in a section's body or in another element's `filter` prop, and loose tabs stay findings. Message, `grammar-laws.yaml` TABS-IN-WELL and `docs/tabs.md` (now with a `tabs-in-well` section) updated.
|
|
7
|
+
|
|
3
8
|
## 0.43.1 - 2026-11-17
|
|
4
9
|
|
|
5
10
|
- Version: moves with the Grammar family (@starci/grammar 0.43.1: the disabled reason on touch, one section filter row, a headless region). No rule changed.
|
package/dist/app-shell.js
CHANGED
|
@@ -135,20 +135,37 @@ const delegatesImportedBar = (context, expression) => {
|
|
|
135
135
|
});
|
|
136
136
|
return imported && !controls && !unknown;
|
|
137
137
|
};
|
|
138
|
-
/**
|
|
139
|
-
const
|
|
138
|
+
/** Whether every value a prop can take is one of the given string literals. */
|
|
139
|
+
const everyLiteral = (context, expression, allowed) => everyValue(context, expression, (value) => value.type === "Literal" && typeof value.value === "string" && allowed.has(value.value));
|
|
140
|
+
const TOGGLE = new Set(["toggle"]);
|
|
141
|
+
const SWITCH_KINDS = new Set(["toggle", "compact"]);
|
|
142
|
+
/**
|
|
143
|
+
* A bar control's height comes from its published API. Buttons publish the shared 40px height as `md` (their default). A `Switch` publishes it
|
|
144
|
+
* as `kind="toggle"`: a stated `kind` wins and the Grammar ignores `size` beside it, so the kind alone decides, and a Switch with no `kind` is
|
|
145
|
+
* the toggle unless `size` says `md` or `lg`. The other bar controls publish `control`.
|
|
146
|
+
*/
|
|
147
|
+
const barControlHeight = (context, control, name) => {
|
|
148
|
+
if (name === "Switch") {
|
|
149
|
+
const kind = propOf(context, control, "kind");
|
|
150
|
+
if (kind.known && kind.value !== null && everyLiteral(context, kind.value, SWITCH_KINDS))
|
|
151
|
+
return everyLiteral(context, kind.value, TOGGLE) ? "control" : "compact";
|
|
152
|
+
if (!kind.known || kind.value !== null)
|
|
153
|
+
return "other";
|
|
154
|
+
}
|
|
140
155
|
const size = propOf(context, control, "size");
|
|
141
156
|
if (!size.known)
|
|
142
|
-
return
|
|
143
|
-
if ((name === "Button" || name === "IconButton") &&
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
return "other";
|
|
158
|
+
if ((name === "Button" || name === "IconButton" || name === "Switch") && size.value === null)
|
|
159
|
+
return "control";
|
|
160
|
+
if ((name === "Button" || name === "IconButton") && everyLiteral(context, size.value, new Set(["md"])))
|
|
161
|
+
return "control";
|
|
162
|
+
return textProp(context, control, "size") === "control" ? "control" : "other";
|
|
147
163
|
};
|
|
148
164
|
/** Every visible control in a navbar band uses the shared control height through its published size API. */
|
|
149
165
|
export const navbarControlSize = defineRule({
|
|
150
166
|
meta: meta("FE_NAVBAR_CONTROL_SIZE", "FE-APP-SHELL-2 requires the shared control height on bar controls.", {
|
|
151
|
-
control: "FE_NAVBAR_CONTROL_SIZE: {{name}} in the navbar band needs Grammar's shared control height: omit size or use md for Button/IconButton, and
|
|
167
|
+
control: "FE_NAVBAR_CONTROL_SIZE: {{name}} in the navbar band needs Grammar's shared control height: omit size or use md for Button/IconButton, kind=\"toggle\" (or no kind and no size) for Switch, and size=\"control\" for the other bar controls.",
|
|
168
|
+
compact: "FE_NAVBAR_CONTROL_SIZE: a Switch kind=\"compact\" (32x18, no thumb glyph) in the navbar band breaks the bar's one 40px height; the bar's switch is kind=\"toggle\" (72x40, the theme switch). Compact is for a setting in a row, a list, a table cell or a toolbar.",
|
|
152
169
|
}),
|
|
153
170
|
create(context) {
|
|
154
171
|
if (!isProductSource(context))
|
|
@@ -156,10 +173,13 @@ export const navbarControlSize = defineRule({
|
|
|
156
173
|
const reported = new Set();
|
|
157
174
|
return { JSXOpeningElement(node) {
|
|
158
175
|
visitBar(context, node, (control, name) => {
|
|
159
|
-
if (!isBarControl(context, control, name) ||
|
|
176
|
+
if (!isBarControl(context, control, name) || reported.has(control))
|
|
177
|
+
return;
|
|
178
|
+
const height = barControlHeight(context, control, name);
|
|
179
|
+
if (height === "control")
|
|
160
180
|
return;
|
|
161
181
|
reported.add(control);
|
|
162
|
-
context.report({ node: control, messageId: "control", data: { name } });
|
|
182
|
+
context.report({ node: control, messageId: height === "compact" ? "compact" : "control", data: { name } });
|
|
163
183
|
});
|
|
164
184
|
} };
|
|
165
185
|
},
|
package/dist/lib/why.js
CHANGED
|
@@ -117,7 +117,7 @@ export const why = {
|
|
|
117
117
|
"navbar-control-size": {
|
|
118
118
|
code: "FE_NAVBAR_CONTROL_SIZE",
|
|
119
119
|
en: "A navbar control does not use Grammar's shared control height.",
|
|
120
|
-
fix: "
|
|
120
|
+
fix: "Give every visible bar control the shared height: Button and IconButton at md (the default), Switch kind=\"toggle\" (never compact), the other controls size=\"control\".",
|
|
121
121
|
},
|
|
122
122
|
"no-navbar-create": {
|
|
123
123
|
code: "FE_NAVBAR_CREATE",
|
package/dist/tabs.d.ts
CHANGED
|
@@ -6,7 +6,8 @@ export declare const tabsDepth: Rule.RuleModule;
|
|
|
6
6
|
/**
|
|
7
7
|
* The second tab layer stands in the white header band (owner, 2026-11-09, TABS-IN-WELL): `Page header={{ tabs, subTabs }}`, on its own
|
|
8
8
|
* full-width separator, flush with the band's left inset. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection`
|
|
9
|
-
* stands on the pink well or in a pane body, so it is a finding
|
|
9
|
+
* stands on the pink well or in a pane body, so it is a finding, unless it narrows a list from a header row of its own: a card (its header
|
|
10
|
+
* zones) or a `Tabs kind="filter"` in a `Section`'s `filter` row (0.43.1). A drawer, dialog, modal, popover or sheet starts its own surface.
|
|
10
11
|
*/
|
|
11
12
|
export declare const tabsInWell: Rule.RuleModule;
|
|
12
13
|
/** The rules this law contributes to the plugin. */
|
package/dist/tabs.js
CHANGED
|
@@ -163,21 +163,24 @@ export const tabsDepth = defineRule({
|
|
|
163
163
|
});
|
|
164
164
|
/** The pink well and the panes: underline Tabs written in their children sit on the well, not in the white header band. */
|
|
165
165
|
const WELL_HOSTS = new Set(["Page", "Pane", "PaneSection"]);
|
|
166
|
+
/** Whether a JSX attribute is the `filter` row of a `Section` (a list's or a region's alike, 0.43.1). */
|
|
167
|
+
const isSectionFilter = (node) => node.name.type === "JSXIdentifier" && node.name.name === "filter" && node.parent.type === "JSXOpeningElement" && elementName(node.parent) === "Section";
|
|
166
168
|
/**
|
|
167
169
|
* The second tab layer stands in the white header band (owner, 2026-11-09, TABS-IN-WELL): `Page header={{ tabs, subTabs }}`, on its own
|
|
168
170
|
* full-width separator, flush with the band's left inset. An underline `Tabs` written as a child of a `Page`, `Pane` or `PaneSection`
|
|
169
|
-
* stands on the pink well or in a pane body, so it is a finding
|
|
171
|
+
* stands on the pink well or in a pane body, so it is a finding, unless it narrows a list from a header row of its own: a card (its header
|
|
172
|
+
* zones) or a `Tabs kind="filter"` in a `Section`'s `filter` row (0.43.1). A drawer, dialog, modal, popover or sheet starts its own surface.
|
|
170
173
|
*/
|
|
171
174
|
export const tabsInWell = defineRule({
|
|
172
175
|
meta: {
|
|
173
176
|
type: "problem",
|
|
174
177
|
docs: {
|
|
175
|
-
description: "An underline Tabs stands in the white header band (Page header.subTabs), never in the pink well or a pane body.",
|
|
178
|
+
description: "An underline Tabs stands in the white header band (Page header.subTabs), a card's header zone or, kind=\"filter\", a Section's filter row; never loose in the pink well or a pane body.",
|
|
176
179
|
url: "knowledge/ui/presentation/grammar-laws.yaml#TABS-IN-WELL",
|
|
177
180
|
},
|
|
178
181
|
schema: [],
|
|
179
182
|
messages: {
|
|
180
|
-
well: "This underline `Tabs` stands in the body of a `{{host}}`, on the pink well or in a pane. The second tab layer sits in the white header band under the page tabs: `Page header` with `subTabs`, on its own full-width separator and flush with the band left inset. Move it to `header.subTabs`,
|
|
183
|
+
well: "This underline `Tabs` stands in the body of a `{{host}}`, on the pink well or in a pane. The second tab layer sits in the white header band under the page tabs: `Page header` with `subTabs`, on its own full-width separator and flush with the band left inset. Move it to `header.subTabs`, make the views a `switch` zone or a filter zone of a card, or, to narrow a list, pass it as `Tabs kind=\"filter\"` in the `filter` row of its `Section`.",
|
|
181
184
|
},
|
|
182
185
|
},
|
|
183
186
|
create(context) {
|
|
@@ -187,8 +190,11 @@ export const tabsInWell = defineRule({
|
|
|
187
190
|
JSXOpeningElement(opening) {
|
|
188
191
|
if (elementName(opening) !== "Tabs" || isPill(opening))
|
|
189
192
|
return;
|
|
193
|
+
const isFilter = literalOf(attributeOf(opening, "kind")) === "filter";
|
|
190
194
|
let child = opening.parent ?? opening;
|
|
191
195
|
for (let node = child.parent; node !== undefined && node !== null; child = node, node = node.parent) {
|
|
196
|
+
if (node.type === "JSXAttribute" && isFilter && isSectionFilter(node))
|
|
197
|
+
return;
|
|
192
198
|
if (node.type !== "JSXElement")
|
|
193
199
|
continue;
|
|
194
200
|
const name = elementName(node.openingElement);
|
package/docs/app-shell.md
CHANGED
|
@@ -21,7 +21,10 @@ export and rendered Base chain prove a `TopBar` in every alternative.
|
|
|
21
21
|
Workspace exports resolve back to source. Raw or unknown imported headers are red; the actual
|
|
22
22
|
bar's own actions are checked where composed. Each lint source snapshot has fresh dependency proofs.
|
|
23
23
|
|
|
24
|
-
`navbar-control-size` requires
|
|
24
|
+
`navbar-control-size` requires the shared 40px height of each bar control through its published API: `Button` and
|
|
25
|
+
`IconButton` at `md` (their default), `Switch` as `kind="toggle"` (a stated `kind` wins and the Grammar ignores `size` beside it;
|
|
26
|
+
with no `kind`, the toggle unless `size` says `md` or `lg`), every other control at `size="control"`. A `Switch kind="compact"`
|
|
27
|
+
(32x18) is refused in the bar with its own message, whatever `size` it carries. Unknown trailing prop spreads
|
|
25
28
|
cannot prove a size; put the explicit size after a spread. A left `Drawer` containing
|
|
26
29
|
`Sidebar presentation="drawer"` also identifies a mobile bar opener when composed in a separate
|
|
27
30
|
client owner. Its trigger is checked; drawer bodies and footers retain their normal field sizes.
|
|
@@ -35,7 +38,7 @@ does not execute application code.
|
|
|
35
38
|
| --- | --- | --- |
|
|
36
39
|
| `app-shell-frame` | An app `Shell` returns a hand-written `<header>` and `<nav>`. | `WorkspaceShell viewport="fixed"` owns the app frame. |
|
|
37
40
|
| `no-shell-bottom-tabs` | The shell supplies `compactNavigation={<BottomNav />}`. | The shell supplies `navigationDrawer` with a drawer `Sidebar`. |
|
|
38
|
-
| `navbar-control-size` | A navbar `IconButton` uses `size="
|
|
41
|
+
| `navbar-control-size` | A navbar `IconButton` uses `size="sm"`; the theme `Switch` is `kind="compact"`. | The `IconButton` keeps `md`; the theme `Switch` is `kind="toggle"`. |
|
|
39
42
|
| `navbar-cluster` | Account precedes notifications, or a language trigger uses a regular `Button`. | Language menu, theme switch, notification popover, account menu use their stated Grammar trigger kinds in that order. |
|
|
40
43
|
| `no-navbar-create` | A navbar button or attached menu item creates a record. | The page owns its create action. |
|
|
41
44
|
|
package/docs/tabs.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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
|
|
|
@@ -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, inside a `SurfaceCard` (its header zones) or, 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.44.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": "27ffff1f56448d21ffcf7595166ab3fc74c8536f",
|
|
72
|
+
"starciSource": "36975198cdfd758aecce3eb5234f1201b939c53dbf66f46f42b8fd240c223974"
|
|
73
73
|
}
|
|
@@ -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, a card's header zone or, kind="filter", 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.
|