eslint-plugin-jsdoc 44.2.3 → 44.2.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 (120) hide show
  1. package/dist/WarnSettings.js +0 -1
  2. package/dist/WarnSettings.js.map +1 -1
  3. package/dist/alignTransform.js +87 -5
  4. package/dist/alignTransform.js.map +1 -1
  5. package/dist/bin/generateRule.js +4 -3
  6. package/dist/bin/generateRule.js.map +1 -1
  7. package/dist/exportParser.js +272 -71
  8. package/dist/exportParser.js.map +1 -1
  9. package/dist/generateRule.js +4 -3
  10. package/dist/generateRule.js.map +1 -1
  11. package/dist/iterateJsdoc.js +921 -357
  12. package/dist/iterateJsdoc.js.map +1 -1
  13. package/dist/jsdocUtils.js +270 -168
  14. package/dist/jsdocUtils.js.map +1 -1
  15. package/dist/rules/checkAlignment.js +6 -0
  16. package/dist/rules/checkAlignment.js.map +1 -1
  17. package/dist/rules/checkExamples.js +73 -9
  18. package/dist/rules/checkExamples.js.map +1 -1
  19. package/dist/rules/checkIndentation.js +12 -2
  20. package/dist/rules/checkIndentation.js.map +1 -1
  21. package/dist/rules/checkLineAlignment.js +71 -7
  22. package/dist/rules/checkLineAlignment.js.map +1 -1
  23. package/dist/rules/checkParamNames.js +29 -11
  24. package/dist/rules/checkParamNames.js.map +1 -1
  25. package/dist/rules/checkPropertyNames.js +13 -7
  26. package/dist/rules/checkPropertyNames.js.map +1 -1
  27. package/dist/rules/checkTagNames.js +45 -9
  28. package/dist/rules/checkTagNames.js.map +1 -1
  29. package/dist/rules/checkTypes.js +98 -41
  30. package/dist/rules/checkTypes.js.map +1 -1
  31. package/dist/rules/checkValues.js +7 -7
  32. package/dist/rules/checkValues.js.map +1 -1
  33. package/dist/rules/emptyTags.js +8 -1
  34. package/dist/rules/emptyTags.js.map +1 -1
  35. package/dist/rules/informativeDocs.js +27 -8
  36. package/dist/rules/informativeDocs.js.map +1 -1
  37. package/dist/rules/matchDescription.js +18 -1
  38. package/dist/rules/matchDescription.js.map +1 -1
  39. package/dist/rules/matchName.js +2 -2
  40. package/dist/rules/matchName.js.map +1 -1
  41. package/dist/rules/multilineBlocks.js +12 -1
  42. package/dist/rules/multilineBlocks.js.map +1 -1
  43. package/dist/rules/noBadBlocks.js +4 -6
  44. package/dist/rules/noBadBlocks.js.map +1 -1
  45. package/dist/rules/noBlankBlockDescriptions.js +2 -0
  46. package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
  47. package/dist/rules/noMissingSyntax.js +53 -16
  48. package/dist/rules/noMissingSyntax.js.map +1 -1
  49. package/dist/rules/noMultiAsterisks.js +1 -6
  50. package/dist/rules/noMultiAsterisks.js.map +1 -1
  51. package/dist/rules/noRestrictedSyntax.js +12 -5
  52. package/dist/rules/noRestrictedSyntax.js.map +1 -1
  53. package/dist/rules/noTypes.js +3 -0
  54. package/dist/rules/noTypes.js.map +1 -1
  55. package/dist/rules/noUndefinedTypes.js +65 -27
  56. package/dist/rules/noUndefinedTypes.js.map +1 -1
  57. package/dist/rules/requireAsteriskPrefix.js +20 -0
  58. package/dist/rules/requireAsteriskPrefix.js.map +1 -1
  59. package/dist/rules/requireDescription.js +6 -2
  60. package/dist/rules/requireDescription.js.map +1 -1
  61. package/dist/rules/requireDescriptionCompleteSentence.js +75 -12
  62. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  63. package/dist/rules/requireFileOverview.js +9 -4
  64. package/dist/rules/requireFileOverview.js.map +1 -1
  65. package/dist/rules/requireHyphenBeforeParamDescription.js +21 -7
  66. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  67. package/dist/rules/requireJsdoc.js +150 -29
  68. package/dist/rules/requireJsdoc.js.map +1 -1
  69. package/dist/rules/requireParam.js +116 -10
  70. package/dist/rules/requireParam.js.map +1 -1
  71. package/dist/rules/requireProperty.js +1 -1
  72. package/dist/rules/requireProperty.js.map +1 -1
  73. package/dist/rules/requireReturns.js +2 -3
  74. package/dist/rules/requireReturns.js.map +1 -1
  75. package/dist/rules/requireReturnsCheck.js +9 -2
  76. package/dist/rules/requireReturnsCheck.js.map +1 -1
  77. package/dist/rules/requireThrows.js +2 -3
  78. package/dist/rules/requireThrows.js.map +1 -1
  79. package/dist/rules/requireYields.js +9 -3
  80. package/dist/rules/requireYields.js.map +1 -1
  81. package/dist/rules/requireYieldsCheck.js +19 -5
  82. package/dist/rules/requireYieldsCheck.js.map +1 -1
  83. package/dist/rules/sortTags.js +67 -9
  84. package/dist/rules/sortTags.js.map +1 -1
  85. package/dist/rules/tagLines.js +22 -3
  86. package/dist/rules/tagLines.js.map +1 -1
  87. package/dist/rules/textEscaping.js +18 -4
  88. package/dist/rules/textEscaping.js.map +1 -1
  89. package/dist/rules/validTypes.js +26 -9
  90. package/dist/rules/validTypes.js.map +1 -1
  91. package/dist/tagNames.js +0 -2
  92. package/dist/tagNames.js.map +1 -1
  93. package/dist/utils/hasReturnValue.js +77 -48
  94. package/dist/utils/hasReturnValue.js.map +1 -1
  95. package/docs/rules/check-line-alignment.md +7 -0
  96. package/docs/rules/check-tag-names.md +15 -0
  97. package/docs/rules/no-missing-syntax.md +6 -0
  98. package/docs/rules/no-undefined-types.md +6 -0
  99. package/docs/rules/require-description-complete-sentence.md +525 -289
  100. package/docs/rules/require-description.md +289 -525
  101. package/docs/rules/require-file-overview.md +7 -0
  102. package/docs/rules/require-jsdoc.md +1 -1
  103. package/docs/rules/require-param-description.md +116 -1694
  104. package/docs/rules/require-param-name.md +58 -133
  105. package/docs/rules/require-param-type.md +119 -55
  106. package/docs/rules/require-param.md +1704 -111
  107. package/docs/rules/require-property-description.md +39 -79
  108. package/docs/rules/require-property-name.md +21 -30
  109. package/docs/rules/require-property-type.md +21 -21
  110. package/docs/rules/require-property.md +82 -33
  111. package/docs/rules/require-returns-check.md +636 -747
  112. package/docs/rules/require-returns-description.md +61 -933
  113. package/docs/rules/require-returns-type.md +42 -79
  114. package/docs/rules/require-returns.md +1081 -61
  115. package/docs/rules/require-yields-check.md +238 -517
  116. package/docs/rules/require-yields.md +517 -238
  117. package/docs/rules/valid-types.md +1 -1
  118. package/docs/settings.md +3 -1
  119. package/package.json +10 -9
  120. package/tsconfig.json +2 -3
@@ -11,14 +11,529 @@ Object.defineProperty(exports, "parseComment", {
11
11
  return _jsdoccomment.parseComment;
12
12
  }
13
13
  });
14
+ var _jsdocUtils = _interopRequireDefault(require("./jsdocUtils"));
14
15
  var _jsdoccomment = require("@es-joy/jsdoccomment");
15
16
  var _commentParser = require("comment-parser");
16
- var _jsdocUtils = _interopRequireDefault(require("./jsdocUtils"));
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
18
  /**
19
19
  * @typedef {number} Integer
20
20
  */
21
21
 
22
+ /**
23
+ * @typedef {import('@es-joy/jsdoccomment').JsdocBlockWithInline} JsdocBlockWithInline
24
+ */
25
+
26
+ /**
27
+ * @typedef {{
28
+ * disallowName?: string,
29
+ * allowName?: string,
30
+ * context?: string,
31
+ * comment?: string,
32
+ * tags?: string[],
33
+ * replacement?: string,
34
+ * minimum?: Integer,
35
+ * message?: string
36
+ * }} ContextObject
37
+ */
38
+ /**
39
+ * @typedef {string|ContextObject} Context
40
+ */
41
+
42
+ /**
43
+ * @callback CheckJsdoc
44
+ * @param {{
45
+ * lastIndex?: Integer,
46
+ * isFunctionContext?: boolean,
47
+ * selector?: string,
48
+ * comment?: string
49
+ * }} info
50
+ * @param {null|((jsdoc: import('@es-joy/jsdoccomment').JsdocBlockWithInline) => boolean|undefined)} handler
51
+ * @param {import('eslint').Rule.Node} node
52
+ * @returns {void}
53
+ */
54
+
55
+ /**
56
+ * @callback ForEachPreferredTag
57
+ * @param {string} tagName
58
+ * @param {(
59
+ * matchingJsdocTag: import('@es-joy/jsdoccomment').JsdocTagWithInline,
60
+ * targetTagName: string
61
+ * ) => void} arrayHandler
62
+ * @param {boolean} [skipReportingBlockedTag]
63
+ * @returns {void}
64
+ */
65
+
66
+ /**
67
+ * @callback ReportSettings
68
+ * @param {string} message
69
+ * @returns {void}
70
+ */
71
+
72
+ /**
73
+ * @callback ParseClosureTemplateTag
74
+ * @param {import('comment-parser').Spec} tag
75
+ * @returns {string[]}
76
+ */
77
+
78
+ /**
79
+ * @callback GetPreferredTagNameObject
80
+ * @param {{
81
+ * tagName: string
82
+ * }} cfg
83
+ * @returns {string|false|{
84
+ * message: string;
85
+ * replacement?: string|undefined
86
+ * }|{
87
+ * blocked: true,
88
+ * tagName: string
89
+ * }}
90
+ */
91
+
92
+ /**
93
+ * @typedef {{
94
+ * forEachPreferredTag: ForEachPreferredTag,
95
+ * reportSettings: ReportSettings,
96
+ * parseClosureTemplateTag: ParseClosureTemplateTag,
97
+ * getPreferredTagNameObject: GetPreferredTagNameObject,
98
+ * pathDoesNotBeginWith: import('./jsdocUtils.js').PathDoesNotBeginWith
99
+ * }} BasicUtils
100
+ */
101
+
102
+ /**
103
+ * @callback IsIteratingFunction
104
+ * @returns {boolean}
105
+ */
106
+
107
+ /**
108
+ * @callback IsVirtualFunction
109
+ * @returns {boolean}
110
+ */
111
+
112
+ /**
113
+ * @callback Stringify
114
+ * @param {import('comment-parser').Block} tagBlock
115
+ * @param {boolean} [specRewire]
116
+ * @returns {string}
117
+ */
118
+
119
+ /**
120
+ * @callback ReportJSDoc
121
+ * @param {string} msg
122
+ * @param {null|import('comment-parser').Spec|{line: Integer, column?: Integer}} [tag]
123
+ * @param {(() => void)|null} [handler]
124
+ * @param {boolean} [specRewire]
125
+ * @param {undefined|{
126
+ * [key: string]: string
127
+ * }} [data]
128
+ */
129
+ /* eslint-enable jsdoc/valid-types -- Old version */
130
+
131
+ /**
132
+ * @callback GetRegexFromString
133
+ * @param {string} str
134
+ * @param {string} [requiredFlags]
135
+ * @returns {RegExp}
136
+ */
137
+
138
+ /**
139
+ * @callback GetTagDescription
140
+ * @param {import('comment-parser').Spec} tg
141
+ * @param {boolean} [returnArray]
142
+ * @returns {string[]|string}
143
+ */
144
+
145
+ /**
146
+ * @callback SetTagDescription
147
+ * @param {import('comment-parser').Spec} tg
148
+ * @param {RegExp} matcher
149
+ * @param {(description: string) => string} setter
150
+ * @returns {Integer}
151
+ */
152
+
153
+ /**
154
+ * @callback GetDescription
155
+ * @returns {{
156
+ * description: string,
157
+ * descriptions: string[],
158
+ * lastDescriptionLine: Integer
159
+ * }}
160
+ */
161
+
162
+ /**
163
+ * @callback SetBlockDescription
164
+ * @param {(
165
+ * info: {
166
+ * delimiter: string,
167
+ * postDelimiter: string,
168
+ * start: string
169
+ * },
170
+ * seedTokens: (
171
+ * tokens?: Partial<import('comment-parser').Tokens>
172
+ * ) => import('comment-parser').Tokens,
173
+ * descLines: string[]
174
+ * ) => import('comment-parser').Line[]} setter
175
+ * @returns {void}
176
+ */
177
+ /* eslint-enable jsdoc/no-undefined-types -- Bug */
178
+
179
+ /**
180
+ * @callback SetDescriptionLines
181
+ * @param {RegExp} matcher
182
+ * @param {(description: string) => string} setter
183
+ * @returns {Integer}
184
+ */
185
+
186
+ /**
187
+ * @callback ChangeTag
188
+ * @param {import('comment-parser').Spec} tag
189
+ * @param {...Partial<import('comment-parser').Tokens>} tokens
190
+ * @returns {void}
191
+ */
192
+ /* eslint-enable jsdoc/no-undefined-types -- TS */
193
+
194
+ /**
195
+ * @callback SetTag
196
+ * @param {import('comment-parser').Spec & {
197
+ * line: Integer
198
+ * }} tag
199
+ * @param {Partial<import('comment-parser').Tokens>} [tokens]
200
+ * @returns {void}
201
+ */
202
+ /* eslint-enable jsdoc/no-undefined-types -- TS */
203
+
204
+ /**
205
+ * @callback RemoveTag
206
+ * @param {Integer} tagIndex
207
+ * @param {{
208
+ * removeEmptyBlock?: boolean,
209
+ * tagSourceOffset?: Integer
210
+ * }} [cfg]
211
+ * @returns {void}
212
+ */
213
+
214
+ /**
215
+ * @callback AddTag
216
+ * @param {string} targetTagName
217
+ * @param {Integer} [number]
218
+ * @param {import('comment-parser').Tokens|{}} [tokens]
219
+ * @returns {void}
220
+ */
221
+
222
+ /**
223
+ * @callback GetFirstLine
224
+ * @returns {Integer|undefined}
225
+ */
226
+
227
+ /**
228
+ * @typedef {(
229
+ * tokens?: Partial<import('comment-parser').Tokens> | undefined
230
+ * ) => import('comment-parser').Tokens} SeedTokens
231
+ */
232
+ /* eslint-enable jsdoc/no-undefined-types -- TS */
233
+
234
+ /**
235
+ * Sets tokens to empty string.
236
+ * @callback EmptyTokens
237
+ * @param {import('comment-parser').Tokens} tokens
238
+ * @returns {void}
239
+ */
240
+
241
+ /**
242
+ * @callback AddLine
243
+ * @param {Integer} sourceIndex
244
+ * @param {Partial<import('comment-parser').Tokens>} tokens
245
+ * @returns {void}
246
+ */
247
+ /* eslint-enable jsdoc/no-undefined-types -- TS */
248
+
249
+ /**
250
+ * @callback AddLines
251
+ * @param {Integer} tagIndex
252
+ * @param {Integer} tagSourceOffset
253
+ * @param {Integer} numLines
254
+ * @returns {void}
255
+ */
256
+
257
+ /**
258
+ * @callback MakeMultiline
259
+ * @returns {void}
260
+ */
261
+
262
+ /**
263
+ * @callback GetFunctionParameterNames
264
+ * @param {boolean} [useDefaultObjectProperties]
265
+ * @returns {import('./jsdocUtils.js').ParamNameInfo[]}
266
+ */
267
+
268
+ /**
269
+ * @callback HasParams
270
+ * @returns {Integer}
271
+ */
272
+
273
+ /**
274
+ * @callback IsGenerator
275
+ * @returns {boolean}
276
+ */
277
+
278
+ /**
279
+ * @callback IsConstructor
280
+ * @returns {boolean}
281
+ */
282
+
283
+ /**
284
+ * @callback GetJsdocTagsDeep
285
+ * @param {string} tagName
286
+ * @returns {false|{
287
+ * idx: Integer,
288
+ * name: string,
289
+ * type: string
290
+ * }[]}
291
+ */
292
+
293
+ /**
294
+ * @callback GetPreferredTagName
295
+ * @param {{
296
+ * tagName: string,
297
+ * skipReportingBlockedTag?: boolean,
298
+ * allowObjectReturn?: boolean,
299
+ * defaultMessage?: string
300
+ * }} cfg
301
+ * @returns {string|undefined|false|{
302
+ * message: string;
303
+ * replacement?: string|undefined;
304
+ * }|{
305
+ * blocked: true,
306
+ * tagName: string
307
+ * }}
308
+ */
309
+
310
+ /**
311
+ * @callback IsValidTag
312
+ * @param {string} name
313
+ * @param {string[]} definedTags
314
+ * @returns {boolean}
315
+ */
316
+
317
+ /**
318
+ * @callback HasATag
319
+ * @param {string[]} names
320
+ * @returns {boolean}
321
+ */
322
+
323
+ /**
324
+ * @callback HasTag
325
+ * @param {string} name
326
+ * @returns {boolean}
327
+ */
328
+
329
+ /**
330
+ * @callback ComparePaths
331
+ * @param {string} name
332
+ * @returns {(otherPathName: string) => boolean}
333
+ */
334
+
335
+ /**
336
+ * @callback DropPathSegmentQuotes
337
+ * @param {string} name
338
+ * @returns {string}
339
+ */
340
+
341
+ /**
342
+ * @callback AvoidDocs
343
+ * @returns {boolean}
344
+ */
345
+
346
+ /**
347
+ * @callback TagMightHaveNamePositionTypePosition
348
+ * @param {string} tagName
349
+ * @param {import('./getDefaultTagStructureForMode.js').
350
+ * TagStructure[]} [otherModeMaps]
351
+ * @returns {boolean|{otherMode: true}}
352
+ */
353
+
354
+ /**
355
+ * @callback TagMustHave
356
+ * @param {string} tagName
357
+ * @param {import('./getDefaultTagStructureForMode.js').
358
+ * TagStructure[]} otherModeMaps
359
+ * @returns {boolean|{
360
+ * otherMode: false
361
+ * }}
362
+ */
363
+
364
+ /**
365
+ * @callback TagMissingRequiredTypeOrNamepath
366
+ * @param {import('comment-parser').Spec} tag
367
+ * @param {import('./getDefaultTagStructureForMode.js').
368
+ * TagStructure[]} otherModeMaps
369
+ * @returns {boolean|{
370
+ * otherMode: false
371
+ * }}
372
+ */
373
+
374
+ /**
375
+ * @callback IsNamepathX
376
+ * @param {string} tagName
377
+ * @returns {boolean}
378
+ */
379
+
380
+ /**
381
+ * @callback GetTagStructureForMode
382
+ * @param {import('./jsdocUtils.js').ParserMode} mde
383
+ * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
384
+ */
385
+
386
+ /**
387
+ * @callback MayBeUndefinedTypeTag
388
+ * @param {import('comment-parser').Spec} tag
389
+ * @returns {boolean}
390
+ */
391
+
392
+ /**
393
+ * @callback HasValueOrExecutorHasNonEmptyResolveValue
394
+ * @param {boolean} anyPromiseAsReturn
395
+ * @param {boolean} [allBranches]
396
+ * @returns {boolean}
397
+ */
398
+
399
+ /**
400
+ * @callback HasYieldValue
401
+ * @returns {boolean}
402
+ */
403
+
404
+ /**
405
+ * @callback HasYieldReturnValue
406
+ * @returns {boolean}
407
+ */
408
+
409
+ /**
410
+ * @callback HasThrowValue
411
+ * @returns {boolean}
412
+ */
413
+
414
+ /**
415
+ * @callback IsAsync
416
+ * @returns {boolean|undefined}
417
+ */
418
+
419
+ /**
420
+ * @callback GetTags
421
+ * @param {string} tagName
422
+ * @returns {import('comment-parser').Spec[]}
423
+ */
424
+
425
+ /**
426
+ * @callback GetPresentTags
427
+ * @param {string[]} tagList
428
+ * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
429
+ */
430
+
431
+ /**
432
+ * @callback FilterTags
433
+ * @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter
434
+ * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
435
+ */
436
+
437
+ /**
438
+ * @callback FilterAllTags
439
+ * @param {(tag: (import('comment-parser').Spec|
440
+ * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)) => boolean} filter
441
+ * @returns {(import('comment-parser').Spec|
442
+ * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
443
+ */
444
+
445
+ /**
446
+ * @callback GetTagsByType
447
+ * @param {import('comment-parser').Spec[]} tags
448
+ * @returns {{
449
+ * tagsWithNames: import('comment-parser').Spec[],
450
+ * tagsWithoutNames: import('comment-parser').Spec[]
451
+ * }}
452
+ */
453
+
454
+ /**
455
+ * @callback HasOptionTag
456
+ * @param {string} tagName
457
+ * @returns {boolean}
458
+ */
459
+
460
+ /**
461
+ * @callback GetClassNode
462
+ * @returns {Node|null}
463
+ */
464
+
465
+ /**
466
+ * @callback GetClassJsdoc
467
+ * @returns {null|JsdocBlockWithInline}
468
+ */
469
+
470
+ /**
471
+ * @callback ClassHasTag
472
+ * @param {string} tagName
473
+ * @returns {boolean}
474
+ */
475
+ /**
476
+ * @typedef {BasicUtils & {
477
+ * isIteratingFunction: IsIteratingFunction,
478
+ * isVirtualFunction: IsVirtualFunction,
479
+ * stringify: Stringify,
480
+ * reportJSDoc: ReportJSDoc,
481
+ * getRegexFromString: GetRegexFromString,
482
+ * getTagDescription: GetTagDescription,
483
+ * setTagDescription: SetTagDescription,
484
+ * getDescription: GetDescription,
485
+ * setBlockDescription: SetBlockDescription,
486
+ * setDescriptionLines: SetDescriptionLines,
487
+ * changeTag: ChangeTag,
488
+ * setTag: SetTag,
489
+ * removeTag: RemoveTag,
490
+ * addTag: AddTag,
491
+ * getFirstLine: GetFirstLine,
492
+ * seedTokens: SeedTokens,
493
+ * emptyTokens: EmptyTokens,
494
+ * addLine: AddLine,
495
+ * addLines: AddLines,
496
+ * makeMultiline: MakeMultiline,
497
+ * flattenRoots: import('./jsdocUtils.js').FlattenRoots,
498
+ * getFunctionParameterNames: GetFunctionParameterNames,
499
+ * hasParams: HasParams,
500
+ * isGenerator: IsGenerator,
501
+ * isConstructor: IsConstructor,
502
+ * getJsdocTagsDeep: GetJsdocTagsDeep,
503
+ * getPreferredTagName: GetPreferredTagName,
504
+ * isValidTag: IsValidTag,
505
+ * hasATag: HasATag,
506
+ * hasTag: HasTag,
507
+ * comparePaths: ComparePaths,
508
+ * dropPathSegmentQuotes: DropPathSegmentQuotes,
509
+ * avoidDocs: AvoidDocs,
510
+ * tagMightHaveNamePosition: TagMightHaveNamePositionTypePosition,
511
+ * tagMightHaveTypePosition: TagMightHaveNamePositionTypePosition,
512
+ * tagMustHaveNamePosition: TagMustHave,
513
+ * tagMustHaveTypePosition: TagMustHave,
514
+ * tagMissingRequiredTypeOrNamepath: TagMissingRequiredTypeOrNamepath,
515
+ * isNamepathDefiningTag: IsNamepathX,
516
+ * isNamepathReferencingTag: IsNamepathX,
517
+ * isNamepathOrUrlReferencingTag: IsNamepathX,
518
+ * tagMightHaveNamepath: IsNamepathX,
519
+ * getTagStructureForMode: GetTagStructureForMode,
520
+ * mayBeUndefinedTypeTag: MayBeUndefinedTypeTag,
521
+ * hasValueOrExecutorHasNonEmptyResolveValue: HasValueOrExecutorHasNonEmptyResolveValue,
522
+ * hasYieldValue: HasYieldValue,
523
+ * hasYieldReturnValue: HasYieldReturnValue,
524
+ * hasThrowValue: HasThrowValue,
525
+ * isAsync: IsAsync,
526
+ * getTags: GetTags,
527
+ * getPresentTags: GetPresentTags,
528
+ * filterTags: FilterTags,
529
+ * filterAllTags: FilterAllTags,
530
+ * getTagsByType: GetTagsByType,
531
+ * hasOptionTag: HasOptionTag,
532
+ * getClassNode: GetClassNode,
533
+ * getClassJsdoc: GetClassJsdoc,
534
+ * classHasTag: ClassHasTag
535
+ * }} Utils
536
+ */
22
537
  const {
23
538
  rewireSpecs,
24
539
  seedTokens
@@ -28,20 +543,35 @@ const {
28
543
 
29
544
  /**
30
545
  * Should use ESLint rule's typing.
31
- *
32
- * @typedef {any} EslintRuleMeta
546
+ * @typedef {import('eslint').Rule.RuleMetaData} EslintRuleMeta
33
547
  */
34
548
 
35
549
  /**
36
550
  * A plain object for tracking state as needed by rules across iterations.
37
- *
38
- * @typedef {any} StateObject
551
+ * @typedef {{
552
+ * globalTags: {},
553
+ * hasDuplicates: {
554
+ * [key: string]: boolean
555
+ * },
556
+ * selectorMap: {
557
+ * [selector: string]: {
558
+ * [comment: string]: Integer
559
+ * }
560
+ * },
561
+ * hasTag: {
562
+ * [key: string]: boolean
563
+ * },
564
+ * hasNonComment: number,
565
+ * hasNonCommentBeforeTag: {
566
+ * [key: string]: boolean|number
567
+ * }
568
+ * }} StateObject
39
569
  */
570
+ /* eslint-enable jsdoc/valid-types -- Old version */
40
571
 
41
572
  /**
42
573
  * The Node AST as supplied by the parser.
43
- *
44
- * @typedef {any} Node
574
+ * @typedef {import('eslint').Rule.Node} Node
45
575
  */
46
576
 
47
577
  /*
@@ -59,18 +589,16 @@ const globalState = new Map();
59
589
  * tagNamePreference?: import('./jsdocUtils.js').TagNamePreference,
60
590
  * mode?: import('./jsdocUtils.js').ParserMode
61
591
  * }} cfg
62
- * @returns {Utils}
592
+ * @returns {BasicUtils}
63
593
  */
64
594
  const getBasicUtils = (context, {
65
595
  tagNamePreference,
66
596
  mode
67
597
  }) => {
598
+ /** @type {BasicUtils} */
68
599
  const utils = {};
69
600
 
70
- /**
71
- * @param {string} message
72
- * @returns {void}
73
- */
601
+ /** @type {ReportSettings} */
74
602
  utils.reportSettings = message => {
75
603
  context.report({
76
604
  loc: {
@@ -87,20 +615,13 @@ const getBasicUtils = (context, {
87
615
  });
88
616
  };
89
617
 
90
- /**
91
- * @param {import('comment-parser').Spec} tag
92
- * @returns {string[]}
93
- */
618
+ /** @type {ParseClosureTemplateTag} */
94
619
  utils.parseClosureTemplateTag = tag => {
95
620
  return _jsdocUtils.default.parseClosureTemplateTag(tag);
96
621
  };
97
622
  utils.pathDoesNotBeginWith = _jsdocUtils.default.pathDoesNotBeginWith;
98
623
 
99
- /**
100
- * @param {{
101
- * tagName: string
102
- * }} cfg
103
- */
624
+ /** @type {GetPreferredTagNameObject} */
104
625
  utils.getPreferredTagNameObject = ({
105
626
  tagName
106
627
  }) => {
@@ -118,21 +639,36 @@ const getBasicUtils = (context, {
118
639
  };
119
640
 
120
641
  /**
121
- * @param {} node
122
- * @param {import('comment-parser').Block} jsdoc
123
- * @param {import('@es-joy/jsdoccomment').Token} jsdocNode
642
+ * @callback Report
643
+ * @param {string} message
644
+ * @param {import('eslint').Rule.ReportFixer|null} [fix]
645
+ * @param {null|
646
+ * {line?: Integer, column?: Integer}|
647
+ * import('comment-parser').Spec & {line?: Integer}
648
+ * } [jsdocLoc]
649
+ * @param {undefined|{
650
+ * [key: string]: string
651
+ * }} [data]
652
+ * @returns {void}
653
+ */
654
+ /* eslint-enable jsdoc/valid-types -- Old version of pratt */
655
+
656
+ /**
657
+ * @param {Node|null} node
658
+ * @param {JsdocBlockWithInline} jsdoc
659
+ * @param {import('eslint').AST.Token} jsdocNode
124
660
  * @param {Settings} settings
125
- * @param {} report
661
+ * @param {Report} report
126
662
  * @param {import('eslint').Rule.RuleContext} context
127
- * @param {boolean} iteratingAll
128
- * @param {} ruleConfig
663
+ * @param {boolean|undefined} iteratingAll
664
+ * @param {RuleConfig} ruleConfig
129
665
  * @param {string} indent
130
- * @returns {}
666
+ * @returns {Utils}
131
667
  */
132
668
  const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAll, ruleConfig, indent) => {
133
- const ancestors = context.getAncestors();
669
+ const ancestors = /** @type {import('eslint').Rule.Node[]} */context.getAncestors();
134
670
  const sourceCode = context.getSourceCode();
135
- const utils = getBasicUtils(context, settings);
671
+ const utils = /** @type {Utils} */getBasicUtils(context, settings);
136
672
  const {
137
673
  tagNamePreference,
138
674
  overrideReplacesDocs,
@@ -144,25 +680,17 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
144
680
  mode
145
681
  } = settings;
146
682
 
147
- /**
148
- * @returns {boolean}
149
- */
683
+ /** @type {IsIteratingFunction} */
150
684
  utils.isIteratingFunction = () => {
151
- return !iteratingAll || ['MethodDefinition', 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(node && node.type);
685
+ return !iteratingAll || ['MethodDefinition', 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(String(node && node.type));
152
686
  };
153
687
 
154
- /**
155
- * @returns {boolean}
156
- */
688
+ /** @type {IsVirtualFunction} */
157
689
  utils.isVirtualFunction = () => {
158
- return iteratingAll && utils.hasATag(['callback', 'function', 'func', 'method']);
690
+ return Boolean(iteratingAll) && utils.hasATag(['callback', 'function', 'func', 'method']);
159
691
  };
160
692
 
161
- /**
162
- * @param {import('comment-parser').Block} tagBlock
163
- * @param {boolean} [specRewire]
164
- * @returns {string}
165
- */
693
+ /** @type {Stringify} */
166
694
  utils.stringify = (tagBlock, specRewire) => {
167
695
  let block;
168
696
  if (specRewire) {
@@ -172,18 +700,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
172
700
  specRewire ? block : tagBlock);
173
701
  };
174
702
 
175
- /* eslint-disable jsdoc/valid-types -- Old version */
176
- /**
177
- * @param {string} msg
178
- * @param {import('comment-parser').Spec} tag
179
- * @param {() => void} handler
180
- * @param {boolean} [specRewire]
181
- * @param {{
182
- * [key: string]: undefined|string
183
- * }} [data]
184
- */
703
+ /** @type {ReportJSDoc} */
185
704
  utils.reportJSDoc = (msg, tag, handler, specRewire, data) => {
186
- /* eslint-enable jsdoc/valid-types -- Old version */
187
705
  report(msg, handler ? /** @type {import('eslint').Rule.ReportFixer} */fixer => {
188
706
  handler();
189
707
  const replacement = utils.stringify(jsdoc, specRewire);
@@ -199,20 +717,12 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
199
717
  } : null, tag, data);
200
718
  };
201
719
 
202
- /**
203
- * @param {string} str
204
- * @param {string} requiredFlags
205
- * @returns {RegExp}
206
- */
720
+ /** @type {GetRegexFromString} */
207
721
  utils.getRegexFromString = (str, requiredFlags) => {
208
722
  return _jsdocUtils.default.getRegexFromString(str, requiredFlags);
209
723
  };
210
724
 
211
- /**
212
- * @param {import('comment-parser').Spec} tg
213
- * @param {boolean} returnArray
214
- * @returns {string[]|string}
215
- */
725
+ /** @type {GetTagDescription} */
216
726
  utils.getTagDescription = (tg, returnArray) => {
217
727
  /**
218
728
  * @type {string[]}
@@ -246,12 +756,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
246
756
  return returnArray ? descriptions : descriptions.join('\n');
247
757
  };
248
758
 
249
- /**
250
- * @param {import('comment-parser').Spec} tg
251
- * @param {RegExp} matcher
252
- * @param {(description: string) => string} setter
253
- * @returns {Integer}
254
- */
759
+ /** @type {SetTagDescription} */
255
760
  utils.setTagDescription = (tg, matcher, setter) => {
256
761
  let finalIdx = 0;
257
762
  tg.source.some(({
@@ -269,13 +774,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
269
774
  return finalIdx;
270
775
  };
271
776
 
272
- /**
273
- * @returns {{
274
- * description: string,
275
- * descriptions: string[],
276
- * lastDescriptionLine: Integer
277
- * }}
278
- */
777
+ /** @type {GetDescription} */
279
778
  utils.getDescription = () => {
280
779
  /** @type {string[]} */
281
780
  const descriptions = [];
@@ -310,23 +809,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
310
809
  };
311
810
  };
312
811
 
313
- /* eslint-disable jsdoc/no-undefined-types -- Bug */
314
- /**
315
- * @param {(
316
- * info: undefined|{
317
- * delimiter: string,
318
- * postDelimiter: string,
319
- * start: string
320
- * },
321
- * seedTokens: (
322
- * tokens?: Partial<import('comment-parser').Tokens> | undefined
323
- * ) => import('comment-parser').Tokens,
324
- * descLines: string[]
325
- * ) => import('comment-parser').Tokens[]} setter
326
- * @returns {void}
327
- */
812
+ /** @type {SetBlockDescription} */
328
813
  utils.setBlockDescription = setter => {
329
- /* eslint-enable jsdoc/no-undefined-types -- Bug */
330
814
  /** @type {string[]} */
331
815
  const descLines = [];
332
816
  /**
@@ -337,6 +821,14 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
337
821
  * @type {undefined|Integer}
338
822
  */
339
823
  let endIdx;
824
+
825
+ /**
826
+ * @type {undefined|{
827
+ * delimiter: string,
828
+ * postDelimiter: string,
829
+ * start: string
830
+ * }}
831
+ */
340
832
  let info;
341
833
  jsdoc.source.some(({
342
834
  tokens: {
@@ -369,15 +861,19 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
369
861
 
370
862
  /* istanbul ignore else -- Won't be called if missing */
371
863
  if (descLines.length) {
372
- jsdoc.source.splice( /** @type {Integer} */startIdx, /** @type {Integer} */endIdx - /** @type {Integer} */startIdx, ...setter(info, seedTokens, descLines));
864
+ jsdoc.source.splice( /** @type {Integer} */startIdx, /** @type {Integer} */endIdx - /** @type {Integer} */startIdx, ...setter(
865
+ /**
866
+ * @type {{
867
+ * delimiter: string,
868
+ * postDelimiter: string,
869
+ * start: string
870
+ * }}
871
+ */
872
+ info, seedTokens, descLines));
373
873
  }
374
874
  };
375
875
 
376
- /**
377
- * @param {RegExp} matcher
378
- * @param {(description: string) => string} setter
379
- * @returns {Integer}
380
- */
876
+ /** @type {SetDescriptionLines} */
381
877
  utils.setDescriptionLines = (matcher, setter) => {
382
878
  let finalIdx = 0;
383
879
  jsdoc.source.some(({
@@ -401,11 +897,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
401
897
  return finalIdx;
402
898
  };
403
899
 
404
- /**
405
- * @param {import('comment-parser').Spec} tag
406
- * @param {import('comment-parser').Tokens[]} tokens
407
- * @returns {void}
408
- */
900
+ /** @type {ChangeTag} */
409
901
  utils.changeTag = (tag, ...tokens) => {
410
902
  for (const [idx, src] of tag.source.entries()) {
411
903
  src.tokens = {
@@ -415,16 +907,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
415
907
  }
416
908
  };
417
909
 
418
- /* eslint-disable jsdoc/no-undefined-types -- TS */
419
- /**
420
- * @param {import('comment-parser').Spec & {
421
- * line: Integer
422
- * }} tag
423
- * @param {Partial<import('comment-parser').Tokens>} tokens
424
- * @returns {void}
425
- */
910
+ /** @type {SetTag} */
426
911
  utils.setTag = (tag, tokens) => {
427
- /* eslint-enable jsdoc/no-undefined-types -- TS */
428
912
  tag.source = [{
429
913
  number: tag.line,
430
914
  // Or tag.source[0].number?
@@ -439,14 +923,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
439
923
  }];
440
924
  };
441
925
 
442
- /**
443
- * @param {Integer} tagIndex
444
- * @param {{
445
- * removeEmptyBlock?: boolean,
446
- * tagSourceOffset?: Integer
447
- * }} cfg
448
- * @returns {void}
449
- */
926
+ /** @type {RemoveTag} */
450
927
  utils.removeTag = (tagIndex, {
451
928
  removeEmptyBlock = false,
452
929
  tagSourceOffset = 0
@@ -520,12 +997,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
520
997
  // correct information will be available)
521
998
  };
522
999
 
523
- /**
524
- * @param {string} targetTagName
525
- * @param {Integer} number
526
- * @param {import('comment-parser').Tokens|{}} tokens
527
- * @returns {void}
528
- */
1000
+ /** @type {AddTag} */
529
1001
  utils.addTag = (targetTagName, number = ((() => {
530
1002
  var _jsdoc$tags, _jsdoc$tags$source$;
531
1003
  return (_jsdoc$tags = jsdoc.tags[jsdoc.tags.length - 1]) === null || _jsdoc$tags === void 0 ? void 0 : (_jsdoc$tags$source$ = _jsdoc$tags.source[0]) === null || _jsdoc$tags$source$ === void 0 ? void 0 : _jsdoc$tags$source$.number;
@@ -552,9 +1024,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
552
1024
  }
553
1025
  };
554
1026
 
555
- /**
556
- * @returns {Integer|undefined}
557
- */
1027
+ /** @type {GetFirstLine} */
558
1028
  utils.getFirstLine = () => {
559
1029
  let firstLine;
560
1030
  for (const {
@@ -570,14 +1040,11 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
570
1040
  }
571
1041
  return firstLine;
572
1042
  };
1043
+
1044
+ /** @type {SeedTokens} */
573
1045
  utils.seedTokens = seedTokens;
574
1046
 
575
- /**
576
- * Sets tokens to empty string.
577
- *
578
- * @param {import('comment-parser').Tokens} tokens
579
- * @returns {void}
580
- */
1047
+ /** @type {EmptyTokens} */
581
1048
  utils.emptyTokens = tokens => {
582
1049
  for (const prop of ['start', 'postDelimiter', 'tag', 'type', 'postType', 'postTag', 'name', 'postName', 'description', 'end', 'lineEnd']) {
583
1050
  tokens[
@@ -589,11 +1056,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
589
1056
  }
590
1057
  };
591
1058
 
592
- /**
593
- * @param {Integer} sourceIndex
594
- * @param {import('comment-parser').Tokens} tokens
595
- * @returns {void}
596
- */
1059
+ /** @type {AddLine} */
597
1060
  utils.addLine = (sourceIndex, tokens) => {
598
1061
  var _jsdoc$source;
599
1062
  const number = (((_jsdoc$source = jsdoc.source[sourceIndex - 1]) === null || _jsdoc$source === void 0 ? void 0 : _jsdoc$source.number) || 0) + 1;
@@ -609,12 +1072,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
609
1072
  // rewireSource(jsdoc);
610
1073
  };
611
1074
 
612
- /**
613
- * @param {Integer} tagIndex
614
- * @param {Integer} tagSourceOffset
615
- * @param {Integer} numLines
616
- * @returns {void}
617
- */
1075
+ /** @type {AddLines} */
618
1076
  utils.addLines = (tagIndex, tagSourceOffset, numLines) => {
619
1077
  const {
620
1078
  source: tagSource
@@ -662,13 +1120,11 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
662
1120
  return false;
663
1121
  });
664
1122
  for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) {
665
- src.number = firstNumber + lastIndex + idx;
1123
+ src.number = firstNumber + /** @type {Integer} */lastIndex + idx;
666
1124
  }
667
1125
  };
668
1126
 
669
- /**
670
- * @returns {void}
671
- */
1127
+ /** @type {MakeMultiline} */
672
1128
  utils.makeMultiline = () => {
673
1129
  const {
674
1130
  source: [{
@@ -724,52 +1180,43 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
724
1180
  };
725
1181
 
726
1182
  /**
727
- * @param {} params
728
- * @returns {}
1183
+ * @type {import('./jsdocUtils.js').FlattenRoots}
729
1184
  */
730
- utils.flattenRoots = params => {
731
- return _jsdocUtils.default.flattenRoots(params);
732
- };
1185
+ utils.flattenRoots = _jsdocUtils.default.flattenRoots;
733
1186
 
734
- /**
735
- * @param {boolean} useDefaultObjectProperties
736
- * @returns {}
737
- */
1187
+ /** @type {GetFunctionParameterNames} */
738
1188
  utils.getFunctionParameterNames = useDefaultObjectProperties => {
739
1189
  return _jsdocUtils.default.getFunctionParameterNames(node, useDefaultObjectProperties);
740
1190
  };
741
1191
 
742
- /**
743
- * @returns {Integer}
744
- */
1192
+ /** @type {HasParams} */
745
1193
  utils.hasParams = () => {
746
- return _jsdocUtils.default.hasParams(node);
1194
+ return _jsdocUtils.default.hasParams( /** @type {Node} */node);
747
1195
  };
748
1196
 
749
- /**
750
- * @returns {boolean}
751
- */
1197
+ /** @type {IsGenerator} */
752
1198
  utils.isGenerator = () => {
753
- return node && (node.generator || node.type === 'MethodDefinition' && node.value.generator || ['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes(node.type) && node.declaration.generator);
1199
+ return node !== null && Boolean(
1200
+ /**
1201
+ * @type {import('estree').FunctionDeclaration|
1202
+ * import('estree').FunctionExpression}
1203
+ */
1204
+ node.generator || node.type === 'MethodDefinition' && node.value.generator || ['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes(node.type) && /** @type {import('estree').FunctionDeclaration} */
1205
+ /**
1206
+ * @type {import('estree').ExportNamedDeclaration|
1207
+ * import('estree').ExportDefaultDeclaration}
1208
+ */
1209
+ node.declaration.generator);
754
1210
  };
755
1211
 
756
- /**
757
- * @returns {boolean}
758
- */
1212
+ /** @type {IsConstructor} */
759
1213
  utils.isConstructor = () => {
760
- return _jsdocUtils.default.isConstructor(node);
1214
+ return _jsdocUtils.default.isConstructor( /** @type {Node} */node);
761
1215
  };
762
1216
 
763
- /**
764
- * @param {string} tagName
765
- * @returns {false|{
766
- * idx: Integer,
767
- * name: string,
768
- * type: string
769
- * }[]}
770
- */
1217
+ /** @type {GetJsdocTagsDeep} */
771
1218
  utils.getJsdocTagsDeep = tagName => {
772
- const name = utils.getPreferredTagName({
1219
+ const name = /** @type {string|false} */utils.getPreferredTagName({
773
1220
  tagName
774
1221
  });
775
1222
  if (!name) {
@@ -778,14 +1225,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
778
1225
  return _jsdocUtils.default.getJsdocTagsDeep(jsdoc, name);
779
1226
  };
780
1227
 
781
- /**
782
- * @param {{
783
- * tagName: string,
784
- * skipReportingBlockedTag?: boolean,
785
- * allowObjectReturn?: boolean,
786
- * defaultMessage?: string
787
- * }} cfg
788
- */
1228
+ /** @type {GetPreferredTagName} */
789
1229
  utils.getPreferredTagName = ({
790
1230
  tagName,
791
1231
  skipReportingBlockedTag = false,
@@ -808,56 +1248,39 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
808
1248
  return isObject && !allowObjectReturn ? ret.replacement : ret;
809
1249
  };
810
1250
 
811
- /**
812
- * @param {string} name
813
- * @param {string[]} definedTags
814
- * @returns {boolean}
815
- */
1251
+ /** @type {IsValidTag} */
816
1252
  utils.isValidTag = (name, definedTags) => {
817
1253
  return _jsdocUtils.default.isValidTag(context, mode, name, definedTags);
818
1254
  };
819
1255
 
820
- /**
821
- * @param {string[]} names
822
- * @returns {boolean}
823
- */
1256
+ /** @type {HasATag} */
824
1257
  utils.hasATag = names => {
825
1258
  return _jsdocUtils.default.hasATag(jsdoc, names);
826
1259
  };
827
1260
 
828
- /**
829
- * @param {string} name
830
- * @returns {boolean}
831
- */
1261
+ /** @type {HasTag} */
832
1262
  utils.hasTag = name => {
833
1263
  return _jsdocUtils.default.hasTag(jsdoc, name);
834
1264
  };
835
1265
 
836
- /**
837
- * @param {string} name
838
- * @returns {}
839
- */
1266
+ /** @type {ComparePaths} */
840
1267
  utils.comparePaths = name => {
841
1268
  return _jsdocUtils.default.comparePaths(name);
842
1269
  };
843
1270
 
844
- /**
845
- * @param {string} name
846
- * @returns {}
847
- */
1271
+ /** @type {DropPathSegmentQuotes} */
848
1272
  utils.dropPathSegmentQuotes = name => {
849
1273
  return _jsdocUtils.default.dropPathSegmentQuotes(name);
850
1274
  };
851
1275
 
852
- /**
853
- * @returns {boolean}
854
- */
1276
+ /** @type {AvoidDocs} */
855
1277
  utils.avoidDocs = () => {
856
1278
  var _context$options$;
857
1279
  if (ignoreReplacesDocs !== false && (utils.hasTag('ignore') || utils.classHasTag('ignore')) || overrideReplacesDocs !== false && (utils.hasTag('override') || utils.classHasTag('override')) || implementsReplacesDocs !== false && (utils.hasTag('implements') || utils.classHasTag('implements')) || augmentsExtendsReplacesDocs && (utils.hasATag(['augments', 'extends']) || utils.classHasTag('augments') || utils.classHasTag('extends'))) {
858
1280
  return true;
859
1281
  }
860
- if (_jsdocUtils.default.exemptSpeciaMethods(jsdoc, node, context, ruleConfig.meta.schema)) {
1282
+ if (_jsdocUtils.default.exemptSpeciaMethods(jsdoc, node, context, /** @type {import('json-schema').JSONSchema4|import('json-schema').JSONSchema4[]} */
1283
+ ruleConfig.meta.schema)) {
861
1284
  return true;
862
1285
  }
863
1286
  const exemptedBy = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.exemptedBy) ?? ['inheritDoc', ...(mode === 'closure' ? [] : ['inheritdoc'])];
@@ -867,12 +1290,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
867
1290
  return false;
868
1291
  };
869
1292
  for (const method of ['tagMightHaveNamePosition', 'tagMightHaveTypePosition']) {
870
- /**
871
- * @param {string} tagName
872
- * @param {import('./getDefaultTagStructureForMode.js').
873
- * TagStructure[]} [otherModeMaps]
874
- * @returns {boolean|{otherMode: true}}
875
- */
1293
+ /** @type {TagMightHaveNamePositionTypePosition} */
876
1294
  utils[/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
877
1295
  method] = (tagName, otherModeMaps) => {
878
1296
  const result = _jsdocUtils.default[/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
@@ -892,16 +1310,25 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
892
1310
  } : false;
893
1311
  };
894
1312
  }
895
- for (const method of ['tagMustHaveNamePosition', 'tagMustHaveTypePosition', 'tagMissingRequiredTypeOrNamepath']) {
896
- /**
897
- * @param {string} tagName
898
- * @param {import('./getDefaultTagStructureForMode.js').
899
- * TagStructure[]} otherModeMaps
900
- * @returns {}
901
- */
902
- utils[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"|"tagMissingRequiredTypeOrNamepath"} */
1313
+
1314
+ /** @type {TagMissingRequiredTypeOrNamepath} */
1315
+ utils.tagMissingRequiredTypeOrNamepath = (tagName, otherModeMaps) => {
1316
+ const result = _jsdocUtils.default.tagMissingRequiredTypeOrNamepath(tagName);
1317
+ if (!result) {
1318
+ return false;
1319
+ }
1320
+ const otherResult = otherModeMaps.every(otherModeMap => {
1321
+ return _jsdocUtils.default.tagMissingRequiredTypeOrNamepath(tagName, otherModeMap);
1322
+ });
1323
+ return otherResult ? true : {
1324
+ otherMode: false
1325
+ };
1326
+ };
1327
+ for (const method of ['tagMustHaveNamePosition', 'tagMustHaveTypePosition']) {
1328
+ /** @type {TagMustHave} */
1329
+ utils[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
903
1330
  method] = (tagName, otherModeMaps) => {
904
- const result = _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"|"tagMissingRequiredTypeOrNamepath"} */
1331
+ const result = _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
905
1332
  method](tagName);
906
1333
  if (!result) {
907
1334
  return false;
@@ -910,7 +1337,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
910
1337
  // if (!otherModeMaps) { return true; }
911
1338
 
912
1339
  const otherResult = otherModeMaps.every(otherModeMap => {
913
- return _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"|"tagMissingRequiredTypeOrNamepath"} */
1340
+ return _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
914
1341
  method](tagName, otherModeMap);
915
1342
  });
916
1343
  return otherResult ? true : {
@@ -919,102 +1346,104 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
919
1346
  };
920
1347
  }
921
1348
  for (const method of ['isNamepathDefiningTag', 'isNamepathReferencingTag', 'isNamepathOrUrlReferencingTag', 'tagMightHaveNamepath']) {
922
- /**
923
- * @param {string} tagName
924
- * @returns {}
925
- */
926
- utils[method] = tagName => {
927
- return _jsdocUtils.default[method](tagName);
1349
+ /** @type {IsNamepathX} */
1350
+ utils[/** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */
1351
+ method] = tagName => {
1352
+ return _jsdocUtils.default[/** @type {"isNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNamepath"} */
1353
+ method](tagName);
928
1354
  };
929
1355
  }
930
1356
 
931
- /**
932
- * @param {import('./jsdocUtils.js').ParserMode} mde
933
- * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
934
- */
1357
+ /** @type {GetTagStructureForMode} */
935
1358
  utils.getTagStructureForMode = mde => {
936
1359
  return _jsdocUtils.default.getTagStructureForMode(mde, settings.structuredTags);
937
1360
  };
938
1361
 
939
- /**
940
- * @param {} tag
941
- * @returns {}
942
- */
1362
+ /** @type {MayBeUndefinedTypeTag} */
943
1363
  utils.mayBeUndefinedTypeTag = tag => {
944
1364
  return _jsdocUtils.default.mayBeUndefinedTypeTag(tag, settings.mode);
945
1365
  };
1366
+
1367
+ /** @type {HasValueOrExecutorHasNonEmptyResolveValue} */
946
1368
  utils.hasValueOrExecutorHasNonEmptyResolveValue = (anyPromiseAsReturn, allBranches) => {
947
- return _jsdocUtils.default.hasValueOrExecutorHasNonEmptyResolveValue(node, anyPromiseAsReturn, allBranches);
1369
+ return _jsdocUtils.default.hasValueOrExecutorHasNonEmptyResolveValue( /** @type {Node} */node, anyPromiseAsReturn, allBranches);
948
1370
  };
949
1371
 
950
- /**
951
- * @returns {boolean}
952
- */
1372
+ /** @type {HasYieldValue} */
953
1373
  utils.hasYieldValue = () => {
954
- if (['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes(node.type)) {
955
- return _jsdocUtils.default.hasYieldValue(node.declaration);
1374
+ if (['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes( /** @type {Node} */node.type)) {
1375
+ return _jsdocUtils.default.hasYieldValue( /** @type {import('estree').Declaration|import('estree').Expression} */
1376
+ /** @type {import('estree').ExportNamedDeclaration|import('estree').ExportDefaultDeclaration} */
1377
+ node.declaration);
956
1378
  }
957
- return _jsdocUtils.default.hasYieldValue(node);
1379
+ return _jsdocUtils.default.hasYieldValue( /** @type {Node} */node);
958
1380
  };
959
1381
 
960
- /**
961
- * @returns {boolean}
962
- */
1382
+ /** @type {HasYieldReturnValue} */
963
1383
  utils.hasYieldReturnValue = () => {
964
- return _jsdocUtils.default.hasYieldValue(node, true);
1384
+ return _jsdocUtils.default.hasYieldValue( /** @type {Node} */node, true);
965
1385
  };
966
1386
 
967
- /**
968
- * @returns {boolean}
969
- */
1387
+ /** @type {HasThrowValue} */
970
1388
  utils.hasThrowValue = () => {
971
1389
  return _jsdocUtils.default.hasThrowValue(node);
972
1390
  };
973
1391
 
974
- /**
975
- * @returns {boolean}
976
- */
1392
+ /** @type {IsAsync} */
977
1393
  utils.isAsync = () => {
978
- return node.async;
1394
+ return 'async' in /** @type {Node} */node && node.async;
979
1395
  };
1396
+
1397
+ /** @type {GetTags} */
980
1398
  utils.getTags = tagName => {
981
1399
  return utils.filterTags(item => {
982
1400
  return item.tag === tagName;
983
1401
  });
984
1402
  };
1403
+
1404
+ /** @type {GetPresentTags} */
985
1405
  utils.getPresentTags = tagList => {
986
1406
  return utils.filterTags(tag => {
987
1407
  return tagList.includes(tag.tag);
988
1408
  });
989
1409
  };
990
- utils.filterTags = (filter, includeInlineTags = false) => {
991
- const tags = _jsdocUtils.default.getAllTags(jsdoc, includeInlineTags);
992
- return _jsdocUtils.default.filterTags(tags, filter);
1410
+
1411
+ /** @type {FilterTags} */
1412
+ utils.filterTags = filter => {
1413
+ return jsdoc.tags.filter(tag => {
1414
+ return filter(tag);
1415
+ });
993
1416
  };
994
1417
 
995
- /**
996
- * @param {import('comment-parser').Spec[]} tags
997
- * @returns {}
998
- */
1418
+ /** @type {FilterAllTags} */
1419
+ utils.filterAllTags = filter => {
1420
+ const tags = _jsdocUtils.default.getAllTags(jsdoc);
1421
+ return tags.filter(tag => {
1422
+ return filter(tag);
1423
+ });
1424
+ };
1425
+
1426
+ /** @type {GetTagsByType} */
999
1427
  utils.getTagsByType = tags => {
1000
1428
  return _jsdocUtils.default.getTagsByType(context, mode, tags, tagNamePreference);
1001
1429
  };
1002
1430
 
1003
- /**
1004
- * @param {string} tagName
1005
- * @returns {boolean}
1006
- */
1431
+ /** @type {HasOptionTag} */
1007
1432
  utils.hasOptionTag = tagName => {
1008
1433
  const {
1009
1434
  tags
1010
1435
  } = context.options[0] ?? {};
1011
1436
  return Boolean(tags && tags.includes(tagName));
1012
1437
  };
1438
+
1439
+ /** @type {GetClassNode} */
1013
1440
  utils.getClassNode = () => {
1014
1441
  return [...ancestors, node].reverse().find(parent => {
1015
1442
  return parent && ['ClassDeclaration', 'ClassExpression'].includes(parent.type);
1016
- }) || null;
1443
+ }) ?? null;
1017
1444
  };
1445
+
1446
+ /** @type {GetClassJsdoc} */
1018
1447
  utils.getClassJsdoc = () => {
1019
1448
  const classNode = utils.getClassNode();
1020
1449
  if (!classNode) {
@@ -1029,12 +1458,17 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
1029
1458
  }
1030
1459
  return null;
1031
1460
  };
1461
+
1462
+ /** @type {ClassHasTag} */
1032
1463
  utils.classHasTag = tagName => {
1033
1464
  const classJsdoc = utils.getClassJsdoc();
1034
- return Boolean(classJsdoc) && _jsdocUtils.default.hasTag(classJsdoc, tagName);
1465
+ return classJsdoc !== null && _jsdocUtils.default.hasTag(classJsdoc, tagName);
1035
1466
  };
1467
+
1468
+ /** @type {ForEachPreferredTag} */
1036
1469
  utils.forEachPreferredTag = (tagName, arrayHandler, skipReportingBlockedTag = false) => {
1037
- const targetTagName = utils.getPreferredTagName({
1470
+ const targetTagName = /** @type {string|false} */
1471
+ utils.getPreferredTagName({
1038
1472
  skipReportingBlockedTag,
1039
1473
  tagName
1040
1474
  });
@@ -1047,25 +1481,52 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
1047
1481
  return tag === targetTagName;
1048
1482
  });
1049
1483
  for (const matchingJsdocTag of matchingJsdocTags) {
1050
- arrayHandler(matchingJsdocTag, targetTagName);
1484
+ arrayHandler(
1485
+ /**
1486
+ * @type {import('@es-joy/jsdoccomment').JsdocTagWithInline}
1487
+ */
1488
+ matchingJsdocTag, targetTagName);
1051
1489
  }
1052
1490
  };
1053
1491
  return utils;
1054
1492
  };
1055
1493
 
1056
- /* eslint-disable jsdoc/valid-types -- Old version */
1494
+ /**
1495
+ * @typedef {{
1496
+ * [key: string]: false|string|{
1497
+ * message: string,
1498
+ * replacement?: false|string
1499
+ * skipRootChecking?: boolean
1500
+ * }
1501
+ * }} PreferredTypes
1502
+ */
1503
+ /**
1504
+ * @typedef {{
1505
+ * [key: string]: {
1506
+ * name?: "text"|"namepath-defining"|"namepath-referencing"|false,
1507
+ * type?: boolean|string[],
1508
+ * required?: ("name"|"type"|"typeOrNameRequired")[]
1509
+ * }
1510
+ * }} StructuredTags
1511
+ */
1057
1512
  /**
1058
1513
  * Settings from ESLint types.
1059
- *
1060
1514
  * @typedef {{
1061
- * [name: string]: any
1515
+ * maxLines: Integer,
1516
+ * minLines: Integer,
1517
+ * tagNamePreference: import('./jsdocUtils.js').TagNamePreference,
1518
+ * mode: import('./jsdocUtils.js').ParserMode,
1519
+ * preferredTypes: PreferredTypes,
1520
+ * structuredTags: StructuredTags,
1521
+ * [name: string]: any,
1522
+ * contexts?: Context[]
1062
1523
  * }} Settings
1063
1524
  */
1064
1525
  /* eslint-enable jsdoc/valid-types -- Old version */
1065
1526
 
1066
1527
  /**
1067
1528
  * @param {import('eslint').Rule.RuleContext} context
1068
- * @returns {Settings}
1529
+ * @returns {Settings|false}
1069
1530
  */
1070
1531
  const getSettings = context => {
1071
1532
  var _context$settings$jsd, _context$settings$jsd2, _context$settings$jsd3, _context$settings$jsd4, _context$settings$jsd5, _context$settings$jsd6, _context$settings$jsd7, _context$settings$jsd8, _context$settings$jsd9, _context$settings$jsd10, _context$settings$jsd11, _context$settings$jsd12, _context$settings$jsd13, _context$settings$jsd14;
@@ -1103,12 +1564,16 @@ const getSettings = context => {
1103
1564
  } catch (error) {
1104
1565
  context.report({
1105
1566
  loc: {
1567
+ end: {
1568
+ column: 1,
1569
+ line: 1
1570
+ },
1106
1571
  start: {
1107
1572
  column: 1,
1108
1573
  line: 1
1109
1574
  }
1110
1575
  },
1111
- message: error.message
1576
+ message: /** @type {Error} */error.message
1112
1577
  });
1113
1578
  return false;
1114
1579
  }
@@ -1117,30 +1582,24 @@ const getSettings = context => {
1117
1582
 
1118
1583
  /**
1119
1584
  * Create the report function
1120
- *
1585
+ * @callback MakeReport
1121
1586
  * @param {import('eslint').Rule.RuleContext} context
1122
- * @param {object} commentNode
1587
+ * @param {import('estree').Node} commentNode
1588
+ * @returns {Report}
1123
1589
  */
1590
+
1591
+ /** @type {MakeReport} */
1124
1592
  exports.getSettings = getSettings;
1125
1593
  const makeReport = (context, commentNode) => {
1126
- /* eslint-disable jsdoc/valid-types -- Old version */
1127
- /**
1128
- * @param {string} message
1129
- * @param {import('eslint').Rule.ReportFixer|null} fix
1130
- * @param {} jsdocLoc
1131
- * @param {undefined|{
1132
- * [key: string]: string
1133
- * }} data
1134
- * @returns {void}
1135
- */
1594
+ /** @type {Report} */
1136
1595
  const report = (message, fix = null, jsdocLoc = null, data = undefined) => {
1137
1596
  /* eslint-enable jsdoc/valid-types -- Old version */
1138
1597
  let loc;
1139
1598
  if (jsdocLoc) {
1140
1599
  if (!('line' in jsdocLoc)) {
1141
- jsdocLoc.line = jsdocLoc.source[0].number;
1600
+ jsdocLoc.line = /** @type {import('comment-parser').Spec & {line?: Integer}} */jsdocLoc.source[0].number;
1142
1601
  }
1143
- const lineNumber = commentNode.loc.start.line + jsdocLoc.line;
1602
+ const lineNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.line + /** @type {Integer} */jsdocLoc.line;
1144
1603
  loc = {
1145
1604
  end: {
1146
1605
  column: 0,
@@ -1154,8 +1613,8 @@ const makeReport = (context, commentNode) => {
1154
1613
 
1155
1614
  // Todo: Remove ignore once `check-examples` can be restored for ESLint 8+
1156
1615
  // istanbul ignore if
1157
- if (jsdocLoc.column) {
1158
- const colNumber = commentNode.loc.start.column + jsdocLoc.column;
1616
+ if ('column' in jsdocLoc && typeof jsdocLoc.column === 'number') {
1617
+ const colNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.column + jsdocLoc.column;
1159
1618
  loc.end.column = colNumber;
1160
1619
  loc.start.column = colNumber;
1161
1620
  }
@@ -1171,43 +1630,86 @@ const makeReport = (context, commentNode) => {
1171
1630
  return report;
1172
1631
  };
1173
1632
 
1174
- /* eslint-disable jsdoc/no-undefined-types -- canonical still using an older version where not defined */
1175
1633
  /**
1176
- * @typedef {ReturnType<typeof getUtils>} Utils
1634
+ * @typedef {(
1635
+ * arg: {
1636
+ * context: import('eslint').Rule.RuleContext,
1637
+ * sourceCode: import('eslint').SourceCode,
1638
+ * indent?: string,
1639
+ * info?: {
1640
+ * comment?: string|undefined,
1641
+ * lastIndex?: Integer|undefined
1642
+ * },
1643
+ * state?: StateObject,
1644
+ * globalState?: Map<string, Map<string, string>>,
1645
+ * jsdoc?: JsdocBlockWithInline,
1646
+ * jsdocNode?: import('eslint').Rule.Node & {
1647
+ * range: [number, number]
1648
+ * },
1649
+ * node?: Node,
1650
+ * allComments?: import('estree').Node[]
1651
+ * report?: Report,
1652
+ * makeReport?: MakeReport,
1653
+ * settings: Settings,
1654
+ * utils: BasicUtils,
1655
+ * }
1656
+ * ) => any } JsdocVisitorBasic
1657
+ */
1658
+ /**
1177
1659
  * @typedef {(
1178
1660
  * arg: {
1179
1661
  * context: import('eslint').Rule.RuleContext,
1180
1662
  * sourceCode: import('eslint').SourceCode,
1181
1663
  * indent: string,
1182
- * jsdoc: object,
1183
- * jsdocNode: object,
1184
- * node: Node | null,
1185
- * report: ReturnType<typeof makeReport>,
1664
+ * info: {
1665
+ * comment?: string|undefined,
1666
+ * lastIndex?: Integer|undefined
1667
+ * },
1668
+ * state: StateObject,
1669
+ * globalState: Map<string, Map<string, string>>,
1670
+ * jsdoc: JsdocBlockWithInline,
1671
+ * jsdocNode: import('eslint').Rule.Node & {
1672
+ * range: [number, number]
1673
+ * },
1674
+ * node: Node|null,
1675
+ * allComments?: import('estree').Node[]
1676
+ * report: Report,
1677
+ * makeReport?: MakeReport,
1186
1678
  * settings: Settings,
1187
1679
  * utils: Utils,
1188
1680
  * }
1189
1681
  * ) => any } JsdocVisitor
1190
1682
  */
1683
+ /* eslint-enable jsdoc/valid-types -- Old version */
1191
1684
  /* eslint-enable jsdoc/no-undefined-types -- canonical still using an older version where not defined */
1192
1685
 
1193
1686
  /**
1194
- * @param {} info
1195
- * @param {} indent
1196
- * @param {import('comment-parser').Block} jsdoc
1197
- * @param {} ruleConfig
1687
+ * @param {{
1688
+ * comment?: string,
1689
+ * lastIndex?: Integer,
1690
+ * selector?: string,
1691
+ * isFunctionContext?: boolean,
1692
+ * }} info
1693
+ * @param {string} indent
1694
+ * @param {JsdocBlockWithInline} jsdoc
1695
+ * @param {RuleConfig} ruleConfig
1198
1696
  * @param {import('eslint').Rule.RuleContext} context
1199
- * @param {} lines
1697
+ * @param {string[]} lines
1200
1698
  * @param {import('@es-joy/jsdoccomment').Token} jsdocNode
1201
- * @param {} node
1699
+ * @param {Node|null} node
1202
1700
  * @param {Settings} settings
1203
1701
  * @param {import('eslint').SourceCode} sourceCode
1204
- * @param {} iterator
1205
- * @param {} state
1206
- * @param {boolean} iteratingAll
1702
+ * @param {JsdocVisitor} iterator
1703
+ * @param {StateObject} state
1704
+ * @param {boolean} [iteratingAll]
1705
+ * @returns {void}
1207
1706
  */
1208
1707
  const iterate = (info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, settings, sourceCode, iterator, state, iteratingAll) => {
1209
- const report = makeReport(context, jsdocNode);
1210
- const utils = getUtils(node, jsdoc, jsdocNode, settings, report, context, iteratingAll, ruleConfig, indent);
1708
+ const jsdocNde = /** @type {unknown} */jsdocNode;
1709
+ const report = makeReport(context, /** @type {import('estree').Node} */
1710
+ jsdocNde);
1711
+ const utils = getUtils(node, jsdoc, /** @type {import('eslint').AST.Token} */
1712
+ jsdocNode, settings, report, context, iteratingAll, ruleConfig, indent);
1211
1713
  if (!ruleConfig.checkInternal && settings.ignoreInternal && utils.hasTag('internal')) {
1212
1714
  return;
1213
1715
  }
@@ -1227,9 +1729,13 @@ const iterate = (info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, nod
1227
1729
  globalState,
1228
1730
  indent,
1229
1731
  info,
1230
- iteratingAll,
1231
1732
  jsdoc,
1232
- jsdocNode,
1733
+ jsdocNode:
1734
+ /**
1735
+ * @type {import('eslint').Rule.Node & {
1736
+ * range: [number, number];}}
1737
+ */
1738
+ jsdocNde,
1233
1739
  node,
1234
1740
  report,
1235
1741
  settings,
@@ -1240,22 +1746,24 @@ const iterate = (info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, nod
1240
1746
  };
1241
1747
 
1242
1748
  /**
1243
- * @param {} lines
1244
- * @param {import('@es-joy/jsdoccomment').Token} jsdocNode
1245
- * @returns {[indent: string, jsdoc: import('comment-parser').Block & {
1246
- * inlineTags: import('@es-joy/jsdoccomment').JsdocInlineTagNoType[]
1247
- * }]}
1749
+ * @param {string[]} lines
1750
+ * @param {import('estree').Comment} jsdocNode
1751
+ * @returns {[indent: string, jsdoc: JsdocBlockWithInline]}
1248
1752
  */
1249
1753
  const getIndentAndJSDoc = function (lines, jsdocNode) {
1250
- const sourceLine = lines[jsdocNode.loc.start.line - 1];
1251
- const indnt = sourceLine.charAt(0).repeat(jsdocNode.loc.start.column);
1754
+ const sourceLine = lines[/** @type {import('estree').SourceLocation} */
1755
+ jsdocNode.loc.start.line - 1];
1756
+ const indnt = sourceLine.charAt(0).repeat( /** @type {import('estree').SourceLocation} */
1757
+ jsdocNode.loc.start.column);
1252
1758
  const jsdc = (0, _jsdoccomment.parseComment)(jsdocNode, '');
1253
1759
  return [indnt, jsdc];
1254
1760
  };
1255
1761
 
1256
1762
  /**
1257
1763
  *
1258
- * @typedef {{node: Node, state: StateObject}} NonCommentArgs
1764
+ * @typedef {{node: Node & {
1765
+ * range: [number, number]
1766
+ * }, state: StateObject}} NonCommentArgs
1259
1767
  */
1260
1768
 
1261
1769
  /**
@@ -1265,43 +1773,68 @@ const getIndentAndJSDoc = function (lines, jsdocNode) {
1265
1773
  * @property {true} [contextSelected] Whether to force a `contexts` check
1266
1774
  * @property {true} [iterateAllJsdocs] Whether to iterate all JSDoc blocks by default
1267
1775
  * regardless of context
1268
- * @property {(context, state: StateObject, utils: Utils) => void} [exit] Handler to be executed
1269
- * upon exiting iteration of program AST
1270
- * @property {(NonCommentArgs) => void} [nonComment] Handler to be executed if rule wishes
1776
+ * @property {true} [checkPrivate] Whether to check `@private` blocks (normally exempted)
1777
+ * @property {true} [checkInternal] Whether to check `@internal` blocks (normally exempted)
1778
+ * @property {true} [checkFile] Whether to iterates over all JSDoc blocks regardless of attachment
1779
+ * @property {true} [nonGlobalSettings] Whether to avoid relying on settings for global contexts
1780
+ * @property {true} [noTracking] Whether to disable the tracking of visited comment nodes (as
1781
+ * non-tracked may conduct further actions)
1782
+ * @property {true} [matchContext] Whether the rule expects contexts to be based on a match option
1783
+ * @property {(args: {
1784
+ * context: import('eslint').Rule.RuleContext,
1785
+ * state: StateObject,
1786
+ * settings: Settings,
1787
+ * utils: BasicUtils
1788
+ * }) => void} [exit] Handler to be executed upon exiting iteration of program AST
1789
+ * @property {(nca: NonCommentArgs) => void} [nonComment] Handler to be executed if rule wishes
1271
1790
  * to be supplied nodes without comments
1272
1791
  */
1273
1792
 
1274
1793
  /**
1275
1794
  * Create an eslint rule that iterates over all JSDocs, regardless of whether
1276
1795
  * they are attached to a function-like node.
1277
- *
1278
1796
  * @param {JsdocVisitor} iterator
1279
1797
  * @param {RuleConfig} ruleConfig The rule's configuration
1280
- * @param contexts The `contexts` containing relevant `comment` info.
1281
- * @param {boolean} additiveCommentContexts If true, will have a separate
1798
+ * @param {ContextObject[]|null} [contexts] The `contexts` containing relevant `comment` info.
1799
+ * @param {boolean} [additiveCommentContexts] If true, will have a separate
1282
1800
  * iteration for each matching comment context. Otherwise, will iterate
1283
1801
  * once if there is a single matching comment context.
1284
1802
  * @returns {import('eslint').Rule.RuleModule}
1285
1803
  */
1286
1804
  const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContexts) => {
1287
1805
  const trackedJsdocs = new Set();
1806
+
1807
+ /** @type {import('@es-joy/jsdoccomment').CommentHandler} */
1288
1808
  let handler;
1809
+
1810
+ /** @type {Settings|false} */
1289
1811
  let settings;
1812
+
1813
+ /**
1814
+ * @param {import('eslint').Rule.RuleContext} context
1815
+ * @param {Node|null} node
1816
+ * @param {import('estree').Comment[]} jsdocNodes
1817
+ * @param {StateObject} state
1818
+ * @param {boolean} [lastCall]
1819
+ * @returns {void}
1820
+ */
1290
1821
  const callIterator = (context, node, jsdocNodes, state, lastCall) => {
1291
1822
  const sourceCode = context.getSourceCode();
1292
1823
  const {
1293
1824
  lines
1294
1825
  } = sourceCode;
1295
- const utils = getBasicUtils(context, settings);
1826
+ const utils = getBasicUtils(context, /** @type {Settings} */settings);
1296
1827
  for (const jsdocNode of jsdocNodes) {
1297
- if (!/^\/\*\*\s/u.test(sourceCode.getText(jsdocNode))) {
1828
+ const jsdocNde = /** @type {unknown} */jsdocNode;
1829
+ if (!/^\/\*\*\s/u.test(sourceCode.getText( /** @type {import('estree').Node} */
1830
+ jsdocNde))) {
1298
1831
  continue;
1299
1832
  }
1300
1833
  const [indent, jsdoc] = getIndentAndJSDoc(lines, jsdocNode);
1301
1834
  if (additiveCommentContexts) {
1302
1835
  for (const [idx, {
1303
1836
  comment
1304
- }] of contexts.entries()) {
1837
+ }] of /** @type {ContextObject[]} */contexts.entries()) {
1305
1838
  if (comment && handler(comment, jsdoc) === false) {
1306
1839
  continue;
1307
1840
  }
@@ -1309,7 +1842,9 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
1309
1842
  comment,
1310
1843
  lastIndex: idx,
1311
1844
  selector: node === null || node === void 0 ? void 0 : node.type
1312
- }, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, settings, sourceCode, iterator, state, true);
1845
+ }, indent, jsdoc, ruleConfig, context, lines, jsdocNode, /** @type {Node} */
1846
+ node, /** @type {Settings} */
1847
+ settings, sourceCode, iterator, state, true);
1313
1848
  }
1314
1849
  continue;
1315
1850
  }
@@ -1332,18 +1867,21 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
1332
1867
  } : {
1333
1868
  lastIndex,
1334
1869
  selector: node === null || node === void 0 ? void 0 : node.type
1335
- }, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, settings, sourceCode, iterator, state, true);
1870
+ }, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, /** @type {Settings} */
1871
+ settings, sourceCode, iterator, state, true);
1336
1872
  }
1873
+ const settngs = /** @type {Settings} */settings;
1337
1874
  if (lastCall && ruleConfig.exit) {
1338
1875
  ruleConfig.exit({
1339
1876
  context,
1340
- settings,
1877
+ settings: settngs,
1341
1878
  state,
1342
1879
  utils
1343
1880
  });
1344
1881
  }
1345
1882
  };
1346
1883
  return {
1884
+ // @ts-expect-error ESLint accepts
1347
1885
  create(context) {
1348
1886
  const sourceCode = context.getSourceCode();
1349
1887
  settings = getSettings(context);
@@ -1355,29 +1893,38 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
1355
1893
  }
1356
1894
  const state = {};
1357
1895
  return {
1896
+ /**
1897
+ * @param {import('eslint').Rule.Node & {
1898
+ * range: [Integer, Integer];
1899
+ * }} node
1900
+ * @returns {void}
1901
+ */
1358
1902
  '*:not(Program)'(node) {
1359
- const commentNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings);
1903
+ const commentNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, /** @type {Settings} */settings);
1360
1904
  if (!ruleConfig.noTracking && trackedJsdocs.has(commentNode)) {
1361
1905
  return;
1362
1906
  }
1363
1907
  if (!commentNode) {
1364
1908
  if (ruleConfig.nonComment) {
1909
+ const ste = /** @type {StateObject} */state;
1365
1910
  ruleConfig.nonComment({
1366
1911
  node,
1367
- state
1912
+ state: ste
1368
1913
  });
1369
1914
  }
1370
1915
  return;
1371
1916
  }
1372
1917
  trackedJsdocs.add(commentNode);
1373
- callIterator(context, node, [commentNode], state);
1918
+ callIterator(context, node, [/** @type {import('estree').Comment} */
1919
+ commentNode], /** @type {StateObject} */state);
1374
1920
  },
1375
1921
  'Program:exit'() {
1376
1922
  const allComments = sourceCode.getAllComments();
1377
1923
  const untrackedJSdoc = allComments.filter(node => {
1378
1924
  return !trackedJsdocs.has(node);
1379
1925
  });
1380
- callIterator(context, null, untrackedJSdoc, state, true);
1926
+ callIterator(context, null, untrackedJSdoc, /** @type {StateObject} */
1927
+ state, true);
1381
1928
  }
1382
1929
  };
1383
1930
  },
@@ -1388,8 +1935,7 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
1388
1935
  /**
1389
1936
  * Create an eslint rule that iterates over all JSDocs, regardless of whether
1390
1937
  * they are attached to a function-like node.
1391
- *
1392
- * @param {JsdocVisitor} iterator
1938
+ * @param {JsdocVisitorBasic} iterator
1393
1939
  * @param {RuleConfig} ruleConfig
1394
1940
  * @returns {import('eslint').Rule.RuleModule}
1395
1941
  */
@@ -1403,15 +1949,11 @@ const checkFile = (iterator, ruleConfig) => {
1403
1949
  }
1404
1950
  return {
1405
1951
  'Program:exit'() {
1406
- const allComments = sourceCode.getAllComments();
1407
- const {
1408
- lines
1409
- } = sourceCode;
1952
+ const allComms = /** @type {unknown} */sourceCode.getAllComments();
1410
1953
  const utils = getBasicUtils(context, settings);
1411
1954
  iterator({
1412
- allComments,
1955
+ allComments: /** @type {import('estree').Node[]} */allComms,
1413
1956
  context,
1414
- lines,
1415
1957
  makeReport,
1416
1958
  settings,
1417
1959
  sourceCode,
@@ -1438,7 +1980,7 @@ function iterateJsdoc(iterator, ruleConfig) {
1438
1980
  throw new TypeError('The iterator argument must be a function.');
1439
1981
  }
1440
1982
  if (ruleConfig.checkFile) {
1441
- return checkFile(iterator, ruleConfig);
1983
+ return checkFile( /** @type {JsdocVisitorBasic} */iterator, ruleConfig);
1442
1984
  }
1443
1985
  if (ruleConfig.iterateAllJsdocs) {
1444
1986
  return iterateAllJsdocs(iterator, ruleConfig);
@@ -1448,19 +1990,23 @@ function iterateJsdoc(iterator, ruleConfig) {
1448
1990
  return {
1449
1991
  /**
1450
1992
  * The entrypoint for the JSDoc rule.
1451
- *
1452
1993
  * @param {import('eslint').Rule.RuleContext} context
1453
1994
  * a reference to the context which hold all important information
1454
1995
  * like settings and the sourcecode to check.
1455
1996
  * @returns {import('eslint').Rule.RuleListener}
1456
- * a list with parser callback function.
1997
+ * a listener with parser callback function.
1457
1998
  */
1458
1999
  create(context) {
1459
2000
  const settings = getSettings(context);
1460
2001
  if (!settings) {
1461
2002
  return {};
1462
2003
  }
2004
+
2005
+ /**
2006
+ * @type {Context[]|undefined}
2007
+ */
1463
2008
  let contexts;
2009
+ /* eslint-enable jsdoc/valid-types -- Old version */
1464
2010
  if (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext) {
1465
2011
  var _context$options$2, _contexts, _contexts2;
1466
2012
  contexts = ruleConfig.matchContext && (_context$options$2 = context.options[0]) !== null && _context$options$2 !== void 0 && _context$options$2.match ? context.options[0].match : _jsdocUtils.default.enforcedContexts(context, ruleConfig.contextDefaults, ruleConfig.nonGlobalSettings ? {} : settings);
@@ -1477,23 +2023,32 @@ function iterateJsdoc(iterator, ruleConfig) {
1477
2023
  }
1478
2024
  const hasPlainAny = (_contexts = contexts) === null || _contexts === void 0 ? void 0 : _contexts.includes('any');
1479
2025
  const hasObjectAny = !hasPlainAny && ((_contexts2 = contexts) === null || _contexts2 === void 0 ? void 0 : _contexts2.find(ctxt => {
2026
+ if (typeof ctxt === 'string') {
2027
+ return false;
2028
+ }
1480
2029
  return (ctxt === null || ctxt === void 0 ? void 0 : ctxt.context) === 'any';
1481
2030
  }));
1482
2031
  if (hasPlainAny || hasObjectAny) {
1483
- return iterateAllJsdocs(iterator, ruleConfig, hasObjectAny ? contexts : null, ruleConfig.matchContext).create(context);
2032
+ return iterateAllJsdocs(iterator, ruleConfig, hasObjectAny ? /** @type {ContextObject[]} */contexts : null, ruleConfig.matchContext).create(context);
1484
2033
  }
1485
2034
  }
1486
2035
  const sourceCode = context.getSourceCode();
1487
2036
  const {
1488
2037
  lines
1489
2038
  } = sourceCode;
2039
+
2040
+ /** @type {Partial<StateObject>} */
1490
2041
  const state = {};
2042
+ /* eslint-enable jsdoc/no-undefined-types -- TS */
2043
+
2044
+ /** @type {CheckJsdoc} */
1491
2045
  const checkJsdoc = (info, handler, node) => {
1492
2046
  const jsdocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings);
1493
2047
  if (!jsdocNode) {
1494
2048
  return;
1495
2049
  }
1496
- const [indent, jsdoc] = getIndentAndJSDoc(lines, jsdocNode);
2050
+ const [indent, jsdoc] = getIndentAndJSDoc(lines, /** @type {import('estree').Comment} */
2051
+ jsdocNode);
1497
2052
  if (
1498
2053
  // Note, `handler` should already be bound in its first argument
1499
2054
  // with these only to be called after the value of
@@ -1501,8 +2056,11 @@ function iterateJsdoc(iterator, ruleConfig) {
1501
2056
  handler && handler(jsdoc) === false) {
1502
2057
  return;
1503
2058
  }
1504
- iterate(info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, settings, sourceCode, iterator, state);
2059
+ iterate(info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, settings, sourceCode, iterator, /** @type {StateObject} */
2060
+ state);
1505
2061
  };
2062
+
2063
+ /** @type {import('eslint').Rule.RuleListener} */
1506
2064
  let contextObject = {};
1507
2065
  if (contexts && (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext)) {
1508
2066
  contextObject = _jsdocUtils.default.getContextObject(contexts, checkJsdoc, (0, _jsdoccomment.commentHandler)(settings));
@@ -1513,15 +2071,21 @@ function iterateJsdoc(iterator, ruleConfig) {
1513
2071
  }, null);
1514
2072
  }
1515
2073
  }
1516
- if (ruleConfig.exit) {
2074
+ if (typeof ruleConfig.exit === 'function') {
1517
2075
  contextObject['Program:exit'] = () => {
2076
+ const ste = /** @type {StateObject} */state;
2077
+
2078
+ // @ts-expect-error `utils` not needed at this point
2079
+ /** @type {Required<RuleConfig>} */
1518
2080
  ruleConfig.exit({
1519
2081
  context,
1520
2082
  settings,
1521
- state
2083
+ state: ste
1522
2084
  });
2085
+ /* eslint-enable jsdoc/no-undefined-types -- Bug */
1523
2086
  };
1524
2087
  }
2088
+
1525
2089
  return contextObject;
1526
2090
  },
1527
2091
  meta: ruleConfig.meta