@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.
- package/.eslintrc.json +4 -0
- package/.vscode/settings.json +11 -0
- package/README.md +17 -2
- package/build/configs/base.js +19 -7
- 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 +179 -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/import-order.d.ts.map +1 -1
- package/build/plugin/rules/import/import-order.js +0 -9
- package/build/plugin/rules/import/import-order.js.map +1 -1
- 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 +19 -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-1.14.6.tgz +0 -0
- package/package.json +1 -1
- package/samples/package.json.example +1 -1
- package/src/configs/base.ts +34 -22
- package/src/plugin/index.ts +3 -0
- package/src/plugin/rules/explicit-types.spec.ts +190 -0
- package/src/plugin/rules/explicit-types.ts +186 -0
- package/src/plugin/rules/import/import-order.ts +0 -9
- package/src/plugin/rules/import/no-import-type.ts +21 -12
- package/src/plugin/rules/import/no-js-import.ts +25 -15
- package/src/plugin/rules/naming-patterns.ts +6 -2
- package/src/scripts/dynamo-fix.ts +66 -2
- package/src/scripts/eslintrc-audit.ts +79 -6
- 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
|
@@ -14,18 +14,29 @@ const rule = {
|
|
|
14
14
|
const sourceCode = context.sourceCode;
|
|
15
15
|
return {
|
|
16
16
|
ImportDeclaration(node) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
try {
|
|
18
|
+
// Check for import type usage
|
|
19
|
+
if (node.importKind === 'type') {
|
|
20
|
+
context.report({
|
|
21
|
+
node,
|
|
22
|
+
messageId: 'forbiddenImportType',
|
|
23
|
+
fix(fixer) {
|
|
24
|
+
try {
|
|
25
|
+
// Remove 'type' keyword
|
|
26
|
+
const importText = sourceCode.getText(node);
|
|
27
|
+
const newImportText = importText.replace(/import\s+type\s+/, 'import ');
|
|
28
|
+
return fixer.replaceText(node, newImportText);
|
|
29
|
+
}
|
|
30
|
+
catch (fixError) {
|
|
31
|
+
console.error('[no-import-type] Error in fix function:', fixError);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
console.error('[no-import-type] Error in ImportDeclaration visitor:', error);
|
|
29
40
|
}
|
|
30
41
|
},
|
|
31
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-import-type.js","sourceRoot":"","sources":["../../../../src/plugin/rules/import/no-import-type.ts"],"names":[],"mappings":";;AAEA,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE;QAC3D,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,mBAAmB,EAAE,oCAAoC;SAC1D;QACD,OAAO,EAAE,MAAM;KAChB;IACD,MAAM,CAAC,OAAO;QACZ,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QAEtC,OAAO;YACL,iBAAiB,CAAC,IAAS;gBACzB,8BAA8B;
|
|
1
|
+
{"version":3,"file":"no-import-type.js","sourceRoot":"","sources":["../../../../src/plugin/rules/import/no-import-type.ts"],"names":[],"mappings":";;AAEA,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE;QAC3D,MAAM,EAAE,EAAE;QAC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
{"version":3,"file":"no-js-import.d.ts","sourceRoot":"","sources":["../../../../src/plugin/rules/import/no-js-import.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAwChB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -11,19 +11,27 @@ const rule = {
|
|
|
11
11
|
fixable: 'code',
|
|
12
12
|
},
|
|
13
13
|
create(context) {
|
|
14
|
+
// List of allowed packages that can use .js extension
|
|
15
|
+
const allowedJsPackages = [
|
|
16
|
+
'discord.js',
|
|
17
|
+
];
|
|
14
18
|
return {
|
|
15
19
|
ImportDeclaration(node) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
try {
|
|
21
|
+
const source = node.source?.value;
|
|
22
|
+
if (source && source.endsWith('.js')) {
|
|
23
|
+
// Check if the import is from an allowed package
|
|
24
|
+
const isAllowedPackage = allowedJsPackages.some((pkg) => source.includes(pkg) || source.startsWith(pkg));
|
|
25
|
+
if (!isAllowedPackage) {
|
|
26
|
+
context.report({
|
|
27
|
+
node: node.source,
|
|
28
|
+
messageId: 'forbiddenJsExtension',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.error('[no-js-import] Error in ImportDeclaration visitor:', error);
|
|
27
35
|
}
|
|
28
36
|
},
|
|
29
37
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-js-import.js","sourceRoot":"","sources":["../../../../src/plugin/rules/import/no-js-import.ts"],"names":[],"mappings":";;AAEA,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,EAAE,WAAW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,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming-patterns.d.ts","sourceRoot":"","sources":["../../../src/plugin/rules/naming-patterns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"naming-patterns.d.ts","sourceRoot":"","sources":["../../../src/plugin/rules/naming-patterns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAqBhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -13,8 +13,13 @@ const rule = {
|
|
|
13
13
|
create(context) {
|
|
14
14
|
return {
|
|
15
15
|
Identifier(node) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
try {
|
|
17
|
+
// Future: use dyfmUtils naming patterns to validate identifiers
|
|
18
|
+
void node;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
console.error('[naming-patterns] Error in Identifier visitor:', error);
|
|
22
|
+
}
|
|
18
23
|
},
|
|
19
24
|
};
|
|
20
25
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"naming-patterns.js","sourceRoot":"","sources":["../../../src/plugin/rules/naming-patterns.ts"],"names":[],"mappings":";;AACA,sDAAsD;AAEtD,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE;QACvE,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,WAAW,EAAE,+DAA+D;SAC7E;KACF;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,UAAU,CAAC,IAAI;gBACb,gEAAgE;
|
|
1
|
+
{"version":3,"file":"naming-patterns.js","sourceRoot":"","sources":["../../../src/plugin/rules/naming-patterns.ts"],"names":[],"mappings":";;AACA,sDAAsD;AAEtD,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,EAAE,WAAW,EAAE,gDAAgD,EAAE;QACvE,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,WAAW,EAAE,+DAA+D;SAC7E;KACF;IACD,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,UAAU,CAAC,IAAI;gBACb,IAAI,CAAC;oBACH,gEAAgE;oBAChE,KAAK,IAAI,CAAC;gBACZ,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,OAAO,CAAC,KAAK,CAAC,gDAAgD,EAAE,KAAK,CAAC,CAAC;gBACzE,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
|
@@ -1,3 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Dynamo ESLint Auto-Fix Script
|
|
4
|
+
*
|
|
5
|
+
* This script runs ESLint with auto-fix capabilities on TypeScript files across the project.
|
|
6
|
+
* It processes all .ts and .tsx files, applies Dynamo-specific rules, and automatically
|
|
7
|
+
* fixes issues where possible.
|
|
8
|
+
*
|
|
9
|
+
* @usage
|
|
10
|
+
* ```bash
|
|
11
|
+
* dynamo-fix
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```bash
|
|
16
|
+
* # Fix all TypeScript files in the project
|
|
17
|
+
* npx dynamo-fix
|
|
18
|
+
*
|
|
19
|
+
* # Or run via npm script
|
|
20
|
+
* npm run fix
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @author Future Development Program Ltd.
|
|
24
|
+
* @version 1.14.3
|
|
25
|
+
*/
|
|
2
26
|
export {};
|
|
3
27
|
//# sourceMappingURL=dynamo-fix.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamo-fix.d.ts","sourceRoot":"","sources":["../../src/scripts/dynamo-fix.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"dynamo-fix.d.ts","sourceRoot":"","sources":["../../src/scripts/dynamo-fix.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
|
|
@@ -1,11 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview Dynamo ESLint Auto-Fix Script
|
|
5
|
+
*
|
|
6
|
+
* This script runs ESLint with auto-fix capabilities on TypeScript files across the project.
|
|
7
|
+
* It processes all .ts and .tsx files, applies Dynamo-specific rules, and automatically
|
|
8
|
+
* fixes issues where possible.
|
|
9
|
+
*
|
|
10
|
+
* @usage
|
|
11
|
+
* ```bash
|
|
12
|
+
* dynamo-fix
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```bash
|
|
17
|
+
* # Fix all TypeScript files in the project
|
|
18
|
+
* npx dynamo-fix
|
|
19
|
+
*
|
|
20
|
+
* # Or run via npm script
|
|
21
|
+
* npm run fix
|
|
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 fs_1 = require("fs");
|
|
32
|
+
/**
|
|
33
|
+
* Fixes a single TypeScript file using ESLint with auto-fix capabilities
|
|
34
|
+
*
|
|
35
|
+
* @param filePath - Path to the TypeScript file to fix
|
|
36
|
+
* @returns Promise that resolves to a FixResult object containing fix statistics
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const result = await fixFile('./src/components/Button.tsx');
|
|
41
|
+
* console.log(`Fixed ${result.fixes} issues in ${result.file}`);
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
8
44
|
async function fixFile(filePath) {
|
|
45
|
+
// Configure ESLint with Dynamo-specific rules and auto-fix enabled
|
|
9
46
|
const eslint = new eslint_1.ESLint({
|
|
10
47
|
baseConfig: [
|
|
11
48
|
{ ignores: ['build/**', 'dist/**', 'node_modules/**'] },
|
|
@@ -31,12 +68,14 @@ async function fixFile(filePath) {
|
|
|
31
68
|
],
|
|
32
69
|
fix: true, // Enable auto-fixing
|
|
33
70
|
});
|
|
71
|
+
// Run ESLint on the file
|
|
34
72
|
const results = await eslint.lintFiles([filePath]);
|
|
35
73
|
const result = results[0];
|
|
74
|
+
// Write the fixed content back to the file if changes were made
|
|
36
75
|
if (result && result.output) {
|
|
37
|
-
// Write the fixed content back to the file
|
|
38
76
|
(0, fs_1.writeFileSync)(filePath, result.output);
|
|
39
77
|
}
|
|
78
|
+
// Return comprehensive fix statistics
|
|
40
79
|
return {
|
|
41
80
|
file: filePath,
|
|
42
81
|
fixed: result && result.output !== undefined,
|
|
@@ -45,7 +84,18 @@ async function fixFile(filePath) {
|
|
|
45
84
|
fixes: result.fixableErrorCount + result.fixableWarningCount,
|
|
46
85
|
};
|
|
47
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Main function that processes all TypeScript files in the project
|
|
89
|
+
*
|
|
90
|
+
* Scans for all .ts and .tsx files, applies ESLint fixes, and provides
|
|
91
|
+
* comprehensive reporting on the results.
|
|
92
|
+
*
|
|
93
|
+
* @returns Promise that resolves when all files have been processed
|
|
94
|
+
*
|
|
95
|
+
* @throws {Error} When file processing fails
|
|
96
|
+
*/
|
|
48
97
|
async function main() {
|
|
98
|
+
// Find all TypeScript files, excluding common directories and test files
|
|
49
99
|
const files = await (0, fast_glob_1.default)(['**/*.{ts,tsx}'], {
|
|
50
100
|
ignore: ['**/node_modules/**', '**/build/**', '**/dist/**', '**/*.spec.ts', '**/*.test.ts'],
|
|
51
101
|
});
|
|
@@ -55,14 +105,17 @@ async function main() {
|
|
|
55
105
|
let totalErrors = 0;
|
|
56
106
|
let totalWarnings = 0;
|
|
57
107
|
let totalFixes = 0;
|
|
108
|
+
// Process each file individually
|
|
58
109
|
for (const file of files) {
|
|
59
110
|
try {
|
|
60
111
|
const result = await fixFile(file);
|
|
61
112
|
results.push(result);
|
|
113
|
+
// Track successful fixes
|
|
62
114
|
if (result.fixed) {
|
|
63
115
|
totalFixed++;
|
|
64
116
|
console.log(`✅ Fixed: ${result.file}`);
|
|
65
117
|
}
|
|
118
|
+
// Accumulate statistics
|
|
66
119
|
totalErrors += result.errors;
|
|
67
120
|
totalWarnings += result.warnings;
|
|
68
121
|
totalFixes += result.fixes;
|
|
@@ -71,13 +124,14 @@ async function main() {
|
|
|
71
124
|
console.error(`❌ Error processing ${file}:`, error);
|
|
72
125
|
}
|
|
73
126
|
}
|
|
74
|
-
//
|
|
127
|
+
// Generate comprehensive summary report
|
|
75
128
|
console.log(`\n📊 Fix Summary:`);
|
|
76
129
|
console.log(` Files processed: ${files.length}`);
|
|
77
130
|
console.log(` Files fixed: ${totalFixed}`);
|
|
78
131
|
console.log(` Total errors: ${totalErrors}`);
|
|
79
132
|
console.log(` Total warnings: ${totalWarnings}`);
|
|
80
133
|
console.log(` Total fixes applied: ${totalFixes}`);
|
|
134
|
+
// Provide appropriate success/failure message
|
|
81
135
|
if (totalFixed === 0) {
|
|
82
136
|
console.log('✅ No files needed fixing!');
|
|
83
137
|
}
|
|
@@ -85,6 +139,7 @@ async function main() {
|
|
|
85
139
|
console.log(`\n🎉 Successfully fixed ${totalFixed} files!`);
|
|
86
140
|
}
|
|
87
141
|
}
|
|
142
|
+
// Execute the main function and handle any errors
|
|
88
143
|
main().catch((err) => {
|
|
89
144
|
console.error('Fix failed:', err);
|
|
90
145
|
process.exit(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamo-fix.js","sourceRoot":"","sources":["../../src/scripts/dynamo-fix.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamo-fix.js","sourceRoot":"","sources":["../../src/scripts/dynamo-fix.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,kEAA2B;AAC3B,mCAAgC;AAChC,2BAAmC;AAkBnC;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,OAAO,CAAC,QAAgB;IACrC,mEAAmE;IACnE,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC;QACxB,UAAU,EAAE;YACV,EAAE,OAAO,EAAE,CAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,CAAE,EAAE;YACzD;gBACE,KAAK,EAAE,CAAE,eAAe,CAAE;gBAC1B,eAAe,EAAE;oBACf,MAAM,EAAE,OAAO,CAAC,2BAA2B,CAAC;oBAC5C,aAAa,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE;iBAC3D;gBACD,OAAO,EAAE;oBACP,mBAAmB,EAAE;wBACnB,KAAK,EAAE;4BACL,cAAc,EAAE,OAAO,CAAC,8BAA8B,CAAC,CAAC,OAAO;4BAC/D,iBAAiB,EAAE,OAAO,CAAC,iCAAiC,CAAC,CAAC,OAAO;yBACtE;qBACF;iBACF;gBACD,KAAK,EAAE;oBACL,gCAAgC,EAAE,OAAO;oBACzC,mCAAmC,EAAE,MAAM;iBAC5C;aACF;SACF;QACD,GAAG,EAAE,IAAI,EAAE,qBAAqB;KACjC,CAAC,CAAC;IAEH,yBAAyB;IACzB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAE,QAAQ,CAAE,CAAC,CAAC;IACrD,MAAM,MAAM,GAAG,OAAO,CAAC,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AK,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview ESLint Configuration Audit Script
|
|
4
|
+
*
|
|
5
|
+
* This script analyzes ESLint configuration files (.eslintrc.json) across the project
|
|
6
|
+
* to provide statistics on rule usage. It helps identify commonly used rules and
|
|
7
|
+
* potential configuration inconsistencies.
|
|
8
|
+
*
|
|
9
|
+
* @usage
|
|
10
|
+
* ```bash
|
|
11
|
+
* dynamo-eslintrc-audit
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```bash
|
|
16
|
+
* # Audit all ESLint configurations in the project
|
|
17
|
+
* npx dynamo-eslintrc-audit
|
|
18
|
+
*
|
|
19
|
+
* # Or run via npm script
|
|
20
|
+
* npm run audit:eslintrc
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @author Future Development Program Ltd.
|
|
24
|
+
* @version 1.14.3
|
|
25
|
+
*/
|
|
2
26
|
export {};
|
|
3
27
|
//# sourceMappingURL=eslintrc-audit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslintrc-audit.d.ts","sourceRoot":"","sources":["../../src/scripts/eslintrc-audit.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"eslintrc-audit.d.ts","sourceRoot":"","sources":["../../src/scripts/eslintrc-audit.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
|
|
@@ -1,34 +1,99 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview ESLint Configuration Audit Script
|
|
5
|
+
*
|
|
6
|
+
* This script analyzes ESLint configuration files (.eslintrc.json) across the project
|
|
7
|
+
* to provide statistics on rule usage. It helps identify commonly used rules and
|
|
8
|
+
* potential configuration inconsistencies.
|
|
9
|
+
*
|
|
10
|
+
* @usage
|
|
11
|
+
* ```bash
|
|
12
|
+
* dynamo-eslintrc-audit
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```bash
|
|
17
|
+
* # Audit all ESLint configurations in the project
|
|
18
|
+
* npx dynamo-eslintrc-audit
|
|
19
|
+
*
|
|
20
|
+
* # Or run via npm script
|
|
21
|
+
* npm run audit:eslintrc
|
|
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 fs_1 = require("fs");
|
|
31
|
+
/**
|
|
32
|
+
* Safely parses a JSON file and returns the parsed object or null if parsing fails
|
|
33
|
+
*
|
|
34
|
+
* @param jsonPath - Path to the JSON file to parse
|
|
35
|
+
* @returns Parsed JSON object or null if parsing fails
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const config = safeParse('./.eslintrc.json');
|
|
40
|
+
* if (config) {
|
|
41
|
+
* console.log('Rules:', Object.keys(config.rules || {}));
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
7
45
|
function safeParse(jsonPath) {
|
|
8
46
|
try {
|
|
9
47
|
const content = (0, fs_1.readFileSync)(jsonPath, 'utf8');
|
|
10
48
|
return JSON.parse(content);
|
|
11
49
|
}
|
|
12
50
|
catch {
|
|
51
|
+
// Return null for any parsing errors (malformed JSON, file not found, etc.)
|
|
13
52
|
return null;
|
|
14
53
|
}
|
|
15
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Main function that analyzes ESLint configuration files and generates rule usage statistics
|
|
57
|
+
*
|
|
58
|
+
* Scans for all .eslintrc.json files in the project, extracts rule configurations,
|
|
59
|
+
* and provides a sorted table of the most commonly used rules.
|
|
60
|
+
*
|
|
61
|
+
* @returns Promise that resolves when analysis is complete
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* // The function will output a table like:
|
|
66
|
+
* // ┌─────────┬─────────────────────────┬───────┐
|
|
67
|
+
* // │ (index) │ rule │ count │
|
|
68
|
+
* // ├─────────┼─────────────────────────┼───────┤
|
|
69
|
+
* // │ 0 │ 'no-unused-vars' │ 5 │
|
|
70
|
+
* // │ 1 │ 'semi' │ 4 │
|
|
71
|
+
* // └─────────┴─────────────────────────┴───────┘
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
16
74
|
async function main() {
|
|
75
|
+
// Find all ESLint configuration files, excluding node_modules
|
|
17
76
|
const files = await (0, fast_glob_1.default)(['**/.eslintrc.json'], { ignore: ['**/node_modules/**'] });
|
|
18
77
|
const ruleCounts = {};
|
|
19
78
|
const total = files.length;
|
|
79
|
+
// Process each configuration file
|
|
20
80
|
for (const p of files) {
|
|
21
81
|
const cfg = safeParse(p);
|
|
82
|
+
// Skip files without rules configuration
|
|
22
83
|
if (!cfg?.rules)
|
|
23
84
|
continue;
|
|
85
|
+
// Count each rule occurrence
|
|
24
86
|
for (const key of Object.keys(cfg.rules)) {
|
|
25
87
|
ruleCounts[key] = (ruleCounts[key] ?? 0) + 1;
|
|
26
88
|
}
|
|
27
89
|
}
|
|
90
|
+
// Sort rules by usage count (most used first)
|
|
28
91
|
const entries = Object.entries(ruleCounts).sort((a, b) => b[1] - a[1]);
|
|
92
|
+
// Display results
|
|
29
93
|
console.log(`[dynamo-eslintrc-audit] analyzed ${total} files`);
|
|
30
94
|
console.table(entries.slice(0, 50).map(([rule, count]) => ({ rule, count })));
|
|
31
95
|
}
|
|
96
|
+
// Execute the main function and handle any errors
|
|
32
97
|
main().catch((err) => {
|
|
33
98
|
console.error(err);
|
|
34
99
|
process.exit(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eslintrc-audit.js","sourceRoot":"","sources":["../../src/scripts/eslintrc-audit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eslintrc-audit.js","sourceRoot":"","sources":["../../src/scripts/eslintrc-audit.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;;AAEH,kEAA2B;AAC3B,2BAAkC;AAIlC;;;;;;;;;;;;;GAaG;AACH,SAAS,SAAS,CAAC,QAAgB;IACjC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,iBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE/C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,4EAA4E;QAC5E,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,KAAK,UAAU,IAAI;IACjB,8DAA8D;IAC9D,MAAM,KAAK,GAAa,MAAM,IAAA,mBAAE,EAAC,CAAE,mBAAmB,CAAE,EAAE,EAAE,MAAM,EAAE,CAAE,oBAAoB,CAAE,EAAE,CAAC,CAAC;IAChG,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAW,KAAK,CAAC,MAAM,CAAC;IAEnC,kCAAkC;IAClC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QAEzB,yCAAyC;QACzC,IAAI,CAAC,GAAG,EAAE,KAAK;YAAE,SAAS;QAE1B,6BAA6B;QAC7B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACzC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,CAC7C,CAAC,CAAqB,EAAE,CAAqB,EAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACtE,CAAC;IAEF,kBAAkB;IAClB,OAAO,CAAC,GAAG,CAAC,oCAAoC,KAAK,QAAQ,CAAC,CAAC;IAC/D,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAE,IAAI,EAAE,KAAK,CAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,kDAAkD;AAClD,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAU,EAAQ,EAAE;IAChC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,28 @@
|
|
|
1
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
|
+
*/
|
|
2
27
|
export {};
|
|
3
28
|
//# sourceMappingURL=fix-return-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fix-return-types.d.ts","sourceRoot":"","sources":["../../src/scripts/fix-return-types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"fix-return-types.d.ts","sourceRoot":"","sources":["../../src/scripts/fix-return-types.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG"}
|