@starci/eslint-grammar-core 0.16.5 → 0.17.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 +9 -0
- package/README.md +1 -1
- package/dist/index.js +2 -0
- package/dist/lib/why.js +20 -0
- package/dist/pane.d.ts +13 -0
- package/dist/pane.js +420 -0
- package/docs/pane.md +115 -0
- package/package.json +2 -2
- package/runtime/knowledge/hfs/canon-pins.yaml +7 -7
- package/runtime/knowledge/hfs/rules.yaml +117 -2
- package/runtime/knowledge/hfs/slots.yaml +5 -1
- package/runtime/knowledge/patterns/fe/ui.yaml +15 -1
- package/runtime/scripts/hfs/declaration-shape.mjs +4 -2
- package/runtime/scripts/hfs/rule-params-shape.mjs +7 -2
- package/runtime/scripts/hfs/slots.mjs +15 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.17.0 - 2026-10-31
|
|
4
|
+
|
|
5
|
+
- Added: the pane laws, `src/pane.ts` (docs/pane.md): R345 `pane-grid-children` (`FE_PANE_GRID_CHILD_NOT_PANE`: a `PaneGrid` child is a literal `Pane`, directly or from a conditional, `&&` or `.map`; a wrapper component, raw element, fragment or variable renders a blank cell), R346 `pane-children` (`FE_PANE_CHILD_NOT_SECTION`: a `Pane` holds `PaneSection`s or one `PaneGrid`, not a raw element or another Grammar component), R347 `no-pane-section-padding` (`FE_PANE_SECTION_PADDING`: no padding or margin utility on the outermost element of a `PaneSection`, same-file component roots and typed imported class constants followed) and R348 `pane-grid-page` (`FE_PANE_GRID_FRAME`: a `PaneGrid` stands in `Page chrome="panes"` or in a `Pane`, never in a `FillViewport`, a card or another page chrome). A Freestyle subtree is exempt. Offset Pop inherits them.
|
|
6
|
+
- Changed: requires @starci/eslint-canon-fe 9.7.0 and follows @starci/grammar 0.17.0 (`Pane` owns its content inset, `PaneSection`, `Page chrome="panes"`); the bundled runtime copies follow @starci/hfs 4.15.0 and the canon pins name the cohort hfs 4.15.0, eslint-canon-be 3.11.0, eslint-canon-fe 9.7.0, @starci/grammar, eslint-grammar-core and eslint-grammar-offset-pop 0.17.0.
|
|
7
|
+
|
|
8
|
+
## 0.16.6 - 2026-10-31
|
|
9
|
+
|
|
10
|
+
- Changed: requires @starci/eslint-canon-fe 9.6.7; the bundled runtime copies follow @starci/hfs 4.14.0 (R334 one style) and the canon pins name @starci/ai-router 0.5.0 (many providers behind one virtual key, the persisted key blacklist) and the cohort hfs 4.14.0, eslint-canon-be 3.11.0, eslint-canon-fe 9.6.7, @starci/grammar, eslint-grammar-core and eslint-grammar-offset-pop 0.16.6; no rule changed.
|
|
11
|
+
|
|
3
12
|
## 0.16.5 - 2026-10-31
|
|
4
13
|
|
|
5
14
|
- Changed: requires @starci/eslint-canon-fe 9.6.5; the bundled runtime copies follow @starci/hfs 4.13.2 (R344 in the catalog) and the canon pins name hfs 4.13.2 and the lint cohort (eslint-canon-be 3.10.0, eslint-canon-fe 9.6.5, eslint-grammar-core and eslint-grammar-offset-pop 0.16.5); no rule changed.
|
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ 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 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, 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
|
|
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
25
|
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { rules as mascotRules } from "./mascot.js";
|
|
|
10
10
|
import { rules as menuEntriesRules } from "./menu-entries.js";
|
|
11
11
|
import { rules as pageRules } from "./page.js";
|
|
12
12
|
import { rules as pageHeaderRules } from "./page-header.js";
|
|
13
|
+
import { rules as paneRules } from "./pane.js";
|
|
13
14
|
import { rules as statusColorsRules } from "./status-colors.js";
|
|
14
15
|
import { rules as surfaceDepthRules } from "./surface-depth.js";
|
|
15
16
|
import { rules as tokensRules } from "./tokens.js";
|
|
@@ -27,6 +28,7 @@ const CONTRIBUTIONS = [
|
|
|
27
28
|
{ law: "menu-entries", rules: menuEntriesRules },
|
|
28
29
|
{ law: "page", rules: pageRules },
|
|
29
30
|
{ law: "page-header", rules: pageHeaderRules },
|
|
31
|
+
{ law: "pane", rules: paneRules },
|
|
30
32
|
{ law: "status-colors", rules: statusColorsRules },
|
|
31
33
|
{ law: "surface-depth", rules: surfaceDepthRules },
|
|
32
34
|
{ law: "tokens", rules: tokensRules },
|
package/dist/lib/why.js
CHANGED
|
@@ -49,6 +49,21 @@ export const why = {
|
|
|
49
49
|
en: "A page tab bar in `<file>` is a Tabs at the top of the Page body or right after a PageHeader, outside the header band.",
|
|
50
50
|
fix: "Pass the tabs as Page header.tabs (or PageHeader tabs): { label, items, selectedKey, onSelect }, or link tabs whose items carry an href each.",
|
|
51
51
|
},
|
|
52
|
+
"pane-children": {
|
|
53
|
+
code: "FE_PANE_CHILD_NOT_SECTION",
|
|
54
|
+
en: "A raw element or a Grammar component other than PaneSection and PaneGrid is placed straight in a `Pane` in `<file>`, skipping the inset the pane publishes.",
|
|
55
|
+
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>`.",
|
|
56
|
+
},
|
|
57
|
+
"pane-grid-children": {
|
|
58
|
+
code: "FE_PANE_GRID_CHILD_NOT_PANE",
|
|
59
|
+
en: "A child of `PaneGrid` in `<file>` is not a `Pane` element (a wrapper component, a fragment or a variable), so its cell renders blank.",
|
|
60
|
+
fix: "Write `<Pane area=\"...\">` as the child (directly, or from `cond ? <Pane/> : null`, `cond && <Pane/>` or a `.map`), and move the wrapper's content into the Pane's PaneSections.",
|
|
61
|
+
},
|
|
62
|
+
"pane-grid-page": {
|
|
63
|
+
code: "FE_PANE_GRID_FRAME",
|
|
64
|
+
en: "A `PaneGrid` in `<file>` is drawn in a FillViewport, a card or a page chrome other than `panes`, or is wrapped inside `Page chrome=\"panes\"`.",
|
|
65
|
+
fix: "Make the grid the one child of `<Page chrome=\"panes\">` (or the one child of a `Pane`, nested) and drop the FillViewport or card around it.",
|
|
66
|
+
},
|
|
52
67
|
"route-page-is-one-page": {
|
|
53
68
|
code: "FE_ROUTE_PAGE_OUTSIDE_PAGE",
|
|
54
69
|
en: "The page or layout owner `<file>` draws something beside its Page, a Page inside another (or inside the Page its tabbed segment's layout draws), a bare PageHeader or PageContainer, or no Page at all (itself, through its pure half, or through the one connected block it renders as its root).",
|
|
@@ -59,6 +74,11 @@ export const why = {
|
|
|
59
74
|
en: "A `<Freestyle>` region in `<file>` has no non-empty string `reason`.",
|
|
60
75
|
fix: "Say why no Grammar component fits: `<Freestyle reason=\"sign-in brand art\">`. If a Grammar component fits, compose it instead.",
|
|
61
76
|
},
|
|
77
|
+
"no-pane-section-padding": {
|
|
78
|
+
code: "FE_PANE_SECTION_PADDING",
|
|
79
|
+
en: "The outermost element a `PaneSection` renders in `<file>` carries a padding or margin utility, a second inset beside the one the pane publishes.",
|
|
80
|
+
fix: "Remove the utility: PaneSection pads inline by the pane inset and spaces its own children by `gap`; use `bleed=\"inline\"` for a scroller that reaches the pane edges.",
|
|
81
|
+
},
|
|
62
82
|
"no-raised-surface-in-surface": {
|
|
63
83
|
code: "FE_RAISED_SURFACE_IN_SURFACE",
|
|
64
84
|
en: "A Grammar surface in `<file>` forces `depth=\"top\"` inside another surface, raising a surface inside a surface (BOUNDARY-6).",
|
package/dist/pane.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Rule } from "eslint";
|
|
2
|
+
/** A `PaneGrid` holds `Pane` elements and nothing else. */
|
|
3
|
+
export declare const paneGridChildren: Rule.RuleModule;
|
|
4
|
+
/** A `Pane` holds `PaneSection`s or one nested `PaneGrid`. */
|
|
5
|
+
export declare const paneChildren: Rule.RuleModule;
|
|
6
|
+
/** What a `PaneSection` renders carries no padding or margin utility on its outermost elements. */
|
|
7
|
+
export declare const noPaneSectionPadding: Rule.RuleModule;
|
|
8
|
+
/** A `PaneGrid` stands in `Page chrome="panes"` or in a `Pane`. */
|
|
9
|
+
export declare const paneGridPage: Rule.RuleModule;
|
|
10
|
+
/** The rules this law contributes to the plugin. */
|
|
11
|
+
export declare const rules: Record<string, Rule.RuleModule>;
|
|
12
|
+
/** Every rule of this law is an error. */
|
|
13
|
+
export declare const recommended: Record<string, "error">;
|
package/dist/pane.js
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { walk } from "@starci/eslint-canon-fe/lib/ast.mjs";
|
|
2
|
+
import { importOf, variableOf } from "@starci/eslint-canon-fe/lib/bindings.mjs";
|
|
3
|
+
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
4
|
+
import { typedClassStrings } from "@starci/eslint-canon-fe/lib/typed-class-values.mjs";
|
|
5
|
+
import { defineFamilyRules, defineRule, exemptFreestyle } from "./lib/rule-contract.js";
|
|
6
|
+
/**
|
|
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
|
|
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
|
+
*
|
|
11
|
+
* `PaneGrid` places each child by the `area` of a `Pane` element and drops a child that is not one: a wrapper component
|
|
12
|
+
* renders nothing in its cell. A `Pane` owns its content inset and publishes it to its `PaneSection`s; a raw element or
|
|
13
|
+
* another Grammar component placed straight in a pane skips that inset, and a padding or margin utility on what a section
|
|
14
|
+
* renders adds a second inset beside it. A grid inside a card or a viewport-fill wrapper re-decides the frame and the
|
|
15
|
+
* bottom edge that `Page chrome="panes"` owns.
|
|
16
|
+
*
|
|
17
|
+
* WHAT THEY READ. Element names (`Pane`, or `G.Pane` as `Pane`) and the children of one JSX parent. A child is read through
|
|
18
|
+
* `cond ? <Pane/> : null`, `cond && <Pane/>`, `items.map(() => <Pane/>)` and arrays, down to the elements it can render; null,
|
|
19
|
+
* false and `undefined` render nothing. A project component (an element imported from outside `@starci/grammar`) placed in a
|
|
20
|
+
* `Pane` is judged in its own file, and so is a component whose root a rule cannot follow; `no-pane-section-padding` follows the
|
|
21
|
+
* roots of components declared in the same file and the class strings of imported constants through the type program.
|
|
22
|
+
* Auto and zero values (`mx-auto`, `p-0`) place or reset and inset nothing, so they are not padding.
|
|
23
|
+
*
|
|
24
|
+
* THE EXEMPTION. A raw element inside a `Freestyle` subtree is the app's own (`exemptFreestyle`); a `PaneGrid` inside one is
|
|
25
|
+
* not judged by `pane-grid-page`.
|
|
26
|
+
*
|
|
27
|
+
* WHERE THEY APPLY. Product source (`isProductSource`).
|
|
28
|
+
*/
|
|
29
|
+
/** The Grammar package entries a component can be imported from. */
|
|
30
|
+
const GRAMMAR_SOURCE = /^@starci\/grammar(?:\/(?:common|core|offset-pop))?$/;
|
|
31
|
+
/** The bounded surfaces a pane grid is not drawn in. */
|
|
32
|
+
const SURFACES = new Set(["SurfaceCard", "SurfaceListCard", "SurfaceAccordionCard"]);
|
|
33
|
+
/** The helpers that join class strings. */
|
|
34
|
+
const CLASS_BUILDERS = new Set(["cn", "clsx", "cx", "classNames", "classnames", "twMerge", "twJoin", "cva", "tv"]);
|
|
35
|
+
/** How many same-file components a section's root follows. */
|
|
36
|
+
const FOLLOW_DEPTH = 8;
|
|
37
|
+
/** The element name of a JSX name: `Pane`, or `G.Pane` as `Pane`. */
|
|
38
|
+
const nameOf = (name) => {
|
|
39
|
+
if (name.type === "JSXIdentifier")
|
|
40
|
+
return name.name;
|
|
41
|
+
if (name.type === "JSXMemberExpression")
|
|
42
|
+
return name.property.name;
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
45
|
+
/** The leftmost identifier of a JSX name (`G` of `G.Pane`), or null for a namespaced name. */
|
|
46
|
+
const rootOf = (name) => {
|
|
47
|
+
if (name.type === "JSXIdentifier")
|
|
48
|
+
return name;
|
|
49
|
+
if (name.type === "JSXMemberExpression")
|
|
50
|
+
return rootOf(name.object);
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
53
|
+
/** True for a plain element (`div`), as opposed to a component. */
|
|
54
|
+
const isDomName = (name) => name.type === "JSXIdentifier" && /^[a-z]/.test(name.name);
|
|
55
|
+
/** The children that render: whitespace-only text and `{/* comments *\/}` are left out. */
|
|
56
|
+
const renderedChildren = (children) => children.filter((child) => {
|
|
57
|
+
if (child.type === "JSXText")
|
|
58
|
+
return child.value.trim() !== "";
|
|
59
|
+
if (child.type === "JSXExpressionContainer")
|
|
60
|
+
return child.expression.type !== "JSXEmptyExpression";
|
|
61
|
+
return true;
|
|
62
|
+
});
|
|
63
|
+
/** The expressions a function returns: its expression body, or the arguments of its own `return` statements. */
|
|
64
|
+
const returnedExpressions = (context, fn) => {
|
|
65
|
+
if (fn.body.type !== "BlockStatement")
|
|
66
|
+
return [fn.body];
|
|
67
|
+
const found = [];
|
|
68
|
+
walk(context.sourceCode, fn.body, (node) => {
|
|
69
|
+
if (node !== fn.body && (node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression" || node.type === "FunctionDeclaration"))
|
|
70
|
+
return false;
|
|
71
|
+
if (node.type === "ReturnStatement" && node.argument !== null)
|
|
72
|
+
found.push(node.argument);
|
|
73
|
+
return undefined;
|
|
74
|
+
});
|
|
75
|
+
return found;
|
|
76
|
+
};
|
|
77
|
+
/** True for a function-shaped node. */
|
|
78
|
+
const isFunction = (node) => node !== undefined && (node.type === "ArrowFunctionExpression" || node.type === "FunctionExpression");
|
|
79
|
+
/** The leaves an expression can render. */
|
|
80
|
+
const leavesOfExpression = (context, expression) => {
|
|
81
|
+
switch (expression.type) {
|
|
82
|
+
case "JSXEmptyExpression":
|
|
83
|
+
return [];
|
|
84
|
+
case "JSXElement":
|
|
85
|
+
return [{ kind: "element", node: expression }];
|
|
86
|
+
case "JSXFragment":
|
|
87
|
+
return [{ kind: "fragment", node: expression }];
|
|
88
|
+
case "Literal":
|
|
89
|
+
if (expression.value === null || typeof expression.value === "boolean")
|
|
90
|
+
return [];
|
|
91
|
+
if (typeof expression.value === "string" && expression.value.trim() === "")
|
|
92
|
+
return [];
|
|
93
|
+
return [{ kind: "opaque", node: expression }];
|
|
94
|
+
case "Identifier":
|
|
95
|
+
return expression.name === "undefined" ? [] : [{ kind: "opaque", node: expression }];
|
|
96
|
+
case "TSAsExpression":
|
|
97
|
+
case "TSNonNullExpression":
|
|
98
|
+
case "TSSatisfiesExpression":
|
|
99
|
+
return leavesOfExpression(context, expression.expression);
|
|
100
|
+
case "ConditionalExpression":
|
|
101
|
+
return [...leavesOfExpression(context, expression.consequent), ...leavesOfExpression(context, expression.alternate)];
|
|
102
|
+
case "LogicalExpression":
|
|
103
|
+
return expression.operator === "&&"
|
|
104
|
+
? leavesOfExpression(context, expression.right)
|
|
105
|
+
: [...leavesOfExpression(context, expression.left), ...leavesOfExpression(context, expression.right)];
|
|
106
|
+
case "ArrayExpression":
|
|
107
|
+
return expression.elements.flatMap((element) => (element === null ? [] : leavesOfExpression(context, element)));
|
|
108
|
+
case "CallExpression": {
|
|
109
|
+
const callee = expression.callee;
|
|
110
|
+
const method = callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier" ? callee.property.name : null;
|
|
111
|
+
const callback = expression.arguments[0];
|
|
112
|
+
if ((method === "map" || method === "flatMap") && isFunction(callback))
|
|
113
|
+
return returnedExpressions(context, callback).flatMap((returned) => leavesOfExpression(context, returned));
|
|
114
|
+
return [{ kind: "opaque", node: expression }];
|
|
115
|
+
}
|
|
116
|
+
default:
|
|
117
|
+
return [{ kind: "opaque", node: expression }];
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
/** The leaves a child of a JSX parent can render. */
|
|
121
|
+
const leavesOfChild = (context, child) => {
|
|
122
|
+
if (child.type === "JSXElement")
|
|
123
|
+
return [{ kind: "element", node: child }];
|
|
124
|
+
if (child.type === "JSXFragment")
|
|
125
|
+
return [{ kind: "fragment", node: child }];
|
|
126
|
+
if (child.type === "JSXExpressionContainer")
|
|
127
|
+
return leavesOfExpression(context, child.expression);
|
|
128
|
+
if (child.type === "JSXSpreadChild")
|
|
129
|
+
return [{ kind: "opaque", node: child }];
|
|
130
|
+
return [{ kind: "opaque", node: child }];
|
|
131
|
+
};
|
|
132
|
+
/** The leaves of every rendered child of an element. */
|
|
133
|
+
const leavesOf = (context, parent) => renderedChildren(parent.children).flatMap((child) => (child.type === "JSXText" ? [] : leavesOfChild(context, child)));
|
|
134
|
+
/** A `PaneGrid` holds `Pane` elements and nothing else. */
|
|
135
|
+
export const paneGridChildren = exemptFreestyle(defineRule({
|
|
136
|
+
meta: {
|
|
137
|
+
type: "problem",
|
|
138
|
+
docs: { description: "R345: a PaneGrid child is a Pane element (directly, in a conditional or in a map), never a wrapper component, a fragment or a variable.", url: "knowledge/hfs/rules.yaml#R345" },
|
|
139
|
+
schema: [],
|
|
140
|
+
messages: {
|
|
141
|
+
notPane: "{{what}} is a child of `PaneGrid`, which places only `Pane` elements by their `area` and drops the rest: this cell renders blank. Write the `<Pane area=\"...\">` here (inline it, or return a `Pane` element from a `cond ? <Pane/> : null`, `cond && <Pane/>` or `.map` expression), and move the wrapper's content into that Pane's PaneSections.",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
create(context) {
|
|
145
|
+
if (!isProductSource(context))
|
|
146
|
+
return {};
|
|
147
|
+
return {
|
|
148
|
+
JSXElement(node) {
|
|
149
|
+
if (nameOf(node.openingElement.name) !== "PaneGrid")
|
|
150
|
+
return;
|
|
151
|
+
for (const leaf of leavesOf(context, node)) {
|
|
152
|
+
if (leaf.kind === "element" && nameOf(leaf.node.openingElement.name) === "Pane")
|
|
153
|
+
continue;
|
|
154
|
+
const what = leaf.kind === "element" ? `\`<${context.sourceCode.getText(leaf.node.openingElement.name)}>\`` : leaf.kind === "fragment" ? "A fragment" : "An expression";
|
|
155
|
+
context.report({ node: leaf.node, messageId: "notPane", data: { what } });
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
}));
|
|
161
|
+
/** What a `Pane` child is, for the message. */
|
|
162
|
+
const describePaneChild = (context, element) => {
|
|
163
|
+
const name = element.openingElement.name;
|
|
164
|
+
const element_ = nameOf(name);
|
|
165
|
+
if (element_ === "PaneSection" || element_ === "PaneGrid" || element_ === "Freestyle")
|
|
166
|
+
return null;
|
|
167
|
+
if (isDomName(name))
|
|
168
|
+
return `The raw \`<${element_ ?? "element"}>\``;
|
|
169
|
+
const root = rootOf(name);
|
|
170
|
+
if (root === null)
|
|
171
|
+
return null;
|
|
172
|
+
const origin = importOf(context, root);
|
|
173
|
+
if (origin === null || !GRAMMAR_SOURCE.test(origin.source))
|
|
174
|
+
return null;
|
|
175
|
+
return `The Grammar component \`<${context.sourceCode.getText(name)}>\``;
|
|
176
|
+
};
|
|
177
|
+
/** The elements a pane holds directly, following fragments. */
|
|
178
|
+
const paneElements = (context, parent) => leavesOf(context, parent).flatMap((leaf) => {
|
|
179
|
+
if (leaf.kind === "element")
|
|
180
|
+
return [leaf.node];
|
|
181
|
+
if (leaf.kind === "fragment")
|
|
182
|
+
return paneElements(context, leaf.node);
|
|
183
|
+
return [];
|
|
184
|
+
});
|
|
185
|
+
/** A `Pane` holds `PaneSection`s or one nested `PaneGrid`. */
|
|
186
|
+
export const paneChildren = exemptFreestyle(defineRule({
|
|
187
|
+
meta: {
|
|
188
|
+
type: "problem",
|
|
189
|
+
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" },
|
|
190
|
+
schema: [],
|
|
191
|
+
messages: {
|
|
192
|
+
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), or make the pane's one child a nested `<PaneGrid>`.",
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
create(context) {
|
|
196
|
+
if (!isProductSource(context))
|
|
197
|
+
return {};
|
|
198
|
+
return {
|
|
199
|
+
JSXElement(node) {
|
|
200
|
+
if (nameOf(node.openingElement.name) !== "Pane")
|
|
201
|
+
return;
|
|
202
|
+
for (const element of paneElements(context, node)) {
|
|
203
|
+
const what = describePaneChild(context, element);
|
|
204
|
+
if (what !== null)
|
|
205
|
+
context.report({ node: element, messageId: "notSection", data: { what } });
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
}));
|
|
211
|
+
/** A padding or margin utility that insets: zero and auto values place or reset and are not one. */
|
|
212
|
+
const INSET_UTILITY = /^-?(?:p|px|py|ps|pe|pt|pb|pl|pr|m|mx|my|ms|me|mt|mb|ml|mr)-(?!0$|auto$)\S+$/;
|
|
213
|
+
/** An arbitrary padding or margin property, `[padding-inline:1rem]`. */
|
|
214
|
+
const ARBITRARY_INSET = /^\[(?:padding|margin)(?:-(?:inline|block)(?:-(?:start|end))?|-(?:top|right|bottom|left))?:(?!0(?:px|rem)?\]$|auto\]$).+\]$/;
|
|
215
|
+
/** A class token without its variants (`sm:`, `[&>*]:`) and its important marker. */
|
|
216
|
+
const bareToken = (token) => {
|
|
217
|
+
let depth = 0;
|
|
218
|
+
let start = 0;
|
|
219
|
+
for (let index = 0; index < token.length; index += 1) {
|
|
220
|
+
const char = token[index];
|
|
221
|
+
if (char === "[")
|
|
222
|
+
depth += 1;
|
|
223
|
+
else if (char === "]")
|
|
224
|
+
depth -= 1;
|
|
225
|
+
else if (char === ":" && depth === 0)
|
|
226
|
+
start = index + 1;
|
|
227
|
+
}
|
|
228
|
+
return token.slice(start).replace(/^!|!$/g, "");
|
|
229
|
+
};
|
|
230
|
+
/** True when a class string carries a padding or margin utility. */
|
|
231
|
+
const hasInsetUtility = (text) => text.split(/\s+/).some((token) => {
|
|
232
|
+
const bare = bareToken(token);
|
|
233
|
+
return INSET_UTILITY.test(bare) || ARBITRARY_INSET.test(bare);
|
|
234
|
+
});
|
|
235
|
+
/** The class strings an expression statically holds: literals, templates, joins, conditionals, constants and typed imports. */
|
|
236
|
+
const classStrings = (context, input, seen = new Set()) => {
|
|
237
|
+
if (input === null || seen.has(input))
|
|
238
|
+
return [];
|
|
239
|
+
seen.add(input);
|
|
240
|
+
switch (input.type) {
|
|
241
|
+
case "JSXExpressionContainer":
|
|
242
|
+
return classStrings(context, input.expression, seen);
|
|
243
|
+
case "Literal":
|
|
244
|
+
return typeof input.value === "string" ? [input.value] : [];
|
|
245
|
+
case "TemplateLiteral":
|
|
246
|
+
return [...input.quasis.map((quasi) => quasi.value.cooked ?? ""), ...input.expressions.flatMap((expression) => classStrings(context, expression, seen))];
|
|
247
|
+
case "TSAsExpression":
|
|
248
|
+
case "TSNonNullExpression":
|
|
249
|
+
case "TSSatisfiesExpression":
|
|
250
|
+
return classStrings(context, input.expression, seen);
|
|
251
|
+
case "ConditionalExpression":
|
|
252
|
+
return [...classStrings(context, input.consequent, seen), ...classStrings(context, input.alternate, seen)];
|
|
253
|
+
case "LogicalExpression":
|
|
254
|
+
return input.operator === "&&" ? classStrings(context, input.right, seen) : [...classStrings(context, input.left, seen), ...classStrings(context, input.right, seen)];
|
|
255
|
+
case "ArrayExpression":
|
|
256
|
+
return input.elements.flatMap((element) => (element === null ? [] : classStrings(context, element, seen)));
|
|
257
|
+
case "ObjectExpression":
|
|
258
|
+
return input.properties.flatMap((property) => property.type === "Property" ? [...(property.key.type === "Literal" && typeof property.key.value === "string" ? [property.key.value] : []), ...classStrings(context, property.value, seen)] : []);
|
|
259
|
+
case "CallExpression":
|
|
260
|
+
return input.callee.type === "Identifier" && CLASS_BUILDERS.has(input.callee.name) ? input.arguments.flatMap((argument) => classStrings(context, argument, seen)) : [];
|
|
261
|
+
case "Identifier":
|
|
262
|
+
case "MemberExpression": {
|
|
263
|
+
const local = input.type === "Identifier" ? variableOf(context, input)?.defs.find((definition) => definition.type === "Variable") : undefined;
|
|
264
|
+
const init = local?.type === "Variable" ? local.node.init : null;
|
|
265
|
+
const resolved = init === null || init === undefined ? [] : classStrings(context, init, seen);
|
|
266
|
+
return resolved.length > 0 ? resolved : typedClassStrings(context, input, "classes").map((entry) => entry.text);
|
|
267
|
+
}
|
|
268
|
+
default:
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
/** The element of a same-file component declaration a JSX name resolves to: its returned roots, or null. */
|
|
273
|
+
const componentRoots = (context, name) => {
|
|
274
|
+
if (name.type !== "JSXIdentifier")
|
|
275
|
+
return null;
|
|
276
|
+
const definition = variableOf(context, name)?.defs.find((entry) => entry.type === "FunctionName" || entry.type === "Variable");
|
|
277
|
+
if (definition === undefined)
|
|
278
|
+
return null;
|
|
279
|
+
const fn = definition.type === "FunctionName" ? definition.node : definition.type === "Variable" ? definition.node.init : null;
|
|
280
|
+
if (fn === null || fn === undefined)
|
|
281
|
+
return null;
|
|
282
|
+
if (fn.type !== "FunctionDeclaration" && fn.type !== "FunctionExpression" && fn.type !== "ArrowFunctionExpression")
|
|
283
|
+
return null;
|
|
284
|
+
return returnedExpressions(context, fn);
|
|
285
|
+
};
|
|
286
|
+
/** The class attribute of an element, or null. */
|
|
287
|
+
const classAttribute = (element) => {
|
|
288
|
+
const found = element.openingElement.attributes.find((entry) => entry.type === "JSXAttribute" && entry.name.type === "JSXIdentifier" && (entry.name.name === "className" || entry.name.name === "class"));
|
|
289
|
+
return found ?? null;
|
|
290
|
+
};
|
|
291
|
+
/** The elements a section renders outermost, following fragments and the roots of same-file components. */
|
|
292
|
+
const outermost = (context, leaves, depth, seen) => leaves.flatMap((leaf) => {
|
|
293
|
+
if (seen.has(leaf.node))
|
|
294
|
+
return [];
|
|
295
|
+
seen.add(leaf.node);
|
|
296
|
+
if (leaf.kind === "fragment")
|
|
297
|
+
return outermost(context, leavesOf(context, leaf.node), depth, seen);
|
|
298
|
+
if (leaf.kind !== "element")
|
|
299
|
+
return [];
|
|
300
|
+
const own = [leaf.node];
|
|
301
|
+
const name = leaf.node.openingElement.name;
|
|
302
|
+
if (isDomName(name) || depth >= FOLLOW_DEPTH)
|
|
303
|
+
return own;
|
|
304
|
+
const roots = componentRoots(context, name);
|
|
305
|
+
if (roots === null)
|
|
306
|
+
return own;
|
|
307
|
+
return [...own, ...outermost(context, roots.flatMap((root) => leavesOfExpression(context, root)), depth + 1, seen)];
|
|
308
|
+
});
|
|
309
|
+
/** What a `PaneSection` renders carries no padding or margin utility on its outermost elements. */
|
|
310
|
+
export const noPaneSectionPadding = exemptFreestyle(defineRule({
|
|
311
|
+
meta: {
|
|
312
|
+
type: "problem",
|
|
313
|
+
docs: { description: "R347: the outermost elements a PaneSection renders carry no padding or margin utility; the section applies the pane inset.", url: "knowledge/hfs/rules.yaml#R347" },
|
|
314
|
+
schema: [],
|
|
315
|
+
messages: {
|
|
316
|
+
padding: "A padding or margin utility on the outermost element of a `PaneSection` stacks a second inset beside the one the pane publishes, so this band no longer lines up with its neighbours. Remove it: `PaneSection` pads inline by the pane inset and spaces its own children by `gap` (`inline`, `row` or `section`); use `bleed=\"inline\"` for a scroller that reaches the pane edges.",
|
|
317
|
+
},
|
|
318
|
+
},
|
|
319
|
+
create(context) {
|
|
320
|
+
if (!isProductSource(context))
|
|
321
|
+
return {};
|
|
322
|
+
const reported = new Set();
|
|
323
|
+
return {
|
|
324
|
+
JSXElement(node) {
|
|
325
|
+
if (nameOf(node.openingElement.name) !== "PaneSection")
|
|
326
|
+
return;
|
|
327
|
+
for (const element of outermost(context, leavesOf(context, node), 0, new Set())) {
|
|
328
|
+
const attribute = classAttribute(element);
|
|
329
|
+
if (attribute === null || reported.has(attribute))
|
|
330
|
+
continue;
|
|
331
|
+
if (!classStrings(context, attribute.value).some(hasInsetUtility))
|
|
332
|
+
continue;
|
|
333
|
+
reported.add(attribute);
|
|
334
|
+
context.report({ node: attribute, messageId: "padding" });
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
}));
|
|
340
|
+
/** The literal text of a `chrome` attribute, or null when it is computed or absent. */
|
|
341
|
+
const chromeOf = (element) => {
|
|
342
|
+
const attributes = element.openingElement.attributes;
|
|
343
|
+
if (attributes.some((entry) => entry.type === "JSXSpreadAttribute"))
|
|
344
|
+
return { known: false, text: null };
|
|
345
|
+
const attribute = attributes.find((entry) => entry.type === "JSXAttribute" && entry.name.type === "JSXIdentifier" && entry.name.name === "chrome");
|
|
346
|
+
if (attribute === undefined)
|
|
347
|
+
return { known: true, text: null };
|
|
348
|
+
const value = attribute.value;
|
|
349
|
+
const node = value?.type === "JSXExpressionContainer" ? value.expression : value;
|
|
350
|
+
if (node?.type === "Literal" && typeof node.value === "string")
|
|
351
|
+
return { known: true, text: node.value };
|
|
352
|
+
if (node?.type === "TemplateLiteral" && node.expressions.length === 0 && node.quasis.length === 1)
|
|
353
|
+
return { known: true, text: node.quasis[0]?.value.cooked ?? "" };
|
|
354
|
+
return { known: false, text: null };
|
|
355
|
+
};
|
|
356
|
+
/** Where a `PaneGrid` stands wrongly, or null when it stands in a pane, in the panes page, or where this file cannot tell. */
|
|
357
|
+
const wrongFrame = (grid) => {
|
|
358
|
+
const frames = [];
|
|
359
|
+
let wrapped = false;
|
|
360
|
+
for (let current = grid.parent; current !== undefined && current !== null; current = current.parent) {
|
|
361
|
+
if (current.type !== "JSXElement")
|
|
362
|
+
continue;
|
|
363
|
+
const name = nameOf(current.openingElement.name);
|
|
364
|
+
if (name === "Freestyle")
|
|
365
|
+
return null;
|
|
366
|
+
if (name === "Pane" || name === "Page" || name === "FillViewport" || (name !== null && SURFACES.has(name)))
|
|
367
|
+
frames.push(current);
|
|
368
|
+
else if (frames.length === 0)
|
|
369
|
+
wrapped = true;
|
|
370
|
+
}
|
|
371
|
+
const frame = frames[0];
|
|
372
|
+
if (frame === undefined)
|
|
373
|
+
return null;
|
|
374
|
+
const name = nameOf(frame.openingElement.name);
|
|
375
|
+
if (name === "Pane")
|
|
376
|
+
return null;
|
|
377
|
+
if (name === "Page") {
|
|
378
|
+
const chrome = chromeOf(frame);
|
|
379
|
+
if (!chrome.known)
|
|
380
|
+
return null;
|
|
381
|
+
if (chrome.text !== "panes")
|
|
382
|
+
return chrome.text === null ? "a `Page` without `chrome=\"panes\"`" : `a \`Page chrome="${chrome.text}"\``;
|
|
383
|
+
return wrapped ? "an element inside `Page chrome=\"panes\"` (the grid is the page's one child)" : null;
|
|
384
|
+
}
|
|
385
|
+
return `a \`${name ?? "frame"}\``;
|
|
386
|
+
};
|
|
387
|
+
/** A `PaneGrid` stands in `Page chrome="panes"` or in a `Pane`. */
|
|
388
|
+
export const paneGridPage = defineRule({
|
|
389
|
+
meta: {
|
|
390
|
+
type: "problem",
|
|
391
|
+
docs: { description: "R348: a PaneGrid is the one child of Page chrome=\"panes\" or stands inside a Pane, never in a FillViewport, a card or another page chrome.", url: "knowledge/hfs/rules.yaml#R348" },
|
|
392
|
+
schema: [],
|
|
393
|
+
messages: {
|
|
394
|
+
frame: "This `PaneGrid` is drawn in {{where}}. A grid is the whole body of a page that is panes, so `<Page chrome=\"panes\">` attaches it flush under the header, full width and to the viewport bottom, with no card, radius or gap; inside a pane it nests as the pane's one child. Make it the child of `Page chrome=\"panes\"` (or of a `Pane`) and drop the wrapper.",
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
create(context) {
|
|
398
|
+
if (!isProductSource(context))
|
|
399
|
+
return {};
|
|
400
|
+
return {
|
|
401
|
+
JSXElement(node) {
|
|
402
|
+
if (nameOf(node.openingElement.name) !== "PaneGrid")
|
|
403
|
+
return;
|
|
404
|
+
const where = wrongFrame(node);
|
|
405
|
+
if (where !== null)
|
|
406
|
+
context.report({ node: node.openingElement, messageId: "frame", data: { where } });
|
|
407
|
+
},
|
|
408
|
+
};
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
/** The rules this law contributes to the plugin. */
|
|
412
|
+
export const rules = {
|
|
413
|
+
"pane-grid-children": paneGridChildren,
|
|
414
|
+
"pane-children": paneChildren,
|
|
415
|
+
"no-pane-section-padding": noPaneSectionPadding,
|
|
416
|
+
"pane-grid-page": paneGridPage,
|
|
417
|
+
};
|
|
418
|
+
defineFamilyRules(rules, "knowledge/hfs/rules.yaml#R345");
|
|
419
|
+
/** Every rule of this law is an error. */
|
|
420
|
+
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]));
|
package/docs/pane.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# A pane grid holds panes, a pane holds sections
|
|
2
|
+
|
|
3
|
+
Law module: `pane.ts`. Catalogue: R345 FE_PANE_GRID_CHILD_NOT_PANE, R346 FE_PANE_CHILD_NOT_SECTION, R347 FE_PANE_SECTION_PADDING,
|
|
4
|
+
R348 FE_PANE_GRID_FRAME.
|
|
5
|
+
|
|
6
|
+
`PaneGrid` places each child by the `area` of a `Pane` element and drops the rest. A `Pane` owns its content inset and
|
|
7
|
+
publishes it to its `PaneSection` bands (or to one nested `PaneGrid`); a band takes its inline inset from the pane, so a
|
|
8
|
+
padding or margin utility on what a band renders adds a second inset beside it. A tabbed app page mounts its grid as
|
|
9
|
+
`Page chrome="panes"`, flush under the tab line; a grid in a card or a viewport-fill wrapper re-decides the frame and the
|
|
10
|
+
bottom edge that chrome owns.
|
|
11
|
+
|
|
12
|
+
Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline. They apply to product
|
|
13
|
+
source (the route, feature, component, hook, foundation, module and transport tiers and the workspace packages); a script or
|
|
14
|
+
a file no slot owns is not judged. A raw element inside a `Freestyle` subtree is the app's own and is not judged.
|
|
15
|
+
|
|
16
|
+
Children are read through `cond ? <Pane/> : null`, `cond && <Pane/>`, `items.map(() => <Pane/>)`, arrays and fragments (a
|
|
17
|
+
fragment inside a `Pane` is read through; a fragment as a `PaneGrid` child is refused). null, false and `undefined` render
|
|
18
|
+
nothing.
|
|
19
|
+
|
|
20
|
+
## `starci-grammar/pane-grid-children`
|
|
21
|
+
|
|
22
|
+
A child of `PaneGrid` that is not a literal `Pane` element (a wrapper component, a raw element, a fragment or a variable) is a
|
|
23
|
+
finding: its cell renders blank.
|
|
24
|
+
|
|
25
|
+
**Invalid** (`src/components/blocks/BrainDossiers/component.tsx`)
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
<PaneGrid areas={areas}>
|
|
29
|
+
<CategoryPane area="list" />
|
|
30
|
+
<Pane area="main">…</Pane>
|
|
31
|
+
</PaneGrid>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Valid**
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<PaneGrid areas={areas}>
|
|
38
|
+
<Pane area="list">…</Pane>
|
|
39
|
+
{hasDetail ? <Pane area="detail">…</Pane> : null}
|
|
40
|
+
</PaneGrid>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Finding code:** `FE_PANE_GRID_CHILD_NOT_PANE`
|
|
44
|
+
|
|
45
|
+
## `starci-grammar/pane-children`
|
|
46
|
+
|
|
47
|
+
A raw element, or a Grammar component other than `PaneSection`, `PaneGrid` and `Freestyle`, placed directly in a `Pane` is a
|
|
48
|
+
finding: it skips the inset the pane publishes. A project component is allowed here and judged in its own file.
|
|
49
|
+
|
|
50
|
+
**Invalid**
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
<Pane area="list">
|
|
54
|
+
<div className="shrink-0 px-4 pt-3 pb-2"><SearchField label={label} /></div>
|
|
55
|
+
</Pane>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Valid**
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<Pane area="list">
|
|
62
|
+
<PaneSection><SearchField label={label} /></PaneSection>
|
|
63
|
+
</Pane>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Finding code:** `FE_PANE_CHILD_NOT_SECTION`
|
|
67
|
+
|
|
68
|
+
## `starci-grammar/no-pane-section-padding`
|
|
69
|
+
|
|
70
|
+
A padding or margin utility (`p-*`, `px-*`, `py-*`, `ps/pe/pt/pb/pl/pr-*`, `m-*`, `mx/my/ms/me/mt/mb/ml/mr-*`, negative forms,
|
|
71
|
+
and the arbitrary `[padding…]` and `[margin…]` properties, under any variant) on the outermost element a `PaneSection` renders
|
|
72
|
+
is a finding, and so is one on the root of a component declared in the same file and returned as a section child. Class strings
|
|
73
|
+
are read from literals, templates, class builders (`cn`, `clsx`, …), conditionals, same-file constants and, through the type
|
|
74
|
+
program, imported constants. Zero and auto values (`p-0`, `mx-auto`) reset or place and inset nothing.
|
|
75
|
+
|
|
76
|
+
**Invalid**
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<PaneSection>
|
|
80
|
+
<div className="px-4 py-3"><SearchField label={label} /></div>
|
|
81
|
+
</PaneSection>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Valid**
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
<PaneSection gap="section">
|
|
88
|
+
<div className="flex items-center gap-2"><Avatar /><Heading level={2}>{name}</Heading></div>
|
|
89
|
+
</PaneSection>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Finding code:** `FE_PANE_SECTION_PADDING`
|
|
93
|
+
|
|
94
|
+
## `starci-grammar/pane-grid-page`
|
|
95
|
+
|
|
96
|
+
A `PaneGrid` whose nearest framing element in the file is a `FillViewport`, a `SurfaceCard`, `SurfaceListCard` or
|
|
97
|
+
`SurfaceAccordionCard`, a `Page` with another chrome than `panes`, or a `Page chrome="panes"` with an element between them, is
|
|
98
|
+
a finding. A grid in a `Pane` is nested and fine; a grid whose frame lives in another file is judged where the frame is.
|
|
99
|
+
|
|
100
|
+
**Invalid**
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
<FillViewport><PaneGrid areas={areas}>…</PaneGrid></FillViewport>
|
|
104
|
+
<SurfaceCard composition="joined"><PaneGrid areas={areas}>…</PaneGrid></SurfaceCard>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Valid**
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
<Page chrome="panes" header={header}><PaneGrid areas={areas}>…</PaneGrid></Page>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Finding code:** `FE_PANE_GRID_FRAME`
|
|
114
|
+
|
|
115
|
+
Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starci/eslint-grammar-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "ESLint rules for the core Grammar's component, token and composition contracts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"node": ">=22"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@starci/eslint-canon-fe": "9.
|
|
44
|
+
"@starci/eslint-canon-fe": "9.7.0",
|
|
45
45
|
"eslint": ">=9",
|
|
46
46
|
"typescript": ">=5.9"
|
|
47
47
|
},
|
|
@@ -31,35 +31,35 @@ pins:
|
|
|
31
31
|
source: packages/event-stream/package.json
|
|
32
32
|
why: 'the one server-sent-events client of every front end (fe-stack event-stream, owner:event-stream-package): the transport client layer (modules/api/sse/clients) creates one instance for the app with the bearer token source and the stream operations follow on it; it carries Last-Event-ID resume, the capped doubling backoff, the heartbeat timeout, the single 401 renewal and the useSWRSubscription adapter, so no app keeps a hand-written reader.'
|
|
33
33
|
'@starci/grammar':
|
|
34
|
-
version: 0.
|
|
34
|
+
version: 0.17.0
|
|
35
35
|
group: starci
|
|
36
36
|
install: registry
|
|
37
37
|
side: fe
|
|
38
38
|
source: packages/grammar/package.json
|
|
39
39
|
why: 'the grammar front ends read: the brand layer sets `--font-sans` and `--font-mono` and the grammar reads them; it carries the Input tel kind, the copyable and read-only Input, the IconButton disclosure props and count badge, ChatBubble, FillViewport, Textarea mentions and Enter-to-send, the leading PrimaryRailLayout rail, the plate-less Image, ListRow, the soft Alert, Progress steps, the floating primary IconButton, FlowGraph, the STATE-8 loading views and the bordered selectable TagGroup chips. The runtime source version wins for a @starci package.'
|
|
40
40
|
'@starci/eslint-canon-be':
|
|
41
|
-
version: 3.
|
|
41
|
+
version: 3.11.0
|
|
42
42
|
group: starci
|
|
43
43
|
install: registry
|
|
44
44
|
side: be
|
|
45
45
|
source: packages/eslint-canon-be/package.json
|
|
46
46
|
why: 'the back-end ESLint canon: `loadHfs(import.meta.url)` of be/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the be side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; `starciBeConfig({ hfs: loadHfs(import.meta.url) })` is the typed factory and the BE-CONVENTION laws are its rules.'
|
|
47
47
|
'@starci/eslint-canon-fe':
|
|
48
|
-
version: 9.
|
|
48
|
+
version: 9.7.0
|
|
49
49
|
group: starci
|
|
50
50
|
install: registry
|
|
51
51
|
side: fe
|
|
52
52
|
source: packages/eslint-canon-fe/package.json
|
|
53
53
|
why: 'the front-end ESLint canon: `loadHfs(import.meta.url)` of fe/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the fe side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; the front end has no tests (FE_NO_TESTS R97 in hfs) and no-vietnamese-in-source (R91) applies.'
|
|
54
54
|
'@starci/eslint-grammar-core':
|
|
55
|
-
version: 0.
|
|
55
|
+
version: 0.17.0
|
|
56
56
|
group: starci
|
|
57
57
|
install: registry
|
|
58
58
|
side: fe
|
|
59
59
|
source: packages/eslint-grammar-core/package.json
|
|
60
60
|
why: 'the StarCi Grammar component API lint, versioned with @starci/grammar; front ends compose this family package with the universal FE canon.'
|
|
61
61
|
'@starci/eslint-grammar-offset-pop':
|
|
62
|
-
version: 0.
|
|
62
|
+
version: 0.17.0
|
|
63
63
|
group: starci
|
|
64
64
|
install: registry
|
|
65
65
|
side: fe
|
|
@@ -99,14 +99,14 @@ pins:
|
|
|
99
99
|
source: packages/test-world/package.json
|
|
100
100
|
why: 'the shared e2e library of every back end (R47, R48), a devDependency of every back end: the warm stack behind toxiproxy, the network-edge fakes, the Nest boot, the typed useTestWorld handle, useSandbox for contract specs and the outage lock. A fake declared https (defineHttpFake) serves TLS with the run''s ephemeral in-memory fake CA and publishes its PEM as w.fake.<name>.ca for the app''s own client to trust; verification is never turned off. Kafka is real own infra (the one digest-pinned apache/kafka KRaft image, a broker listener and proxy per slot, slot-prefixed topics, consumer groups and client ids) and Postgres is schema-per-context (a schema and a login role per context in a shared database). Each worker has its own data slot (<ns>_w<k>) with its own databases, Keycloak realm, leased Redis DB, bucket/collection/topic prefixes, fakes host, toxiproxy proxies and outage lock; a run provisions min(jest workers, workers cap, default 2) slots, and state file protocol 2 pairs exactly with @starci/jest-preset (TEST_WORLD_PAIR_MISMATCH otherwise). A modules world boots real peer apps beside its modules, world.apps.<name>.during(fn) is the outage of a peer app, w.keycloak.clientSecret(client) answers the run-generated secret of a confidential realm client, world.keycloak.events/sessions read the realm user events and live sessions, world.infra.postgresql.connection(name) takes one database connection down while the others serve, and world.resolve and scope.resolve take any Nest token. Every path a declaration names (`stack`, seeds, the realm, Dockerfiles) resolves from the app root (the directory of hfs.json); the globalSetup registers the path aliases as TypeScript resolves them. Its CLI main is exported at ./cli for starci app stack.'
|
|
101
101
|
'@starci/ai-router':
|
|
102
|
-
version: 0.
|
|
102
|
+
version: 0.5.0
|
|
103
103
|
group: starci
|
|
104
104
|
install: registry
|
|
105
105
|
side: be
|
|
106
106
|
source: packages/ai-router/package.json
|
|
107
107
|
why: 'the AI pool router of a back end: a NestJS module that routes OpenAI-compatible chat, stream and embeddings calls across keys, models and providers, with @starci/ai-router/testing for its specs; @starci/jest-preset compiles it as an ESM-only dependency.'
|
|
108
108
|
'@starci/hfs':
|
|
109
|
-
version: 4.
|
|
109
|
+
version: 4.15.0
|
|
110
110
|
group: starci
|
|
111
111
|
install: registry
|
|
112
112
|
side: both
|
|
@@ -1407,7 +1407,7 @@ rules:
|
|
|
1407
1407
|
witness:
|
|
1408
1408
|
- {"path":"packages/eslint/be/legacy-sql-http-log-proof.spec.mjs","edition":"lite","codes":["BE_SQL_INTERPOLATED"]}
|
|
1409
1409
|
- {"path":"packages/eslint/be/legacy-sql-http-log-proof.spec.mjs","edition":"full","codes":["BE_SQL_INTERPOLATED"]}
|
|
1410
|
-
law: "SQL text carries no runtime substitution; values are numbered parameters. The one exception is R334's
|
|
1410
|
+
law: "SQL text carries no runtime substitution; values are numbered parameters. The one exception is R334's call and LISTEN statements in platform/database/database.client.ts, which splice only the name parts and parameter list its own validator checked."
|
|
1411
1411
|
kinds: [lint, codemod]
|
|
1412
1412
|
gates: [pre-commit, settle, land, ci]
|
|
1413
1413
|
failureCodes: ["BE_SQL_INTERPOLATED"]
|
|
@@ -5828,7 +5828,7 @@ rules:
|
|
|
5828
5828
|
ruling: "Lite entities only map tables the migrations create, so each entity column is checked against the migrated schema by starci app db drift, which CI runs in the build job and the release gate runs as its db-drift row."
|
|
5829
5829
|
- id: R334
|
|
5830
5830
|
code: "BE_PERSISTENCE_NO_RAW_SQL"
|
|
5831
|
-
law: "Lite
|
|
5831
|
+
law: "Lite TypeScript holds no SQL text, outside the test world. A table is read and written through its TypeORM entity on an EntityManager (domain code the injected one; specs, builders, fixtures and the test world the world's `world.db.<connection>`): find, save, update, delete, upsert, a pessimistic `lock` option, `createQueryBuilder(Entity, \"alias\")` with named parameters; never a table-name builder or a Repository. Every table a migration creates has an entity. Anything else is a database function, called through `callDbFunction` of `platform/database/database.client.ts`, which names only a function that `ruleParams.be.dbFunctions` or hfs.json `sides.be.dbFunctions` lists with a reason: a function of a migration, schema-qualified (`public.job_claim`); an extension function, schema-qualified; a pg built-in of the canon's list, bare (`pg_notify`, called in pg_catalog). `database.client.ts` alone composes SQL text (the call statement and LISTEN), from parts its validator checked; `advisoryXactLock` and `notify` are `callDbFunction` calls of built-ins there. The only other `.query(` outside the world is the pass-through of a file that `ruleParams.be.sqlPassThrough` or hfs.json `sides.be.sqlPassThrough` lists with a reason, whose text is not the app's own (the tracked seed, a customer data-source read, an outside session's setup), with a plain string first argument, never a template or a `+`. The test world `src/tests/world` may hold raw SQL, as `sql`-tagged text with numbered `$n` parameters (and `<name>.sql.ts` files), only for what neither an entity nor a listed function expresses: a privilege or row-level-security probe, catalog, cron or trigger introspection, a pgmq queue table, a lock or failure probe; in the world too plain CRUD on an application table goes through its entity, an application function through `callDbFunction`, and seeded rows come from builders (R98). No `sql` template, `*.sql.ts`, `sql`/`ident` import or other `.query(` exists anywhere else."
|
|
5832
5832
|
kinds: [lint]
|
|
5833
5833
|
gates: [pre-commit, settle, land, ci]
|
|
5834
5834
|
failureCodes: ["BE_PERSISTENCE_NO_RAW_SQL"]
|
|
@@ -6048,3 +6048,118 @@ rules:
|
|
|
6048
6048
|
source: owner
|
|
6049
6049
|
quote: "Xóa ai api key và openclaw ai key chỉnh thành starci ai key là key ảo"
|
|
6050
6050
|
ruling: "Per app and environment the ai member holds the upstream provider keys and one random virtual key STARCI_AI_KEY that the gateway mounts and every client uses; the gateway has no admin API (ruling be-ai-one-virtual-key)."
|
|
6051
|
+
- id: R345
|
|
6052
|
+
code: "FE_PANE_GRID_CHILD_NOT_PANE"
|
|
6053
|
+
law: "A child of a Grammar PaneGrid is a literal Pane element, written directly or returned by a conditional (`cond ? <Pane/> : null`, `cond && <Pane/>`) or a `.map`; a wrapper component, a raw element, a fragment or a variable is refused, because PaneGrid places each child by the area of a Pane and drops the rest, leaving its cell blank. A Freestyle subtree leaves the raw elements inside it alone."
|
|
6054
|
+
kinds: [lint]
|
|
6055
|
+
gates: [pre-commit, settle, land, ci]
|
|
6056
|
+
failureCodes: ["FE_PANE_GRID_CHILD_NOT_PANE"]
|
|
6057
|
+
enforcers:
|
|
6058
|
+
- {kind: eslint-grammar-core, id: pane-grid-children}
|
|
6059
|
+
editions: [lite, full]
|
|
6060
|
+
docs: [contexts/ui/components/pane-grid.md]
|
|
6061
|
+
templateNa: "A template draws no pane grid; an app adds one with its multi-pane screens."
|
|
6062
|
+
proves:
|
|
6063
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_GRID_CHILD_NOT_PANE]}
|
|
6064
|
+
exemplifiedBy:
|
|
6065
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_GRID_CHILD_NOT_PANE]}
|
|
6066
|
+
witness:
|
|
6067
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_GRID_CHILD_NOT_PANE]}
|
|
6068
|
+
cases:
|
|
6069
|
+
- id: case-1
|
|
6070
|
+
date: "2026-10-31"
|
|
6071
|
+
source: owner
|
|
6072
|
+
quote: "trò thiết kế hệ thống padding đồng nhất cho grammar chứ mỗi nơi 1 padding trò thấy k"
|
|
6073
|
+
ruling: "A Pane owns its content inset and every band in it is a PaneSection; a PaneGrid holds Panes only, so the lint refuses a wrapper component that the grid would drop."
|
|
6074
|
+
- id: R346
|
|
6075
|
+
code: "FE_PANE_CHILD_NOT_SECTION"
|
|
6076
|
+
law: "A Grammar Pane holds PaneSection elements or one nested PaneGrid; a raw element, or a Grammar component other than PaneSection, PaneGrid and Freestyle, placed directly in a Pane skips the inset the pane publishes to its bands. A project component is judged in its own file, and a Freestyle subtree leaves its raw elements alone."
|
|
6077
|
+
kinds: [lint]
|
|
6078
|
+
gates: [pre-commit, settle, land, ci]
|
|
6079
|
+
failureCodes: ["FE_PANE_CHILD_NOT_SECTION"]
|
|
6080
|
+
enforcers:
|
|
6081
|
+
- {kind: eslint-grammar-core, id: pane-children}
|
|
6082
|
+
editions: [lite, full]
|
|
6083
|
+
docs: [contexts/ui/components/pane-grid.md]
|
|
6084
|
+
templateNa: "A template draws no pane grid; an app adds one with its multi-pane screens."
|
|
6085
|
+
proves:
|
|
6086
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_CHILD_NOT_SECTION]}
|
|
6087
|
+
exemplifiedBy:
|
|
6088
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_CHILD_NOT_SECTION]}
|
|
6089
|
+
witness:
|
|
6090
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_CHILD_NOT_SECTION]}
|
|
6091
|
+
cases:
|
|
6092
|
+
- id: case-1
|
|
6093
|
+
date: "2026-10-31"
|
|
6094
|
+
source: owner
|
|
6095
|
+
quote: "trò thiết kế hệ thống padding đồng nhất cho grammar chứ mỗi nơi 1 padding trò thấy k"
|
|
6096
|
+
ruling: "A Pane owns its content inset and every band in it is a PaneSection whose boxes align to that edge, so the lint refuses a band hand-built in a pane."
|
|
6097
|
+
- id: R347
|
|
6098
|
+
code: "FE_PANE_SECTION_PADDING"
|
|
6099
|
+
law: "The outermost element a Grammar PaneSection renders, and the root of a same-file component returned as its child, carries no padding or margin utility (`p-*`, `px-*`, `py-*`, `ps/pe/pt/pb/pl/pr-*`, `m-*`, `mx/my/ms/me/mt/mb/ml/mr-*`, their negative forms, or an arbitrary padding or margin property; zero and auto values place or reset and are not one), because the Pane owns the content inset and the section applies it. A Freestyle subtree leaves its raw elements alone."
|
|
6100
|
+
kinds: [lint]
|
|
6101
|
+
gates: [pre-commit, settle, land, ci]
|
|
6102
|
+
failureCodes: ["FE_PANE_SECTION_PADDING"]
|
|
6103
|
+
enforcers:
|
|
6104
|
+
- {kind: eslint-grammar-core, id: no-pane-section-padding}
|
|
6105
|
+
editions: [lite, full]
|
|
6106
|
+
docs: [contexts/ui/components/pane-grid.md]
|
|
6107
|
+
templateNa: "A template draws no pane grid; an app adds one with its multi-pane screens."
|
|
6108
|
+
proves:
|
|
6109
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_SECTION_PADDING]}
|
|
6110
|
+
exemplifiedBy:
|
|
6111
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_SECTION_PADDING]}
|
|
6112
|
+
witness:
|
|
6113
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_SECTION_PADDING]}
|
|
6114
|
+
cases:
|
|
6115
|
+
- id: case-1
|
|
6116
|
+
date: "2026-10-31"
|
|
6117
|
+
source: owner
|
|
6118
|
+
quote: "trò thiết kế hệ thống padding đồng nhất cho grammar chứ mỗi nơi 1 padding trò thấy k"
|
|
6119
|
+
ruling: "One padding system for everything placed in a PaneGrid: the Pane publishes the inset and the PaneSection applies it, so no band adds its own."
|
|
6120
|
+
- id: R348
|
|
6121
|
+
code: "FE_PANE_GRID_FRAME"
|
|
6122
|
+
law: "A Grammar PaneGrid is the one child of `Page chrome=\"panes\"` or stands inside a Pane; a PaneGrid drawn in a FillViewport, a SurfaceCard, SurfaceListCard or SurfaceAccordionCard, a Page of another chrome, or wrapped inside `Page chrome=\"panes\"` re-decides the frame and the bottom edge that Page owns. A grid whose frame lives in another file is judged where the frame is, and a Freestyle subtree is not judged."
|
|
6123
|
+
kinds: [lint]
|
|
6124
|
+
gates: [pre-commit, settle, land, ci]
|
|
6125
|
+
failureCodes: ["FE_PANE_GRID_FRAME"]
|
|
6126
|
+
enforcers:
|
|
6127
|
+
- {kind: eslint-grammar-core, id: pane-grid-page}
|
|
6128
|
+
editions: [lite, full]
|
|
6129
|
+
docs: [contexts/ui/components/pane-grid.md]
|
|
6130
|
+
templateNa: "A template draws no pane grid; an app adds one with its multi-pane screens."
|
|
6131
|
+
proves:
|
|
6132
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_GRID_FRAME]}
|
|
6133
|
+
exemplifiedBy:
|
|
6134
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_GRID_FRAME]}
|
|
6135
|
+
witness:
|
|
6136
|
+
- {path: packages/eslint-grammar-core/src/pane.spec.ts, editions: [lite, full], codes: [FE_PANE_GRID_FRAME]}
|
|
6137
|
+
cases:
|
|
6138
|
+
- id: case-1
|
|
6139
|
+
date: "2026-10-31"
|
|
6140
|
+
source: owner
|
|
6141
|
+
quote: "sao trang lan agent có gap 1 khoảng trên vậy??? … phải dính vào chứ"
|
|
6142
|
+
ruling: "A tabbed app page's PaneGrid attaches flush under the tab line, full width and to the bottom, with no card, radius or gap: Page chrome=\"panes\"."
|
|
6143
|
+
- id: R349
|
|
6144
|
+
code: "FE_HAND_BUILT_PANES"
|
|
6145
|
+
law: "A multi-pane frame is a Grammar PaneGrid of Panes, which draws the dividers between panes; a vertical Divider used as a column seam (among the plain columns of a flex row, or anywhere inside a SurfaceCard composition=\"joined\") and a joined SurfaceCard that holds a flex row of two or more plain columns are a pane frame drawn by hand and are refused. A short vertical separator between controls and a row whose classes cannot be read in the file are not judged."
|
|
6146
|
+
kinds: [lint]
|
|
6147
|
+
gates: [pre-commit, settle, land, ci]
|
|
6148
|
+
failureCodes: ["FE_HAND_BUILT_PANES"]
|
|
6149
|
+
enforcers:
|
|
6150
|
+
- {kind: eslint-fe, id: no-hand-built-panes}
|
|
6151
|
+
editions: [lite, full]
|
|
6152
|
+
docs: [contexts/ui/components/pane-grid.md]
|
|
6153
|
+
templateNa: "A template draws no multi-pane frame; an app adds one with its multi-pane screens."
|
|
6154
|
+
proves:
|
|
6155
|
+
- {path: packages/eslint-canon-fe/src/surface-rules.spec.ts, editions: [lite, full], codes: [FE_HAND_BUILT_PANES]}
|
|
6156
|
+
exemplifiedBy:
|
|
6157
|
+
- {path: packages/eslint-canon-fe/src/surface-rules.spec.ts, editions: [lite, full], codes: [FE_HAND_BUILT_PANES]}
|
|
6158
|
+
witness:
|
|
6159
|
+
- {path: packages/eslint-canon-fe/src/surface-rules.spec.ts, editions: [lite, full], codes: [FE_HAND_BUILT_PANES]}
|
|
6160
|
+
cases:
|
|
6161
|
+
- id: case-1
|
|
6162
|
+
date: "2026-10-31"
|
|
6163
|
+
source: owner
|
|
6164
|
+
quote: "sao trang lan agent có gap 1 khoảng trên vậy??? … phải dính vào chứ"
|
|
6165
|
+
ruling: "A multi-pane frame is the Grammar's PaneGrid, never columns and a vertical Divider composed by hand inside a card."
|
|
@@ -460,6 +460,10 @@ ruleParams:
|
|
|
460
460
|
- {name: public.event_bus_bury, reason: "platform/event-bus (add webhook, lite): the move of an exhausted or malformed message to its consumer's dead-letter queue"}
|
|
461
461
|
- {name: public.event_bus_dead_letters, reason: "platform/event-bus (add webhook, lite): the operator read of a consumer's dead-letter queue"}
|
|
462
462
|
- {name: public.event_bus_requeue, reason: "platform/event-bus (add webhook, lite): the operator requeue of one dead letter"}
|
|
463
|
+
# R334 (lite): the only `.query(` outside platform/database's composer and the test world is the pass-through of a file listed here
|
|
464
|
+
# (or in hfs.json sides.be.sqlPassThrough), whose SQL text is not the app's own. Paths are relative to the side folder.
|
|
465
|
+
sqlPassThrough:
|
|
466
|
+
- {file: src/modules/platform/database/seed-runner.service.ts, reason: "the tracked seed file's text, run as it is (db/seed.sql); the app writes no SQL there"}
|
|
463
467
|
|
|
464
468
|
lite:
|
|
465
469
|
schemaAuthority: sql
|
|
@@ -2027,7 +2031,7 @@ slots:
|
|
|
2027
2031
|
own; use-test-world.ts exports useTestWorld({ modules: [...] }) -> world.db.<connection> (the shared EntityManager) and
|
|
2028
2032
|
world.fake.<provider> (a network-edge fake of an external SaaS). There is no world.apps (no e2e) and no world.infra
|
|
2029
2033
|
(no self-hosted service to cut)
|
|
2030
|
-
allows: [global-setup.ts, global-teardown.ts, use-test-world.ts, "fakes/<provider>/server.ts", fakes
|
|
2034
|
+
allows: [global-setup.ts, global-teardown.ts, use-test-world.ts, "fakes/<provider>/server.ts", fakes/, "<name>.sql.ts"] # jest globalSetup/globalTeardown default-export (Jest API); fakes/<provider>/server.ts is the fake server of a provider, a literal file name BE_SOURCE_FORM reads as its role; plus root files with a role suffix (test-world-files, R47)
|
|
2031
2035
|
tests: none
|
|
2032
2036
|
coverage: none
|
|
2033
2037
|
why: >-
|
|
@@ -24,7 +24,7 @@ rules:
|
|
|
24
24
|
- id: FE-UI
|
|
25
25
|
title: Compose the selected Grammar
|
|
26
26
|
kind: mandatory
|
|
27
|
-
hfsRules: [R93, R244, R313, R314, R315, R316, R317, R318, R319, R320, R338, R339, R340, R341]
|
|
27
|
+
hfsRules: [R93, R244, R313, R314, R315, R316, R317, R318, R319, R320, R338, R339, R340, R341, R345, R346, R347, R348, R349]
|
|
28
28
|
requirement: |-
|
|
29
29
|
Components compose the selected Grammar through its published entry and props; application CSS carries
|
|
30
30
|
layout only (css.yaml). A missing visual capability is added to that Grammar before the app consumes it.
|
|
@@ -68,6 +68,15 @@ rules:
|
|
|
68
68
|
screen), passing the asset slot it was requested under (assetSlot, and assetSha256 once delivered); a scene
|
|
69
69
|
or illustration is framed by MediaFrame. Generated art under /images/ never renders through a bare Image or
|
|
70
70
|
img (R338, R339).
|
|
71
|
+
- id: case-5
|
|
72
|
+
date: "2026-10-31"
|
|
73
|
+
source: owner
|
|
74
|
+
when: A screen places content in a PaneGrid
|
|
75
|
+
write: |-
|
|
76
|
+
Compose a PaneGrid of Pane elements (never a wrapper component), give each Pane PaneSection bands (never a raw
|
|
77
|
+
element or a padded wrapper), and mount a tabbed app page's grid as Page chrome="panes"; the Pane publishes one
|
|
78
|
+
content inset and the sections apply it (R345, R346, R347, R348). A multi-pane frame is never columns with a
|
|
79
|
+
vertical Divider inside a card (R349).
|
|
71
80
|
verification:
|
|
72
81
|
automated:
|
|
73
82
|
- FE_VENDOR_BOUNDARY
|
|
@@ -94,5 +103,10 @@ rules:
|
|
|
94
103
|
- FE_MASCOT_ASSET_SLOT_MISSING
|
|
95
104
|
- FE_RAISED_SURFACE_IN_SURFACE
|
|
96
105
|
- FE_FREESTYLE_REASON_MISSING
|
|
106
|
+
- FE_PANE_GRID_CHILD_NOT_PANE
|
|
107
|
+
- FE_PANE_CHILD_NOT_SECTION
|
|
108
|
+
- FE_PANE_SECTION_PADDING
|
|
109
|
+
- FE_PANE_GRID_FRAME
|
|
110
|
+
- FE_HAND_BUILT_PANES
|
|
97
111
|
manual: []
|
|
98
112
|
relatedExamples: [full-app-shell, lite-app-shell]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPlainObject } from '../../engine/plain-object.mjs';
|
|
2
2
|
import { APP_KIND, connectionShapeProblems, NAME, PACKAGE_NAME, RUNTIME_KIND, SLOT_ID } from './manifest-shape.mjs';
|
|
3
|
-
import { dbFunctionsOk } from './rule-params-shape.mjs';
|
|
3
|
+
import { dbFunctionsOk, sqlPassThroughOk } from './rule-params-shape.mjs';
|
|
4
4
|
import { kindShapeProblems, patternShapeProblems } from './declaration-slots.mjs';
|
|
5
5
|
import { byCodeUnit } from '../lib/list.mjs';
|
|
6
6
|
/** Shape problems of the optional hfs.json `db` block of a lite app: the environment variable naming its database, its image, forced RLS and its application role. */
|
|
@@ -91,10 +91,12 @@ function declarationSideProblems(side, value, names) {
|
|
|
91
91
|
if (!isPlainObject(value))
|
|
92
92
|
return [`${at} must be an object`];
|
|
93
93
|
for (const key of Object.keys(value))
|
|
94
|
-
if (!['apps', 'optionalSlots', 'patterns', 'kinds', 'connections', 'reads', 'extraPackages', 'grammar', 'backing', 'dbFunctions'].includes(key))
|
|
94
|
+
if (!['apps', 'optionalSlots', 'patterns', 'kinds', 'connections', 'reads', 'extraPackages', 'grammar', 'backing', 'dbFunctions', 'sqlPassThrough'].includes(key))
|
|
95
95
|
bad.push(`${at} has unknown key ${key}`);
|
|
96
96
|
if (value.dbFunctions !== undefined && (side !== 'be' || !dbFunctionsOk(value.dbFunctions, { bare: true })))
|
|
97
97
|
bad.push(`${at}.dbFunctions belongs to the be side and lists {name, reason} database functions, each schema-qualified (schema.name, never pg_catalog) or a bare pg built-in of the canon's list, with unique names`);
|
|
98
|
+
if (value.sqlPassThrough !== undefined && (side !== 'be' || !sqlPassThroughOk(value.sqlPassThrough)))
|
|
99
|
+
bad.push(`${at}.sqlPassThrough belongs to the be side and lists {file, reason} files relative to the side folder, forward slashes, unique, each with the reason its SQL text is not the app's own`);
|
|
98
100
|
bad.push(...appShapeProblems(value.apps, at, side, names));
|
|
99
101
|
if (isBadUniqueList(value.optionalSlots, (slot) => SLOT_ID.test(String(slot))))
|
|
100
102
|
bad.push(`${at}.optionalSlots must be a unique list of slot ids`);
|
|
@@ -73,6 +73,11 @@ const dbFunctionNameOk = (name, bare) => typeof name === 'string' && (/^[a-z_][a
|
|
|
73
73
|
* a bare name, which only the canon's list (ruleParams.be.dbFunctions) uses, for the pg built-ins its helpers call.
|
|
74
74
|
*/
|
|
75
75
|
export const dbFunctionsOk = (list, { bare = false } = {}) => list === undefined || (Array.isArray(list) && list.every((entry) => isPlainObject(entry) && Object.keys(entry).sort().join() === 'name,reason' && dbFunctionNameOk(entry.name, bare) && typeof entry.reason === 'string' && entry.reason.trim().length > 0) && new Set(list.map((entry) => entry.name)).size === list.length);
|
|
76
|
+
/**
|
|
77
|
+
* True for an absent list or a list of {file, reason} SQL pass-through files (R334): `file` is a forward-slash path relative to the
|
|
78
|
+
* side folder (no leading slash, no `..`), unique, and the reason names whose text the file passes through.
|
|
79
|
+
*/
|
|
80
|
+
export const sqlPassThroughOk = (list) => list === undefined || (Array.isArray(list) && list.every((entry) => isPlainObject(entry) && Object.keys(entry).sort().join() === 'file,reason' && typeof entry.file === 'string' && /^[A-Za-z0-9_.-]+(\/[A-Za-z0-9_.-]+)*$/.test(entry.file) && !entry.file.split('/').includes('..') && typeof entry.reason === 'string' && entry.reason.trim().length > 0) && new Set(list.map((entry) => entry.file)).size === list.length);
|
|
76
81
|
/** The shape problems of `m.ruleParams`. */
|
|
77
82
|
export function ruleParamsProblems(m) {
|
|
78
83
|
const bad = [];
|
|
@@ -84,8 +89,8 @@ export function ruleParamsProblems(m) {
|
|
|
84
89
|
// Edition lite: a side's optional `lite` map overrides keys of the same side (never `lite` itself) when the app declares edition lite.
|
|
85
90
|
if (!sideOk(rp.common, []) || !fileLinesOk(rp.common.fileLines) || !blockOk(rp.common.duplicateBlock))
|
|
86
91
|
bad.push('ruleParams.common needs fileLines {soft, hardGrowth} and duplicateBlock {lines >= 2, tokens >= 1}; optional functionLines and featureFiles must be positive integers');
|
|
87
|
-
if (!sideOk(rp.be, BE_OWN, ['schemaAuthority', 'lite', 'dbFunctions']) || (rp.be.schemaAuthority !== undefined && !SCHEMA_AUTHORITIES.includes(rp.be.schemaAuthority)) || !dbFunctionsOk(rp.be.dbFunctions, { bare: true }) || !liteOk(rp.be.lite, [...BE_OWN, ...SHARED_KEYS, 'schemaAuthority', 'dbFunctions']))
|
|
88
|
-
bad.push('ruleParams.be needs infraOwners, eventBus, specDoubles, paramNames, suffixes, bannedSuffixes, contractShape {helper}, unitRoles, logicRoles, thinRoles, patternScenarios, kindPatterns, addKinds and backing (shared parameters live in ruleParams.common, a side may override them); optional: schemaAuthority (' + SCHEMA_AUTHORITIES.join(' | ') + '), dbFunctions ([{name, reason}]: a pg built-in bare, every other function schema.name) and lite (overrides of the same keys)');
|
|
92
|
+
if (!sideOk(rp.be, BE_OWN, ['schemaAuthority', 'lite', 'dbFunctions', 'sqlPassThrough']) || (rp.be.schemaAuthority !== undefined && !SCHEMA_AUTHORITIES.includes(rp.be.schemaAuthority)) || !dbFunctionsOk(rp.be.dbFunctions, { bare: true }) || !sqlPassThroughOk(rp.be.sqlPassThrough) || !liteOk(rp.be.lite, [...BE_OWN, ...SHARED_KEYS, 'schemaAuthority', 'dbFunctions', 'sqlPassThrough']))
|
|
93
|
+
bad.push('ruleParams.be needs infraOwners, eventBus, specDoubles, paramNames, suffixes, bannedSuffixes, contractShape {helper}, unitRoles, logicRoles, thinRoles, patternScenarios, kindPatterns, addKinds and backing (shared parameters live in ruleParams.common, a side may override them); optional: schemaAuthority (' + SCHEMA_AUTHORITIES.join(' | ') + '), dbFunctions ([{name, reason}]: a pg built-in bare, every other function schema.name), sqlPassThrough ([{file, reason}]: a file whose SQL text is not written by the app) and lite (overrides of the same keys)');
|
|
89
94
|
else
|
|
90
95
|
bad.push(...unitRolesProblems(rp.be), ...roleListProblems(rp.be));
|
|
91
96
|
bad.push(...beSpecificProblems(rp.be, m));
|
|
@@ -125,6 +125,7 @@ function sideDeclaration(manifest, declaration, name, edition, providers) {
|
|
|
125
125
|
providers,
|
|
126
126
|
reads: Object.freeze([...(s.reads ?? [])]),
|
|
127
127
|
dbFunctions: Object.freeze((s.dbFunctions ?? []).map((entry) => Object.freeze({ ...entry }))),
|
|
128
|
+
sqlPassThrough: Object.freeze((s.sqlPassThrough ?? []).map((entry) => Object.freeze({ ...entry }))),
|
|
128
129
|
...(s.grammar === undefined ? {} : { grammar: s.grammar }),
|
|
129
130
|
...(s.extraPackages === undefined ? {} : { extraPackages: Object.freeze(s.extraPackages.map((entry) => Object.freeze({ ...entry }))) }),
|
|
130
131
|
manifestVersion: manifest.version,
|
|
@@ -251,8 +252,8 @@ function createScopeResolver(manifest, repo) {
|
|
|
251
252
|
trackingOf,
|
|
252
253
|
/** True only for a path a slot owns and requires to be committed. */
|
|
253
254
|
isTracked: (p) => trackingOf(p) === 'tracked',
|
|
254
|
-
// The app's own database functions (hfs.json sides.be.dbFunctions) join the canon's
|
|
255
|
-
ruleParams: () =>
|
|
255
|
+
// The app's own database functions and SQL pass-through files (hfs.json sides.be.dbFunctions, sides.be.sqlPassThrough) join the canon's lists (R334).
|
|
256
|
+
ruleParams: () => withDeclaredLists(ruleParams(manifest, profile, edition), repo),
|
|
256
257
|
allowedImports: (tier) => manifest.tiers[profile]?.[tier]?.mayImport ?? null,
|
|
257
258
|
});
|
|
258
259
|
}
|
|
@@ -274,9 +275,18 @@ export function createSlotResolver(manifest, repo) {
|
|
|
274
275
|
const sides = Object.fromEntries(PROFILES.map((side) => [side, createScopeResolver(manifest, app.sides[side])]));
|
|
275
276
|
return appResolver(app, root, sides);
|
|
276
277
|
}
|
|
277
|
-
/** The rule parameters with the app's declared database functions appended to `dbFunctions` (be only), frozen. */
|
|
278
|
-
const
|
|
279
|
-
|
|
278
|
+
/** The rule parameters with the app's declared database functions and SQL pass-through files appended to `dbFunctions` and `sqlPassThrough` (be only), the result frozen. */
|
|
279
|
+
const withDeclaredLists = (params, repo) => {
|
|
280
|
+
const functions = repo.dbFunctions ?? [];
|
|
281
|
+
const passThrough = repo.sqlPassThrough ?? [];
|
|
282
|
+
if ((params.dbFunctions === undefined && !functions.length) && (params.sqlPassThrough === undefined && !passThrough.length))
|
|
283
|
+
return params;
|
|
284
|
+
return Object.freeze({
|
|
285
|
+
...params,
|
|
286
|
+
...(params.dbFunctions === undefined && !functions.length ? {} : { dbFunctions: [...(params.dbFunctions ?? []), ...functions] }),
|
|
287
|
+
...(params.sqlPassThrough === undefined && !passThrough.length ? {} : { sqlPassThrough: [...(params.sqlPassThrough ?? []), ...passThrough] }),
|
|
288
|
+
});
|
|
289
|
+
};
|
|
280
290
|
/** The rule parameters of one profile (be: infraOwners, suffixes, bannedSuffixes and the rest over the shared ruleParams.common fileLines and duplicateBlock; fe: common alone or with its overrides; runtime: ruleParams.runtime of a runtime manifest), as a frozen deep copy. Under `edition` lite the `lite` overrides of ruleParams.<profile> merge over the base (the `lite` key itself is never returned). */
|
|
281
291
|
export function ruleParams(manifest, profile, edition = 'full') {
|
|
282
292
|
const profiles = manifestKind(manifest) === RUNTIME_KIND ? [RUNTIME_KIND] : PROFILES;
|