@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,31 +1,95 @@
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
+ */
26
+
2
27
  import fg from 'fast-glob';
3
- import { readFileSync } from 'fs';
4
28
  import { ESLint } from 'eslint';
5
29
 
6
30
  import { DyFM_Log } from '@futdevpro/fsm-dynamo';
7
31
 
32
+ /**
33
+ * Result of validating naming conventions in a single file
34
+ */
8
35
  interface NamingValidationResult {
36
+ /** Path to the file that was validated */
9
37
  file: string;
38
+ /** Array of naming validation errors found in the file */
10
39
  errors: Array<{
40
+ /** Line number where the error occurred */
11
41
  line: number;
42
+ /** Column number where the error occurred */
12
43
  column: number;
44
+ /** Error message describing the violation */
13
45
  message: string;
46
+ /** ID of the ESLint rule that was violated */
14
47
  ruleId: string;
15
48
  }>;
16
49
  }
17
50
 
51
+ /**
52
+ * Validates naming conventions in a single TypeScript file
53
+ *
54
+ * Uses ESLint with the Dynamo naming-patterns rule to check for naming convention
55
+ * violations and returns detailed error information.
56
+ *
57
+ * @param filePath - Path to the TypeScript file to validate
58
+ * @returns Promise that resolves to a NamingValidationResult object
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const result = await validateNamingInFile('./src/components/Button.tsx');
63
+ * if (result.errors.length > 0) {
64
+ * console.log(`Found ${result.errors.length} naming violations`);
65
+ * }
66
+ * ```
67
+ */
18
68
  async function validateNamingInFile(filePath: string): Promise<NamingValidationResult> {
69
+ // Configure ESLint using the main Dynamo configuration
19
70
  const eslint = new ESLint({
20
- baseConfig: require('../eslint.config.js')[1], // Use the main config object from flat config array
71
+ // Use the main config object from flat config array
72
+ baseConfig: require('../eslint.config.js')[1],
21
73
  });
22
74
 
23
- const results = await eslint.lintFiles([ filePath ]);
24
- const result = results[0];
75
+ // Run ESLint on the file
76
+ const results: ESLint.LintResult[] = await eslint.lintFiles([ filePath ]);
77
+ const result: ESLint.LintResult = results[0];
25
78
 
79
+ // Transform ESLint messages into our result format
26
80
  return {
27
81
  file: filePath,
28
- errors: result.messages.map(msg => ({
82
+ errors: result.messages.map((msg: {
83
+ line: number;
84
+ column: number;
85
+ message: string;
86
+ ruleId?: string;
87
+ }): {
88
+ line: number;
89
+ column: number;
90
+ message: string;
91
+ ruleId: string;
92
+ } => ({
29
93
  line: msg.line,
30
94
  column: msg.column,
31
95
  message: msg.message,
@@ -34,8 +98,20 @@ async function validateNamingInFile(filePath: string): Promise<NamingValidationR
34
98
  };
35
99
  }
36
100
 
37
- async function main() {
38
- const files = await fg([ '**/*.{ts,tsx}' ], {
101
+ /**
102
+ * Main function that validates naming conventions across all TypeScript files
103
+ *
104
+ * Scans for all .ts and .tsx files in the project, validates naming conventions
105
+ * using the Dynamo naming-patterns rule, and provides detailed reporting on any
106
+ * violations found.
107
+ *
108
+ * @returns Promise that resolves when all files have been validated
109
+ *
110
+ * @throws {Error} When validation fails and process exits with code 1
111
+ */
112
+ async function main(): Promise<void> {
113
+ // Find all TypeScript files, excluding common directories and test files
114
+ const files: string[] = await fg([ '**/*.{ts,tsx}' ], {
39
115
  ignore: [ '**/node_modules/**', '**/build/**', '**/dist/**', '**/*.spec.ts', '**/*.test.ts' ],
40
116
  });
41
117
 
@@ -44,42 +120,57 @@ async function main() {
44
120
  const results: NamingValidationResult[] = [];
45
121
  let totalErrors = 0;
46
122
 
47
- for (const file of files) {
123
+ // Process each file individually
124
+ for (let i = 0; i < files.length; i++) {
125
+ const filePath: string = files[i];
126
+
48
127
  try {
49
- const result = await validateNamingInFile(file);
128
+ const result: NamingValidationResult = await validateNamingInFile(filePath);
50
129
 
51
130
  results.push(result);
52
131
  totalErrors += result.errors.length;
53
132
  } catch (error) {
54
- DyFM_Log.error(`Error processing ${file}:`, error);
133
+ DyFM_Log.error(`Error processing ${filePath}:`, error);
55
134
  }
56
135
  }
57
136
 
58
- // Report results
59
- const filesWithErrors = results.filter(r => r.errors.length > 0);
137
+ // Filter files that have naming violations
138
+ const filesWithErrors: NamingValidationResult[] = results.filter(
139
+ (r: NamingValidationResult): boolean => r.errors.length > 0
140
+ );
60
141
 
142
+ // Report success if no violations found
61
143
  if (filesWithErrors.length === 0) {
62
144
  DyFM_Log.log('✅ All naming validations passed!');
63
145
 
64
146
  return;
65
147
  }
66
148
 
67
- DyFM_Log.warn(`\n❌ Found ${totalErrors} naming validation errors in ${filesWithErrors.length} files:\n`);
149
+ // Report detailed error information
150
+ DyFM_Log.warn(
151
+ `\n❌ Found ${totalErrors} naming validation errors in ${filesWithErrors.length} files:\n`
152
+ );
68
153
 
69
- filesWithErrors.forEach(result => {
154
+ filesWithErrors.forEach((result: NamingValidationResult): void => {
70
155
  DyFM_Log.log(`📁 ${result.file}:`);
71
- result.errors.forEach(error => {
156
+ result.errors.forEach((error: {
157
+ line: number;
158
+ column: number;
159
+ message: string;
160
+ ruleId: string;
161
+ }): void => {
72
162
  DyFM_Log.log(` ${error.line}:${error.column} - ${error.message}`);
73
163
  });
74
164
  DyFM_Log.log('');
75
165
  });
76
166
 
167
+ // Exit with error code to indicate validation failure
77
168
  process.exit(1);
78
169
  }
79
170
 
80
- main().catch((err) => {
171
+ // Execute the main function and handle any errors
172
+ main().catch((err: Error): void => {
81
173
  DyFM_Log.error('Validation failed:', err);
82
174
  process.exit(1);
83
175
  });
84
176
 
85
-
Binary file