@futdevpro/dynamo-eslint 1.14.2 → 1.14.4
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.
- package/.eslintrc.json +4 -0
- package/.vscode/settings.json +13 -0
- package/README.md +279 -29
- package/build/configs/base.d.ts +6 -81
- package/build/configs/base.d.ts.map +1 -1
- package/build/configs/base.js +90 -54
- package/build/configs/base.js.map +1 -1
- package/build/configs/fsm.d.ts +1 -85
- package/build/configs/fsm.d.ts.map +1 -1
- package/build/configs/fsm.js +3 -6
- package/build/configs/fsm.js.map +1 -1
- package/build/configs/ngx-package.d.ts +1 -85
- package/build/configs/ngx-package.d.ts.map +1 -1
- package/build/configs/ngx-package.js +3 -6
- package/build/configs/ngx-package.js.map +1 -1
- package/build/configs/ngx.d.ts +4 -85
- package/build/configs/ngx.d.ts.map +1 -1
- package/build/configs/ngx.js +67 -11
- package/build/configs/ngx.js.map +1 -1
- package/build/configs/nts-package.d.ts +1 -87
- package/build/configs/nts-package.d.ts.map +1 -1
- package/build/configs/nts-package.js +12 -10
- package/build/configs/nts-package.js.map +1 -1
- package/build/configs/nts.d.ts +1 -86
- package/build/configs/nts.d.ts.map +1 -1
- package/build/configs/nts.js +26 -11
- package/build/configs/nts.js.map +1 -1
- package/build/plugin/index.d.ts +2 -0
- package/build/plugin/index.d.ts.map +1 -1
- package/build/plugin/index.js +3 -0
- package/build/plugin/index.js.map +1 -1
- package/build/plugin/rules/explicit-types.d.ts +4 -0
- package/build/plugin/rules/explicit-types.d.ts.map +1 -0
- package/build/plugin/rules/explicit-types.js +165 -0
- package/build/plugin/rules/explicit-types.js.map +1 -0
- package/build/plugin/rules/explicit-types.spec.d.ts +2 -0
- package/build/plugin/rules/explicit-types.spec.d.ts.map +1 -0
- package/build/plugin/rules/explicit-types.spec.js +162 -0
- package/build/plugin/rules/explicit-types.spec.js.map +1 -0
- package/build/plugin/rules/import/no-import-type.d.ts.map +1 -1
- package/build/plugin/rules/import/no-import-type.js +23 -12
- package/build/plugin/rules/import/no-import-type.js.map +1 -1
- package/build/plugin/rules/import/no-js-import.d.ts.map +1 -1
- package/build/plugin/rules/import/no-js-import.js +22 -11
- package/build/plugin/rules/import/no-js-import.js.map +1 -1
- package/build/plugin/rules/naming-patterns.d.ts.map +1 -1
- package/build/plugin/rules/naming-patterns.js +7 -2
- package/build/plugin/rules/naming-patterns.js.map +1 -1
- package/build/scripts/dynamo-fix.d.ts +24 -0
- package/build/scripts/dynamo-fix.d.ts.map +1 -1
- package/build/scripts/dynamo-fix.js +57 -2
- package/build/scripts/dynamo-fix.js.map +1 -1
- package/build/scripts/eslintrc-audit.d.ts +24 -0
- package/build/scripts/eslintrc-audit.d.ts.map +1 -1
- package/build/scripts/eslintrc-audit.js +65 -0
- package/build/scripts/eslintrc-audit.js.map +1 -1
- package/build/scripts/fix-return-types.d.ts +25 -0
- package/build/scripts/fix-return-types.d.ts.map +1 -1
- package/build/scripts/fix-return-types.js +80 -9
- package/build/scripts/fix-return-types.js.map +1 -1
- package/build/scripts/validate-imports.d.ts +24 -0
- package/build/scripts/validate-imports.d.ts.map +1 -1
- package/build/scripts/validate-imports.js +62 -1
- package/build/scripts/validate-imports.js.map +1 -1
- package/build/scripts/validate-naming.d.ts +24 -0
- package/build/scripts/validate-naming.d.ts.map +1 -1
- package/build/scripts/validate-naming.js +72 -9
- package/build/scripts/validate-naming.js.map +1 -1
- package/eslint.config.js +9 -49
- package/futdevpro-dynamo-eslint-01.14.4.tgz +0 -0
- package/package.json +1 -1
- package/samples/.vscode/settings.json +13 -0
- package/samples/base/eslint.config.js +3 -0
- package/samples/fsm/.eslintrc.json +4 -0
- package/samples/fsm/eslint.config.js +3 -0
- package/samples/ngx/eslint.config.js +3 -0
- package/samples/ngx-package/.eslintrc.json +4 -0
- package/samples/ngx-package/eslint.config.js +3 -0
- package/samples/nts/eslint.config.js +3 -0
- package/samples/nts-package/.eslintrc.json +4 -0
- package/samples/nts-package/eslint.config.js +3 -0
- package/samples/package.json.example +26 -0
- package/src/configs/base.ts +90 -54
- package/src/configs/fsm.ts +3 -6
- package/src/configs/ngx-package.ts +3 -6
- package/src/configs/ngx.ts +67 -11
- package/src/configs/nts-package.ts +12 -10
- package/src/configs/nts.ts +26 -11
- package/src/plugin/index.ts +3 -0
- package/src/plugin/rules/explicit-types.spec.ts +190 -0
- package/src/plugin/rules/explicit-types.ts +169 -0
- package/src/plugin/rules/import/no-import-type.ts +21 -12
- package/src/plugin/rules/import/no-js-import.ts +21 -13
- package/src/plugin/rules/naming-patterns.ts +6 -2
- package/src/scripts/dynamo-fix.ts +66 -2
- package/src/scripts/eslintrc-audit.ts +73 -2
- package/src/scripts/fix-return-types.ts +93 -9
- package/src/scripts/validate-imports.ts +71 -2
- package/src/scripts/validate-naming.ts +108 -17
- package/futdevpro-dynamo-eslint-01.14.2.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
|
-
|
|
71
|
+
// Use the main config object from flat config array
|
|
72
|
+
baseConfig: require('../eslint.config.js')[1],
|
|
21
73
|
});
|
|
22
74
|
|
|
23
|
-
|
|
24
|
-
const
|
|
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
|
-
|
|
38
|
-
|
|
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
|
-
|
|
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(
|
|
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 ${
|
|
133
|
+
DyFM_Log.error(`Error processing ${filePath}:`, error);
|
|
55
134
|
}
|
|
56
135
|
}
|
|
57
136
|
|
|
58
|
-
//
|
|
59
|
-
const filesWithErrors = results.filter(
|
|
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
|
-
|
|
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
|
|
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
|