@futdevpro/dynamo-eslint 1.20.2 → 1.20.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +305 -305
  3. package/build/configs/ngx.js +2 -2
  4. package/build/configs/ngx.js.map +1 -1
  5. package/build/plugin/rules/ts/no-as-cast.d.ts.map +1 -1
  6. package/build/plugin/rules/ts/no-as-cast.js +43 -0
  7. package/build/plugin/rules/ts/no-as-cast.js.map +1 -1
  8. package/package.json +14 -7
  9. package/.c8rc.json +0 -26
  10. package/.cursor/rules/__assistant_guide.mdc +0 -30
  11. package/.cursor/rules/__main.mdc +0 -64
  12. package/.cursor/rules/_ag_backend-structure.mdc +0 -86
  13. package/.cursor/rules/_ag_backend.mdc +0 -16
  14. package/.cursor/rules/_ag_debug.mdc +0 -8
  15. package/.cursor/rules/_ag_documentation_writing_rules.mdc +0 -372
  16. package/.cursor/rules/_ag_file-refactoring.mdc +0 -113
  17. package/.cursor/rules/_ag_fixes_rules.mdc +0 -6
  18. package/.cursor/rules/_ag_frontend-structure.mdc +0 -87
  19. package/.cursor/rules/_ag_frontend.mdc +0 -40
  20. package/.cursor/rules/_ag_import-rules.mdc +0 -45
  21. package/.cursor/rules/_ag_naming.mdc +0 -116
  22. package/.cursor/rules/_ag_running_commands.mdc +0 -5
  23. package/.cursor/rules/_ag_server-controller.mdc +0 -6
  24. package/.cursor/rules/_ag_should-be.mdc +0 -7
  25. package/.cursor/rules/_ag_swearing.mdc +0 -47
  26. package/.cursor/rules/ai_development_guide.md +0 -61
  27. package/.cursor/rules/ai_directives.md +0 -114
  28. package/.cursor/rules/cursor-rules.md +0 -160
  29. package/.cursor/rules/default-command.mdc +0 -465
  30. package/.cursor/rules/error_code_pattern.md +0 -40
  31. package/.cursor/rules/saved rule mcp server use.md +0 -16
  32. package/.dynamo/pipeline.cicd.config.json +0 -184
  33. package/.dynamo/version-bump.config.json +0 -5
  34. package/.eslintrc.json +0 -4
  35. package/.github/workflows/main.yml +0 -436
  36. package/.husky/pre-commit +0 -2
  37. package/.vscode/settings.json +0 -11
  38. package/__documentations/2026-04-18-ccap-review-integration.md +0 -173
  39. package/__documentations/2026-08-18-bfr-ctm-005-eslint9-validator-report.md +0 -45
  40. package/__documentations/2026-08-22-angular-20-phase2-release.md +0 -79
  41. package/eslint.config.js +0 -15
  42. package/pnpm-workspace.yaml +0 -2
  43. package/samples/.vscode/settings.json +0 -13
  44. package/samples/base/.eslintrc.json +0 -6
  45. package/samples/base/eslint.config.js +0 -3
  46. package/samples/fsm/.eslintrc.json +0 -4
  47. package/samples/fsm/eslint.config.js +0 -3
  48. package/samples/ngx/.eslintrc.json +0 -6
  49. package/samples/ngx/eslint.config.js +0 -3
  50. package/samples/ngx-package/.eslintrc.json +0 -4
  51. package/samples/ngx-package/eslint.config.js +0 -3
  52. package/samples/nts/.eslintrc.json +0 -6
  53. package/samples/nts/eslint.config.js +0 -3
  54. package/samples/nts-package/.eslintrc.json +0 -4
  55. package/samples/nts-package/eslint.config.js +0 -3
  56. package/samples/package.json.example +0 -22
  57. package/samples/poc-sample.ts +0 -38
  58. package/samples/poc-violations.ts +0 -54
  59. package/scripts/run-coverage-tests.js +0 -24
  60. package/spec/support/helpers/ts-node-helper.js +0 -9
  61. package/spec/support/jasmine.coverage.json +0 -23
  62. package/spec/support/jasmine.json +0 -24
  63. package/src/configs/angular20-compatibility.spec.ts +0 -62
  64. package/src/configs/base.ts +0 -156
  65. package/src/configs/fsm.ts +0 -10
  66. package/src/configs/ngx-package.ts +0 -10
  67. package/src/configs/ngx.ts +0 -93
  68. package/src/configs/nts-package.ts +0 -20
  69. package/src/configs/nts.ts +0 -34
  70. package/src/index.ts +0 -4
  71. package/src/plugin/index.ts +0 -86
  72. package/src/plugin/rules/angular/angular-for-track-logic.spec.ts +0 -44
  73. package/src/plugin/rules/angular/angular-for-track-logic.ts +0 -88
  74. package/src/plugin/rules/angular/effect-signal-loop.spec.ts +0 -89
  75. package/src/plugin/rules/angular/effect-signal-loop.ts +0 -125
  76. package/src/plugin/rules/angular/no-async-ngoninit.spec.ts +0 -50
  77. package/src/plugin/rules/angular/no-async-ngoninit.ts +0 -43
  78. package/src/plugin/rules/angular/no-component-direct-api.spec.ts +0 -78
  79. package/src/plugin/rules/angular/no-component-direct-api.ts +0 -82
  80. package/src/plugin/rules/angular/no-method-call-in-template.spec.ts +0 -63
  81. package/src/plugin/rules/angular/no-method-call-in-template.ts +0 -89
  82. package/src/plugin/rules/angular/no-ngfor-directive.spec.ts +0 -44
  83. package/src/plugin/rules/angular/no-ngfor-directive.ts +0 -62
  84. package/src/plugin/rules/angular/no-ngif-directive.spec.ts +0 -44
  85. package/src/plugin/rules/angular/no-ngif-directive.ts +0 -62
  86. package/src/plugin/rules/explicit-types.spec.ts +0 -190
  87. package/src/plugin/rules/explicit-types.ts +0 -186
  88. package/src/plugin/rules/import/import-order.spec.ts +0 -219
  89. package/src/plugin/rules/import/import-order.ts +0 -197
  90. package/src/plugin/rules/import/no-import-type.spec.ts +0 -69
  91. package/src/plugin/rules/import/no-import-type.ts +0 -46
  92. package/src/plugin/rules/import/no-js-import.spec.ts +0 -82
  93. package/src/plugin/rules/import/no-js-import.ts +0 -45
  94. package/src/plugin/rules/naming-patterns.spec.ts +0 -189
  95. package/src/plugin/rules/naming-patterns.ts +0 -426
  96. package/src/plugin/rules/no-getter-logic.spec.ts +0 -591
  97. package/src/plugin/rules/no-getter-logic.ts +0 -220
  98. package/src/plugin/rules/prefer-enum-over-string-union.spec.ts +0 -583
  99. package/src/plugin/rules/prefer-enum-over-string-union.ts +0 -333
  100. package/src/plugin/rules/prefer-interface-over-duplicate-types.spec.ts +0 -404
  101. package/src/plugin/rules/prefer-interface-over-duplicate-types.ts +0 -314
  102. package/src/plugin/rules/require-jsdoc-description.spec.ts +0 -779
  103. package/src/plugin/rules/require-jsdoc-description.ts +0 -572
  104. package/src/plugin/rules/require-test-description-prefix.spec.ts +0 -459
  105. package/src/plugin/rules/require-test-description-prefix.ts +0 -154
  106. package/src/plugin/rules/ts/data-model-extends.spec.ts +0 -84
  107. package/src/plugin/rules/ts/data-model-extends.ts +0 -100
  108. package/src/plugin/rules/ts/no-any-type.spec.ts +0 -28
  109. package/src/plugin/rules/ts/no-any-type.ts +0 -36
  110. package/src/plugin/rules/ts/no-as-cast.spec.ts +0 -51
  111. package/src/plugin/rules/ts/no-as-cast.ts +0 -51
  112. package/src/plugin/rules/ts/no-dynamic-imports.spec.ts +0 -54
  113. package/src/plugin/rules/ts/no-dynamic-imports.ts +0 -49
  114. package/src/plugin/rules/ts/no-native-browser-dialogs.spec.ts +0 -54
  115. package/src/plugin/rules/ts/no-native-browser-dialogs.ts +0 -84
  116. package/src/plugin/rules/ts/no-plain-function-export.spec.ts +0 -72
  117. package/src/plugin/rules/ts/no-plain-function-export.ts +0 -73
  118. package/src/plugin/rules/ts/one-export-per-file.spec.ts +0 -64
  119. package/src/plugin/rules/ts/one-export-per-file.ts +0 -77
  120. package/src/scripts/dynamo-fix.ts +0 -172
  121. package/src/scripts/eslintrc-audit.ts +0 -116
  122. package/src/scripts/fix-return-types.spec.ts +0 -65
  123. package/src/scripts/fix-return-types.ts +0 -289
  124. package/src/scripts/validate-imports.ts +0 -292
  125. package/src/scripts/validate-naming.ts +0 -213
  126. package/src/scripts/validator-cli.integration.spec.ts +0 -99
  127. package/tsconfig.json +0 -32
@@ -1,779 +0,0 @@
1
- import requireJSDocRule from './require-jsdoc-description';
2
-
3
- describe('| require-jsdoc-description', () => {
4
- it('| should be a valid ESLint rule', () => {
5
- expect(requireJSDocRule.meta?.type).toBe('suggestion');
6
- expect(requireJSDocRule.meta?.docs?.description).toContain('Require JSDoc comment blocks');
7
- expect(requireJSDocRule.meta?.fixable).toBeUndefined();
8
- });
9
-
10
- it('| should have create function that returns visitor object', () => {
11
- const mockContext = {
12
- report: () => {},
13
- options: [{ scope: 'public' }],
14
- sourceCode: {
15
- getCommentsBefore: () => [],
16
- },
17
- } as any;
18
-
19
- const result = requireJSDocRule.create(mockContext);
20
-
21
- expect(typeof result).toBe('object');
22
- expect(typeof result.FunctionDeclaration).toBe('function');
23
- expect(typeof result.ClassDeclaration).toBe('function');
24
- expect(typeof result.TSInterfaceDeclaration).toBe('function');
25
- expect(typeof result.TSEnumDeclaration).toBe('function');
26
- expect(typeof result.TSTypeAliasDeclaration).toBe('function');
27
- expect(typeof result.MethodDefinition).toBe('function');
28
- expect(typeof result.VariableDeclarator).toBe('function');
29
- });
30
-
31
- it('| should not report when function has valid JSDoc', () => {
32
- const mockContext = {
33
- report: (options: any) => {
34
- fail('Should not report when function has valid JSDoc');
35
- },
36
- options: [{ scope: 'public' }],
37
- sourceCode: {
38
- getCommentsBefore: () => [{
39
- type: 'Block',
40
- value: '* This is a test function',
41
- loc: { end: { line: 1 } },
42
- }],
43
- },
44
- } as any;
45
-
46
- const rule = requireJSDocRule.create(mockContext);
47
-
48
- const mockNode = {
49
- type: 'FunctionDeclaration',
50
- id: { name: 'testFunction' },
51
- loc: { start: { line: 2 } },
52
- } as any;
53
-
54
- rule.FunctionDeclaration(mockNode);
55
- });
56
-
57
- it('| should report when function is missing JSDoc', () => {
58
- let reportCalled = false;
59
- const mockContext = {
60
- report: (options: any) => {
61
- reportCalled = true;
62
- expect(options.messageId).toBe('missingJSDoc');
63
- expect(options.data.type).toBe('Function');
64
- expect(options.data.name).toBe('testFunction');
65
- },
66
- options: [{ scope: 'public' }],
67
- sourceCode: {
68
- getCommentsBefore: () => [],
69
- },
70
- } as any;
71
-
72
- const rule = requireJSDocRule.create(mockContext);
73
-
74
- const mockNode = {
75
- type: 'FunctionDeclaration',
76
- id: { name: 'testFunction' },
77
- loc: { start: { line: 1 } },
78
- } as any;
79
-
80
- rule.FunctionDeclaration(mockNode);
81
-
82
- expect(reportCalled).toBe(true);
83
- });
84
-
85
- it('| should report when JSDoc is empty (no description)', () => {
86
- let reportCalled = false;
87
- const mockContext = {
88
- report: (options: any) => {
89
- reportCalled = true;
90
- expect(options.messageId).toBe('emptyJSDoc');
91
- expect(options.data.type).toBe('Function');
92
- expect(options.data.name).toBe('testFunction');
93
- },
94
- options: [{ scope: 'public' }],
95
- sourceCode: {
96
- getCommentsBefore: () => [{
97
- type: 'Block',
98
- value: '*',
99
- loc: { end: { line: 1 } },
100
- }],
101
- },
102
- } as any;
103
-
104
- const rule = requireJSDocRule.create(mockContext);
105
-
106
- const mockNode = {
107
- type: 'FunctionDeclaration',
108
- id: { name: 'testFunction' },
109
- loc: { start: { line: 2 } },
110
- } as any;
111
-
112
- rule.FunctionDeclaration(mockNode);
113
-
114
- expect(reportCalled).toBe(true);
115
- });
116
-
117
- it('| should report when JSDoc is not on previous line', () => {
118
- let reportCalled = false;
119
- const mockContext = {
120
- report: (options: any) => {
121
- reportCalled = true;
122
- expect(options.messageId).toBe('invalidJSDocPosition');
123
- expect(options.data.type).toBe('Function');
124
- expect(options.data.name).toBe('testFunction');
125
- },
126
- options: [{ scope: 'public' }],
127
- sourceCode: {
128
- getCommentsBefore: () => [{
129
- type: 'Block',
130
- value: '* This is a test function',
131
- loc: { end: { line: 1 } },
132
- }],
133
- },
134
- } as any;
135
-
136
- const rule = requireJSDocRule.create(mockContext);
137
-
138
- const mockNode = {
139
- type: 'FunctionDeclaration',
140
- id: { name: 'testFunction' },
141
- loc: { start: { line: 3 } }, // Gap between comment and function
142
- } as any;
143
-
144
- rule.FunctionDeclaration(mockNode);
145
-
146
- expect(reportCalled).toBe(true);
147
- });
148
-
149
- it('| should report when function is not exported and scope is public', () => {
150
- const mockContext = {
151
- report: (options: any) => {
152
- fail('Should not report when function is not exported in public scope');
153
- },
154
- options: [{ scope: 'public' }],
155
- sourceCode: {
156
- getCommentsBefore: () => [],
157
- },
158
- } as any;
159
-
160
- const rule = requireJSDocRule.create(mockContext);
161
-
162
- const mockNode = {
163
- type: 'FunctionDeclaration',
164
- id: { name: 'privateFunction' },
165
- loc: { start: { line: 1 } },
166
- parent: { type: 'Program', body: [] },
167
- } as any;
168
-
169
- rule.FunctionDeclaration(mockNode);
170
-
171
- // In public scope, non-exported functions should not be documented
172
- });
173
-
174
- it('| should report when function is private and scope is all', () => {
175
- let reportCalled = false;
176
- const mockContext = {
177
- report: (options: any) => {
178
- reportCalled = true;
179
- expect(options.messageId).toBe('missingJSDoc');
180
- },
181
- options: [{ scope: 'all' }],
182
- sourceCode: {
183
- getCommentsBefore: () => [],
184
- },
185
- } as any;
186
-
187
- const rule = requireJSDocRule.create(mockContext);
188
-
189
- const mockNode = {
190
- type: 'FunctionDeclaration',
191
- id: { name: 'privateFunction' },
192
- loc: { start: { line: 1 } },
193
- } as any;
194
-
195
- rule.FunctionDeclaration(mockNode);
196
-
197
- expect(reportCalled).toBe(true);
198
- });
199
-
200
- it('| should handle class declarations', () => {
201
- let reportCalled = false;
202
- const mockContext = {
203
- report: (options: any) => {
204
- reportCalled = true;
205
- expect(options.data.type).toBe('Class');
206
- expect(options.data.name).toBe('TestClass');
207
- },
208
- options: [{ scope: 'public' }],
209
- sourceCode: {
210
- getCommentsBefore: () => [],
211
- },
212
- } as any;
213
-
214
- const rule = requireJSDocRule.create(mockContext);
215
-
216
- const mockNode = {
217
- type: 'ClassDeclaration',
218
- id: { name: 'TestClass' },
219
- loc: { start: { line: 1 } },
220
- } as any;
221
-
222
- rule.ClassDeclaration(mockNode);
223
-
224
- expect(reportCalled).toBe(true);
225
- });
226
-
227
- it('| should handle interface declarations', () => {
228
- let reportCalled = false;
229
- const mockContext = {
230
- report: (options: any) => {
231
- reportCalled = true;
232
- expect(options.data.type).toBe('Interface');
233
- expect(options.data.name).toBe('TestInterface');
234
- },
235
- options: [{ scope: 'public' }],
236
- sourceCode: {
237
- getCommentsBefore: () => [],
238
- },
239
- } as any;
240
-
241
- const rule = requireJSDocRule.create(mockContext);
242
-
243
- const mockNode = {
244
- type: 'TSInterfaceDeclaration',
245
- id: { name: 'TestInterface' },
246
- loc: { start: { line: 1 } },
247
- } as any;
248
-
249
- rule.TSInterfaceDeclaration(mockNode, undefined, undefined);
250
-
251
- expect(reportCalled).toBe(true);
252
- });
253
-
254
- it('| should handle enum declarations', () => {
255
- let reportCalled = false;
256
- const mockContext = {
257
- report: (options: any) => {
258
- reportCalled = true;
259
- expect(options.data.type).toBe('Enum');
260
- expect(options.data.name).toBe('TestEnum');
261
- },
262
- options: [{ scope: 'public' }],
263
- sourceCode: {
264
- getCommentsBefore: () => [],
265
- },
266
- } as any;
267
-
268
- const rule = requireJSDocRule.create(mockContext);
269
-
270
- const mockNode = {
271
- type: 'TSEnumDeclaration',
272
- id: { name: 'TestEnum' },
273
- loc: { start: { line: 1 } },
274
- } as any;
275
-
276
- rule.TSEnumDeclaration(mockNode, undefined, undefined);
277
-
278
- expect(reportCalled).toBe(true);
279
- });
280
-
281
- it('| should handle method definitions', () => {
282
- let reportCalled = false;
283
- const mockContext = {
284
- report: (options: any) => {
285
- reportCalled = true;
286
- expect(options.data.type).toBe('Method');
287
- expect(options.data.name).toBe('testMethod');
288
- },
289
- options: [{ scope: 'public' }],
290
- sourceCode: {
291
- getCommentsBefore: () => [],
292
- },
293
- } as any;
294
-
295
- const rule = requireJSDocRule.create(mockContext);
296
-
297
- const mockNode = {
298
- type: 'MethodDefinition',
299
- key: { name: 'testMethod' },
300
- loc: { start: { line: 1 } },
301
- } as any;
302
-
303
- rule.MethodDefinition(mockNode);
304
-
305
- expect(reportCalled).toBe(true);
306
- });
307
-
308
- it('| should handle function expressions in variable declarations', () => {
309
- let reportCalled = false;
310
- const mockContext = {
311
- report: (options: any) => {
312
- reportCalled = true;
313
- expect(options.data.type).toBe('Function');
314
- },
315
- options: [{ scope: 'public' }],
316
- sourceCode: {
317
- getCommentsBefore: () => [],
318
- },
319
- } as any;
320
-
321
- const rule = requireJSDocRule.create(mockContext);
322
-
323
- const mockNode = {
324
- type: 'VariableDeclarator',
325
- id: { name: 'testFunction' },
326
- init: { type: 'FunctionExpression' },
327
- loc: { start: { line: 1 } },
328
- } as any;
329
-
330
- rule.VariableDeclarator(mockNode);
331
-
332
- expect(reportCalled).toBe(true);
333
- });
334
-
335
- it('| should handle arrow functions in variable declarations', () => {
336
- let reportCalled = false;
337
- const mockContext = {
338
- report: (options: any) => {
339
- reportCalled = true;
340
- expect(options.data.type).toBe('Function');
341
- },
342
- options: [{ scope: 'public' }],
343
- sourceCode: {
344
- getCommentsBefore: () => [],
345
- },
346
- } as any;
347
-
348
- const rule = requireJSDocRule.create(mockContext);
349
-
350
- const mockNode = {
351
- type: 'VariableDeclarator',
352
- id: { name: 'testArrowFunction' },
353
- init: { type: 'ArrowFunctionExpression' },
354
- loc: { start: { line: 1 } },
355
- } as any;
356
-
357
- rule.VariableDeclarator(mockNode);
358
-
359
- expect(reportCalled).toBe(true);
360
- });
361
-
362
- it('| should not report when variable declarator is not a function', () => {
363
- const mockContext = {
364
- report: (options: any) => {
365
- fail('Should not report when variable is not a function');
366
- },
367
- options: [{ scope: 'public' }],
368
- sourceCode: {
369
- getCommentsBefore: () => [],
370
- },
371
- } as any;
372
-
373
- const rule = requireJSDocRule.create(mockContext);
374
-
375
- const mockNode = {
376
- type: 'VariableDeclarator',
377
- id: { name: 'testVariable' },
378
- init: { type: 'Literal', value: 'test' },
379
- loc: { start: { line: 1 } },
380
- } as any;
381
-
382
- rule.VariableDeclarator(mockNode);
383
- });
384
-
385
- it('| should handle JSDoc with @param tags', () => {
386
- const mockContext = {
387
- report: (options: any) => {
388
- fail('Should not report when JSDoc has description and @param tags');
389
- },
390
- options: [{ scope: 'public' }],
391
- sourceCode: {
392
- getCommentsBefore: () => [{
393
- type: 'Block',
394
- value: '* This function does something\n* @param {string} name The name parameter',
395
- loc: { end: { line: 1 } },
396
- }],
397
- },
398
- } as any;
399
-
400
- const rule = requireJSDocRule.create(mockContext);
401
-
402
- const mockNode = {
403
- type: 'FunctionDeclaration',
404
- id: { name: 'testFunction' },
405
- loc: { start: { line: 2 } },
406
- } as any;
407
-
408
- rule.FunctionDeclaration(mockNode);
409
- });
410
-
411
- it('| should handle JSDoc with only @param tags (no description)', () => {
412
- let reportCalled = false;
413
- const mockContext = {
414
- report: (options: any) => {
415
- reportCalled = true;
416
- expect(options.messageId).toBe('emptyJSDoc');
417
- },
418
- options: [{ scope: 'public' }],
419
- sourceCode: {
420
- getCommentsBefore: () => [{
421
- type: 'Block',
422
- value: '* @param {string} name The name parameter',
423
- loc: { end: { line: 1 } },
424
- }],
425
- },
426
- } as any;
427
-
428
- const rule = requireJSDocRule.create(mockContext);
429
-
430
- const mockNode = {
431
- type: 'FunctionDeclaration',
432
- id: { name: 'testFunction' },
433
- loc: { start: { line: 2 } },
434
- } as any;
435
-
436
- rule.FunctionDeclaration(mockNode);
437
-
438
- expect(reportCalled).toBe(true);
439
- });
440
-
441
- it('| should handle default scope when no options provided', () => {
442
- let reportCalled = false;
443
- const mockContext = {
444
- report: (options: any) => {
445
- reportCalled = true;
446
- expect(options.messageId).toBe('missingJSDoc');
447
- },
448
- options: [],
449
- sourceCode: {
450
- getCommentsBefore: () => [],
451
- },
452
- } as any;
453
-
454
- const rule = requireJSDocRule.create(mockContext);
455
-
456
- const mockNode = {
457
- type: 'FunctionDeclaration',
458
- id: { name: 'testFunction' },
459
- loc: { start: { line: 1 } },
460
- } as any;
461
-
462
- rule.FunctionDeclaration(mockNode);
463
-
464
- expect(reportCalled).toBe(true);
465
- });
466
-
467
- it('| should handle error cases gracefully', () => {
468
- const mockContext = {
469
- report: () => {},
470
- options: [{ scope: 'public' }],
471
- sourceCode: {
472
- getCommentsBefore: () => {
473
- throw new Error('Source code error');
474
- },
475
- },
476
- } as any;
477
-
478
- const rule = requireJSDocRule.create(mockContext);
479
-
480
- const mockNode = {
481
- type: 'FunctionDeclaration',
482
- id: { name: 'testFunction' },
483
- loc: { start: { line: 1 } },
484
- } as any;
485
-
486
- // Should not throw error
487
- expect(() => {
488
- rule.FunctionDeclaration(mockNode);
489
- }).not.toThrow();
490
- });
491
-
492
- it('| should handle anonymous functions', () => {
493
- let reportCalled = false;
494
- const mockContext = {
495
- report: (options: any) => {
496
- reportCalled = true;
497
- expect(options.data.name).toBe('anonymous');
498
- },
499
- options: [{ scope: 'public' }],
500
- sourceCode: {
501
- getCommentsBefore: () => [],
502
- },
503
- } as any;
504
-
505
- const rule = requireJSDocRule.create(mockContext);
506
-
507
- const mockNode = {
508
- type: 'FunctionDeclaration',
509
- id: null, // Anonymous function
510
- loc: { start: { line: 1 } },
511
- } as any;
512
-
513
- rule.FunctionDeclaration(mockNode);
514
-
515
- expect(reportCalled).toBe(true);
516
- });
517
-
518
- it('| should handle multiline JSDoc descriptions', () => {
519
- const mockContext = {
520
- report: (options: any) => {
521
- fail('Should not report when JSDoc has multiline description');
522
- },
523
- options: [{ scope: 'public' }],
524
- sourceCode: {
525
- getCommentsBefore: () => [{
526
- type: 'Block',
527
- value: '* This is a multiline\n* description for the function\n* that explains what it does',
528
- loc: { end: { line: 1 } },
529
- }],
530
- },
531
- } as any;
532
-
533
- const rule = requireJSDocRule.create(mockContext);
534
-
535
- const mockNode = {
536
- type: 'FunctionDeclaration',
537
- id: { name: 'testFunction' },
538
- loc: { start: { line: 2 } },
539
- } as any;
540
-
541
- rule.FunctionDeclaration(mockNode);
542
- });
543
-
544
- it('| should handle abstract class with multiline JSDoc', () => {
545
- const mockContext = {
546
- report: (options: any) => {
547
- fail('Should not report when abstract class has multiline JSDoc');
548
- },
549
- options: [{ scope: 'public' }],
550
- sourceCode: {
551
- getCommentsBefore: () => [{
552
- type: 'Block',
553
- value: '* Abstract data service osztály a user műveletek kezeléséhez.\n* Kezeli a login, register, validation és egyéb user-rel kapcsolatos műveleteket.',
554
- loc: { end: { line: 3 } },
555
- }],
556
- },
557
- } as any;
558
-
559
- const rule = requireJSDocRule.create(mockContext);
560
-
561
- const mockNode = {
562
- type: 'ClassDeclaration',
563
- id: { name: 'FDPNTS_User_DataService' },
564
- loc: { start: { line: 4 } },
565
- parent: {
566
- type: 'ExportNamedDeclaration',
567
- },
568
- } as any;
569
-
570
- rule.ClassDeclaration(mockNode);
571
- });
572
-
573
- it('| should handle multiline JSDoc with empty lines', () => {
574
- const mockContext = {
575
- report: (options: any) => {
576
- fail('Should not report when JSDoc has multiline description with empty lines');
577
- },
578
- options: [{ scope: 'public' }],
579
- sourceCode: {
580
- getCommentsBefore: () => [{
581
- type: 'Block',
582
- value: '* This is a multiline description\n*\n* with empty lines in between\n* that should still be valid',
583
- loc: { end: { line: 4 } },
584
- }],
585
- },
586
- } as any;
587
-
588
- const rule = requireJSDocRule.create(mockContext);
589
-
590
- const mockNode = {
591
- type: 'FunctionDeclaration',
592
- id: { name: 'testFunction' },
593
- loc: { start: { line: 5 } },
594
- } as any;
595
-
596
- rule.FunctionDeclaration(mockNode);
597
- });
598
-
599
- it('| should handle multiline JSDoc followed by @tags', () => {
600
- const mockContext = {
601
- report: (options: any) => {
602
- fail('Should not report when JSDoc has description before @tags');
603
- },
604
- options: [{ scope: 'public' }],
605
- sourceCode: {
606
- getCommentsBefore: () => [{
607
- type: 'Block',
608
- value: '* This is a description\n* that spans multiple lines\n* @param {string} name The name parameter',
609
- loc: { end: { line: 2 } },
610
- }],
611
- },
612
- } as any;
613
-
614
- const rule = requireJSDocRule.create(mockContext);
615
-
616
- const mockNode = {
617
- type: 'FunctionDeclaration',
618
- id: { name: 'testFunction' },
619
- loc: { start: { line: 3 } },
620
- } as any;
621
-
622
- rule.FunctionDeclaration(mockNode);
623
- });
624
-
625
- it('| should find JSDoc on the export wrapper for `export class X`', () => {
626
- // A belso ClassDeclaration ele NINCS comment — csak az ExportNamedDeclaration ele.
627
- // A fix nelkul a szabaly tevesen "missingJSDoc"-ot jelez.
628
- const jsdoc = {
629
- type: 'Block',
630
- value: '* Exported class with JSDoc above the export keyword.',
631
- loc: { end: { line: 1 } },
632
- };
633
- const exportNode: any = { type: 'ExportNamedDeclaration' };
634
- const mockContext = {
635
- report: () => {
636
- fail('Should not report — JSDoc is present above the export wrapper');
637
- },
638
- options: [{ scope: 'public' }],
639
- sourceCode: {
640
- getCommentsBefore: (anchor: any): any[] => (anchor === exportNode ? [ jsdoc ] : []),
641
- },
642
- } as any;
643
-
644
- const rule = requireJSDocRule.create(mockContext);
645
-
646
- const mockNode: any = {
647
- type: 'ClassDeclaration',
648
- id: { name: 'X' },
649
- loc: { start: { line: 2 } },
650
- };
651
- mockNode.parent = exportNode;
652
- exportNode.declaration = mockNode;
653
-
654
- rule.ClassDeclaration(mockNode);
655
- });
656
-
657
- it('| should find JSDoc on the export wrapper for an arrow-const function', () => {
658
- const jsdoc = {
659
- type: 'Block',
660
- value: '* Arrow-const with explicit JSDoc above the export.',
661
- loc: { end: { line: 1 } },
662
- };
663
- const varDecl: any = { type: 'VariableDeclaration' };
664
- const exportNode: any = { type: 'ExportNamedDeclaration', declaration: varDecl };
665
- varDecl.parent = exportNode;
666
-
667
- const mockContext = {
668
- report: () => {
669
- fail('Should not report — arrow-const JSDoc is present above the export');
670
- },
671
- options: [{ scope: 'public' }],
672
- sourceCode: {
673
- getCommentsBefore: (anchor: any): any[] => (anchor === exportNode ? [ jsdoc ] : []),
674
- },
675
- } as any;
676
-
677
- const rule = requireJSDocRule.create(mockContext);
678
-
679
- const mockNode: any = {
680
- type: 'VariableDeclarator',
681
- id: { name: 'fn' },
682
- init: { type: 'ArrowFunctionExpression' },
683
- loc: { start: { line: 2 } },
684
- parent: varDecl,
685
- };
686
-
687
- rule.VariableDeclarator(mockNode);
688
- });
689
-
690
- it('| should find JSDoc above a decorator stack', () => {
691
- const jsdoc = {
692
- type: 'Block',
693
- value: '* Decorated component with JSDoc above the decorator.',
694
- loc: { end: { line: 1 } },
695
- };
696
- const decorator: any = { type: 'Decorator' };
697
-
698
- const mockContext = {
699
- report: () => {
700
- fail('Should not report — JSDoc is present above the decorator stack');
701
- },
702
- options: [{ scope: 'public' }],
703
- sourceCode: {
704
- getCommentsBefore: (anchor: any): any[] => (anchor === decorator ? [ jsdoc ] : []),
705
- },
706
- } as any;
707
-
708
- const rule = requireJSDocRule.create(mockContext);
709
-
710
- const mockNode: any = {
711
- type: 'ClassDeclaration',
712
- id: { name: 'X' },
713
- loc: { start: { line: 2 } },
714
- decorators: [ decorator ],
715
- };
716
-
717
- rule.ClassDeclaration(mockNode);
718
- });
719
-
720
- it('| should still report a genuinely missing JSDoc on an export-wrapped class', () => {
721
- let reportCalled = false;
722
- const exportNode: any = { type: 'ExportNamedDeclaration' };
723
- const mockContext = {
724
- report: (options: any) => {
725
- reportCalled = true;
726
- expect(options.messageId).toBe('missingJSDoc');
727
- expect(options.data.name).toBe('Undocumented');
728
- },
729
- options: [{ scope: 'public' }],
730
- sourceCode: {
731
- getCommentsBefore: (): any[] => [],
732
- },
733
- } as any;
734
-
735
- const rule = requireJSDocRule.create(mockContext);
736
-
737
- const mockNode: any = {
738
- type: 'ClassDeclaration',
739
- id: { name: 'Undocumented' },
740
- loc: { start: { line: 1 } },
741
- };
742
- mockNode.parent = exportNode;
743
- exportNode.declaration = mockNode;
744
-
745
- rule.ClassDeclaration(mockNode);
746
-
747
- expect(reportCalled).toBe(true);
748
- });
749
-
750
- it('| should report when abstract class is missing JSDoc', () => {
751
- let reportCalled = false;
752
- const mockContext = {
753
- report: (options: any) => {
754
- reportCalled = true;
755
- expect(options.data.type).toBe('Class');
756
- expect(options.data.name).toBe('AbstractClass');
757
- },
758
- options: [{ scope: 'public' }],
759
- sourceCode: {
760
- getCommentsBefore: () => [],
761
- },
762
- } as any;
763
-
764
- const rule = requireJSDocRule.create(mockContext);
765
-
766
- const mockNode = {
767
- type: 'ClassDeclaration',
768
- id: { name: 'AbstractClass' },
769
- loc: { start: { line: 1 } },
770
- parent: {
771
- type: 'ExportNamedDeclaration',
772
- },
773
- } as any;
774
-
775
- rule.ClassDeclaration(mockNode);
776
-
777
- expect(reportCalled).toBe(true);
778
- });
779
- });