@starci/eslint-grammar-core 0.13.0 → 0.15.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 +13 -0
- package/README.md +4 -1
- package/dist/app-shell.d.ts +15 -0
- package/dist/app-shell.js +224 -0
- package/dist/chip-label.d.ts +14 -0
- package/dist/chip-label.js +117 -0
- package/dist/drawing.d.ts +8 -0
- package/dist/drawing.js +59 -0
- package/dist/grammar-boundary.d.ts +12 -0
- package/dist/grammar-boundary.js +88 -0
- package/dist/icon.d.ts +27 -0
- package/dist/icon.js +293 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +73 -0
- package/dist/lib/app-shell-cluster.d.ts +6 -0
- package/dist/lib/app-shell-cluster.js +75 -0
- package/dist/lib/app-shell-create.d.ts +5 -0
- package/dist/lib/app-shell-create.js +37 -0
- package/dist/lib/app-shell-owner-source.d.ts +11 -0
- package/dist/lib/app-shell-owner-source.js +159 -0
- package/dist/lib/app-shell-owner.d.ts +7 -0
- package/dist/lib/app-shell-owner.js +97 -0
- package/dist/lib/app-shell-scope.d.ts +13 -0
- package/dist/lib/app-shell-scope.js +93 -0
- package/dist/lib/app-shell-visible.d.ts +13 -0
- package/dist/lib/app-shell-visible.js +117 -0
- package/dist/lib/app-shell.d.ts +27 -0
- package/dist/lib/app-shell.js +185 -0
- package/dist/lib/rule-contract.d.ts +12 -0
- package/dist/lib/rule-contract.js +23 -0
- package/dist/lib/status-tones.generated.d.ts +2 -0
- package/dist/lib/status-tones.generated.js +8 -0
- package/dist/lib/types.d.ts +113 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/why.d.ts +8 -0
- package/dist/lib/why.js +42 -0
- package/dist/menu-entries.d.ts +27 -0
- package/dist/menu-entries.js +142 -0
- package/dist/status-colors.d.ts +13 -0
- package/dist/status-colors.js +143 -0
- package/dist/tokens.d.ts +11 -0
- package/dist/tokens.js +166 -0
- package/dist/typography.d.ts +13 -0
- package/dist/typography.js +72 -0
- package/dist/vendor-boundary.d.ts +5 -0
- package/dist/vendor-boundary.js +25 -0
- package/docs/chip-label.md +30 -0
- package/docs/grammar-boundary.md +1 -1
- package/docs/status-colors.md +2 -2
- package/package.json +18 -15
- package/runtime/knowledge/hfs/canon-pins.yaml +22 -14
- package/runtime/knowledge/hfs/rules.yaml +23 -0
- package/app-shell.mjs +0 -208
- package/drawing.mjs +0 -60
- package/grammar-boundary.mjs +0 -94
- package/icon.mjs +0 -313
- package/index.d.ts +0 -28
- package/index.mjs +0 -78
- package/lib/app-shell-cluster.mjs +0 -66
- package/lib/app-shell-create.mjs +0 -33
- package/lib/app-shell-owner-source.mjs +0 -124
- package/lib/app-shell-owner.mjs +0 -83
- package/lib/app-shell-scope.mjs +0 -79
- package/lib/app-shell-visible.mjs +0 -92
- package/lib/app-shell.mjs +0 -148
- package/lib/rule-contract.mjs +0 -11
- package/lib/status-tones.generated.mjs +0 -9
- package/lib/why.mjs +0 -38
- package/menu-entries.mjs +0 -146
- package/status-colors.mjs +0 -140
- package/tokens.mjs +0 -164
- package/typography.mjs +0 -81
- package/vendor-boundary.mjs +0 -29
|
@@ -30,61 +30,61 @@ pins:
|
|
|
30
30
|
source: packages/event-stream/package.json
|
|
31
31
|
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.'
|
|
32
32
|
'@starci/grammar':
|
|
33
|
-
version: 0.
|
|
33
|
+
version: 0.15.0
|
|
34
34
|
group: starci
|
|
35
35
|
install: registry
|
|
36
36
|
side: fe
|
|
37
37
|
source: packages/grammar/package.json
|
|
38
38
|
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.'
|
|
39
39
|
'@starci/eslint-canon-be':
|
|
40
|
-
version: 3.
|
|
40
|
+
version: 3.6.0
|
|
41
41
|
group: starci
|
|
42
42
|
install: registry
|
|
43
43
|
side: be
|
|
44
44
|
source: packages/eslint-canon-be/package.json
|
|
45
45
|
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.'
|
|
46
46
|
'@starci/eslint-canon-fe':
|
|
47
|
-
version: 9.
|
|
47
|
+
version: 9.4.0
|
|
48
48
|
group: starci
|
|
49
49
|
install: registry
|
|
50
50
|
side: fe
|
|
51
51
|
source: packages/eslint-canon-fe/package.json
|
|
52
52
|
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.'
|
|
53
53
|
'@starci/eslint-grammar-core':
|
|
54
|
-
version: 0.
|
|
54
|
+
version: 0.15.0
|
|
55
55
|
group: starci
|
|
56
56
|
install: registry
|
|
57
57
|
side: fe
|
|
58
58
|
source: packages/eslint-grammar-core/package.json
|
|
59
59
|
why: 'the StarCi Grammar component API lint, versioned with @starci/grammar; front ends compose this family package with the universal FE canon.'
|
|
60
60
|
'@starci/eslint-grammar-offset-pop':
|
|
61
|
-
version: 0.
|
|
61
|
+
version: 0.15.0
|
|
62
62
|
group: starci
|
|
63
63
|
install: registry
|
|
64
64
|
side: fe
|
|
65
65
|
source: packages/eslint-grammar-offset-pop/package.json
|
|
66
66
|
why: 'the Offset Pop Grammar component API lint, versioned with @starci/grammar; its shared component contract comes from the StarCi family lint without copying rules.'
|
|
67
67
|
'@starci/stylelint-canon':
|
|
68
|
-
version: 2.1
|
|
68
|
+
version: 2.2.1
|
|
69
69
|
group: starci
|
|
70
70
|
install: registry
|
|
71
71
|
side: fe
|
|
72
72
|
source: packages/stylelint-canon/package.json
|
|
73
73
|
why: 'the front-end stylelint canon: no-class-selector refuses a compound class selector (`div.card`); the brand layer accepts `--font-sans` and `--font-mono`; status-contrast measures the HeroUI soft pairs per theme; brand-layer-shape reads the shared :root,.light,.dark block and the info soft pair; appTokens come from loadAppTokens(import.meta.url) for the managed one-line stylelint.config.mjs.'
|
|
74
74
|
'@starci/tsconfig':
|
|
75
|
-
version: 2.0
|
|
75
|
+
version: 2.1.0
|
|
76
76
|
group: starci
|
|
77
77
|
install: registry
|
|
78
78
|
side: both
|
|
79
79
|
source: packages/tsconfig/package.json
|
|
80
80
|
'@starci/prettier-config':
|
|
81
|
-
version: 1.0
|
|
81
|
+
version: 1.1.0
|
|
82
82
|
group: starci
|
|
83
83
|
install: registry
|
|
84
84
|
side: both
|
|
85
85
|
source: packages/prettier-config/package.json
|
|
86
86
|
'@starci/jest-preset':
|
|
87
|
-
version: 2.
|
|
87
|
+
version: 2.4.1
|
|
88
88
|
group: starci
|
|
89
89
|
install: registry
|
|
90
90
|
side: be
|
|
@@ -97,19 +97,27 @@ pins:
|
|
|
97
97
|
side: be
|
|
98
98
|
source: packages/test-world/package.json
|
|
99
99
|
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. 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.'
|
|
100
|
-
'@starci/
|
|
101
|
-
version:
|
|
100
|
+
'@starci/ai-router':
|
|
101
|
+
version: 0.2.1
|
|
102
|
+
group: starci
|
|
103
|
+
install: registry
|
|
104
|
+
side: be
|
|
105
|
+
source: packages/ai-router/package.json
|
|
106
|
+
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.'
|
|
107
|
+
'starci-harness':
|
|
108
|
+
version: 1.1.0-alpha.1
|
|
102
109
|
group: starci
|
|
103
110
|
install: registry
|
|
104
111
|
side: both
|
|
105
|
-
|
|
112
|
+
source: cli/package.json
|
|
113
|
+
why: 'the one StarCi command line (bins starci and starci-harness): a product repository installs it for starci app, which it runs in-process through its exact @starci/hfs dependency, and its codegen loads starci-harness/input-bounds.'
|
|
106
114
|
'@starci/hfs':
|
|
107
|
-
version: 4.
|
|
115
|
+
version: 4.9.1
|
|
108
116
|
group: starci
|
|
109
117
|
install: registry
|
|
110
118
|
side: both
|
|
111
119
|
source: packages/hfs/package.json
|
|
112
|
-
why: 'the
|
|
120
|
+
why: 'the app implementation starci-harness runs for starci app; it carries the generated runtime slice read by starci app commands.'
|
|
113
121
|
# --- tooling
|
|
114
122
|
typescript:
|
|
115
123
|
version: 5.9.3
|
|
@@ -5664,3 +5664,26 @@ rules:
|
|
|
5664
5664
|
source: owner
|
|
5665
5665
|
quote: "The size of the buttons and controls is uneven; the teacher thinks height = 40px (h-10) should be fixed for every button, switch, input, tabs and so on, what do you think? (translated from Vietnamese)"
|
|
5666
5666
|
ruling: "One 40px control height is the default of every standalone control (owner ruling control-height-40): Grammar draws it, an app omits size, sm is for a nested item or dense toolbar row, lg only for a landing hero call to action, and controls of one row share one size."
|
|
5667
|
+
- id: R322
|
|
5668
|
+
code: "FE_CHIP_LABEL_CASE"
|
|
5669
|
+
law: "The label of a status chip (a StatusDot with text, a Badge) starts with an uppercase letter, so every chip of an app reads in one vocabulary."
|
|
5670
|
+
kinds: [lint, codemod]
|
|
5671
|
+
gates: [pre-commit, settle, land, ci]
|
|
5672
|
+
failureCodes: ["FE_CHIP_LABEL_CASE"]
|
|
5673
|
+
enforcers:
|
|
5674
|
+
- {kind: eslint-grammar-core, id: chip-label-starts-uppercase}
|
|
5675
|
+
editions: [lite, full]
|
|
5676
|
+
docs: [knowledge/patterns/fe/index.yaml#FE-RULE-OWNERSHIP]
|
|
5677
|
+
templateNa: "A template states no chip label; the words are the app's."
|
|
5678
|
+
proves:
|
|
5679
|
+
- packages/eslint/grammar-core/chip-label.spec.mjs
|
|
5680
|
+
exemplifiedBy:
|
|
5681
|
+
- {path: packages/eslint/grammar-core/chip-label.spec.mjs, editions: [lite, full], codes: [FE_CHIP_LABEL_CASE]}
|
|
5682
|
+
witness:
|
|
5683
|
+
- {path: packages/eslint/grammar-core/chip-label.spec.mjs, editions: [lite, full], codes: [FE_CHIP_LABEL_CASE]}
|
|
5684
|
+
cases:
|
|
5685
|
+
- id: case-1
|
|
5686
|
+
date: "2026-10-27"
|
|
5687
|
+
source: owner
|
|
5688
|
+
quote: "A chip label starts uppercase."
|
|
5689
|
+
ruling: "The label of a status chip starts with an uppercase letter (owner ruling chip-label-uppercase); StatusDot capitalises a text label it renders, and the lint refuses a lowercase literal label at its source."
|
package/app-shell.mjs
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { defineFamilyRules } from "./lib/rule-contract.mjs"
|
|
2
|
-
/** FE-APP-SHELL-1..5: static app-frame and visible navbar composition from the UI canon. */
|
|
3
|
-
import { isProductSource } from "@starci/eslint-canon-fe/lib/scope.mjs"
|
|
4
|
-
import { grammarName, isBarControl, propOf, resolveLocal, semanticText, textProp } from "./lib/app-shell.mjs"
|
|
5
|
-
import { appBarOpenings, isAppBar, isAppShell, isNavigationDrawer, ownsAppFrame } from "./lib/app-shell-scope.mjs"
|
|
6
|
-
import { visitVisible } from "./lib/app-shell-visible.mjs"
|
|
7
|
-
import { clusterAlternatives } from "./lib/app-shell-cluster.mjs"
|
|
8
|
-
import { isCreateAction, menuHasCreate } from "./lib/app-shell-create.mjs"
|
|
9
|
-
import { provesImportedBar, provesNavigationOpener } from "./lib/app-shell-owner.mjs"
|
|
10
|
-
import { variableOf } from "@starci/eslint-canon-fe/lib/bindings.mjs"
|
|
11
|
-
import { walk } from "@starci/eslint-canon-fe/lib/ast.mjs"
|
|
12
|
-
|
|
13
|
-
const CANON = "knowledge/ui/composition/app-shell.yaml"
|
|
14
|
-
const BOTTOM_TABS = /^(?:BottomNav|BottomNavigation|BottomTabBar|MobileBottomNav|MobileTabBar)$/
|
|
15
|
-
const EXPECTED_CLUSTER = ["language:IconButton", "theme:Switch", "notifications:IconButton", "account:AvatarButton"]
|
|
16
|
-
|
|
17
|
-
const meta = (code, description, messages) => ({
|
|
18
|
-
type: "problem",
|
|
19
|
-
docs: { description: `${code}: ${description}`, url: CANON },
|
|
20
|
-
schema: [],
|
|
21
|
-
messages,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
/** Whether a slot is present; unknown spreads do not prove either presence or absence. */
|
|
25
|
-
const slotPresence = (context, opening, name) => {
|
|
26
|
-
const prop = propOf(context, opening, name)
|
|
27
|
-
if (!prop.known) return null
|
|
28
|
-
const value = resolveLocal(context, prop.value)
|
|
29
|
-
if (value === null || value.type === "Literal" && (value.value == null || value.value === false)) return false
|
|
30
|
-
return !(value.type === "Identifier" && value.name === "undefined" && !variableOf(context, value)?.defs.length)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/** Resolve constants and require every possible conditional value to prove the slot contract. */
|
|
34
|
-
const everyValue = (context, expression, proves, seen = new Set()) => {
|
|
35
|
-
const node = resolveLocal(context, expression)
|
|
36
|
-
if (!node || seen.has(node)) return false
|
|
37
|
-
if (node.type !== "ConditionalExpression") return proves(node)
|
|
38
|
-
const visited = new Set(seen).add(node)
|
|
39
|
-
return [node.consequent, node.alternate].every((branch) => everyValue(context, branch, proves, visited))
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const hasMobileNavigation = (context, opening) => {
|
|
43
|
-
const drawerProp = propOf(context, opening, "navigationDrawer")
|
|
44
|
-
const drawer = drawerProp.known && everyValue(context, drawerProp.value, (value) => value.type === "ObjectExpression")
|
|
45
|
-
const opener = drawer || provesNavigationOpener(context, propOf(context, opening, "compactHeader").value)
|
|
46
|
-
const visibility = propOf(context, opening, "navigationVisibility")
|
|
47
|
-
const defaultsWide = opener && visibility.known && slotPresence(context, opening, "navigationVisibility") === false
|
|
48
|
-
if (!defaultsWide && (!visibility.known || !everyValue(context, visibility.value, (value) => value.type === "Literal" && value.value === "wide"))) return false
|
|
49
|
-
return opener
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/** App-owned tab names count only in a frame owner or a shell's rendered slots. */
|
|
53
|
-
const visibleFromShell = (context, target) => {
|
|
54
|
-
let visible = false
|
|
55
|
-
walk(context.sourceCode, context.sourceCode.ast, (node) => {
|
|
56
|
-
if (node.type !== "JSXOpeningElement" || !isAppShell(context, node)) return
|
|
57
|
-
const inspect = (opening) => { if (opening === target) visible = true }
|
|
58
|
-
for (const slot of ["header", "compactHeader", "navigation", "primary", "floatingLayer", "compactNavigation"]) visitVisible(context, propOf(context, node, slot).value, inspect)
|
|
59
|
-
for (const child of node.parent.children) visitVisible(context, child, inspect)
|
|
60
|
-
})
|
|
61
|
-
return visible
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** The app frame is the fixed-viewport Grammar shell; hand-written frame landmarks are rejected. */
|
|
65
|
-
export const appShellFrame = {
|
|
66
|
-
meta: meta("FE_APP_SHELL_FRAME", "FE-APP-SHELL-1 uses WorkspaceShell viewport=fixed.", {
|
|
67
|
-
frame: "FE_APP_SHELL_FRAME: compose the app frame with WorkspaceShell viewport=\"fixed\"; navigation must resolve to navigationVisibility=\"wide\" and have navigationDrawer or a compactHeader with a left Drawer containing Sidebar presentation=\"drawer\". Grammar owns its header, navigation and independent scroll regions.",
|
|
68
|
-
}),
|
|
69
|
-
create(context) {
|
|
70
|
-
if (!isProductSource(context)) return {}
|
|
71
|
-
return { JSXOpeningElement(node) {
|
|
72
|
-
const shell = isAppShell(context, node)
|
|
73
|
-
const wrongViewport = shell && textProp(context, node, "viewport") !== "fixed"
|
|
74
|
-
const missingVisibility = shell && slotPresence(context, node, "navigation") !== false && !hasMobileNavigation(context, node)
|
|
75
|
-
const handFrame = ownsAppFrame(context, node) && (node.name.type === "JSXIdentifier" && ["header", "nav", "main"].includes(node.name.name) || isAppBar(context, node) && !appBarOpenings(context).has(node))
|
|
76
|
-
if (wrongViewport || missingVisibility || handFrame) {
|
|
77
|
-
context.report({ node, messageId: "frame" })
|
|
78
|
-
}
|
|
79
|
-
} }
|
|
80
|
-
},
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Bottom navigation is not an alternative compact app-shell frame. */
|
|
84
|
-
export const noShellBottomTabs = {
|
|
85
|
-
meta: meta("FE_APP_SHELL_BOTTOM_TABS", "FE-APP-SHELL-4 keeps mobile navigation in the sidebar drawer.", {
|
|
86
|
-
bottom: "FE_APP_SHELL_BOTTOM_TABS: the app shell uses a mobile subnav opener and Sidebar drawer. Remove bottom tab navigation and WorkspaceShell compactNavigation.",
|
|
87
|
-
}),
|
|
88
|
-
create(context) {
|
|
89
|
-
if (!isProductSource(context)) return {}
|
|
90
|
-
return { JSXOpeningElement(node) {
|
|
91
|
-
const name = grammarName(context, node)
|
|
92
|
-
const appTab = name === null && node.name.type === "JSXIdentifier" && BOTTOM_TABS.test(node.name.name) && (ownsAppFrame(context, node) || visibleFromShell(context, node))
|
|
93
|
-
const compact = name === "WorkspaceShell" && propOf(context, node, "compactNavigation")
|
|
94
|
-
const value = compact && resolveLocal(context, compact.value)
|
|
95
|
-
const absent = value?.type === "Identifier" && value.name === "undefined" && !variableOf(context, value)?.defs.length
|
|
96
|
-
if (BOTTOM_TABS.test(name ?? "") || appTab || compact && !absent && (!compact.known || compact.value !== null || compact.present)) context.report({ node, messageId: "bottom" })
|
|
97
|
-
} }
|
|
98
|
-
},
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const visitBar = (context, node, visit) => {
|
|
102
|
-
const name = grammarName(context, node)
|
|
103
|
-
if (name === "WorkspaceShell" && isAppShell(context, node)) {
|
|
104
|
-
for (const slot of ["header", "compactHeader"]) visitVisible(context, propOf(context, node, slot).value, visit)
|
|
105
|
-
} else if (isAppBar(context, node)) {
|
|
106
|
-
visitVisible(context, node.parent, visit)
|
|
107
|
-
} else if (isNavigationDrawer(context, node)) {
|
|
108
|
-
visitVisible(context, propOf(context, node, "trigger").value, visit)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const delegatesImportedBar = (context, expression) => {
|
|
113
|
-
let imported = false
|
|
114
|
-
let controls = false
|
|
115
|
-
let unknown = false
|
|
116
|
-
visitVisible(context, expression, (opening, name) => {
|
|
117
|
-
if (isBarControl(context, opening, name)) controls = true
|
|
118
|
-
if (name !== null) return
|
|
119
|
-
const proof = provesImportedBar(context, opening)
|
|
120
|
-
if (proof === true) imported = true
|
|
121
|
-
if (proof === false) unknown = true
|
|
122
|
-
})
|
|
123
|
-
return imported && !controls && !unknown
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Every visible control in a navbar band uses the shared control size. */
|
|
127
|
-
export const navbarControlSize = {
|
|
128
|
-
meta: meta("FE_NAVBAR_CONTROL_SIZE", "FE-APP-SHELL-2 requires size=control on bar controls.", {
|
|
129
|
-
control: "FE_NAVBAR_CONTROL_SIZE: {{name}} in the navbar band needs size=\"control\" so every bar control shares Grammar's control height.",
|
|
130
|
-
}),
|
|
131
|
-
create(context) {
|
|
132
|
-
if (!isProductSource(context)) return {}
|
|
133
|
-
const reported = new Set()
|
|
134
|
-
return { JSXOpeningElement(node) {
|
|
135
|
-
visitBar(context, node, (control, name) => {
|
|
136
|
-
if (!isBarControl(context, control, name) || textProp(context, control, "size") === "control" || reported.has(control)) return
|
|
137
|
-
reported.add(control)
|
|
138
|
-
context.report({ node: control, messageId: "control", data: { name } })
|
|
139
|
-
})
|
|
140
|
-
} }
|
|
141
|
-
},
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/** The right cluster is checked at the bar's actions composition, in visual source order. */
|
|
145
|
-
export const navbarCluster = {
|
|
146
|
-
meta: meta("FE_NAVBAR_CLUSTER", "FE-APP-SHELL-3 fixes navbar action kinds and order.", {
|
|
147
|
-
cluster: "FE_NAVBAR_CLUSTER: navbar actions must be a tertiary Language IconButton in DropdownMenu, theme Switch, notification IconButton in Popover, account AvatarButton in DropdownMenu, in that order. Mobile retains notifications then account and moves language/theme into the drawer.",
|
|
148
|
-
}),
|
|
149
|
-
create(context) {
|
|
150
|
-
if (!isProductSource(context)) return {}
|
|
151
|
-
return { JSXOpeningElement(node) {
|
|
152
|
-
const name = grammarName(context, node)
|
|
153
|
-
if (!isAppShell(context, node) && !isAppBar(context, node)) return
|
|
154
|
-
const shellHeader = name === "WorkspaceShell"
|
|
155
|
-
const actions = propOf(context, node, shellHeader ? "header" : "actions")
|
|
156
|
-
const { alternatives, ownsBar } = clusterAlternatives(context, actions.value, shellHeader)
|
|
157
|
-
if (ownsBar) return
|
|
158
|
-
if (shellHeader && delegatesImportedBar(context, actions.value)) return
|
|
159
|
-
const desktop = EXPECTED_CLUSTER.join("|")
|
|
160
|
-
const mobile = EXPECTED_CLUSTER.slice(2).join("|")
|
|
161
|
-
const sequences = alternatives.map((sequence) => sequence.join("|"))
|
|
162
|
-
if (!sequences.includes(desktop) || sequences.some((sequence) => sequence !== desktop && sequence !== mobile)) context.report({ node, messageId: "cluster" })
|
|
163
|
-
} }
|
|
164
|
-
},
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** Creation belongs to its page, never to the global app bar. */
|
|
168
|
-
export const noNavbarCreate = {
|
|
169
|
-
meta: meta("FE_NAVBAR_CREATE", "FE-APP-SHELL-5 keeps create actions on pages.", {
|
|
170
|
-
create: "FE_NAVBAR_CREATE: move this create action from the navbar to its page.",
|
|
171
|
-
}),
|
|
172
|
-
create(context) {
|
|
173
|
-
if (!isProductSource(context)) return {}
|
|
174
|
-
const reported = new Set()
|
|
175
|
-
const report = (node) => {
|
|
176
|
-
if (reported.has(node)) return
|
|
177
|
-
reported.add(node)
|
|
178
|
-
context.report({ node, messageId: "create" })
|
|
179
|
-
}
|
|
180
|
-
const inspect = (control, name) => {
|
|
181
|
-
if (name === "DropdownMenu" || name === "Popover") {
|
|
182
|
-
if (["entries", "items", "sections"].some((slot) => menuHasCreate(context, propOf(context, control, slot).value))) report(control)
|
|
183
|
-
visitVisible(context, propOf(context, control, "content").value, inspect)
|
|
184
|
-
for (const child of control.parent.children) visitVisible(context, child, inspect)
|
|
185
|
-
}
|
|
186
|
-
if (!isBarControl(context, control, name) || reported.has(control)) return
|
|
187
|
-
const text = `${semanticText(context, control)} ${control.parent.children.map((child) => context.sourceCode.getText(child)).join(" ")}`
|
|
188
|
-
if (isCreateAction(text)) report(control)
|
|
189
|
-
}
|
|
190
|
-
return { JSXOpeningElement(node) {
|
|
191
|
-
visitBar(context, node, inspect)
|
|
192
|
-
} }
|
|
193
|
-
},
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/** Every app-shell enforcer is gathered into the ordinary FE lint and gate path. */
|
|
197
|
-
export const rules = {
|
|
198
|
-
"app-shell-frame": appShellFrame,
|
|
199
|
-
"no-shell-bottom-tabs": noShellBottomTabs,
|
|
200
|
-
"navbar-control-size": navbarControlSize,
|
|
201
|
-
"navbar-cluster": navbarCluster,
|
|
202
|
-
"no-navbar-create": noNavbarCreate,
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
defineFamilyRules(rules, "knowledge/ui/composition/app-shell.yaml")
|
|
206
|
-
|
|
207
|
-
/** Every rule is mandatory. */
|
|
208
|
-
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]))
|
package/drawing.mjs
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/** StarCi per-slot status composition, governed by FE-RULE-OWNERSHIP. */
|
|
2
|
-
import { pureHalf } from "@starci/eslint-canon-fe/lib/drawing-scope.mjs"
|
|
3
|
-
import { defineFamilyRules } from "./lib/rule-contract.mjs"
|
|
4
|
-
|
|
5
|
-
// -- DRAWING-4 ----------------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
/** Flags that are a slot's data status. */
|
|
8
|
-
const STATUS_FLAG = /^(?:isLoading|isError|isForbidden|isPending|isValidating|isEmpty)$/
|
|
9
|
-
|
|
10
|
-
/** The name a test expression reads, if it is a status flag. */
|
|
11
|
-
const statusFlagOf = (node) => {
|
|
12
|
-
if (!node) return null
|
|
13
|
-
if (node.type === "UnaryExpression") return statusFlagOf(node.argument)
|
|
14
|
-
if (node.type === "ChainExpression") return statusFlagOf(node.expression)
|
|
15
|
-
if (node.type === "Identifier" && STATUS_FLAG.test(node.name)) return node.name
|
|
16
|
-
if (node.type === "MemberExpression" && node.property?.type === "Identifier" && STATUS_FLAG.test(node.property.name)) {
|
|
17
|
-
return node.property.name
|
|
18
|
-
}
|
|
19
|
-
if (node.type === "LogicalExpression" || node.type === "BinaryExpression") return statusFlagOf(node.left) ?? statusFlagOf(node.right)
|
|
20
|
-
return null
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** A block's pure half never branches on a data status itself. */
|
|
24
|
-
export const slotStatusThroughSlotView = {
|
|
25
|
-
meta: {
|
|
26
|
-
type: "problem",
|
|
27
|
-
docs: { description: "A block's pure half renders data status through `SlotView`, never its own branch." },
|
|
28
|
-
schema: [],
|
|
29
|
-
messages: {
|
|
30
|
-
branch:
|
|
31
|
-
"This branches on `{{flag}}` by hand. Every slot renders its status through `SlotView`, the one recipe: a second branch drifts from it and becomes one more variant somebody draws.",
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
create(context) {
|
|
35
|
-
if (pureHalf(context) !== "blocks") return {}
|
|
36
|
-
const check = (node, test) => {
|
|
37
|
-
const flag = statusFlagOf(test)
|
|
38
|
-
if (flag) context.report({ node, messageId: "branch", data: { flag } })
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
ConditionalExpression(node) {
|
|
42
|
-
check(node, node.test)
|
|
43
|
-
},
|
|
44
|
-
IfStatement(node) {
|
|
45
|
-
check(node, node.test)
|
|
46
|
-
},
|
|
47
|
-
LogicalExpression(node) {
|
|
48
|
-
if (node.operator === "&&" && node.parent?.type === "JSXExpressionContainer") check(node, node.left)
|
|
49
|
-
},
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** The family status recipe retains its published rule ID. */
|
|
55
|
-
export const rules = { "slot-status-through-slotview": slotStatusThroughSlotView }
|
|
56
|
-
|
|
57
|
-
defineFamilyRules(rules, "knowledge/grammars/core/playbook.yaml#state-recipes")
|
|
58
|
-
|
|
59
|
-
/** Every family composition rule is mandatory. */
|
|
60
|
-
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]))
|
package/grammar-boundary.mjs
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { defineFamilyRules } from "./lib/rule-contract.mjs"
|
|
2
|
-
/**
|
|
3
|
-
* The boundary between product code and `@starci/grammar`.
|
|
4
|
-
*
|
|
5
|
-
* Grammar is a business-neutral HeroUI-backed component package. Product code composes its components with ordinary React
|
|
6
|
-
* children and typed props. A page's structure and text are made of those components, not of raw HTML: a raw `<section>`, `<p>`
|
|
7
|
-
* or `<ul>` carries no density, no focus or landmark contract and no dark value from the design system, and the class names
|
|
8
|
-
* written by hand to compensate are where a second visual language starts.
|
|
9
|
-
*
|
|
10
|
-
* Which tags are refused is decided by the package: a tag is in the list only when `@starci/grammar` exports a component that
|
|
11
|
-
* renders it (`GRAMMAR_OWNERS` below, each entry verified against the package source by the twin test). A tag the grammar has no
|
|
12
|
-
* component for (`div`, `br`, `aside`, `article`) is not refused: there is nothing to compose instead, and refusing it would
|
|
13
|
-
* demand a workaround. When the grammar gains a component for one, the tag joins the list.
|
|
14
|
-
*
|
|
15
|
-
* WHERE IT APPLIES. App source that composes the grammar (slots `fe.feature`, `fe.components`, `fe.route`, `fe.hooks`) and any
|
|
16
|
-
* workspace package except the `<family>-ui` package (`fe.package.ui`), whose components are the renderers and are the one place
|
|
17
|
-
* a raw tag belongs. Spec files render raw HTML as a harness and are not judged. A file no slot owns is not judged either: the
|
|
18
|
-
* rule refuses to guess a scope.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
import { hfsOf } from "@starci/eslint-canon-fe/lib/hfs.mjs"
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* The intrinsic elements of page structure and text, each with the grammar components that render it.
|
|
25
|
-
* Read against packages/grammar/src (`export const <Component>`); `grammar-boundary.spec.mjs` fails when one is not exported.
|
|
26
|
-
*/
|
|
27
|
-
export const GRAMMAR_OWNERS = Object.freeze({
|
|
28
|
-
h1: "Heading", h2: "Heading", h3: "Heading", h4: "Heading", h5: "Heading", h6: "Heading",
|
|
29
|
-
p: "Text", span: "Text",
|
|
30
|
-
hr: "Divider",
|
|
31
|
-
label: "Label",
|
|
32
|
-
form: "Form",
|
|
33
|
-
fieldset: "Fieldset",
|
|
34
|
-
dl: "DescriptionList", dt: "DescriptionList", dd: "DescriptionList",
|
|
35
|
-
table: "DataTable", thead: "DataTable", tbody: "DataTable", tr: "DataTable", td: "DataTable", th: "DataTable",
|
|
36
|
-
ul: "List, SurfaceListCard or StaticStateRow", ol: "List, SurfaceListCard or StaticStateRow", li: "ListItem, SurfaceListCard or StaticStateRow",
|
|
37
|
-
header: "SectionHeader or TopBar",
|
|
38
|
-
footer: "Footer",
|
|
39
|
-
nav: "NavLandmark, Subnav, Breadcrumbs or NavigationFeatureNav",
|
|
40
|
-
section: "Region or SurfaceCard",
|
|
41
|
-
main: "WorkspaceShell",
|
|
42
|
-
figure: "MediaFrame", figcaption: "MediaFrame",
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
/** The slots of app source that compose the grammar: features, components, routes and hooks. */
|
|
46
|
-
const APP_SLOTS = new Set(["fe.feature", "fe.components", "fe.route", "fe.hooks"])
|
|
47
|
-
|
|
48
|
-
/** The slot of the package whose leaves ARE the renderers: the only place raw structural tags belong. */
|
|
49
|
-
const RENDERER_SLOT = "fe.package.ui"
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* True for a file that composes the grammar: app source (`fe.feature`, `fe.components`, `fe.route`, `fe.hooks`) and any
|
|
53
|
-
* workspace package but the `<family>-ui` package, whose components are the renderers.
|
|
54
|
-
*/
|
|
55
|
-
const composesGrammar = (context, file) => {
|
|
56
|
-
const hfs = hfsOf(context)
|
|
57
|
-
const slot = hfs.slotOf(file)
|
|
58
|
-
if (slot === null || slot === RENDERER_SLOT) return false
|
|
59
|
-
return APP_SLOTS.has(slot) || hfs.tierOf(file) === "package"
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/** No raw structural or text element in app source or in a package that composes the grammar. */
|
|
63
|
-
export const noRawStructuralElement = {
|
|
64
|
-
meta: {
|
|
65
|
-
type: "problem",
|
|
66
|
-
docs: { description: "Page structure and text are grammar components, not raw `div`-family HTML; only `fe.package.ui` renderers draw raw tags." },
|
|
67
|
-
schema: [],
|
|
68
|
-
messages: {
|
|
69
|
-
raw:
|
|
70
|
-
"A raw `<{{tag}}>`. Page structure and text are composed from the grammar (`@starci/grammar`, or the repository's `<family>-ui` package): use {{owner}}. A raw tag brings none of the design system's density, landmark and state contract, and the class names written to make up for it start a second visual language. If the grammar cannot express this structure, add the component to the grammar or the ui package rather than drawing it here.",
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
create(context) {
|
|
74
|
-
const file = context.filename || context.getFilename()
|
|
75
|
-
if (!composesGrammar(context, file)) return {}
|
|
76
|
-
return {
|
|
77
|
-
JSXOpeningElement(node) {
|
|
78
|
-
if (node.name.type !== "JSXIdentifier") return
|
|
79
|
-
const owner = Object.hasOwn(GRAMMAR_OWNERS, node.name.name) ? GRAMMAR_OWNERS[node.name.name] : null
|
|
80
|
-
if (owner !== null) context.report({ node, messageId: "raw", data: { tag: node.name.name, owner: `\`${owner}\`` } })
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** The rules this law contributes to the plugin. */
|
|
87
|
-
export const rules = {
|
|
88
|
-
"no-raw-structural-element": noRawStructuralElement,
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
defineFamilyRules(rules, "knowledge/patterns/fe/ui.yaml#FE-UI")
|
|
92
|
-
|
|
93
|
-
/** Every rule is an error. */
|
|
94
|
-
export const recommended = Object.fromEntries(Object.keys(rules).map((name) => [`starci-grammar/${name}`, "error"]))
|