@starci/eslint-canon-be 3.8.20 → 3.9.2

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 (164) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/package.json +1 -1
  3. package/runtime/bundle.json +192 -0
  4. package/runtime/engine/by-code-unit.mjs +6 -6
  5. package/runtime/engine/model-config.mjs +98 -76
  6. package/runtime/engine/orca-config.mjs +22 -17
  7. package/runtime/engine/release-config.mjs +22 -18
  8. package/runtime/engine/removed-vocabulary.mjs +21 -20
  9. package/runtime/engine/resources-config.mjs +42 -35
  10. package/runtime/engine/runtime-root.mjs +11 -13
  11. package/runtime/engine/secrets.mjs +170 -102
  12. package/runtime/engine/sonar-config.mjs +16 -13
  13. package/runtime/engine/temp-root.mjs +3 -9
  14. package/runtime/knowledge/hfs/canon-pins.yaml +10 -10
  15. package/runtime/knowledge/hfs/rules.yaml +6 -6
  16. package/runtime/knowledge/hfs/slots.yaml +2 -2
  17. package/runtime/knowledge/sonar-gate.yaml +1 -1
  18. package/runtime/packages/hfs/templates/app/package-scripts/package.json +1 -1
  19. package/runtime/scripts/api/git/cat-file.mjs +0 -1
  20. package/runtime/scripts/api/git/config-get.mjs +1 -2
  21. package/runtime/scripts/api/git/diff.mjs +0 -1
  22. package/runtime/scripts/api/git/lib.mjs +32 -32
  23. package/runtime/scripts/api/git/ls-files.mjs +0 -1
  24. package/runtime/scripts/api/git/ls-tree.mjs +0 -1
  25. package/runtime/scripts/api/git/merge-base.mjs +2 -3
  26. package/runtime/scripts/api/git/remote.mjs +0 -1
  27. package/runtime/scripts/api/git/rev-parse-query.mjs +0 -1
  28. package/runtime/scripts/api/git/show.mjs +0 -1
  29. package/runtime/scripts/hfs/allows.mjs +37 -38
  30. package/runtime/scripts/hfs/architecture/ast-walks.mjs +180 -163
  31. package/runtime/scripts/hfs/architecture/automatic-gates.mjs +80 -73
  32. package/runtime/scripts/hfs/architecture/backend-app-files.mjs +88 -77
  33. package/runtime/scripts/hfs/architecture/backend.mjs +378 -357
  34. package/runtime/scripts/hfs/architecture/background-unowned.mjs +201 -187
  35. package/runtime/scripts/hfs/architecture/canon-clones.mjs +260 -209
  36. package/runtime/scripts/hfs/architecture/canon-jsx-clones.mjs +149 -116
  37. package/runtime/scripts/hfs/architecture/client-reaches-server.mjs +72 -68
  38. package/runtime/scripts/hfs/architecture/clones.mjs +212 -217
  39. package/runtime/scripts/hfs/architecture/config-unread.mjs +7 -9
  40. package/runtime/scripts/hfs/architecture/config.mjs +302 -268
  41. package/runtime/scripts/hfs/architecture/connection-map.mjs +258 -225
  42. package/runtime/scripts/hfs/architecture/constructor-deps.mjs +80 -71
  43. package/runtime/scripts/hfs/architecture/context-coupling.mjs +82 -77
  44. package/runtime/scripts/hfs/architecture/context-map.mjs +267 -234
  45. package/runtime/scripts/hfs/architecture/context-owner.mjs +73 -61
  46. package/runtime/scripts/hfs/architecture/context-platform-tables.mjs +47 -43
  47. package/runtime/scripts/hfs/architecture/context-transaction.mjs +54 -52
  48. package/runtime/scripts/hfs/architecture/contract-fixture-guard.mjs +113 -104
  49. package/runtime/scripts/hfs/architecture/contracts-readonly.mjs +288 -270
  50. package/runtime/scripts/hfs/architecture/contracts.mjs +408 -393
  51. package/runtime/scripts/hfs/architecture/cross-app-duplicate.mjs +50 -51
  52. package/runtime/scripts/hfs/architecture/dead-exports-bindings.mjs +143 -119
  53. package/runtime/scripts/hfs/architecture/dead-exports.mjs +286 -228
  54. package/runtime/scripts/hfs/architecture/default-deny.mjs +129 -110
  55. package/runtime/scripts/hfs/architecture/doc-language.mjs +24 -19
  56. package/runtime/scripts/hfs/architecture/entity-registry.mjs +20 -22
  57. package/runtime/scripts/hfs/architecture/entrypoint.mjs +47 -45
  58. package/runtime/scripts/hfs/architecture/error-codes.mjs +37 -35
  59. package/runtime/scripts/hfs/architecture/error-masked.mjs +55 -59
  60. package/runtime/scripts/hfs/architecture/fe-slot-allows.mjs +24 -23
  61. package/runtime/scripts/hfs/architecture/feature-shape.mjs +40 -38
  62. package/runtime/scripts/hfs/architecture/framework-pinned.mjs +21 -21
  63. package/runtime/scripts/hfs/architecture/frontend-block-render.mjs +106 -98
  64. package/runtime/scripts/hfs/architecture/frontend-grammar.mjs +153 -150
  65. package/runtime/scripts/hfs/architecture/frontend-routing.mjs +161 -149
  66. package/runtime/scripts/hfs/architecture/frontend-world-render.mjs +343 -305
  67. package/runtime/scripts/hfs/architecture/frontend-world.mjs +340 -294
  68. package/runtime/scripts/hfs/architecture/frontend.mjs +174 -184
  69. package/runtime/scripts/hfs/architecture/function-spec-providers.mjs +124 -106
  70. package/runtime/scripts/hfs/architecture/hfs-graph.mjs +52 -48
  71. package/runtime/scripts/hfs/architecture/hooks-are-hooks.mjs +81 -71
  72. package/runtime/scripts/hfs/architecture/i18n-keys.mjs +155 -141
  73. package/runtime/scripts/hfs/architecture/identity.mjs +141 -125
  74. package/runtime/scripts/hfs/architecture/index.mjs +272 -272
  75. package/runtime/scripts/hfs/architecture/injection-token-exported.mjs +45 -43
  76. package/runtime/scripts/hfs/architecture/jwt-ast.mjs +195 -176
  77. package/runtime/scripts/hfs/architecture/machine-ast.mjs +163 -155
  78. package/runtime/scripts/hfs/architecture/managed-scripts.mjs +19 -20
  79. package/runtime/scripts/hfs/architecture/module-per-transport.mjs +177 -172
  80. package/runtime/scripts/hfs/architecture/next-data-contract.mjs +100 -78
  81. package/runtime/scripts/hfs/architecture/next-data-inference.mjs +170 -154
  82. package/runtime/scripts/hfs/architecture/next-data-key.mjs +311 -275
  83. package/runtime/scripts/hfs/architecture/next-data-symbols.mjs +17 -17
  84. package/runtime/scripts/hfs/architecture/next-data.mjs +351 -334
  85. package/runtime/scripts/hfs/architecture/operation-contract-roots.mjs +39 -37
  86. package/runtime/scripts/hfs/architecture/owners.mjs +97 -98
  87. package/runtime/scripts/hfs/architecture/package-shape.mjs +56 -55
  88. package/runtime/scripts/hfs/architecture/presentation.mjs +138 -130
  89. package/runtime/scripts/hfs/architecture/reachability.mjs +258 -241
  90. package/runtime/scripts/hfs/architecture/register-once.mjs +152 -139
  91. package/runtime/scripts/hfs/architecture/registration.mjs +301 -267
  92. package/runtime/scripts/hfs/architecture/required-files.mjs +172 -167
  93. package/runtime/scripts/hfs/architecture/route-files-thin.mjs +85 -77
  94. package/runtime/scripts/hfs/architecture/schema-owner.mjs +206 -181
  95. package/runtime/scripts/hfs/architecture/server-action.mjs +48 -48
  96. package/runtime/scripts/hfs/architecture/side-boundary.mjs +2 -5
  97. package/runtime/scripts/hfs/architecture/source-names-shape.mjs +261 -259
  98. package/runtime/scripts/hfs/architecture/source-names.mjs +304 -278
  99. package/runtime/scripts/hfs/architecture/sql-keys.mjs +277 -194
  100. package/runtime/scripts/hfs/architecture/sql-owner.mjs +236 -194
  101. package/runtime/scripts/hfs/architecture/sql-returning.mjs +46 -45
  102. package/runtime/scripts/hfs/architecture/sql-token-forms.mjs +86 -74
  103. package/runtime/scripts/hfs/architecture/sql-tokens.mjs +456 -341
  104. package/runtime/scripts/hfs/architecture/staged-consumers.mjs +35 -30
  105. package/runtime/scripts/hfs/architecture/surface.mjs +64 -74
  106. package/runtime/scripts/hfs/architecture/symbols.mjs +209 -216
  107. package/runtime/scripts/hfs/architecture/test-world-files.mjs +165 -155
  108. package/runtime/scripts/hfs/architecture/tiers.mjs +161 -154
  109. package/runtime/scripts/hfs/architecture/transport-owner.mjs +155 -149
  110. package/runtime/scripts/hfs/architecture/type-context.mjs +255 -250
  111. package/runtime/scripts/hfs/architecture/typescript.mjs +358 -318
  112. package/runtime/scripts/hfs/architecture/unit-spec-providers.mjs +110 -92
  113. package/runtime/scripts/hfs/declaration-shape.mjs +140 -103
  114. package/runtime/scripts/hfs/declaration-slots.mjs +64 -61
  115. package/runtime/scripts/hfs/edition-slots.mjs +43 -40
  116. package/runtime/scripts/hfs/linear-text.mjs +20 -20
  117. package/runtime/scripts/hfs/param-names.mjs +6 -11
  118. package/runtime/scripts/hfs/path-findings.mjs +120 -100
  119. package/runtime/scripts/hfs/repo-identity.mjs +55 -42
  120. package/runtime/scripts/hfs/rule-catalog.mjs +353 -257
  121. package/runtime/scripts/hfs/rule-params-shape.mjs +60 -47
  122. package/runtime/scripts/hfs/rules/database-migrations.mjs +428 -388
  123. package/runtime/scripts/hfs/rules/fe-no-tests.mjs +37 -36
  124. package/runtime/scripts/hfs/rules/read.mjs +19 -15
  125. package/runtime/scripts/hfs/rules/secrets.mjs +1 -1
  126. package/runtime/scripts/hfs/rules/spec-placement.mjs +12 -13
  127. package/runtime/scripts/hfs/slot-app-view.mjs +69 -74
  128. package/runtime/scripts/hfs/slot-classify.mjs +42 -38
  129. package/runtime/scripts/hfs/slot-errors.mjs +8 -7
  130. package/runtime/scripts/hfs/slot-imports.mjs +70 -63
  131. package/runtime/scripts/hfs/slot-manifest-shape.mjs +74 -52
  132. package/runtime/scripts/hfs/slot-match.mjs +122 -111
  133. package/runtime/scripts/hfs/slot-path.mjs +0 -2
  134. package/runtime/scripts/hfs/slot-required.mjs +65 -59
  135. package/runtime/scripts/hfs/slot-semantic-problems.mjs +138 -112
  136. package/runtime/scripts/hfs/slot-side-problems.mjs +23 -19
  137. package/runtime/scripts/hfs/slots.mjs +175 -152
  138. package/runtime/scripts/hfs/test-world-slot.mjs +0 -1
  139. package/runtime/scripts/hfs/trailing-slashes.mjs +4 -4
  140. package/runtime/scripts/hfs/typescript-programs.mjs +66 -69
  141. package/runtime/scripts/hfs/view.mjs +38 -40
  142. package/runtime/scripts/lib/dockerfile.mjs +131 -114
  143. package/runtime/scripts/lib/env.mjs +3 -6
  144. package/runtime/scripts/lib/event-contract.mjs +73 -78
  145. package/runtime/scripts/lib/git.mjs +15 -16
  146. package/runtime/scripts/lib/glob.mjs +23 -14
  147. package/runtime/scripts/lib/grammar-lint.mjs +33 -37
  148. package/runtime/scripts/lib/i18n.mjs +32 -35
  149. package/runtime/scripts/lib/in-order.mjs +57 -38
  150. package/runtime/scripts/lib/json-clone.mjs +45 -36
  151. package/runtime/scripts/lib/json.mjs +26 -14
  152. package/runtime/scripts/lib/language.mjs +133 -129
  153. package/runtime/scripts/lib/list.mjs +9 -14
  154. package/runtime/scripts/lib/mutation-fence.mjs +10 -5
  155. package/runtime/scripts/lib/path-key.mjs +53 -38
  156. package/runtime/scripts/lib/read-text.mjs +30 -17
  157. package/runtime/scripts/lib/regex.mjs +1 -2
  158. package/runtime/scripts/lib/same-text.mjs +0 -1
  159. package/runtime/scripts/lib/sops-envelope.mjs +148 -120
  160. package/runtime/scripts/lib/stack-services.mjs +128 -129
  161. package/runtime/scripts/lib/ts-analysis.mjs +28 -26
  162. package/runtime/scripts/lib/ts-ast.mjs +36 -42
  163. package/runtime/scripts/lib/walk.mjs +33 -27
  164. package/runtime/scripts/lib/yaml-cached.mjs +4 -4
@@ -7,322 +7,368 @@ const WORLD_INTL_CALLS = new Set(['useLocale', 'useMessages', 'useNow', 'useTime
7
7
  const WORLD_SWR_CALLS = new Set(['default', 'useSWR', 'useSWRConfig', 'useSWRImmutable', 'useSWRMutation']);
8
8
  const LOWER_COMPONENT_TIERS = new Set(['composites', 'branches', 'leaves']);
9
9
  function selectedSymbol(ts, checker, expression) {
10
- const selected = unwrapExpression(ts, expression);
11
- if (!selected) return null;
12
- if (ts.isIdentifier(selected)) return checker.getSymbolAtLocation(selected) ?? null;
13
- if (ts.isPropertyAccessExpression(selected)) return checker.getSymbolAtLocation(selected.name) ?? null;
14
- if (ts.isElementAccessExpression(selected) && ts.isStringLiteralLike(selected.argumentExpression)) {
15
- return checker.getSymbolAtLocation(selected.argumentExpression)
16
- ?? checker.getTypeAtLocation(selected.expression).getProperty(selected.argumentExpression.text)
17
- ?? null;
18
- }
19
- return null;
10
+ const selected = unwrapExpression(ts, expression);
11
+ if (!selected)
12
+ return null;
13
+ if (ts.isIdentifier(selected))
14
+ return checker.getSymbolAtLocation(selected) ?? null;
15
+ if (ts.isPropertyAccessExpression(selected))
16
+ return checker.getSymbolAtLocation(selected.name) ?? null;
17
+ if (ts.isElementAccessExpression(selected) && ts.isStringLiteralLike(selected.argumentExpression)) {
18
+ return checker.getSymbolAtLocation(selected.argumentExpression)
19
+ ?? checker.getTypeAtLocation(selected.expression).getProperty(selected.argumentExpression.text)
20
+ ?? null;
21
+ }
22
+ return null;
20
23
  }
21
-
22
24
  /* The wider boundary set: `ts.isFunctionLike` (includes call signatures' declarations) rather than the
23
25
  * four default callable kinds. */
24
26
  const returnedExpressions = (ts, declaration) => sharedReturnedExpressions(ts, declaration, { functionLike: ts.isFunctionLike });
25
-
26
27
  function knownWorldImport(specifier, imported) {
27
- if (specifier === 'next-intl') return WORLD_INTL_CALLS.has(imported);
28
- if (specifier === 'next/navigation' || /(?:^|\/)i18n\/navigation$/.test(specifier)) return WORLD_NAVIGATION_CALLS.has(imported);
29
- if (specifier === 'swr' || specifier === 'swr/immutable' || specifier === 'swr/mutation') return WORLD_SWR_CALLS.has(imported);
30
- if (specifier === 'next-auth/react') return imported === 'useSession';
31
- return false;
28
+ if (specifier === 'next-intl')
29
+ return WORLD_INTL_CALLS.has(imported);
30
+ if (specifier === 'next/navigation' || /(?:^|\/)i18n\/navigation$/.test(specifier))
31
+ return WORLD_NAVIGATION_CALLS.has(imported);
32
+ if (specifier === 'swr' || specifier === 'swr/immutable' || specifier === 'swr/mutation')
33
+ return WORLD_SWR_CALLS.has(imported);
34
+ if (specifier === 'next-auth/react')
35
+ return imported === 'useSession';
36
+ return false;
32
37
  }
33
-
34
38
  class WorldAnalysis {
35
- constructor(config, context, roots, helpers) {
36
- this.config = config;
37
- this.context = context;
38
- this.roots = roots;
39
- this.ts = context.ts;
40
- Object.assign(this, helpers);
41
- this.violations = [];
42
- this.sourceSet = new Set(context.files.map(source => path.resolve(source.fileName)));
43
- this.worldInfoCache = new Map();
44
- this.functionWorldCache = new Map();
45
- this.renderOutputCache = new Map();
46
- this.intrinsicUiHookCache = new Map();
47
- this.renderer = new WorldRenderAnalysis(this, { selectedSymbol, returnedExpressions });
48
- }
49
-
50
- forbiddenIntrinsicEdge(edge, nextVisiting) {
51
- const forbidden = reachableViolation(this.context.edges, edge, target => this.insideAny(this.roots.transport, target)
52
- || this.insideAny(this.roots.modules, target) || this.insideAny(this.roots.features, target) || this.insideAny(this.roots.routes, target)
53
- || (this.insideAny(this.roots.hooks, target) && relativePath(this.rootFor(this.roots.hooks, target), target).split('/')[0] !== 'ui'),
54
- { follow: candidate => candidate.runtime });
55
- return Boolean(forbidden || (this.insideAny(this.roots.hooks, edge.to) && !this.intrinsicUiHookFile(edge.to, nextVisiting)));
56
- }
57
-
58
- forbiddenWorldImport(statement) {
59
- if (!this.ts.isImportDeclaration(statement) || !statement.importClause || statement.importClause.isTypeOnly
60
- || !this.ts.isStringLiteralLike(statement.moduleSpecifier)) return false;
61
- const specifier = statement.moduleSpecifier.text;
62
- const bindings = [];
63
- if (statement.importClause.name) bindings.push('default');
64
- const named = statement.importClause.namedBindings;
65
- if (named && this.ts.isNamespaceImport(named)
66
- && ['next/navigation', 'next-intl', 'swr', 'swr/immutable', 'swr/mutation', 'next-auth/react'].includes(specifier)) return true;
67
- if (named && this.ts.isNamedImports(named)) {
68
- for (const element of named.elements) if (!element.isTypeOnly) bindings.push(element.propertyName?.text ?? element.name.text);
39
+ config;
40
+ context;
41
+ roots;
42
+ ts;
43
+ violations;
44
+ sourceSet;
45
+ worldInfoCache;
46
+ functionWorldCache;
47
+ renderOutputCache;
48
+ intrinsicUiHookCache;
49
+ renderer;
50
+ constructor(config, context, roots, helpers) {
51
+ this.config = config;
52
+ this.context = context;
53
+ this.roots = roots;
54
+ this.ts = context.ts;
55
+ Object.assign(this, helpers);
56
+ this.violations = [];
57
+ this.sourceSet = new Set(context.files.map(source => path.resolve(source.fileName)));
58
+ this.worldInfoCache = new Map();
59
+ this.functionWorldCache = new Map();
60
+ this.renderOutputCache = new Map();
61
+ this.intrinsicUiHookCache = new Map();
62
+ this.renderer = new WorldRenderAnalysis(this, { selectedSymbol, returnedExpressions });
69
63
  }
70
- return bindings.some(imported => knownWorldImport(specifier, imported));
71
- }
72
-
73
- containsUnshadowedFetch(sourceFile, checker) {
74
- let found = false;
75
- const visit = node => {
76
- if (!found && this.ts.isCallExpression(node) && this.ts.isIdentifier(node.expression) && node.expression.text === 'fetch'
77
- && (checker.getSymbolAtLocation(node.expression)?.getDeclarations() ?? []).every(declaration => declaration.getSourceFile().isDeclarationFile)) found = true;
78
- if (!found) this.ts.forEachChild(node, visit);
79
- };
80
- visit(sourceFile);
81
- return found;
82
- }
83
-
84
- intrinsicUiHookFile(fileName, visiting = new Set()) {
85
- const resolved = path.resolve(fileName);
86
- if (this.intrinsicUiHookCache.has(resolved)) return this.intrinsicUiHookCache.get(resolved);
87
- const hookRoot = this.rootFor(this.roots.hooks, resolved);
88
- if (!hookRoot || relativePath(hookRoot, resolved).split('/')[0] !== 'ui' || visiting.has(resolved)) return false;
89
- const sourceFile = this.context.files.find(source => path.resolve(source.fileName) === resolved);
90
- if (!sourceFile) return false;
91
- this.intrinsicUiHookCache.set(resolved, false);
92
- const nextVisiting = new Set(visiting).add(resolved);
93
- const checker = this.context.checkerFor(resolved);
94
- const edges = this.importsForSource(this.context, resolved);
95
- let intrinsic = true;
96
- for (const edge of edges.filter(candidate => candidate.runtime)) {
97
- if (this.forbiddenIntrinsicEdge(edge, nextVisiting)) {
98
- intrinsic = false;
99
- break;
100
- }
64
+ /** The checker of a program source file (every file the analysis visits belongs to a loaded program). */
65
+ checkerFor(fileName) {
66
+ const checker = this.context.checkerFor(fileName);
67
+ if (!checker)
68
+ throw new Error(`No type checker holds ${fileName}.`);
69
+ return checker;
101
70
  }
102
- for (const statement of sourceFile.statements) {
103
- if (!intrinsic) break;
104
- if (this.forbiddenWorldImport(statement)) { intrinsic = false; break; }
71
+ forbiddenIntrinsicEdge(edge, nextVisiting) {
72
+ const forbidden = reachableViolation(this.context.edges, edge, (target) => this.insideAny(this.roots.transport, target)
73
+ || this.insideAny(this.roots.modules, target) || this.insideAny(this.roots.features, target) || this.insideAny(this.roots.routes, target)
74
+ // insideAny held, so the hooks root exists.
75
+ || (this.insideAny(this.roots.hooks, target) && relativePath(this.rootFor(this.roots.hooks, target), target).split('/')[0] !== 'ui'), { follow: (candidate) => candidate.runtime });
76
+ return Boolean(forbidden || (this.insideAny(this.roots.hooks, edge.to) && !this.intrinsicUiHookFile(edge.to, nextVisiting)));
105
77
  }
106
- if (intrinsic && this.containsUnshadowedFetch(sourceFile, checker)) intrinsic = false;
107
- this.intrinsicUiHookCache.set(resolved, intrinsic);
108
- return intrinsic;
109
- }
110
-
111
- intrinsicUiHookSymbol(symbol, checker) {
112
- const identity = normalizedSymbolValue(this.ts, checker, symbol);
113
- const declarations = identity?.getDeclarations?.() ?? [];
114
- return declarations.length > 0 && declarations.every(declaration => this.intrinsicUiHookFile(declaration.getSourceFile().fileName));
115
- }
116
-
117
- worldEdgeOf(edge) {
118
- return edge && Boolean(reachableViolation(this.context.edges, edge,
119
- target => this.insideAny(this.roots.hooks, target) || this.insideAny(this.roots.transport, target),
120
- { follow: candidate => candidate.reexport && candidate.runtime }));
121
- }
122
-
123
- collectNamedWorldImports(checker, named, specifier, worldEdge, symbols) {
124
- for (const element of named.elements) {
125
- if (element.isTypeOnly) continue;
126
- const imported = element.propertyName?.text ?? element.name.text;
127
- const symbol = checker.getSymbolAtLocation(element.name);
128
- if (symbol && (worldEdge || knownWorldImport(specifier, imported))) symbols.add(symbol);
78
+ forbiddenWorldImport(statement) {
79
+ if (!this.ts.isImportDeclaration(statement) || !statement.importClause || statement.importClause.isTypeOnly
80
+ || !this.ts.isStringLiteralLike(statement.moduleSpecifier))
81
+ return false;
82
+ const specifier = statement.moduleSpecifier.text;
83
+ const bindings = [];
84
+ if (statement.importClause.name)
85
+ bindings.push('default');
86
+ const named = statement.importClause.namedBindings;
87
+ if (named && this.ts.isNamespaceImport(named)
88
+ && ['next/navigation', 'next-intl', 'swr', 'swr/immutable', 'swr/mutation', 'next-auth/react'].includes(specifier))
89
+ return true;
90
+ if (named && this.ts.isNamedImports(named)) {
91
+ for (const element of named.elements)
92
+ if (!element.isTypeOnly)
93
+ bindings.push(element.propertyName?.text ?? element.name.text);
94
+ }
95
+ return bindings.some(imported => knownWorldImport(specifier, imported));
129
96
  }
130
- }
131
-
132
- inspectWorldImportStatement(sourceFile, checker, byStart, symbols, namespaces, statement) {
133
- if (!this.ts.isImportDeclaration(statement) || !statement.importClause || statement.importClause.isTypeOnly
134
- || !this.ts.isStringLiteralLike(statement.moduleSpecifier)) return;
135
- const specifier = statement.moduleSpecifier.text;
136
- const worldEdge = this.worldEdgeOf(byStart.get(statement.moduleSpecifier.getStart(sourceFile)));
137
- const clause = statement.importClause;
138
- if (clause.name) {
139
- const symbol = checker.getSymbolAtLocation(clause.name);
140
- if (symbol && (worldEdge || knownWorldImport(specifier, 'default'))) symbols.add(symbol);
97
+ containsUnshadowedFetch(sourceFile, checker) {
98
+ let found = false;
99
+ const visit = (node) => {
100
+ if (!found && this.ts.isCallExpression(node) && this.ts.isIdentifier(node.expression) && node.expression.text === 'fetch'
101
+ && (checker.getSymbolAtLocation(node.expression)?.getDeclarations() ?? []).every(declaration => declaration.getSourceFile().isDeclarationFile))
102
+ found = true;
103
+ if (!found)
104
+ this.ts.forEachChild(node, visit);
105
+ };
106
+ visit(sourceFile);
107
+ return found;
141
108
  }
142
- const named = clause.namedBindings;
143
- if (named && this.ts.isNamedImports(named)) this.collectNamedWorldImports(checker, named, specifier, worldEdge, symbols);
144
- if (named && this.ts.isNamespaceImport(named)) {
145
- const symbol = checker.getSymbolAtLocation(named.name);
146
- if (symbol) namespaces.set(symbol, { specifier, worldEdge });
109
+ intrinsicUiHookFile(fileName, visiting = new Set()) {
110
+ const resolved = path.resolve(fileName);
111
+ const cached = this.intrinsicUiHookCache.get(resolved);
112
+ if (cached !== undefined)
113
+ return cached;
114
+ const hookRoot = this.rootFor(this.roots.hooks, resolved);
115
+ if (!hookRoot || relativePath(hookRoot, resolved).split('/')[0] !== 'ui' || visiting.has(resolved))
116
+ return false;
117
+ const sourceFile = this.context.files.find(source => path.resolve(source.fileName) === resolved);
118
+ if (!sourceFile)
119
+ return false;
120
+ this.intrinsicUiHookCache.set(resolved, false);
121
+ const nextVisiting = new Set(visiting).add(resolved);
122
+ const checker = this.checkerFor(resolved);
123
+ const edges = this.importsForSource(this.context, resolved);
124
+ let intrinsic = true;
125
+ for (const edge of edges.filter(candidate => candidate.runtime)) {
126
+ if (this.forbiddenIntrinsicEdge(edge, nextVisiting)) {
127
+ intrinsic = false;
128
+ break;
129
+ }
130
+ }
131
+ for (const statement of sourceFile.statements) {
132
+ if (!intrinsic)
133
+ break;
134
+ if (this.forbiddenWorldImport(statement)) {
135
+ intrinsic = false;
136
+ break;
137
+ }
138
+ }
139
+ if (intrinsic && this.containsUnshadowedFetch(sourceFile, checker))
140
+ intrinsic = false;
141
+ this.intrinsicUiHookCache.set(resolved, intrinsic);
142
+ return intrinsic;
147
143
  }
148
- }
149
-
150
- importInfo(sourceFile) {
151
- const key = path.resolve(sourceFile.fileName);
152
- if (this.worldInfoCache.has(key)) return this.worldInfoCache.get(key);
153
- const checker = this.context.checkerFor(sourceFile.fileName);
154
- const edges = this.importsForSource(this.context, sourceFile.fileName);
155
- const byStart = new Map(edges.map(edge => [edge.node.getStart(sourceFile), edge]));
156
- const symbols = new Set();
157
- const namespaces = new Map();
158
- for (const statement of sourceFile.statements) this.inspectWorldImportStatement(sourceFile, checker, byStart, symbols, namespaces, statement);
159
- const value = { checker, symbols, namespaces };
160
- this.worldInfoCache.set(key, value);
161
- return value;
162
- }
163
-
164
- collectExpressionFunctions(declaration, checker, seen, functions) {
165
- if (this.ts.isFunctionDeclaration(declaration) || this.ts.isMethodDeclaration(declaration)) functions.push(declaration);
166
- else if (this.ts.isVariableDeclaration(declaration) && declaration.initializer) {
167
- functions.push(...this.expressionFunctions(declaration.initializer, checker, seen));
168
- } else if (this.ts.isClassDeclaration(declaration)) {
169
- functions.push(...declaration.members.filter(member => this.ts.isMethodDeclaration(member)
170
- && member.name && (this.ts.isIdentifier(member.name) || this.ts.isStringLiteralLike(member.name)) && member.name.text === 'render'));
144
+ intrinsicUiHookSymbol(symbol, checker) {
145
+ const identity = normalizedSymbolValue(this.ts, checker, symbol);
146
+ const declarations = identity?.getDeclarations?.() ?? [];
147
+ return declarations.length > 0 && declarations.every(declaration => this.intrinsicUiHookFile(declaration.getSourceFile().fileName));
171
148
  }
172
- }
173
-
174
- isComponentWrapperCall(call) {
175
- const selected = unwrapExpression(this.ts, call.expression);
176
- const name = (this.ts.isIdentifier(selected) && selected.text) || (this.ts.isPropertyAccessExpression(selected) && selected.name.text) || null;
177
- return ['forwardRef', 'memo'].includes(name);
178
- }
179
-
180
- expressionFunctions(expression, checker, seen = new Set()) {
181
- expression = unwrapExpression(this.ts, expression);
182
- if (!expression) return [];
183
- if (this.ts.isArrowFunction(expression) || this.ts.isFunctionExpression(expression) || this.ts.isMethodDeclaration(expression)
184
- || this.ts.isFunctionDeclaration(expression)) return [expression];
185
- if (this.ts.isConditionalExpression(expression)) {
186
- return [...this.expressionFunctions(expression.whenTrue, checker, seen), ...this.expressionFunctions(expression.whenFalse, checker, seen)];
149
+ worldEdgeOf(edge) {
150
+ return edge && Boolean(reachableViolation(this.context.edges, edge, (target) => this.insideAny(this.roots.hooks, target) || this.insideAny(this.roots.transport, target), { follow: (candidate) => candidate.reexport && candidate.runtime }));
187
151
  }
188
- if (this.ts.isCallExpression(expression) && this.isComponentWrapperCall(expression) && expression.arguments[0]) {
189
- return this.expressionFunctions(expression.arguments[0], checker, seen);
152
+ collectNamedWorldImports(checker, named, specifier, worldEdge, symbols) {
153
+ for (const element of named.elements) {
154
+ if (element.isTypeOnly)
155
+ continue;
156
+ const imported = element.propertyName?.text ?? element.name.text;
157
+ const symbol = checker.getSymbolAtLocation(element.name);
158
+ if (symbol && (worldEdge || knownWorldImport(specifier, imported)))
159
+ symbols.add(symbol);
160
+ }
190
161
  }
191
- const symbol = normalizedSymbolValue(this.ts, checker, selectedSymbol(this.ts, checker, expression));
192
- if (!symbol || seen.has(symbol)) return [];
193
- const nextSeen = new Set(seen).add(symbol);
194
- const functions = [];
195
- for (const declaration of symbol.getDeclarations?.() ?? []) this.collectExpressionFunctions(declaration, checker, nextSeen, functions);
196
- return [...new Set(functions.filter(fn => fn.body))];
197
- }
198
-
199
- symbolIsWorld(raw, sourceFile, propertyName = null) {
200
- if (!raw) return false;
201
- const info = this.importInfo(sourceFile);
202
- if (this.intrinsicUiHookSymbol(raw, info.checker)) return false;
203
- if (info.symbols.has(raw)) return true;
204
- for (const [namespace, declaration] of info.namespaces) if (namespace === raw) {
205
- return declaration.worldEdge || knownWorldImport(declaration.specifier, propertyName ?? '');
162
+ inspectWorldImportStatement(sourceFile, checker, byStart, symbols, namespaces, statement) {
163
+ if (!this.ts.isImportDeclaration(statement) || !statement.importClause || statement.importClause.isTypeOnly
164
+ || !this.ts.isStringLiteralLike(statement.moduleSpecifier))
165
+ return;
166
+ const specifier = statement.moduleSpecifier.text;
167
+ const worldEdge = this.worldEdgeOf(byStart.get(statement.moduleSpecifier.getStart(sourceFile)));
168
+ const clause = statement.importClause;
169
+ if (clause.name) {
170
+ const symbol = checker.getSymbolAtLocation(clause.name);
171
+ if (symbol && (worldEdge || knownWorldImport(specifier, 'default')))
172
+ symbols.add(symbol);
173
+ }
174
+ const named = clause.namedBindings;
175
+ if (named && this.ts.isNamedImports(named))
176
+ this.collectNamedWorldImports(checker, named, specifier, worldEdge, symbols);
177
+ if (named && this.ts.isNamespaceImport(named)) {
178
+ const symbol = checker.getSymbolAtLocation(named.name);
179
+ if (symbol)
180
+ namespaces.set(symbol, { specifier, worldEdge });
181
+ }
206
182
  }
207
- const identity = normalizedSymbolValue(this.ts, info.checker, raw);
208
- return (identity?.getDeclarations?.() ?? []).some(declaration => {
209
- const fileName = declaration.getSourceFile().fileName;
210
- return this.insideAny(this.roots.hooks, fileName) || this.insideAny(this.roots.transport, fileName);
211
- });
212
- }
213
-
214
- namespaceIsWorld(raw, sourceFile, propertyName) {
215
- const info = this.importInfo(sourceFile);
216
- const declaration = info.namespaces.get(raw);
217
- return Boolean(declaration && (declaration.worldEdge || knownWorldImport(declaration.specifier, propertyName ?? '')));
218
- }
219
-
220
- worldMemberCallee(expression, checker, sourceFile) {
221
- let property = this.ts.isPropertyAccessExpression(expression) ? expression.name.text : null;
222
- if (property === null && this.ts.isStringLiteralLike(expression.argumentExpression)) property = expression.argumentExpression.text;
223
- const namespace = checker.getSymbolAtLocation(expression.expression);
224
- if (this.intrinsicUiHookSymbol(selectedSymbol(this.ts, checker, expression), checker)) return false;
225
- if (this.namespaceIsWorld(namespace, sourceFile, property)) return true;
226
- return this.symbolIsWorld(selectedSymbol(this.ts, checker, expression), sourceFile);
227
- }
228
-
229
- worldVariableInitializer(symbol, checker, nextSeen) {
230
- for (const declaration of symbol.getDeclarations?.() ?? []) {
231
- if (this.ts.isVariableDeclaration(declaration) && declaration.initializer
232
- && this.calleeIsWorld(declaration.initializer, checker, declaration.getSourceFile(), nextSeen)) return true;
183
+ importInfo(sourceFile) {
184
+ const key = path.resolve(sourceFile.fileName);
185
+ const cached = this.worldInfoCache.get(key);
186
+ if (cached)
187
+ return cached;
188
+ const checker = this.checkerFor(sourceFile.fileName);
189
+ const edges = this.importsForSource(this.context, sourceFile.fileName);
190
+ const byStart = new Map(edges.map((edge) => [edge.node.getStart(sourceFile), edge]));
191
+ const symbols = new Set();
192
+ const namespaces = new Map();
193
+ for (const statement of sourceFile.statements)
194
+ this.inspectWorldImportStatement(sourceFile, checker, byStart, symbols, namespaces, statement);
195
+ const value = { checker, symbols, namespaces };
196
+ this.worldInfoCache.set(key, value);
197
+ return value;
233
198
  }
234
- return false;
235
- }
236
-
237
- calleeIsWorld(input, checker, sourceFile, seen = new Set()) {
238
- const expression = unwrapExpression(this.ts, input);
239
- if (this.ts.isIdentifier(expression) && this.symbolIsWorld(checker.getSymbolAtLocation(expression), sourceFile)) return true;
240
- if (this.ts.isPropertyAccessExpression(expression) || this.ts.isElementAccessExpression(expression))
241
- if (this.worldMemberCallee(expression, checker, sourceFile)) return true;
242
- const symbol = normalizedSymbolValue(this.ts, checker, selectedSymbol(this.ts, checker, expression));
243
- if (!symbol || seen.has(symbol)) return false;
244
- const nextSeen = new Set(seen).add(symbol);
245
- if (this.worldVariableInitializer(symbol, checker, nextSeen)) return true;
246
- return this.expressionFunctions(expression, checker).some(fn => this.functionUsesWorld(fn, checker, nextSeen));
247
- }
248
-
249
- callIsWorld(call, checker, sourceFile, seen) { return this.calleeIsWorld(call.expression, checker, sourceFile, seen); }
250
-
251
- functionUsesWorld(fn, checker, seen = new Set()) {
252
- if (this.functionWorldCache.has(fn)) return this.functionWorldCache.get(fn);
253
- this.functionWorldCache.set(fn, false);
254
- let found = false;
255
- const sourceFile = fn.getSourceFile();
256
- const visit = node => {
257
- if (found) return;
258
- if (this.ts.isCallExpression(node) && this.callIsWorld(node, checker, sourceFile, seen)) { found = true; return; }
259
- this.ts.forEachChild(node, visit);
260
- };
261
- visit(fn.body ?? fn);
262
- this.functionWorldCache.set(fn, found);
263
- return found;
264
- }
265
-
266
- collectFunctionNodes(node, functions) {
267
- if (this.ts.isFunctionDeclaration(node) || this.ts.isMethodDeclaration(node) || this.ts.isArrowFunction(node) || this.ts.isFunctionExpression(node)) functions.push(node);
268
- this.ts.forEachChild(node, child => this.collectFunctionNodes(child, functions));
269
- }
270
-
271
- inspectBlockProductHooks(sourceFile, checker, tier, functions) {
272
- for (const fn of functions) {
273
- const name = this.declarationName(this.ts, fn);
274
- if (tier?.tier === 'blocks' && name && /^use[A-Z0-9]/.test(name.text) && this.functionUsesWorld(fn, checker)) {
275
- this.violations.push(this.violation(this.config, sourceFile, name, 'FE_BLOCK_PRODUCT_HOOK_DEFINITION',
276
- 'A block may call a product hook from hooks but cannot define product-world or data lifecycle under the block.', { ts: this.ts }));
277
- }
199
+ collectExpressionFunctions(declaration, checker, seen, functions) {
200
+ if (this.ts.isFunctionDeclaration(declaration) || this.ts.isMethodDeclaration(declaration))
201
+ functions.push(declaration);
202
+ else if (this.ts.isVariableDeclaration(declaration) && declaration.initializer) {
203
+ functions.push(...this.expressionFunctions(declaration.initializer, checker, seen));
204
+ }
205
+ else if (this.ts.isClassDeclaration(declaration)) {
206
+ functions.push(...declaration.members.filter((member) => this.ts.isMethodDeclaration(member)
207
+ && !!member.name && (this.ts.isIdentifier(member.name) || this.ts.isStringLiteralLike(member.name)) && member.name.text === 'render'));
208
+ }
209
+ }
210
+ isComponentWrapperCall(call) {
211
+ const selected = unwrapExpression(this.ts, call.expression);
212
+ const name = (this.ts.isIdentifier(selected) && selected.text) || (this.ts.isPropertyAccessExpression(selected) && selected.name.text) || null;
213
+ return name !== null && ['forwardRef', 'memo'].includes(name);
214
+ }
215
+ expressionFunctions(input, checker, seen = new Set()) {
216
+ const expression = unwrapExpression(this.ts, input);
217
+ if (!expression)
218
+ return [];
219
+ if (this.ts.isArrowFunction(expression) || this.ts.isFunctionExpression(expression) || this.ts.isMethodDeclaration(expression)
220
+ || this.ts.isFunctionDeclaration(expression))
221
+ return [expression];
222
+ if (this.ts.isConditionalExpression(expression)) {
223
+ return [...this.expressionFunctions(expression.whenTrue, checker, seen), ...this.expressionFunctions(expression.whenFalse, checker, seen)];
224
+ }
225
+ if (this.ts.isCallExpression(expression) && this.isComponentWrapperCall(expression) && expression.arguments[0]) {
226
+ return this.expressionFunctions(expression.arguments[0], checker, seen);
227
+ }
228
+ const symbol = normalizedSymbolValue(this.ts, checker, selectedSymbol(this.ts, checker, expression));
229
+ if (!symbol || seen.has(symbol))
230
+ return [];
231
+ const nextSeen = new Set(seen).add(symbol);
232
+ const functions = [];
233
+ for (const declaration of symbol.getDeclarations?.() ?? [])
234
+ this.collectExpressionFunctions(declaration, checker, nextSeen, functions);
235
+ return [...new Set(functions.filter(fn => fn.body))];
236
+ }
237
+ symbolIsWorld(raw, sourceFile, propertyName = null) {
238
+ if (!raw)
239
+ return false;
240
+ const info = this.importInfo(sourceFile);
241
+ if (this.intrinsicUiHookSymbol(raw, info.checker))
242
+ return false;
243
+ if (info.symbols.has(raw))
244
+ return true;
245
+ for (const [namespace, declaration] of info.namespaces)
246
+ if (namespace === raw) {
247
+ return declaration.worldEdge || knownWorldImport(declaration.specifier, propertyName ?? '');
248
+ }
249
+ const identity = normalizedSymbolValue(this.ts, info.checker, raw);
250
+ return (identity?.getDeclarations?.() ?? []).some(declaration => {
251
+ const fileName = declaration.getSourceFile().fileName;
252
+ return this.insideAny(this.roots.hooks, fileName) || this.insideAny(this.roots.transport, fileName);
253
+ });
254
+ }
255
+ namespaceIsWorld(raw, sourceFile, propertyName) {
256
+ const info = this.importInfo(sourceFile);
257
+ const declaration = raw ? info.namespaces.get(raw) : undefined;
258
+ return Boolean(declaration && (declaration.worldEdge || knownWorldImport(declaration.specifier, propertyName ?? '')));
259
+ }
260
+ worldMemberCallee(expression, checker, sourceFile) {
261
+ let property = null;
262
+ if (this.ts.isPropertyAccessExpression(expression))
263
+ property = expression.name.text;
264
+ else if (this.ts.isStringLiteralLike(expression.argumentExpression))
265
+ property = expression.argumentExpression.text;
266
+ const namespace = checker.getSymbolAtLocation(expression.expression);
267
+ if (this.intrinsicUiHookSymbol(selectedSymbol(this.ts, checker, expression), checker))
268
+ return false;
269
+ if (this.namespaceIsWorld(namespace, sourceFile, property))
270
+ return true;
271
+ return this.symbolIsWorld(selectedSymbol(this.ts, checker, expression), sourceFile);
272
+ }
273
+ worldVariableInitializer(symbol, checker, nextSeen) {
274
+ for (const declaration of symbol.getDeclarations?.() ?? []) {
275
+ if (this.ts.isVariableDeclaration(declaration) && declaration.initializer
276
+ && this.calleeIsWorld(declaration.initializer, checker, declaration.getSourceFile(), nextSeen))
277
+ return true;
278
+ }
279
+ return false;
280
+ }
281
+ calleeIsWorld(input, checker, sourceFile, seen = new Set()) {
282
+ const expression = unwrapExpression(this.ts, input);
283
+ if (this.ts.isIdentifier(expression) && this.symbolIsWorld(checker.getSymbolAtLocation(expression), sourceFile))
284
+ return true;
285
+ if (this.ts.isPropertyAccessExpression(expression) || this.ts.isElementAccessExpression(expression))
286
+ if (this.worldMemberCallee(expression, checker, sourceFile))
287
+ return true;
288
+ const symbol = normalizedSymbolValue(this.ts, checker, selectedSymbol(this.ts, checker, expression));
289
+ if (!symbol || seen.has(symbol))
290
+ return false;
291
+ const nextSeen = new Set(seen).add(symbol);
292
+ if (this.worldVariableInitializer(symbol, checker, nextSeen))
293
+ return true;
294
+ return this.expressionFunctions(expression, checker).some(fn => this.functionUsesWorld(fn, checker, nextSeen));
295
+ }
296
+ callIsWorld(call, checker, sourceFile, seen) { return this.calleeIsWorld(call.expression, checker, sourceFile, seen); }
297
+ functionUsesWorld(fn, checker, seen = new Set()) {
298
+ const cached = this.functionWorldCache.get(fn);
299
+ if (cached !== undefined)
300
+ return cached;
301
+ this.functionWorldCache.set(fn, false);
302
+ let found = false;
303
+ const sourceFile = fn.getSourceFile();
304
+ const visit = (node) => {
305
+ if (found)
306
+ return;
307
+ if (this.ts.isCallExpression(node) && this.callIsWorld(node, checker, sourceFile, seen)) {
308
+ found = true;
309
+ return;
310
+ }
311
+ this.ts.forEachChild(node, visit);
312
+ };
313
+ visit(fn.body ?? fn);
314
+ this.functionWorldCache.set(fn, found);
315
+ return found;
316
+ }
317
+ collectFunctionNodes(node, functions) {
318
+ if (this.ts.isFunctionDeclaration(node) || this.ts.isMethodDeclaration(node) || this.ts.isArrowFunction(node) || this.ts.isFunctionExpression(node))
319
+ functions.push(node);
320
+ this.ts.forEachChild(node, child => this.collectFunctionNodes(child, functions));
321
+ }
322
+ inspectBlockProductHooks(sourceFile, checker, tier, functions) {
323
+ for (const fn of functions) {
324
+ const name = this.declarationName(this.ts, fn);
325
+ if (tier?.tier === 'blocks' && name && /^use[A-Z0-9]/.test(name.text) && this.functionUsesWorld(fn, checker)) {
326
+ this.violations.push(this.violation(this.config, sourceFile, name, 'FE_BLOCK_PRODUCT_HOOK_DEFINITION', 'A block may call a product hook from hooks but cannot define product-world or data lifecycle under the block.', { ts: this.ts }));
327
+ }
328
+ }
329
+ }
330
+ inspectWorldOwner(sourceFile, checker, tier, fn) {
331
+ if (!this.renderer.functionHasRender(fn, checker) || !this.functionUsesWorld(fn, checker))
332
+ return;
333
+ const returned = returnedExpressions(this.ts, fn);
334
+ if (!returned.length || returned.some(expression => !this.renderer.renderBoundary(expression, checker, new Set(), true))) {
335
+ this.violations.push(this.violation(this.config, sourceFile, fn, 'FE_WORLD_OWNER_RENDER_BOUNDARY', 'A visual owner that reads product/world state must hand every render path to a statically resolved pure render function or component; intrinsic-only interaction does not select this rule.', { ts: this.ts }));
336
+ }
337
+ if (tier && LOWER_COMPONENT_TIERS.has(tier.tier)) {
338
+ this.violations.push(this.violation(this.config, sourceFile, fn, 'FE_COMPONENT_WORLD_OWNERSHIP', `${tier.tier} may own intrinsic browser interaction but cannot own product-world, navigation, locale, session or data lifecycle.`, { ts: this.ts }));
339
+ }
340
+ if (tier?.tier === 'blocks')
341
+ this.inspectConnectedBlock(sourceFile, checker, fn, returned);
342
+ }
343
+ inspectConnectedBlock(sourceFile, checker, fn, returned) {
344
+ const expected = path.resolve(path.dirname(sourceFile.fileName), 'component.tsx');
345
+ const index = path.basename(sourceFile.fileName).toLowerCase() === 'index.tsx';
346
+ if (!index || !this.sourceSet.has(expected) || !returned.length
347
+ || returned.some(expression => !this.renderer.renderBoundary(expression, checker, new Set(), true, expected))) {
348
+ this.violations.push(this.violation(this.config, sourceFile, fn, 'FE_CONNECTED_BLOCK_RENDER_PAIR', 'A connected blocks/index.tsx must hand every nonempty render path to a resolved pure export from its sibling component.tsx; pure blocks and lower tiers need no twin.', { ts: this.ts }));
349
+ }
278
350
  }
279
- }
280
-
281
- inspectWorldOwner(sourceFile, checker, tier, fn) {
282
- if (!this.renderer.functionHasRender(fn, checker) || !this.functionUsesWorld(fn, checker)) return;
283
- const returned = returnedExpressions(this.ts, fn);
284
- if (!returned.length || returned.some(expression => !this.renderer.renderBoundary(expression, checker, new Set(), true))) {
285
- this.violations.push(this.violation(this.config, sourceFile, fn, 'FE_WORLD_OWNER_RENDER_BOUNDARY',
286
- 'A visual owner that reads product/world state must hand every render path to a statically resolved pure render function or component; intrinsic-only interaction does not select this rule.', { ts: this.ts }));
351
+ inspectWorldOwners(sourceFile, checker, tier, functions) {
352
+ for (const fn of functions)
353
+ this.inspectWorldOwner(sourceFile, checker, tier, fn);
287
354
  }
288
- if (tier && LOWER_COMPONENT_TIERS.has(tier.tier)) {
289
- this.violations.push(this.violation(this.config, sourceFile, fn, 'FE_COMPONENT_WORLD_OWNERSHIP',
290
- `${tier.tier} may own intrinsic browser interaction but cannot own product-world, navigation, locale, session or data lifecycle.`, { ts: this.ts }));
355
+ inspectSourceFile(sourceFile) {
356
+ if ((!this.insideAny(this.roots.components, sourceFile.fileName) && !this.insideAny(this.roots.features, sourceFile.fileName))
357
+ || !/\.[cm]?tsx$/i.test(sourceFile.fileName))
358
+ return;
359
+ const checker = this.checkerFor(sourceFile.fileName);
360
+ const tier = this.tierOf(this.roots.components, sourceFile.fileName);
361
+ const functions = [];
362
+ this.collectFunctionNodes(sourceFile, functions);
363
+ this.inspectBlockProductHooks(sourceFile, checker, tier, functions);
364
+ this.inspectWorldOwners(sourceFile, checker, tier, functions);
291
365
  }
292
- if (tier?.tier === 'blocks') this.inspectConnectedBlock(sourceFile, checker, fn, returned);
293
- }
294
-
295
- inspectConnectedBlock(sourceFile, checker, fn, returned) {
296
- const expected = path.resolve(path.dirname(sourceFile.fileName), 'component.tsx');
297
- const index = path.basename(sourceFile.fileName).toLowerCase() === 'index.tsx';
298
- if (!index || !this.sourceSet.has(expected) || !returned.length
299
- || returned.some(expression => !this.renderer.renderBoundary(expression, checker, new Set(), true, expected))) {
300
- this.violations.push(this.violation(this.config, sourceFile, fn, 'FE_CONNECTED_BLOCK_RENDER_PAIR',
301
- 'A connected blocks/index.tsx must hand every nonempty render path to a resolved pure export from its sibling component.tsx; pure blocks and lower tiers need no twin.', { ts: this.ts }));
366
+ check() {
367
+ for (const sourceFile of this.context.files)
368
+ this.inspectSourceFile(sourceFile);
369
+ return this.violations;
302
370
  }
303
- }
304
-
305
- inspectWorldOwners(sourceFile, checker, tier, functions) {
306
- for (const fn of functions) this.inspectWorldOwner(sourceFile, checker, tier, fn);
307
- }
308
-
309
- inspectSourceFile(sourceFile) {
310
- if ((!this.insideAny(this.roots.components, sourceFile.fileName) && !this.insideAny(this.roots.features, sourceFile.fileName))
311
- || !/\.[cm]?tsx$/i.test(sourceFile.fileName)) return;
312
- const checker = this.context.checkerFor(sourceFile.fileName);
313
- const tier = this.tierOf(this.roots.components, sourceFile.fileName);
314
- const functions = [];
315
- this.collectFunctionNodes(sourceFile, functions);
316
- this.inspectBlockProductHooks(sourceFile, checker, tier, functions);
317
- this.inspectWorldOwners(sourceFile, checker, tier, functions);
318
- }
319
-
320
- check() {
321
- for (const sourceFile of this.context.files) this.inspectSourceFile(sourceFile);
322
- return this.violations;
323
- }
324
371
  }
325
-
326
372
  export function checkWorldRenderBoundaries(config, context, roots, helpers) {
327
- return new WorldAnalysis(config, context, roots, helpers).check();
373
+ return new WorldAnalysis(config, context, roots, helpers).check();
328
374
  }