@starci/eslint-grammar-core 0.58.0 → 0.60.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 -955
- package/README.md +4 -4
- package/dist/app-shell.js +1 -1
- package/dist/avatar-row-uses-group.js +1 -2
- package/dist/button-arrow.d.ts +2 -2
- package/dist/button-arrow.js +2 -2
- package/dist/choice-controls.d.ts +0 -18
- package/dist/choice-controls.js +7 -47
- package/dist/field-label.js +2 -2
- package/dist/gap-proximity.js +2 -2
- package/dist/index.js +0 -2
- package/dist/layout-two-axis.js +1 -1
- package/dist/lib/grammar-jsx.js +1 -1
- package/dist/lib/site-scope.d.ts +1 -2
- package/dist/lib/site-scope.js +1 -2
- package/dist/lib/why.js +5 -15
- package/dist/link-look.js +1 -1
- package/dist/no-card-lead-description.js +1 -1
- package/dist/no-nested-label.js +1 -1
- package/dist/no-raw-scroll.js +1 -1
- package/dist/no-raw-spacing-style.d.ts +1 -1
- package/dist/no-raw-spacing-style.js +1 -1
- package/dist/no-raw-type-size.d.ts +1 -1
- package/dist/no-raw-type-size.js +1 -1
- package/dist/outline-icons.js +1 -1
- package/dist/page-breadcrumbs.js +1 -1
- package/dist/page.d.ts +1 -1
- package/dist/page.js +4 -17
- package/dist/pane.js +4 -4
- package/dist/same-line-size.js +1 -1
- package/dist/section-head-action.js +2 -2
- package/dist/site-type-role.d.ts +2 -2
- package/dist/site-type-role.js +3 -3
- package/dist/surface-depth.js +1 -1
- package/dist/surface-in-surface.js +1 -1
- package/dist/table-cell-type.js +1 -1
- package/dist/tabs.d.ts +2 -2
- package/dist/tabs.js +5 -5
- package/dist/text-rules.js +1 -1
- package/docs/avatar-row-uses-group.md +1 -1
- package/docs/button-arrow.md +2 -2
- package/docs/card-is-object.md +1 -1
- package/docs/choice-controls.md +1 -13
- package/docs/field-label.md +1 -1
- package/docs/no-raw-scroll.md +2 -2
- package/docs/no-raw-type-size.md +1 -1
- package/docs/page.md +0 -52
- package/docs/pane.md +1 -1
- package/docs/section-head-action.md +1 -1
- package/docs/site-type-role.md +1 -1
- package/docs/tabs.md +1 -1
- package/package.json +3 -3
- package/runtime/knowledge/ui/presentation/grammar-laws.yaml +15 -16
- package/dist/lib/grammar-imports.d.ts +0 -16
- package/dist/lib/grammar-imports.js +0 -37
- package/dist/page-header.d.ts +0 -17
- package/dist/page-header.js +0 -36
- package/docs/page-header.md +0 -37
package/README.md
CHANGED
|
@@ -19,11 +19,11 @@ Family helpers and the generated runtime closure belong to this package.
|
|
|
19
19
|
|
|
20
20
|
The rule IDs remain stable when their namespace moves. Laws cover the navbar control height,
|
|
21
21
|
Grammar-owned structural elements, glyphs and icon sizes, destructive menu entries,
|
|
22
|
-
a Button that leads somewhere ending with `endArrow` (no icon arrow; `button-arrow`), no typed arrow character in any rendered text (`no-typed-arrow`), report cards in one axis (`layout-two-axis`), no app-made scroll area (`no-raw-scroll`), no raw type size in app source, only the type roles (`no-raw-type-size`, the counting rule: a warning until its `COUNTING` entry is deleted), 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`), 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`), every `Mascot` naming its asset slot, the
|
|
22
|
+
a Button that leads somewhere ending with `endArrow` (no icon arrow; `button-arrow`), no typed arrow character in any rendered text (`no-typed-arrow`), report cards in one axis (`layout-two-axis`), no app-made scroll area (`no-raw-scroll`), no raw type size in app source, only the type roles (`no-raw-type-size`, the counting rule: a warning until its `COUNTING` entry is deleted), 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`), 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`), every `Mascot` naming its asset slot, 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
|
-
`card-is-object` (
|
|
26
|
-
The proximity and composition laws
|
|
25
|
+
`card-is-object` (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`).
|
|
26
|
+
The proximity and composition laws 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"`).
|
|
27
27
|
|
|
28
28
|
## Migrating from @starci/eslint-canon-fe 8.x
|
|
29
29
|
|
|
@@ -54,7 +54,7 @@ Regression checks live in this ESLint package. The Grammar and consuming app fro
|
|
|
54
54
|
The source is TypeScript in `src/` (`src/lib/` holds the shared readers, `src/vendor.d.ts` types the untyped canon and runtime
|
|
55
55
|
JavaScript it imports); `npm run build` emits `dist/`, which is what the package ships beside `runtime/` and `docs/`.
|
|
56
56
|
|
|
57
|
-
## Fragment
|
|
57
|
+
## Fragment
|
|
58
58
|
|
|
59
59
|
`<Fragment reason="...">` is the Grammar's escape hatch: inside it no rule of this plugin reports anything, nor an import whose every use is there (`docs/fragment.md`). `starci-grammar/fragment-has-reason` is the one law that judges the element. `node node_modules/@starci/eslint-grammar-core/dist/lib/fragment-inventory-cli.js [root] [--json]` (the package `bin`) lists every use for audit and always exits 0.
|
|
60
60
|
|
package/dist/app-shell.js
CHANGED
|
@@ -56,7 +56,7 @@ const barControlHeight = (context, control, name) => {
|
|
|
56
56
|
return "other";
|
|
57
57
|
if ((name === "Button" || name === "IconButton" || name === "Switch" || name === "AvatarButton") && size.value === null)
|
|
58
58
|
return "control";
|
|
59
|
-
// An AvatarButton's md is the 40px round mark, the control height (
|
|
59
|
+
// An AvatarButton's md is the 40px round mark, the control height (round marks are sm 24 or md 40).
|
|
60
60
|
if ((name === "Button" || name === "IconButton" || name === "AvatarButton") && everyLiteral(context, size.value, new Set(["md"])))
|
|
61
61
|
return "control";
|
|
62
62
|
return textProp(context, control, "size") === "control" ? "control" : "other";
|
|
@@ -2,8 +2,7 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
|
2
2
|
import { elementNameOf, grammarName, renderedChildren } from "./lib/grammar-jsx.js";
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* AVATARS IN A ROW ARE ONE AVATARGROUP (DNA-COMMON-AVATAR-ROW-GROUP
|
|
6
|
-
* tụi này render sáng tạo nhỉ"). Avatars that stand side by side, or that come out of a list, are `<AvatarGroup items max>`: it overlaps them, shows `max - 1` and the "+N" tile,
|
|
5
|
+
* AVATARS IN A ROW ARE ONE AVATARGROUP (DNA-COMMON-AVATAR-ROW-GROUP). Avatars that stand side by side, or that come out of a list, are `<AvatarGroup items max>`: it overlaps them, shows `max - 1` and the "+N" tile,
|
|
7
6
|
* names every member on hover, and takes people and provider or channel marks alike. A hand-made row of `Avatar` has none of that and every app draws its own overflow.
|
|
8
7
|
*
|
|
9
8
|
* WHAT IT READS. In product source, a Grammar `Avatar` that (a) shares its parent with another Grammar `Avatar` (siblings, looked through fragments, conditions and `&&`), or
|
package/dist/button-arrow.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
2
|
/**
|
|
3
|
-
* A typed arrow (
|
|
3
|
+
* A typed arrow (no arrow characters in ANY rendered text):
|
|
4
4
|
* the Unicode Arrows block U+2190-U+21FF, the dingbat arrows U+2794-U+27BF, the long arrows U+27F0-U+27FF, and the ASCII `->`.
|
|
5
5
|
*/
|
|
6
6
|
export declare const TYPED_ARROW: RegExp;
|
|
7
7
|
/** A Button leads somewhere with `endArrow` and does something with `startGlyph`; no typed arrow, no arrow icon, never both. */
|
|
8
8
|
export declare const buttonArrow: Rule.RuleModule;
|
|
9
9
|
/**
|
|
10
|
-
* No typed arrow in ANY rendered text (`FE_NO_TYPED_ARROW
|
|
10
|
+
* No typed arrow in ANY rendered text (`FE_NO_TYPED_ARROW`). In product source, JSX text, a string or template literal
|
|
11
11
|
* rendered as a child (and the branches of a conditional), and a string attribute that is rendered text (`label`, `title`, `aria-label`,
|
|
12
12
|
* `description`, ...) holding an arrow character is an error: direction is the Grammar's arrow or link icon, `Link`'s own arrow or
|
|
13
13
|
* `Button endArrow`. i18n message values are JSON the lint does not read; the content concept (contexts/ui/content.md) holds them.
|
package/dist/button-arrow.js
CHANGED
|
@@ -17,7 +17,7 @@ import { attributeOf, descendants, elementOf, grammarBindings } from "./lib/row-
|
|
|
17
17
|
/** A Button label's pointing quote marks: `›` and `»` (a typed arrow character is `no-typed-arrow`, for every element). */
|
|
18
18
|
const LABEL_ARROW = /[›»]/u;
|
|
19
19
|
/**
|
|
20
|
-
* A typed arrow (
|
|
20
|
+
* A typed arrow (no arrow characters in ANY rendered text):
|
|
21
21
|
* the Unicode Arrows block U+2190-U+21FF, the dingbat arrows U+2794-U+27BF, the long arrows U+27F0-U+27FF, and the ASCII `->`.
|
|
22
22
|
*/
|
|
23
23
|
export const TYPED_ARROW = /[\u2190-\u21FF\u2794-\u27BF\u27F0-\u27FF]|->/u;
|
|
@@ -145,7 +145,7 @@ export const buttonArrow = defineRule({
|
|
|
145
145
|
},
|
|
146
146
|
});
|
|
147
147
|
/**
|
|
148
|
-
* No typed arrow in ANY rendered text (`FE_NO_TYPED_ARROW
|
|
148
|
+
* No typed arrow in ANY rendered text (`FE_NO_TYPED_ARROW`). In product source, JSX text, a string or template literal
|
|
149
149
|
* rendered as a child (and the branches of a conditional), and a string attribute that is rendered text (`label`, `title`, `aria-label`,
|
|
150
150
|
* `description`, ...) holding an arrow character is an error: direction is the Grammar's arrow or link icon, `Link`'s own arrow or
|
|
151
151
|
* `Button endArrow`. i18n message values are JSON the lint does not read; the content concept (contexts/ui/content.md) holds them.
|
|
@@ -1,22 +1,4 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
|
-
/**
|
|
3
|
-
* The rule that holds the one-way-to-choose law (HFS R380, `FE_GROUPED_CHOICE_CONTROL`): the Grammar draws no group of
|
|
4
|
-
* attached buttons. Choosing among a few is one component by meaning: `Tabs` to switch a view or filter a list, `ChoiceChips`
|
|
5
|
-
* or `RadioGroup` to choose a value of a form, separate `Button`s or a `DropdownMenu` for actions, and the Calendar and
|
|
6
|
-
* `ChoiceChips` for a date and a time.
|
|
7
|
-
*
|
|
8
|
-
* WHAT IT READS. A JSX element named `ButtonGroup`, `FilterButtonGroup` or `SegmentedControl` in product source, written
|
|
9
|
-
* bare or as a member (`Grammar.ButtonGroup`). ButtonGroup and FilterButtonGroup were deleted in Grammar 0.55.0; the rule still names the replacement.
|
|
10
|
-
*
|
|
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
|
-
* `.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 `filter` row of the block's `Section` (a mode or period pill is `Section action`);
|
|
14
|
-
* `ChoiceButtons`, `ChoiceChips` or `RadioGroup` choose a form value; a button holds a command, never a selection state.
|
|
15
|
-
*/
|
|
16
|
-
/** Each banned component with the replacement its message names. */
|
|
17
|
-
export declare const REPLACEMENTS: Readonly<Record<string, string>>;
|
|
18
|
-
/** No ButtonGroup, FilterButtonGroup or SegmentedControl in product source. */
|
|
19
|
-
export declare const noGroupedChoiceControls: Rule.RuleModule;
|
|
20
2
|
/** No joined buttons acting as tabs: two or more Buttons carrying a selection state are a view switch. */
|
|
21
3
|
export declare const noButtonViewSwitch: Rule.RuleModule;
|
|
22
4
|
/** Primary tabs (a pill in a track) switch a mode or period: 2 to 4 short fixed options, no count, no destination. */
|
package/dist/choice-controls.js
CHANGED
|
@@ -1,26 +1,13 @@
|
|
|
1
1
|
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
2
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
3
|
/**
|
|
4
|
-
* The
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* `
|
|
8
|
-
*
|
|
9
|
-
* WHAT IT READS. A JSX element named `ButtonGroup`, `FilterButtonGroup` or `SegmentedControl` in product source, written
|
|
10
|
-
* bare or as a member (`Grammar.ButtonGroup`). ButtonGroup and FilterButtonGroup were deleted in Grammar 0.55.0; the rule still names the replacement.
|
|
11
|
-
*
|
|
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
|
-
* `.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 `filter` row of the block's `Section` (a mode or period pill is `Section action`);
|
|
15
|
-
* `ChoiceButtons`, `ChoiceChips` or `RadioGroup` choose a form value; a button holds a command, never a selection state.
|
|
4
|
+
* The rules that hold the one-way-to-choose law (HFS R380, `FE_GROUPED_CHOICE_CONTROL`). Two or more adjacent `Button` or
|
|
5
|
+
* `IconButton` elements (or one written in a `.map`) that carry `aria-pressed`, `isSelected` or `isActive` are joined buttons
|
|
6
|
+
* acting as tabs, a pill toggle ("This month / Last month"). A switch between views or periods of one block is `Tabs` (the
|
|
7
|
+
* primary underline) in the `filter` row of the block's `Section` (a mode or period pill is `Section action`); a form value is a
|
|
8
|
+
* `Select` or a `RadioGroup`; a button holds a command, never a selection state.
|
|
16
9
|
*/
|
|
17
|
-
/**
|
|
18
|
-
export const REPLACEMENTS = {
|
|
19
|
-
ButtonGroup: "separate `Button`s (one commit, the rest alternative or dismiss), or a `DropdownMenu` for the overflow",
|
|
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\"` (in the `action` of its `Section`) to switch a mode or period of one block",
|
|
22
|
-
};
|
|
23
|
-
/** The element name of a JSX opening element (`ButtonGroup`, or `Grammar.ButtonGroup` as `ButtonGroup`). */
|
|
10
|
+
/** The element name of a JSX opening element (`Tabs`, or `Grammar.Tabs` as `Tabs`). */
|
|
24
11
|
const elementName = (opening) => {
|
|
25
12
|
const name = opening.name;
|
|
26
13
|
if (name.type === "JSXIdentifier")
|
|
@@ -29,32 +16,6 @@ const elementName = (opening) => {
|
|
|
29
16
|
return name.property.name;
|
|
30
17
|
return null;
|
|
31
18
|
};
|
|
32
|
-
/** No ButtonGroup, FilterButtonGroup or SegmentedControl in product source. */
|
|
33
|
-
export const noGroupedChoiceControls = defineRule({
|
|
34
|
-
meta: {
|
|
35
|
-
type: "problem",
|
|
36
|
-
docs: { description: "R380: no ButtonGroup, FilterButtonGroup or SegmentedControl; choose by meaning (Tabs, ChoiceChips, RadioGroup, separate Buttons, DropdownMenu)." },
|
|
37
|
-
schema: [],
|
|
38
|
-
messages: {
|
|
39
|
-
grouped: "`{{component}}` is deprecated: the Grammar draws no group of attached buttons, because a few choices have exactly one component by meaning. Use {{replacement}}.",
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
create(context) {
|
|
43
|
-
if (!isProductSource(context))
|
|
44
|
-
return {};
|
|
45
|
-
return {
|
|
46
|
-
JSXOpeningElement(opening) {
|
|
47
|
-
const component = elementName(opening);
|
|
48
|
-
if (component === null)
|
|
49
|
-
return;
|
|
50
|
-
const replacement = REPLACEMENTS[component];
|
|
51
|
-
if (replacement === undefined)
|
|
52
|
-
return;
|
|
53
|
-
context.report({ node: opening, messageId: "grouped", data: { component, replacement } });
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
19
|
/** The buttons whose pressed or selected state makes a set of them a switch. */
|
|
59
20
|
const BUTTON_COMPONENTS = new Set(["Button", "IconButton"]);
|
|
60
21
|
const SELECTION_ATTRIBUTES = new Set(["aria-pressed", "isSelected", "isActive"]);
|
|
@@ -101,7 +62,7 @@ export const noButtonViewSwitch = defineRule({
|
|
|
101
62
|
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
63
|
schema: [],
|
|
103
64
|
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 `filter` row of the block's `Section`, or a pill (`Tabs appearance=\"primary\"`) in its `action`; choosing a form value is `
|
|
65
|
+
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 a `Select` or a `RadioGroup`; a `Button` holds a command, never a selection state.",
|
|
105
66
|
},
|
|
106
67
|
},
|
|
107
68
|
create(context) {
|
|
@@ -188,7 +149,6 @@ export const noPrimaryTabsMisuse = defineRule({
|
|
|
188
149
|
});
|
|
189
150
|
/** The rules this law contributes to the plugin. */
|
|
190
151
|
export const rules = {
|
|
191
|
-
"no-grouped-choice-controls": noGroupedChoiceControls,
|
|
192
152
|
"no-button-view-switch": noButtonViewSwitch,
|
|
193
153
|
"no-primary-tabs-misuse": noPrimaryTabsMisuse,
|
|
194
154
|
};
|
package/dist/field-label.js
CHANGED
|
@@ -2,13 +2,13 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
|
2
2
|
import { FORM_CONTROLS, attributeOf, elementNameOf, grammarName, nameOf, renderedChildren } from "./lib/grammar-jsx.js";
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* The field label law (
|
|
5
|
+
* The field label law (FIELD-LABEL): a control is labelled by its own `label` prop. The Field
|
|
6
6
|
* contract spaces label to control 8, control to help 4, and field to field 24 (the Form or the field stack sets that
|
|
7
7
|
* last one). A `Text` placed beside the control as its label is spaced by whoever placed it, and the rhythm drifts.
|
|
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,
|
|
11
|
+
* NumberField, ComboBox, Autocomplete, CheckboxGroup, RadioGroup, 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
|
@@ -2,7 +2,7 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
|
2
2
|
import { FORM_CONTROLS, attributeOf, elementNameOf, grammarName, isFragmentElement, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* The proximity law (
|
|
5
|
+
* The proximity law (GAP-PROXIMITY): inside any container, its children stand at least ONE step
|
|
6
6
|
* closer than the container stands to its siblings. The gap roles rise strictly: identity 4 < inline 8 < row 12 <
|
|
7
7
|
* section 24 < region 32. A layout element whose role is the same as, or wider than, its parent's makes the child's
|
|
8
8
|
* parts read as far apart as the parent's siblings, so the grouping disappears.
|
|
@@ -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,
|
|
21
|
+
* ComboBox, Autocomplete, CheckboxGroup, RadioGroup, 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/index.js
CHANGED
|
@@ -24,7 +24,6 @@ import { rules as noRawTypeSizeRules } from "./no-raw-type-size.js";
|
|
|
24
24
|
import { rules as outlineIconsRules } from "./outline-icons.js";
|
|
25
25
|
import { rules as pageRules } from "./page.js";
|
|
26
26
|
import { rules as pageBreadcrumbsRules } from "./page-breadcrumbs.js";
|
|
27
|
-
import { rules as pageHeaderRules } from "./page-header.js";
|
|
28
27
|
import { rules as paneRules } from "./pane.js";
|
|
29
28
|
import { rules as rowTitleLinkRules } from "./row-title-link.js";
|
|
30
29
|
import { rules as rowsInCardRules } from "./rows-in-card.js";
|
|
@@ -80,7 +79,6 @@ const DECLARED = [
|
|
|
80
79
|
{ law: "outline-icons", rules: outlineIconsRules },
|
|
81
80
|
{ law: "page", rules: pageRules },
|
|
82
81
|
{ law: "page-breadcrumbs", rules: pageBreadcrumbsRules },
|
|
83
|
-
{ law: "page-header", rules: pageHeaderRules },
|
|
84
82
|
{ law: "pane", rules: paneRules },
|
|
85
83
|
{ law: "row-title-link", rules: rowTitleLinkRules },
|
|
86
84
|
{ law: "same-line-size", rules: sameLineSizeRules },
|
package/dist/layout-two-axis.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
|
2
2
|
import { elementNameOf, grammarName, hasSpread, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* The two-axis layout law (
|
|
5
|
+
* The two-axis layout law (LAYOUT-5): a REPORT page (`Page` standard: the pink well) stacks its card surfaces in ONE
|
|
6
6
|
* direction, a vertical column 24 apart. Cards stand side by side only as siblings of the same role and height (figure cells, short
|
|
7
7
|
* equal cards). A card beside a column of other cards makes two axes in one well, and two cards of different roles side by side
|
|
8
8
|
* are unequal in height. A page that needs a persistent selection column or a full-height chat or editor is a WORKSPACE page
|
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",
|
|
134
|
+
"Input", "Select", "Textarea", "NumberField", "ComboBox", "Autocomplete", "CheckboxGroup", "RadioGroup",
|
|
135
135
|
"Switch", "DatePicker", "DateField", "TimeField", "SearchField", "Slider", "CopyField",
|
|
136
136
|
]);
|
package/dist/lib/site-scope.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { ReaderContext } from "./types.js";
|
|
2
2
|
/**
|
|
3
|
-
* THE PUBLIC SITE
|
|
3
|
+
* THE PUBLIC SITE. No hfs slot marks an app's public marketing site yet; the proposed one is `fe.site`, and a file it owns is
|
|
4
4
|
* the site at once. Until it exists the site is read from the slots the manifest already has, through `classify`, never a raw path test:
|
|
5
5
|
* - an owner of `fe.components` or `fe.feature` named `Site…` or `Marketing…` (its `<name>` binding: `SiteHead`, `SiteBrandPage`);
|
|
6
6
|
* - a route file of `fe.route` under the `(site)` or `(marketing)` route group (FE-CSS-2 names the marketing `(site)` group);
|
|
7
7
|
* - a capability of `fe.modules` named `site…` or `marketing…` (`modules/site-home`).
|
|
8
|
-
* The codemod v0550 mirrors this as `isSitePath` (packages/grammar/codemods/v0550).
|
|
9
8
|
*/
|
|
10
9
|
export declare const SITE_SLOT = "fe.site";
|
|
11
10
|
/** True for a file of the app's public marketing site. */
|
package/dist/lib/site-scope.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { hfsOf } from "@starci/eslint-canon-fe/lib/hfs.mjs";
|
|
2
2
|
/**
|
|
3
|
-
* THE PUBLIC SITE
|
|
3
|
+
* THE PUBLIC SITE. No hfs slot marks an app's public marketing site yet; the proposed one is `fe.site`, and a file it owns is
|
|
4
4
|
* the site at once. Until it exists the site is read from the slots the manifest already has, through `classify`, never a raw path test:
|
|
5
5
|
* - an owner of `fe.components` or `fe.feature` named `Site…` or `Marketing…` (its `<name>` binding: `SiteHead`, `SiteBrandPage`);
|
|
6
6
|
* - a route file of `fe.route` under the `(site)` or `(marketing)` route group (FE-CSS-2 names the marketing `(site)` group);
|
|
7
7
|
* - a capability of `fe.modules` named `site…` or `marketing…` (`modules/site-home`).
|
|
8
|
-
* The codemod v0550 mirrors this as `isSitePath` (packages/grammar/codemods/v0550).
|
|
9
8
|
*/
|
|
10
9
|
export const SITE_SLOT = "fe.site";
|
|
11
10
|
const SITE_OWNER = /^(?:Site|Marketing)[A-Z0-9]/;
|
package/dist/lib/why.js
CHANGED
|
@@ -67,12 +67,7 @@ export const why = {
|
|
|
67
67
|
"no-button-view-switch": {
|
|
68
68
|
code: "FE_GROUPED_CHOICE_CONTROL",
|
|
69
69
|
en: "Buttons carrying `aria-pressed`, `isSelected` or `isActive` stand side by side in `<file>`: joined buttons or pills acting as tabs.",
|
|
70
|
-
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 `
|
|
71
|
-
},
|
|
72
|
-
"no-grouped-choice-controls": {
|
|
73
|
-
code: "FE_GROUPED_CHOICE_CONTROL",
|
|
74
|
-
en: "A ButtonGroup, FilterButtonGroup or SegmentedControl in `<file>` draws a group of attached buttons, which the Grammar no longer has.",
|
|
75
|
-
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.",
|
|
70
|
+
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 a `Select` or a `RadioGroup`; a `Button` holds a command, never a selection state.",
|
|
76
71
|
},
|
|
77
72
|
"field-label": {
|
|
78
73
|
code: "FE_FIELD_LABEL",
|
|
@@ -104,11 +99,6 @@ export const why = {
|
|
|
104
99
|
en: "Raw `<tag>` in `<file>`. Page structure and text are composed from grammar components, not hand-written HTML.",
|
|
105
100
|
fix: "Replace it with the matching grammar component (`Heading`, `Text`, `SurfaceCard`, ...); if grammar lacks it, add it to grammar or the ui package instead of drawing it in place.",
|
|
106
101
|
},
|
|
107
|
-
"no-hand-rolled-page-header": {
|
|
108
|
-
code: "FE_PAGE_HEADER_HAND_ROLLED",
|
|
109
|
-
en: "A page head in `<file>` imports PageHeader or Breadcrumbs from the Grammar, so the head is composed by hand.",
|
|
110
|
-
fix: "Pass the head to Page `header` (title, breadcrumbs and the slots it needs: description, meta, status, mark, actions, tabs).",
|
|
111
|
-
},
|
|
112
102
|
"page-breadcrumbs": {
|
|
113
103
|
code: "FE_PAGE_BREADCRUMBS",
|
|
114
104
|
en: "The `Page` header of a console page in `<file>` states no `breadcrumbs`.",
|
|
@@ -121,7 +111,7 @@ export const why = {
|
|
|
121
111
|
},
|
|
122
112
|
"pane-children": {
|
|
123
113
|
code: "FE_PANE_CHILD_NOT_SECTION",
|
|
124
|
-
en: "A raw element or a Grammar component other than PaneSection and
|
|
114
|
+
en: "A raw element or a Grammar component other than PaneSection, PaneGrid and ChatFrame is placed straight in a `Pane` in `<file>`, skipping the inset the pane publishes.",
|
|
125
115
|
fix: "Wrap it in a `<PaneSection>` (grow, scroll, align or bleed as the band needs), or make the pane's one child a nested `<PaneGrid>`.",
|
|
126
116
|
},
|
|
127
117
|
"pane-grid-children": {
|
|
@@ -171,7 +161,7 @@ export const why = {
|
|
|
171
161
|
},
|
|
172
162
|
"no-raised-surface-in-surface": {
|
|
173
163
|
code: "FE_RAISED_SURFACE_IN_SURFACE",
|
|
174
|
-
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
|
|
164
|
+
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).",
|
|
175
165
|
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\"`).",
|
|
176
166
|
},
|
|
177
167
|
"surface-in-surface": {
|
|
@@ -212,12 +202,12 @@ export const why = {
|
|
|
212
202
|
"no-raw-type-size": {
|
|
213
203
|
code: "FE_RAW_TYPE_SIZE",
|
|
214
204
|
en: "`<file>` sets a type size of its own: a Tailwind text-size utility (`text-sm`, `text-[13px]`), a `fontSize` or a CSS `font-size`.",
|
|
215
|
-
fix: "Type is a Grammar role
|
|
205
|
+
fix: "Type is a Grammar role: use `<Text role=\"label.item\">` or the class of the role, `starci-type-<role>` with dots as dashes (`starci-type-label-item`). The roles: figure, title.page, title.section, label.item, body, label.field, label.group, caption, badge, code; on the public site also display.hero, display.section, display.figure, lead and title.card.",
|
|
216
206
|
},
|
|
217
207
|
"site-type-role": {
|
|
218
208
|
code: "FE_SITE_TYPE_ROLE",
|
|
219
209
|
en: "`<file>` is not the public site, and it draws a role of the site group: `display.hero`, `display.section`, `display.figure`, `lead` or `title.card` (`<Text role>` or `starci-type-<role>`).",
|
|
220
|
-
fix: "The site group
|
|
210
|
+
fix: "The site group is the public marketing site's alone. A console draws with the ten roles: title.page for a page heading, title.section for a section or card title, figure for a value, body for copy. A file of the site is a `Site…` or `Marketing…` owner, a route under `(site)`, or `modules/site…`.",
|
|
221
211
|
},
|
|
222
212
|
"table-cell-type": {
|
|
223
213
|
code: "FE_TABLE_CELL_TYPE",
|
package/dist/link-look.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
|
2
2
|
import { attributeOf, grammarName } from "./lib/grammar-jsx.js";
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* THE LINK LOOK (
|
|
5
|
+
* THE LINK LOOK (LINK-LOOK). Grammar's `Link` is HeroUI v3's own link: the primary colour, the underline on hover only
|
|
6
6
|
* and the anchor icon at the end of its label. Its type size and leading are INHERITED from the line it stands in (14 in a body, 12 in
|
|
7
7
|
* meta or caption text). An app never restyles it.
|
|
8
8
|
*
|
|
@@ -2,7 +2,7 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
|
2
2
|
import { elementNameOf, grammarName, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* NO CARD LEAD DESCRIPTION (
|
|
5
|
+
* NO CARD LEAD DESCRIPTION (CARD-NO-DESCRIPTION). A card head is its label, a count chip, one fact and one end action: it has NO description. The
|
|
6
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
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
|
*
|
package/dist/no-nested-label.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
|
2
2
|
import { attributeOf, grammarName } from "./lib/grammar-jsx.js";
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* NO NESTED LABEL (
|
|
5
|
+
* NO NESTED LABEL (LABEL-SUBLABEL-HIERARCHY). A section has exactly ONE Label (its head, 14/500, 12px above its content). The groups nested inside it
|
|
6
6
|
* are named by a Sublabel (12/500 muted, 8px above the card), never by a second Label: a `Section` or `SurfaceCard` inside a labelled one takes `sublabel`, not `title`/`label`.
|
|
7
7
|
*
|
|
8
8
|
* WHAT IT READS. In product source, a Grammar `Section` with a `title` or a `SurfaceCard` with a `label` whose JSX ancestor in the same file is a Grammar `Section` with a
|
package/dist/no-raw-scroll.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
2
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
3
|
/**
|
|
4
|
-
* Grammar never shows scrollbars (
|
|
4
|
+
* Grammar never shows scrollbars (OVERFLOW-6). Every scroll area is drawn by Grammar, which hides the bar and
|
|
5
5
|
* fades the edge where content continues (HeroUI's ScrollShadow behaviour). An app element that makes its own scroll area with
|
|
6
6
|
* an `overflow-y-auto` / `overflow-auto` class (or the `-x-`, `-scroll` forms) has no such edge and, in a browser that draws bars, shows one.
|
|
7
7
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
2
|
/**
|
|
3
|
-
* THE SPACING ROLES (
|
|
3
|
+
* THE SPACING ROLES (SPACING-ROLES; contexts/ui/scale.md "The spacing roles"). A distance between two things an app
|
|
4
4
|
* places is a ROLE the Grammar resolves (`Stack gap`, `Cluster gap`, `Grid`, `PaneSection`, `Page`, the inset of a Grammar box), never
|
|
5
5
|
* a raw value. The class-string half is the canon's `starci-fe/no-spacing-utility` (R350); this rule is the `style` half.
|
|
6
6
|
*
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
2
|
import { defineFamilyRules, defineRule, exemptFreestyle } from "./lib/rule-contract.js";
|
|
3
3
|
/**
|
|
4
|
-
* THE SPACING ROLES (
|
|
4
|
+
* THE SPACING ROLES (SPACING-ROLES; contexts/ui/scale.md "The spacing roles"). A distance between two things an app
|
|
5
5
|
* places is a ROLE the Grammar resolves (`Stack gap`, `Cluster gap`, `Grid`, `PaneSection`, `Page`, the inset of a Grammar box), never
|
|
6
6
|
* a raw value. The class-string half is the canon's `starci-fe/no-spacing-utility` (R350); this rule is the `style` half.
|
|
7
7
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
2
|
/**
|
|
3
|
-
* THE TYPE ROLES (
|
|
3
|
+
* THE TYPE ROLES (TYPE-ROLES). Type in an app is a role the Grammar draws: `<Text role="label.item">`, or the
|
|
4
4
|
* public class of the role (`starci-type-label-item`) on an element of the app's own. A raw size is a second type scale.
|
|
5
5
|
*
|
|
6
6
|
* WHAT IT READS, in product source (Grammar's own sources are not product source):
|
package/dist/no-raw-type-size.js
CHANGED
|
@@ -2,7 +2,7 @@ import { classTextVisitors } from "@starci/eslint-canon-fe/lib/class-text.mjs";
|
|
|
2
2
|
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
3
3
|
import { defineFamilyRules, defineRule, exemptFreestyle } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* THE TYPE ROLES (
|
|
5
|
+
* THE TYPE ROLES (TYPE-ROLES). Type in an app is a role the Grammar draws: `<Text role="label.item">`, or the
|
|
6
6
|
* public class of the role (`starci-type-label-item`) on an element of the app's own. A raw size is a second type scale.
|
|
7
7
|
*
|
|
8
8
|
* WHAT IT READS, in product source (Grammar's own sources are not product source):
|
package/dist/outline-icons.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
2
2
|
/**
|
|
3
|
-
* ICONS ARE OUTLINE ONLY (
|
|
3
|
+
* ICONS ARE OUTLINE ONLY (ICONS-OUTLINE). Never a filled or solid icon: no `@heroicons/react/16/solid`, `/20/solid` or `/24/solid`
|
|
4
4
|
* (and the same for `@starci/heroicons`' solid sets), no filled glyph, no filled-circle status mark. An icon that STANDS ALONE as the mark of a row, a
|
|
5
5
|
* card, an empty state or a graph step sits in an icon tile (a soft-tone square holding an outline icon); an icon INLINE with text (a status beside a
|
|
6
6
|
* 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 is a tone-coloured outline
|
package/dist/page-breadcrumbs.js
CHANGED
|
@@ -3,7 +3,7 @@ import { attributeOf, grammarName } from "./lib/grammar-jsx.js";
|
|
|
3
3
|
import { mountedOnlyUnderAuthGroup } from "./lib/page-frame.js";
|
|
4
4
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
5
5
|
/**
|
|
6
|
-
* The breadcrumbs law (
|
|
6
|
+
* The breadcrumbs law (PAGE-BREADCRUMBS): every console page states its trail. A `Page` whose
|
|
7
7
|
* `header` has no `breadcrumbs` leaves the reader without a way up; the root page of a console says so with
|
|
8
8
|
* `breadcrumbs: "root"` (the Grammar's `PageHeaderBreadcrumbs | "root"`; "root" draws no trail).
|
|
9
9
|
*
|
package/dist/page.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const tabsOutsideHeader: (parent: TSESTree.JSXElement | TSESTree.
|
|
|
6
6
|
export declare const pageTabsInHeader: Rule.RuleModule;
|
|
7
7
|
/**
|
|
8
8
|
* A route draws exactly one `Page` and nothing beside it: the page owner draws it, its pure half does, or the one connected
|
|
9
|
-
* block it renders as its root does.
|
|
9
|
+
* block it renders as its root does.
|
|
10
10
|
*/
|
|
11
11
|
export declare const routePageIsOnePage: Rule.RuleModule;
|
|
12
12
|
/** The rules these laws contribute to the plugin. */
|
package/dist/page.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { inSlot, isProductSource, kindOfFile } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
-
import { refuseGrammarExports } from "./lib/grammar-imports.js";
|
|
3
2
|
import { PURE_HALF, blockDrawsPage, mountedOnlyUnderAuthGroup, segmentFrame } from "./lib/page-frame.js";
|
|
4
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
5
4
|
/**
|
|
@@ -14,9 +13,8 @@ import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
|
14
13
|
* block it renders as its root, where client data builds the header a server owner cannot build. A route segment
|
|
15
14
|
* `layout` whose owner (`fe.feature`, kind `layouts`) draws, in the same ways, a `Page` whose `header` carries `tabs` is
|
|
16
15
|
* the one `Page` of every route under it: those page owners draw body content only, so a `Page` they draw is a second
|
|
17
|
-
* one, and they need none. A `Page` (or a block that draws one) with an element sibling, a `Page` inside another,
|
|
18
|
-
*
|
|
19
|
-
* are not exported, so the law reads the import and nothing else of them. A page
|
|
16
|
+
* one, and they need none. A `Page` (or a block that draws one) with an element sibling, or a `Page` inside another, is the
|
|
17
|
+
* finding. A page
|
|
20
18
|
* owner file that draws JSX but no `Page` in one of those ways has no page frame at all, unless a segment layout frames
|
|
21
19
|
* every route that mounts it, or every such route lies under the auth route group `(auth)` with its own layout: that
|
|
22
20
|
* layout draws the auth frame, the page frame of its sign-in, sign-up, password and callback pages.
|
|
@@ -82,8 +80,6 @@ export const pageTabsInHeader = defineRule({
|
|
|
82
80
|
};
|
|
83
81
|
},
|
|
84
82
|
});
|
|
85
|
-
/** The Grammar exports that are Page's parts and no longer public. */
|
|
86
|
-
const PAGE_PARTS = new Set(["PageHeader", "PageContainer"]);
|
|
87
83
|
/** The owner kind a file belongs to: a page owner or a layout owner (`fe.feature`, kind `pages` or `layouts`), or null. */
|
|
88
84
|
const ownerKind = (context) => {
|
|
89
85
|
if (!inSlot(context, "fe.feature"))
|
|
@@ -106,17 +102,16 @@ const enclosingElement = (node) => {
|
|
|
106
102
|
};
|
|
107
103
|
/**
|
|
108
104
|
* A route draws exactly one `Page` and nothing beside it: the page owner draws it, its pure half does, or the one connected
|
|
109
|
-
* block it renders as its root does.
|
|
105
|
+
* block it renders as its root does.
|
|
110
106
|
*/
|
|
111
107
|
export const routePageIsOnePage = defineRule({
|
|
112
108
|
meta: {
|
|
113
109
|
type: "problem",
|
|
114
|
-
docs: { description: "R325: a route draws one Page (in its page owner, its pure half or its one root block, or in the layout of its tabbed segment) with nothing beside it,
|
|
110
|
+
docs: { description: "R325: a route draws one Page (in its page owner, its pure half or its one root block, or in the layout of its tabbed segment) with nothing beside it, and never no Page at all." },
|
|
115
111
|
schema: [],
|
|
116
112
|
messages: {
|
|
117
113
|
sibling: "This `{{name}}` draws the route's `Page` and has a sibling: a route page is one `Page`, and whatever sits beside it escapes the header band, the measure and the rhythm `Page` owns. Move the sibling into the `Page` body (as the block's children when a block draws the `Page`), or into `header` when it heads the page.",
|
|
118
114
|
twice: "This `{{name}}` draws a second `Page` inside the route's `Page`{{framer}}: a route page is exactly one `Page`, so the band, the measure and the rhythm would be decided twice. Draw its content as the body of the one `Page`.",
|
|
119
|
-
part: "`{{name}}` is a part of `Page`, not an export: a page or layout owner composes `Page` (`header` for the band, `measure` for the body), so the inset and the rhythm have one owner. Replace it with `Page`.",
|
|
120
115
|
missing: "This page owner draws no `Page`: a route page is one Grammar `Page`, which owns the header band, the measure and the rhythm, so without it the page has no heading band and its body sits on no inset. Wrap what it draws in a `Page` whose `header.title` is the page heading (never a `Heading` of its own), draw it through the owner's pure half in `./component`, or render as the root the one connected block that draws the `Page` from client data.",
|
|
121
116
|
},
|
|
122
117
|
},
|
|
@@ -144,16 +139,8 @@ export const routePageIsOnePage = defineRule({
|
|
|
144
139
|
const opening = element.openingElement.name;
|
|
145
140
|
return opening.type === "JSXIdentifier" && appImports.has(opening.name) && blockDrawsPage(context, element.openingElement);
|
|
146
141
|
};
|
|
147
|
-
const parts = refuseGrammarExports(PAGE_PARTS, ({ node, name }) => {
|
|
148
|
-
// The part's own finding already says to draw a `Page` instead; the missing Page is not reported twice.
|
|
149
|
-
drawsPage = true;
|
|
150
|
-
context.report({ node, messageId: "part", data: { name } });
|
|
151
|
-
});
|
|
152
142
|
return {
|
|
153
|
-
MemberExpression: parts.MemberExpression,
|
|
154
|
-
JSXMemberExpression: parts.JSXMemberExpression,
|
|
155
143
|
ImportDeclaration(declaration) {
|
|
156
|
-
parts.ImportDeclaration(declaration);
|
|
157
144
|
const source = String(declaration.source.value);
|
|
158
145
|
const into = PURE_HALF.test(source) ? pureHalf : APP_SOURCE.test(source) ? appImports : null;
|
|
159
146
|
if (into === null || declaration.importKind === "type")
|
package/dist/pane.js
CHANGED
|
@@ -5,7 +5,7 @@ import { typedClassStrings } from "@starci/eslint-canon-fe/lib/typed-class-value
|
|
|
5
5
|
import { defineFamilyRules, defineRule, exemptFreestyle } from "./lib/rule-contract.js";
|
|
6
6
|
/**
|
|
7
7
|
* The pane laws (HFS R345 `FE_PANE_GRID_CHILD_NOT_PANE`, R346 `FE_PANE_CHILD_NOT_SECTION`, R347 `FE_PANE_SECTION_PADDING`, R348
|
|
8
|
-
* `FE_PANE_GRID_FRAME`): a `PaneGrid` holds `Pane`s, a `Pane` holds `PaneSection`s (or one nested `PaneGrid`), a
|
|
8
|
+
* `FE_PANE_GRID_FRAME`): a `PaneGrid` holds `Pane`s, a `Pane` holds `PaneSection`s (or one nested `PaneGrid`, or the one `ChatFrame` of a chat pane), a
|
|
9
9
|
* `PaneSection` takes its inset from the pane it stands in, and a `PaneGrid` stands in a `Page chrome="panes"` or in a `Pane`;
|
|
10
10
|
* the one child of `Page chrome="panes"` is a `PaneGrid` element written there, never a component that renders one (Page throws
|
|
11
11
|
* `PAGE_PANES_CHILD_NOT_PANE_GRID` at run time for anything else).
|
|
@@ -182,7 +182,7 @@ export const paneGridChildren = exemptFreestyle(defineRule({
|
|
|
182
182
|
const describePaneChild = (context, element) => {
|
|
183
183
|
const name = element.openingElement.name;
|
|
184
184
|
const element_ = nameOf(name);
|
|
185
|
-
if (element_ === "PaneSection" || element_ === "PaneGrid" || element_ === "Freestyle")
|
|
185
|
+
if (element_ === "PaneSection" || element_ === "PaneGrid" || element_ === "ChatFrame" || element_ === "Freestyle")
|
|
186
186
|
return null;
|
|
187
187
|
if (isDomName(name))
|
|
188
188
|
return `The raw \`<${element_ ?? "element"}>\``;
|
|
@@ -206,10 +206,10 @@ const paneElements = (context, parent) => leavesOf(context, parent).flatMap((lea
|
|
|
206
206
|
export const paneChildren = exemptFreestyle(defineRule({
|
|
207
207
|
meta: {
|
|
208
208
|
type: "problem",
|
|
209
|
-
docs: { description: "R346: a Pane holds PaneSection elements (or one PaneGrid), never a raw element or another Grammar component.", url: "knowledge/hfs/rules.yaml#R346" },
|
|
209
|
+
docs: { description: "R346: a Pane holds PaneSection elements (or one PaneGrid, or one ChatFrame), never a raw element or another Grammar component.", url: "knowledge/hfs/rules.yaml#R346" },
|
|
210
210
|
schema: [],
|
|
211
211
|
messages: {
|
|
212
|
-
notSection: "{{what}} is placed straight in a `Pane`, so it skips the inset the pane publishes to its bands. Wrap it in a `<PaneSection>` (with `grow`, `scroll`, `align` or `bleed` as the band needs),
|
|
212
|
+
notSection: "{{what}} is placed straight in a `Pane`, so it skips the inset the pane publishes to its bands. Wrap it in a `<PaneSection>` (with `grow`, `scroll`, `align` or `bleed` as the band needs), make the pane's one child a nested `<PaneGrid>`, or for a chat pane (`content=\"chat\"`) its one child a `<ChatFrame>`.",
|
|
213
213
|
},
|
|
214
214
|
},
|
|
215
215
|
create(context) {
|
package/dist/same-line-size.js
CHANGED
|
@@ -12,7 +12,7 @@ import { attributeOf, elementOf, grammarBindings, literalAttribute } from "./lib
|
|
|
12
12
|
/** The line containers: a Cluster lays its children on one line, a Text holds runs. */
|
|
13
13
|
const LINES = new Set(["Cluster", "Text"]);
|
|
14
14
|
/** The size step a Text states: its literal `size` (`sm` folds into `md`, both 14), `md` when it has none, null when it cannot be read. */
|
|
15
|
-
/** The size step of each type role
|
|
15
|
+
/** The size step of each type role, in the names of the `size` steps where one is the same size. */
|
|
16
16
|
const ROLE_STEP = {
|
|
17
17
|
figure: "figure", "title.page": "title.page", "title.section": "title.section", "label.item": "md", body: "md",
|
|
18
18
|
"label.field": "label.field", "label.group": "xs", caption: "xs", badge: "xs", code: "xs",
|
|
@@ -2,9 +2,9 @@ import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
|
2
2
|
import { attributeOf, grammarName, literalString } from "./lib/grammar-jsx.js";
|
|
3
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
4
|
/**
|
|
5
|
-
* THE SECTION HEAD (
|
|
5
|
+
* THE SECTION HEAD (SECTION-HEAD-ACTION). A section's head is ONE row: the label (14, 500) and an optional count chip at the
|
|
6
6
|
* start, and at the end at most ONE thing: a navigation `Link variant="head"` (the label then an arrow that slides on hover), an info `IconButton`,
|
|
7
|
-
* or
|
|
7
|
+
* or a border small `Button` ("Add provider"). The head never holds two commands.
|
|
8
8
|
*
|
|
9
9
|
* WHAT IT READS. A Grammar `Section` in product source whose `action` prop holds:
|
|
10
10
|
* - a Grammar `Button` that is not a `border` (the default look, or `variant="border"`) at `size="sm"` (message `button`: a primary, a danger or any other size is refused);
|