@starci/eslint-grammar-core 0.27.1 → 0.28.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 +19 -0
- package/README.md +2 -1
- package/dist/button-arrow.d.ts +7 -0
- package/dist/button-arrow.js +146 -0
- package/dist/field-label.d.ts +7 -0
- package/dist/field-label.js +83 -0
- package/dist/gap-proximity.d.ts +7 -0
- package/dist/gap-proximity.js +194 -0
- package/dist/index.js +18 -0
- package/dist/lib/cross-file-inputs.js +3 -0
- package/dist/lib/grammar-jsx.d.ts +27 -0
- package/dist/lib/grammar-jsx.js +136 -0
- package/dist/lib/row-context.d.ts +25 -0
- package/dist/lib/row-context.js +134 -0
- package/dist/lib/why.js +50 -0
- package/dist/page-breadcrumbs.d.ts +7 -0
- package/dist/page-breadcrumbs.js +103 -0
- package/dist/row-title-link.d.ts +6 -0
- package/dist/row-title-link.js +172 -0
- package/dist/same-line-size.d.ts +6 -0
- package/dist/same-line-size.js +93 -0
- package/dist/surface-in-surface.d.ts +7 -0
- package/dist/surface-in-surface.js +84 -0
- package/dist/table-cell-type.d.ts +6 -0
- package/dist/table-cell-type.js +122 -0
- package/dist/tabs.d.ts +9 -0
- package/dist/tabs.js +147 -0
- package/docs/button-arrow.md +34 -0
- package/docs/field-label.md +26 -0
- package/docs/gap-proximity.md +31 -0
- package/docs/page-breadcrumbs.md +28 -0
- package/docs/row-title-link.md +30 -0
- package/docs/same-line-size.md +26 -0
- package/docs/surface-in-surface.md +28 -0
- package/docs/table-cell-type.md +32 -0
- package/docs/tabs.md +48 -0
- package/package.json +4 -4
- package/runtime/bundle.json +1 -0
- package/runtime/knowledge/ui/presentation/grammar-laws.yaml +102 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.28.0 - 2026-11-09
|
|
4
|
+
|
|
5
|
+
- Changed: released with the Grammar family at 0.28.0; peers `@starci/hfs ~6.5.0`. The new rules below are errors, with no escape.
|
|
6
|
+
|
|
7
|
+
- Added: `button-arrow` (`FE_BUTTON_ARROW`, BUTTON-ARROW): a `Button` that leads somewhere takes `endArrow`; an arrow typed in its label (`→ ← ➜ ➔ ⟶ › »`, `->`), an arrow or end-chevron icon passed as `endContent`, and `endArrow` with `startGlyph`/`startContent` are refused. `docs/button-arrow.md`.
|
|
8
|
+
- Added: `table-cell-type` (`FE_TABLE_CELL_TYPE`, TABLE-CELL-TYPE): no `Text size="figure"`, `Heading`, `Label` or `h1`-`h6` in a DataTable `renderCell` (or column `editor`) or in the `title`/`description` of a ListRow data object. `docs/table-cell-type.md`.
|
|
9
|
+
- Added: `same-line-size` (`FE_SAME_LINE_SIZE`, SAME-LINE-SIZE): the `Text` children of one `Cluster` (or of a `Text` holding runs) share one `size` (absent is `md`); Badge, StatusDot, Chip and TagGroup are exempt, a non-literal size is skipped. `docs/same-line-size.md`.
|
|
10
|
+
- Added: `row-title-link` (`FE_ROW_TITLE_LINK`, ROW-TITLE-LINK): a `Link` as the title of a ListRow data object that has `onPress`, `onAction`, `href`, `onFollow` or `chevron`, or as the row-header cell of a DataTable whose rows open (`onRowAction` or row `href`), is refused: the row is the one pressable. `docs/row-title-link.md`.
|
|
11
|
+
- Added: `tabs-switch-zone` (`FE_TABS_SWITCH_ZONE`, TABS-SWITCH-ZONE): a pill (`Tabs appearance="primary"`) written in JSX is refused; it is drawn only as the `switch` header zone of a card. `no-primary-tabs-misuse` keeps the item checks.
|
|
12
|
+
- Added: `tabs-depth` (`FE_TABS_DEPTH`, TABS-DEPTH): at most two underline `Tabs` layers (the `Page header.tabs` and one region set, nested through the panel a `selectedKey` guards). Every tab is one size, so only the count is judged. `docs/tabs.md` says what each reads.
|
|
13
|
+
- Added: `gap-proximity` (`FE_GAP_PROXIMITY`, GAP-PROXIMITY): a Grammar layout element (Stack, Cluster, PaneSection, Section, Grid, Form, Fieldset) nested directly in another (through fragments, `cond && x`, `cond ? x : null` and `.map`) stands at least one gap step closer (identity 4 < inline 8 < row 12 < section 24 < region 32). A SurfaceCard, Drawer and Dialog reset it; a field stack inside a Form or Fieldset and `Grid kind="main-rail"` are exempt. `docs/gap-proximity.md`.
|
|
14
|
+
- Added: `field-label` (`FE_FIELD_LABEL`, FIELD-LABEL): a `Text`, `Label`, `label` or `span` standing right before a Grammar form control that has no `label` prop is a hand-made label; use the control's `label` prop. `docs/field-label.md`.
|
|
15
|
+
- Added: `surface-in-surface` (`FE_SURFACE_IN_SURFACE`, SURFACE-IN-SURFACE): a hand-made row list (Stack, ul, ol or div whose rows are divided by `Divider`) inside a SurfaceCard, Drawer, Dialog, PaneSection or main-rail rail is refused; use `Section kind="list"` or `SurfaceCard kind="list"`. `docs/surface-in-surface.md`.
|
|
16
|
+
- Added: `page-breadcrumbs` (`FE_PAGE_BREADCRUMBS`, PAGE-BREADCRUMBS): the `header` object of a console `Page` (page owner, layout owner or app block, not a boundary or `(auth)` page) states `breadcrumbs`, or `breadcrumbs: "root"` for the root page. `docs/page-breadcrumbs.md`.
|
|
17
|
+
|
|
18
|
+
## 0.27.2 - 2026-11-09
|
|
19
|
+
|
|
20
|
+
- Changed: peers `@starci/hfs ~6.5.0`; no lint rule changed.
|
|
21
|
+
|
|
3
22
|
## 0.27.1 - 2026-11-09
|
|
4
23
|
|
|
5
24
|
- Changed: its lint family peers `@starci/hfs ~6.4.0`; no lint rule changed.
|
package/README.md
CHANGED
|
@@ -19,9 +19,10 @@ Family helpers and the generated runtime closure belong to this package.
|
|
|
19
19
|
|
|
20
20
|
The rule IDs remain stable when their namespace moves. Laws cover the fixed app shell and navbar,
|
|
21
21
|
Grammar-owned structural elements, glyphs and icon sizes, destructive menu entries, status inks,
|
|
22
|
-
chip labels that start uppercase, 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). Each rule's metadata cites
|
|
22
|
+
chip labels that start uppercase, a Button that leads somewhere ending with `endArrow` (no typed or icon arrow), 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 `switch` header zone of a card, 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
|
+
The proximity and composition laws of 2026-11-09 each have a doc: `gap-proximity` (a layout element stands at least one gap step closer than its layout parent), `field-label` (a control is labelled by its own `label` prop), `surface-in-surface` (a hand-made divided row list in a surface is `Section kind="list"`) and `page-breadcrumbs` (a console `Page` header states `breadcrumbs`, or `"root"`).
|
|
25
26
|
|
|
26
27
|
## Migrating from @starci/eslint-canon-fe 8.x
|
|
27
28
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** A Button leads somewhere with `endArrow` and does something with `startGlyph`; no typed arrow, no arrow icon, never both. */
|
|
3
|
+
export declare const buttonArrow: Rule.RuleModule;
|
|
4
|
+
/** The rules this law contributes to the plugin. */
|
|
5
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
6
|
+
/** Every rule of this law is an error. */
|
|
7
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
|
+
import { attributeOf, descendants, elementOf, grammarBindings } from "./lib/row-context.js";
|
|
4
|
+
/**
|
|
5
|
+
* The button arrow law (`FE_BUTTON_ARROW`): a Button that leads somewhere ends with `endArrow`; a Button that does something
|
|
6
|
+
* starts with a `startGlyph`. The arrow of a destination is the Grammar's own (it slides toward the reading end on hover and is
|
|
7
|
+
* mirrored in RTL); a typed `→` or a passed-in arrow icon does neither.
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT READS. A `Button` bound to `@starci/grammar`:
|
|
10
|
+
* - a label (children) that states an arrow literally: `→ ← ➜ ➔ ⟶ › »` or ASCII `->`;
|
|
11
|
+
* - an `endContent` that is an arrow: an element named `Arrow*` or `ChevronRight*`, or any element whose `source` / `glyph` / `name`
|
|
12
|
+
* is such an identifier or a string that names `arrow`, `chevron-right` or `chevron-end`;
|
|
13
|
+
* - `endArrow` together with `startGlyph` or `startContent` (the Button type refuses it as well).
|
|
14
|
+
* `Button` takes the label as its children only, so no string label prop exists to read. `IconButton` has no label to type an arrow
|
|
15
|
+
* in and no `endArrow`; `TextAction` takes `endContent` but not `endArrow`, so neither is judged.
|
|
16
|
+
*/
|
|
17
|
+
/** A label arrow: a character that points, or the ASCII `->`. */
|
|
18
|
+
const LABEL_ARROW = /[→←➜➔⟶›»]|->/u;
|
|
19
|
+
/** A glyph or icon name that is an arrow or an end-pointing chevron, whatever its case and separators. */
|
|
20
|
+
const isArrowName = (name) => {
|
|
21
|
+
const flat = name.toLowerCase().replace(/[^a-z0-9]/gu, "");
|
|
22
|
+
return flat.includes("arrow") || /chevron(?:double)?(?:right|end)/u.test(flat);
|
|
23
|
+
};
|
|
24
|
+
const nameOfElement = (opening) => {
|
|
25
|
+
const name = opening.name;
|
|
26
|
+
if (name.type === "JSXIdentifier")
|
|
27
|
+
return name.name;
|
|
28
|
+
if (name.type === "JSXMemberExpression")
|
|
29
|
+
return name.property.name;
|
|
30
|
+
return null;
|
|
31
|
+
};
|
|
32
|
+
/** True when the value of a prop names an arrow: an identifier (`ArrowRightIcon`) or a string (`"arrow-right"`). */
|
|
33
|
+
const valueNamesArrow = (value) => {
|
|
34
|
+
if (value == null)
|
|
35
|
+
return false;
|
|
36
|
+
if (value.type === "Literal")
|
|
37
|
+
return typeof value.value === "string" && isArrowName(value.value);
|
|
38
|
+
if (value.type !== "JSXExpressionContainer")
|
|
39
|
+
return false;
|
|
40
|
+
const expression = value.expression;
|
|
41
|
+
if (expression.type === "Identifier")
|
|
42
|
+
return isArrowName(expression.name);
|
|
43
|
+
if (expression.type === "Literal")
|
|
44
|
+
return typeof expression.value === "string" && isArrowName(expression.value);
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
47
|
+
/** Whether an `endContent` expression holds an arrow element. */
|
|
48
|
+
const endContentIsArrow = (container, source) => {
|
|
49
|
+
for (const node of descendants(container, source)) {
|
|
50
|
+
if (node.type !== "JSXOpeningElement")
|
|
51
|
+
continue;
|
|
52
|
+
const name = nameOfElement(node);
|
|
53
|
+
if (name !== null && isArrowName(name))
|
|
54
|
+
return true;
|
|
55
|
+
for (const attribute of node.attributes) {
|
|
56
|
+
if (attribute.type === "JSXAttribute" && attribute.name.type === "JSXIdentifier" && ["source", "glyph", "name"].includes(attribute.name.name) && valueNamesArrow(attribute.value))
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
};
|
|
62
|
+
/** The literal text a child states: JSX text, a string, a template without expressions, and the branches of a conditional. */
|
|
63
|
+
function* literalTexts(node) {
|
|
64
|
+
if (!node)
|
|
65
|
+
return;
|
|
66
|
+
switch (node.type) {
|
|
67
|
+
case "JSXText":
|
|
68
|
+
yield { node, text: node.value };
|
|
69
|
+
return;
|
|
70
|
+
case "JSXExpressionContainer":
|
|
71
|
+
yield* literalTexts(node.expression);
|
|
72
|
+
return;
|
|
73
|
+
case "Literal":
|
|
74
|
+
if (typeof node.value === "string")
|
|
75
|
+
yield { node, text: node.value };
|
|
76
|
+
return;
|
|
77
|
+
case "TemplateLiteral":
|
|
78
|
+
for (const quasi of node.quasis)
|
|
79
|
+
yield { node: quasi, text: quasi.value.cooked ?? "" };
|
|
80
|
+
return;
|
|
81
|
+
case "ConditionalExpression":
|
|
82
|
+
yield* literalTexts(node.consequent);
|
|
83
|
+
yield* literalTexts(node.alternate);
|
|
84
|
+
return;
|
|
85
|
+
case "LogicalExpression":
|
|
86
|
+
yield* literalTexts(node.right);
|
|
87
|
+
return;
|
|
88
|
+
default:
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** A Button leads somewhere with `endArrow` and does something with `startGlyph`; no typed arrow, no arrow icon, never both. */
|
|
92
|
+
export const buttonArrow = defineRule({
|
|
93
|
+
meta: {
|
|
94
|
+
type: "problem",
|
|
95
|
+
docs: { description: "FE_BUTTON_ARROW: a Button that leads somewhere ends with `endArrow`; one that does something starts with `startGlyph`." },
|
|
96
|
+
schema: [],
|
|
97
|
+
messages: {
|
|
98
|
+
label: "The Button label types an arrow (`{{text}}`). A Button that leads somewhere takes `endArrow`: the Grammar arrow slides toward the reading end on hover and is mirrored in RTL. Remove the character from the label and add `endArrow`; keep the start side (`startGlyph`) for what the action does and the end side for where it goes.",
|
|
99
|
+
endContent: "The Button passes an arrow icon as `endContent`. A Button that leads somewhere takes `endArrow` (the Grammar arrow that slides on hover and is mirrored in RTL). Replace the `endContent` arrow with `endArrow`.",
|
|
100
|
+
both: "The Button sets `endArrow` and `{{start}}`. A Button either leads somewhere (`endArrow`) or does something (`startGlyph`), never both. Keep the one that says what the Button is.",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
create(context) {
|
|
104
|
+
if (!isProductSource(context))
|
|
105
|
+
return {};
|
|
106
|
+
let bound = new Map();
|
|
107
|
+
return {
|
|
108
|
+
Program(program) {
|
|
109
|
+
bound = grammarBindings(program);
|
|
110
|
+
},
|
|
111
|
+
JSXElement(element) {
|
|
112
|
+
const opening = element.openingElement;
|
|
113
|
+
if (elementOf(opening, bound).grammar !== "Button")
|
|
114
|
+
return;
|
|
115
|
+
for (const child of element.children) {
|
|
116
|
+
for (const { node, text } of literalTexts(child)) {
|
|
117
|
+
const found = LABEL_ARROW.exec(text);
|
|
118
|
+
if (found)
|
|
119
|
+
context.report({ node, messageId: "label", data: { text: found[0] } });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const endContent = attributeOf(opening, "endContent");
|
|
123
|
+
if (endContent?.value?.type === "JSXExpressionContainer" && endContentIsArrow(endContent.value, context.sourceCode)) {
|
|
124
|
+
context.report({ node: endContent, messageId: "endContent" });
|
|
125
|
+
}
|
|
126
|
+
const endArrow = attributeOf(opening, "endArrow");
|
|
127
|
+
if (endArrow === null)
|
|
128
|
+
return;
|
|
129
|
+
const isOff = endArrow.value?.type === "JSXExpressionContainer" && endArrow.value.expression.type === "Literal" && endArrow.value.expression.value === false;
|
|
130
|
+
if (isOff)
|
|
131
|
+
return;
|
|
132
|
+
for (const start of ["startGlyph", "startContent"]) {
|
|
133
|
+
if (attributeOf(opening, start) !== null)
|
|
134
|
+
context.report({ node: opening, messageId: "both", data: { start } });
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
/** The rules this law contributes to the plugin. */
|
|
141
|
+
export const rules = {
|
|
142
|
+
"button-arrow": buttonArrow,
|
|
143
|
+
};
|
|
144
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#BUTTON-ARROW");
|
|
145
|
+
/** Every rule of this law is an error. */
|
|
146
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** A control is labelled by its own `label` prop, never by a Text standing beside it. */
|
|
3
|
+
export declare const fieldLabel: Rule.RuleModule;
|
|
4
|
+
/** The rules this law contributes to the plugin. */
|
|
5
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
6
|
+
/** Every rule of this law is an error. */
|
|
7
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { FORM_CONTROLS, attributeOf, elementNameOf, grammarName, nameOf, renderedChildren } from "./lib/grammar-jsx.js";
|
|
3
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* The field label law (owner, 2026-11-09, FIELD-LABEL): a control is labelled by its own `label` prop. The Field
|
|
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
|
+
* last one). A `Text` placed beside the control as its label is spaced by whoever placed it, and the rhythm drifts.
|
|
8
|
+
*
|
|
9
|
+
* WHAT IT READS. In one element's rendered children (looked through fragments, `cond && <x/>`, `cond ? <x/> : null` and
|
|
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,
|
|
12
|
+
* TimeField, SearchField, Slider, CopyField) that carries no `label` prop (a control that has only an `aria-label`
|
|
13
|
+
* included). A hand-made label is a Grammar `Text` or a `Label`, or a plain `<label>` or `<span>` whose children are
|
|
14
|
+
* literal text.
|
|
15
|
+
*
|
|
16
|
+
* WHAT IT LEAVES ALONE. A control with a `label` prop, a control with a JSX spread (the label may arrive through it), a
|
|
17
|
+
* `Text` that is not immediately before a control, and any text beside a control that is not a Grammar form control.
|
|
18
|
+
*
|
|
19
|
+
* WHERE IT APPLIES. Product source (`isProductSource`).
|
|
20
|
+
*/
|
|
21
|
+
/** Plain elements that read as a label when their children are literal text. */
|
|
22
|
+
const PLAIN_LABELS = new Set(["label", "span"]);
|
|
23
|
+
/** True when every rendered child is literal text and there is some. */
|
|
24
|
+
const literalText = (element) => {
|
|
25
|
+
const children = renderedChildren(element.children);
|
|
26
|
+
return children.length > 0 && children.every((child) => child.type === "JSXText" || (child.type === "Literal" && typeof child.value === "string"));
|
|
27
|
+
};
|
|
28
|
+
/** True when a rendered child is a hand-made label. */
|
|
29
|
+
const isHandLabel = (context, node) => {
|
|
30
|
+
if (node.type !== "JSXElement")
|
|
31
|
+
return false;
|
|
32
|
+
const name = nameOf(node.openingElement.name);
|
|
33
|
+
if (name === null)
|
|
34
|
+
return false;
|
|
35
|
+
if (name === "Text" || name === "Label")
|
|
36
|
+
return grammarName(context, node.openingElement) !== null;
|
|
37
|
+
return PLAIN_LABELS.has(name) && node.openingElement.name.type === "JSXIdentifier" && literalText(node);
|
|
38
|
+
};
|
|
39
|
+
/** A control is labelled by its own `label` prop, never by a Text standing beside it. */
|
|
40
|
+
export const fieldLabel = defineRule({
|
|
41
|
+
meta: {
|
|
42
|
+
type: "problem",
|
|
43
|
+
docs: { description: "FIELD-LABEL: a form control is labelled by its own label prop, never by a Text, Label, label or span placed before it." },
|
|
44
|
+
schema: [],
|
|
45
|
+
messages: {
|
|
46
|
+
handMade: "This text is a hand-made label for `{{control}}`: use the control's `label` prop instead. The Field contract spaces label to control 8 and control to help 4, and the Form or the field stack sets field to field 24, so a label placed beside the control re-decides that rhythm.",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
create(context) {
|
|
50
|
+
if (!isProductSource(context))
|
|
51
|
+
return {};
|
|
52
|
+
const reported = new Set();
|
|
53
|
+
const judge = (children) => {
|
|
54
|
+
const flat = renderedChildren(children);
|
|
55
|
+
flat.forEach((node, index) => {
|
|
56
|
+
if (node.type !== "JSXElement" || index === 0)
|
|
57
|
+
return;
|
|
58
|
+
const control = grammarName(context, node.openingElement);
|
|
59
|
+
if (control === null || !FORM_CONTROLS.has(control))
|
|
60
|
+
return;
|
|
61
|
+
const opening = node.openingElement;
|
|
62
|
+
if (attributeOf(opening, "label") !== undefined || opening.attributes.some((entry) => entry.type === "JSXSpreadAttribute"))
|
|
63
|
+
return;
|
|
64
|
+
const previous = flat[index - 1];
|
|
65
|
+
if (previous === undefined || !isHandLabel(context, previous) || reported.has(previous))
|
|
66
|
+
return;
|
|
67
|
+
reported.add(previous);
|
|
68
|
+
context.report({ node: previous, messageId: "handMade", data: { control: elementNameOf(node) ?? control } });
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
return {
|
|
72
|
+
JSXElement(element) { judge(element.children); },
|
|
73
|
+
JSXFragment(fragment) { judge(fragment.children); },
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
/** The rules this law contributes to the plugin. */
|
|
78
|
+
export const rules = {
|
|
79
|
+
"field-label": fieldLabel,
|
|
80
|
+
};
|
|
81
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#FIELD-LABEL");
|
|
82
|
+
/** Every rule of this law is an error. */
|
|
83
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** A layout element nests at least one step tighter than its layout parent. */
|
|
3
|
+
export declare const gapProximity: Rule.RuleModule;
|
|
4
|
+
/** The rules this law contributes to the plugin. */
|
|
5
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
6
|
+
/** Every rule of this law is an error. */
|
|
7
|
+
export declare const recommended: Record<string, "error">;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { FORM_CONTROLS, attributeOf, elementNameOf, grammarName, isFragmentElement, renderedChildren, stringProp } from "./lib/grammar-jsx.js";
|
|
3
|
+
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
4
|
+
/**
|
|
5
|
+
* The proximity law (owner, 2026-11-09, GAP-PROXIMITY): inside any container, its children stand at least ONE step
|
|
6
|
+
* closer than the container stands to its siblings. The gap roles rise strictly: identity 4 < inline 8 < row 12 <
|
|
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
|
+
* parts read as far apart as the parent's siblings, so the grouping disappears.
|
|
9
|
+
*
|
|
10
|
+
* WHAT IT READS. A Grammar layout element (imported from `@starci/grammar`) nested DIRECTLY in another: through plain
|
|
11
|
+
* fragments, `{cond ? <x/> : null}`, `{cond && <x/>}` and `{items.map(() => <x/>)}`, never through another element.
|
|
12
|
+
* Roles: `Stack` and `Cluster` are their `gap` literal (a non-literal gap has no role and is skipped); `PaneSection` is
|
|
13
|
+
* its `gap`, default `inline`; `Section` is `row` (its head, filter and body stand 12 apart); `Grid` by kind (`cards`,
|
|
14
|
+
* `week`, `week-summary` inline; `sections`, `pair`, `featured`, `form` section; `main-rail` region); `Form` and
|
|
15
|
+
* `Fieldset` are section (their fields stand 24 apart).
|
|
16
|
+
*
|
|
17
|
+
* WHAT IT LEAVES ALONE.
|
|
18
|
+
* - A `SurfaceCard`, `Drawer`, `Dialog`, `AlertDialog` or `Popover` is a reset: a surface is its own edge, so what
|
|
19
|
+
* stands inside it is not compared with anything outside it.
|
|
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,
|
|
22
|
+
* SearchField, Slider, CopyField, Fieldset, Field), directly inside a `Form` or a `Fieldset` (a Drawer body is
|
|
23
|
+
* a reset already). Fields stand 24 apart; that is the Field rule's own rhythm.
|
|
24
|
+
* - `Grid kind="main-rail"`: nothing in it is compared with it, and it is not compared with a region parent. It fixes
|
|
25
|
+
* its own role and region is the top of the scale, so there is nothing to step down to.
|
|
26
|
+
* - The props of a Grid (`main`, `rail`, `featured`...) are not children.
|
|
27
|
+
*
|
|
28
|
+
* Region is the top of the scale: any other region child in a region parent is still reported (the app steps it down).
|
|
29
|
+
*
|
|
30
|
+
* WHERE IT APPLIES. Product source (`isProductSource`).
|
|
31
|
+
*/
|
|
32
|
+
/** The gap roles, narrowest first. */
|
|
33
|
+
const ROLES = ["identity", "inline", "row", "section", "region"];
|
|
34
|
+
const PIXELS = { identity: 4, inline: 8, row: 12, section: 24, region: 32 };
|
|
35
|
+
/** The layout elements whose gap is a role. */
|
|
36
|
+
const LAYOUTS = new Set(["Stack", "Cluster", "PaneSection", "Section", "Grid", "Form", "Fieldset"]);
|
|
37
|
+
/** The elements that are a surface of their own: nothing inside is compared with anything outside. */
|
|
38
|
+
const RESETS = new Set(["SurfaceCard", "Drawer", "Dialog", "AlertDialog", "Popover"]);
|
|
39
|
+
/** What a field stack holds. */
|
|
40
|
+
const FIELD_CHILDREN = new Set([...FORM_CONTROLS, "Fieldset", "Field"]);
|
|
41
|
+
const GRID_ROLES = {
|
|
42
|
+
cards: "inline", week: "inline", "week-summary": "inline", sections: "section", pair: "section", featured: "section", form: "section", "main-rail": "region",
|
|
43
|
+
};
|
|
44
|
+
const isRole = (value) => value !== null && ROLES.includes(value);
|
|
45
|
+
/** The role of a layout element, or null when it is not a layout element or states no literal role. */
|
|
46
|
+
const roleOf = (context, element) => {
|
|
47
|
+
const opening = element.openingElement;
|
|
48
|
+
const name = grammarName(context, opening);
|
|
49
|
+
if (name === null || !LAYOUTS.has(name))
|
|
50
|
+
return null;
|
|
51
|
+
if (name === "Stack" || name === "Cluster") {
|
|
52
|
+
const gap = stringProp(opening, "gap");
|
|
53
|
+
return isRole(gap) ? { name, role: gap, steppable: true } : null;
|
|
54
|
+
}
|
|
55
|
+
if (name === "PaneSection") {
|
|
56
|
+
if (attributeOf(opening, "gap") === undefined)
|
|
57
|
+
return { name, role: "inline", steppable: true };
|
|
58
|
+
const gap = stringProp(opening, "gap");
|
|
59
|
+
return isRole(gap) ? { name, role: gap, steppable: true } : null;
|
|
60
|
+
}
|
|
61
|
+
if (name === "Section")
|
|
62
|
+
return { name, role: "row", steppable: false };
|
|
63
|
+
if (name === "Grid") {
|
|
64
|
+
const kind = stringProp(opening, "kind");
|
|
65
|
+
const role = kind === null ? undefined : GRID_ROLES[kind];
|
|
66
|
+
return role === undefined || kind === null ? null : { name: `${name} kind="${kind}"`, role, steppable: false };
|
|
67
|
+
}
|
|
68
|
+
return { name, role: "section", steppable: false };
|
|
69
|
+
};
|
|
70
|
+
/** True when the `.map` call-back is a function passed to a `.map` call. */
|
|
71
|
+
const isMapCallback = (fn) => {
|
|
72
|
+
const call = fn.parent;
|
|
73
|
+
if (call?.type !== "CallExpression" || call.arguments[0] !== fn)
|
|
74
|
+
return false;
|
|
75
|
+
const callee = call.callee;
|
|
76
|
+
return callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" && callee.property.name === "map";
|
|
77
|
+
};
|
|
78
|
+
/** The element a node is a rendered child of, looking through fragments, conditions, `&&` and `.map`; null when it is not a child (an attribute, a call argument). */
|
|
79
|
+
const parentElement = (node) => {
|
|
80
|
+
let child = node;
|
|
81
|
+
for (let parent = node.parent; parent; child = parent, parent = parent.parent) {
|
|
82
|
+
switch (parent.type) {
|
|
83
|
+
case "JSXElement":
|
|
84
|
+
if (isFragmentElement(parent))
|
|
85
|
+
continue;
|
|
86
|
+
return parent;
|
|
87
|
+
case "JSXFragment":
|
|
88
|
+
case "JSXExpressionContainer":
|
|
89
|
+
case "TSAsExpression":
|
|
90
|
+
case "TSNonNullExpression":
|
|
91
|
+
case "ArrayExpression":
|
|
92
|
+
continue;
|
|
93
|
+
case "ConditionalExpression":
|
|
94
|
+
if (parent.test === child)
|
|
95
|
+
return null;
|
|
96
|
+
continue;
|
|
97
|
+
case "LogicalExpression":
|
|
98
|
+
if (parent.right !== child)
|
|
99
|
+
return null;
|
|
100
|
+
continue;
|
|
101
|
+
case "ArrowFunctionExpression":
|
|
102
|
+
case "FunctionExpression":
|
|
103
|
+
if (!isMapCallback(parent))
|
|
104
|
+
return null;
|
|
105
|
+
continue;
|
|
106
|
+
case "ReturnStatement":
|
|
107
|
+
continue;
|
|
108
|
+
case "BlockStatement":
|
|
109
|
+
if (parent.parent?.type === "ArrowFunctionExpression" || parent.parent?.type === "FunctionExpression")
|
|
110
|
+
continue;
|
|
111
|
+
return null;
|
|
112
|
+
case "CallExpression":
|
|
113
|
+
if (parent.arguments[0] !== child || !isMapCallback(child))
|
|
114
|
+
return null;
|
|
115
|
+
continue;
|
|
116
|
+
default:
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
};
|
|
122
|
+
/** True when every child a `Stack gap="section"` renders is a form control (and it renders at least one). */
|
|
123
|
+
const holdsOnlyFields = (context, stack) => {
|
|
124
|
+
const children = renderedChildren(stack.children);
|
|
125
|
+
return children.length > 0 && children.every((child) => {
|
|
126
|
+
if (child.type !== "JSXElement")
|
|
127
|
+
return false;
|
|
128
|
+
const name = elementNameOf(child);
|
|
129
|
+
return name !== null && FIELD_CHILDREN.has(name) && grammarName(context, child.openingElement) !== null;
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
/** The right role for the child: one step below the parent's. */
|
|
133
|
+
const below = (parent) => ROLES[ROLES.indexOf(parent) - 1] ?? null;
|
|
134
|
+
/** A layout element nests at least one step tighter than its layout parent. */
|
|
135
|
+
export const gapProximity = defineRule({
|
|
136
|
+
meta: {
|
|
137
|
+
type: "problem",
|
|
138
|
+
docs: { description: "GAP-PROXIMITY: a Grammar layout element stands at least one gap step closer than the layout element that contains it." },
|
|
139
|
+
schema: [],
|
|
140
|
+
messages: {
|
|
141
|
+
wide: "`{{child}}` ({{childRole}}, {{childPixels}}px) stands directly in `{{parent}}` ({{parentRole}}, {{parentPixels}}px): the children of a container stand at least one step closer than the container stands to its siblings, or the grouping disappears (identity 4 < inline 8 < row 12 < section 24 < region 32). {{advice}}",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
create(context) {
|
|
145
|
+
if (!isProductSource(context))
|
|
146
|
+
return {};
|
|
147
|
+
return {
|
|
148
|
+
JSXElement(element) {
|
|
149
|
+
const child = roleOf(context, element);
|
|
150
|
+
if (child === null)
|
|
151
|
+
return;
|
|
152
|
+
const container = parentElement(element);
|
|
153
|
+
if (container === null)
|
|
154
|
+
return;
|
|
155
|
+
const containerName = grammarName(context, container.openingElement);
|
|
156
|
+
if (containerName === null || RESETS.has(containerName))
|
|
157
|
+
return;
|
|
158
|
+
const parent = roleOf(context, container);
|
|
159
|
+
if (parent === null)
|
|
160
|
+
return;
|
|
161
|
+
if (ROLES.indexOf(child.role) < ROLES.indexOf(parent.role))
|
|
162
|
+
return;
|
|
163
|
+
// A main-rail grid fixes its own role and region is the top of the scale: nothing is compared with it, in either direction.
|
|
164
|
+
if (parent.name === 'Grid kind="main-rail"' || child.name === 'Grid kind="main-rail"')
|
|
165
|
+
return;
|
|
166
|
+
// A field stack (fields 24 apart) is the Field rule's own rhythm inside a Form or a Fieldset.
|
|
167
|
+
if (child.name === "Stack" && child.role === "section" && (containerName === "Form" || containerName === "Fieldset") && holdsOnlyFields(context, element))
|
|
168
|
+
return;
|
|
169
|
+
const target = below(parent.role);
|
|
170
|
+
const advice = target === null
|
|
171
|
+
? `\`${parent.name}\` is the narrowest role: split the parent instead of nesting inside it.`
|
|
172
|
+
: child.steppable
|
|
173
|
+
? `Give it gap="${target}" (one step below the parent), or step the parent up.`
|
|
174
|
+
: `\`${child.name}\` fixes its own gap role (${child.role}), so step the parent up (a ${ROLES[ROLES.indexOf(child.role) + 1] ?? "wider"} gap) or do not nest ${child.name.split(" ")[0] ?? child.name} there.`;
|
|
175
|
+
context.report({
|
|
176
|
+
node: element.openingElement,
|
|
177
|
+
messageId: "wide",
|
|
178
|
+
data: {
|
|
179
|
+
child: child.name, childRole: child.role, childPixels: PIXELS[child.role],
|
|
180
|
+
parent: parent.name, parentRole: parent.role, parentPixels: PIXELS[parent.role],
|
|
181
|
+
advice,
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
/** The rules this law contributes to the plugin. */
|
|
189
|
+
export const rules = {
|
|
190
|
+
"gap-proximity": gapProximity,
|
|
191
|
+
};
|
|
192
|
+
defineFamilyRules(rules, "knowledge/ui/presentation/grammar-laws.yaml#GAP-PROXIMITY");
|
|
193
|
+
/** Every rule of this law is an error. */
|
|
194
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
package/dist/index.js
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
import tsParser from "@typescript-eslint/parser";
|
|
2
2
|
import { SOURCE_FILES, linterOptions as canonLinterOptions, scopeToPackages } from "@starci/eslint-canon-fe/lib/config.mjs";
|
|
3
3
|
import { rules as appShellRules } from "./app-shell.js";
|
|
4
|
+
import { rules as buttonArrowRules } from "./button-arrow.js";
|
|
4
5
|
import { rules as chipLabelRules } from "./chip-label.js";
|
|
5
6
|
import { rules as choiceControlsRules } from "./choice-controls.js";
|
|
6
7
|
import { rules as drawingRules } from "./drawing.js";
|
|
8
|
+
import { rules as fieldLabelRules } from "./field-label.js";
|
|
7
9
|
import { rules as freestyleRules } from "./freestyle.js";
|
|
10
|
+
import { rules as gapProximityRules } from "./gap-proximity.js";
|
|
8
11
|
import { rules as grammarBoundaryRules } from "./grammar-boundary.js";
|
|
9
12
|
import { rules as iconRules } from "./icon.js";
|
|
10
13
|
import { rules as mascotRules } from "./mascot.js";
|
|
11
14
|
import { rules as menuEntriesRules } from "./menu-entries.js";
|
|
12
15
|
import { rules as pageRules } from "./page.js";
|
|
16
|
+
import { rules as pageBreadcrumbsRules } from "./page-breadcrumbs.js";
|
|
13
17
|
import { rules as pageHeaderRules } from "./page-header.js";
|
|
14
18
|
import { rules as paneRules } from "./pane.js";
|
|
19
|
+
import { rules as rowTitleLinkRules } from "./row-title-link.js";
|
|
20
|
+
import { rules as sameLineSizeRules } from "./same-line-size.js";
|
|
15
21
|
import { rules as statusColorsRules } from "./status-colors.js";
|
|
16
22
|
import { rules as surfaceCardRules } from "./surface-card.js";
|
|
17
23
|
import { rules as surfaceDepthRules } from "./surface-depth.js";
|
|
24
|
+
import { rules as surfaceInSurfaceRules } from "./surface-in-surface.js";
|
|
25
|
+
import { rules as tabsRules } from "./tabs.js";
|
|
26
|
+
import { rules as tableCellTypeRules } from "./table-cell-type.js";
|
|
18
27
|
import { rules as textRules } from "./text-rules.js";
|
|
19
28
|
import { rules as tokensRules } from "./tokens.js";
|
|
20
29
|
import { rules as vendorRules } from "./vendor-boundary.js";
|
|
21
30
|
import { why as familyWhy } from "./lib/why.js";
|
|
22
31
|
const CONTRIBUTIONS = [
|
|
23
32
|
{ law: "app-shell", rules: appShellRules },
|
|
33
|
+
{ law: "button-arrow", rules: buttonArrowRules },
|
|
24
34
|
{ law: "chip-label", rules: chipLabelRules },
|
|
25
35
|
{ law: "choice-controls", rules: choiceControlsRules },
|
|
26
36
|
{ law: "drawing", rules: drawingRules },
|
|
37
|
+
{ law: "field-label", rules: fieldLabelRules },
|
|
27
38
|
{ law: "freestyle", rules: freestyleRules },
|
|
39
|
+
{ law: "gap-proximity", rules: gapProximityRules },
|
|
28
40
|
{ law: "grammar-boundary", rules: grammarBoundaryRules },
|
|
29
41
|
{ law: "icon", rules: iconRules },
|
|
30
42
|
{ law: "mascot", rules: mascotRules },
|
|
31
43
|
{ law: "menu-entries", rules: menuEntriesRules },
|
|
32
44
|
{ law: "page", rules: pageRules },
|
|
45
|
+
{ law: "page-breadcrumbs", rules: pageBreadcrumbsRules },
|
|
33
46
|
{ law: "page-header", rules: pageHeaderRules },
|
|
34
47
|
{ law: "pane", rules: paneRules },
|
|
48
|
+
{ law: "row-title-link", rules: rowTitleLinkRules },
|
|
49
|
+
{ law: "same-line-size", rules: sameLineSizeRules },
|
|
35
50
|
{ law: "status-colors", rules: statusColorsRules },
|
|
36
51
|
{ law: "surface-card", rules: surfaceCardRules },
|
|
37
52
|
{ law: "surface-depth", rules: surfaceDepthRules },
|
|
53
|
+
{ law: "surface-in-surface", rules: surfaceInSurfaceRules },
|
|
54
|
+
{ law: "tabs", rules: tabsRules },
|
|
55
|
+
{ law: "table-cell-type", rules: tableCellTypeRules },
|
|
38
56
|
{ law: "text-rules", rules: textRules },
|
|
39
57
|
{ law: "tokens", rules: tokensRules },
|
|
40
58
|
{ law: "vendor-boundary", rules: vendorRules },
|
|
@@ -26,6 +26,9 @@ export const crossFileInputs = [
|
|
|
26
26
|
{ rule: "page-tabs-in-header", kind: "exists", relativeTo: "side", globs: ["**/src/app", "**/src/app/**"], appliesTo: ["**/src/features/pages/**/*.{ts,tsx}"], reader: "lib/page-frame.ts" },
|
|
27
27
|
{ rule: "route-page-is-one-page", kind: "exists", relativeTo: "side", globs: ["**/src/app", "**/src/app/**"], appliesTo: ["**/src/features/pages/**/*.{ts,tsx}"], reader: "lib/page-frame.ts" },
|
|
28
28
|
{ rule: "route-page-is-one-page", kind: "content", relativeTo: "side", globs: ["**/src/app/**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts}"], appliesTo: ["**/src/features/pages/**/*.{ts,tsx}"], reader: "lib/page-frame.ts" },
|
|
29
|
+
// a console page is told from an auth page by the route files that mount its owner and the route group above them
|
|
30
|
+
{ rule: "page-breadcrumbs", kind: "exists", relativeTo: "side", globs: ["**/src/app", "**/src/app/**"], appliesTo: ["**/src/features/pages/**/*.{ts,tsx}"], reader: "lib/page-frame.ts" },
|
|
31
|
+
{ rule: "page-breadcrumbs", kind: "content", relativeTo: "side", globs: ["**/src/app/**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts}"], appliesTo: ["**/src/features/pages/**/*.{ts,tsx}"], reader: "lib/page-frame.ts" },
|
|
29
32
|
// the page owner is judged by the blocks it renders as its root (a block that draws the Page, its own sub-blocks and the feature files it imports): a changed block re-judges the owner
|
|
30
33
|
{ rule: "route-page-is-one-page", kind: "content", relativeTo: "side", globs: ["**/src/components/{blocks,frames,composites,branches,leaves}/**/*.{ts,tsx}", "**/src/features/**/*.{ts,tsx}"], appliesTo: ["**/src/features/pages/**/*.{ts,tsx}", "**/src/app/**/*.{ts,tsx}"], reader: "lib/page-frame.ts" },
|
|
31
34
|
// the theme an app defines its tokens in: the route slot's globals.css and the brand slot's brand.css
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Readers of Grammar JSX shared by the composition laws (gap proximity, field label, surface in surface, page
|
|
3
|
+
* breadcrumbs): which Grammar component an element names, a literal prop, and the children an element renders once
|
|
4
|
+
* fragments, `cond ? <x/> : null`, `cond && <x/>` and `items.map(() => <x/>)` are looked through.
|
|
5
|
+
*/
|
|
6
|
+
import type { TSESTree } from "@typescript-eslint/types";
|
|
7
|
+
import type { Context, Node } from "./types.js";
|
|
8
|
+
/** The element name of a JSX name: `Stack`, or `G.Stack` as `Stack`. */
|
|
9
|
+
export declare const nameOf: (name: TSESTree.JSXTagNameExpression) => string | null;
|
|
10
|
+
/** The Grammar component an opening element names (imported from `@starci/grammar`), or null for another source or a plain element. */
|
|
11
|
+
export declare const grammarName: (context: Context, opening: TSESTree.JSXOpeningElement) => string | null;
|
|
12
|
+
/** The attribute `name` of an opening element, or undefined. */
|
|
13
|
+
export declare const attributeOf: (opening: TSESTree.JSXOpeningElement, name: string) => TSESTree.JSXAttribute | undefined;
|
|
14
|
+
/** True when the element carries a JSX spread, so a prop may arrive that the source does not show. */
|
|
15
|
+
export declare const hasSpread: (opening: TSESTree.JSXOpeningElement) => boolean;
|
|
16
|
+
/** The string a literal attribute value spells (`"x"`, `{"x"}`, `` {`x`} ``), or null. */
|
|
17
|
+
export declare const literalString: (attribute: TSESTree.JSXAttribute | undefined) => string | null;
|
|
18
|
+
/** The literal string prop `name` of an opening element, or null when absent or not a literal. */
|
|
19
|
+
export declare const stringProp: (opening: TSESTree.JSXOpeningElement, name: string) => string | null;
|
|
20
|
+
/** True for `<Fragment>` and `<React.Fragment>`: a plain fragment with a name. */
|
|
21
|
+
export declare const isFragmentElement: (element: TSESTree.JSXElement) => boolean;
|
|
22
|
+
/** What an element or fragment renders as children: elements, non-blank text, and opaque expressions. */
|
|
23
|
+
export declare const renderedChildren: (children: readonly TSESTree.JSXChild[]) => Node[];
|
|
24
|
+
/** The name a rendered node is drawn by if it is a JSX element (`Stack`, `G.Stack` as `Stack`), else null. */
|
|
25
|
+
export declare const elementNameOf: (node: Node) => string | null;
|
|
26
|
+
/** The Grammar form controls a field label belongs to. */
|
|
27
|
+
export declare const FORM_CONTROLS: ReadonlySet<string>;
|