@starci/eslint-canon-be 3.11.9 → 3.11.13

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,7 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.11.13
4
+
5
+ - 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.
6
+
3
7
  ## Unreleased
4
8
 
9
+ ## 3.11.12 - 2026-11-02
10
+
11
+ - Fixed: unit-spec subject discovery resolves callable re-exports through the canonical HFS provenance owner, including namespace and renamed exports, without relaxing real subject invocation requirements.
12
+ - Changed: bundled pins follow HFS 5.0.1 and the coherent canon cohort.
13
+
14
+ ## 3.11.11 - 2026-11-02
15
+
16
+ - Changed: refreshed bundled canonical pins for the HFS 5.0.0 CLI selector cohort; the Grammar component runtime stays at 0.21.3.
17
+ - Fixed: TypeORM read-query selectors retain their query shape instead of being treated as entity row fixtures; actual entity and partial row literals remain checked.
18
+
19
+ ## 3.11.10 - 2026-11-02
20
+
21
+ - Changed: bundled canonical pins follow the consolidated Grammar 0.21.3 preservation API cohort; runtime rules are unchanged.
22
+
5
23
  ## 3.11.9 - 2026-11-02
6
24
 
7
25
  - Changed: bundled pins follow Grammar 0.21.2 with disabled tab items and its coherent canon cohort; existing runtime checks are unchanged.
package/dist/builders.js CHANGED
@@ -76,12 +76,37 @@ const isEntityClass = (checker, declaration) => {
76
76
  return (target?.getDeclarations?.() ?? []).some((found) => moduleOf(found, String(found.getSourceFile().fileName).replace(/\\/g, "/")) === "typeorm");
77
77
  });
78
78
  };
79
- /** The entity class declarations a type stands for: itself, a union member, or the argument of a `Partial<Entity>` style alias. */
79
+ /** A TypeORM FindOptions contract selects rows; its entity argument does not turn the selector into a row. */
80
+ const isFindOptionsDeclaration = (checker, declaration, seen) => {
81
+ if (seen.has(declaration))
82
+ return false;
83
+ seen.add(declaration);
84
+ const file = String(declaration.getSourceFile().fileName).replace(/\\/g, "/");
85
+ if ((ts.isTypeAliasDeclaration(declaration) || ts.isInterfaceDeclaration(declaration)) && declaration.name.text.startsWith("FindOptions") && moduleOf(declaration, file) === "typeorm")
86
+ return true;
87
+ if (!ts.isTypeAliasDeclaration(declaration))
88
+ return false;
89
+ const selectorReference = (node) => {
90
+ if (ts.isParenthesizedTypeNode(node))
91
+ return selectorReference(node.type);
92
+ if (ts.isUnionTypeNode(node) || ts.isIntersectionTypeNode(node))
93
+ return node.types.some(selectorReference);
94
+ if (!ts.isTypeReferenceNode(node))
95
+ return false;
96
+ const symbol = checker.getSymbolAtLocation(node.typeName);
97
+ if (!symbol)
98
+ return false;
99
+ return (resolvedSymbol(checker, symbol)?.getDeclarations() ?? []).some(found => isFindOptionsDeclaration(checker, found, seen));
100
+ };
101
+ return selectorReference(declaration.type);
102
+ };
103
+ const isFindOptionsType = (checker, type) => [type.aliasSymbol, type.getSymbol()].some(symbol => (symbol?.getDeclarations() ?? []).some(declaration => isFindOptionsDeclaration(checker, declaration, new Set())));
104
+ /** Entity rows, including partial row aliases; read selectors retain their distinct TypeORM contract through local aliases. */
80
105
  const entityClassesOf = (checker, type) => {
81
106
  if (!type)
82
107
  return [];
83
108
  const parts = type.isUnion?.() ? type.types : [type];
84
- const candidates = parts.flatMap((part) => [part, ...(part.aliasTypeArguments ?? [])]);
109
+ const candidates = parts.filter(part => !isFindOptionsType(checker, part)).flatMap((part) => [part, ...(part.aliasTypeArguments ?? [])]);
85
110
  return candidates.flatMap((candidate) => (candidate.getSymbol?.()?.getDeclarations?.() ?? []).filter((declaration) => isEntityClass(checker, declaration)));
86
111
  };
87
112
  /** A spec builds each persistence entity as an object literal at most once; further rows come from a builder. */
@@ -15,16 +15,16 @@ const realSubjectFunction = (context, value) => {
15
15
  const tsNode = toTs(value);
16
16
  const symbol = ts.isShorthandPropertyAssignment(tsNode.parent)
17
17
  ? checker.getShorthandAssignmentValueSymbol(tsNode.parent) : checker.getSymbolAtLocation(tsNode);
18
- const alias = symbol?.declarations?.some(declaration => ts.isImportSpecifier(declaration));
19
- const target = alias && symbol ? checker.getAliasedSymbol(symbol) : symbol;
20
- const declaration = target?.valueDeclaration;
21
- if (!declaration)
18
+ const declaration = symbol?.declarations?.find(ts.isImportSpecifier);
19
+ if (!declaration || declaration.isTypeOnly || declaration.parent.parent.isTypeOnly)
22
20
  return null;
23
- const sourceFile = declaration.getSourceFile();
21
+ const importedModule = checker.getSymbolAtLocation(declaration.parent.parent.parent.moduleSpecifier);
24
22
  const sibling = (context.filename || context.getFilename()).replace(/\.spec\.ts$/u, ".ts");
25
- if (path.resolve(sourceFile.fileName) !== path.resolve(sibling))
23
+ const sourceFile = importedModule?.declarations?.find((candidate) => ts.isSourceFile(candidate)
24
+ && path.resolve(candidate.fileName) === path.resolve(sibling));
25
+ if (!sourceFile)
26
26
  return null;
27
- const names = functionSubjectExports(ts, sourceFile);
27
+ const names = functionSubjectExports(ts, sourceFile, checker);
28
28
  return imported.imported !== null && names?.includes(imported.imported) ? imported.imported : null;
29
29
  };
30
30
  const VALUE_OBJECTS = new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@starci/eslint-canon-be",
3
- "version": "3.11.9",
3
+ "version": "3.11.13",
4
4
  "description": "The StarCi back-end lint canon: every rule its laws publish, gathered as one flat-config plugin.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -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.2
34
+ version: 0.21.6
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.9
41
+ version: 3.11.13
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.2
48
+ version: 9.9.6
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.2
55
+ version: 0.21.6
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.2
62
+ version: 0.21.6
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: 4.17.2
109
+ version: 5.0.2
110
110
  group: starci
111
111
  install: registry
112
112
  side: both
@@ -17,7 +17,7 @@ function importBindings(ts, scope, statement) {
17
17
  return;
18
18
  const module = statement.moduleSpecifier.text;
19
19
  if (clause.name)
20
- scope.bindings.set(clause.name.text, { kind: 'component' });
20
+ scope.bindings.set(clause.name.text, { kind: 'component', module, name: 'default' });
21
21
  const named = clause.namedBindings;
22
22
  if (!named)
23
23
  return;
@@ -28,8 +28,9 @@ function importBindings(ts, scope, statement) {
28
28
  if (element.isTypeOnly)
29
29
  continue;
30
30
  const imported = element.propertyName?.text ?? element.name.text;
31
- const kind = TRANSLATION_MODULES.has(module) && TRANSLATION_FACTORIES.has(imported) ? 'translation-factory' : 'component';
32
- scope.bindings.set(element.name.text, { kind });
31
+ const binding = TRANSLATION_MODULES.has(module) && TRANSLATION_FACTORIES.has(imported)
32
+ ? { kind: 'translation-factory' } : { kind: 'component', module, name: imported };
33
+ scope.bindings.set(element.name.text, binding);
33
34
  }
34
35
  }
35
36
  function lexicalBindings(ts, sourceFile) {
@@ -151,12 +152,55 @@ function nestedDataObjects(ts, expression, bindingOf, excluded) {
151
152
  nestedDataObjects(ts, element, bindingOf, excluded);
152
153
  }
153
154
  }
155
+ /** Resolve the canonical status owner through its import binding, including aliases and namespaces. */
156
+ function statusOwner(ts, tag, bindingOf) {
157
+ const binding = ts.isIdentifier(tag) ? bindingOf(tag) : ts.isPropertyAccessExpression(tag) && ts.isIdentifier(tag.expression) ? bindingOf(tag.expression) : null;
158
+ const module = binding?.kind === 'component' || binding?.kind === 'namespace' ? binding.module : null;
159
+ const name = binding?.kind === 'component' ? binding.name : ts.isPropertyAccessExpression(tag) ? tag.name.text : null;
160
+ return name === 'SlotView' && module !== null && /(?:^|\/)components\/composites\/SlotView(?:\/index)?(?:\.[cm]?tsx?)?$/.test(module);
161
+ }
162
+ /** The mandated status wiring breaks clone windows; its render body remains ordinary compared code. */
163
+ function statusRecipe(ts, opening, bindingOf, excluded) {
164
+ if (!statusOwner(ts, opening.tagName, bindingOf))
165
+ return;
166
+ const attributes = opening.attributes.properties;
167
+ const render = attributes.find(attribute => ts.isJsxAttribute(attribute) && ts.isIdentifier(attribute.name) && attribute.name.text === 'render');
168
+ const value = render && ts.isJsxAttribute(render) && render.initializer && ts.isJsxExpression(render.initializer) ? unwrap(ts, render.initializer.expression) : undefined;
169
+ if (!value || !ts.isArrowFunction(value) || value.parameters.length !== 2 || ts.isBlock(value.body))
170
+ return;
171
+ const waiting = value.parameters[1];
172
+ if (!waiting || !ts.isIdentifier(waiting.name) || waiting.initializer || waiting.dotDotDotToken)
173
+ return;
174
+ const waitingBinding = bindingOf(waiting.name);
175
+ let forwardsLoading = false;
176
+ const visit = (node) => {
177
+ if (ts.isJsxAttribute(node) && ts.isIdentifier(node.name) && node.name.text === 'isLoading'
178
+ && node.initializer && ts.isJsxExpression(node.initializer)) {
179
+ const flag = unwrap(ts, node.initializer.expression);
180
+ if (flag && ts.isIdentifier(flag) && waitingBinding && bindingOf(flag) === waitingBinding)
181
+ forwardsLoading = true;
182
+ }
183
+ ts.forEachChild(node, visit);
184
+ };
185
+ visit(value.body);
186
+ if (!forwardsLoading)
187
+ return;
188
+ const wiring = attributes.filter(attribute => ts.isJsxSpreadAttribute(attribute) ? dataMapping(ts, attribute.expression, bindingOf)
189
+ : ts.isIdentifier(attribute.name) && ['slot', 'placeholder', 'labels', 'onRetry'].includes(attribute.name.text)
190
+ && !!attribute.initializer && ts.isJsxExpression(attribute.initializer) && dataMapping(ts, attribute.initializer.expression, bindingOf));
191
+ const hasSlot = wiring.some(attribute => ts.isJsxSpreadAttribute(attribute) || ts.isJsxAttribute(attribute) && ts.isIdentifier(attribute.name) && attribute.name.text === 'slot');
192
+ if (!hasSlot)
193
+ return;
194
+ for (const attribute of wiring)
195
+ excluded.add(attribute);
196
+ }
154
197
  /** Canon data prop objects qualify through an imported component binding, never its chosen name or file path. */
155
198
  export function canonJsxCloneNodes(ts, sourceFile) {
156
199
  const bindingOf = lexicalBindings(ts, sourceFile);
157
200
  const excluded = new Set();
158
201
  const visit = (node) => {
159
202
  if ((ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node)) && importedComponent(ts, node.tagName, bindingOf)) {
203
+ statusRecipe(ts, node, bindingOf, excluded);
160
204
  for (const attribute of node.attributes.properties) {
161
205
  if (!ts.isJsxAttribute(attribute) || !attribute.initializer || !ts.isJsxExpression(attribute.initializer))
162
206
  continue;
@@ -203,6 +203,9 @@ function signatureParameterStatus(ts, checker, signature, location, parameter, s
203
203
  const actual = parameterSymbol ? checker.getTypeOfSymbolAtLocation(parameterSymbol, location) : null;
204
204
  if (actual && parameter.questionToken && !ts.isUnionTypeNode(parameter.type) && hasAnyFlag(actual.flags, ts.TypeFlags.Union)) {
205
205
  const selected = actual.types.filter((type) => !hasAnyFlag(type.flags, ts.TypeFlags.Undefined));
206
+ // An optional boolean is represented as true | false | undefined, not one Boolean member.
207
+ if (selected.length > 0 && selected.every((type) => hasAnyFlag(type.flags, ts.TypeFlags.BooleanLike)))
208
+ return 'scalar';
206
209
  return selected.length === 1 ? contractTypeStatusFromType(ts, checker, selected[0]) : 'inline';
207
210
  }
208
211
  return actual ? contractTypeStatusFromType(ts, checker, actual) : contractTypeStatus(ts, checker, parameter.type);
@@ -1,4 +1,5 @@
1
1
  import path from 'node:path';
2
+ import { normalizedSymbol } from './ast-walks.mjs';
2
3
  export const keyOf = (ts, property) => (ts.isPropertyAssignment(property) || ts.isShorthandPropertyAssignment(property)) && (ts.isIdentifier(property.name) || ts.isStringLiteralLike(property.name)) ? property.name.text : null;
3
4
  const exported = (ts, statement) => statement.modifiers?.some(modifier => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;
4
5
  /** The directly defined functions among the declarations of an exported variable statement; other values are not callable. */
@@ -19,17 +20,30 @@ function callableExports(ts, statement) {
19
20
  return statement.name && statement.body ? [statement.name.text] : [];
20
21
  return ts.isVariableStatement(statement) ? callableVariables(ts, statement) : [];
21
22
  }
23
+ /** Named value re-exports count only when the checker resolves an actual function implementation. */
24
+ function callableReexports(ts, checker, statement) {
25
+ if (!ts.isExportDeclaration(statement) || statement.isTypeOnly || !statement.exportClause || !ts.isNamedExports(statement.exportClause))
26
+ return [];
27
+ return statement.exportClause.elements.filter(element => !element.isTypeOnly && (normalizedSymbol(ts, checker, element.name)?.declarations ?? []).some(declaration => {
28
+ if (declaration.getSourceFile().isDeclarationFile)
29
+ return false;
30
+ if (ts.isFunctionDeclaration(declaration))
31
+ return Boolean(declaration.body);
32
+ return ts.isVariableDeclaration(declaration) && Boolean(declaration.initializer
33
+ && (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)));
34
+ })).map(element => element.name.text);
35
+ }
22
36
  /**
23
- * The callable subset of a function subject's exports. Constants, enums, objects, types, `export ... from` re-exports and overload
24
- * signatures do not change which functions the spec must provide; a class or a default-export assignment keeps the class-provider
25
- * check (null), as does a module with no callable export.
37
+ * The callable subset of a function subject's exports, including named re-exports resolved to real implementations. Constants,
38
+ * enums, objects, type-only exports and bodyless declarations do not count; a class or a default-export assignment keeps the
39
+ * class-provider check (null), as does a module with no callable export.
26
40
  */
27
- export function functionSubjectExports(ts, sourceFile) {
41
+ export function functionSubjectExports(ts, sourceFile, checker) {
28
42
  const names = [];
29
43
  for (const statement of sourceFile.statements) {
30
44
  if (ts.isClassDeclaration(statement) || ts.isExportAssignment(statement))
31
45
  return null;
32
- for (const name of callableExports(ts, statement))
46
+ for (const name of [...callableExports(ts, statement), ...callableReexports(ts, checker, statement)])
33
47
  if (!names.includes(name))
34
48
  names.push(name);
35
49
  }
@@ -18,7 +18,7 @@ import { checkFunctionSubject, functionSubjectExports, keyOf as literalKey, valu
18
18
  * constructor-deps.mjs). Providers are matched by the exported name of the imported binding (`import { CACHE as C }` is
19
19
  * CACHE), never by text. A provider is a class, or `{ provide: TOKEN, useValue: double }` and nothing else. A sibling
20
20
  * containing only exported functions instead provides its complete real function object and exercises it through module.get;
21
- * the constants, enums, re-exports and overload signatures beside those functions do not count. A value-object subject (an
21
+ * callable named re-exports count, while constants, enums, type-only exports and overload signatures do not. A value-object subject (an
22
22
  * undecorated class whose constructor parameters carry no injection token) is built with `new`, Nest never constructs it.
23
23
  *
24
24
  * Findings: an extra provider, a missing provider, a service that is not the first provider, a dependency whose token cannot
@@ -111,7 +111,7 @@ function checkTestingModule({ ts, kit, rel, serviceRel, serviceFile, imports, ca
111
111
  const list = providerList(ts, call, rel, report);
112
112
  if (!list)
113
113
  return;
114
- const names = functionSubjectExports(ts, serviceFile.sourceFile);
114
+ const names = functionSubjectExports(ts, serviceFile.sourceFile, kit.checkerOf(serviceFile.sourceFile));
115
115
  if (names) {
116
116
  checkFunctionSubject({ ts, rel, serviceRel, imports, call, list, names, report });
117
117
  return;