@webpieces/dev-config 0.2.95 → 0.2.98

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 (181) hide show
  1. package/config/eslint/base.mjs +1 -1
  2. package/executors.json +6 -91
  3. package/package.json +6 -19
  4. package/{executors → src/executors}/help/executor.d.ts +4 -2
  5. package/src/executors/help/executor.js.map +1 -0
  6. package/src/executors/validate-eslint-sync/executor.js.map +1 -0
  7. package/{executors → src/executors}/validate-versions-locked/executor.js +2 -1
  8. package/src/executors/validate-versions-locked/executor.js.map +1 -0
  9. package/src/index.d.ts +1 -1
  10. package/src/index.js +1 -1
  11. package/src/index.js.map +1 -1
  12. package/src/plugin.d.ts +86 -0
  13. package/{plugin.js → src/plugin.js} +31 -15
  14. package/src/plugin.js.map +1 -0
  15. package/src/toError.d.ts +5 -0
  16. package/src/toError.js +37 -0
  17. package/src/toError.js.map +1 -0
  18. package/templates/eslint.webpieces.config.mjs +1 -1
  19. package/architecture/executors/diff-utils.d.ts +0 -24
  20. package/architecture/executors/diff-utils.js +0 -119
  21. package/architecture/executors/diff-utils.js.map +0 -1
  22. package/architecture/executors/diff-utils.ts +0 -127
  23. package/architecture/executors/generate/executor.d.ts +0 -16
  24. package/architecture/executors/generate/executor.js +0 -44
  25. package/architecture/executors/generate/executor.js.map +0 -1
  26. package/architecture/executors/generate/executor.ts +0 -59
  27. package/architecture/executors/generate/schema.json +0 -14
  28. package/architecture/executors/validate-architecture-unchanged/executor.d.ts +0 -17
  29. package/architecture/executors/validate-architecture-unchanged/executor.js +0 -229
  30. package/architecture/executors/validate-architecture-unchanged/executor.js.map +0 -1
  31. package/architecture/executors/validate-architecture-unchanged/executor.ts +0 -251
  32. package/architecture/executors/validate-architecture-unchanged/schema.json +0 -14
  33. package/architecture/executors/validate-code/executor.d.ts +0 -78
  34. package/architecture/executors/validate-code/executor.js +0 -243
  35. package/architecture/executors/validate-code/executor.js.map +0 -1
  36. package/architecture/executors/validate-code/executor.ts +0 -406
  37. package/architecture/executors/validate-code/schema.json +0 -227
  38. package/architecture/executors/validate-dtos/executor.d.ts +0 -42
  39. package/architecture/executors/validate-dtos/executor.js +0 -561
  40. package/architecture/executors/validate-dtos/executor.js.map +0 -1
  41. package/architecture/executors/validate-dtos/executor.ts +0 -689
  42. package/architecture/executors/validate-dtos/schema.json +0 -33
  43. package/architecture/executors/validate-modified-files/executor.d.ts +0 -25
  44. package/architecture/executors/validate-modified-files/executor.js +0 -501
  45. package/architecture/executors/validate-modified-files/executor.js.map +0 -1
  46. package/architecture/executors/validate-modified-files/executor.ts +0 -571
  47. package/architecture/executors/validate-modified-files/schema.json +0 -25
  48. package/architecture/executors/validate-modified-methods/executor.d.ts +0 -31
  49. package/architecture/executors/validate-modified-methods/executor.js +0 -694
  50. package/architecture/executors/validate-modified-methods/executor.js.map +0 -1
  51. package/architecture/executors/validate-modified-methods/executor.ts +0 -797
  52. package/architecture/executors/validate-modified-methods/schema.json +0 -25
  53. package/architecture/executors/validate-new-methods/executor.d.ts +0 -28
  54. package/architecture/executors/validate-new-methods/executor.js +0 -513
  55. package/architecture/executors/validate-new-methods/executor.js.map +0 -1
  56. package/architecture/executors/validate-new-methods/executor.ts +0 -584
  57. package/architecture/executors/validate-new-methods/schema.json +0 -25
  58. package/architecture/executors/validate-no-any-unknown/executor.d.ts +0 -42
  59. package/architecture/executors/validate-no-any-unknown/executor.js +0 -462
  60. package/architecture/executors/validate-no-any-unknown/executor.js.map +0 -1
  61. package/architecture/executors/validate-no-any-unknown/executor.ts +0 -540
  62. package/architecture/executors/validate-no-any-unknown/schema.json +0 -24
  63. package/architecture/executors/validate-no-architecture-cycles/executor.d.ts +0 -16
  64. package/architecture/executors/validate-no-architecture-cycles/executor.js +0 -48
  65. package/architecture/executors/validate-no-architecture-cycles/executor.js.map +0 -1
  66. package/architecture/executors/validate-no-architecture-cycles/executor.ts +0 -60
  67. package/architecture/executors/validate-no-architecture-cycles/schema.json +0 -8
  68. package/architecture/executors/validate-no-destructure/executor.d.ts +0 -52
  69. package/architecture/executors/validate-no-destructure/executor.js +0 -491
  70. package/architecture/executors/validate-no-destructure/executor.js.map +0 -1
  71. package/architecture/executors/validate-no-destructure/executor.ts +0 -578
  72. package/architecture/executors/validate-no-destructure/schema.json +0 -24
  73. package/architecture/executors/validate-no-direct-api-resolver/executor.d.ts +0 -47
  74. package/architecture/executors/validate-no-direct-api-resolver/executor.js +0 -566
  75. package/architecture/executors/validate-no-direct-api-resolver/executor.js.map +0 -1
  76. package/architecture/executors/validate-no-direct-api-resolver/executor.ts +0 -666
  77. package/architecture/executors/validate-no-direct-api-resolver/schema.json +0 -29
  78. package/architecture/executors/validate-no-inline-types/executor.d.ts +0 -91
  79. package/architecture/executors/validate-no-inline-types/executor.js +0 -669
  80. package/architecture/executors/validate-no-inline-types/executor.js.map +0 -1
  81. package/architecture/executors/validate-no-inline-types/executor.ts +0 -775
  82. package/architecture/executors/validate-no-inline-types/schema.json +0 -24
  83. package/architecture/executors/validate-no-skiplevel-deps/executor.d.ts +0 -19
  84. package/architecture/executors/validate-no-skiplevel-deps/executor.js +0 -227
  85. package/architecture/executors/validate-no-skiplevel-deps/executor.js.map +0 -1
  86. package/architecture/executors/validate-no-skiplevel-deps/executor.ts +0 -267
  87. package/architecture/executors/validate-no-skiplevel-deps/schema.json +0 -8
  88. package/architecture/executors/validate-packagejson/executor.d.ts +0 -16
  89. package/architecture/executors/validate-packagejson/executor.js +0 -57
  90. package/architecture/executors/validate-packagejson/executor.js.map +0 -1
  91. package/architecture/executors/validate-packagejson/executor.ts +0 -74
  92. package/architecture/executors/validate-packagejson/schema.json +0 -8
  93. package/architecture/executors/validate-prisma-converters/executor.d.ts +0 -60
  94. package/architecture/executors/validate-prisma-converters/executor.js +0 -634
  95. package/architecture/executors/validate-prisma-converters/executor.js.map +0 -1
  96. package/architecture/executors/validate-prisma-converters/executor.ts +0 -822
  97. package/architecture/executors/validate-prisma-converters/schema.json +0 -38
  98. package/architecture/executors/validate-return-types/executor.d.ts +0 -29
  99. package/architecture/executors/validate-return-types/executor.js +0 -439
  100. package/architecture/executors/validate-return-types/executor.js.map +0 -1
  101. package/architecture/executors/validate-return-types/executor.ts +0 -524
  102. package/architecture/executors/validate-return-types/schema.json +0 -24
  103. package/architecture/executors/visualize/executor.d.ts +0 -17
  104. package/architecture/executors/visualize/executor.js +0 -49
  105. package/architecture/executors/visualize/executor.js.map +0 -1
  106. package/architecture/executors/visualize/executor.ts +0 -63
  107. package/architecture/executors/visualize/schema.json +0 -14
  108. package/architecture/index.d.ts +0 -19
  109. package/architecture/index.js +0 -23
  110. package/architecture/index.js.map +0 -1
  111. package/architecture/index.ts +0 -20
  112. package/architecture/lib/graph-comparator.d.ts +0 -39
  113. package/architecture/lib/graph-comparator.js +0 -100
  114. package/architecture/lib/graph-comparator.js.map +0 -1
  115. package/architecture/lib/graph-comparator.ts +0 -141
  116. package/architecture/lib/graph-generator.d.ts +0 -19
  117. package/architecture/lib/graph-generator.js +0 -84
  118. package/architecture/lib/graph-generator.js.map +0 -1
  119. package/architecture/lib/graph-generator.ts +0 -97
  120. package/architecture/lib/graph-loader.d.ts +0 -31
  121. package/architecture/lib/graph-loader.js +0 -98
  122. package/architecture/lib/graph-loader.js.map +0 -1
  123. package/architecture/lib/graph-loader.ts +0 -116
  124. package/architecture/lib/graph-sorter.d.ts +0 -37
  125. package/architecture/lib/graph-sorter.js +0 -110
  126. package/architecture/lib/graph-sorter.js.map +0 -1
  127. package/architecture/lib/graph-sorter.ts +0 -137
  128. package/architecture/lib/graph-visualizer.d.ts +0 -29
  129. package/architecture/lib/graph-visualizer.js +0 -217
  130. package/architecture/lib/graph-visualizer.js.map +0 -1
  131. package/architecture/lib/graph-visualizer.ts +0 -231
  132. package/architecture/lib/package-validator.d.ts +0 -38
  133. package/architecture/lib/package-validator.js +0 -126
  134. package/architecture/lib/package-validator.js.map +0 -1
  135. package/architecture/lib/package-validator.ts +0 -170
  136. package/eslint-plugin/__tests__/catch-error-pattern.test.ts +0 -374
  137. package/eslint-plugin/__tests__/max-file-lines.test.ts +0 -207
  138. package/eslint-plugin/__tests__/max-method-lines.test.ts +0 -258
  139. package/eslint-plugin/__tests__/no-unmanaged-exceptions.test.ts +0 -359
  140. package/eslint-plugin/index.d.ts +0 -23
  141. package/eslint-plugin/index.js +0 -30
  142. package/eslint-plugin/index.js.map +0 -1
  143. package/eslint-plugin/index.ts +0 -29
  144. package/eslint-plugin/rules/catch-error-pattern.d.ts +0 -11
  145. package/eslint-plugin/rules/catch-error-pattern.js +0 -143
  146. package/eslint-plugin/rules/catch-error-pattern.js.map +0 -1
  147. package/eslint-plugin/rules/catch-error-pattern.ts +0 -246
  148. package/eslint-plugin/rules/enforce-architecture.d.ts +0 -15
  149. package/eslint-plugin/rules/enforce-architecture.js +0 -476
  150. package/eslint-plugin/rules/enforce-architecture.js.map +0 -1
  151. package/eslint-plugin/rules/enforce-architecture.ts +0 -543
  152. package/eslint-plugin/rules/max-file-lines.d.ts +0 -12
  153. package/eslint-plugin/rules/max-file-lines.js +0 -257
  154. package/eslint-plugin/rules/max-file-lines.js.map +0 -1
  155. package/eslint-plugin/rules/max-file-lines.ts +0 -272
  156. package/eslint-plugin/rules/max-method-lines.d.ts +0 -12
  157. package/eslint-plugin/rules/max-method-lines.js +0 -240
  158. package/eslint-plugin/rules/max-method-lines.js.map +0 -1
  159. package/eslint-plugin/rules/max-method-lines.ts +0 -287
  160. package/eslint-plugin/rules/no-unmanaged-exceptions.d.ts +0 -22
  161. package/eslint-plugin/rules/no-unmanaged-exceptions.js +0 -160
  162. package/eslint-plugin/rules/no-unmanaged-exceptions.js.map +0 -1
  163. package/eslint-plugin/rules/no-unmanaged-exceptions.ts +0 -179
  164. package/executors/help/executor.js.map +0 -1
  165. package/executors/help/executor.ts +0 -61
  166. package/executors/validate-eslint-sync/executor.js.map +0 -1
  167. package/executors/validate-eslint-sync/executor.ts +0 -87
  168. package/executors/validate-versions-locked/executor.js.map +0 -1
  169. package/executors/validate-versions-locked/executor.ts +0 -368
  170. package/plugin/README.md +0 -243
  171. package/plugin/index.d.ts +0 -4
  172. package/plugin/index.js +0 -8
  173. package/plugin/index.js.map +0 -1
  174. package/plugin/index.ts +0 -4
  175. /package/{executors → src/executors}/help/executor.js +0 -0
  176. /package/{executors → src/executors}/help/schema.json +0 -0
  177. /package/{executors → src/executors}/validate-eslint-sync/executor.d.ts +0 -0
  178. /package/{executors → src/executors}/validate-eslint-sync/executor.js +0 -0
  179. /package/{executors → src/executors}/validate-eslint-sync/schema.json +0 -0
  180. /package/{executors → src/executors}/validate-versions-locked/executor.d.ts +0 -0
  181. /package/{executors → src/executors}/validate-versions-locked/schema.json +0 -0
@@ -1,462 +0,0 @@
1
- "use strict";
2
- /**
3
- * Validate No Any Unknown Executor
4
- *
5
- * Validates that `any` and `unknown` TypeScript keywords are not used.
6
- * Uses LINE-BASED detection (not method-based) for git diff filtering.
7
- *
8
- * ============================================================================
9
- * VIOLATIONS (BAD) - These patterns are flagged:
10
- * ============================================================================
11
- *
12
- * - const x: any = ...
13
- * - function foo(arg: any): any { }
14
- * - const data = response as any;
15
- * - type T = any;
16
- * - const x: unknown = ...
17
- * - function foo(arg: unknown): unknown { }
18
- *
19
- * ============================================================================
20
- * MODES (LINE-BASED)
21
- * ============================================================================
22
- * - OFF: Skip validation entirely
23
- * - MODIFIED_CODE: Flag any/unknown on changed lines (lines in diff hunks)
24
- * - MODIFIED_FILES: Flag ALL any/unknown in files that were modified
25
- *
26
- * ============================================================================
27
- * ESCAPE HATCH
28
- * ============================================================================
29
- * Add comment above the violation:
30
- * // webpieces-disable no-any-unknown -- [your justification]
31
- * const x: any = ...;
32
- */
33
- Object.defineProperty(exports, "__esModule", { value: true });
34
- exports.default = runExecutor;
35
- const tslib_1 = require("tslib");
36
- const child_process_1 = require("child_process");
37
- const fs = tslib_1.__importStar(require("fs"));
38
- const path = tslib_1.__importStar(require("path"));
39
- const ts = tslib_1.__importStar(require("typescript"));
40
- /**
41
- * Get changed TypeScript files between base and head (or working tree if head not specified).
42
- */
43
- // webpieces-disable max-lines-new-methods -- Git command handling with untracked files requires multiple code paths
44
- function getChangedTypeScriptFiles(workspaceRoot, base, head) {
45
- try {
46
- const diffTarget = head ? `${base} ${head}` : base;
47
- const output = (0, child_process_1.execSync)(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {
48
- cwd: workspaceRoot,
49
- encoding: 'utf-8',
50
- });
51
- const changedFiles = output
52
- .trim()
53
- .split('\n')
54
- .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));
55
- if (!head) {
56
- try {
57
- const untrackedOutput = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {
58
- cwd: workspaceRoot,
59
- encoding: 'utf-8',
60
- });
61
- const untrackedFiles = untrackedOutput
62
- .trim()
63
- .split('\n')
64
- .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));
65
- const allFiles = new Set([...changedFiles, ...untrackedFiles]);
66
- return Array.from(allFiles);
67
- }
68
- catch {
69
- return changedFiles;
70
- }
71
- }
72
- return changedFiles;
73
- }
74
- catch {
75
- return [];
76
- }
77
- }
78
- /**
79
- * Get the diff content for a specific file.
80
- */
81
- function getFileDiff(workspaceRoot, file, base, head) {
82
- try {
83
- const diffTarget = head ? `${base} ${head}` : base;
84
- const diff = (0, child_process_1.execSync)(`git diff ${diffTarget} -- "${file}"`, {
85
- cwd: workspaceRoot,
86
- encoding: 'utf-8',
87
- });
88
- if (!diff && !head) {
89
- const fullPath = path.join(workspaceRoot, file);
90
- if (fs.existsSync(fullPath)) {
91
- const isUntracked = (0, child_process_1.execSync)(`git ls-files --others --exclude-standard "${file}"`, {
92
- cwd: workspaceRoot,
93
- encoding: 'utf-8',
94
- }).trim();
95
- if (isUntracked) {
96
- const content = fs.readFileSync(fullPath, 'utf-8');
97
- const lines = content.split('\n');
98
- return lines.map((line) => `+${line}`).join('\n');
99
- }
100
- }
101
- }
102
- return diff;
103
- }
104
- catch {
105
- return '';
106
- }
107
- }
108
- /**
109
- * Parse diff to extract changed line numbers (additions only - lines starting with +).
110
- */
111
- function getChangedLineNumbers(diffContent) {
112
- const changedLines = new Set();
113
- const lines = diffContent.split('\n');
114
- let currentLine = 0;
115
- for (const line of lines) {
116
- const hunkMatch = line.match(/^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/);
117
- if (hunkMatch) {
118
- currentLine = parseInt(hunkMatch[1], 10);
119
- continue;
120
- }
121
- if (line.startsWith('+') && !line.startsWith('+++')) {
122
- changedLines.add(currentLine);
123
- currentLine++;
124
- }
125
- else if (line.startsWith('-') && !line.startsWith('---')) {
126
- // Deletions don't increment line number
127
- }
128
- else {
129
- currentLine++;
130
- }
131
- }
132
- return changedLines;
133
- }
134
- /**
135
- * Check if a line contains a webpieces-disable comment for no-any-unknown.
136
- */
137
- function hasDisableComment(lines, lineNumber) {
138
- const startCheck = Math.max(0, lineNumber - 5);
139
- for (let i = lineNumber - 2; i >= startCheck; i--) {
140
- const line = lines[i]?.trim() ?? '';
141
- if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {
142
- break;
143
- }
144
- if (line.includes('webpieces-disable') && line.includes('no-any-unknown')) {
145
- return true;
146
- }
147
- }
148
- return false;
149
- }
150
- /**
151
- * Get a description of the context where the any/unknown keyword appears.
152
- */
153
- // webpieces-disable max-lines-new-methods -- Context detection requires checking many AST node types
154
- function getViolationContext(node, sourceFile) {
155
- try {
156
- let current = node;
157
- while (current.parent) {
158
- const parent = current.parent;
159
- if (ts.isParameter(parent)) {
160
- return 'parameter type';
161
- }
162
- if (ts.isFunctionDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isArrowFunction(parent)) {
163
- if (parent.type === current) {
164
- return 'return type';
165
- }
166
- }
167
- if (ts.isVariableDeclaration(parent)) {
168
- return 'variable type';
169
- }
170
- if (ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) {
171
- return 'property type';
172
- }
173
- if (ts.isAsExpression(parent)) {
174
- return 'type assertion';
175
- }
176
- if (ts.isTypeAliasDeclaration(parent)) {
177
- return 'type alias';
178
- }
179
- if (ts.isTypeReferenceNode(parent)) {
180
- return 'generic argument';
181
- }
182
- if (ts.isArrayTypeNode(parent)) {
183
- return 'array element type';
184
- }
185
- if (ts.isUnionTypeNode(parent) || ts.isIntersectionTypeNode(parent)) {
186
- return 'union/intersection type';
187
- }
188
- current = parent;
189
- }
190
- return 'type position';
191
- }
192
- catch {
193
- return 'type position';
194
- }
195
- }
196
- /**
197
- * Check if a node is in a catch clause variable declaration.
198
- * This allows `catch (err: unknown)` and `catch (err: unknown)` patterns.
199
- */
200
- function isInCatchClause(node) {
201
- let current = node.parent;
202
- while (current) {
203
- if (ts.isCatchClause(current)) {
204
- // We're somewhere in a catch clause - check if we're in the variable declaration
205
- const catchClause = current;
206
- if (catchClause.variableDeclaration) {
207
- // Walk back up from the original node to see if we're part of the variable declaration
208
- let checkNode = node.parent;
209
- while (checkNode && checkNode !== current) {
210
- if (checkNode === catchClause.variableDeclaration) {
211
- return true;
212
- }
213
- checkNode = checkNode.parent;
214
- }
215
- }
216
- }
217
- current = current.parent;
218
- }
219
- return false;
220
- }
221
- /**
222
- * Find all `any` and `unknown` keywords in a file using AST.
223
- */
224
- // webpieces-disable max-lines-new-methods -- AST traversal with nested visitor function for keyword detection
225
- function findAnyUnknownInFile(filePath, workspaceRoot) {
226
- const fullPath = path.join(workspaceRoot, filePath);
227
- if (!fs.existsSync(fullPath))
228
- return [];
229
- const content = fs.readFileSync(fullPath, 'utf-8');
230
- const fileLines = content.split('\n');
231
- const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);
232
- const violations = [];
233
- // webpieces-disable max-lines-new-methods -- AST visitor needs to handle both any and unknown keywords with full context detection
234
- function visit(node) {
235
- try {
236
- // Detect `any` keyword
237
- if (node.kind === ts.SyntaxKind.AnyKeyword) {
238
- // Skip catch clause variable types: catch (err: unknown) is allowed
239
- if (isInCatchClause(node)) {
240
- ts.forEachChild(node, visit);
241
- return;
242
- }
243
- const startPos = node.getStart(sourceFile);
244
- if (startPos >= 0) {
245
- const pos = sourceFile.getLineAndCharacterOfPosition(startPos);
246
- const line = pos.line + 1;
247
- const column = pos.character + 1;
248
- const context = getViolationContext(node, sourceFile);
249
- const disabled = hasDisableComment(fileLines, line);
250
- violations.push({
251
- line,
252
- column,
253
- keyword: 'any',
254
- context,
255
- hasDisableComment: disabled,
256
- });
257
- }
258
- }
259
- // Detect `unknown` keyword
260
- if (node.kind === ts.SyntaxKind.UnknownKeyword) {
261
- // Skip catch clause variable types: catch (err: unknown) is allowed
262
- if (isInCatchClause(node)) {
263
- ts.forEachChild(node, visit);
264
- return;
265
- }
266
- const startPos = node.getStart(sourceFile);
267
- if (startPos >= 0) {
268
- const pos = sourceFile.getLineAndCharacterOfPosition(startPos);
269
- const line = pos.line + 1;
270
- const column = pos.character + 1;
271
- const context = getViolationContext(node, sourceFile);
272
- const disabled = hasDisableComment(fileLines, line);
273
- violations.push({
274
- line,
275
- column,
276
- keyword: 'unknown',
277
- context,
278
- hasDisableComment: disabled,
279
- });
280
- }
281
- }
282
- }
283
- catch {
284
- // Skip nodes that cause errors during analysis
285
- }
286
- ts.forEachChild(node, visit);
287
- }
288
- visit(sourceFile);
289
- return violations;
290
- }
291
- /**
292
- * MODIFIED_CODE mode: Flag violations on changed lines in diff hunks.
293
- * This is LINE-BASED detection.
294
- */
295
- // webpieces-disable max-lines-new-methods -- File iteration with diff parsing and line filtering
296
- function findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed) {
297
- const violations = [];
298
- for (const file of changedFiles) {
299
- const diff = getFileDiff(workspaceRoot, file, base, head);
300
- const changedLines = getChangedLineNumbers(diff);
301
- if (changedLines.size === 0)
302
- continue;
303
- const allViolations = findAnyUnknownInFile(file, workspaceRoot);
304
- for (const v of allViolations) {
305
- if (disableAllowed && v.hasDisableComment)
306
- continue;
307
- // LINE-BASED: Only include if the violation is on a changed line
308
- if (!changedLines.has(v.line))
309
- continue;
310
- violations.push({
311
- file,
312
- line: v.line,
313
- column: v.column,
314
- keyword: v.keyword,
315
- context: v.context,
316
- });
317
- }
318
- }
319
- return violations;
320
- }
321
- /**
322
- * MODIFIED_FILES mode: Flag ALL violations in files that were modified.
323
- */
324
- function findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed) {
325
- const violations = [];
326
- for (const file of changedFiles) {
327
- const allViolations = findAnyUnknownInFile(file, workspaceRoot);
328
- for (const v of allViolations) {
329
- if (disableAllowed && v.hasDisableComment)
330
- continue;
331
- violations.push({
332
- file,
333
- line: v.line,
334
- column: v.column,
335
- keyword: v.keyword,
336
- context: v.context,
337
- });
338
- }
339
- }
340
- return violations;
341
- }
342
- /**
343
- * Auto-detect the base branch by finding the merge-base with origin/main.
344
- */
345
- function detectBase(workspaceRoot) {
346
- try {
347
- const mergeBase = (0, child_process_1.execSync)('git merge-base HEAD origin/main', {
348
- cwd: workspaceRoot,
349
- encoding: 'utf-8',
350
- stdio: ['pipe', 'pipe', 'pipe'],
351
- }).trim();
352
- if (mergeBase) {
353
- return mergeBase;
354
- }
355
- }
356
- catch {
357
- try {
358
- const mergeBase = (0, child_process_1.execSync)('git merge-base HEAD main', {
359
- cwd: workspaceRoot,
360
- encoding: 'utf-8',
361
- stdio: ['pipe', 'pipe', 'pipe'],
362
- }).trim();
363
- if (mergeBase) {
364
- return mergeBase;
365
- }
366
- }
367
- catch {
368
- // Ignore
369
- }
370
- }
371
- return null;
372
- }
373
- /**
374
- * Report violations to console.
375
- */
376
- function reportViolations(violations, mode) {
377
- console.error('');
378
- console.error('❌ `any` and `unknown` keywords found! Use specific types instead.');
379
- console.error('');
380
- console.error('📚 Avoiding any/unknown improves type safety:');
381
- console.error('');
382
- console.error(' BAD: const data: any = fetchData();');
383
- console.error(' GOOD: const data: UserData = fetchData();');
384
- console.error('');
385
- console.error(' BAD: function process(input: unknown): unknown { }');
386
- console.error(' GOOD: function process(input: ValidInput): ValidOutput { }');
387
- console.error('');
388
- for (const v of violations) {
389
- console.error(` ❌ ${v.file}:${v.line}:${v.column}`);
390
- console.error(` \`${v.keyword}\` keyword in ${v.context}`);
391
- }
392
- console.error('');
393
- console.error(' To fix: Replace with specific types or interfaces');
394
- console.error('');
395
- console.error(' Escape hatch (use sparingly):');
396
- console.error(' // webpieces-disable no-any-unknown -- [your reason]');
397
- console.error('');
398
- console.error(` Current mode: ${mode}`);
399
- console.error('');
400
- }
401
- /**
402
- * Resolve mode considering ignoreModifiedUntilEpoch override.
403
- * When active, downgrades to OFF. When expired, logs a warning.
404
- */
405
- function resolveMode(normalMode, epoch) {
406
- if (epoch === undefined || normalMode === 'OFF') {
407
- return normalMode;
408
- }
409
- const nowSeconds = Date.now() / 1000;
410
- if (nowSeconds < epoch) {
411
- const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];
412
- console.log(`\n⏭️ Skipping no-any-unknown validation (ignoreModifiedUntilEpoch active, expires: ${expiresDate})`);
413
- console.log('');
414
- return 'OFF';
415
- }
416
- return normalMode;
417
- }
418
- async function runExecutor(options, context) {
419
- const workspaceRoot = context.root;
420
- const mode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch);
421
- const disableAllowed = options.disableAllowed ?? true;
422
- if (mode === 'OFF') {
423
- console.log('\n⏭️ Skipping no-any-unknown validation (mode: OFF)');
424
- console.log('');
425
- return { success: true };
426
- }
427
- console.log('\n📏 Validating No Any/Unknown\n');
428
- console.log(` Mode: ${mode}`);
429
- let base = process.env['NX_BASE'];
430
- const head = process.env['NX_HEAD'];
431
- if (!base) {
432
- base = detectBase(workspaceRoot) ?? undefined;
433
- if (!base) {
434
- console.log('\n⏭️ Skipping no-any-unknown validation (could not detect base branch)');
435
- console.log('');
436
- return { success: true };
437
- }
438
- }
439
- console.log(` Base: ${base}`);
440
- console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);
441
- console.log('');
442
- const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);
443
- if (changedFiles.length === 0) {
444
- console.log('✅ No TypeScript files changed');
445
- return { success: true };
446
- }
447
- console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);
448
- let violations = [];
449
- if (mode === 'MODIFIED_CODE') {
450
- violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed);
451
- }
452
- else if (mode === 'MODIFIED_FILES') {
453
- violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);
454
- }
455
- if (violations.length === 0) {
456
- console.log('✅ No any/unknown keywords found');
457
- return { success: true };
458
- }
459
- reportViolations(violations, mode);
460
- return { success: false };
461
- }
462
- //# sourceMappingURL=executor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/dev-config/architecture/executors/validate-no-any-unknown/executor.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;;AAkcH,8BA2DC;;AA1fD,iDAAyC;AACzC,+CAAyB;AACzB,mDAA6B;AAC7B,uDAAiC;AAsBjC;;GAEG;AACH,oHAAoH;AACpH,SAAS,yBAAyB,CAAC,aAAqB,EAAE,IAAY,EAAE,IAAa;IACjF,IAAI,CAAC;QACD,MAAM,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACnD,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,wBAAwB,UAAU,oBAAoB,EAAE;YAC5E,GAAG,EAAE,aAAa;YAClB,QAAQ,EAAE,OAAO;SACpB,CAAC,CAAC;QACH,MAAM,YAAY,GAAG,MAAM;aACtB,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CA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C;IACjF,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAEhB,MAAM,YAAY,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAE1E,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;QAC7C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAe,YAAY,CAAC,MAAM,qBAAqB,CAAC,CAAC;IAErE,IAAI,UAAU,GAA0B,EAAE,CAAC;IAE3C,IAAI,IAAI,KAAK,eAAe,EAAE,CAAC;QAC3B,UAAU,GAAG,6BAA6B,CAAC,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IACxG,CAAC;SAAM,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACnC,UAAU,GAAG,8BAA8B,CAAC,aAAa,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;IAC7F,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAEnC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["/**\n * Validate No Any Unknown Executor\n *\n * Validates that `any` and `unknown` TypeScript keywords are not used.\n * Uses LINE-BASED detection (not method-based) for git diff filtering.\n *\n * ============================================================================\n * VIOLATIONS (BAD) - These patterns are flagged:\n * ============================================================================\n *\n * - const x: any = ...\n * - function foo(arg: any): any { }\n * - const data = response as any;\n * - type T = any;\n * - const x: unknown = ...\n * - function foo(arg: unknown): unknown { }\n *\n * ============================================================================\n * MODES (LINE-BASED)\n * ============================================================================\n * - OFF: Skip validation entirely\n * - MODIFIED_CODE: Flag any/unknown on changed lines (lines in diff hunks)\n * - MODIFIED_FILES: Flag ALL any/unknown in files that were modified\n *\n * ============================================================================\n * ESCAPE HATCH\n * ============================================================================\n * Add comment above the violation:\n * // webpieces-disable no-any-unknown -- [your justification]\n * const x: any = ...;\n */\n\nimport type { ExecutorContext } from '@nx/devkit';\nimport { execSync } from 'child_process';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport * as ts from 'typescript';\n\nexport type NoAnyUnknownMode = 'OFF' | 'MODIFIED_CODE' | 'MODIFIED_FILES';\n\nexport interface ValidateNoAnyUnknownOptions {\n mode?: NoAnyUnknownMode;\n disableAllowed?: boolean;\n ignoreModifiedUntilEpoch?: number;\n}\n\nexport interface ExecutorResult {\n success: boolean;\n}\n\ninterface AnyUnknownViolation {\n file: string;\n line: number;\n column: number;\n keyword: 'any' | 'unknown';\n context: string;\n}\n\n/**\n * Get changed TypeScript files between base and head (or working tree if head not specified).\n */\n// webpieces-disable max-lines-new-methods -- Git command handling with untracked files requires multiple code paths\nfunction getChangedTypeScriptFiles(workspaceRoot: string, base: string, head?: string): string[] {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const output = execSync(`git diff --name-only ${diffTarget} -- '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const changedFiles = output\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n\n if (!head) {\n try {\n const untrackedOutput = execSync(`git ls-files --others --exclude-standard '*.ts' '*.tsx'`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n const untrackedFiles = untrackedOutput\n .trim()\n .split('\\n')\n .filter((f) => f && !f.includes('.spec.ts') && !f.includes('.test.ts'));\n const allFiles = new Set([...changedFiles, ...untrackedFiles]);\n return Array.from(allFiles);\n } catch {\n return changedFiles;\n }\n }\n\n return changedFiles;\n } catch {\n return [];\n }\n}\n\n/**\n * Get the diff content for a specific file.\n */\nfunction getFileDiff(workspaceRoot: string, file: string, base: string, head?: string): string {\n try {\n const diffTarget = head ? `${base} ${head}` : base;\n const diff = execSync(`git diff ${diffTarget} -- \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n });\n\n if (!diff && !head) {\n const fullPath = path.join(workspaceRoot, file);\n if (fs.existsSync(fullPath)) {\n const isUntracked = execSync(`git ls-files --others --exclude-standard \"${file}\"`, {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n }).trim();\n\n if (isUntracked) {\n const content = fs.readFileSync(fullPath, 'utf-8');\n const lines = content.split('\\n');\n return lines.map((line) => `+${line}`).join('\\n');\n }\n }\n }\n\n return diff;\n } catch {\n return '';\n }\n}\n\n/**\n * Parse diff to extract changed line numbers (additions only - lines starting with +).\n */\nfunction getChangedLineNumbers(diffContent: string): Set<number> {\n const changedLines = new Set<number>();\n const lines = diffContent.split('\\n');\n let currentLine = 0;\n\n for (const line of lines) {\n const hunkMatch = line.match(/^@@ -\\d+(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/);\n if (hunkMatch) {\n currentLine = parseInt(hunkMatch[1], 10);\n continue;\n }\n\n if (line.startsWith('+') && !line.startsWith('+++')) {\n changedLines.add(currentLine);\n currentLine++;\n } else if (line.startsWith('-') && !line.startsWith('---')) {\n // Deletions don't increment line number\n } else {\n currentLine++;\n }\n }\n\n return changedLines;\n}\n\n/**\n * Check if a line contains a webpieces-disable comment for no-any-unknown.\n */\nfunction hasDisableComment(lines: string[], lineNumber: number): boolean {\n const startCheck = Math.max(0, lineNumber - 5);\n for (let i = lineNumber - 2; i >= startCheck; i--) {\n const line = lines[i]?.trim() ?? '';\n if (line.startsWith('function ') || line.startsWith('class ') || line.endsWith('}')) {\n break;\n }\n if (line.includes('webpieces-disable') && line.includes('no-any-unknown')) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Get a description of the context where the any/unknown keyword appears.\n */\n// webpieces-disable max-lines-new-methods -- Context detection requires checking many AST node types\nfunction getViolationContext(node: ts.Node, sourceFile: ts.SourceFile): string {\n try {\n let current: ts.Node = node;\n while (current.parent) {\n const parent = current.parent;\n if (ts.isParameter(parent)) {\n return 'parameter type';\n }\n if (ts.isFunctionDeclaration(parent) || ts.isMethodDeclaration(parent) || ts.isArrowFunction(parent)) {\n if (parent.type === current) {\n return 'return type';\n }\n }\n if (ts.isVariableDeclaration(parent)) {\n return 'variable type';\n }\n if (ts.isPropertyDeclaration(parent) || ts.isPropertySignature(parent)) {\n return 'property type';\n }\n if (ts.isAsExpression(parent)) {\n return 'type assertion';\n }\n if (ts.isTypeAliasDeclaration(parent)) {\n return 'type alias';\n }\n if (ts.isTypeReferenceNode(parent)) {\n return 'generic argument';\n }\n if (ts.isArrayTypeNode(parent)) {\n return 'array element type';\n }\n if (ts.isUnionTypeNode(parent) || ts.isIntersectionTypeNode(parent)) {\n return 'union/intersection type';\n }\n current = parent;\n }\n return 'type position';\n } catch {\n return 'type position';\n }\n}\n\ninterface AnyUnknownInfo {\n line: number;\n column: number;\n keyword: 'any' | 'unknown';\n context: string;\n hasDisableComment: boolean;\n}\n\n/**\n * Check if a node is in a catch clause variable declaration.\n * This allows `catch (err: unknown)` and `catch (err: unknown)` patterns.\n */\nfunction isInCatchClause(node: ts.Node): boolean {\n let current: ts.Node | undefined = node.parent;\n while (current) {\n if (ts.isCatchClause(current)) {\n // We're somewhere in a catch clause - check if we're in the variable declaration\n const catchClause = current as ts.CatchClause;\n if (catchClause.variableDeclaration) {\n // Walk back up from the original node to see if we're part of the variable declaration\n let checkNode: ts.Node | undefined = node.parent;\n while (checkNode && checkNode !== current) {\n if (checkNode === catchClause.variableDeclaration) {\n return true;\n }\n checkNode = checkNode.parent;\n }\n }\n }\n current = current.parent;\n }\n return false;\n}\n\n/**\n * Find all `any` and `unknown` keywords in a file using AST.\n */\n// webpieces-disable max-lines-new-methods -- AST traversal with nested visitor function for keyword detection\nfunction findAnyUnknownInFile(filePath: string, workspaceRoot: string): AnyUnknownInfo[] {\n const fullPath = path.join(workspaceRoot, filePath);\n if (!fs.existsSync(fullPath)) return [];\n\n const content = fs.readFileSync(fullPath, 'utf-8');\n const fileLines = content.split('\\n');\n const sourceFile = ts.createSourceFile(filePath, content, ts.ScriptTarget.Latest, true);\n\n const violations: AnyUnknownInfo[] = [];\n\n // webpieces-disable max-lines-new-methods -- AST visitor needs to handle both any and unknown keywords with full context detection\n function visit(node: ts.Node): void {\n try {\n // Detect `any` keyword\n if (node.kind === ts.SyntaxKind.AnyKeyword) {\n // Skip catch clause variable types: catch (err: unknown) is allowed\n if (isInCatchClause(node)) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const startPos = node.getStart(sourceFile);\n if (startPos >= 0) {\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n const column = pos.character + 1;\n const context = getViolationContext(node, sourceFile);\n const disabled = hasDisableComment(fileLines, line);\n\n violations.push({\n line,\n column,\n keyword: 'any',\n context,\n hasDisableComment: disabled,\n });\n }\n }\n\n // Detect `unknown` keyword\n if (node.kind === ts.SyntaxKind.UnknownKeyword) {\n // Skip catch clause variable types: catch (err: unknown) is allowed\n if (isInCatchClause(node)) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const startPos = node.getStart(sourceFile);\n if (startPos >= 0) {\n const pos = sourceFile.getLineAndCharacterOfPosition(startPos);\n const line = pos.line + 1;\n const column = pos.character + 1;\n const context = getViolationContext(node, sourceFile);\n const disabled = hasDisableComment(fileLines, line);\n\n violations.push({\n line,\n column,\n keyword: 'unknown',\n context,\n hasDisableComment: disabled,\n });\n }\n }\n } catch {\n // Skip nodes that cause errors during analysis\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return violations;\n}\n\n/**\n * MODIFIED_CODE mode: Flag violations on changed lines in diff hunks.\n * This is LINE-BASED detection.\n */\n// webpieces-disable max-lines-new-methods -- File iteration with diff parsing and line filtering\nfunction findViolationsForModifiedCode(\n workspaceRoot: string,\n changedFiles: string[],\n base: string,\n head: string | undefined,\n disableAllowed: boolean\n): AnyUnknownViolation[] {\n const violations: AnyUnknownViolation[] = [];\n\n for (const file of changedFiles) {\n const diff = getFileDiff(workspaceRoot, file, base, head);\n const changedLines = getChangedLineNumbers(diff);\n\n if (changedLines.size === 0) continue;\n\n const allViolations = findAnyUnknownInFile(file, workspaceRoot);\n\n for (const v of allViolations) {\n if (disableAllowed && v.hasDisableComment) continue;\n // LINE-BASED: Only include if the violation is on a changed line\n if (!changedLines.has(v.line)) continue;\n\n violations.push({\n file,\n line: v.line,\n column: v.column,\n keyword: v.keyword,\n context: v.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * MODIFIED_FILES mode: Flag ALL violations in files that were modified.\n */\nfunction findViolationsForModifiedFiles(workspaceRoot: string, changedFiles: string[], disableAllowed: boolean): AnyUnknownViolation[] {\n const violations: AnyUnknownViolation[] = [];\n\n for (const file of changedFiles) {\n const allViolations = findAnyUnknownInFile(file, workspaceRoot);\n\n for (const v of allViolations) {\n if (disableAllowed && v.hasDisableComment) continue;\n\n violations.push({\n file,\n line: v.line,\n column: v.column,\n keyword: v.keyword,\n context: v.context,\n });\n }\n }\n\n return violations;\n}\n\n/**\n * Auto-detect the base branch by finding the merge-base with origin/main.\n */\nfunction detectBase(workspaceRoot: string): string | null {\n try {\n const mergeBase = execSync('git merge-base HEAD origin/main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n try {\n const mergeBase = execSync('git merge-base HEAD main', {\n cwd: workspaceRoot,\n encoding: 'utf-8',\n stdio: ['pipe', 'pipe', 'pipe'],\n }).trim();\n\n if (mergeBase) {\n return mergeBase;\n }\n } catch {\n // Ignore\n }\n }\n return null;\n}\n\n/**\n * Report violations to console.\n */\nfunction reportViolations(violations: AnyUnknownViolation[], mode: NoAnyUnknownMode): void {\n console.error('');\n console.error('❌ `any` and `unknown` keywords found! Use specific types instead.');\n console.error('');\n console.error('📚 Avoiding any/unknown improves type safety:');\n console.error('');\n console.error(' BAD: const data: any = fetchData();');\n console.error(' GOOD: const data: UserData = fetchData();');\n console.error('');\n console.error(' BAD: function process(input: unknown): unknown { }');\n console.error(' GOOD: function process(input: ValidInput): ValidOutput { }');\n console.error('');\n\n for (const v of violations) {\n console.error(` ❌ ${v.file}:${v.line}:${v.column}`);\n console.error(` \\`${v.keyword}\\` keyword in ${v.context}`);\n }\n console.error('');\n\n console.error(' To fix: Replace with specific types or interfaces');\n console.error('');\n console.error(' Escape hatch (use sparingly):');\n console.error(' // webpieces-disable no-any-unknown -- [your reason]');\n console.error('');\n console.error(` Current mode: ${mode}`);\n console.error('');\n}\n\n/**\n * Resolve mode considering ignoreModifiedUntilEpoch override.\n * When active, downgrades to OFF. When expired, logs a warning.\n */\nfunction resolveMode(normalMode: NoAnyUnknownMode, epoch: number | undefined): NoAnyUnknownMode {\n if (epoch === undefined || normalMode === 'OFF') {\n return normalMode;\n }\n const nowSeconds = Date.now() / 1000;\n if (nowSeconds < epoch) {\n const expiresDate = new Date(epoch * 1000).toISOString().split('T')[0];\n console.log(`\\n⏭️ Skipping no-any-unknown validation (ignoreModifiedUntilEpoch active, expires: ${expiresDate})`);\n console.log('');\n return 'OFF';\n }\n return normalMode;\n}\n\nexport default async function runExecutor(\n options: ValidateNoAnyUnknownOptions,\n context: ExecutorContext\n): Promise<ExecutorResult> {\n const workspaceRoot = context.root;\n const mode: NoAnyUnknownMode = resolveMode(options.mode ?? 'OFF', options.ignoreModifiedUntilEpoch);\n const disableAllowed = options.disableAllowed ?? true;\n\n if (mode === 'OFF') {\n console.log('\\n⏭️ Skipping no-any-unknown validation (mode: OFF)');\n console.log('');\n return { success: true };\n }\n\n console.log('\\n📏 Validating No Any/Unknown\\n');\n console.log(` Mode: ${mode}`);\n\n let base = process.env['NX_BASE'];\n const head = process.env['NX_HEAD'];\n\n if (!base) {\n base = detectBase(workspaceRoot) ?? undefined;\n\n if (!base) {\n console.log('\\n⏭️ Skipping no-any-unknown validation (could not detect base branch)');\n console.log('');\n return { success: true };\n }\n }\n\n console.log(` Base: ${base}`);\n console.log(` Head: ${head ?? 'working tree (includes uncommitted changes)'}`);\n console.log('');\n\n const changedFiles = getChangedTypeScriptFiles(workspaceRoot, base, head);\n\n if (changedFiles.length === 0) {\n console.log('✅ No TypeScript files changed');\n return { success: true };\n }\n\n console.log(`📂 Checking ${changedFiles.length} changed file(s)...`);\n\n let violations: AnyUnknownViolation[] = [];\n\n if (mode === 'MODIFIED_CODE') {\n violations = findViolationsForModifiedCode(workspaceRoot, changedFiles, base, head, disableAllowed);\n } else if (mode === 'MODIFIED_FILES') {\n violations = findViolationsForModifiedFiles(workspaceRoot, changedFiles, disableAllowed);\n }\n\n if (violations.length === 0) {\n console.log('✅ No any/unknown keywords found');\n return { success: true };\n }\n\n reportViolations(violations, mode);\n\n return { success: false };\n}\n"]}