@futdevpro/dynamo-eslint 1.12.1
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 +16 -0
- package/.github/workflows/main.yml +393 -0
- package/INTEGRATION.md +74 -0
- package/POC-README.md +147 -0
- package/README.md +36 -0
- package/build/configs/base.d.ts +81 -0
- package/build/configs/base.d.ts.map +1 -0
- package/build/configs/base.js +51 -0
- package/build/configs/base.js.map +1 -0
- package/build/configs/fsm.d.ts +82 -0
- package/build/configs/fsm.d.ts.map +1 -0
- package/build/configs/fsm.js +7 -0
- package/build/configs/fsm.js.map +1 -0
- package/build/configs/ngx-package.d.ts +81 -0
- package/build/configs/ngx-package.d.ts.map +1 -0
- package/build/configs/ngx-package.js +7 -0
- package/build/configs/ngx-package.js.map +1 -0
- package/build/configs/ngx.d.ts +81 -0
- package/build/configs/ngx.d.ts.map +1 -0
- package/build/configs/ngx.js +12 -0
- package/build/configs/ngx.js.map +1 -0
- package/build/configs/nts-package.d.ts +83 -0
- package/build/configs/nts-package.d.ts.map +1 -0
- package/build/configs/nts-package.js +12 -0
- package/build/configs/nts-package.js.map +1 -0
- package/build/configs/nts.d.ts +82 -0
- package/build/configs/nts.d.ts.map +1 -0
- package/build/configs/nts.js +13 -0
- package/build/configs/nts.js.map +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3 -0
- package/build/index.js.map +1 -0
- package/build/plugin/index.d.ts +16 -0
- package/build/plugin/index.d.ts.map +1 -0
- package/build/plugin/index.js +19 -0
- package/build/plugin/index.js.map +1 -0
- package/build/plugin/rules/import-order.d.ts +4 -0
- package/build/plugin/rules/import-order.d.ts.map +1 -0
- package/build/plugin/rules/import-order.js +134 -0
- package/build/plugin/rules/import-order.js.map +1 -0
- package/build/plugin/rules/import-order.spec.d.ts +2 -0
- package/build/plugin/rules/import-order.spec.d.ts.map +1 -0
- package/build/plugin/rules/import-order.spec.js +181 -0
- package/build/plugin/rules/import-order.spec.js.map +1 -0
- package/build/plugin/rules/naming-patterns.d.ts +4 -0
- package/build/plugin/rules/naming-patterns.d.ts.map +1 -0
- package/build/plugin/rules/naming-patterns.js +23 -0
- package/build/plugin/rules/naming-patterns.js.map +1 -0
- package/build/plugin/rules/naming-patterns.spec.d.ts +2 -0
- package/build/plugin/rules/naming-patterns.spec.d.ts.map +1 -0
- package/build/plugin/rules/naming-patterns.spec.js +36 -0
- package/build/plugin/rules/naming-patterns.spec.js.map +1 -0
- package/build/scripts/eslintrc-audit.d.ts +3 -0
- package/build/scripts/eslintrc-audit.d.ts.map +1 -0
- package/build/scripts/eslintrc-audit.js +36 -0
- package/build/scripts/eslintrc-audit.js.map +1 -0
- package/build/scripts/validate-imports.d.ts +3 -0
- package/build/scripts/validate-imports.d.ts.map +1 -0
- package/build/scripts/validate-imports.js +76 -0
- package/build/scripts/validate-imports.js.map +1 -0
- package/build/scripts/validate-naming.d.ts +3 -0
- package/build/scripts/validate-naming.d.ts.map +1 -0
- package/build/scripts/validate-naming.js +76 -0
- package/build/scripts/validate-naming.js.map +1 -0
- package/build-test/plugin/rules/import-order.d.ts +3 -0
- package/build-test/plugin/rules/import-order.js +23 -0
- package/build-test/plugin/rules/import-order.spec.d.ts +1 -0
- package/build-test/plugin/rules/import-order.spec.js +44 -0
- package/build-test/plugin/rules/naming-patterns.d.ts +3 -0
- package/build-test/plugin/rules/naming-patterns.js +22 -0
- package/build-test/plugin/rules/naming-patterns.spec.d.ts +1 -0
- package/build-test/plugin/rules/naming-patterns.spec.js +41 -0
- package/futdevpro-dynamo-eslint-01.12.01.tgz +0 -0
- package/package.json +95 -0
- package/samples/base/.eslintrc.json +6 -0
- package/samples/ngx/.eslintrc.json +6 -0
- package/samples/nts/.eslintrc.json +6 -0
- package/samples/poc-sample.ts +38 -0
- package/samples/poc-violations.ts +25 -0
- package/spec/support/jasmine.json +24 -0
- package/src/configs/base.ts +51 -0
- package/src/configs/fsm.ts +9 -0
- package/src/configs/ngx-package.ts +9 -0
- package/src/configs/ngx.ts +14 -0
- package/src/configs/nts-package.ts +14 -0
- package/src/configs/nts.ts +15 -0
- package/src/index.ts +4 -0
- package/src/plugin/index.ts +19 -0
- package/src/plugin/rules/import-order.spec.ts +197 -0
- package/src/plugin/rules/import-order.ts +167 -0
- package/src/plugin/rules/naming-patterns.spec.ts +39 -0
- package/src/plugin/rules/naming-patterns.ts +25 -0
- package/src/scripts/eslintrc-audit.ts +39 -0
- package/src/scripts/validate-imports.ts +98 -0
- package/src/scripts/validate-naming.ts +97 -0
- package/tsconfig.json +32 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
rules: {
|
|
3
|
+
'import-order': import("eslint").Rule.RuleModule;
|
|
4
|
+
'naming-patterns': import("eslint").Rule.RuleModule;
|
|
5
|
+
};
|
|
6
|
+
configs: {
|
|
7
|
+
recommended: {
|
|
8
|
+
rules: {
|
|
9
|
+
'@futdevpro/dynamo/import-order': string;
|
|
10
|
+
'@futdevpro/dynamo/naming-patterns': string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export = _default;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAGA,kBAaE"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const tslib_1 = require("tslib");
|
|
3
|
+
const import_order_1 = tslib_1.__importDefault(require("./rules/import-order"));
|
|
4
|
+
const naming_patterns_1 = tslib_1.__importDefault(require("./rules/naming-patterns"));
|
|
5
|
+
module.exports = {
|
|
6
|
+
rules: {
|
|
7
|
+
'import-order': import_order_1.default,
|
|
8
|
+
'naming-patterns': naming_patterns_1.default,
|
|
9
|
+
},
|
|
10
|
+
configs: {
|
|
11
|
+
recommended: {
|
|
12
|
+
rules: {
|
|
13
|
+
'@futdevpro/dynamo/import-order': 'warn',
|
|
14
|
+
'@futdevpro/dynamo/naming-patterns': 'warn',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":";;AAAA,gFAAmD;AACnD,sFAAyD;AAEzD,iBAAS;IACP,KAAK,EAAE;QACL,cAAc,EAAE,sBAAe;QAC/B,iBAAiB,EAAE,yBAAkB;KACtC;IACD,OAAO,EAAE;QACP,WAAW,EAAE;YACX,KAAK,EAAE;gBACL,gCAAgC,EAAE,MAAM;gBACxC,mCAAmC,EAAE,MAAM;aAC5C;SACF;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-order.d.ts","sourceRoot":"","sources":["../../../src/plugin/rules/import-order.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAOnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UA2JhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const rule = {
|
|
4
|
+
meta: {
|
|
5
|
+
type: 'suggestion',
|
|
6
|
+
docs: { description: 'Validate import ordering based on Dynamo conventions' },
|
|
7
|
+
schema: [],
|
|
8
|
+
messages: {
|
|
9
|
+
misordered: 'Import statements should be grouped and ordered by convention.',
|
|
10
|
+
forbiddenNpmPackages: 'Import from "*/../NPM-packages/*" is forbidden. Use "@futdevpro/*" instead.',
|
|
11
|
+
forbiddenJsExtension: 'Import with ".js" extension is forbidden. Use ".ts" or no extension.',
|
|
12
|
+
forbiddenImportType: 'Use of "import type" is forbidden.',
|
|
13
|
+
missingEmptyLine: 'Missing empty line between import groups.',
|
|
14
|
+
extraEmptyLine: 'Extra empty line detected.',
|
|
15
|
+
},
|
|
16
|
+
fixable: 'code',
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
const sourceCode = context.getSourceCode();
|
|
20
|
+
const filename = context.getFilename();
|
|
21
|
+
function getImportGroup(importNode) {
|
|
22
|
+
const source = importNode.source.value;
|
|
23
|
+
// Check for forbidden patterns first
|
|
24
|
+
if (source.includes('/NPM-packages/')) {
|
|
25
|
+
return 'non-futdevpro'; // Will be flagged as error
|
|
26
|
+
}
|
|
27
|
+
if (source.endsWith('.js')) {
|
|
28
|
+
return 'non-futdevpro'; // Will be flagged as error
|
|
29
|
+
}
|
|
30
|
+
// FutDevPro packages
|
|
31
|
+
if (source.startsWith('@futdevpro/')) {
|
|
32
|
+
return 'futdevpro';
|
|
33
|
+
}
|
|
34
|
+
// Same module (relative imports with specific patterns)
|
|
35
|
+
if (source.startsWith('./') || source.startsWith('../')) {
|
|
36
|
+
const pathParts = source.split('/');
|
|
37
|
+
const upLevels = pathParts.filter(part => part === '..').length;
|
|
38
|
+
// Same module: up to 3 ".." and starts with "_", or less than 2 ".."
|
|
39
|
+
if (upLevels <= 2 || (upLevels <= 3 && pathParts.some(part => part.startsWith('_')))) {
|
|
40
|
+
return 'same-module';
|
|
41
|
+
}
|
|
42
|
+
// Other modules
|
|
43
|
+
return 'other-modules';
|
|
44
|
+
}
|
|
45
|
+
// Non-FutDevPro packages
|
|
46
|
+
return 'non-futdevpro';
|
|
47
|
+
}
|
|
48
|
+
function validateImportDeclaration(importNode) {
|
|
49
|
+
const source = importNode.source.value;
|
|
50
|
+
// Check for forbidden patterns
|
|
51
|
+
if (source.includes('/NPM-packages/')) {
|
|
52
|
+
context.report({
|
|
53
|
+
node: importNode.source,
|
|
54
|
+
messageId: 'forbiddenNpmPackages',
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (source.endsWith('.js')) {
|
|
58
|
+
context.report({
|
|
59
|
+
node: importNode.source,
|
|
60
|
+
messageId: 'forbiddenJsExtension',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// Check for import type usage
|
|
64
|
+
if (importNode.importKind === 'type') {
|
|
65
|
+
context.report({
|
|
66
|
+
node: importNode,
|
|
67
|
+
messageId: 'forbiddenImportType',
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function validateImportOrdering(importNodes) {
|
|
72
|
+
if (importNodes.length === 0)
|
|
73
|
+
return;
|
|
74
|
+
// Group imports
|
|
75
|
+
const groups = [
|
|
76
|
+
{ type: 'non-futdevpro', imports: [] },
|
|
77
|
+
{ type: 'futdevpro', imports: [] },
|
|
78
|
+
{ type: 'other-modules', imports: [] },
|
|
79
|
+
{ type: 'same-module', imports: [] },
|
|
80
|
+
];
|
|
81
|
+
importNodes.forEach(importNode => {
|
|
82
|
+
const groupType = getImportGroup(importNode);
|
|
83
|
+
const group = groups.find(g => g.type === groupType);
|
|
84
|
+
if (group) {
|
|
85
|
+
group.imports.push(importNode);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
// Remove empty groups
|
|
89
|
+
const nonEmptyGroups = groups.filter(group => group.imports.length > 0);
|
|
90
|
+
// Check if imports are in correct order
|
|
91
|
+
let currentGroupIndex = 0;
|
|
92
|
+
for (let i = 0; i < importNodes.length; i++) {
|
|
93
|
+
const importNode = importNodes[i];
|
|
94
|
+
const expectedGroupType = getImportGroup(importNode);
|
|
95
|
+
const expectedGroup = nonEmptyGroups.find(g => g.type === expectedGroupType);
|
|
96
|
+
const expectedGroupIndex = nonEmptyGroups.findIndex(g => g.type === expectedGroupType);
|
|
97
|
+
if (expectedGroupIndex < currentGroupIndex) {
|
|
98
|
+
context.report({
|
|
99
|
+
node: importNode,
|
|
100
|
+
messageId: 'misordered',
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
currentGroupIndex = expectedGroupIndex;
|
|
104
|
+
}
|
|
105
|
+
// Check empty lines between groups
|
|
106
|
+
for (let i = 0; i < nonEmptyGroups.length - 1; i++) {
|
|
107
|
+
const currentGroup = nonEmptyGroups[i];
|
|
108
|
+
const nextGroup = nonEmptyGroups[i + 1];
|
|
109
|
+
const lastImportOfCurrentGroup = currentGroup.imports[currentGroup.imports.length - 1];
|
|
110
|
+
const firstImportOfNextGroup = nextGroup.imports[0];
|
|
111
|
+
const lines = sourceCode.getLines();
|
|
112
|
+
const lastImportLine = lastImportOfCurrentGroup.loc?.end.line || 0;
|
|
113
|
+
const firstImportLine = firstImportOfNextGroup.loc?.start.line || 0;
|
|
114
|
+
if (firstImportLine - lastImportLine < 2) {
|
|
115
|
+
context.report({
|
|
116
|
+
node: firstImportOfNextGroup,
|
|
117
|
+
messageId: 'missingEmptyLine',
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
Program(node) {
|
|
124
|
+
const importNodes = node.body.filter((statement) => statement.type === 'ImportDeclaration');
|
|
125
|
+
// Validate individual import declarations
|
|
126
|
+
importNodes.forEach(validateImportDeclaration);
|
|
127
|
+
// Validate import ordering
|
|
128
|
+
validateImportOrdering(importNodes);
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
exports.default = rule;
|
|
134
|
+
//# sourceMappingURL=import-order.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-order.js","sourceRoot":"","sources":["../../../src/plugin/rules/import-order.ts"],"names":[],"mappings":";;AAOA,MAAM,IAAI,GAAoB;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,EAAE,WAAW,EAAE,sDAAsD,EAAE;QAC7E,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,UAAU,EAAE,gEAAgE;YAC5E,oBA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":"import-order.spec.d.ts","sourceRoot":"","sources":["../../../src/plugin/rules/import-order.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const import_order_1 = tslib_1.__importDefault(require("./import-order"));
|
|
5
|
+
describe('| import-order', () => {
|
|
6
|
+
it('| should be a valid ESLint rule', () => {
|
|
7
|
+
expect(import_order_1.default.meta?.type).toBe('suggestion');
|
|
8
|
+
expect(import_order_1.default.meta?.docs?.description).toContain('import ordering');
|
|
9
|
+
expect(import_order_1.default.meta?.fixable).toBe('code');
|
|
10
|
+
});
|
|
11
|
+
it('| should have create function that returns object with Program method', () => {
|
|
12
|
+
const mockContext = {
|
|
13
|
+
getSourceCode: () => ({
|
|
14
|
+
ast: {},
|
|
15
|
+
getLines: () => ['line1', 'line2', 'line3']
|
|
16
|
+
}),
|
|
17
|
+
getFilename: () => 'test.ts',
|
|
18
|
+
report: () => { },
|
|
19
|
+
};
|
|
20
|
+
const result = import_order_1.default.create(mockContext);
|
|
21
|
+
expect(typeof result).toBe('object');
|
|
22
|
+
expect(typeof result.Program).toBe('function');
|
|
23
|
+
});
|
|
24
|
+
it('| should detect forbidden NPM-packages imports', () => {
|
|
25
|
+
const mockContext = {
|
|
26
|
+
getSourceCode: () => ({
|
|
27
|
+
ast: {},
|
|
28
|
+
getLines: () => ['import { Something } from \'../../../NPM-packages/some-package\';']
|
|
29
|
+
}),
|
|
30
|
+
getFilename: () => 'test.ts',
|
|
31
|
+
report: (options) => {
|
|
32
|
+
expect(options.messageId).toBe('forbiddenNpmPackages');
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const mockNode = {
|
|
36
|
+
type: 'Program',
|
|
37
|
+
sourceType: 'module',
|
|
38
|
+
body: [
|
|
39
|
+
{
|
|
40
|
+
type: 'ImportDeclaration',
|
|
41
|
+
source: { value: '../../../NPM-packages/some-package' },
|
|
42
|
+
importKind: 'value',
|
|
43
|
+
loc: { start: { line: 1 }, end: { line: 1 } }
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
};
|
|
47
|
+
const rule = import_order_1.default.create(mockContext);
|
|
48
|
+
rule.Program(mockNode);
|
|
49
|
+
});
|
|
50
|
+
it('| should detect forbidden .js extension imports', () => {
|
|
51
|
+
const mockContext = {
|
|
52
|
+
getSourceCode: () => ({
|
|
53
|
+
ast: {},
|
|
54
|
+
getLines: () => ['import { Something } from \'./some-file.js\';']
|
|
55
|
+
}),
|
|
56
|
+
getFilename: () => 'test.ts',
|
|
57
|
+
report: (options) => {
|
|
58
|
+
expect(options.messageId).toBe('forbiddenJsExtension');
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
const mockNode = {
|
|
62
|
+
type: 'Program',
|
|
63
|
+
sourceType: 'module',
|
|
64
|
+
body: [
|
|
65
|
+
{
|
|
66
|
+
type: 'ImportDeclaration',
|
|
67
|
+
source: { value: './some-file.js' },
|
|
68
|
+
importKind: 'value',
|
|
69
|
+
loc: { start: { line: 1 }, end: { line: 1 } }
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
};
|
|
73
|
+
const rule = import_order_1.default.create(mockContext);
|
|
74
|
+
rule.Program(mockNode);
|
|
75
|
+
});
|
|
76
|
+
it('| should detect forbidden import type usage', () => {
|
|
77
|
+
const mockContext = {
|
|
78
|
+
getSourceCode: () => ({
|
|
79
|
+
ast: {},
|
|
80
|
+
getLines: () => ['import type { SomeType } from \'./some-file\';']
|
|
81
|
+
}),
|
|
82
|
+
getFilename: () => 'test.ts',
|
|
83
|
+
report: (options) => {
|
|
84
|
+
expect(options.messageId).toBe('forbiddenImportType');
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
const mockNode = {
|
|
88
|
+
type: 'Program',
|
|
89
|
+
sourceType: 'module',
|
|
90
|
+
body: [
|
|
91
|
+
{
|
|
92
|
+
type: 'ImportDeclaration',
|
|
93
|
+
source: { value: './some-file' },
|
|
94
|
+
importKind: 'type',
|
|
95
|
+
loc: { start: { line: 1 }, end: { line: 1 } }
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
};
|
|
99
|
+
const rule = import_order_1.default.create(mockContext);
|
|
100
|
+
rule.Program(mockNode);
|
|
101
|
+
});
|
|
102
|
+
it('| should detect misordered imports', () => {
|
|
103
|
+
let reportCount = 0;
|
|
104
|
+
const mockContext = {
|
|
105
|
+
getSourceCode: () => ({
|
|
106
|
+
ast: {},
|
|
107
|
+
getLines: () => [
|
|
108
|
+
'import { DyFM_Error } from \'@futdevpro/fsm-dynamo\';',
|
|
109
|
+
'import { Component } from \'@angular/core\';'
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
112
|
+
getFilename: () => 'test.ts',
|
|
113
|
+
report: (options) => {
|
|
114
|
+
if (options.messageId === 'misordered') {
|
|
115
|
+
reportCount++;
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
const mockNode = {
|
|
120
|
+
type: 'Program',
|
|
121
|
+
sourceType: 'module',
|
|
122
|
+
body: [
|
|
123
|
+
{
|
|
124
|
+
type: 'ImportDeclaration',
|
|
125
|
+
source: { value: '@futdevpro/fsm-dynamo' },
|
|
126
|
+
importKind: 'value',
|
|
127
|
+
loc: { start: { line: 1 }, end: { line: 1 } }
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: 'ImportDeclaration',
|
|
131
|
+
source: { value: '@angular/core' },
|
|
132
|
+
importKind: 'value',
|
|
133
|
+
loc: { start: { line: 2 }, end: { line: 2 } }
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
};
|
|
137
|
+
const rule = import_order_1.default.create(mockContext);
|
|
138
|
+
rule.Program(mockNode);
|
|
139
|
+
expect(reportCount).toBeGreaterThan(0);
|
|
140
|
+
});
|
|
141
|
+
it('| should detect missing empty line between groups', () => {
|
|
142
|
+
let reportCount = 0;
|
|
143
|
+
const mockContext = {
|
|
144
|
+
getSourceCode: () => ({
|
|
145
|
+
ast: {},
|
|
146
|
+
getLines: () => [
|
|
147
|
+
'import { Component } from \'@angular/core\';',
|
|
148
|
+
'import { DyFM_Error } from \'@futdevpro/fsm-dynamo\';'
|
|
149
|
+
]
|
|
150
|
+
}),
|
|
151
|
+
getFilename: () => 'test.ts',
|
|
152
|
+
report: (options) => {
|
|
153
|
+
if (options.messageId === 'missingEmptyLine') {
|
|
154
|
+
reportCount++;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
const mockNode = {
|
|
159
|
+
type: 'Program',
|
|
160
|
+
sourceType: 'module',
|
|
161
|
+
body: [
|
|
162
|
+
{
|
|
163
|
+
type: 'ImportDeclaration',
|
|
164
|
+
source: { value: '@angular/core' },
|
|
165
|
+
importKind: 'value',
|
|
166
|
+
loc: { start: { line: 1 }, end: { line: 1 } }
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
type: 'ImportDeclaration',
|
|
170
|
+
source: { value: '@futdevpro/fsm-dynamo' },
|
|
171
|
+
importKind: 'value',
|
|
172
|
+
loc: { start: { line: 2 }, end: { line: 2 } }
|
|
173
|
+
}
|
|
174
|
+
]
|
|
175
|
+
};
|
|
176
|
+
const rule = import_order_1.default.create(mockContext);
|
|
177
|
+
rule.Program(mockNode);
|
|
178
|
+
expect(reportCount).toBeGreaterThan(0);
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
//# sourceMappingURL=import-order.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import-order.spec.js","sourceRoot":"","sources":["../../../src/plugin/rules/import-order.spec.ts"],"names":[],"mappings":";;;AAAA,0EAA6C;AAE7C,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,sBAAe,CAAC,IAAI,EAAE,IAAI,CAAC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AAQ,CAAC;AAGnC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,UAiBhB,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
// import * as dyfmUtils from '@futdevpro/fsm-dynamo';
|
|
4
|
+
const rule = {
|
|
5
|
+
meta: {
|
|
6
|
+
type: 'suggestion',
|
|
7
|
+
docs: { description: 'Enforce naming conventions using DyFM patterns' },
|
|
8
|
+
schema: [],
|
|
9
|
+
messages: {
|
|
10
|
+
invalidName: 'Identifier "{{name}}" does not match required naming pattern.',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
create(context) {
|
|
14
|
+
return {
|
|
15
|
+
Identifier(node) {
|
|
16
|
+
// Future: use dyfmUtils naming patterns to validate identifiers
|
|
17
|
+
void node;
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
exports.default = rule;
|
|
23
|
+
//# sourceMappingURL=naming-patterns.js.map
|
|
@@ -0,0 +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;gBAChE,KAAK,IAAI,CAAC;YACZ,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC;AAEF,kBAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-patterns.spec.d.ts","sourceRoot":"","sources":["../../../src/plugin/rules/naming-patterns.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const naming_patterns_1 = tslib_1.__importDefault(require("./naming-patterns"));
|
|
5
|
+
describe('| naming-patterns', () => {
|
|
6
|
+
it('| should be a valid ESLint rule', () => {
|
|
7
|
+
expect(naming_patterns_1.default.meta?.type).toBe('suggestion');
|
|
8
|
+
expect(naming_patterns_1.default.meta?.docs?.description).toContain('naming conventions');
|
|
9
|
+
});
|
|
10
|
+
it('| should have create function that returns object with Identifier method', () => {
|
|
11
|
+
const mockContext = {
|
|
12
|
+
report: () => { },
|
|
13
|
+
};
|
|
14
|
+
const result = naming_patterns_1.default.create(mockContext);
|
|
15
|
+
expect(typeof result).toBe('object');
|
|
16
|
+
expect(typeof result.Identifier).toBe('function');
|
|
17
|
+
});
|
|
18
|
+
it('| should handle valid identifiers without errors', () => {
|
|
19
|
+
const mockContext = {
|
|
20
|
+
report: (options) => {
|
|
21
|
+
// Should not be called for valid identifiers
|
|
22
|
+
fail('Should not report errors for valid identifiers');
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const mockNode = {
|
|
26
|
+
type: 'Identifier',
|
|
27
|
+
name: 'validVariableName',
|
|
28
|
+
loc: { start: { line: 1 }, end: { line: 1 } }
|
|
29
|
+
};
|
|
30
|
+
const rule = naming_patterns_1.default.create(mockContext);
|
|
31
|
+
rule.Identifier(mockNode);
|
|
32
|
+
// If we get here without the report function being called, the test passes
|
|
33
|
+
expect(true).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=naming-patterns.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming-patterns.spec.js","sourceRoot":"","sources":["../../../src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,CAAC,QAAQ,CAAC,CAAC;QAE1B,2EAA2E;QAC3E,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslintrc-audit.d.ts","sourceRoot":"","sources":["../../src/scripts/eslintrc-audit.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
function safeParse(jsonPath) {
|
|
8
|
+
try {
|
|
9
|
+
const content = (0, fs_1.readFileSync)(jsonPath, 'utf8');
|
|
10
|
+
return JSON.parse(content);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function main() {
|
|
17
|
+
const files = await (0, fast_glob_1.default)(['**/.eslintrc.json'], { ignore: ['**/node_modules/**'] });
|
|
18
|
+
const ruleCounts = {};
|
|
19
|
+
const total = files.length;
|
|
20
|
+
for (const p of files) {
|
|
21
|
+
const cfg = safeParse(p);
|
|
22
|
+
if (!cfg?.rules)
|
|
23
|
+
continue;
|
|
24
|
+
for (const key of Object.keys(cfg.rules)) {
|
|
25
|
+
ruleCounts[key] = (ruleCounts[key] ?? 0) + 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const entries = Object.entries(ruleCounts).sort((a, b) => b[1] - a[1]);
|
|
29
|
+
console.log(`[dynamo-eslintrc-audit] analyzed ${total} files`);
|
|
30
|
+
console.table(entries.slice(0, 50).map(([rule, count]) => ({ rule, count })));
|
|
31
|
+
}
|
|
32
|
+
main().catch((err) => {
|
|
33
|
+
console.error(err);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=eslintrc-audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslintrc-audit.js","sourceRoot":"","sources":["../../src/scripts/eslintrc-audit.ts"],"names":[],"mappings":";;;;AACA,kEAA2B;AAC3B,2BAAkC;AAIlC,SAAS,SAAS,CAAC,QAAgB;IACjC,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,iBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,KAAK,GAAG,MAAM,IAAA,mBAAE,EAAC,CAAC,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC;IAClF,MAAM,UAAU,GAA2B,EAAE,CAAC;IAC9C,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;IAE3B,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,GAAG,EAAE,KAAK;YAAE,SAAS;QAC1B,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,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,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,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-imports.d.ts","sourceRoot":"","sources":["../../src/scripts/validate-imports.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fast_glob_1 = tslib_1.__importDefault(require("fast-glob"));
|
|
6
|
+
const eslint_1 = require("eslint");
|
|
7
|
+
async function validateImportsInFile(filePath) {
|
|
8
|
+
const eslint = new eslint_1.ESLint({
|
|
9
|
+
baseConfig: {
|
|
10
|
+
parser: '@typescript-eslint/parser',
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaVersion: 2020,
|
|
13
|
+
sourceType: 'module',
|
|
14
|
+
},
|
|
15
|
+
rules: {
|
|
16
|
+
'@futdevpro/dynamo/import-order': 'error',
|
|
17
|
+
},
|
|
18
|
+
plugins: {
|
|
19
|
+
'@futdevpro/dynamo': {
|
|
20
|
+
rules: {
|
|
21
|
+
'import-order': require('../plugin/rules/import-order').default,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const results = await eslint.lintFiles([filePath]);
|
|
28
|
+
const result = results[0];
|
|
29
|
+
return {
|
|
30
|
+
file: filePath,
|
|
31
|
+
errors: result.messages.map(msg => ({
|
|
32
|
+
line: msg.line,
|
|
33
|
+
column: msg.column,
|
|
34
|
+
message: msg.message,
|
|
35
|
+
ruleId: msg.ruleId || 'unknown',
|
|
36
|
+
})),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async function main() {
|
|
40
|
+
const files = await (0, fast_glob_1.default)(['**/*.{ts,tsx}'], {
|
|
41
|
+
ignore: ['**/node_modules/**', '**/build/**', '**/dist/**', '**/*.spec.ts', '**/*.test.ts']
|
|
42
|
+
});
|
|
43
|
+
console.log(`[dynamo-validate-imports] Scanning ${files.length} files...`);
|
|
44
|
+
const results = [];
|
|
45
|
+
let totalErrors = 0;
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
try {
|
|
48
|
+
const result = await validateImportsInFile(file);
|
|
49
|
+
results.push(result);
|
|
50
|
+
totalErrors += result.errors.length;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error(`Error processing ${file}:`, error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Report results
|
|
57
|
+
const filesWithErrors = results.filter(r => r.errors.length > 0);
|
|
58
|
+
if (filesWithErrors.length === 0) {
|
|
59
|
+
console.log('ā
All import validations passed!');
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
console.log(`\nā Found ${totalErrors} import validation errors in ${filesWithErrors.length} files:\n`);
|
|
63
|
+
filesWithErrors.forEach(result => {
|
|
64
|
+
console.log(`š ${result.file}:`);
|
|
65
|
+
result.errors.forEach(error => {
|
|
66
|
+
console.log(` ${error.line}:${error.column} - ${error.message}`);
|
|
67
|
+
});
|
|
68
|
+
console.log('');
|
|
69
|
+
});
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
main().catch((err) => {
|
|
73
|
+
console.error('Validation failed:', err);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=validate-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-imports.js","sourceRoot":"","sources":["../../src/scripts/validate-imports.ts"],"names":[],"mappings":";;;;AACA,kEAA2B;AAE3B,mCAAgC;AAahC,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,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,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnD,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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