@futdevpro/dynamo-eslint 1.20.3 → 1.20.6

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 (125) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +304 -304
  3. package/build/plugin/rules/ts/no-as-cast.d.ts.map +1 -1
  4. package/build/plugin/rules/ts/no-as-cast.js +43 -0
  5. package/build/plugin/rules/ts/no-as-cast.js.map +1 -1
  6. package/package.json +14 -7
  7. package/.c8rc.json +0 -26
  8. package/.cursor/rules/__assistant_guide.mdc +0 -30
  9. package/.cursor/rules/__main.mdc +0 -64
  10. package/.cursor/rules/_ag_backend-structure.mdc +0 -86
  11. package/.cursor/rules/_ag_backend.mdc +0 -16
  12. package/.cursor/rules/_ag_debug.mdc +0 -8
  13. package/.cursor/rules/_ag_documentation_writing_rules.mdc +0 -372
  14. package/.cursor/rules/_ag_file-refactoring.mdc +0 -113
  15. package/.cursor/rules/_ag_fixes_rules.mdc +0 -6
  16. package/.cursor/rules/_ag_frontend-structure.mdc +0 -87
  17. package/.cursor/rules/_ag_frontend.mdc +0 -40
  18. package/.cursor/rules/_ag_import-rules.mdc +0 -45
  19. package/.cursor/rules/_ag_naming.mdc +0 -116
  20. package/.cursor/rules/_ag_running_commands.mdc +0 -5
  21. package/.cursor/rules/_ag_server-controller.mdc +0 -6
  22. package/.cursor/rules/_ag_should-be.mdc +0 -7
  23. package/.cursor/rules/_ag_swearing.mdc +0 -47
  24. package/.cursor/rules/ai_development_guide.md +0 -61
  25. package/.cursor/rules/ai_directives.md +0 -114
  26. package/.cursor/rules/cursor-rules.md +0 -160
  27. package/.cursor/rules/default-command.mdc +0 -465
  28. package/.cursor/rules/error_code_pattern.md +0 -40
  29. package/.cursor/rules/saved rule mcp server use.md +0 -16
  30. package/.dynamo/pipeline.cicd.config.json +0 -184
  31. package/.dynamo/version-bump.config.json +0 -5
  32. package/.eslintrc.json +0 -4
  33. package/.github/workflows/main.yml +0 -436
  34. package/.husky/pre-commit +0 -2
  35. package/.vscode/settings.json +0 -11
  36. package/__documentations/2026-04-18-ccap-review-integration.md +0 -173
  37. package/__documentations/2026-08-18-bfr-ctm-005-eslint9-validator-report.md +0 -45
  38. package/__documentations/2026-08-22-angular-20-phase2-release.md +0 -83
  39. package/eslint.config.js +0 -15
  40. package/pnpm-workspace.yaml +0 -2
  41. package/samples/.vscode/settings.json +0 -13
  42. package/samples/base/.eslintrc.json +0 -6
  43. package/samples/base/eslint.config.js +0 -3
  44. package/samples/fsm/.eslintrc.json +0 -4
  45. package/samples/fsm/eslint.config.js +0 -3
  46. package/samples/ngx/.eslintrc.json +0 -6
  47. package/samples/ngx/eslint.config.js +0 -3
  48. package/samples/ngx-package/.eslintrc.json +0 -4
  49. package/samples/ngx-package/eslint.config.js +0 -3
  50. package/samples/nts/.eslintrc.json +0 -6
  51. package/samples/nts/eslint.config.js +0 -3
  52. package/samples/nts-package/.eslintrc.json +0 -4
  53. package/samples/nts-package/eslint.config.js +0 -3
  54. package/samples/package.json.example +0 -22
  55. package/samples/poc-sample.ts +0 -38
  56. package/samples/poc-violations.ts +0 -54
  57. package/scripts/run-coverage-tests.js +0 -24
  58. package/spec/support/helpers/ts-node-helper.js +0 -9
  59. package/spec/support/jasmine.coverage.json +0 -23
  60. package/spec/support/jasmine.json +0 -24
  61. package/src/configs/angular20-compatibility.spec.ts +0 -73
  62. package/src/configs/base.ts +0 -156
  63. package/src/configs/fsm.ts +0 -10
  64. package/src/configs/ngx-package.ts +0 -10
  65. package/src/configs/ngx.ts +0 -93
  66. package/src/configs/nts-package.ts +0 -20
  67. package/src/configs/nts.ts +0 -34
  68. package/src/index.ts +0 -4
  69. package/src/plugin/index.ts +0 -86
  70. package/src/plugin/rules/angular/angular-for-track-logic.spec.ts +0 -44
  71. package/src/plugin/rules/angular/angular-for-track-logic.ts +0 -88
  72. package/src/plugin/rules/angular/effect-signal-loop.spec.ts +0 -89
  73. package/src/plugin/rules/angular/effect-signal-loop.ts +0 -125
  74. package/src/plugin/rules/angular/no-async-ngoninit.spec.ts +0 -50
  75. package/src/plugin/rules/angular/no-async-ngoninit.ts +0 -43
  76. package/src/plugin/rules/angular/no-component-direct-api.spec.ts +0 -78
  77. package/src/plugin/rules/angular/no-component-direct-api.ts +0 -82
  78. package/src/plugin/rules/angular/no-method-call-in-template.spec.ts +0 -63
  79. package/src/plugin/rules/angular/no-method-call-in-template.ts +0 -89
  80. package/src/plugin/rules/angular/no-ngfor-directive.spec.ts +0 -44
  81. package/src/plugin/rules/angular/no-ngfor-directive.ts +0 -62
  82. package/src/plugin/rules/angular/no-ngif-directive.spec.ts +0 -44
  83. package/src/plugin/rules/angular/no-ngif-directive.ts +0 -62
  84. package/src/plugin/rules/explicit-types.spec.ts +0 -190
  85. package/src/plugin/rules/explicit-types.ts +0 -186
  86. package/src/plugin/rules/import/import-order.spec.ts +0 -219
  87. package/src/plugin/rules/import/import-order.ts +0 -197
  88. package/src/plugin/rules/import/no-import-type.spec.ts +0 -69
  89. package/src/plugin/rules/import/no-import-type.ts +0 -46
  90. package/src/plugin/rules/import/no-js-import.spec.ts +0 -82
  91. package/src/plugin/rules/import/no-js-import.ts +0 -45
  92. package/src/plugin/rules/naming-patterns.spec.ts +0 -189
  93. package/src/plugin/rules/naming-patterns.ts +0 -426
  94. package/src/plugin/rules/no-getter-logic.spec.ts +0 -591
  95. package/src/plugin/rules/no-getter-logic.ts +0 -220
  96. package/src/plugin/rules/prefer-enum-over-string-union.spec.ts +0 -583
  97. package/src/plugin/rules/prefer-enum-over-string-union.ts +0 -333
  98. package/src/plugin/rules/prefer-interface-over-duplicate-types.spec.ts +0 -404
  99. package/src/plugin/rules/prefer-interface-over-duplicate-types.ts +0 -314
  100. package/src/plugin/rules/require-jsdoc-description.spec.ts +0 -779
  101. package/src/plugin/rules/require-jsdoc-description.ts +0 -572
  102. package/src/plugin/rules/require-test-description-prefix.spec.ts +0 -459
  103. package/src/plugin/rules/require-test-description-prefix.ts +0 -154
  104. package/src/plugin/rules/ts/data-model-extends.spec.ts +0 -84
  105. package/src/plugin/rules/ts/data-model-extends.ts +0 -100
  106. package/src/plugin/rules/ts/no-any-type.spec.ts +0 -28
  107. package/src/plugin/rules/ts/no-any-type.ts +0 -36
  108. package/src/plugin/rules/ts/no-as-cast.spec.ts +0 -51
  109. package/src/plugin/rules/ts/no-as-cast.ts +0 -51
  110. package/src/plugin/rules/ts/no-dynamic-imports.spec.ts +0 -54
  111. package/src/plugin/rules/ts/no-dynamic-imports.ts +0 -49
  112. package/src/plugin/rules/ts/no-native-browser-dialogs.spec.ts +0 -54
  113. package/src/plugin/rules/ts/no-native-browser-dialogs.ts +0 -84
  114. package/src/plugin/rules/ts/no-plain-function-export.spec.ts +0 -72
  115. package/src/plugin/rules/ts/no-plain-function-export.ts +0 -73
  116. package/src/plugin/rules/ts/one-export-per-file.spec.ts +0 -64
  117. package/src/plugin/rules/ts/one-export-per-file.ts +0 -77
  118. package/src/scripts/dynamo-fix.ts +0 -172
  119. package/src/scripts/eslintrc-audit.ts +0 -116
  120. package/src/scripts/fix-return-types.spec.ts +0 -65
  121. package/src/scripts/fix-return-types.ts +0 -289
  122. package/src/scripts/validate-imports.ts +0 -292
  123. package/src/scripts/validate-naming.ts +0 -213
  124. package/src/scripts/validator-cli.integration.spec.ts +0 -99
  125. package/tsconfig.json +0 -32
@@ -1,289 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @fileoverview TypeScript Type Annotation Fix Script
4
- *
5
- * This script uses TypeScript's AST (Abstract Syntax Tree) to automatically add
6
- * type annotations to functions and arrow functions. It analyzes TypeScript files,
7
- * infers return types using the TypeScript compiler, and adds explicit type
8
- * annotations where missing.
9
- *
10
- * @usage
11
- * ```bash
12
- * dynamo-fix-return-types
13
- * ```
14
- *
15
- * @example
16
- * ```bash
17
- * # Fix type annotations in all TypeScript files
18
- * npx dynamo-fix-return-types
19
- *
20
- * # Or run via npm script
21
- * npm run fix:types
22
- * ```
23
- *
24
- * @author Future Development Program Ltd.
25
- * @version 1.14.3
26
- */
27
-
28
- import * as ts from 'typescript';
29
- import * as fs from 'fs';
30
- import * as path from 'path';
31
- import fg from 'fast-glob';
32
-
33
- import { DyFM_Log } from '@futdevpro/fsm-dynamo';
34
-
35
- /**
36
- * Result of fixing type annotations in a single file
37
- */
38
- interface FixResult {
39
- /** Path to the file that was processed */
40
- file: string;
41
- /** Whether the file was actually modified */
42
- fixed: boolean;
43
- /** Number of type annotations added to the file */
44
- changes: number;
45
- }
46
-
47
- /**
48
- * Egy `checker.typeToString(...)`-bol jovo TIPUS-STRING-et valodi `ts.TypeNode`-da
49
- * alakit ugy, hogy egy eldobhato `type __T = <typeString>;` forrast parse-ol es
50
- * kiszedi belole a TypeNode-ot.
51
- *
52
- * MIERT: a regi megoldas `ts.factory.createTypeReferenceNode(typeString)`-et hivott,
53
- * ami CSAK bare identifier-t (entity-name-et) fogad el. Egy generic/union/stb.
54
- * tipus-string (pl. `Record<string, unknown>`) eseten ez tort node-ot epitett, amit
55
- * a printer csonka `Record`-kent (type-argumentumok nelkul) emittalt — ami EGYSZERRE
56
- * tsc-hiba ES uj lint-hiba, igy egyetlen fix-futas 0 → 1+ lint-szamot regresszalt.
57
- * A `typeToString` mindig syntactically valid TS tipus-syntaxot ad vissza, ezert a
58
- * `type __T = …;` parse-olas minden esetre korrekt TypeNode-ot allit elo.
59
- *
60
- * BAIL-OUT: ha a tipus nem alakithato biztonsagos node-da — pl. inline
61
- * `import("/abs/path").Foo` format tartalmaz, ami abszolut path-t szivarogtatna a
62
- * fajlba —, `undefined`-et adunk vissza. A hivo ilyenkor KIHAGYJA az annotaciot:
63
- * jobb annotalatlanul hagyni (marad a figyelmeztetes), mint tort kodot irni.
64
- */
65
- function buildTypeNodeFromString(typeString: string): ts.TypeNode | undefined {
66
- // Inline `import(...)` tipus → projekt-specifikus abszolut/relativ path-t vinne a
67
- // fajlba; sosem biztonsagos textualisan beilleszteni, ezert bail.
68
- if (typeString.includes('import(')) {
69
- return undefined;
70
- }
71
-
72
- const probe: ts.SourceFile = ts.createSourceFile(
73
- '__dynamo_type_probe__.ts',
74
- `type __T = ${typeString};`,
75
- ts.ScriptTarget.Latest,
76
- /* setParentNodes */ false,
77
- );
78
-
79
- const statement: ts.Statement | undefined = probe.statements[0];
80
-
81
- if (!statement || !ts.isTypeAliasDeclaration(statement) || !statement.type) {
82
- return undefined;
83
- }
84
-
85
- return statement.type;
86
- }
87
-
88
- /**
89
- * Adds type annotations to functions and arrow functions in a TypeScript file
90
- *
91
- * Uses TypeScript's compiler API to analyze the file, infer return types,
92
- * and automatically add explicit type annotations where missing.
93
- *
94
- * @param filePath - Path to the TypeScript file to process
95
- * @returns FixResult object containing statistics about the changes made
96
- *
97
- * @example
98
- * ```typescript
99
- * const result = addTypesToFile('./src/utils.ts');
100
- * console.log(`Added ${result.changes} type annotations to ${result.file}`);
101
- * ```
102
- */
103
- function addTypesToFile(filePath: string): FixResult {
104
- // Read and parse the source file
105
- const sourceCode = fs.readFileSync(filePath, 'utf8');
106
- const sourceFile = ts.createSourceFile(filePath, sourceCode, ts.ScriptTarget.Latest, true);
107
-
108
- // Create TypeScript program for type checking
109
- const program = ts.createProgram([filePath], {
110
- target: ts.ScriptTarget.Latest,
111
- module: ts.ModuleKind.ESNext,
112
- strict: true,
113
- skipLibCheck: true,
114
- });
115
-
116
- const checker = program.getTypeChecker();
117
- let changes = 0;
118
- let hasChanges = false;
119
-
120
- /**
121
- * Recursively visits AST nodes and adds type annotations where needed
122
- *
123
- * @param node - The current AST node being visited
124
- * @returns The potentially modified AST node
125
- */
126
- function visit(node: ts.Node): ts.Node {
127
- // Handle function declarations without return types
128
- if (ts.isFunctionDeclaration(node) && !node.type) {
129
- const signature = checker.getSignatureFromDeclaration(node);
130
-
131
- if (signature) {
132
- const returnType = checker.getReturnTypeOfSignature(signature);
133
- const typeString = checker.typeToString(returnType);
134
-
135
- // Add type annotation if it's not void or any
136
- if (typeString !== 'void' && typeString !== 'any') {
137
- const newType = buildTypeNodeFromString(typeString);
138
-
139
- // newType === undefined → a tipus nem serializalhato biztonsagosan,
140
- // kihagyjuk az annotaciot ahelyett hogy tort kodot irnank (B2 bail-out).
141
- if (newType) {
142
- const updatedNode = ts.factory.updateFunctionDeclaration(
143
- node,
144
- node.modifiers,
145
- node.asteriskToken,
146
- node.name,
147
- node.typeParameters,
148
- node.parameters,
149
- newType,
150
- node.body
151
- );
152
- changes++;
153
- hasChanges = true;
154
- return ts.visitEachChild(updatedNode, visit, {} as ts.TransformationContext);
155
- }
156
- }
157
- }
158
- }
159
-
160
- // Handle arrow functions without return types
161
- if (ts.isArrowFunction(node) && !node.type) {
162
- const signature = checker.getSignatureFromDeclaration(node);
163
-
164
- if (signature) {
165
- const returnType = checker.getReturnTypeOfSignature(signature);
166
- const typeString = checker.typeToString(returnType);
167
-
168
- // Add type annotation if it's not void or any
169
- if (typeString !== 'void' && typeString !== 'any') {
170
- const newType = buildTypeNodeFromString(typeString);
171
-
172
- // newType === undefined → a tipus nem serializalhato biztonsagosan,
173
- // kihagyjuk az annotaciot ahelyett hogy tort kodot irnank (B2 bail-out).
174
- if (newType) {
175
- const updatedNode = ts.factory.updateArrowFunction(
176
- node,
177
- node.modifiers,
178
- node.typeParameters,
179
- node.parameters,
180
- newType,
181
- node.equalsGreaterThanToken,
182
- node.body
183
- );
184
- changes++;
185
- hasChanges = true;
186
- return ts.visitEachChild(updatedNode, visit, {} as ts.TransformationContext);
187
- }
188
- }
189
- }
190
- }
191
-
192
- // Note: Variable declarations, parameters, and class properties
193
- // are handled by the existing @typescript-eslint/typedef rule
194
- // and can be auto-fixed with eslint --fix
195
-
196
- return ts.visitEachChild(node, visit, {} as ts.TransformationContext);
197
- }
198
-
199
- // Transform the AST and apply changes
200
- const result = ts.visitEachChild(sourceFile, visit, {} as ts.TransformationContext);
201
-
202
- // Write the modified code back to the file if changes were made
203
- if (hasChanges) {
204
- const printer = ts.createPrinter();
205
- const newSourceCode = printer.printFile(result);
206
- fs.writeFileSync(filePath, newSourceCode);
207
- }
208
-
209
- return {
210
- file: filePath,
211
- fixed: hasChanges,
212
- changes,
213
- };
214
- }
215
-
216
-
217
- /**
218
- * Main function that processes all TypeScript files and adds type annotations
219
- *
220
- * Scans for all .ts and .tsx files in the project, processes each file to add
221
- * missing type annotations, and provides comprehensive reporting on the results.
222
- *
223
- * @returns Promise that resolves when all files have been processed
224
- *
225
- * @throws {Error} When file processing fails
226
- */
227
- async function main() {
228
- // Find all TypeScript files, excluding common directories and test files
229
- const files = await fg([ '**/*.{ts,tsx}' ], {
230
- ignore: [
231
- '**/node_modules/**',
232
- '**/build/**',
233
- '**/dist/**',
234
- '**/*.spec.ts',
235
- '**/*.test.ts',
236
- ],
237
- });
238
-
239
- DyFM_Log.log(`[fix-types] Processing ${files.length} files...`);
240
-
241
- const results: FixResult[] = [];
242
- let totalFixed = 0;
243
- let totalChanges = 0;
244
-
245
- // Process each file individually
246
- for (const file of files) {
247
- try {
248
- const result = addTypesToFile(file);
249
- results.push(result);
250
-
251
- // Track successful fixes
252
- if (result.fixed) {
253
- totalFixed++;
254
- totalChanges += result.changes;
255
- DyFM_Log.log(`✅ Fixed ${result.changes} type annotations in ${file}`);
256
- }
257
- } catch (error) {
258
- DyFM_Log.error(`❌ Error processing ${file}:`, error);
259
- }
260
- }
261
-
262
- // Generate comprehensive summary report
263
- DyFM_Log.log(`\n📊 Fix Summary:`);
264
- DyFM_Log.log(` Files processed: ${files.length}`);
265
- DyFM_Log.log(` Files fixed: ${totalFixed}`);
266
- DyFM_Log.log(` Total type annotations added: ${totalChanges}`);
267
-
268
- // Provide appropriate success/failure message
269
- if (totalFixed > 0) {
270
- DyFM_Log.log(`🎉 Successfully added type annotations to ${totalFixed} files!`);
271
- } else {
272
- DyFM_Log.log('✅ No files needed type annotation fixes!');
273
- }
274
- }
275
-
276
- // Csak akkor futtatjuk a teljes fajl-scan-t, ha a scriptet KOZVETLENUL hivjak
277
- // (CLI bin / `npm run fix:return-types`). Import eseten (pl. spec a helper-ekhez)
278
- // NEM indul el a main(), igy a tiszta segedfuggvenyek unit-tesztelhetok.
279
- if (require.main === module) {
280
- // Execute the main function and handle any errors
281
- main().catch((err) => {
282
- DyFM_Log.error('Fix script failed:', err);
283
- process.exit(1);
284
- });
285
- }
286
-
287
- export { buildTypeNodeFromString, addTypesToFile };
288
-
289
-
@@ -1,292 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * @fileoverview Import Validation Script
4
- *
5
- * This script validates import ordering across all TypeScript files in the project
6
- * using the Dynamo import-order ESLint rule. It scans files, runs ESLint validation,
7
- * and reports any import ordering violations.
8
- *
9
- * @usage
10
- * ```bash
11
- * dynamo-validate-imports
12
- * ```
13
- *
14
- * @example
15
- * ```bash
16
- * # Validate import ordering in all TypeScript files
17
- * npx dynamo-validate-imports
18
- *
19
- * # Or run via npm script
20
- * npm run validate:imports
21
- * ```
22
- *
23
- * @author Future Development Program Ltd.
24
- * @version 1.14.3
25
- */
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
- import { ESLint, Linter } from 'eslint';
108
- import fg from 'fast-glob';
109
-
110
- import { DyFM_Log } from '@futdevpro/fsm-dynamo';
111
-
112
- import importOrderRule from '../plugin/rules/import/import-order';
113
-
114
- // The parser is provided by the unified typescript-eslint consumer peer.
115
- // eslint-disable-next-line @futdevpro/dynamo/no-dynamic-imports, @typescript-eslint/no-require-imports
116
- const tsParser = require('typescript-eslint').parser;
117
-
118
- /**
119
- * Result of validating imports in a single file
120
- */
121
- interface ImportValidationResult {
122
- /** Path to the file that was validated */
123
- file: string;
124
- /** Array of import validation errors found in the file */
125
- errors: {
126
- /** Line number where the error occurred */
127
- line: number;
128
- /** Column number where the error occurred */
129
- column: number;
130
- /** Error message describing the violation */
131
- message: string;
132
- /** ID of the ESLint rule that was violated */
133
- ruleId: string;
134
- }[];
135
- }
136
-
137
- /** Identifies the informational diagnostic emitted when isolated validators intentionally ignore inline config. */
138
- function isIgnoredInlineConfigDiagnostic(message: Linter.LintMessage): boolean {
139
- return !message.ruleId && message.message.includes("has no effect because you have 'noInlineConfig'");
140
- }
141
-
142
- /**
143
- * Validates import ordering in a single TypeScript file
144
- *
145
- * Uses ESLint with the Dynamo import-order rule to check for import ordering
146
- * violations and returns detailed error information.
147
- *
148
- * @param filePath - Path to the TypeScript file to validate
149
- * @returns Promise that resolves to an ImportValidationResult object
150
- *
151
- * @example
152
- * ```typescript
153
- * const result = await validateImportsInFile('./src/components/Button.tsx');
154
- * if (result.errors.length > 0) {
155
- * console.log(`Found ${result.errors.length} import violations`);
156
- * }
157
- * ```
158
- */
159
- async function validateImportsInFile(filePath: string): Promise<ImportValidationResult> {
160
- const eslint = new ESLint({
161
- overrideConfigFile: true,
162
- overrideConfig: [{
163
- files: [ '**/*.{ts,tsx}' ],
164
- linterOptions: {
165
- noInlineConfig: true,
166
- reportUnusedDisableDirectives: 'off',
167
- },
168
- languageOptions: {
169
- parser: tsParser,
170
- parserOptions: {
171
- ecmaVersion: 'latest',
172
- sourceType: 'module',
173
- },
174
- },
175
- plugins: {
176
- '@futdevpro/dynamo': {
177
- rules: {
178
- 'import-order': importOrderRule,
179
- },
180
- },
181
- },
182
- rules: {
183
- '@futdevpro/dynamo/import-order': 'error',
184
- },
185
- }],
186
- });
187
-
188
- // Run ESLint on the file
189
- const results: ESLint.LintResult[] = await eslint.lintFiles([ filePath ]);
190
- const result: ESLint.LintResult = results[0];
191
-
192
- // Transform ESLint messages into our result format
193
- return {
194
- file: filePath,
195
- errors: result.messages
196
- .filter((message: Linter.LintMessage): boolean => !isIgnoredInlineConfigDiagnostic(message))
197
- .map((message: Linter.LintMessage): ImportValidationResult['errors'][number] => ({
198
- line: message.line,
199
- column: message.column,
200
- message: message.message,
201
- ruleId: message.ruleId || 'unknown',
202
- })),
203
- };
204
- }
205
-
206
- /**
207
- * Main function that validates import ordering across all TypeScript files
208
- *
209
- * Scans for all .ts and .tsx files in the project, validates import ordering
210
- * using the Dynamo import-order rule, and provides detailed reporting on any
211
- * violations found.
212
- *
213
- * @returns Promise that resolves when all files have been validated
214
- *
215
- * @throws {Error} When validation fails and process exits with code 1
216
- */
217
- async function main(): Promise<void> {
218
- // Find all TypeScript files, excluding common directories and test files
219
- const files: string[] = await fg([ '**/*.{ts,tsx}' ], {
220
- ignore: [
221
- '**/node_modules/**',
222
- '**/build/**',
223
- '**/dist/**',
224
- '**/samples/**',
225
- '**/*.spec.ts',
226
- '**/*.test.ts',
227
- ],
228
- });
229
-
230
- DyFM_Log.log(`[dynamo-validate-imports] Scanning ${files.length} files...`);
231
-
232
- const results: ImportValidationResult[] = [];
233
- let totalErrors = 0;
234
- let processingFailures = 0;
235
-
236
- // Process each file individually
237
- for (const file of files) {
238
- try {
239
- const result: ImportValidationResult = await validateImportsInFile(file);
240
-
241
- results.push(result);
242
- totalErrors += result.errors.length;
243
- } catch (error) {
244
- DyFM_Log.error(`Error processing ${file}:`, error);
245
- processingFailures++;
246
- }
247
- }
248
-
249
- // BFR-PROTO-005: a feldolgozási hiba (pl. hiányzó runtime-modul) NEM nyelhető le zöldre —
250
- // korábban minden fájl crash-elt, és a végén mégis "✅ passed" + exit 0 ment ki (fail-green).
251
- if (processingFailures > 0) {
252
- DyFM_Log.error(
253
- `❌ ${processingFailures}/${files.length} file(s) FAILED to process (runtime/module error above) — ` +
254
- 'validation result is NOT trustworthy, failing hard.'
255
- );
256
- process.exit(1);
257
- }
258
-
259
- // Filter files that have import violations
260
- const filesWithErrors: ImportValidationResult[] = results.filter(
261
- (result: ImportValidationResult): boolean => result.errors.length > 0,
262
- );
263
-
264
- // Report success if no violations found
265
- if (filesWithErrors.length === 0) {
266
- DyFM_Log.log('✅ All import validations passed!');
267
-
268
- return;
269
- }
270
-
271
- // Report detailed error information
272
- DyFM_Log.warn(`\n❌ Found ${totalErrors} import validation errors in ${filesWithErrors.length} files:\n`);
273
-
274
- filesWithErrors.forEach((result: ImportValidationResult): void => {
275
- DyFM_Log.log(`📁 ${result.file}:`);
276
- result.errors.forEach((error: ImportValidationResult['errors'][number]): void => {
277
- DyFM_Log.log(` ${error.line}:${error.column} - ${error.message}`);
278
- });
279
- DyFM_Log.log('');
280
- });
281
-
282
- // Exit with error code to indicate validation failure
283
- process.exit(1);
284
- }
285
-
286
- // Execute the main function and handle any errors
287
- main().catch((err: Error): void => {
288
- DyFM_Log.error('Validation failed:', err);
289
- process.exit(1);
290
- });
291
-
292
-