@futdevpro/dynamo-eslint 1.15.25 → 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 (194) 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.js +366 -366
  73. package/build/plugin/rules/no-getter-logic.d.ts +3 -3
  74. package/build/plugin/rules/no-getter-logic.js +194 -194
  75. package/build/plugin/rules/prefer-enum-over-string-union.d.ts +3 -3
  76. package/build/plugin/rules/prefer-enum-over-string-union.js +289 -289
  77. package/build/plugin/rules/prefer-interface-over-duplicate-types.d.ts +3 -3
  78. package/build/plugin/rules/prefer-interface-over-duplicate-types.js +264 -264
  79. package/build/plugin/rules/require-jsdoc-description.d.ts +3 -3
  80. package/build/plugin/rules/require-jsdoc-description.js +496 -496
  81. package/build/plugin/rules/require-test-description-prefix.d.ts +3 -3
  82. package/build/plugin/rules/require-test-description-prefix.js +135 -135
  83. package/build/plugin/rules/ts/data-model-extends.d.ts +8 -8
  84. package/build/plugin/rules/ts/data-model-extends.js +94 -94
  85. package/build/plugin/rules/ts/no-any-type.d.ts +8 -8
  86. package/build/plugin/rules/ts/no-any-type.js +36 -36
  87. package/build/plugin/rules/ts/no-as-cast.d.ts +8 -8
  88. package/build/plugin/rules/ts/no-as-cast.js +49 -49
  89. package/build/plugin/rules/ts/no-dynamic-imports.d.ts +8 -8
  90. package/build/plugin/rules/ts/no-dynamic-imports.js +50 -50
  91. package/build/plugin/rules/ts/no-native-browser-dialogs.d.ts +8 -8
  92. package/build/plugin/rules/ts/no-native-browser-dialogs.js +78 -78
  93. package/build/plugin/rules/ts/no-plain-function-export.d.ts +9 -9
  94. package/build/plugin/rules/ts/no-plain-function-export.js +69 -69
  95. package/build/plugin/rules/ts/one-export-per-file.d.ts +8 -8
  96. package/build/plugin/rules/ts/one-export-per-file.js +73 -73
  97. package/build/scripts/dynamo-fix.d.ts +26 -26
  98. package/build/scripts/dynamo-fix.js +146 -146
  99. package/build/scripts/eslintrc-audit.d.ts +26 -26
  100. package/build/scripts/eslintrc-audit.js +100 -100
  101. package/build/scripts/fix-return-types.d.ts +74 -74
  102. package/build/scripts/fix-return-types.js +226 -226
  103. package/build/scripts/validate-imports.d.ts +26 -26
  104. package/build/scripts/validate-imports.js +157 -146
  105. package/build/scripts/validate-imports.js.map +1 -1
  106. package/build/scripts/validate-naming.d.ts +26 -26
  107. package/build/scripts/validate-naming.js +157 -131
  108. package/build/scripts/validate-naming.js.map +1 -1
  109. package/eslint.config.js +15 -15
  110. package/package.json +105 -105
  111. package/samples/.vscode/settings.json +13 -13
  112. package/samples/base/.eslintrc.json +6 -6
  113. package/samples/base/eslint.config.js +3 -3
  114. package/samples/fsm/.eslintrc.json +4 -4
  115. package/samples/fsm/eslint.config.js +3 -3
  116. package/samples/ngx/.eslintrc.json +6 -6
  117. package/samples/ngx/eslint.config.js +3 -3
  118. package/samples/ngx-package/.eslintrc.json +4 -4
  119. package/samples/ngx-package/eslint.config.js +3 -3
  120. package/samples/nts/.eslintrc.json +6 -6
  121. package/samples/nts/eslint.config.js +3 -3
  122. package/samples/nts-package/.eslintrc.json +4 -4
  123. package/samples/nts-package/eslint.config.js +3 -3
  124. package/samples/package.json.example +26 -26
  125. package/samples/poc-sample.ts +38 -38
  126. package/samples/poc-violations.ts +54 -54
  127. package/scripts/run-coverage-tests.js +24 -24
  128. package/spec/support/helpers/ts-node-helper.js +9 -9
  129. package/spec/support/jasmine.coverage.json +23 -23
  130. package/spec/support/jasmine.json +24 -24
  131. package/src/configs/base.ts +157 -157
  132. package/src/configs/fsm.ts +10 -10
  133. package/src/configs/ngx-package.ts +10 -10
  134. package/src/configs/ngx.ts +96 -96
  135. package/src/configs/nts-package.ts +20 -20
  136. package/src/configs/nts.ts +34 -34
  137. package/src/index.ts +4 -4
  138. package/src/plugin/index.ts +86 -86
  139. package/src/plugin/rules/angular/angular-for-track-logic.spec.ts +44 -44
  140. package/src/plugin/rules/angular/angular-for-track-logic.ts +88 -88
  141. package/src/plugin/rules/angular/effect-signal-loop.spec.ts +89 -89
  142. package/src/plugin/rules/angular/effect-signal-loop.ts +125 -125
  143. package/src/plugin/rules/angular/no-async-ngoninit.spec.ts +50 -50
  144. package/src/plugin/rules/angular/no-async-ngoninit.ts +43 -43
  145. package/src/plugin/rules/angular/no-component-direct-api.spec.ts +78 -78
  146. package/src/plugin/rules/angular/no-component-direct-api.ts +82 -82
  147. package/src/plugin/rules/angular/no-method-call-in-template.spec.ts +63 -63
  148. package/src/plugin/rules/angular/no-method-call-in-template.ts +89 -89
  149. package/src/plugin/rules/angular/no-ngfor-directive.spec.ts +44 -44
  150. package/src/plugin/rules/angular/no-ngfor-directive.ts +62 -62
  151. package/src/plugin/rules/angular/no-ngif-directive.spec.ts +44 -44
  152. package/src/plugin/rules/angular/no-ngif-directive.ts +62 -62
  153. package/src/plugin/rules/explicit-types.spec.ts +190 -190
  154. package/src/plugin/rules/explicit-types.ts +186 -186
  155. package/src/plugin/rules/import/import-order.spec.ts +219 -219
  156. package/src/plugin/rules/import/import-order.ts +197 -197
  157. package/src/plugin/rules/import/no-import-type.spec.ts +69 -69
  158. package/src/plugin/rules/import/no-import-type.ts +46 -46
  159. package/src/plugin/rules/import/no-js-import.spec.ts +82 -82
  160. package/src/plugin/rules/import/no-js-import.ts +45 -45
  161. package/src/plugin/rules/naming-patterns.spec.ts +189 -189
  162. package/src/plugin/rules/naming-patterns.ts +426 -426
  163. package/src/plugin/rules/no-getter-logic.spec.ts +591 -591
  164. package/src/plugin/rules/no-getter-logic.ts +220 -220
  165. package/src/plugin/rules/prefer-enum-over-string-union.spec.ts +583 -583
  166. package/src/plugin/rules/prefer-enum-over-string-union.ts +333 -333
  167. package/src/plugin/rules/prefer-interface-over-duplicate-types.spec.ts +404 -404
  168. package/src/plugin/rules/prefer-interface-over-duplicate-types.ts +314 -314
  169. package/src/plugin/rules/require-jsdoc-description.spec.ts +779 -779
  170. package/src/plugin/rules/require-jsdoc-description.ts +572 -572
  171. package/src/plugin/rules/require-test-description-prefix.spec.ts +459 -459
  172. package/src/plugin/rules/require-test-description-prefix.ts +154 -154
  173. package/src/plugin/rules/ts/data-model-extends.spec.ts +84 -84
  174. package/src/plugin/rules/ts/data-model-extends.ts +100 -100
  175. package/src/plugin/rules/ts/no-any-type.spec.ts +28 -28
  176. package/src/plugin/rules/ts/no-any-type.ts +36 -36
  177. package/src/plugin/rules/ts/no-as-cast.spec.ts +51 -51
  178. package/src/plugin/rules/ts/no-as-cast.ts +51 -51
  179. package/src/plugin/rules/ts/no-dynamic-imports.spec.ts +54 -54
  180. package/src/plugin/rules/ts/no-dynamic-imports.ts +49 -49
  181. package/src/plugin/rules/ts/no-native-browser-dialogs.spec.ts +54 -54
  182. package/src/plugin/rules/ts/no-native-browser-dialogs.ts +84 -84
  183. package/src/plugin/rules/ts/no-plain-function-export.spec.ts +72 -72
  184. package/src/plugin/rules/ts/no-plain-function-export.ts +73 -73
  185. package/src/plugin/rules/ts/one-export-per-file.spec.ts +64 -64
  186. package/src/plugin/rules/ts/one-export-per-file.ts +77 -77
  187. package/src/scripts/dynamo-fix.ts +172 -172
  188. package/src/scripts/eslintrc-audit.ts +116 -116
  189. package/src/scripts/fix-return-types.spec.ts +65 -65
  190. package/src/scripts/fix-return-types.ts +288 -288
  191. package/src/scripts/validate-imports.ts +278 -261
  192. package/src/scripts/validate-naming.ts +204 -187
  193. package/src/scripts/validator-cli.integration.spec.ts +96 -0
  194. package/tsconfig.json +31 -31
@@ -1,591 +1,591 @@
1
- import noGetterLogicRule from './no-getter-logic';
2
-
3
- describe('| no-getter-logic', () => {
4
- it('| should be a valid ESLint rule', () => {
5
- expect(noGetterLogicRule.meta?.type).toBe('suggestion');
6
- expect(noGetterLogicRule.meta?.docs?.description).toContain('Getters should only contain simple property mappings');
7
- });
8
-
9
- it('| should have create function that returns visitor object', () => {
10
- const mockContext = {
11
- report: () => {},
12
- options: [],
13
- sourceCode: {
14
- getText: () => '',
15
- },
16
- } as any;
17
-
18
- const result = noGetterLogicRule.create(mockContext);
19
-
20
- expect(typeof result).toBe('object');
21
- expect(typeof result.MethodDefinition).toBe('function');
22
- });
23
-
24
- it('| should not report for simple property access getter', () => {
25
- let reportCalled = false;
26
- const mockContext = {
27
- report: () => {
28
- reportCalled = true;
29
- },
30
- options: [],
31
- sourceCode: {
32
- getText: () => '',
33
- },
34
- } as any;
35
-
36
- const rule = noGetterLogicRule.create(mockContext);
37
-
38
- const mockNode = {
39
- kind: 'get',
40
- key: { name: 'selectedTokenPackage' },
41
- value: {
42
- body: {
43
- type: 'BlockStatement',
44
- body: [
45
- {
46
- type: 'ReturnStatement',
47
- argument: {
48
- type: 'MemberExpression',
49
- object: {
50
- type: 'MemberExpression',
51
- object: { type: 'ThisExpression' },
52
- property: { type: 'Identifier', name: 'tokenPackages_CS' },
53
- },
54
- property: {
55
- type: 'MemberExpression',
56
- object: { type: 'Identifier', name: 'tokenPackageByType' },
57
- property: {
58
- type: 'MemberExpression',
59
- object: { type: 'ThisExpression' },
60
- property: { type: 'Identifier', name: 'selectedPackageType' },
61
- },
62
- computed: true,
63
- },
64
- computed: true,
65
- },
66
- },
67
- ],
68
- },
69
- },
70
- } as any;
71
-
72
- rule.MethodDefinition(mockNode);
73
-
74
- expect(reportCalled).toBe(false);
75
- });
76
-
77
- it('| should not report for simple length property access', () => {
78
- let reportCalled = false;
79
- const mockContext = {
80
- report: () => {
81
- reportCalled = true;
82
- },
83
- options: [],
84
- sourceCode: {
85
- getText: () => '',
86
- },
87
- } as any;
88
-
89
- const rule = noGetterLogicRule.create(mockContext);
90
-
91
- const mockNode = {
92
- kind: 'get',
93
- key: { name: 'runningProgressCount' },
94
- value: {
95
- body: {
96
- type: 'BlockStatement',
97
- body: [
98
- {
99
- type: 'ReturnStatement',
100
- argument: {
101
- type: 'MemberExpression',
102
- object: {
103
- type: 'MemberExpression',
104
- object: { type: 'ThisExpression' },
105
- property: { type: 'Identifier', name: '_runningProgresses' },
106
- },
107
- property: { type: 'Identifier', name: 'length' },
108
- },
109
- },
110
- ],
111
- },
112
- },
113
- } as any;
114
-
115
- rule.MethodDefinition(mockNode);
116
-
117
- expect(reportCalled).toBe(false);
118
- });
119
-
120
- it('| should not report for simple signal property access', () => {
121
- let reportCalled = false;
122
- const mockContext = {
123
- report: () => {
124
- reportCalled = true;
125
- },
126
- options: [],
127
- sourceCode: {
128
- getText: () => '',
129
- },
130
- } as any;
131
-
132
- const rule = noGetterLogicRule.create(mockContext);
133
-
134
- const mockNode = {
135
- kind: 'get',
136
- key: { name: 'myChannels_$' },
137
- value: {
138
- body: {
139
- type: 'BlockStatement',
140
- body: [
141
- {
142
- type: 'ReturnStatement',
143
- argument: {
144
- type: 'MemberExpression',
145
- object: {
146
- type: 'MemberExpression',
147
- object: { type: 'ThisExpression' },
148
- property: { type: 'Identifier', name: 'myChannels_DH' },
149
- },
150
- property: { type: 'Identifier', name: 'dataList_$' },
151
- },
152
- },
153
- ],
154
- },
155
- },
156
- } as any;
157
-
158
- rule.MethodDefinition(mockNode);
159
-
160
- expect(reportCalled).toBe(false);
161
- });
162
-
163
- it('| should report for binary expression (multiplication)', () => {
164
- let reportCalled = false;
165
- const mockContext = {
166
- report: (options: any) => {
167
- reportCalled = true;
168
- expect(options.messageId).toBe('noLogic');
169
- expect(options.data.name).toBe('shownHUNVat');
170
- },
171
- options: [],
172
- sourceCode: {
173
- getText: () => '',
174
- },
175
- } as any;
176
-
177
- const rule = noGetterLogicRule.create(mockContext);
178
-
179
- const mockNode = {
180
- kind: 'get',
181
- key: { name: 'shownHUNVat' },
182
- value: {
183
- body: {
184
- type: 'BlockStatement',
185
- body: [
186
- {
187
- type: 'ReturnStatement',
188
- argument: {
189
- type: 'BinaryExpression',
190
- operator: '*',
191
- left: { type: 'Identifier', name: 'HU_vat' },
192
- right: { type: 'Literal', value: 100 },
193
- },
194
- },
195
- ],
196
- },
197
- },
198
- } as any;
199
-
200
- rule.MethodDefinition(mockNode);
201
-
202
- expect(reportCalled).toBe(true);
203
- });
204
-
205
- it('| should report for function call', () => {
206
- let reportCalled = false;
207
- const mockContext = {
208
- report: (options: any) => {
209
- reportCalled = true;
210
- expect(options.messageId).toBe('noLogic');
211
- expect(options.data.name).toBe('selectedPackageType');
212
- },
213
- options: [],
214
- sourceCode: {
215
- getText: () => '',
216
- },
217
- } as any;
218
-
219
- const rule = noGetterLogicRule.create(mockContext);
220
-
221
- const mockNode = {
222
- kind: 'get',
223
- key: { name: 'selectedPackageType' },
224
- value: {
225
- body: {
226
- type: 'BlockStatement',
227
- body: [
228
- {
229
- type: 'ReturnStatement',
230
- argument: {
231
- type: 'MemberExpression',
232
- object: {
233
- type: 'CallExpression',
234
- callee: {
235
- type: 'MemberExpression',
236
- object: { type: 'ThisExpression' },
237
- property: { type: 'Identifier', name: 'completedPurchaseData$' },
238
- },
239
- arguments: [],
240
- },
241
- property: { type: 'Identifier', name: 'selectedPackageType' },
242
- },
243
- },
244
- ],
245
- },
246
- },
247
- } as any;
248
-
249
- rule.MethodDefinition(mockNode);
250
-
251
- expect(reportCalled).toBe(true);
252
- });
253
-
254
- it('| should report for unary expression', () => {
255
- let reportCalled = false;
256
- const mockContext = {
257
- report: (options: any) => {
258
- reportCalled = true;
259
- expect(options.messageId).toBe('noLogic');
260
- },
261
- options: [],
262
- sourceCode: {
263
- getText: () => '',
264
- },
265
- } as any;
266
-
267
- const rule = noGetterLogicRule.create(mockContext);
268
-
269
- const mockNode = {
270
- kind: 'get',
271
- key: { name: 'negatedValue' },
272
- value: {
273
- body: {
274
- type: 'BlockStatement',
275
- body: [
276
- {
277
- type: 'ReturnStatement',
278
- argument: {
279
- type: 'UnaryExpression',
280
- operator: '!',
281
- argument: { type: 'Identifier', name: 'someValue' },
282
- },
283
- },
284
- ],
285
- },
286
- },
287
- } as any;
288
-
289
- rule.MethodDefinition(mockNode);
290
-
291
- expect(reportCalled).toBe(true);
292
- });
293
-
294
- it('| should report for conditional expression (ternary)', () => {
295
- let reportCalled = false;
296
- const mockContext = {
297
- report: (options: any) => {
298
- reportCalled = true;
299
- expect(options.messageId).toBe('noLogic');
300
- },
301
- options: [],
302
- sourceCode: {
303
- getText: () => '',
304
- },
305
- } as any;
306
-
307
- const rule = noGetterLogicRule.create(mockContext);
308
-
309
- const mockNode = {
310
- kind: 'get',
311
- key: { name: 'conditionalValue' },
312
- value: {
313
- body: {
314
- type: 'BlockStatement',
315
- body: [
316
- {
317
- type: 'ReturnStatement',
318
- argument: {
319
- type: 'ConditionalExpression',
320
- test: { type: 'Identifier', name: 'condition' },
321
- consequent: { type: 'Literal', value: 'true' },
322
- alternate: { type: 'Literal', value: 'false' },
323
- },
324
- },
325
- ],
326
- },
327
- },
328
- } as any;
329
-
330
- rule.MethodDefinition(mockNode);
331
-
332
- expect(reportCalled).toBe(true);
333
- });
334
-
335
- it('| should report for logical expression', () => {
336
- let reportCalled = false;
337
- const mockContext = {
338
- report: (options: any) => {
339
- reportCalled = true;
340
- expect(options.messageId).toBe('noLogic');
341
- },
342
- options: [],
343
- sourceCode: {
344
- getText: () => '',
345
- },
346
- } as any;
347
-
348
- const rule = noGetterLogicRule.create(mockContext);
349
-
350
- const mockNode = {
351
- kind: 'get',
352
- key: { name: 'logicalValue' },
353
- value: {
354
- body: {
355
- type: 'BlockStatement',
356
- body: [
357
- {
358
- type: 'ReturnStatement',
359
- argument: {
360
- type: 'LogicalExpression',
361
- operator: '&&',
362
- left: { type: 'Identifier', name: 'value1' },
363
- right: { type: 'Identifier', name: 'value2' },
364
- },
365
- },
366
- ],
367
- },
368
- },
369
- } as any;
370
-
371
- rule.MethodDefinition(mockNode);
372
-
373
- expect(reportCalled).toBe(true);
374
- });
375
-
376
- it('| should not report for non-getter methods', () => {
377
- let reportCalled = false;
378
- const mockContext = {
379
- report: () => {
380
- reportCalled = true;
381
- },
382
- options: [],
383
- sourceCode: {
384
- getText: () => '',
385
- },
386
- } as any;
387
-
388
- const rule = noGetterLogicRule.create(mockContext);
389
-
390
- const mockNode = {
391
- kind: 'method',
392
- key: { name: 'someMethod' },
393
- value: {
394
- body: {
395
- type: 'BlockStatement',
396
- body: [
397
- {
398
- type: 'ReturnStatement',
399
- argument: {
400
- type: 'CallExpression',
401
- callee: { type: 'Identifier', name: 'someFunction' },
402
- arguments: [],
403
- },
404
- },
405
- ],
406
- },
407
- },
408
- } as any;
409
-
410
- rule.MethodDefinition(mockNode);
411
-
412
- expect(reportCalled).toBe(false);
413
- });
414
-
415
- it('| should not report for setter methods', () => {
416
- let reportCalled = false;
417
- const mockContext = {
418
- report: () => {
419
- reportCalled = true;
420
- },
421
- options: [],
422
- sourceCode: {
423
- getText: () => '',
424
- },
425
- } as any;
426
-
427
- const rule = noGetterLogicRule.create(mockContext);
428
-
429
- const mockNode = {
430
- kind: 'set',
431
- key: { name: 'someSetter' },
432
- value: {
433
- body: {
434
- type: 'BlockStatement',
435
- body: [
436
- {
437
- type: 'ExpressionStatement',
438
- expression: {
439
- type: 'AssignmentExpression',
440
- operator: '=',
441
- left: { type: 'Identifier', name: 'this.value' },
442
- right: { type: 'Identifier', name: 'value' },
443
- },
444
- },
445
- ],
446
- },
447
- },
448
- } as any;
449
-
450
- rule.MethodDefinition(mockNode);
451
-
452
- expect(reportCalled).toBe(false);
453
- });
454
-
455
- it('| should handle getter without body gracefully', () => {
456
- let reportCalled = false;
457
- const mockContext = {
458
- report: () => {
459
- reportCalled = true;
460
- },
461
- options: [],
462
- sourceCode: {
463
- getText: () => '',
464
- },
465
- } as any;
466
-
467
- const rule = noGetterLogicRule.create(mockContext);
468
-
469
- const mockNode = {
470
- kind: 'get',
471
- key: { name: 'emptyGetter' },
472
- value: {},
473
- } as any;
474
-
475
- expect(() => {
476
- rule.MethodDefinition(mockNode);
477
- }).not.toThrow();
478
-
479
- expect(reportCalled).toBe(false);
480
- });
481
-
482
- it('| should report multi-statement getter body (CCAP-megerősítés)', () => {
483
- let reportCalled: boolean = false;
484
- const mockContext = {
485
- report: (options: any) => {
486
- reportCalled = true;
487
- expect(options.messageId).toBe('noLogic');
488
- },
489
- options: [],
490
- sourceCode: { getText: () => '' },
491
- } as any;
492
-
493
- const rule = noGetterLogicRule.create(mockContext);
494
-
495
- const mockNode = {
496
- kind: 'get',
497
- key: { name: 'multiStatementGetter' },
498
- value: {
499
- body: {
500
- type: 'BlockStatement',
501
- body: [
502
- {
503
- type: 'VariableDeclaration',
504
- declarations: [{ id: { name: 'tmp' }, init: { type: 'Identifier', name: 'foo' }}],
505
- },
506
- {
507
- type: 'ReturnStatement',
508
- argument: { type: 'Identifier', name: 'tmp' },
509
- },
510
- ],
511
- },
512
- },
513
- } as any;
514
-
515
- rule.MethodDefinition(mockNode);
516
-
517
- expect(reportCalled).toBe(true);
518
- });
519
-
520
- it('| should report `if`-statement inside getter (CCAP-megerősítés)', () => {
521
- let reportCalled: boolean = false;
522
- const mockContext = {
523
- report: () => { reportCalled = true; },
524
- options: [],
525
- sourceCode: { getText: () => '' },
526
- } as any;
527
-
528
- const rule = noGetterLogicRule.create(mockContext);
529
-
530
- const mockNode = {
531
- kind: 'get',
532
- key: { name: 'gateGetter' },
533
- value: {
534
- body: {
535
- type: 'BlockStatement',
536
- body: [
537
- {
538
- type: 'IfStatement',
539
- test: { type: 'Identifier', name: 'cond' },
540
- consequent: { type: 'ReturnStatement', argument: { type: 'Literal', value: 1 }},
541
- alternate: { type: 'ReturnStatement', argument: { type: 'Literal', value: 0 }},
542
- },
543
- ],
544
- },
545
- },
546
- } as any;
547
-
548
- rule.MethodDefinition(mockNode);
549
-
550
- expect(reportCalled).toBe(true);
551
- });
552
-
553
- it('| should handle errors gracefully', () => {
554
- const mockContext = {
555
- report: () => {},
556
- options: [],
557
- sourceCode: {
558
- getText: () => {
559
- throw new Error('Test error');
560
- },
561
- },
562
- } as any;
563
-
564
- const rule = noGetterLogicRule.create(mockContext);
565
-
566
- const mockNode = {
567
- kind: 'get',
568
- key: { name: 'testGetter' },
569
- value: {
570
- body: {
571
- type: 'BlockStatement',
572
- body: [
573
- {
574
- type: 'ReturnStatement',
575
- argument: {
576
- type: 'CallExpression',
577
- callee: { type: 'Identifier', name: 'test' },
578
- arguments: [],
579
- },
580
- },
581
- ],
582
- },
583
- },
584
- } as any;
585
-
586
- // Should not throw error
587
- expect(() => {
588
- rule.MethodDefinition(mockNode);
589
- }).not.toThrow();
590
- });
591
- });
1
+ import noGetterLogicRule from './no-getter-logic';
2
+
3
+ describe('| no-getter-logic', () => {
4
+ it('| should be a valid ESLint rule', () => {
5
+ expect(noGetterLogicRule.meta?.type).toBe('suggestion');
6
+ expect(noGetterLogicRule.meta?.docs?.description).toContain('Getters should only contain simple property mappings');
7
+ });
8
+
9
+ it('| should have create function that returns visitor object', () => {
10
+ const mockContext = {
11
+ report: () => {},
12
+ options: [],
13
+ sourceCode: {
14
+ getText: () => '',
15
+ },
16
+ } as any;
17
+
18
+ const result = noGetterLogicRule.create(mockContext);
19
+
20
+ expect(typeof result).toBe('object');
21
+ expect(typeof result.MethodDefinition).toBe('function');
22
+ });
23
+
24
+ it('| should not report for simple property access getter', () => {
25
+ let reportCalled = false;
26
+ const mockContext = {
27
+ report: () => {
28
+ reportCalled = true;
29
+ },
30
+ options: [],
31
+ sourceCode: {
32
+ getText: () => '',
33
+ },
34
+ } as any;
35
+
36
+ const rule = noGetterLogicRule.create(mockContext);
37
+
38
+ const mockNode = {
39
+ kind: 'get',
40
+ key: { name: 'selectedTokenPackage' },
41
+ value: {
42
+ body: {
43
+ type: 'BlockStatement',
44
+ body: [
45
+ {
46
+ type: 'ReturnStatement',
47
+ argument: {
48
+ type: 'MemberExpression',
49
+ object: {
50
+ type: 'MemberExpression',
51
+ object: { type: 'ThisExpression' },
52
+ property: { type: 'Identifier', name: 'tokenPackages_CS' },
53
+ },
54
+ property: {
55
+ type: 'MemberExpression',
56
+ object: { type: 'Identifier', name: 'tokenPackageByType' },
57
+ property: {
58
+ type: 'MemberExpression',
59
+ object: { type: 'ThisExpression' },
60
+ property: { type: 'Identifier', name: 'selectedPackageType' },
61
+ },
62
+ computed: true,
63
+ },
64
+ computed: true,
65
+ },
66
+ },
67
+ ],
68
+ },
69
+ },
70
+ } as any;
71
+
72
+ rule.MethodDefinition(mockNode);
73
+
74
+ expect(reportCalled).toBe(false);
75
+ });
76
+
77
+ it('| should not report for simple length property access', () => {
78
+ let reportCalled = false;
79
+ const mockContext = {
80
+ report: () => {
81
+ reportCalled = true;
82
+ },
83
+ options: [],
84
+ sourceCode: {
85
+ getText: () => '',
86
+ },
87
+ } as any;
88
+
89
+ const rule = noGetterLogicRule.create(mockContext);
90
+
91
+ const mockNode = {
92
+ kind: 'get',
93
+ key: { name: 'runningProgressCount' },
94
+ value: {
95
+ body: {
96
+ type: 'BlockStatement',
97
+ body: [
98
+ {
99
+ type: 'ReturnStatement',
100
+ argument: {
101
+ type: 'MemberExpression',
102
+ object: {
103
+ type: 'MemberExpression',
104
+ object: { type: 'ThisExpression' },
105
+ property: { type: 'Identifier', name: '_runningProgresses' },
106
+ },
107
+ property: { type: 'Identifier', name: 'length' },
108
+ },
109
+ },
110
+ ],
111
+ },
112
+ },
113
+ } as any;
114
+
115
+ rule.MethodDefinition(mockNode);
116
+
117
+ expect(reportCalled).toBe(false);
118
+ });
119
+
120
+ it('| should not report for simple signal property access', () => {
121
+ let reportCalled = false;
122
+ const mockContext = {
123
+ report: () => {
124
+ reportCalled = true;
125
+ },
126
+ options: [],
127
+ sourceCode: {
128
+ getText: () => '',
129
+ },
130
+ } as any;
131
+
132
+ const rule = noGetterLogicRule.create(mockContext);
133
+
134
+ const mockNode = {
135
+ kind: 'get',
136
+ key: { name: 'myChannels_$' },
137
+ value: {
138
+ body: {
139
+ type: 'BlockStatement',
140
+ body: [
141
+ {
142
+ type: 'ReturnStatement',
143
+ argument: {
144
+ type: 'MemberExpression',
145
+ object: {
146
+ type: 'MemberExpression',
147
+ object: { type: 'ThisExpression' },
148
+ property: { type: 'Identifier', name: 'myChannels_DH' },
149
+ },
150
+ property: { type: 'Identifier', name: 'dataList_$' },
151
+ },
152
+ },
153
+ ],
154
+ },
155
+ },
156
+ } as any;
157
+
158
+ rule.MethodDefinition(mockNode);
159
+
160
+ expect(reportCalled).toBe(false);
161
+ });
162
+
163
+ it('| should report for binary expression (multiplication)', () => {
164
+ let reportCalled = false;
165
+ const mockContext = {
166
+ report: (options: any) => {
167
+ reportCalled = true;
168
+ expect(options.messageId).toBe('noLogic');
169
+ expect(options.data.name).toBe('shownHUNVat');
170
+ },
171
+ options: [],
172
+ sourceCode: {
173
+ getText: () => '',
174
+ },
175
+ } as any;
176
+
177
+ const rule = noGetterLogicRule.create(mockContext);
178
+
179
+ const mockNode = {
180
+ kind: 'get',
181
+ key: { name: 'shownHUNVat' },
182
+ value: {
183
+ body: {
184
+ type: 'BlockStatement',
185
+ body: [
186
+ {
187
+ type: 'ReturnStatement',
188
+ argument: {
189
+ type: 'BinaryExpression',
190
+ operator: '*',
191
+ left: { type: 'Identifier', name: 'HU_vat' },
192
+ right: { type: 'Literal', value: 100 },
193
+ },
194
+ },
195
+ ],
196
+ },
197
+ },
198
+ } as any;
199
+
200
+ rule.MethodDefinition(mockNode);
201
+
202
+ expect(reportCalled).toBe(true);
203
+ });
204
+
205
+ it('| should report for function call', () => {
206
+ let reportCalled = false;
207
+ const mockContext = {
208
+ report: (options: any) => {
209
+ reportCalled = true;
210
+ expect(options.messageId).toBe('noLogic');
211
+ expect(options.data.name).toBe('selectedPackageType');
212
+ },
213
+ options: [],
214
+ sourceCode: {
215
+ getText: () => '',
216
+ },
217
+ } as any;
218
+
219
+ const rule = noGetterLogicRule.create(mockContext);
220
+
221
+ const mockNode = {
222
+ kind: 'get',
223
+ key: { name: 'selectedPackageType' },
224
+ value: {
225
+ body: {
226
+ type: 'BlockStatement',
227
+ body: [
228
+ {
229
+ type: 'ReturnStatement',
230
+ argument: {
231
+ type: 'MemberExpression',
232
+ object: {
233
+ type: 'CallExpression',
234
+ callee: {
235
+ type: 'MemberExpression',
236
+ object: { type: 'ThisExpression' },
237
+ property: { type: 'Identifier', name: 'completedPurchaseData$' },
238
+ },
239
+ arguments: [],
240
+ },
241
+ property: { type: 'Identifier', name: 'selectedPackageType' },
242
+ },
243
+ },
244
+ ],
245
+ },
246
+ },
247
+ } as any;
248
+
249
+ rule.MethodDefinition(mockNode);
250
+
251
+ expect(reportCalled).toBe(true);
252
+ });
253
+
254
+ it('| should report for unary expression', () => {
255
+ let reportCalled = false;
256
+ const mockContext = {
257
+ report: (options: any) => {
258
+ reportCalled = true;
259
+ expect(options.messageId).toBe('noLogic');
260
+ },
261
+ options: [],
262
+ sourceCode: {
263
+ getText: () => '',
264
+ },
265
+ } as any;
266
+
267
+ const rule = noGetterLogicRule.create(mockContext);
268
+
269
+ const mockNode = {
270
+ kind: 'get',
271
+ key: { name: 'negatedValue' },
272
+ value: {
273
+ body: {
274
+ type: 'BlockStatement',
275
+ body: [
276
+ {
277
+ type: 'ReturnStatement',
278
+ argument: {
279
+ type: 'UnaryExpression',
280
+ operator: '!',
281
+ argument: { type: 'Identifier', name: 'someValue' },
282
+ },
283
+ },
284
+ ],
285
+ },
286
+ },
287
+ } as any;
288
+
289
+ rule.MethodDefinition(mockNode);
290
+
291
+ expect(reportCalled).toBe(true);
292
+ });
293
+
294
+ it('| should report for conditional expression (ternary)', () => {
295
+ let reportCalled = false;
296
+ const mockContext = {
297
+ report: (options: any) => {
298
+ reportCalled = true;
299
+ expect(options.messageId).toBe('noLogic');
300
+ },
301
+ options: [],
302
+ sourceCode: {
303
+ getText: () => '',
304
+ },
305
+ } as any;
306
+
307
+ const rule = noGetterLogicRule.create(mockContext);
308
+
309
+ const mockNode = {
310
+ kind: 'get',
311
+ key: { name: 'conditionalValue' },
312
+ value: {
313
+ body: {
314
+ type: 'BlockStatement',
315
+ body: [
316
+ {
317
+ type: 'ReturnStatement',
318
+ argument: {
319
+ type: 'ConditionalExpression',
320
+ test: { type: 'Identifier', name: 'condition' },
321
+ consequent: { type: 'Literal', value: 'true' },
322
+ alternate: { type: 'Literal', value: 'false' },
323
+ },
324
+ },
325
+ ],
326
+ },
327
+ },
328
+ } as any;
329
+
330
+ rule.MethodDefinition(mockNode);
331
+
332
+ expect(reportCalled).toBe(true);
333
+ });
334
+
335
+ it('| should report for logical expression', () => {
336
+ let reportCalled = false;
337
+ const mockContext = {
338
+ report: (options: any) => {
339
+ reportCalled = true;
340
+ expect(options.messageId).toBe('noLogic');
341
+ },
342
+ options: [],
343
+ sourceCode: {
344
+ getText: () => '',
345
+ },
346
+ } as any;
347
+
348
+ const rule = noGetterLogicRule.create(mockContext);
349
+
350
+ const mockNode = {
351
+ kind: 'get',
352
+ key: { name: 'logicalValue' },
353
+ value: {
354
+ body: {
355
+ type: 'BlockStatement',
356
+ body: [
357
+ {
358
+ type: 'ReturnStatement',
359
+ argument: {
360
+ type: 'LogicalExpression',
361
+ operator: '&&',
362
+ left: { type: 'Identifier', name: 'value1' },
363
+ right: { type: 'Identifier', name: 'value2' },
364
+ },
365
+ },
366
+ ],
367
+ },
368
+ },
369
+ } as any;
370
+
371
+ rule.MethodDefinition(mockNode);
372
+
373
+ expect(reportCalled).toBe(true);
374
+ });
375
+
376
+ it('| should not report for non-getter methods', () => {
377
+ let reportCalled = false;
378
+ const mockContext = {
379
+ report: () => {
380
+ reportCalled = true;
381
+ },
382
+ options: [],
383
+ sourceCode: {
384
+ getText: () => '',
385
+ },
386
+ } as any;
387
+
388
+ const rule = noGetterLogicRule.create(mockContext);
389
+
390
+ const mockNode = {
391
+ kind: 'method',
392
+ key: { name: 'someMethod' },
393
+ value: {
394
+ body: {
395
+ type: 'BlockStatement',
396
+ body: [
397
+ {
398
+ type: 'ReturnStatement',
399
+ argument: {
400
+ type: 'CallExpression',
401
+ callee: { type: 'Identifier', name: 'someFunction' },
402
+ arguments: [],
403
+ },
404
+ },
405
+ ],
406
+ },
407
+ },
408
+ } as any;
409
+
410
+ rule.MethodDefinition(mockNode);
411
+
412
+ expect(reportCalled).toBe(false);
413
+ });
414
+
415
+ it('| should not report for setter methods', () => {
416
+ let reportCalled = false;
417
+ const mockContext = {
418
+ report: () => {
419
+ reportCalled = true;
420
+ },
421
+ options: [],
422
+ sourceCode: {
423
+ getText: () => '',
424
+ },
425
+ } as any;
426
+
427
+ const rule = noGetterLogicRule.create(mockContext);
428
+
429
+ const mockNode = {
430
+ kind: 'set',
431
+ key: { name: 'someSetter' },
432
+ value: {
433
+ body: {
434
+ type: 'BlockStatement',
435
+ body: [
436
+ {
437
+ type: 'ExpressionStatement',
438
+ expression: {
439
+ type: 'AssignmentExpression',
440
+ operator: '=',
441
+ left: { type: 'Identifier', name: 'this.value' },
442
+ right: { type: 'Identifier', name: 'value' },
443
+ },
444
+ },
445
+ ],
446
+ },
447
+ },
448
+ } as any;
449
+
450
+ rule.MethodDefinition(mockNode);
451
+
452
+ expect(reportCalled).toBe(false);
453
+ });
454
+
455
+ it('| should handle getter without body gracefully', () => {
456
+ let reportCalled = false;
457
+ const mockContext = {
458
+ report: () => {
459
+ reportCalled = true;
460
+ },
461
+ options: [],
462
+ sourceCode: {
463
+ getText: () => '',
464
+ },
465
+ } as any;
466
+
467
+ const rule = noGetterLogicRule.create(mockContext);
468
+
469
+ const mockNode = {
470
+ kind: 'get',
471
+ key: { name: 'emptyGetter' },
472
+ value: {},
473
+ } as any;
474
+
475
+ expect(() => {
476
+ rule.MethodDefinition(mockNode);
477
+ }).not.toThrow();
478
+
479
+ expect(reportCalled).toBe(false);
480
+ });
481
+
482
+ it('| should report multi-statement getter body (CCAP-megerősítés)', () => {
483
+ let reportCalled: boolean = false;
484
+ const mockContext = {
485
+ report: (options: any) => {
486
+ reportCalled = true;
487
+ expect(options.messageId).toBe('noLogic');
488
+ },
489
+ options: [],
490
+ sourceCode: { getText: () => '' },
491
+ } as any;
492
+
493
+ const rule = noGetterLogicRule.create(mockContext);
494
+
495
+ const mockNode = {
496
+ kind: 'get',
497
+ key: { name: 'multiStatementGetter' },
498
+ value: {
499
+ body: {
500
+ type: 'BlockStatement',
501
+ body: [
502
+ {
503
+ type: 'VariableDeclaration',
504
+ declarations: [{ id: { name: 'tmp' }, init: { type: 'Identifier', name: 'foo' }}],
505
+ },
506
+ {
507
+ type: 'ReturnStatement',
508
+ argument: { type: 'Identifier', name: 'tmp' },
509
+ },
510
+ ],
511
+ },
512
+ },
513
+ } as any;
514
+
515
+ rule.MethodDefinition(mockNode);
516
+
517
+ expect(reportCalled).toBe(true);
518
+ });
519
+
520
+ it('| should report `if`-statement inside getter (CCAP-megerősítés)', () => {
521
+ let reportCalled: boolean = false;
522
+ const mockContext = {
523
+ report: () => { reportCalled = true; },
524
+ options: [],
525
+ sourceCode: { getText: () => '' },
526
+ } as any;
527
+
528
+ const rule = noGetterLogicRule.create(mockContext);
529
+
530
+ const mockNode = {
531
+ kind: 'get',
532
+ key: { name: 'gateGetter' },
533
+ value: {
534
+ body: {
535
+ type: 'BlockStatement',
536
+ body: [
537
+ {
538
+ type: 'IfStatement',
539
+ test: { type: 'Identifier', name: 'cond' },
540
+ consequent: { type: 'ReturnStatement', argument: { type: 'Literal', value: 1 }},
541
+ alternate: { type: 'ReturnStatement', argument: { type: 'Literal', value: 0 }},
542
+ },
543
+ ],
544
+ },
545
+ },
546
+ } as any;
547
+
548
+ rule.MethodDefinition(mockNode);
549
+
550
+ expect(reportCalled).toBe(true);
551
+ });
552
+
553
+ it('| should handle errors gracefully', () => {
554
+ const mockContext = {
555
+ report: () => {},
556
+ options: [],
557
+ sourceCode: {
558
+ getText: () => {
559
+ throw new Error('Test error');
560
+ },
561
+ },
562
+ } as any;
563
+
564
+ const rule = noGetterLogicRule.create(mockContext);
565
+
566
+ const mockNode = {
567
+ kind: 'get',
568
+ key: { name: 'testGetter' },
569
+ value: {
570
+ body: {
571
+ type: 'BlockStatement',
572
+ body: [
573
+ {
574
+ type: 'ReturnStatement',
575
+ argument: {
576
+ type: 'CallExpression',
577
+ callee: { type: 'Identifier', name: 'test' },
578
+ arguments: [],
579
+ },
580
+ },
581
+ ],
582
+ },
583
+ },
584
+ } as any;
585
+
586
+ // Should not throw error
587
+ expect(() => {
588
+ rule.MethodDefinition(mockNode);
589
+ }).not.toThrow();
590
+ });
591
+ });