@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,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
+ });