@futdevpro/dynamo-eslint 1.20.2 → 1.20.5
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/LICENSE +21 -0
- package/README.md +305 -305
- package/build/configs/ngx.js +2 -2
- package/build/configs/ngx.js.map +1 -1
- package/build/plugin/rules/ts/no-as-cast.d.ts.map +1 -1
- package/build/plugin/rules/ts/no-as-cast.js +43 -0
- package/build/plugin/rules/ts/no-as-cast.js.map +1 -1
- package/package.json +14 -7
- package/.c8rc.json +0 -26
- package/.cursor/rules/__assistant_guide.mdc +0 -30
- package/.cursor/rules/__main.mdc +0 -64
- package/.cursor/rules/_ag_backend-structure.mdc +0 -86
- package/.cursor/rules/_ag_backend.mdc +0 -16
- package/.cursor/rules/_ag_debug.mdc +0 -8
- package/.cursor/rules/_ag_documentation_writing_rules.mdc +0 -372
- package/.cursor/rules/_ag_file-refactoring.mdc +0 -113
- package/.cursor/rules/_ag_fixes_rules.mdc +0 -6
- package/.cursor/rules/_ag_frontend-structure.mdc +0 -87
- package/.cursor/rules/_ag_frontend.mdc +0 -40
- package/.cursor/rules/_ag_import-rules.mdc +0 -45
- package/.cursor/rules/_ag_naming.mdc +0 -116
- package/.cursor/rules/_ag_running_commands.mdc +0 -5
- package/.cursor/rules/_ag_server-controller.mdc +0 -6
- package/.cursor/rules/_ag_should-be.mdc +0 -7
- package/.cursor/rules/_ag_swearing.mdc +0 -47
- package/.cursor/rules/ai_development_guide.md +0 -61
- package/.cursor/rules/ai_directives.md +0 -114
- package/.cursor/rules/cursor-rules.md +0 -160
- package/.cursor/rules/default-command.mdc +0 -465
- package/.cursor/rules/error_code_pattern.md +0 -40
- package/.cursor/rules/saved rule mcp server use.md +0 -16
- package/.dynamo/pipeline.cicd.config.json +0 -184
- package/.dynamo/version-bump.config.json +0 -5
- package/.eslintrc.json +0 -4
- package/.github/workflows/main.yml +0 -436
- package/.husky/pre-commit +0 -2
- package/.vscode/settings.json +0 -11
- package/__documentations/2026-04-18-ccap-review-integration.md +0 -173
- package/__documentations/2026-08-18-bfr-ctm-005-eslint9-validator-report.md +0 -45
- package/__documentations/2026-08-22-angular-20-phase2-release.md +0 -79
- package/eslint.config.js +0 -15
- package/pnpm-workspace.yaml +0 -2
- package/samples/.vscode/settings.json +0 -13
- package/samples/base/.eslintrc.json +0 -6
- package/samples/base/eslint.config.js +0 -3
- package/samples/fsm/.eslintrc.json +0 -4
- package/samples/fsm/eslint.config.js +0 -3
- package/samples/ngx/.eslintrc.json +0 -6
- package/samples/ngx/eslint.config.js +0 -3
- package/samples/ngx-package/.eslintrc.json +0 -4
- package/samples/ngx-package/eslint.config.js +0 -3
- package/samples/nts/.eslintrc.json +0 -6
- package/samples/nts/eslint.config.js +0 -3
- package/samples/nts-package/.eslintrc.json +0 -4
- package/samples/nts-package/eslint.config.js +0 -3
- package/samples/package.json.example +0 -22
- package/samples/poc-sample.ts +0 -38
- package/samples/poc-violations.ts +0 -54
- package/scripts/run-coverage-tests.js +0 -24
- package/spec/support/helpers/ts-node-helper.js +0 -9
- package/spec/support/jasmine.coverage.json +0 -23
- package/spec/support/jasmine.json +0 -24
- package/src/configs/angular20-compatibility.spec.ts +0 -62
- package/src/configs/base.ts +0 -156
- package/src/configs/fsm.ts +0 -10
- package/src/configs/ngx-package.ts +0 -10
- package/src/configs/ngx.ts +0 -93
- package/src/configs/nts-package.ts +0 -20
- package/src/configs/nts.ts +0 -34
- package/src/index.ts +0 -4
- package/src/plugin/index.ts +0 -86
- package/src/plugin/rules/angular/angular-for-track-logic.spec.ts +0 -44
- package/src/plugin/rules/angular/angular-for-track-logic.ts +0 -88
- package/src/plugin/rules/angular/effect-signal-loop.spec.ts +0 -89
- package/src/plugin/rules/angular/effect-signal-loop.ts +0 -125
- package/src/plugin/rules/angular/no-async-ngoninit.spec.ts +0 -50
- package/src/plugin/rules/angular/no-async-ngoninit.ts +0 -43
- package/src/plugin/rules/angular/no-component-direct-api.spec.ts +0 -78
- package/src/plugin/rules/angular/no-component-direct-api.ts +0 -82
- package/src/plugin/rules/angular/no-method-call-in-template.spec.ts +0 -63
- package/src/plugin/rules/angular/no-method-call-in-template.ts +0 -89
- package/src/plugin/rules/angular/no-ngfor-directive.spec.ts +0 -44
- package/src/plugin/rules/angular/no-ngfor-directive.ts +0 -62
- package/src/plugin/rules/angular/no-ngif-directive.spec.ts +0 -44
- package/src/plugin/rules/angular/no-ngif-directive.ts +0 -62
- package/src/plugin/rules/explicit-types.spec.ts +0 -190
- package/src/plugin/rules/explicit-types.ts +0 -186
- package/src/plugin/rules/import/import-order.spec.ts +0 -219
- package/src/plugin/rules/import/import-order.ts +0 -197
- package/src/plugin/rules/import/no-import-type.spec.ts +0 -69
- package/src/plugin/rules/import/no-import-type.ts +0 -46
- package/src/plugin/rules/import/no-js-import.spec.ts +0 -82
- package/src/plugin/rules/import/no-js-import.ts +0 -45
- package/src/plugin/rules/naming-patterns.spec.ts +0 -189
- package/src/plugin/rules/naming-patterns.ts +0 -426
- package/src/plugin/rules/no-getter-logic.spec.ts +0 -591
- package/src/plugin/rules/no-getter-logic.ts +0 -220
- package/src/plugin/rules/prefer-enum-over-string-union.spec.ts +0 -583
- package/src/plugin/rules/prefer-enum-over-string-union.ts +0 -333
- package/src/plugin/rules/prefer-interface-over-duplicate-types.spec.ts +0 -404
- package/src/plugin/rules/prefer-interface-over-duplicate-types.ts +0 -314
- package/src/plugin/rules/require-jsdoc-description.spec.ts +0 -779
- package/src/plugin/rules/require-jsdoc-description.ts +0 -572
- package/src/plugin/rules/require-test-description-prefix.spec.ts +0 -459
- package/src/plugin/rules/require-test-description-prefix.ts +0 -154
- package/src/plugin/rules/ts/data-model-extends.spec.ts +0 -84
- package/src/plugin/rules/ts/data-model-extends.ts +0 -100
- package/src/plugin/rules/ts/no-any-type.spec.ts +0 -28
- package/src/plugin/rules/ts/no-any-type.ts +0 -36
- package/src/plugin/rules/ts/no-as-cast.spec.ts +0 -51
- package/src/plugin/rules/ts/no-as-cast.ts +0 -51
- package/src/plugin/rules/ts/no-dynamic-imports.spec.ts +0 -54
- package/src/plugin/rules/ts/no-dynamic-imports.ts +0 -49
- package/src/plugin/rules/ts/no-native-browser-dialogs.spec.ts +0 -54
- package/src/plugin/rules/ts/no-native-browser-dialogs.ts +0 -84
- package/src/plugin/rules/ts/no-plain-function-export.spec.ts +0 -72
- package/src/plugin/rules/ts/no-plain-function-export.ts +0 -73
- package/src/plugin/rules/ts/one-export-per-file.spec.ts +0 -64
- package/src/plugin/rules/ts/one-export-per-file.ts +0 -77
- package/src/scripts/dynamo-fix.ts +0 -172
- package/src/scripts/eslintrc-audit.ts +0 -116
- package/src/scripts/fix-return-types.spec.ts +0 -65
- package/src/scripts/fix-return-types.ts +0 -289
- package/src/scripts/validate-imports.ts +0 -292
- package/src/scripts/validate-naming.ts +0 -213
- package/src/scripts/validator-cli.integration.spec.ts +0 -99
- package/tsconfig.json +0 -32
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import namingPatternsRule from './naming-patterns';
|
|
2
|
-
|
|
3
|
-
describe('| naming-patterns', () => {
|
|
4
|
-
it('| should be a valid ESLint rule', () => {
|
|
5
|
-
expect(namingPatternsRule.meta?.type).toBe('suggestion');
|
|
6
|
-
expect(namingPatternsRule.meta?.docs?.description).toContain('naming conventions');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('| should expose PropertyDefinition / ClassDeclaration / TSEnumDeclaration visitors for non-spec files', () => {
|
|
10
|
-
const mockContext: any = {
|
|
11
|
-
filename: '/x/foo.ts',
|
|
12
|
-
report: () => {},
|
|
13
|
-
options: [],
|
|
14
|
-
};
|
|
15
|
-
const result: any = namingPatternsRule.create(mockContext);
|
|
16
|
-
expect(typeof result.PropertyDefinition).toBe('function');
|
|
17
|
-
expect(typeof result.ClassDeclaration).toBe('function');
|
|
18
|
-
expect(typeof result.TSEnumDeclaration).toBe('function');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('| should skip .spec.ts files entirely', () => {
|
|
22
|
-
const mockContext: any = {
|
|
23
|
-
filename: '/x/foo.spec.ts',
|
|
24
|
-
report: () => {},
|
|
25
|
-
options: [],
|
|
26
|
-
};
|
|
27
|
-
const result: any = namingPatternsRule.create(mockContext);
|
|
28
|
-
expect(result.PropertyDefinition).toBeUndefined();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('| should report class without required postfix in *.data-model.ts', () => {
|
|
32
|
-
let reportCalled: boolean = false;
|
|
33
|
-
const mockContext: any = {
|
|
34
|
-
filename: '/x/user.data-model.ts',
|
|
35
|
-
report: (options: any): void => {
|
|
36
|
-
if (options.messageId === 'fileClassPostfix') {
|
|
37
|
-
reportCalled = true;
|
|
38
|
-
expect(options.data.requiredPostfix).toBe('_DataModel');
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
options: [],
|
|
42
|
-
};
|
|
43
|
-
const rule: any = namingPatternsRule.create(mockContext);
|
|
44
|
-
const mockNode: any = { id: { name: 'User' } };
|
|
45
|
-
rule.ClassDeclaration(mockNode);
|
|
46
|
-
expect(reportCalled).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('| should NOT report class with correct postfix in *.data-model.ts', () => {
|
|
50
|
-
let reportCalled: boolean = false;
|
|
51
|
-
const mockContext: any = {
|
|
52
|
-
filename: '/x/user.data-model.ts',
|
|
53
|
-
report: (options: any): void => {
|
|
54
|
-
if (options.messageId === 'fileClassPostfix') {
|
|
55
|
-
reportCalled = true;
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
options: [],
|
|
59
|
-
};
|
|
60
|
-
const rule: any = namingPatternsRule.create(mockContext);
|
|
61
|
-
const mockNode: any = { id: { name: 'User_DataModel' } };
|
|
62
|
-
rule.ClassDeclaration(mockNode);
|
|
63
|
-
expect(reportCalled).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('| should report non-camelCase enum key in *.type-enum.ts', () => {
|
|
67
|
-
let reportCalled: boolean = false;
|
|
68
|
-
const mockContext: any = {
|
|
69
|
-
filename: '/x/user-status.type-enum.ts',
|
|
70
|
-
report: (options: any): void => {
|
|
71
|
-
if (options.messageId === 'enumKeyCamel') {
|
|
72
|
-
reportCalled = true;
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
options: [],
|
|
76
|
-
};
|
|
77
|
-
const rule: any = namingPatternsRule.create(mockContext);
|
|
78
|
-
const mockNode: any = {
|
|
79
|
-
members: [
|
|
80
|
-
{ id: { name: 'NotCamelCase' }, initializer: null },
|
|
81
|
-
],
|
|
82
|
-
};
|
|
83
|
-
rule.TSEnumDeclaration(mockNode);
|
|
84
|
-
expect(reportCalled).toBe(true);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('| should report non-kebab-case string value in enum', () => {
|
|
88
|
-
let reportCalled: boolean = false;
|
|
89
|
-
const mockContext: any = {
|
|
90
|
-
filename: '/x/user-status.type-enum.ts',
|
|
91
|
-
report: (options: any): void => {
|
|
92
|
-
if (options.messageId === 'enumValueKebab') {
|
|
93
|
-
reportCalled = true;
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
options: [],
|
|
97
|
-
};
|
|
98
|
-
const rule: any = namingPatternsRule.create(mockContext);
|
|
99
|
-
const mockNode: any = {
|
|
100
|
-
members: [
|
|
101
|
-
{
|
|
102
|
-
id: { name: 'activeUser' },
|
|
103
|
-
initializer: { type: 'Literal', value: 'NotKebabCase' },
|
|
104
|
-
},
|
|
105
|
-
],
|
|
106
|
-
};
|
|
107
|
-
rule.TSEnumDeclaration(mockNode);
|
|
108
|
-
expect(reportCalled).toBe(true);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('| should respect `checks` option and disable booleanIsPrefix', () => {
|
|
112
|
-
let reportCalled: boolean = false;
|
|
113
|
-
const mockContext: any = {
|
|
114
|
-
filename: '/x/user.ts',
|
|
115
|
-
report: () => { reportCalled = true; },
|
|
116
|
-
options: [{ checks: { booleanIsPrefix: false }}],
|
|
117
|
-
};
|
|
118
|
-
const rule: any = namingPatternsRule.create(mockContext);
|
|
119
|
-
const mockNode: any = {
|
|
120
|
-
key: { type: 'Identifier', name: 'active' },
|
|
121
|
-
typeAnnotation: { typeAnnotation: { type: 'TSBooleanKeyword' }},
|
|
122
|
-
value: null,
|
|
123
|
-
};
|
|
124
|
-
rule.PropertyDefinition(mockNode);
|
|
125
|
-
expect(reportCalled).toBe(false);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
// ─ BFR-ADVENTOR-018 — kanonikus `ls` nyelv-service kivétel a service-property-postfix alól ─
|
|
129
|
-
|
|
130
|
-
/** Helper: inject(<serviceName>) CallExpression mock. */
|
|
131
|
-
function buildInjectNode(propName: string, serviceName: string): any {
|
|
132
|
-
return {
|
|
133
|
-
key: { type: 'Identifier', name: propName },
|
|
134
|
-
value: {
|
|
135
|
-
type: 'CallExpression',
|
|
136
|
-
callee: { type: 'Identifier', name: 'inject' },
|
|
137
|
-
arguments: [ { type: 'Identifier', name: serviceName } ],
|
|
138
|
-
},
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
it('| BFR-ADVENTOR-018: `ls = inject(A_Language_ControlService)` NEM lelet (beépített kivétel)', () => {
|
|
143
|
-
let reportCalled: boolean = false;
|
|
144
|
-
const mockContext: any = {
|
|
145
|
-
filename: '/x/app.component.ts',
|
|
146
|
-
report: (options: any): void => {
|
|
147
|
-
if (options.messageId === 'servicePropertyPostfix') {
|
|
148
|
-
reportCalled = true;
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
options: [],
|
|
152
|
-
};
|
|
153
|
-
const rule: any = namingPatternsRule.create(mockContext);
|
|
154
|
-
rule.PropertyDefinition(buildInjectNode('ls', 'A_Language_ControlService'));
|
|
155
|
-
expect(reportCalled).toBe(false);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('| BFR-ADVENTOR-018: más rövid név ControlService-re továbbra is lelet', () => {
|
|
159
|
-
let reportCalled: boolean = false;
|
|
160
|
-
const mockContext: any = {
|
|
161
|
-
filename: '/x/app.component.ts',
|
|
162
|
-
report: (options: any): void => {
|
|
163
|
-
if (options.messageId === 'servicePropertyPostfix') {
|
|
164
|
-
reportCalled = true;
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
options: [],
|
|
168
|
-
};
|
|
169
|
-
const rule: any = namingPatternsRule.create(mockContext);
|
|
170
|
-
rule.PropertyDefinition(buildInjectNode('auth', 'A_Auth_ControlService'));
|
|
171
|
-
expect(reportCalled).toBe(true);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('| BFR-ADVENTOR-018: projekt-szintű allowedPropertyNames opció bővíti a kivétel-listát', () => {
|
|
175
|
-
let reportCalled: boolean = false;
|
|
176
|
-
const mockContext: any = {
|
|
177
|
-
filename: '/x/app.component.ts',
|
|
178
|
-
report: (options: any): void => {
|
|
179
|
-
if (options.messageId === 'servicePropertyPostfix') {
|
|
180
|
-
reportCalled = true;
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
options: [ { allowedPropertyNames: [ 'store' ] } ],
|
|
184
|
-
};
|
|
185
|
-
const rule: any = namingPatternsRule.create(mockContext);
|
|
186
|
-
rule.PropertyDefinition(buildInjectNode('store', 'A_Store_ControlService'));
|
|
187
|
-
expect(reportCalled).toBe(false);
|
|
188
|
-
});
|
|
189
|
-
});
|
|
@@ -1,426 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import { Rule } from 'eslint';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Konfigurálható al-ellenőrzések — alapból minden bekapcsolva.
|
|
6
|
-
* Eredete: CCAP "naming/*" review-k (boolean-is-prefix, signal-postfix, rxjs-postfix,
|
|
7
|
-
* file-class-postfix, enum-value-format, service-property-postfix,
|
|
8
|
-
* file-class-name-consistency).
|
|
9
|
-
*/
|
|
10
|
-
interface NamingChecksOptions {
|
|
11
|
-
booleanIsPrefix?: boolean;
|
|
12
|
-
signalPostfix?: boolean;
|
|
13
|
-
rxjsPostfix?: boolean;
|
|
14
|
-
fileClassPostfix?: boolean;
|
|
15
|
-
enumValueFormat?: boolean;
|
|
16
|
-
servicePropertyPostfix?: boolean;
|
|
17
|
-
fileClassNameConsistency?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Fájlminta → kötelező class postfix leképezés (CCAP file-class-postfix).
|
|
22
|
-
*/
|
|
23
|
-
const FILE_POSTFIX_MAP: { pattern: RegExp; classPostfix: string; entitySuffix: string }[] = [
|
|
24
|
-
{ pattern: /\.data-model\.ts$/, classPostfix: '_DataModel', entitySuffix: '.data-model.ts' },
|
|
25
|
-
{ pattern: /\.control-model\.ts$/, classPostfix: '_ControlModel', entitySuffix: '.control-model.ts' },
|
|
26
|
-
{ pattern: /\.control-service\.ts$/, classPostfix: '_ControlService', entitySuffix: '.control-service.ts' },
|
|
27
|
-
{ pattern: /\.data-service\.ts$/, classPostfix: '_DataService', entitySuffix: '.data-service.ts' },
|
|
28
|
-
{ pattern: /\.api-service\.ts$/, classPostfix: '_ApiService', entitySuffix: '.api-service.ts' },
|
|
29
|
-
{ pattern: /\.util-service\.ts$/, classPostfix: '_Util', entitySuffix: '.util-service.ts' },
|
|
30
|
-
{ pattern: /\.service-base\.ts$/, classPostfix: '_ServiceBase', entitySuffix: '.service-base.ts' },
|
|
31
|
-
{ pattern: /\.controller\.ts$/, classPostfix: '_Controller', entitySuffix: '.controller.ts' },
|
|
32
|
-
{ pattern: /\.component\.ts$/, classPostfix: '_Component', entitySuffix: '.component.ts' },
|
|
33
|
-
{ pattern: /\.pipe\.ts$/, classPostfix: '_Pipe', entitySuffix: '.pipe.ts' },
|
|
34
|
-
{ pattern: /\.directive\.ts$/, classPostfix: '_Directive', entitySuffix: '.directive.ts' },
|
|
35
|
-
{ pattern: /\.module\.ts$/, classPostfix: '_Module', entitySuffix: '.module.ts' },
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* BFR-ADVENTOR-018: kanonikus, a service-property-postfix kényszer ALÓL KIVETT property-nevek.
|
|
40
|
-
* Az `ls` a flotta bevett nyelv-service mintája (`readonly ls = inject(A_Language_ControlService)`;
|
|
41
|
-
* a template-ekben `{{ ls.llt.… }}`) — a szabály eddig a bedrock SAJÁT dokumentált
|
|
42
|
-
* konzumens-mintáját flagelte. Projekt-szinten bővíthető az `allowedPropertyNames` opcióval.
|
|
43
|
-
*/
|
|
44
|
-
const DEFAULT_ALLOWED_PROPERTY_NAMES: string[] = [ 'ls' ];
|
|
45
|
-
|
|
46
|
-
/** Service class postfix → kötelező inject property postfix leképezés (CCAP service-property-postfix). */
|
|
47
|
-
const SERVICE_INJECT_POSTFIX_MAP: { classPostfix: string; propertyPostfix: string }[] = [
|
|
48
|
-
{ classPostfix: '_DataService', propertyPostfix: '_DS' },
|
|
49
|
-
{ classPostfix: '_ControlService', propertyPostfix: '_CS' },
|
|
50
|
-
{ classPostfix: '_ApiService', propertyPostfix: '_AS' },
|
|
51
|
-
{ classPostfix: '_MasterService', propertyPostfix: '_MS' },
|
|
52
|
-
];
|
|
53
|
-
|
|
54
|
-
/** Signal factory függvény nevek (CCAP signal-postfix). */
|
|
55
|
-
const SIGNAL_FACTORY_NAMES: Set<string> = new Set<string>([ 'signal', 'computed', 'toSignal' ]);
|
|
56
|
-
|
|
57
|
-
/** RxJS típusnevek detektáláshoz. */
|
|
58
|
-
const RXJS_BEHAVIOR_SUBJECT_NAME: string = 'BehaviorSubject';
|
|
59
|
-
const RXJS_SUBJECT_NAME: string = 'Subject';
|
|
60
|
-
const RXJS_OBSERVABLE_NAME: string = 'Observable';
|
|
61
|
-
|
|
62
|
-
/** camelCase enum kulcs regex. */
|
|
63
|
-
const CAMEL_CASE_KEY_REGEX: RegExp = /^[a-z][a-zA-Z0-9]*$/;
|
|
64
|
-
|
|
65
|
-
/** kebab-case enum érték regex. */
|
|
66
|
-
const KEBAB_CASE_VALUE_REGEX: RegExp = /^[a-z0-9][a-z0-9-]*$/;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* PascalCase szót kebab-case-re konvertál (CCAP file-class-name-consistency).
|
|
70
|
-
*/
|
|
71
|
-
function pascalPartToKebab(str: string): string {
|
|
72
|
-
if (str === str.toUpperCase() && str.length > 1) {
|
|
73
|
-
return str.toLowerCase();
|
|
74
|
-
}
|
|
75
|
-
return str
|
|
76
|
-
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
77
|
-
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
|
|
78
|
-
.toLowerCase();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Class entity nevet kebab-case fájlnév entity részére konvertál.
|
|
83
|
-
*/
|
|
84
|
-
function classEntityToKebab(classEntity: string): string {
|
|
85
|
-
const parts: string[] = classEntity.split('_').filter((p: string): boolean => p.length > 0);
|
|
86
|
-
return parts.map(pascalPartToKebab).join('-');
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Megnézi, hogy a property type-annotation `boolean`-e.
|
|
91
|
-
*/
|
|
92
|
-
function isBooleanType(typeAnnotation: any): boolean {
|
|
93
|
-
if (!typeAnnotation || !typeAnnotation.typeAnnotation) {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
return typeAnnotation.typeAnnotation.type === 'TSBooleanKeyword';
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Megnézi, hogy a property init signal/computed/toSignal hívás-e.
|
|
101
|
-
*/
|
|
102
|
-
function isSignalFactoryCall(init: any): boolean {
|
|
103
|
-
if (!init || init.type !== 'CallExpression') {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
const callee: any = init.callee;
|
|
107
|
-
if (!callee || callee.type !== 'Identifier') {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
return SIGNAL_FACTORY_NAMES.has(callee.name);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Detektálja az RxJS típust property type-annotation vagy `new XSubject()` init alapján.
|
|
115
|
-
*/
|
|
116
|
-
function detectRxjsKind(typeAnnotation: any, init: any): 'BS' | 'S' | 'OBS' | null {
|
|
117
|
-
const typeName: string | null = (() => {
|
|
118
|
-
if (!typeAnnotation || !typeAnnotation.typeAnnotation) {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
const t: any = typeAnnotation.typeAnnotation;
|
|
122
|
-
if (t.type !== 'TSTypeReference' || !t.typeName) {
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
if (t.typeName.type === 'Identifier') {
|
|
126
|
-
return t.typeName.name;
|
|
127
|
-
}
|
|
128
|
-
return null;
|
|
129
|
-
})();
|
|
130
|
-
|
|
131
|
-
const newName: string | null = (() => {
|
|
132
|
-
if (!init || init.type !== 'NewExpression' || !init.callee || init.callee.type !== 'Identifier') {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
return init.callee.name;
|
|
136
|
-
})();
|
|
137
|
-
|
|
138
|
-
const candidate: string | null = typeName ?? newName;
|
|
139
|
-
if (candidate === null) {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
if (candidate === RXJS_BEHAVIOR_SUBJECT_NAME) {
|
|
143
|
-
return 'BS';
|
|
144
|
-
}
|
|
145
|
-
if (candidate === RXJS_SUBJECT_NAME) {
|
|
146
|
-
return 'S';
|
|
147
|
-
}
|
|
148
|
-
if (candidate === RXJS_OBSERVABLE_NAME) {
|
|
149
|
-
return 'OBS';
|
|
150
|
-
}
|
|
151
|
-
return null;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Detektálja, hogy az init `inject(SomeService)` hívás-e — visszaadja a service nevet.
|
|
156
|
-
*/
|
|
157
|
-
function detectInjectedService(init: any): string | null {
|
|
158
|
-
if (!init || init.type !== 'CallExpression') {
|
|
159
|
-
return null;
|
|
160
|
-
}
|
|
161
|
-
if (!init.callee || init.callee.type !== 'Identifier' || init.callee.name !== 'inject') {
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
const arg: any = init.arguments && init.arguments[0];
|
|
165
|
-
if (!arg || arg.type !== 'Identifier') {
|
|
166
|
-
return null;
|
|
167
|
-
}
|
|
168
|
-
return arg.name;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Property kulcs név szöveggé alakítása.
|
|
173
|
-
*/
|
|
174
|
-
function getPropertyKeyName(node: any): string | null {
|
|
175
|
-
if (node.key && node.key.type === 'Identifier' && node.key.name) {
|
|
176
|
-
return node.key.name;
|
|
177
|
-
}
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Naming-patterns szabály (CCAP-megerősített): 7 al-ellenőrzés a CCAP "naming/*" review-kből.
|
|
183
|
-
* Minden al-ellenőrzés külön-külön kapcsolható a `checks` schema option-nel.
|
|
184
|
-
*/
|
|
185
|
-
const rule: Rule.RuleModule = {
|
|
186
|
-
meta: {
|
|
187
|
-
type: 'suggestion',
|
|
188
|
-
docs: {
|
|
189
|
-
description: 'Enforce Dynamo naming conventions (CCAP-derived sub-checks).',
|
|
190
|
-
recommended: true,
|
|
191
|
-
},
|
|
192
|
-
schema: [
|
|
193
|
-
{
|
|
194
|
-
type: 'object',
|
|
195
|
-
properties: {
|
|
196
|
-
checks: {
|
|
197
|
-
type: 'object',
|
|
198
|
-
properties: {
|
|
199
|
-
booleanIsPrefix: { type: 'boolean' },
|
|
200
|
-
signalPostfix: { type: 'boolean' },
|
|
201
|
-
rxjsPostfix: { type: 'boolean' },
|
|
202
|
-
fileClassPostfix: { type: 'boolean' },
|
|
203
|
-
enumValueFormat: { type: 'boolean' },
|
|
204
|
-
servicePropertyPostfix: { type: 'boolean' },
|
|
205
|
-
fileClassNameConsistency: { type: 'boolean' },
|
|
206
|
-
},
|
|
207
|
-
additionalProperties: false,
|
|
208
|
-
},
|
|
209
|
-
allowedPropertyNames: {
|
|
210
|
-
type: 'array',
|
|
211
|
-
items: { type: 'string' },
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
additionalProperties: false,
|
|
215
|
-
},
|
|
216
|
-
],
|
|
217
|
-
messages: {
|
|
218
|
-
booleanIsPrefix: 'Boolean property `{{name}}` nem `is`-sel kezdődik.',
|
|
219
|
-
signalPostfix: 'Signal változó `{{name}}` nem végződik `_$`-re.',
|
|
220
|
-
rxjsBsPostfix: '`BehaviorSubject` mező `{{name}}` nem végződik `_BS`-re.',
|
|
221
|
-
rxjsSPostfix: '`Subject` mező `{{name}}` nem végződik `_S`-re.',
|
|
222
|
-
rxjsObsPostfix: '`Observable` mező `{{name}}` nem végződik `$`-re.',
|
|
223
|
-
fileClassPostfix:
|
|
224
|
-
'Osztály `{{className}}` nem végződik `{{requiredPostfix}}`-re (fájlminta: {{fileName}}).',
|
|
225
|
-
enumKeyCamel: 'Enum kulcs `{{keyName}}` nem camelCase.',
|
|
226
|
-
enumValueKebab: 'Enum érték `{{value}}` nem kebab-case.',
|
|
227
|
-
servicePropertyPostfix:
|
|
228
|
-
'Property `{{property}}` `{{service}}`-t inject-el, de nem végződik `{{requiredPostfix}}`-re.',
|
|
229
|
-
fileClassNameConsistency:
|
|
230
|
-
'Osztály `{{className}}` entity része `{{classEntity}}` → '
|
|
231
|
-
+ 'elvárt fájlnév entity: `{{expected}}`, de a tényleges: `{{actual}}`.',
|
|
232
|
-
},
|
|
233
|
-
},
|
|
234
|
-
create(context: Rule.RuleContext): Rule.RuleListener {
|
|
235
|
-
const filename: string = context.filename ?? '';
|
|
236
|
-
const baseName: string = path.basename(filename);
|
|
237
|
-
if (baseName.endsWith('.spec.ts') || baseName.endsWith('.test.ts') || baseName.endsWith('.d.ts')) {
|
|
238
|
-
return {};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
const userOptions: { checks?: NamingChecksOptions; allowedPropertyNames?: string[] } =
|
|
242
|
-
(context.options[0] ?? {}) as { checks?: NamingChecksOptions; allowedPropertyNames?: string[] };
|
|
243
|
-
const checks: NamingChecksOptions = userOptions.checks ?? {};
|
|
244
|
-
const isOn = (key: keyof NamingChecksOptions): boolean => checks[key] !== false;
|
|
245
|
-
// BFR-ADVENTOR-018: beépített kanonikus kivételek + projekt-szintű bővítés
|
|
246
|
-
const allowedPropertyNames: string[] = [
|
|
247
|
-
...DEFAULT_ALLOWED_PROPERTY_NAMES,
|
|
248
|
-
...(userOptions.allowedPropertyNames ?? []),
|
|
249
|
-
];
|
|
250
|
-
|
|
251
|
-
const filePostfixRule: { pattern: RegExp; classPostfix: string; entitySuffix: string } | undefined =
|
|
252
|
-
FILE_POSTFIX_MAP.find(
|
|
253
|
-
(r: { pattern: RegExp; classPostfix: string; entitySuffix: string }): boolean =>
|
|
254
|
-
r.pattern.test(baseName),
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
return {
|
|
258
|
-
PropertyDefinition(node: any): void {
|
|
259
|
-
try {
|
|
260
|
-
const propName: string | null = getPropertyKeyName(node);
|
|
261
|
-
if (propName === null) {
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (
|
|
266
|
-
isOn('booleanIsPrefix')
|
|
267
|
-
&& isBooleanType(node.typeAnnotation)
|
|
268
|
-
&& !propName.startsWith('is')
|
|
269
|
-
&& !propName.endsWith('_$')
|
|
270
|
-
) {
|
|
271
|
-
context.report({
|
|
272
|
-
node: node.key,
|
|
273
|
-
messageId: 'booleanIsPrefix',
|
|
274
|
-
data: { name: propName },
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (
|
|
279
|
-
isOn('signalPostfix')
|
|
280
|
-
&& isSignalFactoryCall(node.value)
|
|
281
|
-
&& !propName.endsWith('_$')
|
|
282
|
-
) {
|
|
283
|
-
context.report({
|
|
284
|
-
node: node.key,
|
|
285
|
-
messageId: 'signalPostfix',
|
|
286
|
-
data: { name: propName },
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (isOn('rxjsPostfix')) {
|
|
291
|
-
const rxKind: 'BS' | 'S' | 'OBS' | null = detectRxjsKind(node.typeAnnotation, node.value);
|
|
292
|
-
if (rxKind === 'BS' && !propName.endsWith('_BS')) {
|
|
293
|
-
context.report({ node: node.key, messageId: 'rxjsBsPostfix', data: { name: propName } });
|
|
294
|
-
} else if (rxKind === 'S' && !propName.endsWith('_S') && !propName.endsWith('_BS')) {
|
|
295
|
-
context.report({ node: node.key, messageId: 'rxjsSPostfix', data: { name: propName } });
|
|
296
|
-
} else if (rxKind === 'OBS' && !propName.endsWith('$')) {
|
|
297
|
-
context.report({ node: node.key, messageId: 'rxjsObsPostfix', data: { name: propName } });
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
if (isOn('servicePropertyPostfix') && !allowedPropertyNames.includes(propName)) {
|
|
302
|
-
const injectedService: string | null = detectInjectedService(node.value);
|
|
303
|
-
if (injectedService !== null) {
|
|
304
|
-
for (const mapping of SERVICE_INJECT_POSTFIX_MAP) {
|
|
305
|
-
if (
|
|
306
|
-
injectedService.endsWith(mapping.classPostfix)
|
|
307
|
-
&& !propName.endsWith(mapping.propertyPostfix)
|
|
308
|
-
) {
|
|
309
|
-
context.report({
|
|
310
|
-
node: node.key,
|
|
311
|
-
messageId: 'servicePropertyPostfix',
|
|
312
|
-
data: {
|
|
313
|
-
property: propName,
|
|
314
|
-
service: injectedService,
|
|
315
|
-
requiredPostfix: mapping.propertyPostfix,
|
|
316
|
-
},
|
|
317
|
-
});
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
} catch (error) {
|
|
324
|
-
console.error('[naming-patterns] Error in PropertyDefinition visitor:', error);
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
|
|
328
|
-
ClassDeclaration(node: any): void {
|
|
329
|
-
try {
|
|
330
|
-
if (!node.id || !node.id.name || !filePostfixRule) {
|
|
331
|
-
return;
|
|
332
|
-
}
|
|
333
|
-
const className: string = node.id.name;
|
|
334
|
-
|
|
335
|
-
if (isOn('fileClassPostfix') && !className.endsWith(filePostfixRule.classPostfix)) {
|
|
336
|
-
context.report({
|
|
337
|
-
node: node.id,
|
|
338
|
-
messageId: 'fileClassPostfix',
|
|
339
|
-
data: {
|
|
340
|
-
className: className,
|
|
341
|
-
requiredPostfix: filePostfixRule.classPostfix,
|
|
342
|
-
fileName: baseName,
|
|
343
|
-
},
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (isOn('fileClassNameConsistency') && className.endsWith(filePostfixRule.classPostfix)) {
|
|
348
|
-
const fileEntity: string = baseName.slice(
|
|
349
|
-
0,
|
|
350
|
-
baseName.length - filePostfixRule.entitySuffix.length,
|
|
351
|
-
);
|
|
352
|
-
const classEntity: string = className.slice(
|
|
353
|
-
0,
|
|
354
|
-
className.length - filePostfixRule.classPostfix.length,
|
|
355
|
-
);
|
|
356
|
-
const expectedFull: string = classEntityToKebab(classEntity);
|
|
357
|
-
const firstUnderscoreIdx: number = classEntity.indexOf('_');
|
|
358
|
-
const expectedWithoutPrefix: string = firstUnderscoreIdx > 0
|
|
359
|
-
? classEntityToKebab(classEntity.slice(firstUnderscoreIdx + 1))
|
|
360
|
-
: '';
|
|
361
|
-
const isMatch: boolean = expectedFull === fileEntity || expectedWithoutPrefix === fileEntity;
|
|
362
|
-
if (!isMatch && classEntity.length > 0) {
|
|
363
|
-
context.report({
|
|
364
|
-
node: node.id,
|
|
365
|
-
messageId: 'fileClassNameConsistency',
|
|
366
|
-
data: {
|
|
367
|
-
className: className,
|
|
368
|
-
classEntity: classEntity,
|
|
369
|
-
expected: expectedFull + (expectedWithoutPrefix ? ` vagy ${expectedWithoutPrefix}` : ''),
|
|
370
|
-
actual: fileEntity,
|
|
371
|
-
},
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
} catch (error) {
|
|
376
|
-
console.error('[naming-patterns] Error in ClassDeclaration visitor:', error);
|
|
377
|
-
}
|
|
378
|
-
},
|
|
379
|
-
|
|
380
|
-
TSEnumDeclaration(node: any): void {
|
|
381
|
-
try {
|
|
382
|
-
if (!isOn('enumValueFormat')) {
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
if (!baseName.endsWith('.type-enum.ts')) {
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
const members: any[] = node.members ?? [];
|
|
389
|
-
for (const member of members) {
|
|
390
|
-
const keyName: string | null = (member.id && member.id.name) ? member.id.name : null;
|
|
391
|
-
const initializer: any = member.initializer;
|
|
392
|
-
if (keyName === null) {
|
|
393
|
-
continue;
|
|
394
|
-
}
|
|
395
|
-
if (!CAMEL_CASE_KEY_REGEX.test(keyName)) {
|
|
396
|
-
context.report({
|
|
397
|
-
node: member.id,
|
|
398
|
-
messageId: 'enumKeyCamel',
|
|
399
|
-
data: { keyName: keyName },
|
|
400
|
-
});
|
|
401
|
-
continue;
|
|
402
|
-
}
|
|
403
|
-
if (
|
|
404
|
-
initializer
|
|
405
|
-
&& initializer.type === 'Literal'
|
|
406
|
-
&& typeof initializer.value === 'string'
|
|
407
|
-
) {
|
|
408
|
-
const value: string = initializer.value;
|
|
409
|
-
if (!KEBAB_CASE_VALUE_REGEX.test(value)) {
|
|
410
|
-
context.report({
|
|
411
|
-
node: initializer,
|
|
412
|
-
messageId: 'enumValueKebab',
|
|
413
|
-
data: { value: value },
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
} catch (error) {
|
|
419
|
-
console.error('[naming-patterns] Error in TSEnumDeclaration visitor:', error);
|
|
420
|
-
}
|
|
421
|
-
},
|
|
422
|
-
};
|
|
423
|
-
},
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
export default rule;
|