@futdevpro/dynamo-eslint 1.14.3 → 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 +17 -2
- package/build/configs/base.js +2 -1
- package/build/configs/base.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/src/configs/base.ts +2 -1
- 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 +91 -9
- package/src/scripts/validate-imports.ts +71 -2
- package/src/scripts/validate-naming.ts +108 -17
- package/futdevpro-dynamo-eslint-01.14.3.tgz +0 -0
|
@@ -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
|
-
//
|
|
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":"
|
|
1
|
+
{"version":3,"file":"validate-imports.js","sourceRoot":"","sources":["../../src/scripts/validate-imports.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAkFH,sDAAiD;AACjD,kEAA2B;AAC3B,mCAAgC;AAqBhC;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,UAAU,qBAAqB,CAAC,QAAgB;IACnD,iDAAiD;IACjD,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;QACxB,UAAU,EAAE;YACV,MAAM,EAAE,2BAA2B;YACnC,aAAa,EAAE;gBACb,WAAW,EAAE,IAAI;gBACjB,UAAU,EAAE,QAAQ;aACrB;YACD,KAAK,EAAE;gBACL,gCAAgC,EAAE,OAAO;aAC1C;YACD,OAAO,EAAE;gBACP,mBAAmB,EAAE;oBACnB,KAAK,EAAE;wBACL,cAAc,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC,OAAO;qBAChE;iBACF;aACF;SACK;KACT,CAAC,CAAC;IAEH,yBAAyB;IACzB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAE,QAAQ,CAAE,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG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AAC,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEjE,wCAAwC;IACxC,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,qBAAQ,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QACjD,OAAO;IACT,CAAC;IAED,oCAAoC;IACpC,qBAAQ,CAAC,IAAI,CAAC,aAAa,WAAW,gCAAgC,eAAe,CAAC,MAAM,WAAW,CAAC,CAAC;IAEzG,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QAC/B,qBAAQ,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC;QACnC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC5B,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,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
|
-
|
|
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
|
-
|
|
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(
|
|
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 ${
|
|
97
|
+
fsm_dynamo_1.DyFM_Log.error(`Error processing ${filePath}:`, error);
|
|
39
98
|
}
|
|
40
99
|
}
|
|
41
|
-
//
|
|
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":"
|
|
1
|
+
{"version":3,"file":"validate-naming.js","sourceRoot":"","sources":["../../src/scripts/validate-naming.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,kEAA2B;AAC3B,mCAAgC;AAEhC,sDAAiD;AAqBjD;;;;;;;;;;;;;;;;GAgBG;AACH,KAAK,UAAU,oBAAoB,CAAC,QAAgB;IAClD,uDAAuD;IACvD,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;QACxB,oDAAoD;QACpD,UAAU,EAAE,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;KAC9C,CAAC,CAAC;IAEH,yBAAyB;IACzB,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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:
|
|
37
|
-
parserOptions: {
|
|
38
|
-
ecmaVersion: 'latest',
|
|
39
|
-
sourceType: 'module'
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
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
|
-
|
|
Binary file
|
package/package.json
CHANGED
package/src/configs/base.ts
CHANGED
|
@@ -51,7 +51,7 @@ module.exports = [
|
|
|
51
51
|
// ESLint recommended rules
|
|
52
52
|
'no-warning-comments': ['warn', { terms: ['todo', 'fixme', 'removable', '??'], location: 'anywhere' }],
|
|
53
53
|
'indent': ['warn', 2, { SwitchCase: 1 }],
|
|
54
|
-
'max-len': ['warn', { code:
|
|
54
|
+
'max-len': ['warn', { code: 120, comments: 120 }],
|
|
55
55
|
'max-lines': ['warn', 1000],
|
|
56
56
|
'linebreak-style': 'off',
|
|
57
57
|
'semi': ['warn', 'always'],
|
|
@@ -85,6 +85,7 @@ module.exports = [
|
|
|
85
85
|
'@typescript-eslint/typedef': 'warn',
|
|
86
86
|
|
|
87
87
|
// Dynamo custom rules
|
|
88
|
+
'@futdevpro/dynamo/explicit-types': 'warn',
|
|
88
89
|
'@futdevpro/dynamo/import-order': 'warn',
|
|
89
90
|
'@futdevpro/dynamo/naming-patterns': 'warn',
|
|
90
91
|
'@futdevpro/dynamo/no-import-type': 'warn',
|
package/src/plugin/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import explicitTypesRule from './rules/explicit-types';
|
|
1
2
|
import importOrderRule from './rules/import/import-order';
|
|
2
3
|
import namingPatternsRule from './rules/naming-patterns';
|
|
3
4
|
import noImportTypeRule from './rules/import/no-import-type';
|
|
@@ -5,6 +6,7 @@ import noJsExtensionRule from './rules/import/no-js-import';
|
|
|
5
6
|
|
|
6
7
|
export = {
|
|
7
8
|
rules: {
|
|
9
|
+
'explicit-types': explicitTypesRule,
|
|
8
10
|
'import-order': importOrderRule,
|
|
9
11
|
'no-import-type': noImportTypeRule,
|
|
10
12
|
'no-js-import': noJsExtensionRule,
|
|
@@ -14,6 +16,7 @@ export = {
|
|
|
14
16
|
configs: {
|
|
15
17
|
recommended: {
|
|
16
18
|
rules: {
|
|
19
|
+
'@futdevpro/dynamo/explicit-types': 'warn',
|
|
17
20
|
'@futdevpro/dynamo/import-order': 'warn',
|
|
18
21
|
'@futdevpro/dynamo/no-import-type': 'warn',
|
|
19
22
|
'@futdevpro/dynamo/no-js-import': 'warn',
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import explicitTypesRule from './explicit-types';
|
|
2
|
+
|
|
3
|
+
describe('| explicit-types', () => {
|
|
4
|
+
it('| should be a valid ESLint rule', () => {
|
|
5
|
+
expect(explicitTypesRule.meta?.type).toBe('suggestion');
|
|
6
|
+
expect(explicitTypesRule.meta?.docs?.description).toContain('explicit type annotations');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it('| should have create function that returns visitor object', () => {
|
|
10
|
+
const mockContext = {
|
|
11
|
+
report: () => {},
|
|
12
|
+
} as any;
|
|
13
|
+
|
|
14
|
+
const result = explicitTypesRule.create(mockContext);
|
|
15
|
+
|
|
16
|
+
expect(typeof result).toBe('object');
|
|
17
|
+
expect(typeof result.FunctionDeclaration).toBe('function');
|
|
18
|
+
expect(typeof result.ArrowFunctionExpression).toBe('function');
|
|
19
|
+
expect(typeof result.VariableDeclarator).toBe('function');
|
|
20
|
+
expect(typeof result.PropertyDefinition).toBe('function');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('| should report missing return types on function declarations', () => {
|
|
24
|
+
const mockContext = {
|
|
25
|
+
report: (options: any) => {
|
|
26
|
+
expect(options.messageId).toBe('missingReturnType');
|
|
27
|
+
expect(options.data.name).toBe('testFunction');
|
|
28
|
+
},
|
|
29
|
+
} as any;
|
|
30
|
+
|
|
31
|
+
const mockNode = {
|
|
32
|
+
type: 'FunctionDeclaration' as const,
|
|
33
|
+
id: { name: 'testFunction' },
|
|
34
|
+
returnType: null,
|
|
35
|
+
params: [],
|
|
36
|
+
} as any;
|
|
37
|
+
|
|
38
|
+
const rule = explicitTypesRule.create(mockContext);
|
|
39
|
+
rule.FunctionDeclaration(mockNode);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('| should not report when function has return type', () => {
|
|
43
|
+
const mockContext = {
|
|
44
|
+
report: (options: any) => {
|
|
45
|
+
fail('Should not report when function has return type');
|
|
46
|
+
},
|
|
47
|
+
} as any;
|
|
48
|
+
|
|
49
|
+
const mockNode = {
|
|
50
|
+
type: 'FunctionDeclaration' as const,
|
|
51
|
+
id: { name: 'testFunction' },
|
|
52
|
+
returnType: { type: 'TSTypeAnnotation' },
|
|
53
|
+
params: [],
|
|
54
|
+
} as any;
|
|
55
|
+
|
|
56
|
+
const rule = explicitTypesRule.create(mockContext);
|
|
57
|
+
rule.FunctionDeclaration(mockNode);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('| should report missing return types on arrow functions', () => {
|
|
61
|
+
const mockContext = {
|
|
62
|
+
report: (options: any) => {
|
|
63
|
+
expect(options.messageId).toBe('missingArrowReturnType');
|
|
64
|
+
},
|
|
65
|
+
} as any;
|
|
66
|
+
|
|
67
|
+
const mockNode = {
|
|
68
|
+
type: 'ArrowFunctionExpression' as const,
|
|
69
|
+
returnType: null,
|
|
70
|
+
params: [],
|
|
71
|
+
} as any;
|
|
72
|
+
|
|
73
|
+
const rule = explicitTypesRule.create(mockContext);
|
|
74
|
+
rule.ArrowFunctionExpression(mockNode);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('| should report missing types on variable declarations', () => {
|
|
78
|
+
const mockContext = {
|
|
79
|
+
report: (options: any) => {
|
|
80
|
+
expect(options.messageId).toBe('missingVariableType');
|
|
81
|
+
expect(options.data.name).toBe('testVar');
|
|
82
|
+
},
|
|
83
|
+
} as any;
|
|
84
|
+
|
|
85
|
+
const mockNode = {
|
|
86
|
+
type: 'VariableDeclarator' as const,
|
|
87
|
+
id: { name: 'testVar', typeAnnotation: null },
|
|
88
|
+
init: null,
|
|
89
|
+
} as any;
|
|
90
|
+
|
|
91
|
+
const rule = explicitTypesRule.create(mockContext);
|
|
92
|
+
rule.VariableDeclarator(mockNode);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('| should not report when variable has type annotation', () => {
|
|
96
|
+
const mockContext = {
|
|
97
|
+
report: (options: any) => {
|
|
98
|
+
fail('Should not report when variable has type annotation');
|
|
99
|
+
},
|
|
100
|
+
} as any;
|
|
101
|
+
|
|
102
|
+
const mockNode = {
|
|
103
|
+
type: 'VariableDeclarator' as const,
|
|
104
|
+
id: { name: 'testVar', typeAnnotation: { type: 'TSTypeAnnotation' } },
|
|
105
|
+
init: null,
|
|
106
|
+
} as any;
|
|
107
|
+
|
|
108
|
+
const rule = explicitTypesRule.create(mockContext);
|
|
109
|
+
rule.VariableDeclarator(mockNode);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('| should not report when variable has typed initializer', () => {
|
|
113
|
+
const mockContext = {
|
|
114
|
+
report: (options: any) => {
|
|
115
|
+
fail('Should not report when variable has typed initializer');
|
|
116
|
+
},
|
|
117
|
+
} as any;
|
|
118
|
+
|
|
119
|
+
const mockNode = {
|
|
120
|
+
type: 'VariableDeclarator' as const,
|
|
121
|
+
id: { name: 'testVar', typeAnnotation: null },
|
|
122
|
+
init: { type: 'CallExpression' },
|
|
123
|
+
} as any;
|
|
124
|
+
|
|
125
|
+
const rule = explicitTypesRule.create(mockContext);
|
|
126
|
+
rule.VariableDeclarator(mockNode);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('| should report missing parameter types', () => {
|
|
130
|
+
const mockContext = {
|
|
131
|
+
report: (options: any) => {
|
|
132
|
+
expect(options.messageId).toBe('missingParameterType');
|
|
133
|
+
expect(options.data.name).toBe('param');
|
|
134
|
+
},
|
|
135
|
+
} as any;
|
|
136
|
+
|
|
137
|
+
const mockNode = {
|
|
138
|
+
type: 'FunctionDeclaration' as const,
|
|
139
|
+
id: { name: 'testFunction' },
|
|
140
|
+
returnType: { type: 'TSTypeAnnotation' },
|
|
141
|
+
params: [
|
|
142
|
+
{ type: 'Identifier', name: 'param', typeAnnotation: null }
|
|
143
|
+
],
|
|
144
|
+
} as any;
|
|
145
|
+
|
|
146
|
+
const rule = explicitTypesRule.create(mockContext);
|
|
147
|
+
rule.FunctionDeclaration(mockNode);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('| should report missing class property types', () => {
|
|
151
|
+
const mockContext = {
|
|
152
|
+
report: (options: any) => {
|
|
153
|
+
expect(options.messageId).toBe('missingPropertyType');
|
|
154
|
+
expect(options.data.name).toBe('property');
|
|
155
|
+
},
|
|
156
|
+
} as any;
|
|
157
|
+
|
|
158
|
+
const mockNode = {
|
|
159
|
+
type: 'PropertyDefinition' as const,
|
|
160
|
+
key: { name: 'property' },
|
|
161
|
+
typeAnnotation: null,
|
|
162
|
+
value: null,
|
|
163
|
+
} as any;
|
|
164
|
+
|
|
165
|
+
const rule = explicitTypesRule.create(mockContext);
|
|
166
|
+
rule.PropertyDefinition(mockNode);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('| should report missing destructuring types', () => {
|
|
170
|
+
const mockContext = {
|
|
171
|
+
report: (options: any) => {
|
|
172
|
+
expect(options.messageId).toBe('missingDestructuringType');
|
|
173
|
+
},
|
|
174
|
+
} as any;
|
|
175
|
+
|
|
176
|
+
const objectPatternNode = {
|
|
177
|
+
type: 'ObjectPattern' as const,
|
|
178
|
+
typeAnnotation: null,
|
|
179
|
+
} as any;
|
|
180
|
+
|
|
181
|
+
const arrayPatternNode = {
|
|
182
|
+
type: 'ArrayPattern' as const,
|
|
183
|
+
typeAnnotation: null,
|
|
184
|
+
} as any;
|
|
185
|
+
|
|
186
|
+
const rule = explicitTypesRule.create(mockContext);
|
|
187
|
+
rule.ObjectPattern(objectPatternNode);
|
|
188
|
+
rule.ArrayPattern(arrayPatternNode);
|
|
189
|
+
});
|
|
190
|
+
});
|