@starci/eslint-grammar-core 0.21.6 → 0.21.8

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.21.8
4
+
5
+ - Changed: Use the shared FE owner-source and connected Page drawing proofs for mounted route frames, require FE 9.9.8, and refresh the declared runtime catalog and pins.
6
+
7
+ ## 0.21.7
8
+
9
+ - Changed: Bundled canon pins name the builder-provenance BE canon release and its coherent dependency cohort. This package changes no runtime behavior or rule severity.
10
+
3
11
  ## 0.21.6
4
12
 
5
13
  - Changed: Align bundled canon pins and exact sibling requirements with Grammar and its lint families at 0.21.6. Runtime behavior and rule severity are unchanged.
@@ -1,13 +1,3 @@
1
- import type { TSESTree } from "@typescript-eslint/types";
2
- import type { Node, ParsedContext, ReaderContext } from "./types.js";
3
- /** An exported value together with the parsed file that holds it. */
4
- export interface Owner {
5
- readonly context: ParsedContext;
6
- readonly value: Node;
7
- }
8
- /** An imported JSX owner, or null when its implementation cannot be proved from owned source. */
9
- export declare const importedHeader: (context: ReaderContext, opening: TSESTree.JSXOpeningElement) => Owner | null;
10
- /** A file of the app parsed on its own (a route `layout`), sharing the run's parse cache. */
11
- export declare const parsedSource: (context: ReaderContext, filename: string) => ParsedContext;
12
- /** The per-repository proof cache shares the same lifetime as parsed header source. */
13
- export declare const headerProofs: (context: ReaderContext) => Map<string, boolean>;
1
+ /** Shared selected-export parser; app-shell and Page proofs use the same owner graph. */
2
+ export { importedHeader, parsedSource, headerProofs } from "@starci/eslint-canon-fe/lib/owner-source.mjs";
3
+ export type { Owner } from "@starci/eslint-canon-fe/lib/owner-source.mjs";
@@ -1,161 +1,2 @@
1
- /** Resolve only an imported header's owned source and selected public export. */
2
- import fs from "node:fs";
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import ts from "typescript";
6
- import parser from "@typescript-eslint/parser";
7
- import { SourceCode } from "eslint";
8
- import { importOf, variableOf } from "@starci/eslint-canon-fe/lib/bindings.mjs";
9
- import { resolveImport } from "@starci/eslint-canon-fe/lib/scope.mjs";
10
- import { hfsOf } from "@starci/eslint-canon-fe/lib/hfs.mjs";
11
- import { walk } from "@starci/eslint-canon-fe/lib/ast.mjs";
12
- import { loadArchitectureConfig } from "../../runtime/scripts/hfs/architecture/config.mjs";
13
- import { workspaceSourceEntry } from "../../runtime/scripts/hfs/architecture/typescript.mjs";
14
- import { openHfs } from "../../runtime/scripts/hfs/slots.mjs";
15
- const RUNTIME = fileURLToPath(new URL("../../runtime/", import.meta.url));
16
- const roots = new WeakMap();
17
- const origins = new WeakMap();
18
- const stateOf = (context) => {
19
- const root = hfsOf(context).repoRoot;
20
- const snapshot = origins.get(context.sourceCode) ?? context.sourceCode;
21
- let state = roots.get(snapshot);
22
- if (state === undefined) {
23
- state = { root, files: new Map(), proofs: new Map(), workspaces: null };
24
- roots.set(snapshot, state);
25
- }
26
- return state;
27
- };
28
- /** A workspace package from the text of its `package.json`. */
29
- const workspaceOf = (root, text) => {
30
- const manifest = JSON.parse(text);
31
- const record = typeof manifest === "object" && manifest !== null ? manifest : {};
32
- return {
33
- root,
34
- workspace: true,
35
- name: "name" in record && typeof record.name === "string" ? record.name : null,
36
- manifest,
37
- exports: "exports" in record ? record.exports : undefined,
38
- };
39
- };
40
- const workspaceFile = (context, source) => {
41
- const state = stateOf(context);
42
- if (!state.workspaces) {
43
- const hfs = openHfs({ root: RUNTIME, repoRoot: state.root });
44
- const config = loadArchitectureConfig(state.root, { hfs });
45
- state.workspaces = config.workspaces.map((relative) => {
46
- const root = path.join(state.root, relative);
47
- return workspaceOf(root, fs.readFileSync(path.join(root, "package.json"), "utf8"));
48
- });
49
- }
50
- const workspace = state.workspaces.find((entry) => entry.name && (source === entry.name || source.startsWith(`${entry.name}/`)));
51
- return workspace ? workspaceSourceEntry(ts, workspace, source) : null;
52
- };
53
- const sourceFile = (context, source) => {
54
- const target = resolveImport(context, source) ?? workspaceFile(context, source);
55
- if (!target)
56
- return null;
57
- const hfs = hfsOf(context);
58
- return [target, `${target}.tsx`, `${target}.ts`, `${target}/index.tsx`, `${target}/index.ts`]
59
- .find((file) => /\.[cm]?[jt]sx?$/i.test(file) && !/\.d\.[cm]?ts$/i.test(file) && ts.sys.fileExists(file) && hfs.classify(file).status === "owned") ?? null;
60
- };
61
- /** Record the parent of a child node: the parser leaves it to ESLint's traversal, which this independent parse bypasses. */
62
- const adopt = (child, parent) => {
63
- if (typeof child === "object" && child !== null && "type" in child && child.type)
64
- Reflect.set(child, "parent", parent);
65
- };
66
- const sourceContext = (context, filename) => {
67
- const state = stateOf(context);
68
- const known = state.files.get(filename);
69
- if (known)
70
- return known;
71
- const text = fs.readFileSync(filename, "utf8");
72
- const parsed = parser.parseForESLint(text, { filePath: filename, sourceType: "module", ecmaFeatures: { jsx: true }, range: true, loc: true, tokens: true, comment: true });
73
- const sourceCode = new SourceCode({
74
- text,
75
- ast: parsed.ast,
76
- scopeManager: parsed.scopeManager,
77
- visitorKeys: parsed.visitorKeys,
78
- parserServices: parsed.services,
79
- });
80
- const view = sourceCode;
81
- walk(view, parsed.ast, (node) => {
82
- for (const key of view.visitorKeys[node.type] ?? []) {
83
- const value = Reflect.get(node, key);
84
- const values = Array.isArray(value) ? value : [value];
85
- for (const child of values)
86
- adopt(child, node);
87
- }
88
- });
89
- const owned = { filename, sourceCode: view, settings: context.settings, program: parsed.ast };
90
- origins.set(view, origins.get(context.sourceCode) ?? context.sourceCode);
91
- state.files.set(filename, owned);
92
- return owned;
93
- };
94
- const moduleContext = (context, source) => {
95
- const filename = sourceFile(context, source);
96
- return filename ? sourceContext(context, filename) : null;
97
- };
98
- const namedDeclaration = (declaration, name) => {
99
- if (declaration?.type === "FunctionDeclaration")
100
- return declaration.id?.name === name ? declaration : null;
101
- if (declaration?.type !== "VariableDeclaration")
102
- return null;
103
- return declaration.declarations.find((entry) => entry.id.type === "Identifier" && entry.id.name === name)?.init ?? null;
104
- };
105
- /** The name an export specifier spells: an identifier's name or a string literal's value. */
106
- const specifierName = (name) => (name.type === "Identifier" ? name.name : name.value);
107
- const namedExport = (context, statement, name, visited) => {
108
- const value = namedDeclaration(statement.declaration, name);
109
- if (value)
110
- return { matched: true, owner: { context, value } };
111
- const specifier = statement.specifiers.find((entry) => specifierName(entry.exported) === name);
112
- if (!specifier)
113
- return { matched: false };
114
- if (!statement.source)
115
- return { matched: true, owner: { context, value: specifier.local } };
116
- const target = moduleContext(context, String(statement.source.value));
117
- return { matched: true, owner: target ? headerExport(target, specifierName(specifier.local), visited) : null };
118
- };
119
- /** The selected exported value, following public barrels without scanning unrelated imported implementations. */
120
- const headerExport = (context, name, seen = new Set()) => {
121
- const key = `${context.filename}:${name}`;
122
- if (seen.has(key))
123
- return null;
124
- const visited = new Set(seen).add(key);
125
- for (const statement of context.program.body) {
126
- if (statement.type === "ExportDefaultDeclaration" && name === "default")
127
- return { context, value: statement.declaration };
128
- if (statement.type === "ExportNamedDeclaration") {
129
- const found = namedExport(context, statement, name, visited);
130
- if (found.matched)
131
- return found.owner;
132
- }
133
- if (statement.type === "ExportAllDeclaration") {
134
- const target = moduleContext(context, String(statement.source.value));
135
- const found = target && headerExport(target, name, visited);
136
- if (found)
137
- return found;
138
- }
139
- }
140
- return null;
141
- };
142
- /** An imported JSX owner, or null when its implementation cannot be proved from owned source. */
143
- export const importedHeader = (context, opening) => {
144
- const name = opening.name;
145
- const identifier = name.type === "JSXIdentifier" ? name : name.type === "JSXMemberExpression" ? name.object : null;
146
- if (identifier?.type !== "JSXIdentifier")
147
- return null;
148
- const imported = importOf(context, identifier);
149
- if (!imported)
150
- return null;
151
- const definition = variableOf(context, identifier)?.defs.find((entry) => entry.type === "ImportBinding");
152
- if (name.type === "JSXMemberExpression" && definition?.node.type !== "ImportNamespaceSpecifier")
153
- return null;
154
- const target = moduleContext(context, imported.source);
155
- const exported = name.type === "JSXMemberExpression" ? name.property.name : imported.imported ?? "default";
156
- return target ? headerExport(target, exported) : null;
157
- };
158
- /** A file of the app parsed on its own (a route `layout`), sharing the run's parse cache. */
159
- export const parsedSource = (context, filename) => sourceContext(context, filename);
160
- /** The per-repository proof cache shares the same lifetime as parsed header source. */
161
- export const headerProofs = (context) => stateOf(context).proofs;
1
+ /** Shared selected-export parser; app-shell and Page proofs use the same owner graph. */
2
+ export { importedHeader, parsedSource, headerProofs } from "@starci/eslint-canon-fe/lib/owner-source.mjs";
@@ -7,6 +7,7 @@ import fs from "node:fs";
7
7
  import path from "node:path";
8
8
  import { walk } from "@starci/eslint-canon-fe/lib/ast.mjs";
9
9
  import { hfsOf } from "@starci/eslint-canon-fe/lib/hfs.mjs";
10
+ import { connectedPageDrawing } from "@starci/eslint-canon-fe/lib/root-page.mjs";
10
11
  import { importedHeader, parsedSource } from "./app-shell-owner-source.js";
11
12
  /** The pure half of a unit: the module its connected half draws through. */
12
13
  export const PURE_HALF = /^\.\/component(?:\.[cm]?[jt]sx?)?$/;
@@ -87,7 +88,7 @@ const blockFiles = (context, opening) => {
87
88
  * `Page`, in its connected half or in the pure half it draws through (`./component`). One level only: what the block
88
89
  * hands to other blocks is not followed.
89
90
  */
90
- export const blockDrawsPage = (context, opening) => blockFiles(context, opening)?.some((file) => pagesIn(file).length > 0) === true;
91
+ export const blockDrawsPage = (context, opening) => connectedPageDrawing(context, opening) !== null;
91
92
  /**
92
93
  * True when a unit (a layout owner) draws a `Page` whose header carries `tabs`: itself, through its pure half, or through
93
94
  * the one connected block either renders, read one level deep as for a page owner.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-grammar-core",
3
- "version": "0.21.6",
3
+ "version": "0.21.8",
4
4
  "description": "ESLint rules for the core Grammar's component, token and composition contracts.",
5
5
  "keywords": [
6
6
  "eslint",
@@ -41,7 +41,7 @@
41
41
  "node": ">=22"
42
42
  },
43
43
  "peerDependencies": {
44
- "@starci/eslint-canon-fe": "9.9.6",
44
+ "@starci/eslint-canon-fe": "9.9.8",
45
45
  "eslint": ">=9",
46
46
  "typescript": ">=5.9"
47
47
  },
@@ -68,6 +68,8 @@ families:
68
68
  package: '@starci/grammar'
69
69
  entry: '@starci/grammar/common'
70
70
  styleEntry: '@starci/grammar/common.css'
71
+ semanticRoles:
72
+ page: { export: Page, entries: ['@starci/grammar/common', '@starci/grammar/<family>'], segment: { attribute: header, member: tabs }, bodyContainers: [PaneGrid, Pane] }
71
73
  peers: [react, '@heroui/react', '@xyflow/react', react-aria-components]
72
74
  packageSnapshot: common/DNA.yaml
73
75
  scope: |
@@ -31,35 +31,35 @@ pins:
31
31
  source: packages/event-stream/package.json
32
32
  why: 'the one server-sent-events client of every front end (fe-stack event-stream, owner:event-stream-package): the transport client layer (modules/api/sse/clients) creates one instance for the app with the bearer token source and the stream operations follow on it; it carries Last-Event-ID resume, the capped doubling backoff, the heartbeat timeout, the single 401 renewal and the useSWRSubscription adapter, so no app keeps a hand-written reader.'
33
33
  '@starci/grammar':
34
- version: 0.21.6
34
+ version: 0.21.8
35
35
  group: starci
36
36
  install: registry
37
37
  side: fe
38
38
  source: packages/grammar/package.json
39
39
  why: 'the grammar front ends read: the brand layer sets `--font-sans` and `--font-mono` and the grammar reads them; it carries the Input tel kind, the copyable and read-only Input, the IconButton disclosure props and count badge, ChatBubble, FillViewport, Textarea mentions and Enter-to-send, the leading PrimaryRailLayout rail, the plate-less Image, ListRow, the soft Alert, Progress steps, the floating primary IconButton, FlowGraph, the STATE-8 loading views and the bordered selectable TagGroup chips. The runtime source version wins for a @starci package.'
40
40
  '@starci/eslint-canon-be':
41
- version: 3.11.13
41
+ version: 3.11.15
42
42
  group: starci
43
43
  install: registry
44
44
  side: be
45
45
  source: packages/eslint-canon-be/package.json
46
46
  why: 'the back-end ESLint canon: `loadHfs(import.meta.url)` of be/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the be side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; `starciBeConfig({ hfs: loadHfs(import.meta.url) })` is the typed factory and the BE-CONVENTION laws are its rules.'
47
47
  '@starci/eslint-canon-fe':
48
- version: 9.9.6
48
+ version: 9.9.8
49
49
  group: starci
50
50
  install: registry
51
51
  side: fe
52
52
  source: packages/eslint-canon-fe/package.json
53
53
  why: 'the front-end ESLint canon: `loadHfs(import.meta.url)` of fe/eslint.config.mjs finds the app-root hfs.json (kind app) and gives every linted file the view of the fe side, and the project graph is built per side; its bundled runtime copies (slots, canon-pins, failure codes, the architecture machine) put .starcistacks and .sops.yaml at the app root; the front end has no tests (FE_NO_TESTS R97 in hfs) and no-vietnamese-in-source (R91) applies.'
54
54
  '@starci/eslint-grammar-core':
55
- version: 0.21.6
55
+ version: 0.21.8
56
56
  group: starci
57
57
  install: registry
58
58
  side: fe
59
59
  source: packages/eslint-grammar-core/package.json
60
60
  why: 'the StarCi Grammar component API lint, versioned with @starci/grammar; front ends compose this family package with the universal FE canon.'
61
61
  '@starci/eslint-grammar-offset-pop':
62
- version: 0.21.6
62
+ version: 0.21.8
63
63
  group: starci
64
64
  install: registry
65
65
  side: fe
@@ -106,7 +106,7 @@ pins:
106
106
  source: packages/ai-router/package.json
107
107
  why: 'the AI pool router of a back end: a NestJS module that routes OpenAI-compatible chat, stream and embeddings calls across keys, models and providers, with @starci/ai-router/testing for its specs; @starci/jest-preset compiles it as an ESM-only dependency.'
108
108
  '@starci/hfs':
109
- version: 5.0.2
109
+ version: 5.0.4
110
110
  group: starci
111
111
  install: registry
112
112
  side: both