@starci/eslint-grammar-core 0.0.0-stage → 0.13.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.
Files changed (96) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/LICENSE +21 -0
  3. package/README.md +50 -2
  4. package/app-shell.mjs +208 -0
  5. package/docs/app-shell.md +52 -0
  6. package/docs/grammar-boundary.md +37 -0
  7. package/docs/status-colors.md +34 -0
  8. package/drawing.mjs +60 -0
  9. package/grammar-boundary.mjs +94 -0
  10. package/icon.mjs +313 -0
  11. package/index.d.ts +28 -0
  12. package/index.mjs +78 -0
  13. package/lib/app-shell-cluster.mjs +66 -0
  14. package/lib/app-shell-create.mjs +33 -0
  15. package/lib/app-shell-owner-source.mjs +124 -0
  16. package/lib/app-shell-owner.mjs +83 -0
  17. package/lib/app-shell-scope.mjs +79 -0
  18. package/lib/app-shell-visible.mjs +92 -0
  19. package/lib/app-shell.mjs +148 -0
  20. package/lib/rule-contract.mjs +11 -0
  21. package/lib/status-tones.generated.mjs +9 -0
  22. package/lib/why.mjs +38 -0
  23. package/menu-entries.mjs +146 -0
  24. package/package.json +64 -4
  25. package/runtime/engine/by-code-unit.mjs +12 -0
  26. package/runtime/engine/config.mjs +461 -0
  27. package/runtime/engine/invalid-config.mjs +15 -0
  28. package/runtime/engine/model-config.mjs +90 -0
  29. package/runtime/engine/orca-config.mjs +29 -0
  30. package/runtime/engine/plain-object.mjs +5 -0
  31. package/runtime/engine/release-config.mjs +28 -0
  32. package/runtime/engine/removed-vocabulary.mjs +26 -0
  33. package/runtime/engine/resources-config.mjs +52 -0
  34. package/runtime/engine/runtime-root.mjs +54 -0
  35. package/runtime/engine/secrets.mjs +134 -0
  36. package/runtime/engine/sonar-config.mjs +21 -0
  37. package/runtime/engine/yaml.mjs +161 -0
  38. package/runtime/knowledge/grammars/core/playbook.yaml +1214 -0
  39. package/runtime/knowledge/grammars/index.yaml +102 -0
  40. package/runtime/knowledge/hfs/canon-pins.yaml +615 -0
  41. package/runtime/knowledge/hfs/rules.yaml +5666 -0
  42. package/runtime/knowledge/hfs/slots.yaml +2570 -0
  43. package/runtime/knowledge/patterns/fe/index.yaml +213 -0
  44. package/runtime/knowledge/patterns/fe/ui.yaml +85 -0
  45. package/runtime/knowledge/ui/composition/app-shell.yaml +182 -0
  46. package/runtime/knowledge/ui/presentation/font.yaml +101 -0
  47. package/runtime/knowledge/ui/presentation/padding.yaml +217 -0
  48. package/runtime/knowledge/ui/proof/anatomy-source.yaml +198 -0
  49. package/runtime/modules/goal/source-phrases.yaml +95 -0
  50. package/runtime/modules/kernel/removed-vocabulary.yaml +458 -0
  51. package/runtime/modules/models/registry.yaml +221 -0
  52. package/runtime/modules/models/runtimes.yaml +556 -0
  53. package/runtime/modules/models/tiers.yaml +66 -0
  54. package/runtime/scripts/hfs/allows.mjs +57 -0
  55. package/runtime/scripts/hfs/architecture/config.mjs +349 -0
  56. package/runtime/scripts/hfs/architecture/side-boundary.mjs +16 -0
  57. package/runtime/scripts/hfs/architecture/type-context.mjs +300 -0
  58. package/runtime/scripts/hfs/architecture/typescript.mjs +417 -0
  59. package/runtime/scripts/hfs/declaration-shape.mjs +157 -0
  60. package/runtime/scripts/hfs/declaration-slots.mjs +86 -0
  61. package/runtime/scripts/hfs/edition-slots.mjs +77 -0
  62. package/runtime/scripts/hfs/manifest-shape.mjs +435 -0
  63. package/runtime/scripts/hfs/param-names.mjs +18 -0
  64. package/runtime/scripts/hfs/rule-catalog.mjs +362 -0
  65. package/runtime/scripts/hfs/rule-params-shape.mjs +80 -0
  66. package/runtime/scripts/hfs/slot-app-view.mjs +102 -0
  67. package/runtime/scripts/hfs/slot-classify.mjs +65 -0
  68. package/runtime/scripts/hfs/slot-errors.mjs +11 -0
  69. package/runtime/scripts/hfs/slot-imports.mjs +91 -0
  70. package/runtime/scripts/hfs/slot-manifest-shape.mjs +73 -0
  71. package/runtime/scripts/hfs/slot-match.mjs +153 -0
  72. package/runtime/scripts/hfs/slot-path.mjs +8 -0
  73. package/runtime/scripts/hfs/slot-required.mjs +89 -0
  74. package/runtime/scripts/hfs/slot-semantic-problems.mjs +149 -0
  75. package/runtime/scripts/hfs/slot-side-problems.mjs +28 -0
  76. package/runtime/scripts/hfs/slots.mjs +259 -0
  77. package/runtime/scripts/hfs/typescript-programs.mjs +98 -0
  78. package/runtime/scripts/hfs/view.mjs +73 -0
  79. package/runtime/scripts/lib/glob.mjs +23 -0
  80. package/runtime/scripts/lib/grammar-lint.mjs +61 -0
  81. package/runtime/scripts/lib/i18n.mjs +85 -0
  82. package/runtime/scripts/lib/json-clone.mjs +61 -0
  83. package/runtime/scripts/lib/json.mjs +32 -0
  84. package/runtime/scripts/lib/list.mjs +31 -0
  85. package/runtime/scripts/lib/path-key.mjs +109 -0
  86. package/runtime/scripts/lib/read-text.mjs +34 -0
  87. package/runtime/scripts/lib/regex.mjs +4 -0
  88. package/runtime/scripts/lib/source-phrases.mjs +34 -0
  89. package/runtime/scripts/lib/ts-analysis.mjs +37 -0
  90. package/runtime/scripts/lib/ts-ast.mjs +69 -0
  91. package/runtime/scripts/lib/walk.mjs +39 -0
  92. package/runtime/scripts/lib/yaml-cached.mjs +14 -0
  93. package/status-colors.mjs +140 -0
  94. package/tokens.mjs +164 -0
  95. package/typography.mjs +81 -0
  96. package/vendor-boundary.mjs +29 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,61 @@
1
+ # Changelog
2
+
3
+ ## 0.13.0 - 2026-10-27
4
+
5
+ - Changed: `@starci/eslint-canon-fe` is a peer dependency (9.2.0), installed by the app beside this package, instead of a nested dependency.
6
+ - Changed: the package lives in github.com/starci183/starci-harness under `packages/` and publishes from there; its bundled `runtime/` is committed source, edited in place (no generator, no `prepack`/`pretest` hook).
7
+ - Changed: owner ruling: there are exactly two Grammar families, `core` and `offset-pop`. This package is renamed from
8
+ `@starci/eslint-grammar-starci` to `@starci/eslint-grammar-core`, and its factory from `starciGrammarConfig` to
9
+ `coreGrammarConfig`, which loads for `sides.fe.grammar: core`.
10
+ - Removed: the ids `starci` and `starci-core` are not families and have no alias; an app that names them is refused.
11
+ Migrate: `sides.fe.grammar: core`, depend on `@starci/eslint-grammar-core`, call `coreGrammarConfig`.
12
+
13
+ ## 0.12.14 - 2026-10-27
14
+
15
+ - Changed: versioned together with Grammar 0.12.14; bundled canon pins moved.
16
+
17
+ ## 0.12.13 - 2026-10-26
18
+
19
+ - Changed: versioned together with Grammar 0.12.13 (control height 40, shared scroll carets).
20
+
21
+ ## 0.12.12 - 2026-10-26
22
+
23
+ - Changed: versioned with Grammar 0.12.12 (the family equality spec); the bundled canon pins and runtime copies follow the final package versions. No rule changes.
24
+
25
+ ## 0.12.11 - 2026-10-26
26
+
27
+ - Changed: versioned with the other lint families; depends on the exact front-end canon 9.1.7; the alpha.31.1 round folded into alpha.31; the bundled canon pins and runtime copies follow the final package versions. No rule changes.
28
+
29
+ ## 0.12.10 - 2026-10-26
30
+
31
+ - Changed: versioned with Grammar 0.12.10; depends on the exact canon-fe 9.1.6; the bundled canon pins follow the new package pins. No rule changes.
32
+
33
+ ## 0.12.9 - 2026-10-26
34
+
35
+ - Changed: versioned with Grammar 0.12.9; depends on the exact canon-fe 9.1.5; the bundled canon pins follow the new package pins. No rule changes.
36
+
37
+ ## 0.12.8 - 2026-10-26
38
+
39
+ - Changed: versioned with Grammar 0.12.8; depends on the exact canon-fe 9.1.4; the bundled canon pins follow the new package pins. No rule changes.
40
+
41
+ ## 0.12.7 - 2026-10-26
42
+
43
+ - Changed: versioned with Grammar 0.12.7; depends on the exact canon-fe 9.1.3; the bundled canon pins follow the new package pins. No rule changes.
44
+
45
+ ## 0.12.6 - 2026-10-26
46
+
47
+ - Changed: versioned with Grammar 0.12.6; depends on @starci/eslint-canon-fe 9.1.2; the bundled runtime copies follow the new sources. No rule changes.
48
+
49
+ ## 0.12.5 - 2026-10-26
50
+
51
+ - Changed: versioned with Grammar 0.12.5; depends on @starci/eslint-canon-fe 9.1.1; the bundled canon pins follow the new package pins. No rule changes.
52
+
53
+ ## 0.12.4 - 2026-10-26
54
+
55
+ - Changed: versioned with Grammar 0.12.4; no rule changes beyond the version pin.
56
+
57
+ ## 0.12.3 - 2026-10-26
58
+
59
+ - Added: the StarCi Grammar lint package, released with Grammar 0.12.3. Concrete family laws move from the universal FE canon with their rule IDs and behavioral specs, including the Grammar 0.12.3 lane's `no-icon-size-class` and `destructive-menu-entry-needs-danger-tone` in their latest form. The R318 surface composition rules stay in the universal canon.
60
+ - Added: the `starciGrammarConfig` flat-config factory, complete error-level recommendations, ownership citations and a generated runtime closure.
61
+ - Shared: generic lint readers are imported from `@starci/eslint-canon-fe` 9.0.0.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) StarCi contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,51 @@
1
- # Temporary Holding Version
1
+ # @starci/eslint-grammar-core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Concrete StarCi Grammar component, prop, variant and token contracts belong here under
4
+ [FE-RULE-OWNERSHIP](../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
5
+ The package version follows `@starci/grammar`; universal FE laws remain in `@starci/eslint-canon-fe`.
6
+
7
+ ```js
8
+ import { loadHfs, starciFeConfig } from "@starci/eslint-canon-fe"
9
+ import { coreGrammarConfig } from "@starci/eslint-grammar-core"
10
+
11
+ const hfs = loadHfs(import.meta.url)
12
+ export default [...starciFeConfig({ hfs }), ...coreGrammarConfig({ hfs })]
13
+ ```
14
+
15
+ Every rule uses the `starci-grammar` namespace and runs at error. The factory checks the selected
16
+ Grammar and covers the same source files as the universal factory. Shared AST, type, slot and
17
+ binding readers are imported from the universal package's explicit infrastructure exports.
18
+ Family helpers and the generated runtime closure belong to this package.
19
+
20
+ The rule IDs remain stable when their namespace moves. Laws cover the fixed app shell and navbar,
21
+ Grammar-owned structural elements, glyphs and icon sizes, destructive menu entries, status inks,
22
+ heading and token scales, vendor ownership and slot-status composition. Each rule's metadata cites
23
+ its behavioral knowledge source and the governing ownership test. The R318 surface composition
24
+ rules (nested control variants, panel-list alignment, layout-only CSS) stay in the universal canon.
25
+
26
+ ## Migrating from @starci/eslint-canon-fe 8.x
27
+
28
+ The pinned canon-fe release moved twenty rules here. Their IDs, finding codes and error severity are unchanged;
29
+ only the namespace changes from `starci-fe/` to `starci-grammar/`: `app-shell-frame`,
30
+ `no-shell-bottom-tabs`, `navbar-control-size`, `navbar-cluster`, `no-navbar-create`,
31
+ `no-raw-structural-element`, `no-heading-tag-outside-heading-component`,
32
+ `status-text-uses-soft-foreground`, `vendor-primitive-has-named-owner`,
33
+ `no-vendor-icon-outside-icon-leaf`, `heroicons-is-the-glyph-vendor`, `no-off-scale-glyph-size`,
34
+ `no-icon-size-class`, `destructive-menu-entry-needs-danger-tone`,
35
+ `no-decorative-icon-in-metric-cell`, `no-inline-svg-outside-brand-mark-leaf`, `no-fractional-step`,
36
+ `no-hand-rolled-heading`, `no-unresolved-token-class` and `slot-status-through-slotview`.
37
+
38
+ 1. Set `sides.fe.grammar` to `core` in `hfs.json`; no family is inferred.
39
+ 2. Install this package at its canon-pins version beside `@starci/eslint-canon-fe` 9 in the app
40
+ root `devDependencies`. `starci app check` refuses canon-fe 9 without it
41
+ (`FE_STACK_FAMILY_LINT_MISSING`), so the rules cannot be lost silently.
42
+ 3. Compose the universal factory first and this one second, with the same HFS view (the block
43
+ above). `starci app sync` renders that managed `fe/eslint.config.mjs`.
44
+ 4. Rename references to the moved rules from `starci-fe/` to `starci-grammar/`.
45
+
46
+ Consuming apps migrate in their own release.
47
+
48
+ Offset Pop inherits the Common component contract through `@starci/eslint-grammar-offset-pop`.
49
+ Its own adapter selects that family and reuses these implementations.
50
+
51
+ Regression checks live in this ESLint package. The Grammar and consuming app front ends carry no specs.
package/app-shell.mjs ADDED
@@ -0,0 +1,208 @@
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"]))
@@ -0,0 +1,52 @@
1
+ # App shell
2
+
3
+ Owner: contexts/ui/composition.md
4
+
5
+ The application composes `WorkspaceShell viewport="fixed"`. The `app-shell-frame` rule identifies
6
+ workspace chrome from a fixed shell, sidebar/navigation slot, workspace identity, HFS layout owner,
7
+ or a shell owner combining a bar and sidebar. It rejects hand-written app-frame landmarks and
8
+ workspace shells without the fixed viewport. Generic flow-based site chrome stays in its own scope.
9
+ `no-shell-bottom-tabs` rejects bottom navigation components and the shell's `compactNavigation` slot.
10
+
11
+ The `navbar-cluster` rule reads the visible `TopBar` or `NavigationFeatureNav` actions in source order:
12
+ tertiary Language `IconButton` triggering `DropdownMenu`, theme `Switch`, notification `IconButton`
13
+ triggering `Popover`, account `AvatarButton` triggering `DropdownMenu`. It follows
14
+ local JSX constants and components, constant object members, imported Grammar aliases, and namespace imports. Translated
15
+ labels may be dynamic; icon sources identify language and notifications. Menu contents and popover
16
+ content belong to their overlays and are outside the bar's control sequence. Conditional render
17
+ branches are checked separately. Grammar `TopBar` and `NavigationFeatureNav` compositions are app
18
+ bars by default. A proven `WorkspaceShell viewport="flow"` with no workspace/sidebar evidence owns
19
+ generic site chrome. A shell hosting an imported navbar delegates only after its owned public
20
+ export and rendered Base chain prove a `TopBar` or `NavigationFeatureNav` in every alternative.
21
+ Workspace exports resolve back to source. Raw or unknown imported headers are red; the actual
22
+ bar's own actions are checked where composed. Each lint source snapshot has fresh dependency proofs.
23
+
24
+ `navbar-control-size` requires `size="control"` on each bar control. Unknown trailing prop spreads
25
+ cannot prove a size; put the explicit size after a spread. A left `Drawer` containing
26
+ `Sidebar presentation="drawer"` also identifies a mobile bar opener when composed in a separate
27
+ client owner. Its trigger is checked; drawer bodies and footers retain their normal field sizes.
28
+ `no-navbar-create` places creation on its
29
+ own page and rejects create controls in the navbar and its attached menus or popovers. Static
30
+ evidence includes literal labels, translated keys with create semantics, and conventional create
31
+ handlers. Runtime-generated labels and arbitrary handler behavior need semantic review; the rule
32
+ does not execute application code.
33
+
34
+ | Rule | Invalid composition | Valid composition |
35
+ | --- | --- | --- |
36
+ | `app-shell-frame` | An app `Shell` returns a hand-written `<header>` and `<nav>`. | `WorkspaceShell viewport="fixed"` owns the app frame. |
37
+ | `no-shell-bottom-tabs` | The shell supplies `compactNavigation={<BottomNav />}`. | The shell supplies `navigationDrawer` with a drawer `Sidebar`. |
38
+ | `navbar-control-size` | A navbar `IconButton` uses `size="md"`. | The same control uses `size="control"`. |
39
+ | `navbar-cluster` | Account precedes notifications, or a language trigger uses a regular `Button`. | Language menu, theme switch, notification popover, account menu use their stated Grammar trigger kinds in that order. |
40
+ | `no-navbar-create` | A navbar button or attached menu item creates a record. | The page owns its create action. |
41
+
42
+ ```tsx
43
+ // Invalid: the navbar action creates a page record and has a different height.
44
+ <TopBar actions={<Button onPress={on.create}>Create</Button>} />
45
+
46
+ // Valid: a page action belongs to page content.
47
+ <SurfaceCard><Button onPress={on.create}>Create</Button></SurfaceCard>
48
+ ```
49
+
50
+ All five rules are errors in the gathered FE canon and run through the ordinary application gate.
51
+
52
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -0,0 +1,37 @@
1
+ # Grammar boundary
2
+
3
+ Law module: `grammar-boundary.mjs`. Catalogue: R62 FE_NATIVE_FORM_CONTROL (the grammar owns the element).
4
+
5
+ Page structure and text are composed from `@starci/grammar` (or the repository's `<family>-ui` package), not drawn as raw HTML.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/no-raw-structural-element`
10
+
11
+ Page structure and text are grammar components, not raw `div`-family HTML; only `fe.package.ui` renderers draw raw tags.
12
+
13
+ Applies to app source that composes the grammar (slots `fe.feature`, `fe.components`, `fe.route`, `fe.hooks`) and to every workspace package except the `<family>-ui` package (`fe.package.ui`), whose components are the renderers. Spec files render raw HTML as a harness and are not judged; a file no slot owns is not judged.
14
+
15
+ The refused tags are exactly those `@starci/grammar` has a component for (the twin test reads the package source): `h1-h6` (`Heading`), `p` and `span` (`Text`), `hr` (`Divider`), `label` (`Label`), `form` (`Form`), `fieldset` (`Fieldset`), `dl` `dt` `dd` (`DescriptionList`), `table` `thead` `tbody` `tr` `td` `th` (`DataTable`), `ul` `ol` `li` (`List` and `ListItem` for a plain semantic list, `SurfaceListCard`, `StaticStateRow`), `header` (`SectionHeader`, `TopBar`), `footer` (`Footer`), `nav` (`NavLandmark` for a named row of links, `Subnav`, `Breadcrumbs`, `NavigationFeatureNav`), `section` (`Region` for a named non-card region, `SurfaceCard`), `main` (`WorkspaceShell`), `figure` and `figcaption` (`MediaFrame`). `div`, `br`, `aside` and `article` are not refused: the grammar has no component for them.
16
+
17
+ Native `<time>` remains available for an absolute timestamp. Live relative time and countdown labels use `RelativeTime` (the universal canon's `starci-fe/no-app-relative-clock`).
18
+
19
+ **Invalid** (`src/features/pages/home/component.tsx`)
20
+
21
+ ```ts
22
+ export const Home = () => <section><p>{t("intro")}</p></section>
23
+ ```
24
+
25
+ **Valid** (`src/features/pages/home/component.tsx`)
26
+
27
+ ```ts
28
+ export const Home = () => <SurfaceCard><Text>{t("intro")}</Text></SurfaceCard>
29
+ ```
30
+
31
+ **Finding code:** `FE_NATIVE_FORM_CONTROL`
32
+
33
+ **Why:** Raw `<tag>` in `<file>`. Page structure and text are composed from grammar components, not written as raw HTML.
34
+
35
+ **Fix:** Replace it with the matching grammar component (`Heading`, `Text`, `SurfaceCard`, ...); if the grammar lacks one, add it to the grammar or the ui package instead of drawing it in place.
36
+
37
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
@@ -0,0 +1,34 @@
1
+ # Status colours: text and icons take the soft pair
2
+
3
+ Law module: `status-colors.mjs`. Catalogue: R61 FE_STYLE_TOKEN_ONLY (the class-name half of the soft-pair contrast obligation; the brand layer's own contrast is `starci/status-contrast` of @starci/stylelint-canon).
4
+
5
+ A status tone has two faces. The solid tone (`--success`) is a fill, with `--success-foreground` ink on it. A status shown as text or as an icon takes the soft pair, the way a HeroUI flat Chip does: `--success-soft-foreground` ink, on `--success-soft` when it sits on a tint. The soft pair is what the brand layer is checked to make readable (3:1 on the tint and on the page); the solid tone reads 3.8:1 or worse on white, so as a text colour it fails. The tones are the grammar's status tones (`success`, `warning`, `danger`, `info`), read from `lib/status-tones.generated.mjs`, which is generated from the grammar with the stylelint vocabulary.
6
+
7
+ Every rule below is an error in `coreGrammarConfig`; none can be switched off or suppressed inline.
8
+
9
+ ## `starci-grammar/status-text-uses-soft-foreground`
10
+
11
+ No class that paints text, an icon or a text decoration with a solid status tone: `text-<tone>`, `fill-<tone>`, `stroke-<tone>`, `decoration-<tone>` (with any variant, opacity or `!`), read from `className`/`class`, from `cn()`/`clsx()` arguments, conditionals, arrays, constants and `classes` entries.
12
+
13
+ **Invalid** (`src/components/leaves/StatusText/index.tsx`)
14
+
15
+ ```tsx
16
+ <span className="text-success" />
17
+ <svg className={cn("size-4", ok && "fill-danger")} />
18
+ ```
19
+
20
+ **Valid** (`src/components/leaves/StatusText/index.tsx`)
21
+
22
+ ```tsx
23
+ <span className="bg-success-soft text-success-soft-foreground" />
24
+ <button className="bg-success text-success-foreground" />
25
+ <div className="border-danger ring-2 ring-warning" />
26
+ ```
27
+
28
+ **Finding code:** `FE_STYLE_TOKEN_ONLY`
29
+
30
+ **Why:** `<file>` colours text or an icon with a solid status tone (`<what>`, for example `text-success`). A solid tone is a background colour; used as a text colour it reads below 4.5:1 on the page background.
31
+
32
+ **Fix:** Change to the soft pair: `text-<tone>-soft-foreground` (with `bg-<tone>-soft` if it sits on a light background); solid tones are used only with `bg-<tone>` and `text-<tone>-foreground`.
33
+
34
+ Rule ownership: [FE-RULE-OWNERSHIP](../../../contexts/code/fe/README.md#the-placement-test-fe-rule-ownership).
package/drawing.mjs ADDED
@@ -0,0 +1,60 @@
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"]))
@@ -0,0 +1,94 @@
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"]))