@futdevpro/dynamo-eslint 1.15.22 → 1.15.28

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