@starci/eslint-grammar-core 0.20.2 → 0.21.2
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 +25 -1
- package/README.md +5 -4
- package/dist/app-shell.js +1 -1
- package/dist/grammar-boundary.js +5 -5
- package/dist/icon.d.ts +0 -4
- package/dist/icon.js +1 -64
- package/dist/index.js +4 -2
- package/dist/lib/app-shell-cluster.js +1 -1
- package/dist/lib/app-shell-owner.js +1 -1
- package/dist/lib/app-shell-scope.js +1 -1
- package/dist/lib/app-shell-visible.js +0 -1
- package/dist/lib/app-shell.js +2 -2
- package/dist/lib/grammar-imports.d.ts +16 -0
- package/dist/lib/grammar-imports.js +37 -0
- package/dist/lib/why.js +31 -6
- package/dist/page-header.d.ts +11 -4
- package/dist/page-header.js +12 -42
- package/dist/page.d.ts +3 -3
- package/dist/page.js +21 -21
- package/dist/pane.js +3 -3
- package/dist/status-colors.js +2 -2
- package/dist/surface-card.d.ts +9 -0
- package/dist/surface-card.js +191 -0
- package/dist/surface-depth.d.ts +1 -1
- package/dist/surface-depth.js +53 -49
- package/dist/text-rules.d.ts +18 -0
- package/dist/text-rules.js +160 -0
- package/dist/tokens.d.ts +0 -2
- package/dist/tokens.js +0 -38
- package/docs/app-shell.md +3 -3
- package/docs/grammar-boundary.md +1 -1
- package/docs/page-header.md +15 -12
- package/docs/page.md +5 -5
- package/docs/status-colors.md +1 -1
- package/docs/surface-card.md +57 -0
- package/docs/surface-depth.md +16 -14
- package/package.json +3 -3
- package/runtime/bundle.json +2 -1
- package/runtime/knowledge/grammars/core/playbook.yaml +41 -51
- package/runtime/knowledge/hfs/canon-pins.yaml +7 -7
- package/runtime/knowledge/hfs/rules.yaml +286 -40
- package/runtime/knowledge/hfs/slots.yaml +5 -5
- package/runtime/knowledge/patterns/fe/ui.yaml +0 -1
- package/runtime/knowledge/ui/proof/anatomy-source.yaml +1 -1
- package/runtime/scripts/hfs/architecture/component-tiers.mjs +161 -0
- package/runtime/scripts/hfs/architecture/config.mjs +1 -1
- package/runtime/scripts/hfs/slot-manifest-shape.mjs +16 -1
- package/dist/typography.d.ts +0 -13
- package/dist/typography.js +0 -72
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 0.21.2 - 2026-11-02
|
|
6
|
+
|
|
7
|
+
- Changed: bundled pins follow Grammar 0.21.2 with disabled tab items and its coherent canon cohort; existing runtime checks are unchanged.
|
|
8
|
+
|
|
9
|
+
## 0.21.1 - 2026-11-02
|
|
10
|
+
|
|
11
|
+
- Changed: synchronized the Grammar 0.21.1 API and canon cohort pins; bundled cross-file checks distinguish semantic week regions from labelled peer-card grids.
|
|
12
|
+
|
|
13
|
+
- Changed: bundled R356 names `Grid kind="cards"` as the peer-card layout whose repeated tiles take no outside label, matching the existing `no-label-in-grid` rule and the cross-file surface-nesting owner.
|
|
14
|
+
|
|
15
|
+
## 0.21.0 - 2026-11-02
|
|
16
|
+
|
|
17
|
+
- Removed: `NavigationFeatureNav` from the surface names and the bundled Core playbook (the component is gone; `TopBar` takes `subnavigation`).
|
|
18
|
+
- Changed: the bundled rule catalog words the laws of R348, R351, R352 and R355 for the one card (no SurfaceListCard, SectionHeader or PageHeader).
|
|
19
|
+
- Added: `text-inline-only` (R357, `FE_TEXT_BLOCK`), `no-text-heading` (R358, `FE_TEXT_HEADING`) and `one-highlight-per-render` (R359, `FE_ONE_HIGHLIGHT`).
|
|
20
|
+
- Removed: `no-off-scale-glyph-size` (subsumed by `no-icon-size-class`), `no-decorative-icon-in-metric-cell` (named a component that does not exist), and `no-hand-rolled-heading` with `no-heading-tag-outside-heading-component` (one rule for headings: `no-raw-structural-element`).
|
|
21
|
+
- Changed: the app-shell laws and the pane laws stop naming `NavigationFeatureNav`, `BottomNav`, `FillViewport` and `Region`; the specs run from a worktree (`fixtures/canon-fe-source.mjs` resolves `@starci/eslint-canon-fe` to the sibling source, because `install-links=true` copies the package before its `dist/` is built).
|
|
22
|
+
- Fixed: the type declaration of `@starci/eslint-canon-fe/lib/freestyle.mjs`, so `npm test`'s typecheck passes.
|
|
23
|
+
|
|
24
|
+
- Changed: R323 (`no-hand-rolled-page-header`) reduces to imports: `PageHeader` and `Breadcrumbs` imported from `@starci/grammar` (by name, aliased or through a namespace) are the finding. R325 (`route-page-is-one-page`) refuses `PageHeader` and `PageContainer` the same way (message `part`) and keeps its one-Page reading. R324 (`page-tabs-in-header`) loses its `PageHeader` sibling clause. The bundled catalog carries the new law text.
|
|
25
|
+
- Changed: `no-raw-structural-element` names `Section` as the owner of `section`, `header`, `ul`, `ol` and `li`, and `Input`, `Select` and `Textarea` as the owners of `label`, since `Region`, `SectionHeader`, `List`, `ListItem` and `Label` are no longer grammar components. The bundled core playbook states `Text isStrong` in place of `Text weight`.
|
|
26
|
+
- eslint-grammar-core: R355 `surface-card-kind`, R366 `no-label-in-grid`; R340 `no-raised-surface-in-surface` now refuses any card in a card, Pane surface or overlay.
|
|
27
|
+
|
|
3
28
|
## 0.20.2 - 2026-11-01
|
|
4
29
|
|
|
5
30
|
- Changed: `status-text-uses-soft-foreground` follows the owner's pair rule. It refuses a solid tone painted as text on a `bg-<tone>-soft` tint of the same element (message `onTint`: use `text-<tone>-soft-foreground`) and the soft foreground with no `bg-<tone>-soft` behind it on its element or on an enclosing element of the file (message `alone`: use `text-<tone>`). A bare `text-<tone>`, which the rule refused before, is no longer a finding. Constants and `classes` entries are judged for the first finding only.
|
|
@@ -163,7 +188,6 @@
|
|
|
163
188
|
|
|
164
189
|
- Changed: the peer moves to the 0.15.11 cohort; the bundled slot manifest 3.9.0 replaces the lite `app.supabase*` slots with `app.db` (`db/migrations`, `db/migrations/archive`, `db/seed.sql`, the managed `db/bootstrap.sql`), `be.integrations.supabase` with `be.integrations.passport` and `be.integrations.object-storage`, removes `fe.route.callback`, sets lite `schemaAuthority: sql`, gives lite TypeORM entities in `be.persistence`, adds `ruleParams.be.dbFunctions`, and moves the S3 SDKs to `integrations/object-storage` and the identity libraries to `integrations/passport` in `infraOwners` (`@supabase/*`, `minio` and `bcrypt` nowhere); the bundled rule catalog retires R216, R217, R219, R254 and R287 and adds R328-R334; the bundled canon pins name hfs 4.10.0, eslint-canon-be 3.7.0, eslint-canon-fe 9.5.0 and the Grammar family 0.15.11, pin `@nestjs/passport` 11.0.5 (CommonJS on the Nest 11 line), `passport` 0.7.0, `passport-google-oauth20` 2.0.0, `passport-local` 1.0.0, `bcryptjs` 3.0.3 and their types (tokens are signed and verified with `jose`; `@nestjs/jwt` stays allowed in `integrations/passport` but unpinned), and drop `@supabase/ssr`, `@supabase/supabase-js` and the `supabase` CLI. No rule changed.
|
|
165
190
|
|
|
166
|
-
|
|
167
191
|
## 0.15.10 - 2026-10-29
|
|
168
192
|
|
|
169
193
|
- Changed: `@starci/eslint-canon-fe` 9.4.9 is the peer dependency; the bundled slot manifest gives the model libraries their owners in `ruleParams.be.infraOwners` (`@starci/ai-router` to `integrations/ai-gateway`, `@langchain/*` to `integrations/ai`; `openai`, `langchain`, `@langchain/langgraph`, `@langchain/community` and the provider SDKs nowhere) and lists R326 and R327 on `be.integrations`; the bundled rule catalog carries R326 and R327; the bundled canon pins name hfs 4.9.11, eslint-canon-be 3.6.8, eslint-canon-fe 9.4.9, the Grammar family 0.15.10 (grammar, eslint-grammar-core, eslint-grammar-offset-pop), and pin `@langchain/core` 1.3.1 and `@langchain/openai` 1.8.0. No rule changed.
|
package/README.md
CHANGED
|
@@ -28,12 +28,13 @@ rules (nested control variants, panel-list alignment, layout-only CSS) stay in t
|
|
|
28
28
|
The pinned canon-fe release moved twenty rules here. Their IDs, finding codes and error severity are unchanged;
|
|
29
29
|
only the namespace changes from `starci-fe/` to `starci-grammar/`: `app-shell-frame`,
|
|
30
30
|
`no-shell-bottom-tabs`, `navbar-control-size`, `navbar-cluster`, `no-navbar-create`,
|
|
31
|
-
`no-raw-structural-element`,
|
|
31
|
+
`no-raw-structural-element`,
|
|
32
32
|
`status-text-uses-soft-foreground`, `vendor-primitive-has-named-owner`,
|
|
33
|
-
`no-vendor-icon-outside-icon-leaf`, `heroicons-is-the-glyph-vendor`,
|
|
33
|
+
`no-vendor-icon-outside-icon-leaf`, `heroicons-is-the-glyph-vendor`,
|
|
34
34
|
`no-icon-size-class`, `destructive-menu-entry-needs-danger-tone`,
|
|
35
|
-
`no-
|
|
36
|
-
`no-
|
|
35
|
+
`no-inline-svg-outside-brand-mark-leaf`, `no-fractional-step`,
|
|
36
|
+
`no-unresolved-token-class`, `slot-status-through-slotview`, and the text laws `text-inline-only` (R357),
|
|
37
|
+
`no-text-heading` (R358) and `one-highlight-per-render` (R359).
|
|
37
38
|
|
|
38
39
|
1. Set `sides.fe.grammar` to `core` in `hfs.json`; no family is inferred.
|
|
39
40
|
2. Install this package at its canon-pins version beside `@starci/eslint-canon-fe` 9 in the app
|
package/dist/app-shell.js
CHANGED
|
@@ -10,7 +10,7 @@ import { provesImportedBar, provesNavigationOpener } from "./lib/app-shell-owner
|
|
|
10
10
|
import { variableOf } from "@starci/eslint-canon-fe/lib/bindings.mjs";
|
|
11
11
|
import { walk } from "@starci/eslint-canon-fe/lib/ast.mjs";
|
|
12
12
|
const CANON = "knowledge/ui/composition/app-shell.yaml";
|
|
13
|
-
const BOTTOM_TABS = /^(?:
|
|
13
|
+
const BOTTOM_TABS = /^(?:BottomNavigation|BottomTabBar|MobileBottomNav|MobileTabBar)$/;
|
|
14
14
|
const EXPECTED_CLUSTER = ["language:IconButton", "theme:Switch", "notifications:IconButton", "account:AvatarButton"];
|
|
15
15
|
const meta = (code, description, messages) => ({
|
|
16
16
|
type: "problem",
|
package/dist/grammar-boundary.js
CHANGED
|
@@ -26,16 +26,16 @@ export const GRAMMAR_OWNERS = Object.freeze({
|
|
|
26
26
|
h1: "Heading", h2: "Heading", h3: "Heading", h4: "Heading", h5: "Heading", h6: "Heading",
|
|
27
27
|
p: "Text", span: "Text",
|
|
28
28
|
hr: "Divider",
|
|
29
|
-
label: "
|
|
29
|
+
label: "Input, Select or Textarea",
|
|
30
30
|
form: "Form",
|
|
31
31
|
fieldset: "Fieldset",
|
|
32
32
|
dl: "DescriptionList", dt: "DescriptionList", dd: "DescriptionList",
|
|
33
33
|
table: "DataTable", thead: "DataTable", tbody: "DataTable", tr: "DataTable", td: "DataTable", th: "DataTable",
|
|
34
|
-
ul: "
|
|
35
|
-
header: "
|
|
34
|
+
ul: "Section or SurfaceCard", ol: "Section or SurfaceCard", li: "Section or SurfaceCard",
|
|
35
|
+
header: "Section or TopBar",
|
|
36
36
|
footer: "Footer",
|
|
37
|
-
nav: "NavLandmark,
|
|
38
|
-
section: "
|
|
37
|
+
nav: "NavLandmark, Page or TopBar",
|
|
38
|
+
section: "Section or SurfaceCard",
|
|
39
39
|
main: "WorkspaceShell",
|
|
40
40
|
figure: "MediaFrame", figcaption: "MediaFrame",
|
|
41
41
|
});
|
package/dist/icon.d.ts
CHANGED
|
@@ -7,12 +7,8 @@ export declare const noVendorIconOutsideIconLeaf: Rule.RuleModule;
|
|
|
7
7
|
* ones no list can name in advance.
|
|
8
8
|
*/
|
|
9
9
|
export declare const heroiconsIsTheGlyphVendor: Rule.RuleModule;
|
|
10
|
-
/** A glyph takes one of the two steps; a fraction or an arbitrary value is a third. */
|
|
11
|
-
export declare const noOffScaleGlyphSize: Rule.RuleModule;
|
|
12
10
|
/** The icon's size is its usage's: the call site passes the glyph and never a size class. */
|
|
13
11
|
export declare const noIconSizeClass: Rule.RuleModule;
|
|
14
|
-
/** A repeated metric cell does not invent a feature glyph absent from the reference. */
|
|
15
|
-
export declare const noDecorativeIconInMetricCell: Rule.RuleModule;
|
|
16
12
|
/** Inline SVG belongs only to an explicitly declared brand mark in a leaf entry. */
|
|
17
13
|
export declare const noInlineSvgOutsideBrandMarkLeaf: Rule.RuleModule;
|
|
18
14
|
/** The rules this law contributes to the plugin. */
|
package/dist/icon.js
CHANGED
|
@@ -12,7 +12,7 @@ import { defineFamilyRules, defineRule, exemptFreestyle } from "./lib/rule-contr
|
|
|
12
12
|
* protects one vendor, and a rule that scans one family of utilities protects that family. Neither
|
|
13
13
|
* generalises on its own, and the gap between them is exactly where a third step gets invented.
|
|
14
14
|
*/
|
|
15
|
-
import { attribute,
|
|
15
|
+
import { attribute, staticText, tagName } from "@starci/eslint-canon-fe/lib/ast.mjs";
|
|
16
16
|
import { canonicalPackages } from "@starci/eslint-canon-fe/lib/fe-stack.mjs";
|
|
17
17
|
import { hfsOf } from "@starci/eslint-canon-fe/lib/hfs.mjs";
|
|
18
18
|
import { fileOf, inSlot, isComponentFile, isProductSource, kindOfFile, roleOfFile } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
@@ -20,7 +20,6 @@ import { why } from "./lib/why.js";
|
|
|
20
20
|
/** The one module allowed to name a glyph from a library: the entry of the leaf owner named `Icon`. */
|
|
21
21
|
const ICON_LEAF = { kind: "leaves", owner: "Icon" };
|
|
22
22
|
/** Repeated goal / metric cells are text-led in the reference: the entry of the composite owner named `LabelledProgressRow`. */
|
|
23
|
-
const LABELLED_PROGRESS_ROW = { kind: "composites", owner: "LabelledProgressRow" };
|
|
24
23
|
/**
|
|
25
24
|
* Package roots that ship glyphs.
|
|
26
25
|
*
|
|
@@ -60,8 +59,6 @@ const isEntryOf = (context, { kind, owner }) => isComponentFile(context) && kind
|
|
|
60
59
|
* whose region draws the status glyph of each toast and sits in the modules tier, below every component it could ask.
|
|
61
60
|
*/
|
|
62
61
|
const isIconLeafFile = (context) => isEntryOf(context, ICON_LEAF) || inSlot(context, "fe.modules.toast");
|
|
63
|
-
/** True for the reusable repeated metric cell whose reference contains no decorative glyph. */
|
|
64
|
-
const isLabelledProgressRowFile = (context) => isEntryOf(context, LABELLED_PROGRESS_ROW);
|
|
65
62
|
/** True when an import source resolves into a glyph library, subpaths included. */
|
|
66
63
|
const isGlyphImport = (source) => {
|
|
67
64
|
const value = typeof source === "string" ? source : "";
|
|
@@ -69,8 +66,6 @@ const isGlyphImport = (source) => {
|
|
|
69
66
|
return GLYPH_PACKAGES.some((pkg) => value === pkg || value.startsWith(pkg)) ||
|
|
70
67
|
(isExternalPackage && GLYPH_PACKAGE_NAME.test(value));
|
|
71
68
|
};
|
|
72
|
-
/** A glyph size written as a fraction of a step, or as an arbitrary value. */
|
|
73
|
-
const OFF_SCALE_GLYPH = /\bsize-(?:\d+\.\d+|\[[^\]]+\])/;
|
|
74
69
|
// -- ICON-6 ----------------------------------------------------------------------------------------
|
|
75
70
|
/** A glyph library is named in one file, and a caller asks for a MEANING instead. */
|
|
76
71
|
export const noVendorIconOutsideIconLeaf = defineRule({
|
|
@@ -124,39 +119,6 @@ export const heroiconsIsTheGlyphVendor = defineRule({
|
|
|
124
119
|
};
|
|
125
120
|
},
|
|
126
121
|
});
|
|
127
|
-
// -- ICON-1 ----------------------------------------------------------------------------------------
|
|
128
|
-
/** A glyph takes one of the two steps; a fraction or an arbitrary value is a third. */
|
|
129
|
-
export const noOffScaleGlyphSize = defineRule({
|
|
130
|
-
meta: {
|
|
131
|
-
type: "problem",
|
|
132
|
-
docs: { description: "A glyph is sized by one of the two steps, never by a fraction or an arbitrary value." },
|
|
133
|
-
schema: [],
|
|
134
|
-
messages: {
|
|
135
|
-
offScale: "`{{cls}}` is a glyph size off both steps. A third step is one nobody applies consistently - the author picks it for a reason true on their screen, and everyone after copies the nearest of three. Use the step the icon leaf offers, and if the case genuinely needs a size neither step gives, that is a change to the two steps rather than an exception here.",
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
create(context) {
|
|
139
|
-
if (!isProductSource(context))
|
|
140
|
-
return {};
|
|
141
|
-
const scan = (node, text) => {
|
|
142
|
-
if (!text)
|
|
143
|
-
return;
|
|
144
|
-
const hit = text.match(OFF_SCALE_GLYPH);
|
|
145
|
-
if (hit)
|
|
146
|
-
context.report({ node, messageId: "offScale", data: { cls: hit[0] } });
|
|
147
|
-
};
|
|
148
|
-
return {
|
|
149
|
-
JSXAttribute(node) {
|
|
150
|
-
if (!isClassAttribute(node))
|
|
151
|
-
return;
|
|
152
|
-
scan(node, staticText(node.value));
|
|
153
|
-
},
|
|
154
|
-
VariableDeclarator(node) {
|
|
155
|
-
scan(node, staticText(node.init));
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
122
|
// -- ICON-1 (call site) ----------------------------------------------------------------------------
|
|
161
123
|
/** A size utility on the class of a glyph: `size-5`, `w-4`, `h-6`, `min-w-4`. */
|
|
162
124
|
const SIZE_UTILITY = /(?:^|\s)(?:size|w|h|min-w|min-h|max-w|max-h)-\S+/;
|
|
@@ -185,29 +147,6 @@ export const noIconSizeClass = defineRule({
|
|
|
185
147
|
};
|
|
186
148
|
},
|
|
187
149
|
});
|
|
188
|
-
// -- ICON-10 ---------------------------------------------------------------------------------------
|
|
189
|
-
/** A repeated metric cell does not invent a feature glyph absent from the reference. */
|
|
190
|
-
export const noDecorativeIconInMetricCell = defineRule({
|
|
191
|
-
meta: {
|
|
192
|
-
type: "problem",
|
|
193
|
-
docs: { description: "Repeated metric cells stay text-led unless the reference explicitly contains an icon." },
|
|
194
|
-
schema: [],
|
|
195
|
-
messages: {
|
|
196
|
-
decorative: "`LabelledProgressRow` is a repeated metric cell, not a feature entry. Its reference is text-led, so an `Icon` here invents emphasis and repeats glyph meanings across the grid. Keep the label and figure; reserve tiny glyphs for generic state or action semantics actually present in the reference.",
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
create(context) {
|
|
200
|
-
if (!isLabelledProgressRowFile(context))
|
|
201
|
-
return {};
|
|
202
|
-
return {
|
|
203
|
-
JSXOpeningElement(node) {
|
|
204
|
-
if (node.name?.type === "JSXIdentifier" && node.name.name === "Icon") {
|
|
205
|
-
context.report({ node, messageId: "decorative" });
|
|
206
|
-
}
|
|
207
|
-
},
|
|
208
|
-
};
|
|
209
|
-
},
|
|
210
|
-
});
|
|
211
150
|
/** The immediately preceding JSDoc declares this exported component as a brand mark. */
|
|
212
151
|
const declaresBrandMark = (sourceCode, node) => {
|
|
213
152
|
const comment = sourceCode.getCommentsBefore(node).at(-1);
|
|
@@ -277,9 +216,7 @@ Object.assign(why, {
|
|
|
277
216
|
export const rules = {
|
|
278
217
|
"no-vendor-icon-outside-icon-leaf": noVendorIconOutsideIconLeaf,
|
|
279
218
|
"heroicons-is-the-glyph-vendor": heroiconsIsTheGlyphVendor,
|
|
280
|
-
"no-off-scale-glyph-size": noOffScaleGlyphSize,
|
|
281
219
|
"no-icon-size-class": noIconSizeClass,
|
|
282
|
-
"no-decorative-icon-in-metric-cell": noDecorativeIconInMetricCell,
|
|
283
220
|
"no-inline-svg-outside-brand-mark-leaf": noInlineSvgOutsideBrandMarkLeaf,
|
|
284
221
|
};
|
|
285
222
|
defineFamilyRules(rules, "knowledge/hfs/rules.yaml#R93");
|
package/dist/index.js
CHANGED
|
@@ -12,9 +12,10 @@ import { rules as pageRules } from "./page.js";
|
|
|
12
12
|
import { rules as pageHeaderRules } from "./page-header.js";
|
|
13
13
|
import { rules as paneRules } from "./pane.js";
|
|
14
14
|
import { rules as statusColorsRules } from "./status-colors.js";
|
|
15
|
+
import { rules as surfaceCardRules } from "./surface-card.js";
|
|
15
16
|
import { rules as surfaceDepthRules } from "./surface-depth.js";
|
|
17
|
+
import { rules as textRules } from "./text-rules.js";
|
|
16
18
|
import { rules as tokensRules } from "./tokens.js";
|
|
17
|
-
import { rules as typographyRules } from "./typography.js";
|
|
18
19
|
import { rules as vendorRules } from "./vendor-boundary.js";
|
|
19
20
|
import { why as familyWhy } from "./lib/why.js";
|
|
20
21
|
const CONTRIBUTIONS = [
|
|
@@ -30,9 +31,10 @@ const CONTRIBUTIONS = [
|
|
|
30
31
|
{ law: "page-header", rules: pageHeaderRules },
|
|
31
32
|
{ law: "pane", rules: paneRules },
|
|
32
33
|
{ law: "status-colors", rules: statusColorsRules },
|
|
34
|
+
{ law: "surface-card", rules: surfaceCardRules },
|
|
33
35
|
{ law: "surface-depth", rules: surfaceDepthRules },
|
|
36
|
+
{ law: "text-rules", rules: textRules },
|
|
34
37
|
{ law: "tokens", rules: tokensRules },
|
|
35
|
-
{ law: "typography", rules: typographyRules },
|
|
36
38
|
{ law: "vendor-boundary", rules: vendorRules },
|
|
37
39
|
];
|
|
38
40
|
/** Each concrete Grammar law has one gathered owner. */
|
|
@@ -7,7 +7,7 @@ const controlsOf = (context, expression, choices, shellHeader = false) => {
|
|
|
7
7
|
const branches = [];
|
|
8
8
|
let ownsBar = false;
|
|
9
9
|
visitVisible(context, expression, (opening, name, ancestors) => {
|
|
10
|
-
if (shellHeader && name !== null && ["TopBar"
|
|
10
|
+
if (shellHeader && name !== null && ["TopBar"].includes(name)) {
|
|
11
11
|
ownsBar = true;
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
@@ -42,7 +42,7 @@ const matchesComposition = (context, opening, name, seen, kind) => {
|
|
|
42
42
|
return isNavigationDrawer(context, opening) && proveDrawerBody(context, opening, seen);
|
|
43
43
|
if (kind === "sidebar")
|
|
44
44
|
return name === "Sidebar" && textProp(context, opening, "presentation") === "drawer";
|
|
45
|
-
return name !== null && ["TopBar"
|
|
45
|
+
return name !== null && ["TopBar"].includes(name);
|
|
46
46
|
};
|
|
47
47
|
const proveComposition = (context, render, seen, kind) => {
|
|
48
48
|
const pending = [new Map()];
|
|
@@ -80,7 +80,7 @@ export const appBarOpenings = (context) => {
|
|
|
80
80
|
/** Grammar bars are app bars unless an explicit generic flow shell establishes site-chrome ownership. */
|
|
81
81
|
export const isAppBar = (context, opening) => {
|
|
82
82
|
const barName = grammarName(context, opening);
|
|
83
|
-
if (barName !== "TopBar"
|
|
83
|
+
if (barName !== "TopBar")
|
|
84
84
|
return false;
|
|
85
85
|
for (let current = opening.parent; current; current = current.parent) {
|
|
86
86
|
if (current.type !== "JSXElement")
|
|
@@ -3,7 +3,6 @@ import { grammarName, propOf, realNode, resolveLocal } from "./app-shell.js";
|
|
|
3
3
|
const BAR_SLOTS = {
|
|
4
4
|
WorkspaceShell: ["header", "compactHeader"],
|
|
5
5
|
TopBar: ["brand", "navigation", "actions"],
|
|
6
|
-
NavigationFeatureNav: ["identity", "navigation", "actions", "compactNavigationTrigger"],
|
|
7
6
|
DropdownMenu: ["trigger"],
|
|
8
7
|
Popover: ["trigger"],
|
|
9
8
|
Drawer: ["trigger"],
|
package/dist/lib/app-shell.js
CHANGED
|
@@ -3,8 +3,8 @@ import { functionOf, importOf, unwrap, variableOf } from "@starci/eslint-canon-f
|
|
|
3
3
|
import { isNode } from "./types.js";
|
|
4
4
|
const GRAMMAR_SOURCE = /^@starci\/grammar(?:\/|$)/;
|
|
5
5
|
/** Grammar controls whose visible hit target belongs to the navbar band's size contract. */
|
|
6
|
-
const BAR_CONTROLS = new Set(["Button", "IconButton", "Switch", "AvatarButton", "
|
|
7
|
-
const BAR_WRAPPERS = new Set(["GrammarRoot", "WorkspaceShell", "TopBar", "
|
|
6
|
+
const BAR_CONTROLS = new Set(["Button", "IconButton", "Switch", "AvatarButton", "IdentityLockup", "SearchField", "Input", "TextField", "Select", "TextAction"]);
|
|
7
|
+
const BAR_WRAPPERS = new Set(["GrammarRoot", "WorkspaceShell", "TopBar", "Section", "NavLandmark", "Form", "Fieldset", "Field", "ButtonGroup", "DropdownMenu", "Popover", "Drawer", "Tooltip"]);
|
|
8
8
|
const ACTION_PROPS = ["onPress", "onClick", "onAction", "onValueChange", "onSelectionChange", "onSelectedChange", "onChange", "onInputChange"];
|
|
9
9
|
const INTERACTION_PROPS = new Set(["label", "value", "defaultValue", "selectedKey", "selectedKeys", "selectionMode", "href", ...ACTION_PROPS]);
|
|
10
10
|
/** The name of a plain (non-namespaced) JSX attribute; null for a namespaced one. */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TSESTree } from "@typescript-eslint/types";
|
|
2
|
+
/** Where a name was reached: a named import specifier, or a member of a Grammar namespace import. */
|
|
3
|
+
export interface RemovedImport {
|
|
4
|
+
readonly node: TSESTree.Node;
|
|
5
|
+
readonly name: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The visitor of a law that reduces to imports: a Grammar export that no longer exists is refused where it is imported
|
|
9
|
+
* (`import { Name }`) or reached through a namespace (`G.Name`, in an expression or a JSX tag). The law needs no
|
|
10
|
+
* structural reading, because the export is the whole of the thing it forbids.
|
|
11
|
+
*/
|
|
12
|
+
export declare const refuseGrammarExports: (names: ReadonlySet<string>, refuse: (found: RemovedImport) => void) => {
|
|
13
|
+
ImportDeclaration(declaration: TSESTree.ImportDeclaration): void;
|
|
14
|
+
MemberExpression(node: TSESTree.MemberExpression): void;
|
|
15
|
+
JSXMemberExpression(node: TSESTree.JSXMemberExpression): void;
|
|
16
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** A module that is the Grammar package or one of its entries (`@starci/grammar`, `@starci/grammar/core`, `/common`, `/offset-pop`). */
|
|
2
|
+
const GRAMMAR_SOURCE = /^@starci\/grammar(?:\/|$)/;
|
|
3
|
+
/**
|
|
4
|
+
* The visitor of a law that reduces to imports: a Grammar export that no longer exists is refused where it is imported
|
|
5
|
+
* (`import { Name }`) or reached through a namespace (`G.Name`, in an expression or a JSX tag). The law needs no
|
|
6
|
+
* structural reading, because the export is the whole of the thing it forbids.
|
|
7
|
+
*/
|
|
8
|
+
export const refuseGrammarExports = (names, refuse) => {
|
|
9
|
+
const namespaces = new Set();
|
|
10
|
+
const member = (object, property, node) => {
|
|
11
|
+
const owner = object.type === "Identifier" || object.type === "JSXIdentifier" ? object.name : null;
|
|
12
|
+
const name = property.type === "Identifier" || property.type === "JSXIdentifier" ? property.name : null;
|
|
13
|
+
if (owner !== null && name !== null && namespaces.has(owner) && names.has(name))
|
|
14
|
+
refuse({ node, name });
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
ImportDeclaration(declaration) {
|
|
18
|
+
if (!GRAMMAR_SOURCE.test(String(declaration.source.value)))
|
|
19
|
+
return;
|
|
20
|
+
for (const specifier of declaration.specifiers) {
|
|
21
|
+
if (specifier.type === "ImportNamespaceSpecifier")
|
|
22
|
+
namespaces.add(specifier.local.name);
|
|
23
|
+
else if (specifier.type === "ImportSpecifier") {
|
|
24
|
+
const imported = specifier.imported.type === "Identifier" ? specifier.imported.name : String(specifier.imported.value);
|
|
25
|
+
if (names.has(imported))
|
|
26
|
+
refuse({ node: specifier, name: imported });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
MemberExpression(node) { member(node.object, node.property, node); },
|
|
31
|
+
JSXMemberExpression(node) {
|
|
32
|
+
if (node.parent.type === "JSXClosingElement")
|
|
33
|
+
return;
|
|
34
|
+
member(node.object, node.property, node);
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
package/dist/lib/why.js
CHANGED
|
@@ -41,8 +41,8 @@ export const why = {
|
|
|
41
41
|
},
|
|
42
42
|
"no-hand-rolled-page-header": {
|
|
43
43
|
code: "FE_PAGE_HEADER_HAND_ROLLED",
|
|
44
|
-
en: "A page head in `<file>`
|
|
45
|
-
fix: "
|
|
44
|
+
en: "A page head in `<file>` imports PageHeader or Breadcrumbs from the Grammar, so the head is composed by hand.",
|
|
45
|
+
fix: "Pass the head to Page `header` (title, breadcrumbs and the slots it needs: description, meta, status, mark, actions, tabs).",
|
|
46
46
|
},
|
|
47
47
|
"page-tabs-in-header": {
|
|
48
48
|
code: "FE_PAGE_TABS_OUTSIDE_HEADER",
|
|
@@ -61,14 +61,29 @@ export const why = {
|
|
|
61
61
|
},
|
|
62
62
|
"pane-grid-page": {
|
|
63
63
|
code: "FE_PANE_GRID_FRAME",
|
|
64
|
-
en: "A `PaneGrid` in `<file>` is drawn in a
|
|
65
|
-
fix: "Make the grid the one child of `<Page chrome=\"panes\">` (or the one child of a `Pane`, nested) and drop the
|
|
64
|
+
en: "A `PaneGrid` in `<file>` is drawn in 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 card around it.",
|
|
66
66
|
},
|
|
67
67
|
"route-page-is-one-page": {
|
|
68
68
|
code: "FE_ROUTE_PAGE_OUTSIDE_PAGE",
|
|
69
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).",
|
|
70
70
|
fix: "Draw one Page: the band as its header, everything else in its body, the measure as its measure. When client data builds the header, render as the root the one connected block that draws the Page and pass the body as its children. Under a segment layout whose Page carries header.tabs, a page draws its body only; that layout's Page has nothing beside it, its head in its header. A page mounted only under the (auth) route group is framed by that group's layout.",
|
|
71
71
|
},
|
|
72
|
+
"text-inline-only": {
|
|
73
|
+
code: "FE_TEXT_BLOCK",
|
|
74
|
+
en: "A block component inside `Text` in `<file>`.",
|
|
75
|
+
fix: "Close the Text and place the block beside it, or use the component that owns that layout.",
|
|
76
|
+
},
|
|
77
|
+
"no-text-heading": {
|
|
78
|
+
code: "FE_TEXT_HEADING",
|
|
79
|
+
en: "A strong `Text` in `<file>` only titles the blocks that follow it.",
|
|
80
|
+
fix: "Give the group a Section title, a card label or Heading; they own the level and the spacing.",
|
|
81
|
+
},
|
|
82
|
+
"one-highlight-per-render": {
|
|
83
|
+
code: "FE_ONE_HIGHLIGHT",
|
|
84
|
+
en: "A second `isHighlight` in one render of `<file>`.",
|
|
85
|
+
fix: "Keep the highlight on the one thing that matters now and give the other its plain state.",
|
|
86
|
+
},
|
|
72
87
|
"freestyle-has-reason": {
|
|
73
88
|
code: "FE_FREESTYLE_REASON_MISSING",
|
|
74
89
|
en: "A `<Freestyle>` region in `<file>` has no non-empty string `reason`.",
|
|
@@ -79,16 +94,26 @@ export const why = {
|
|
|
79
94
|
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
95
|
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
96
|
},
|
|
97
|
+
"no-label-in-grid": {
|
|
98
|
+
code: "FE_LABEL_IN_GRID",
|
|
99
|
+
en: "A `SurfaceCard` with a `label` is repeated in a `Grid kind=\"cards\"` in `<file>`: the label sits outside the material, so the grid reads as headings over boxes.",
|
|
100
|
+
fix: "A peer you recognise and open is a tile: `<SurfaceCard kind=\"tile\" name mark description badge action />`, named inside beside its mark. Comparing a fact across peers is one `kind=\"list\"` card.",
|
|
101
|
+
},
|
|
82
102
|
"no-raised-surface-in-surface": {
|
|
83
103
|
code: "FE_RAISED_SURFACE_IN_SURFACE",
|
|
84
|
-
en: "A
|
|
85
|
-
fix: "
|
|
104
|
+
en: "A `SurfaceCard` in `<file>` stands inside another SurfaceCard, a Pane surface, or a Dialog, Drawer, AlertDialog or Popover: a surface never stands inside a surface.",
|
|
105
|
+
fix: "Give the content to the host's own body, or use a kind of the outer card (`bands`, `list`, `figures`) for what needs its own faces.",
|
|
86
106
|
},
|
|
87
107
|
"no-shell-bottom-tabs": {
|
|
88
108
|
code: "FE_APP_SHELL_BOTTOM_TABS",
|
|
89
109
|
en: "Bottom tab navigation replaces the required mobile sidebar drawer.",
|
|
90
110
|
fix: "Use WorkspaceShell navigationDrawer and Sidebar presentation=\"drawer\".",
|
|
91
111
|
},
|
|
112
|
+
"surface-card-kind": {
|
|
113
|
+
code: "FE_SURFACE_CARD_KIND",
|
|
114
|
+
en: "A `body` SurfaceCard in `<file>` holds a hand-built list, a Divider, a SectionHeader or Heading as a second title.",
|
|
115
|
+
fix: "Rows are `kind=\"list\"`, key figures `kind=\"figures\"`, faces divided by seams `kind=\"bands\"`; the card's title is its `label`.",
|
|
116
|
+
},
|
|
92
117
|
"status-text-uses-soft-foreground": {
|
|
93
118
|
code: "FE_STYLE_TOKEN_ONLY",
|
|
94
119
|
en: "`<file>` colours status content against the owner's pair rule (`<what>`): content on a `bg-<tone>-soft` tint paints with the solid tone (e.g. `bg-success-soft text-success`), or a mark with no tint behind it paints with the soft foreground (e.g. `text-success-soft-foreground` alone).",
|
package/dist/page-header.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The rule that holds the page header law (HFS R323, `FE_PAGE_HEADER_HAND_ROLLED`): a page is headed by Grammar's `Page`,
|
|
4
|
+
* whose `header` is the band. `PageHeader` and `Breadcrumbs` are Page's own parts and are not exported; a page head
|
|
5
|
+
* composed from them by hand has no band, no top inset and no separator, and every page re-decides its spacing.
|
|
6
|
+
*
|
|
7
|
+
* WHAT IT READS. The imports of a file: a `PageHeader` or `Breadcrumbs` imported from `@starci/grammar` (by name, or
|
|
8
|
+
* as a member of a namespace import) is the finding. The law is the export that is gone, so it reads nothing else.
|
|
9
|
+
*/
|
|
10
|
+
/** The Grammar exports that are Page's parts and no longer public. */
|
|
11
|
+
export declare const PAGE_HEAD_PARTS: ReadonlySet<string>;
|
|
12
|
+
/** A page head is Page `header`, never `PageHeader` or `Breadcrumbs` reached for by hand. */
|
|
6
13
|
export declare const noHandRolledPageHeader: Rule.RuleModule;
|
|
7
14
|
/** The rules this law contributes to the plugin. */
|
|
8
15
|
export declare const rules: Record<string, Rule.RuleModule>;
|
package/dist/page-header.js
CHANGED
|
@@ -1,60 +1,30 @@
|
|
|
1
1
|
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs";
|
|
2
|
+
import { refuseGrammarExports } from "./lib/grammar-imports.js";
|
|
2
3
|
import { defineFamilyRules, defineRule } from "./lib/rule-contract.js";
|
|
3
4
|
/**
|
|
4
|
-
* The rule that holds the page header law (HFS R323, `FE_PAGE_HEADER_HAND_ROLLED`): a page is headed by Grammar's
|
|
5
|
-
* `
|
|
6
|
-
* inset and no separator, and every page re-decides its spacing
|
|
5
|
+
* The rule that holds the page header law (HFS R323, `FE_PAGE_HEADER_HAND_ROLLED`): a page is headed by Grammar's `Page`,
|
|
6
|
+
* whose `header` is the band. `PageHeader` and `Breadcrumbs` are Page's own parts and are not exported; a page head
|
|
7
|
+
* composed from them by hand has no band, no top inset and no separator, and every page re-decides its spacing.
|
|
7
8
|
*
|
|
8
|
-
* WHAT IT READS. The
|
|
9
|
-
*
|
|
10
|
-
* is exactly what `PageHeader` composes. A `Breadcrumbs` and a `SectionHeader` in different parents, a `SectionHeader`
|
|
11
|
-
* before the trail, or either alone are not judged: a region's `SectionHeader` under the page head stays legal.
|
|
9
|
+
* WHAT IT READS. The imports of a file: a `PageHeader` or `Breadcrumbs` imported from `@starci/grammar` (by name, or
|
|
10
|
+
* as a member of a namespace import) is the finding. The law is the export that is gone, so it reads nothing else.
|
|
12
11
|
*/
|
|
13
|
-
/** The
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
return null;
|
|
17
|
-
const name = child.openingElement.name;
|
|
18
|
-
if (name.type === "JSXIdentifier")
|
|
19
|
-
return name.name;
|
|
20
|
-
if (name.type === "JSXMemberExpression")
|
|
21
|
-
return name.property.name;
|
|
22
|
-
return null;
|
|
23
|
-
};
|
|
24
|
-
/** The `SectionHeader` that follows a `Breadcrumbs` among the element children, or null. */
|
|
25
|
-
export const handRolledHead = (children) => {
|
|
26
|
-
let trail = false;
|
|
27
|
-
for (const child of children) {
|
|
28
|
-
const name = elementName(child);
|
|
29
|
-
if (name === "Breadcrumbs")
|
|
30
|
-
trail = true;
|
|
31
|
-
if (name === "SectionHeader" && trail && child.type === "JSXElement")
|
|
32
|
-
return child;
|
|
33
|
-
}
|
|
34
|
-
return null;
|
|
35
|
-
};
|
|
36
|
-
/** A page head is Grammar's `PageHeader`, never a `Breadcrumbs` and a `SectionHeader` composed by hand. */
|
|
12
|
+
/** The Grammar exports that are Page's parts and no longer public. */
|
|
13
|
+
export const PAGE_HEAD_PARTS = new Set(["PageHeader", "Breadcrumbs"]);
|
|
14
|
+
/** A page head is Page `header`, never `PageHeader` or `Breadcrumbs` reached for by hand. */
|
|
37
15
|
export const noHandRolledPageHeader = defineRule({
|
|
38
16
|
meta: {
|
|
39
17
|
type: "problem",
|
|
40
|
-
docs: { description: "R323: a page head is
|
|
18
|
+
docs: { description: "R323: a page head is Page header (title, breadcrumbs, slots), never PageHeader or Breadcrumbs imported by hand." },
|
|
41
19
|
schema: [],
|
|
42
20
|
messages: {
|
|
43
|
-
handRolled: "
|
|
21
|
+
handRolled: "`{{name}}` is a part of `Page`, not an export to compose: a head built from it has no band, no top inset and no separator, and each page re-decides its spacing. Pass the head as `header` of `Page`: `{ breadcrumbs, title, description, meta, status, mark, actions, tabs }`.",
|
|
44
22
|
},
|
|
45
23
|
},
|
|
46
24
|
create(context) {
|
|
47
25
|
if (!isProductSource(context))
|
|
48
26
|
return {};
|
|
49
|
-
|
|
50
|
-
const header = handRolledHead(children);
|
|
51
|
-
if (header !== null)
|
|
52
|
-
context.report({ node: header, messageId: "handRolled" });
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
JSXElement(element) { judge(element.children); },
|
|
56
|
-
JSXFragment(fragment) { judge(fragment.children); },
|
|
57
|
-
};
|
|
27
|
+
return refuseGrammarExports(PAGE_HEAD_PARTS, ({ node, name }) => { context.report({ node, messageId: "handRolled", data: { name } }); });
|
|
58
28
|
},
|
|
59
29
|
});
|
|
60
30
|
/** The rules this law contributes to the plugin. */
|
package/dist/page.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Rule } from "eslint";
|
|
2
2
|
import type { TSESTree } from "@typescript-eslint/types";
|
|
3
|
-
/** The `Tabs` element drawn as page tabs
|
|
3
|
+
/** The `Tabs` element drawn as page tabs at the top of a `Page` body, outside the header band, or null. */
|
|
4
4
|
export declare const tabsOutsideHeader: (parent: TSESTree.JSXElement | TSESTree.JSXFragment) => TSESTree.JSXElement | null;
|
|
5
|
-
/** Page tabs are the header's `tabs`, never a `Tabs` at the top of the body
|
|
5
|
+
/** Page tabs are the header's `tabs`, never a `Tabs` at the top of the body. */
|
|
6
6
|
export declare const pageTabsInHeader: Rule.RuleModule;
|
|
7
7
|
/**
|
|
8
8
|
* A route draws exactly one `Page` and nothing beside it: the page owner draws it, its pure half does, or the one connected
|
|
9
|
-
* block it renders as its root does. `PageHeader` and `PageContainer` are Page's own parts.
|
|
9
|
+
* block it renders as its root does. `PageHeader` and `PageContainer` are Page's own parts, refused where they are imported.
|
|
10
10
|
*/
|
|
11
11
|
export declare const routePageIsOnePage: Rule.RuleModule;
|
|
12
12
|
/** The rules these laws contribute to the plugin. */
|