@futdevpro/dynamo-eslint 1.14.3 → 1.14.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 (67) hide show
  1. package/.eslintrc.json +4 -0
  2. package/.vscode/settings.json +11 -0
  3. package/README.md +17 -2
  4. package/build/configs/base.js +19 -7
  5. package/build/configs/base.js.map +1 -1
  6. package/build/plugin/index.d.ts +2 -0
  7. package/build/plugin/index.d.ts.map +1 -1
  8. package/build/plugin/index.js +3 -0
  9. package/build/plugin/index.js.map +1 -1
  10. package/build/plugin/rules/explicit-types.d.ts +4 -0
  11. package/build/plugin/rules/explicit-types.d.ts.map +1 -0
  12. package/build/plugin/rules/explicit-types.js +179 -0
  13. package/build/plugin/rules/explicit-types.js.map +1 -0
  14. package/build/plugin/rules/explicit-types.spec.d.ts +2 -0
  15. package/build/plugin/rules/explicit-types.spec.d.ts.map +1 -0
  16. package/build/plugin/rules/explicit-types.spec.js +162 -0
  17. package/build/plugin/rules/explicit-types.spec.js.map +1 -0
  18. package/build/plugin/rules/import/import-order.d.ts.map +1 -1
  19. package/build/plugin/rules/import/import-order.js +0 -9
  20. package/build/plugin/rules/import/import-order.js.map +1 -1
  21. package/build/plugin/rules/import/no-import-type.d.ts.map +1 -1
  22. package/build/plugin/rules/import/no-import-type.js +23 -12
  23. package/build/plugin/rules/import/no-import-type.js.map +1 -1
  24. package/build/plugin/rules/import/no-js-import.d.ts.map +1 -1
  25. package/build/plugin/rules/import/no-js-import.js +19 -11
  26. package/build/plugin/rules/import/no-js-import.js.map +1 -1
  27. package/build/plugin/rules/naming-patterns.d.ts.map +1 -1
  28. package/build/plugin/rules/naming-patterns.js +7 -2
  29. package/build/plugin/rules/naming-patterns.js.map +1 -1
  30. package/build/scripts/dynamo-fix.d.ts +24 -0
  31. package/build/scripts/dynamo-fix.d.ts.map +1 -1
  32. package/build/scripts/dynamo-fix.js +57 -2
  33. package/build/scripts/dynamo-fix.js.map +1 -1
  34. package/build/scripts/eslintrc-audit.d.ts +24 -0
  35. package/build/scripts/eslintrc-audit.d.ts.map +1 -1
  36. package/build/scripts/eslintrc-audit.js +65 -0
  37. package/build/scripts/eslintrc-audit.js.map +1 -1
  38. package/build/scripts/fix-return-types.d.ts +25 -0
  39. package/build/scripts/fix-return-types.d.ts.map +1 -1
  40. package/build/scripts/fix-return-types.js +80 -9
  41. package/build/scripts/fix-return-types.js.map +1 -1
  42. package/build/scripts/validate-imports.d.ts +24 -0
  43. package/build/scripts/validate-imports.d.ts.map +1 -1
  44. package/build/scripts/validate-imports.js +62 -1
  45. package/build/scripts/validate-imports.js.map +1 -1
  46. package/build/scripts/validate-naming.d.ts +24 -0
  47. package/build/scripts/validate-naming.d.ts.map +1 -1
  48. package/build/scripts/validate-naming.js +72 -9
  49. package/build/scripts/validate-naming.js.map +1 -1
  50. package/eslint.config.js +9 -49
  51. package/futdevpro-dynamo-eslint-1.14.6.tgz +0 -0
  52. package/package.json +1 -1
  53. package/samples/package.json.example +1 -1
  54. package/src/configs/base.ts +34 -22
  55. package/src/plugin/index.ts +3 -0
  56. package/src/plugin/rules/explicit-types.spec.ts +190 -0
  57. package/src/plugin/rules/explicit-types.ts +186 -0
  58. package/src/plugin/rules/import/import-order.ts +0 -9
  59. package/src/plugin/rules/import/no-import-type.ts +21 -12
  60. package/src/plugin/rules/import/no-js-import.ts +25 -15
  61. package/src/plugin/rules/naming-patterns.ts +6 -2
  62. package/src/scripts/dynamo-fix.ts +66 -2
  63. package/src/scripts/eslintrc-audit.ts +79 -6
  64. package/src/scripts/fix-return-types.ts +91 -9
  65. package/src/scripts/validate-imports.ts +71 -2
  66. package/src/scripts/validate-naming.ts +108 -17
  67. package/futdevpro-dynamo-eslint-01.14.3.tgz +0 -0
@@ -1,14 +1,56 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ /**
4
+ * @fileoverview TypeScript Type Annotation Fix Script
5
+ *
6
+ * This script uses TypeScript's AST (Abstract Syntax Tree) to automatically add
7
+ * type annotations to functions and arrow functions. It analyzes TypeScript files,
8
+ * infers return types using the TypeScript compiler, and adds explicit type
9
+ * annotations where missing.
10
+ *
11
+ * @usage
12
+ * ```bash
13
+ * dynamo-fix-return-types
14
+ * ```
15
+ *
16
+ * @example
17
+ * ```bash
18
+ * # Fix type annotations in all TypeScript files
19
+ * npx dynamo-fix-return-types
20
+ *
21
+ * # Or run via npm script
22
+ * npm run fix:types
23
+ * ```
24
+ *
25
+ * @author Future Development Program Ltd.
26
+ * @version 1.14.3
27
+ */
3
28
  Object.defineProperty(exports, "__esModule", { value: true });
4
29
  const tslib_1 = require("tslib");
5
30
  const ts = tslib_1.__importStar(require("typescript"));
6
31
  const fs = tslib_1.__importStar(require("fs"));
7
32
  const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
8
33
  const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
9
- function addReturnTypesToFile(filePath) {
34
+ /**
35
+ * Adds type annotations to functions and arrow functions in a TypeScript file
36
+ *
37
+ * Uses TypeScript's compiler API to analyze the file, infer return types,
38
+ * and automatically add explicit type annotations where missing.
39
+ *
40
+ * @param filePath - Path to the TypeScript file to process
41
+ * @returns FixResult object containing statistics about the changes made
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const result = addTypesToFile('./src/utils.ts');
46
+ * console.log(`Added ${result.changes} type annotations to ${result.file}`);
47
+ * ```
48
+ */
49
+ function addTypesToFile(filePath) {
50
+ // Read and parse the source file
10
51
  const sourceCode = fs.readFileSync(filePath, 'utf8');
11
52
  const sourceFile = ts.createSourceFile(filePath, sourceCode, ts.ScriptTarget.Latest, true);
53
+ // Create TypeScript program for type checking
12
54
  const program = ts.createProgram([filePath], {
13
55
  target: ts.ScriptTarget.Latest,
14
56
  module: ts.ModuleKind.ESNext,
@@ -18,13 +60,20 @@ function addReturnTypesToFile(filePath) {
18
60
  const checker = program.getTypeChecker();
19
61
  let changes = 0;
20
62
  let hasChanges = false;
63
+ /**
64
+ * Recursively visits AST nodes and adds type annotations where needed
65
+ *
66
+ * @param node - The current AST node being visited
67
+ * @returns The potentially modified AST node
68
+ */
21
69
  function visit(node) {
22
- // Handle function declarations
70
+ // Handle function declarations without return types
23
71
  if (ts.isFunctionDeclaration(node) && !node.type) {
24
72
  const signature = checker.getSignatureFromDeclaration(node);
25
73
  if (signature) {
26
74
  const returnType = checker.getReturnTypeOfSignature(signature);
27
75
  const typeString = checker.typeToString(returnType);
76
+ // Add type annotation if it's not void or any
28
77
  if (typeString !== 'void' && typeString !== 'any') {
29
78
  const newType = ts.factory.createTypeReferenceNode(typeString);
30
79
  const updatedNode = ts.factory.updateFunctionDeclaration(node, node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, newType, node.body);
@@ -34,12 +83,13 @@ function addReturnTypesToFile(filePath) {
34
83
  }
35
84
  }
36
85
  }
37
- // Handle arrow functions
86
+ // Handle arrow functions without return types
38
87
  if (ts.isArrowFunction(node) && !node.type) {
39
88
  const signature = checker.getSignatureFromDeclaration(node);
40
89
  if (signature) {
41
90
  const returnType = checker.getReturnTypeOfSignature(signature);
42
91
  const typeString = checker.typeToString(returnType);
92
+ // Add type annotation if it's not void or any
43
93
  if (typeString !== 'void' && typeString !== 'any') {
44
94
  const newType = ts.factory.createTypeReferenceNode(typeString);
45
95
  const updatedNode = ts.factory.updateArrowFunction(node, node.modifiers, node.typeParameters, node.parameters, newType, node.equalsGreaterThanToken, node.body);
@@ -49,9 +99,14 @@ function addReturnTypesToFile(filePath) {
49
99
  }
50
100
  }
51
101
  }
102
+ // Note: Variable declarations, parameters, and class properties
103
+ // are handled by the existing @typescript-eslint/typedef rule
104
+ // and can be auto-fixed with eslint --fix
52
105
  return ts.visitEachChild(node, visit, {});
53
106
  }
107
+ // Transform the AST and apply changes
54
108
  const result = ts.visitEachChild(sourceFile, visit, {});
109
+ // Write the modified code back to the file if changes were made
55
110
  if (hasChanges) {
56
111
  const printer = ts.createPrinter();
57
112
  const newSourceCode = printer.printFile(result);
@@ -63,7 +118,18 @@ function addReturnTypesToFile(filePath) {
63
118
  changes,
64
119
  };
65
120
  }
121
+ /**
122
+ * Main function that processes all TypeScript files and adds type annotations
123
+ *
124
+ * Scans for all .ts and .tsx files in the project, processes each file to add
125
+ * missing type annotations, and provides comprehensive reporting on the results.
126
+ *
127
+ * @returns Promise that resolves when all files have been processed
128
+ *
129
+ * @throws {Error} When file processing fails
130
+ */
66
131
  async function main() {
132
+ // Find all TypeScript files, excluding common directories and test files
67
133
  const files = await (0, fast_glob_1.default)(['**/*.{ts,tsx}'], {
68
134
  ignore: [
69
135
  '**/node_modules/**',
@@ -73,35 +139,40 @@ async function main() {
73
139
  '**/*.test.ts',
74
140
  ],
75
141
  });
76
- fsm_dynamo_1.DyFM_Log.log(`[fix-return-types] Processing ${files.length} files...`);
142
+ fsm_dynamo_1.DyFM_Log.log(`[fix-types] Processing ${files.length} files...`);
77
143
  const results = [];
78
144
  let totalFixed = 0;
79
145
  let totalChanges = 0;
146
+ // Process each file individually
80
147
  for (const file of files) {
81
148
  try {
82
- const result = addReturnTypesToFile(file);
149
+ const result = addTypesToFile(file);
83
150
  results.push(result);
151
+ // Track successful fixes
84
152
  if (result.fixed) {
85
153
  totalFixed++;
86
154
  totalChanges += result.changes;
87
- fsm_dynamo_1.DyFM_Log.log(`✅ Fixed ${result.changes} return types in ${file}`);
155
+ fsm_dynamo_1.DyFM_Log.log(`✅ Fixed ${result.changes} type annotations in ${file}`);
88
156
  }
89
157
  }
90
158
  catch (error) {
91
159
  fsm_dynamo_1.DyFM_Log.error(`❌ Error processing ${file}:`, error);
92
160
  }
93
161
  }
162
+ // Generate comprehensive summary report
94
163
  fsm_dynamo_1.DyFM_Log.log(`\n📊 Fix Summary:`);
95
164
  fsm_dynamo_1.DyFM_Log.log(` Files processed: ${files.length}`);
96
165
  fsm_dynamo_1.DyFM_Log.log(` Files fixed: ${totalFixed}`);
97
- fsm_dynamo_1.DyFM_Log.log(` Total return types added: ${totalChanges}`);
166
+ fsm_dynamo_1.DyFM_Log.log(` Total type annotations added: ${totalChanges}`);
167
+ // Provide appropriate success/failure message
98
168
  if (totalFixed > 0) {
99
- fsm_dynamo_1.DyFM_Log.log(`🎉 Successfully added return types to ${totalFixed} files!`);
169
+ fsm_dynamo_1.DyFM_Log.log(`🎉 Successfully added type annotations to ${totalFixed} files!`);
100
170
  }
101
171
  else {
102
- fsm_dynamo_1.DyFM_Log.log('✅ No files needed return type fixes!');
172
+ fsm_dynamo_1.DyFM_Log.log('✅ No files needed type annotation fixes!');
103
173
  }
104
174
  }
175
+ // Execute the main function and handle any errors
105
176
  main().catch((err) => {
106
177
  fsm_dynamo_1.DyFM_Log.error('Fix script failed:', err);
107
178
  process.exit(1);
@@ -1 +1 @@
1
- {"version":3,"file":"fix-return-types.js","sourceRoot":"","sources":["../../src/scripts/fix-return-types.ts"],"names":[],"mappings":";;;;AACA,uDAAiC;AACjC,+CAAyB;AAEzB,kEAA2B;AAC3B,sDAAiD;AAQjD,SAAS,oBAAoB,CAAC,QAAgB;IAC5C,MAAM,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE3F,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,EAAE;QAC3C,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM;QAC9B,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM;QAC5B,MAAM,EAAE,IAAI;QACZ,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IACzC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,UAAU,GAAG,KAAK,CAAC;IAEvB,SAAS,KAAK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AClD,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,qBAAQ,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,3 +1,27 @@
1
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
+ */
2
26
  export {};
3
27
  //# sourceMappingURL=validate-imports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-imports.d.ts","sourceRoot":"","sources":["../../src/scripts/validate-imports.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"validate-imports.d.ts","sourceRoot":"","sources":["../../src/scripts/validate-imports.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
@@ -1,11 +1,53 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ /**
4
+ * @fileoverview Import Validation Script
5
+ *
6
+ * This script validates import ordering across all TypeScript files in the project
7
+ * using the Dynamo import-order ESLint rule. It scans files, runs ESLint validation,
8
+ * and reports any import ordering violations.
9
+ *
10
+ * @usage
11
+ * ```bash
12
+ * dynamo-validate-imports
13
+ * ```
14
+ *
15
+ * @example
16
+ * ```bash
17
+ * # Validate import ordering in all TypeScript files
18
+ * npx dynamo-validate-imports
19
+ *
20
+ * # Or run via npm script
21
+ * npm run validate:imports
22
+ * ```
23
+ *
24
+ * @author Future Development Program Ltd.
25
+ * @version 1.14.3
26
+ */
3
27
  Object.defineProperty(exports, "__esModule", { value: true });
4
28
  const tslib_1 = require("tslib");
5
29
  const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
6
30
  const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
7
31
  const eslint_1 = require("eslint");
32
+ /**
33
+ * Validates import ordering in a single TypeScript file
34
+ *
35
+ * Uses ESLint with the Dynamo import-order rule to check for import ordering
36
+ * violations and returns detailed error information.
37
+ *
38
+ * @param filePath - Path to the TypeScript file to validate
39
+ * @returns Promise that resolves to an ImportValidationResult object
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const result = await validateImportsInFile('./src/components/Button.tsx');
44
+ * if (result.errors.length > 0) {
45
+ * console.log(`Found ${result.errors.length} import violations`);
46
+ * }
47
+ * ```
48
+ */
8
49
  async function validateImportsInFile(filePath) {
50
+ // Configure ESLint with Dynamo import-order rule
9
51
  const eslint = new eslint_1.ESLint({
10
52
  baseConfig: {
11
53
  parser: '@typescript-eslint/parser',
@@ -25,8 +67,10 @@ async function validateImportsInFile(filePath) {
25
67
  },
26
68
  },
27
69
  });
70
+ // Run ESLint on the file
28
71
  const results = await eslint.lintFiles([filePath]);
29
72
  const result = results[0];
73
+ // Transform ESLint messages into our result format
30
74
  return {
31
75
  file: filePath,
32
76
  errors: result.messages.map(msg => ({
@@ -37,13 +81,26 @@ async function validateImportsInFile(filePath) {
37
81
  })),
38
82
  };
39
83
  }
84
+ /**
85
+ * Main function that validates import ordering across all TypeScript files
86
+ *
87
+ * Scans for all .ts and .tsx files in the project, validates import ordering
88
+ * using the Dynamo import-order rule, and provides detailed reporting on any
89
+ * violations found.
90
+ *
91
+ * @returns Promise that resolves when all files have been validated
92
+ *
93
+ * @throws {Error} When validation fails and process exits with code 1
94
+ */
40
95
  async function main() {
96
+ // Find all TypeScript files, excluding common directories and test files
41
97
  const files = await (0, fast_glob_1.default)(['**/*.{ts,tsx}'], {
42
98
  ignore: ['**/node_modules/**', '**/build/**', '**/dist/**', '**/*.spec.ts', '**/*.test.ts'],
43
99
  });
44
100
  fsm_dynamo_1.DyFM_Log.log(`[dynamo-validate-imports] Scanning ${files.length} files...`);
45
101
  const results = [];
46
102
  let totalErrors = 0;
103
+ // Process each file individually
47
104
  for (const file of files) {
48
105
  try {
49
106
  const result = await validateImportsInFile(file);
@@ -54,12 +111,14 @@ async function main() {
54
111
  fsm_dynamo_1.DyFM_Log.error(`Error processing ${file}:`, error);
55
112
  }
56
113
  }
57
- // Report results
114
+ // Filter files that have import violations
58
115
  const filesWithErrors = results.filter(r => r.errors.length > 0);
116
+ // Report success if no violations found
59
117
  if (filesWithErrors.length === 0) {
60
118
  fsm_dynamo_1.DyFM_Log.log('✅ All import validations passed!');
61
119
  return;
62
120
  }
121
+ // Report detailed error information
63
122
  fsm_dynamo_1.DyFM_Log.warn(`\n❌ Found ${totalErrors} import validation errors in ${filesWithErrors.length} files:\n`);
64
123
  filesWithErrors.forEach(result => {
65
124
  fsm_dynamo_1.DyFM_Log.log(`📁 ${result.file}:`);
@@ -68,8 +127,10 @@ async function main() {
68
127
  });
69
128
  fsm_dynamo_1.DyFM_Log.log('');
70
129
  });
130
+ // Exit with error code to indicate validation failure
71
131
  process.exit(1);
72
132
  }
133
+ // Execute the main function and handle any errors
73
134
  main().catch((err) => {
74
135
  fsm_dynamo_1.DyFM_Log.error('Validation failed:', err);
75
136
  process.exit(1);
@@ -1 +1 @@
1
- {"version":3,"file":"validate-imports.js","sourceRoot":"","sources":["../../src/scripts/validate-imports.ts"],"names":[],"mappings":";;;;AAkFA,sDAAiD;AACjD,kEAA2B;AAC3B,mCAAgC;AAYhC,KAAK,UAAU,qBAAqB,CAAC,QAAgB;IACnD,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;QACxB,UAAU,EAAE;YACV,MAAM,EAAE,2BAA2B;YACnC,aAAa,EAAE;gBACb,WAAW,EAAE,IAA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,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;QACH,qBAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,sDAAsD;IACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,kDAAkD;AAClD,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,qBAAQ,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,3 +1,27 @@
1
1
  #!/usr/bin/env node
2
+ /**
3
+ * @fileoverview Naming Convention Validation Script
4
+ *
5
+ * This script validates naming conventions across all TypeScript files in the project
6
+ * using the Dynamo naming-patterns ESLint rule. It scans files, runs ESLint validation,
7
+ * and reports any naming convention violations.
8
+ *
9
+ * @usage
10
+ * ```bash
11
+ * dynamo-validate-naming
12
+ * ```
13
+ *
14
+ * @example
15
+ * ```bash
16
+ * # Validate naming conventions in all TypeScript files
17
+ * npx dynamo-validate-naming
18
+ *
19
+ * # Or run via npm script
20
+ * npm run validate:naming
21
+ * ```
22
+ *
23
+ * @author Future Development Program Ltd.
24
+ * @version 1.14.3
25
+ */
2
26
  export {};
3
27
  //# sourceMappingURL=validate-naming.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validate-naming.d.ts","sourceRoot":"","sources":["../../src/scripts/validate-naming.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"validate-naming.d.ts","sourceRoot":"","sources":["../../src/scripts/validate-naming.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
@@ -1,19 +1,64 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
+ /**
4
+ * @fileoverview Naming Convention Validation Script
5
+ *
6
+ * This script validates naming conventions across all TypeScript files in the project
7
+ * using the Dynamo naming-patterns ESLint rule. It scans files, runs ESLint validation,
8
+ * and reports any naming convention violations.
9
+ *
10
+ * @usage
11
+ * ```bash
12
+ * dynamo-validate-naming
13
+ * ```
14
+ *
15
+ * @example
16
+ * ```bash
17
+ * # Validate naming conventions in all TypeScript files
18
+ * npx dynamo-validate-naming
19
+ *
20
+ * # Or run via npm script
21
+ * npm run validate:naming
22
+ * ```
23
+ *
24
+ * @author Future Development Program Ltd.
25
+ * @version 1.14.3
26
+ */
3
27
  Object.defineProperty(exports, "__esModule", { value: true });
4
28
  const tslib_1 = require("tslib");
5
29
  const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
6
30
  const eslint_1 = require("eslint");
7
31
  const fsm_dynamo_1 = require("@futdevpro/fsm-dynamo");
32
+ /**
33
+ * Validates naming conventions in a single TypeScript file
34
+ *
35
+ * Uses ESLint with the Dynamo naming-patterns rule to check for naming convention
36
+ * violations and returns detailed error information.
37
+ *
38
+ * @param filePath - Path to the TypeScript file to validate
39
+ * @returns Promise that resolves to a NamingValidationResult object
40
+ *
41
+ * @example
42
+ * ```typescript
43
+ * const result = await validateNamingInFile('./src/components/Button.tsx');
44
+ * if (result.errors.length > 0) {
45
+ * console.log(`Found ${result.errors.length} naming violations`);
46
+ * }
47
+ * ```
48
+ */
8
49
  async function validateNamingInFile(filePath) {
50
+ // Configure ESLint using the main Dynamo configuration
9
51
  const eslint = new eslint_1.ESLint({
10
- baseConfig: require('../eslint.config.js')[1], // Use the main config object from flat config array
52
+ // Use the main config object from flat config array
53
+ baseConfig: require('../eslint.config.js')[1],
11
54
  });
55
+ // Run ESLint on the file
12
56
  const results = await eslint.lintFiles([filePath]);
13
57
  const result = results[0];
58
+ // Transform ESLint messages into our result format
14
59
  return {
15
60
  file: filePath,
16
- errors: result.messages.map(msg => ({
61
+ errors: result.messages.map((msg) => ({
17
62
  line: msg.line,
18
63
  column: msg.column,
19
64
  message: msg.message,
@@ -21,39 +66,57 @@ async function validateNamingInFile(filePath) {
21
66
  })),
22
67
  };
23
68
  }
69
+ /**
70
+ * Main function that validates naming conventions across all TypeScript files
71
+ *
72
+ * Scans for all .ts and .tsx files in the project, validates naming conventions
73
+ * using the Dynamo naming-patterns rule, and provides detailed reporting on any
74
+ * violations found.
75
+ *
76
+ * @returns Promise that resolves when all files have been validated
77
+ *
78
+ * @throws {Error} When validation fails and process exits with code 1
79
+ */
24
80
  async function main() {
81
+ // Find all TypeScript files, excluding common directories and test files
25
82
  const files = await (0, fast_glob_1.default)(['**/*.{ts,tsx}'], {
26
83
  ignore: ['**/node_modules/**', '**/build/**', '**/dist/**', '**/*.spec.ts', '**/*.test.ts'],
27
84
  });
28
85
  fsm_dynamo_1.DyFM_Log.log(`[dynamo-validate-naming] Scanning ${files.length} files...`);
29
86
  const results = [];
30
87
  let totalErrors = 0;
31
- for (const file of files) {
88
+ // Process each file individually
89
+ for (let i = 0; i < files.length; i++) {
90
+ const filePath = files[i];
32
91
  try {
33
- const result = await validateNamingInFile(file);
92
+ const result = await validateNamingInFile(filePath);
34
93
  results.push(result);
35
94
  totalErrors += result.errors.length;
36
95
  }
37
96
  catch (error) {
38
- fsm_dynamo_1.DyFM_Log.error(`Error processing ${file}:`, error);
97
+ fsm_dynamo_1.DyFM_Log.error(`Error processing ${filePath}:`, error);
39
98
  }
40
99
  }
41
- // Report results
42
- const filesWithErrors = results.filter(r => r.errors.length > 0);
100
+ // Filter files that have naming violations
101
+ const filesWithErrors = results.filter((r) => r.errors.length > 0);
102
+ // Report success if no violations found
43
103
  if (filesWithErrors.length === 0) {
44
104
  fsm_dynamo_1.DyFM_Log.log('✅ All naming validations passed!');
45
105
  return;
46
106
  }
107
+ // Report detailed error information
47
108
  fsm_dynamo_1.DyFM_Log.warn(`\n❌ Found ${totalErrors} naming validation errors in ${filesWithErrors.length} files:\n`);
48
- filesWithErrors.forEach(result => {
109
+ filesWithErrors.forEach((result) => {
49
110
  fsm_dynamo_1.DyFM_Log.log(`📁 ${result.file}:`);
50
- result.errors.forEach(error => {
111
+ result.errors.forEach((error) => {
51
112
  fsm_dynamo_1.DyFM_Log.log(` ${error.line}:${error.column} - ${error.message}`);
52
113
  });
53
114
  fsm_dynamo_1.DyFM_Log.log('');
54
115
  });
116
+ // Exit with error code to indicate validation failure
55
117
  process.exit(1);
56
118
  }
119
+ // Execute the main function and handle any errors
57
120
  main().catch((err) => {
58
121
  fsm_dynamo_1.DyFM_Log.error('Validation failed:', err);
59
122
  process.exit(1);
@@ -1 +1 @@
1
- {"version":3,"file":"validate-naming.js","sourceRoot":"","sources":["../../src/scripts/validate-naming.ts"],"names":[],"mappings":";;;;AACA,kEAA2B;AAE3B,mCAAgC;AAEhC,sDAAiD;AAYjD,KAAK,UAAU,oBAAoB,CAAC,QAAgB;IAClD,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;QACxB,UAAU,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,EAAE,oDAAoD;KACpG,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAE,QAAQ,CAAE,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAE1B,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAClC,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,SAAS;SAChC,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAE,EAAC,CAAE,eAAe,CAAE,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,kCAAkC,CAAC,CAAC;QAEjD,OAAO;IACT,CAAC;IAED,oCAAoC;IACpC,qBAAQ,CAAC,IAAI,CACX,aAAa,WAAW,gCAAgC,eAAe,CAAC,MAAM,WAAW,CAC1F,CAAC;IAEF,eAAe,CAAC,OAAO,CAAC,CAAC,MAA8B,EAAQ,EAAE;QAC/D,qBAAQ,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAKtB,EAAQ,EAAE;YACT,qBAAQ,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;QACH,qBAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,sDAAsD;IACtD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,kDAAkD;AAClD,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAU,EAAQ,EAAE;IAChC,qBAAQ,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/eslint.config.js CHANGED
@@ -1,55 +1,15 @@
1
- // ESLint v9 flat config for self-linting this package
2
- // Uses nts-package ruleset with Dynamo custom rules
3
-
4
- const tsParser = require('@typescript-eslint/parser');
5
- const tsPlugin = require('@typescript-eslint/eslint-plugin');
6
- const unusedImportsPlugin = require('eslint-plugin-unused-imports');
7
- const maxParamsNoConstructorPlugin = require('eslint-plugin-max-params-no-constructor');
8
-
9
- // Load our plugin from build-test to avoid requiring a prior build
10
- const dynamoPlugin = (function loadDynamoPlugin() {
11
- try {
12
- // build-test compiled output for quick iteration
13
- return require('./build-test/plugin').default || require('./build-test/plugin');
14
- } catch {
15
- // fallback: try built output if present
16
- return require('./build/plugin');
17
- }
18
- })();
19
-
20
- // Load nts-package config
21
1
  const ntsPackageConfig = require('./build/configs/nts-package');
22
2
 
23
3
  module.exports = [
24
- {
25
- ignores: [
26
- 'build/**',
27
- 'dist/**',
28
- 'node_modules/**'
29
- ]
30
- },
4
+ ...ntsPackageConfig,
31
5
  {
32
- files: [
33
- 'src/**/*.ts'
34
- ],
6
+ files: ['**/*.ts', '**/*.tsx'],
35
7
  languageOptions: {
36
- parser: tsParser,
37
- parserOptions: {
38
- ecmaVersion: 'latest',
39
- sourceType: 'module'
40
- },
41
- },
42
- plugins: {
43
- '@typescript-eslint': tsPlugin,
44
- '@futdevpro/dynamo': dynamoPlugin,
45
- 'unused-imports': unusedImportsPlugin,
46
- 'max-params-no-constructor': maxParamsNoConstructorPlugin,
47
- },
48
- rules: {
49
- // Apply all nts-package rules (they're all compatible now!)
50
- ...ntsPackageConfig.rules,
51
- },
52
- },
8
+ parser: require('@typescript-eslint/parser'),
9
+ parserOptions: {
10
+ ecmaVersion: 'latest',
11
+ sourceType: 'module'
12
+ }
13
+ }
14
+ }
53
15
  ];
54
-
55
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@futdevpro/dynamo-eslint",
3
- "version": "01.14.3",
3
+ "version": "1.14.6",
4
4
  "description": "Shared ESLint configs, Dynamo-powered plugin and validators for FutDevPro stacks",
5
5
  "author": "Future Development Program Ltd.",
6
6
  "license": "ISC",
@@ -13,7 +13,7 @@
13
13
  "test": "npm run lint && npm run validate:imports && npm run validate:naming"
14
14
  },
15
15
  "devDependencies": {
16
- "@futdevpro/dynamo-eslint": "^01.14.2",
16
+ "@futdevpro/dynamo-eslint": "1.14.4",
17
17
  "@typescript-eslint/eslint-plugin": "^8.0.0",
18
18
  "@typescript-eslint/parser": "^8.0.0",
19
19
  "eslint": "^9.0.0",