@starci/eslint-canon-fe 9.1.12 → 9.2.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 +3 -2
- package/README.md +5 -7
- package/button-intent.mjs +1 -1
- package/control-height.mjs +1 -1
- package/lint-escape-hatch.mjs +4 -8
- package/package.json +1 -1
- package/runtime/knowledge/grammars/index.yaml +12 -27
- package/runtime/knowledge/hfs/canon-pins.yaml +18 -19
- package/runtime/knowledge/hfs/fe-stack.yaml +1 -1
- package/runtime/scripts/hfs/rule-catalog.mjs +2 -2
- package/runtime/scripts/lib/grammar-lint.mjs +7 -27
- package/surface-rules.mjs +1 -1
- package/ui-rulings.mjs +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 9.
|
|
3
|
+
## 9.2.0 - 2026-10-27
|
|
4
4
|
|
|
5
|
-
- Changed: owner ruling two-grammars: the bundled Grammar catalog
|
|
5
|
+
- Changed: owner ruling two-grammars: the bundled Grammar catalog declares exactly two families, `core` (`@starci/eslint-grammar-core`, `coreGrammarConfig`) and `offset-pop`; `starci`, `starci-core` and `heritage` are refused. The Grammar entry checks (button intent, control height, surface rules, UI rulings) accept `@starci/grammar/<common|core|offset-pop>`. The bundled canon pins follow the harness packages (Grammar family 0.13.0, hfs 4.8.0, canon-fe 9.2.0, canon-be 3.4.57, stylelint-canon 2.1.0).
|
|
6
|
+
- Changed: the doc comment of `lint-escape-hatch.mjs` names the three patterns that own the refused spellings instead of spelling them again. No rule or behaviour changed.
|
|
6
7
|
|
|
7
8
|
## 9.1.11 - 2026-10-27
|
|
8
9
|
|
package/README.md
CHANGED
|
@@ -7,10 +7,10 @@ structure, typed contracts, token discipline and check integrity across Grammar
|
|
|
7
7
|
|
|
8
8
|
```js
|
|
9
9
|
import { loadHfs, starciFeConfig } from "@starci/eslint-canon-fe"
|
|
10
|
-
import {
|
|
10
|
+
import { coreGrammarConfig } from "@starci/eslint-grammar-core"
|
|
11
11
|
|
|
12
12
|
const hfs = loadHfs(import.meta.url)
|
|
13
|
-
export default [...starciFeConfig({ hfs }), ...
|
|
13
|
+
export default [...starciFeConfig({ hfs }), ...coreGrammarConfig({ hfs })]
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
`starci app sync` renders the selected family's managed flat config. Both factories cover every
|
|
@@ -19,7 +19,7 @@ Sonar rules run at error; the factory sets typed parsing and refuses inline lint
|
|
|
19
19
|
Generated wire types, dependencies and build outputs follow the shared source-scope contract.
|
|
20
20
|
|
|
21
21
|
Concrete Grammar component names, props, variants, scales and vendor recipes belong to
|
|
22
|
-
`@starci/eslint-grammar-
|
|
22
|
+
`@starci/eslint-grammar-core` or the selected family's package. The family rules keep their
|
|
23
23
|
bare IDs under the `starci-grammar` namespace. This package exports shared AST, binding, type,
|
|
24
24
|
slot and configuration infrastructure through `@starci/eslint-canon-fe/lib/*`; family packages
|
|
25
25
|
import those readers without copying them.
|
|
@@ -50,7 +50,5 @@ Regression specs belong to this package. Application front ends and Grammar libr
|
|
|
50
50
|
## The runtime copy
|
|
51
51
|
|
|
52
52
|
`runtime/` holds the StarCi runtime files the rules import (the slot manifest and view, the project graph and the
|
|
53
|
-
architecture machine it runs, the Sonar syntax rules), byte for byte at their runtime paths.
|
|
54
|
-
|
|
55
|
-
`scripts/hfs/sync-runtime.mjs` generates it; refresh it by running that generator there and copying
|
|
56
|
-
`packages/eslint/fe/runtime/` over this folder. Nothing in this package edits it.
|
|
53
|
+
architecture machine it runs, the Sonar syntax rules), byte for byte at their runtime paths. It is committed source of
|
|
54
|
+
this package, edited in place ([packages/README.md](../README.md) says how the bundled copies move together).
|
package/button-intent.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { functionOf, importOf, isFn, patternPath, unwrap, variableOf } from "./l
|
|
|
4
4
|
import { typedPropertyStrings } from "./lib/typed-class-values.mjs"
|
|
5
5
|
import ts from "typescript"
|
|
6
6
|
|
|
7
|
-
const GRAMMAR_ENTRY = /^@starci\/grammar(?:\/(?:common|core|
|
|
7
|
+
const GRAMMAR_ENTRY = /^@starci\/grammar(?:\/(?:common|core|offset-pop))?$/
|
|
8
8
|
const BUTTONS = new Set(["Button", "IconButton"])
|
|
9
9
|
const DIALOGS = new Set(["AlertDialog", "ConfirmDialog"])
|
|
10
10
|
const ITEMS = new Set(["CollectionItem", "ItemActions", "ListItem", "ListRow", "ListBox.Item", "GridList.Item", "Table.Row", "TableRow"])
|
package/control-height.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { attributeValue, stringOf } from "./lib/ast.mjs"
|
|
3
3
|
import { importOf } from "./lib/bindings.mjs"
|
|
4
4
|
|
|
5
|
-
const GRAMMAR_ENTRY = /^@starci\/grammar(?:\/(?:common|core|
|
|
5
|
+
const GRAMMAR_ENTRY = /^@starci\/grammar(?:\/(?:common|core|offset-pop))?$/
|
|
6
6
|
const CONTROLS = new Set(["Button", "IconButton", "Switch", "Input", "SearchField", "Select", "Tabs", "SegmentedControl", "Textarea", "NumberField", "ComboBox"])
|
|
7
7
|
/** A marketing hero call to action on a landing page is the one place the 48px step is allowed. */
|
|
8
8
|
const LANDING_PATH = /[\\/](?:landing|hero|marketing)[\\/]|(?:Landing|Hero)[^\\/]*[\\/]/
|
package/lint-escape-hatch.mjs
CHANGED
|
@@ -3,14 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* NO LOCAL EXCEPTION, OF ANY SPELLING. A rule that a comment can switch off is a convention, and a
|
|
5
5
|
* codebase learns which conventions are real by which ones it can suppress. The spellings this law
|
|
6
|
-
* refuses are the ones an author actually reaches for:
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* the no-sonar word, @sonar-ignore - Sonar's own switches
|
|
11
|
-
* istanbul ignore, c8 ignore, v8 ignore - a line taken out of the coverage the gate reads
|
|
12
|
-
* prettier-ignore - a region taken out of the formatter
|
|
13
|
-
* stylelint-disable / -enable - a stylelint switch that reached a TS file
|
|
6
|
+
* refuses are the ones an author actually reaches for, and the three patterns below own them:
|
|
7
|
+
* ESLINT_DIRECTIVE (an ESLint switch or inline rule configuration), TS_DIRECTIVE (a TypeScript
|
|
8
|
+
* suppression) and TOOL_DIRECTIVE (Sonar's own switches, a line taken out of the coverage the gate
|
|
9
|
+
* reads, a region taken out of the formatter, a stylelint switch that reached a TS file).
|
|
14
10
|
*
|
|
15
11
|
* TWO LAYERS, BECAUSE ONE IS NOT ENOUGH. The flat-config fence (`noInlineConfig`) makes an ESLint
|
|
16
12
|
* directive INEFFECTIVE; this rule makes it a FINDING, so the attempt is named in the log instead of
|
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ guidance:
|
|
|
24
24
|
Do not treat this catalog as selecting a default Grammar family. Family choice belongs to the
|
|
25
25
|
current design specification and its explicit sides.fe.grammar declaration.
|
|
26
26
|
rationale: |
|
|
27
|
-
Silent fallback to
|
|
27
|
+
Silent fallback to a family would invent product direction and override an absent/ambiguous design.
|
|
28
28
|
- id: verify-before-use
|
|
29
29
|
requirement: |
|
|
30
30
|
Before applying snapshot APIs or recorded gaps, inspect the selected repository's package
|
|
@@ -47,11 +47,11 @@ topics:
|
|
|
47
47
|
Generated DNA snapshot of the `@starci/grammar/common` public entry: custom properties,
|
|
48
48
|
the 110 renderers of its registry, their classes, stamped rule ids and recorded gaps. The DNA owns the observed package
|
|
49
49
|
version and source inventory. Common supplies anatomy, not colour. The snapshot is drift-checked.
|
|
50
|
-
- id:
|
|
51
|
-
path:
|
|
52
|
-
title:
|
|
50
|
+
- id: core
|
|
51
|
+
path: core/index.yaml
|
|
52
|
+
title: Core Grammar
|
|
53
53
|
summary: |
|
|
54
|
-
Historical snapshot of the
|
|
54
|
+
Historical snapshot of the core family — DNA, idioms, playbook (including composing the
|
|
55
55
|
0.5.0 forms, overlays and navigation chrome) and family boundaries.
|
|
56
56
|
- id: offset-pop
|
|
57
57
|
path: offset-pop/index.yaml
|
|
@@ -61,22 +61,7 @@ topics:
|
|
|
61
61
|
shadow, one pink decision accent with a text-safe accent for text — with DNA, idioms, a
|
|
62
62
|
mobile-first playbook for playful learning or consumer apps, and family boundaries including two
|
|
63
63
|
decisions flagged for the family owner.
|
|
64
|
-
- id: heritage
|
|
65
|
-
path: heritage/DNA.yaml
|
|
66
|
-
title: Heritage Grammar
|
|
67
|
-
summary: |
|
|
68
|
-
Generated snapshot of the Heritage family's parity declaration, arrangement, scoped tokens and Common renderers.
|
|
69
|
-
# The one alias table of Grammar family ids (ruling two-grammars, 2026-10-27): `core` is the canonical id of the
|
|
70
|
-
# legacy core grammar; the legacy catalog id `starci` and the DNA id `starci-core` are deprecated spellings that
|
|
71
|
-
# resolve to it. Every reader resolves a selection through scripts/lib/grammar-lint.mjs, never through its own list.
|
|
72
|
-
familyAliases:
|
|
73
|
-
starci: core
|
|
74
|
-
starci-core: core
|
|
75
64
|
families:
|
|
76
|
-
- id: heritage
|
|
77
|
-
title: heritage
|
|
78
|
-
contractRef: common
|
|
79
|
-
packageSnapshot: heritage/DNA.yaml
|
|
80
65
|
- id: common
|
|
81
66
|
title: common
|
|
82
67
|
componentContract:
|
|
@@ -95,14 +80,14 @@ families:
|
|
|
95
80
|
title: core
|
|
96
81
|
contractRef: common
|
|
97
82
|
lint:
|
|
98
|
-
package: '@starci/eslint-grammar-
|
|
99
|
-
factory:
|
|
83
|
+
package: '@starci/eslint-grammar-core'
|
|
84
|
+
factory: coreGrammarConfig
|
|
100
85
|
prefix: starci-grammar
|
|
101
|
-
authority:
|
|
102
|
-
packageSnapshot:
|
|
103
|
-
reusableStyle:
|
|
104
|
-
productComposition:
|
|
105
|
-
index:
|
|
86
|
+
authority: core/family.yaml
|
|
87
|
+
packageSnapshot: core/DNA.yaml
|
|
88
|
+
reusableStyle: core/idioms.yaml
|
|
89
|
+
productComposition: core/playbook.yaml
|
|
90
|
+
index: core/index.yaml
|
|
106
91
|
- id: offset-pop
|
|
107
92
|
title: offset-pop
|
|
108
93
|
contractRef: common
|
|
@@ -21,7 +21,7 @@ pins:
|
|
|
21
21
|
install: registry
|
|
22
22
|
side: fe
|
|
23
23
|
source: packages/heroicons/package.json
|
|
24
|
-
why: 'StarCi custom Heroicons-compatible cuts; eslint-grammar-
|
|
24
|
+
why: 'StarCi custom Heroicons-compatible cuts; eslint-grammar-core (icon.mjs) admits @starci/heroicons/24/outline and /16/solid as icon sources, so an app that uses them gets this exact version.'
|
|
25
25
|
'@starci/event-stream':
|
|
26
26
|
version: 0.1.0
|
|
27
27
|
group: starci
|
|
@@ -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.13.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.4.
|
|
40
|
+
version: 3.4.57
|
|
41
41
|
group: starci
|
|
42
42
|
install: registry
|
|
43
43
|
side: be
|
|
44
|
-
source: packages/eslint
|
|
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.2.0
|
|
48
48
|
group: starci
|
|
49
49
|
install: registry
|
|
50
50
|
side: fe
|
|
51
|
-
source: packages/eslint
|
|
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
|
-
'@starci/eslint-grammar-
|
|
54
|
-
version: 0.
|
|
53
|
+
'@starci/eslint-grammar-core':
|
|
54
|
+
version: 0.13.0
|
|
55
55
|
group: starci
|
|
56
56
|
install: registry
|
|
57
57
|
side: fe
|
|
58
|
-
source: packages/eslint
|
|
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.13.0
|
|
62
62
|
group: starci
|
|
63
63
|
install: registry
|
|
64
64
|
side: fe
|
|
65
|
-
source: packages/eslint
|
|
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.0
|
|
68
|
+
version: 2.1.0
|
|
69
69
|
group: starci
|
|
70
70
|
install: registry
|
|
71
71
|
side: fe
|
|
72
|
-
source: packages/stylelint/package.json
|
|
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.0.8
|
|
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.0.5
|
|
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.3.
|
|
87
|
+
version: 2.3.7
|
|
88
88
|
group: starci
|
|
89
89
|
install: registry
|
|
90
90
|
side: be
|
|
@@ -102,10 +102,9 @@ pins:
|
|
|
102
102
|
group: starci
|
|
103
103
|
install: registry
|
|
104
104
|
side: both
|
|
105
|
-
source: packages/cli/package.json
|
|
106
105
|
why: 'the only StarCi command package; product repositories install it for starci app, while @starci/hfs remains its pinned transitive implementation.'
|
|
107
106
|
'@starci/hfs':
|
|
108
|
-
version: 4.
|
|
107
|
+
version: 4.8.0
|
|
109
108
|
group: starci
|
|
110
109
|
install: registry
|
|
111
110
|
side: both
|
|
@@ -406,7 +405,7 @@ pins:
|
|
|
406
405
|
version: 2.2.0
|
|
407
406
|
group: ui
|
|
408
407
|
side: fe
|
|
409
|
-
why: 'the base of the one application icon set (fe-stack icons, with @starci/heroicons for the glyphs it lacks); eslint-grammar-
|
|
408
|
+
why: 'the base of the one application icon set (fe-stack icons, with @starci/heroicons for the glyphs it lacks); eslint-grammar-core (icon.mjs) admits @heroicons/react/24/outline and /16/solid.'
|
|
410
409
|
'@dicebear/core':
|
|
411
410
|
version: 10.4.0
|
|
412
411
|
group: ui
|
|
@@ -251,7 +251,7 @@ concerns:
|
|
|
251
251
|
why: the canon lint and format configuration.
|
|
252
252
|
- id: grammar-lint
|
|
253
253
|
tier: opt
|
|
254
|
-
packages: ['@starci/eslint-grammar-
|
|
254
|
+
packages: ['@starci/eslint-grammar-core', '@starci/eslint-grammar-offset-pop']
|
|
255
255
|
home: [fe.source-root-pinned]
|
|
256
256
|
pattern: FE-RULE-OWNERSHIP
|
|
257
257
|
forbids: []
|
|
@@ -12,7 +12,7 @@ import { fail } from './slot-errors.mjs';
|
|
|
12
12
|
|
|
13
13
|
const HFS_RULES_FILE = 'knowledge/hfs/rules.yaml';
|
|
14
14
|
const RULE_GATES = Object.freeze(['pre-commit', 'pre-push', 'settle', 'land', 'ci', 'sonar', 'runtime']);
|
|
15
|
-
const ENFORCER_FAMILIES = Object.freeze(['eslint-be', 'eslint-fe', 'eslint-grammar-
|
|
15
|
+
const ENFORCER_FAMILIES = Object.freeze(['eslint-be', 'eslint-fe', 'eslint-grammar-core', 'stylelint', 'machine', 'hfs', 'work-validate', 'sonar', 'runtime']);
|
|
16
16
|
const RULE_KINDS = Object.freeze(['codemod', 'lint', 'check', 'design']);
|
|
17
17
|
const FINDING_CODE = /^[A-Z][A-Z0-9]*(_[A-Z0-9]+)+$/;
|
|
18
18
|
const ENFORCER_ID = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
@@ -346,7 +346,7 @@ export function loadRuleCatalog({ root = skillRoot, file = path.join(root, HFS_R
|
|
|
346
346
|
/** The catalogued why code of a lint finding's rule id (`starci-be/<id>`, `starci-fe/<id>`), or undefined. */
|
|
347
347
|
lintCode: (ruleId) => {
|
|
348
348
|
const [plugin, id] = String(ruleId ?? '').split('/');
|
|
349
|
-
const kind = (plugin === 'starci-be' && 'eslint-be') || (plugin === 'starci-fe' && 'eslint-fe') || (plugin === 'starci-grammar' && 'eslint-grammar-
|
|
349
|
+
const kind = (plugin === 'starci-be' && 'eslint-be') || (plugin === 'starci-fe' && 'eslint-fe') || (plugin === 'starci-grammar' && 'eslint-grammar-core') || null;
|
|
350
350
|
return kind ? list.find((rule) => rule.enforcers.some((enforcer) => enforcer.kind === kind && enforcer.id === id))?.code : undefined;
|
|
351
351
|
},
|
|
352
352
|
/** The rules one enforcer judges, e.g. forEnforcer('eslint-be', 'error-home'). */
|
|
@@ -8,40 +8,21 @@ function readCatalog() {
|
|
|
8
8
|
return parseYamlCached(fs.readFileSync(CATALOG_FILE, 'utf8'));
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
/** The catalog's one alias table: a deprecated id names exactly one canonical family and is never itself a family. */
|
|
12
|
-
function aliasTarget(catalog, family) {
|
|
13
|
-
const aliases = catalog.familyAliases ?? {};
|
|
14
|
-
if (!Object.hasOwn(aliases, family)) return null;
|
|
15
|
-
const target = aliases[family];
|
|
16
|
-
if (typeof target !== 'string' || Object.hasOwn(aliases, target)
|
|
17
|
-
|| (catalog.families ?? []).some(entry => entry.id === family)) {
|
|
18
|
-
throw new Error(`Grammar family alias ${family} in knowledge/grammars/index.yaml must name one canonical family`);
|
|
19
|
-
}
|
|
20
|
-
return target;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
11
|
function selectedFamily(family) {
|
|
24
12
|
if (typeof family !== 'string' || !family.trim()) throw new Error('sides.fe.grammar must explicitly name the selected Grammar family');
|
|
25
13
|
const catalog = readCatalog();
|
|
26
|
-
const
|
|
27
|
-
const matches = (catalog.families ?? []).filter(entry => entry.id === id);
|
|
14
|
+
const matches = (catalog.families ?? []).filter(entry => entry.id === family);
|
|
28
15
|
if (matches.length !== 1) throw new Error(`Grammar family ${family} has no declared lint contract in knowledge/grammars/index.yaml`);
|
|
29
16
|
return { catalog, selected: matches[0] };
|
|
30
17
|
}
|
|
31
18
|
|
|
32
19
|
/**
|
|
33
|
-
* Resolve a selection to its
|
|
20
|
+
* Resolve a selection to its declared family id; only a catalog family id resolves, there are no aliases.
|
|
34
21
|
* @param {string} family - The id an app or caller names (sides.fe.grammar).
|
|
35
|
-
* @returns {{ id: string
|
|
22
|
+
* @returns {{ id: string }} The declared family id.
|
|
36
23
|
*/
|
|
37
24
|
export function resolveGrammarFamily(family) {
|
|
38
|
-
|
|
39
|
-
if (selected.id === family) return Object.freeze({ id: family, alias: null, note: null });
|
|
40
|
-
return Object.freeze({
|
|
41
|
-
id: selected.id,
|
|
42
|
-
alias: family,
|
|
43
|
-
note: `Grammar family id ${family} is a deprecated alias of ${selected.id}; write sides.fe.grammar: ${selected.id}`,
|
|
44
|
-
});
|
|
25
|
+
return Object.freeze({ id: selectedFamily(family).selected.id });
|
|
45
26
|
}
|
|
46
27
|
|
|
47
28
|
/** The explicitly selected authored family entry; callers share the catalog lookup rather than inferring a family. */
|
|
@@ -49,21 +30,20 @@ export function grammarFamilyFor(family) {
|
|
|
49
30
|
return Object.freeze(selectedFamily(family).selected);
|
|
50
31
|
}
|
|
51
32
|
|
|
52
|
-
/** The declared family's lint contract
|
|
33
|
+
/** The declared family's lint contract, including an explicit null package when that family has no rules. */
|
|
53
34
|
export function grammarLintFor(family) {
|
|
54
35
|
const { selected } = selectedFamily(family);
|
|
55
36
|
if (!selected.lint || !Object.hasOwn(selected.lint, 'package')) {
|
|
56
37
|
throw new Error(`Grammar family ${family} has no declared lint contract in knowledge/grammars/index.yaml`);
|
|
57
38
|
}
|
|
58
39
|
const lint = selected.lint;
|
|
59
|
-
|
|
60
|
-
if (lint.package === null) return Object.freeze({ family: canonical, package: null });
|
|
40
|
+
if (lint.package === null) return Object.freeze({ family: selected.id, package: null });
|
|
61
41
|
if (typeof lint.package !== 'string' || !lint.package.startsWith('@starci/eslint-grammar-')
|
|
62
42
|
|| typeof lint.factory !== 'string' || !/^[a-zA-Z][a-zA-Z0-9]*$/.test(lint.factory)
|
|
63
43
|
|| typeof lint.prefix !== 'string' || !/^[a-z][a-z0-9-]*$/.test(lint.prefix)) {
|
|
64
44
|
throw new Error(`Grammar family ${family} has an invalid lint contract in knowledge/grammars/index.yaml`);
|
|
65
45
|
}
|
|
66
|
-
return Object.freeze({ family:
|
|
46
|
+
return Object.freeze({ family: selected.id, package: lint.package, factory: lint.factory, prefix: lint.prefix });
|
|
67
47
|
}
|
|
68
48
|
|
|
69
49
|
/** The selected family's shared component/export contract, resolved through its catalog reference. */
|
package/surface-rules.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { functionOf, importOf, isFn, patternPath, unwrap, variableOf } from "./l
|
|
|
4
4
|
import { typedClassStrings, typedPropertyStrings } from "./lib/typed-class-values.mjs"
|
|
5
5
|
import { reactHookOf } from "./lib/react.mjs"
|
|
6
6
|
|
|
7
|
-
const GRAMMAR_ENTRY = /^@starci\/grammar(?:\/(?:common|core|
|
|
7
|
+
const GRAMMAR_ENTRY = /^@starci\/grammar(?:\/(?:common|core|offset-pop))?$/
|
|
8
8
|
const SURFACES = new Set([
|
|
9
9
|
"SurfaceCard", "SurfaceListCard", "SurfaceAccordionCard", "Sidebar",
|
|
10
10
|
"Dialog", "Drawer", "AlertDialog", "Popover",
|
package/ui-rulings.mjs
CHANGED
|
@@ -12,7 +12,7 @@ const grammarComponent = (context, opening, expected) => {
|
|
|
12
12
|
const binding = importOf(context, root);
|
|
13
13
|
if (
|
|
14
14
|
!binding ||
|
|
15
|
-
!/^@starci\/grammar(?:\/(?:common|core|
|
|
15
|
+
!/^@starci\/grammar(?:\/(?:common|core|offset-pop))?$/.test(
|
|
16
16
|
binding.source,
|
|
17
17
|
)
|
|
18
18
|
)
|