@futdevpro/dynamo-eslint 1.15.25 → 1.20.2

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.
Files changed (146) hide show
  1. package/.c8rc.json +26 -26
  2. package/.cursor/rules/__assistant_guide.mdc +30 -30
  3. package/.cursor/rules/__main.mdc +64 -64
  4. package/.cursor/rules/_ag_backend-structure.mdc +85 -85
  5. package/.cursor/rules/_ag_backend.mdc +16 -16
  6. package/.cursor/rules/_ag_debug.mdc +7 -7
  7. package/.cursor/rules/_ag_documentation_writing_rules.mdc +372 -372
  8. package/.cursor/rules/_ag_file-refactoring.mdc +113 -113
  9. package/.cursor/rules/_ag_fixes_rules.mdc +5 -5
  10. package/.cursor/rules/_ag_frontend-structure.mdc +86 -86
  11. package/.cursor/rules/_ag_frontend.mdc +39 -39
  12. package/.cursor/rules/_ag_import-rules.mdc +44 -44
  13. package/.cursor/rules/_ag_naming.mdc +115 -115
  14. package/.cursor/rules/_ag_running_commands.mdc +4 -4
  15. package/.cursor/rules/_ag_server-controller.mdc +5 -5
  16. package/.cursor/rules/_ag_should-be.mdc +6 -6
  17. package/.cursor/rules/_ag_swearing.mdc +47 -47
  18. package/.cursor/rules/ai_development_guide.md +60 -60
  19. package/.cursor/rules/ai_directives.md +114 -114
  20. package/.cursor/rules/cursor-rules.md +160 -160
  21. package/.cursor/rules/default-command.mdc +464 -464
  22. package/.cursor/rules/error_code_pattern.md +39 -39
  23. package/.cursor/rules/saved rule mcp server use.md +15 -15
  24. package/.dynamo/pipeline.cicd.config.json +184 -184
  25. package/.dynamo/version-bump.config.json +5 -5
  26. package/.eslintrc.json +4 -4
  27. package/.github/workflows/main.yml +436 -436
  28. package/.husky/pre-commit +2 -2
  29. package/.vscode/settings.json +11 -11
  30. package/README.md +312 -315
  31. package/__documentations/2026-04-18-ccap-review-integration.md +173 -173
  32. package/__documentations/2026-08-18-bfr-ctm-005-eslint9-validator-report.md +45 -0
  33. package/__documentations/2026-08-22-angular-20-phase2-release.md +79 -0
  34. package/build/configs/base.d.ts +1 -2
  35. package/build/configs/base.d.ts.map +1 -1
  36. package/build/configs/base.js +3 -4
  37. package/build/configs/base.js.map +1 -1
  38. package/build/configs/ngx.d.ts +1 -3
  39. package/build/configs/ngx.d.ts.map +1 -1
  40. package/build/configs/ngx.js +4 -7
  41. package/build/configs/ngx.js.map +1 -1
  42. package/build/plugin/index.d.ts +24 -24
  43. package/build/plugin/rules/no-getter-logic.js +1 -1
  44. package/build/plugin/rules/no-getter-logic.js.map +1 -1
  45. package/build/plugin/rules/prefer-enum-over-string-union.js +7 -7
  46. package/build/plugin/rules/prefer-enum-over-string-union.js.map +1 -1
  47. package/build/plugin/rules/prefer-interface-over-duplicate-types.js +2 -2
  48. package/build/plugin/rules/prefer-interface-over-duplicate-types.js.map +1 -1
  49. package/build/plugin/rules/require-jsdoc-description.js +7 -7
  50. package/build/plugin/rules/require-jsdoc-description.js.map +1 -1
  51. package/build/scripts/dynamo-fix.js +1 -1
  52. package/build/scripts/dynamo-fix.js.map +1 -1
  53. package/build/scripts/fix-return-types.d.ts.map +1 -1
  54. package/build/scripts/fix-return-types.js.map +1 -1
  55. package/build/scripts/validate-imports.js +51 -27
  56. package/build/scripts/validate-imports.js.map +1 -1
  57. package/build/scripts/validate-naming.js +49 -10
  58. package/build/scripts/validate-naming.js.map +1 -1
  59. package/eslint.config.js +15 -15
  60. package/package.json +27 -28
  61. package/pnpm-workspace.yaml +2 -0
  62. package/samples/.vscode/settings.json +13 -13
  63. package/samples/base/.eslintrc.json +6 -6
  64. package/samples/base/eslint.config.js +3 -3
  65. package/samples/fsm/.eslintrc.json +4 -4
  66. package/samples/fsm/eslint.config.js +3 -3
  67. package/samples/ngx/.eslintrc.json +6 -6
  68. package/samples/ngx/eslint.config.js +3 -3
  69. package/samples/ngx-package/.eslintrc.json +4 -4
  70. package/samples/ngx-package/eslint.config.js +3 -3
  71. package/samples/nts/.eslintrc.json +6 -6
  72. package/samples/nts/eslint.config.js +3 -3
  73. package/samples/nts-package/.eslintrc.json +4 -4
  74. package/samples/nts-package/eslint.config.js +3 -3
  75. package/samples/package.json.example +22 -26
  76. package/samples/poc-sample.ts +38 -38
  77. package/samples/poc-violations.ts +54 -54
  78. package/scripts/run-coverage-tests.js +24 -24
  79. package/spec/support/helpers/ts-node-helper.js +9 -9
  80. package/spec/support/jasmine.coverage.json +23 -23
  81. package/spec/support/jasmine.json +24 -24
  82. package/src/configs/angular20-compatibility.spec.ts +62 -0
  83. package/src/configs/base.ts +156 -157
  84. package/src/configs/fsm.ts +10 -10
  85. package/src/configs/ngx-package.ts +10 -10
  86. package/src/configs/ngx.ts +92 -95
  87. package/src/configs/nts-package.ts +20 -20
  88. package/src/configs/nts.ts +34 -34
  89. package/src/index.ts +4 -4
  90. package/src/plugin/index.ts +86 -86
  91. package/src/plugin/rules/angular/angular-for-track-logic.spec.ts +44 -44
  92. package/src/plugin/rules/angular/angular-for-track-logic.ts +88 -88
  93. package/src/plugin/rules/angular/effect-signal-loop.spec.ts +89 -89
  94. package/src/plugin/rules/angular/effect-signal-loop.ts +125 -125
  95. package/src/plugin/rules/angular/no-async-ngoninit.spec.ts +50 -50
  96. package/src/plugin/rules/angular/no-async-ngoninit.ts +43 -43
  97. package/src/plugin/rules/angular/no-component-direct-api.spec.ts +78 -78
  98. package/src/plugin/rules/angular/no-component-direct-api.ts +82 -82
  99. package/src/plugin/rules/angular/no-method-call-in-template.spec.ts +63 -63
  100. package/src/plugin/rules/angular/no-method-call-in-template.ts +89 -89
  101. package/src/plugin/rules/angular/no-ngfor-directive.spec.ts +44 -44
  102. package/src/plugin/rules/angular/no-ngfor-directive.ts +62 -62
  103. package/src/plugin/rules/angular/no-ngif-directive.spec.ts +44 -44
  104. package/src/plugin/rules/angular/no-ngif-directive.ts +62 -62
  105. package/src/plugin/rules/explicit-types.spec.ts +190 -190
  106. package/src/plugin/rules/explicit-types.ts +186 -186
  107. package/src/plugin/rules/import/import-order.spec.ts +219 -219
  108. package/src/plugin/rules/import/import-order.ts +197 -197
  109. package/src/plugin/rules/import/no-import-type.spec.ts +69 -69
  110. package/src/plugin/rules/import/no-import-type.ts +46 -46
  111. package/src/plugin/rules/import/no-js-import.spec.ts +82 -82
  112. package/src/plugin/rules/import/no-js-import.ts +45 -45
  113. package/src/plugin/rules/naming-patterns.spec.ts +189 -189
  114. package/src/plugin/rules/naming-patterns.ts +426 -426
  115. package/src/plugin/rules/no-getter-logic.spec.ts +591 -591
  116. package/src/plugin/rules/no-getter-logic.ts +220 -220
  117. package/src/plugin/rules/prefer-enum-over-string-union.spec.ts +583 -583
  118. package/src/plugin/rules/prefer-enum-over-string-union.ts +333 -334
  119. package/src/plugin/rules/prefer-interface-over-duplicate-types.spec.ts +404 -404
  120. package/src/plugin/rules/prefer-interface-over-duplicate-types.ts +314 -314
  121. package/src/plugin/rules/require-jsdoc-description.spec.ts +779 -779
  122. package/src/plugin/rules/require-jsdoc-description.ts +572 -572
  123. package/src/plugin/rules/require-test-description-prefix.spec.ts +459 -459
  124. package/src/plugin/rules/require-test-description-prefix.ts +154 -154
  125. package/src/plugin/rules/ts/data-model-extends.spec.ts +84 -84
  126. package/src/plugin/rules/ts/data-model-extends.ts +100 -100
  127. package/src/plugin/rules/ts/no-any-type.spec.ts +28 -28
  128. package/src/plugin/rules/ts/no-any-type.ts +36 -36
  129. package/src/plugin/rules/ts/no-as-cast.spec.ts +51 -51
  130. package/src/plugin/rules/ts/no-as-cast.ts +51 -51
  131. package/src/plugin/rules/ts/no-dynamic-imports.spec.ts +54 -54
  132. package/src/plugin/rules/ts/no-dynamic-imports.ts +49 -49
  133. package/src/plugin/rules/ts/no-native-browser-dialogs.spec.ts +54 -54
  134. package/src/plugin/rules/ts/no-native-browser-dialogs.ts +84 -84
  135. package/src/plugin/rules/ts/no-plain-function-export.spec.ts +72 -72
  136. package/src/plugin/rules/ts/no-plain-function-export.ts +73 -73
  137. package/src/plugin/rules/ts/one-export-per-file.spec.ts +64 -64
  138. package/src/plugin/rules/ts/one-export-per-file.ts +77 -77
  139. package/src/scripts/dynamo-fix.ts +172 -172
  140. package/src/scripts/eslintrc-audit.ts +116 -116
  141. package/src/scripts/fix-return-types.spec.ts +65 -65
  142. package/src/scripts/fix-return-types.ts +286 -285
  143. package/src/scripts/validate-imports.ts +288 -257
  144. package/src/scripts/validate-naming.ts +209 -183
  145. package/src/scripts/validator-cli.integration.spec.ts +99 -0
  146. package/tsconfig.json +31 -31
@@ -1,426 +1,426 @@
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;
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;