@starci/eslint-grammar-core 0.49.0 → 0.50.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 +8 -0
- package/README.md +1 -1
- package/dist/choice-controls.d.ts +1 -1
- package/dist/choice-controls.js +1 -1
- package/dist/field-label.js +1 -1
- package/dist/gap-proximity.js +1 -1
- package/dist/lib/grammar-jsx.js +1 -1
- package/dist/lib/why.js +2 -2
- package/dist/suggestion-buttons.js +3 -3
- package/docs/choice-controls.md +2 -2
- package/docs/suggestion-buttons.md +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.50.0 - 2026-11-20
|
|
4
|
+
|
|
5
|
+
- Changed: `suggestion-buttons` treats `ChoiceButtons` like `ChoiceChips` (a group that sends its choice is refused); `ChoiceButtons` is a form control for the field-label and gap rules.
|
|
6
|
+
|
|
7
|
+
## 0.49.1 - 2026-11-20
|
|
8
|
+
|
|
9
|
+
- Changed: versioned with the Grammar 0.49.1 (ToastStack, no lint change).
|
|
10
|
+
|
|
3
11
|
## 0.49.0 - 2026-11-19 - Fragment
|
|
4
12
|
|
|
5
13
|
- Added: `starci-grammar/fragment-has-reason` (law `fragment`): a Grammar `<Fragment>` region (followed through an import alias such as `GrammarFragment`; React's Fragment and `<>` are not regions) names a non-empty string literal `reason`.
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Grammar-owned structural elements, glyphs and icon sizes, destructive menu entri
|
|
|
22
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
|
-
`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`).
|
|
25
|
+
`suggestion-buttons` (suggestions and quick replies are a Cluster of neutral sm Buttons, never a Link row, ChoiceChips, ChoiceButtons 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
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
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`).
|
|
@@ -11,7 +11,7 @@ import type { Rule } from "eslint";
|
|
|
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
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
|
-
* `ChoiceChips` or `RadioGroup` choose a form value; a button holds a command, never a selection state.
|
|
14
|
+
* `ChoiceButtons`, `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. */
|
|
17
17
|
export declare const REPLACEMENTS: Readonly<Record<string, string>>;
|
package/dist/choice-controls.js
CHANGED
|
@@ -12,7 +12,7 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
|
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
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
|
-
* `ChoiceChips` or `RadioGroup` choose a form value; a button holds a command, never a selection state.
|
|
15
|
+
* `ChoiceButtons`, `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 = {
|
package/dist/field-label.js
CHANGED
|
@@ -8,7 +8,7 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
|
8
8
|
*
|
|
9
9
|
* WHAT IT READS. In one element's rendered children (looked through fragments, `cond && <x/>`, `cond ? <x/> : null` and
|
|
10
10
|
* `.map`), a hand-made label standing as the sibling IMMEDIATELY BEFORE a Grammar form control (Input, Select, Textarea,
|
|
11
|
-
* NumberField, ComboBox, Autocomplete, CheckboxGroup, RadioGroup, ChoiceChips, Switch, DatePicker, DateField,
|
|
11
|
+
* NumberField, ComboBox, Autocomplete, CheckboxGroup, RadioGroup, ChoiceChips, ChoiceButtons, Switch, DatePicker, DateField,
|
|
12
12
|
* TimeField, SearchField, Slider, CopyField) that carries no `label` prop (a control that has only an `aria-label`
|
|
13
13
|
* included). A hand-made label is a Grammar `Text` or a `Label`, or a plain `<label>` or `<span>` whose children are
|
|
14
14
|
* literal text.
|
package/dist/gap-proximity.js
CHANGED
|
@@ -18,7 +18,7 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
|
18
18
|
* - A `SurfaceCard`, `Drawer`, `Dialog`, `AlertDialog` or `Popover` is a reset: a surface is its own edge, so what
|
|
19
19
|
* stands inside it is not compared with anything outside it.
|
|
20
20
|
* - A field stack: a `Stack gap="section"` whose children are all form controls (Input, Select, Textarea, NumberField,
|
|
21
|
-
* ComboBox, Autocomplete, CheckboxGroup, RadioGroup, ChoiceChips, Switch, DatePicker, DateField, TimeField,
|
|
21
|
+
* ComboBox, Autocomplete, CheckboxGroup, RadioGroup, ChoiceChips, ChoiceButtons, Switch, DatePicker, DateField, TimeField,
|
|
22
22
|
* SearchField, Slider, CopyField, Fieldset, Field), directly inside a `Form` or a `Fieldset` (a Drawer body is
|
|
23
23
|
* a reset already). Fields stand 24 apart; that is the Field rule's own rhythm.
|
|
24
24
|
* - `Grid kind="main-rail"`: nothing in it is compared with it, and it is not compared with a region parent. It fixes
|
package/dist/lib/grammar-jsx.js
CHANGED
|
@@ -131,6 +131,6 @@ export const renderedChildren = (children) => {
|
|
|
131
131
|
export const elementNameOf = (node) => (node.type === "JSXElement" ? nameOf(node.openingElement.name) : null);
|
|
132
132
|
/** The Grammar form controls a field label belongs to. */
|
|
133
133
|
export const FORM_CONTROLS = new Set([
|
|
134
|
-
"Input", "Select", "Textarea", "NumberField", "ComboBox", "Autocomplete", "CheckboxGroup", "RadioGroup", "ChoiceChips",
|
|
134
|
+
"Input", "Select", "Textarea", "NumberField", "ComboBox", "Autocomplete", "CheckboxGroup", "RadioGroup", "ChoiceChips", "ChoiceButtons",
|
|
135
135
|
"Switch", "DatePicker", "DateField", "TimeField", "SearchField", "Slider", "CopyField",
|
|
136
136
|
]);
|
package/dist/lib/why.js
CHANGED
|
@@ -87,7 +87,7 @@ export const why = {
|
|
|
87
87
|
"no-grouped-choice-controls": {
|
|
88
88
|
code: "FE_GROUPED_CHOICE_CONTROL",
|
|
89
89
|
en: "A ButtonGroup, FilterButtonGroup or SegmentedControl in `<file>` draws a group of attached buttons, which the Grammar no longer has.",
|
|
90
|
-
fix: "Use the component of the meaning: Tabs (kind filter for a list) to switch a view or filter, ChoiceChips or RadioGroup to choose a form value, separate Buttons or a DropdownMenu for actions.",
|
|
90
|
+
fix: "Use the component of the meaning: Tabs (kind filter for a list) to switch a view or filter, ChoiceButtons, ChoiceChips or RadioGroup to choose a form value, separate Buttons or a DropdownMenu for actions.",
|
|
91
91
|
},
|
|
92
92
|
"field-label": {
|
|
93
93
|
code: "FE_FIELD_LABEL",
|
|
@@ -276,7 +276,7 @@ export const why = {
|
|
|
276
276
|
},
|
|
277
277
|
"suggestion-buttons": {
|
|
278
278
|
code: "FE_SUGGESTION_BUTTONS",
|
|
279
|
-
en: "A Link row, a ChoiceChips or a Chip in `<file>` runs an action or sends its own label as a suggestion.",
|
|
279
|
+
en: "A Link row, a ChoiceChips, a ChoiceButtons or a Chip in `<file>` runs an action or sends its own label as a suggestion.",
|
|
280
280
|
fix: "Suggestions and quick replies are one pattern: a `Cluster gap=\"inline\"` (with `label`) of neutral `Button size=\"sm\"` (a pill).",
|
|
281
281
|
},
|
|
282
282
|
};
|
|
@@ -128,7 +128,7 @@ export const suggestionButtons = defineRule({
|
|
|
128
128
|
const opening = element.openingElement;
|
|
129
129
|
const { grammar, tag } = elementOf(opening, bound);
|
|
130
130
|
const report = (name) => context.report({ node: opening, messageId: "element", data: { element: name } });
|
|
131
|
-
if (grammar === "ChoiceChips") {
|
|
131
|
+
if (grammar === "ChoiceChips" || grammar === "ChoiceButtons") {
|
|
132
132
|
if (opening.attributes.some((entry) => entry.type === "JSXSpreadAttribute"))
|
|
133
133
|
return;
|
|
134
134
|
const value = attributeOf(opening, "onValueChange")?.value;
|
|
@@ -138,7 +138,7 @@ export const suggestionButtons = defineRule({
|
|
|
138
138
|
if (handler.type === "Identifier" || handler.type === "MemberExpression") {
|
|
139
139
|
const name = calleeName(handler);
|
|
140
140
|
if (name !== null && SENDERS.test(name) && !NOT_SENDING.test(name))
|
|
141
|
-
report(
|
|
141
|
+
report(`\`${grammar}\``);
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
if (handler.type !== "ArrowFunctionExpression")
|
|
@@ -151,7 +151,7 @@ export const suggestionButtons = defineRule({
|
|
|
151
151
|
if (name === null || NOT_SENDING.test(name))
|
|
152
152
|
return;
|
|
153
153
|
if (call.arguments.some((arg) => arg.type === "Identifier" && arg.name === param.name))
|
|
154
|
-
report(
|
|
154
|
+
report(`\`${grammar}\``);
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
if (grammar === null && tag === null && opening.name.type === "JSXIdentifier" && chips.has(opening.name.name)) {
|
package/docs/choice-controls.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Law module: `choice-controls.ts`. Catalogue: R380 FE_GROUPED_CHOICE_CONTROL.
|
|
4
4
|
|
|
5
|
-
The Grammar draws no group of attached buttons. A choice among a few has one component by meaning: `Tabs` switches a view or filters a list that stays in place (`kind="filter"`: compact underline tabs with a `count` each, in the list pane under its search field), `ChoiceChips` or `RadioGroup` chooses a value of a form (a tablist is not a form field), separate `Button`s or a `DropdownMenu` carry actions, and a date is the `Calendar` with a time as `ChoiceChips`. `ButtonGroup`, `FilterButtonGroup` and `SegmentedControl` stay exported and deprecated for one release so existing screens build; the rule stops new uses.
|
|
5
|
+
The Grammar draws no group of attached buttons. A choice among a few has one component by meaning: `Tabs` switches a view or filters a list that stays in place (`kind="filter"`: compact underline tabs with a `count` each, in the list pane under its search field), `ChoiceButtons`, `ChoiceChips` or `RadioGroup` chooses a value of a form (a tablist is not a form field), separate `Button`s or a `DropdownMenu` carry actions, and a date is the `Calendar` with a time as `ChoiceChips`. `ButtonGroup`, `FilterButtonGroup` and `SegmentedControl` stay exported and deprecated for one release so existing screens build; the rule stops new uses.
|
|
6
6
|
|
|
7
7
|
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
|
|
8
8
|
|
|
9
9
|
## Which component switches what
|
|
10
10
|
|
|
11
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
|
-
- `ChoiceChips` or `RadioGroup` chooses a value of a form.
|
|
12
|
+
- `ChoiceButtons` (options with the weight of a button, as tall as a Button), `ChoiceChips` (short options, as tall as a Chip) 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
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.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Law module: `suggestion-buttons.ts`. Finding code: `FE_SUGGESTION_BUTTONS`. Knowledge: `knowledge/ui/presentation/grammar-laws.yaml#SUGGESTION-BUTTONS`.
|
|
4
4
|
|
|
5
|
-
Suggestions, quick replies and empty-state shortcuts (the assistant drawer, chat composer suggestions) have ONE pattern: a `Cluster gap="inline"` (with a `label`) of neutral `Button size="sm"`. Every Button size draws a pill. The law refuses the alternatives drawn as suggestions: Links, ChoiceChips and Chips that run an action or send their own label.
|
|
5
|
+
Suggestions, quick replies and empty-state shortcuts (the assistant drawer, chat composer suggestions) have ONE pattern: a `Cluster gap="inline"` (with a `label`) of neutral `Button size="sm"`. Every Button size draws a pill. The law refuses the alternatives drawn as suggestions: Links, ChoiceChips, ChoiceButtons and Chips that run an action or send their own label.
|
|
6
6
|
|
|
7
7
|
The rule is an error in `coreGrammarConfig`; it cannot be switched off or suppressed inline.
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ The rule is an error in `coreGrammarConfig`; it cannot be switched off or suppre
|
|
|
11
11
|
Flagged, in cheap static shapes only:
|
|
12
12
|
|
|
13
13
|
- a row (two or more siblings in a Grammar `Cluster` or `Stack`, or a `div`, through fragments, `cond && x`, ternaries and `.map`; or one Link drawn by a `.map`) of Grammar `Link`s whose `onFollow` or `onPress` is an inline arrow passing the Link's own label (`{q}` and `send(q)`, `{item.label}` and `ask(item.label)`, or an equal string literal) and whose `href` is absent or `"#"`;
|
|
14
|
-
- a Grammar `ChoiceChips` whose `onValueChange` is an inline arrow calling something that is not a state setter with the value, or is a bare `send`/`ask`/`submit`/`reply`/`post`/`dispatch` function: it sends the choice instead of keeping it selected;
|
|
14
|
+
- a Grammar `ChoiceChips` or `ChoiceButtons` whose `onValueChange` is an inline arrow calling something that is not a state setter with the value, or is a bare `send`/`ask`/`submit`/`reply`/`post`/`dispatch` function: it sends the choice instead of keeping it selected;
|
|
15
15
|
- a HeroUI `Chip` (imported from `@heroui/react`) whose `onPress` or `onClick` passes its own label.
|
|
16
16
|
|
|
17
17
|
Grammar `Badge` has no action prop and Grammar `TagGroup` only `onRemove(ids)` and `onReorder(ids)`, so neither is judged. A spread, a computed prop, an unreadable handler, or a callee named `set*`, `on*`, `handle*` or `update*` is not flagged.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/eslint-grammar-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.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": "a21c99d23227b5595333f38f1fc3c5eca509e938",
|
|
72
|
+
"starciSource": "9c83768e100b46a971166664af14dfe0a66a92118fffae0eb603a8b392302ed9"
|
|
73
73
|
}
|