eslint-plugin-jsdoc 44.2.3 → 44.2.4

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 (110) hide show
  1. package/dist/alignTransform.js +86 -4
  2. package/dist/alignTransform.js.map +1 -1
  3. package/dist/exportParser.js +134 -4
  4. package/dist/exportParser.js.map +1 -1
  5. package/dist/iterateJsdoc.js +936 -345
  6. package/dist/iterateJsdoc.js.map +1 -1
  7. package/dist/jsdocUtils.js +173 -105
  8. package/dist/jsdocUtils.js.map +1 -1
  9. package/dist/rules/checkAlignment.js +6 -0
  10. package/dist/rules/checkAlignment.js.map +1 -1
  11. package/dist/rules/checkExamples.js +70 -6
  12. package/dist/rules/checkExamples.js.map +1 -1
  13. package/dist/rules/checkIndentation.js +11 -1
  14. package/dist/rules/checkIndentation.js.map +1 -1
  15. package/dist/rules/checkLineAlignment.js +68 -4
  16. package/dist/rules/checkLineAlignment.js.map +1 -1
  17. package/dist/rules/checkParamNames.js +12 -7
  18. package/dist/rules/checkParamNames.js.map +1 -1
  19. package/dist/rules/checkPropertyNames.js +13 -7
  20. package/dist/rules/checkPropertyNames.js.map +1 -1
  21. package/dist/rules/checkTagNames.js +45 -5
  22. package/dist/rules/checkTagNames.js.map +1 -1
  23. package/dist/rules/checkTypes.js +97 -36
  24. package/dist/rules/checkTypes.js.map +1 -1
  25. package/dist/rules/checkValues.js +6 -6
  26. package/dist/rules/checkValues.js.map +1 -1
  27. package/dist/rules/emptyTags.js +8 -1
  28. package/dist/rules/emptyTags.js.map +1 -1
  29. package/dist/rules/informativeDocs.js +26 -7
  30. package/dist/rules/informativeDocs.js.map +1 -1
  31. package/dist/rules/matchDescription.js +18 -1
  32. package/dist/rules/matchDescription.js.map +1 -1
  33. package/dist/rules/matchName.js +2 -2
  34. package/dist/rules/matchName.js.map +1 -1
  35. package/dist/rules/multilineBlocks.js +12 -1
  36. package/dist/rules/multilineBlocks.js.map +1 -1
  37. package/dist/rules/noBadBlocks.js +3 -5
  38. package/dist/rules/noBadBlocks.js.map +1 -1
  39. package/dist/rules/noBlankBlockDescriptions.js +2 -0
  40. package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
  41. package/dist/rules/noMissingSyntax.js +58 -15
  42. package/dist/rules/noMissingSyntax.js.map +1 -1
  43. package/dist/rules/noMultiAsterisks.js +1 -6
  44. package/dist/rules/noMultiAsterisks.js.map +1 -1
  45. package/dist/rules/noRestrictedSyntax.js +17 -4
  46. package/dist/rules/noRestrictedSyntax.js.map +1 -1
  47. package/dist/rules/noTypes.js +3 -0
  48. package/dist/rules/noTypes.js.map +1 -1
  49. package/dist/rules/noUndefinedTypes.js +61 -20
  50. package/dist/rules/noUndefinedTypes.js.map +1 -1
  51. package/dist/rules/requireAsteriskPrefix.js +20 -0
  52. package/dist/rules/requireAsteriskPrefix.js.map +1 -1
  53. package/dist/rules/requireDescription.js +6 -2
  54. package/dist/rules/requireDescription.js.map +1 -1
  55. package/dist/rules/requireDescriptionCompleteSentence.js +72 -9
  56. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  57. package/dist/rules/requireFileOverview.js +9 -4
  58. package/dist/rules/requireFileOverview.js.map +1 -1
  59. package/dist/rules/requireHyphenBeforeParamDescription.js +23 -6
  60. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  61. package/dist/rules/requireJsdoc.js +144 -28
  62. package/dist/rules/requireJsdoc.js.map +1 -1
  63. package/dist/rules/requireParam.js +46 -2
  64. package/dist/rules/requireParam.js.map +1 -1
  65. package/dist/rules/requireProperty.js +1 -1
  66. package/dist/rules/requireProperty.js.map +1 -1
  67. package/dist/rules/requireReturns.js +2 -2
  68. package/dist/rules/requireReturns.js.map +1 -1
  69. package/dist/rules/requireReturnsCheck.js +9 -2
  70. package/dist/rules/requireReturnsCheck.js.map +1 -1
  71. package/dist/rules/requireThrows.js +2 -2
  72. package/dist/rules/requireThrows.js.map +1 -1
  73. package/dist/rules/requireYields.js +9 -2
  74. package/dist/rules/requireYields.js.map +1 -1
  75. package/dist/rules/requireYieldsCheck.js +19 -5
  76. package/dist/rules/requireYieldsCheck.js.map +1 -1
  77. package/dist/rules/sortTags.js +67 -9
  78. package/dist/rules/sortTags.js.map +1 -1
  79. package/dist/rules/tagLines.js +22 -3
  80. package/dist/rules/tagLines.js.map +1 -1
  81. package/dist/rules/textEscaping.js +16 -2
  82. package/dist/rules/textEscaping.js.map +1 -1
  83. package/dist/rules/validTypes.js +25 -8
  84. package/dist/rules/validTypes.js.map +1 -1
  85. package/dist/utils/hasReturnValue.js +77 -43
  86. package/dist/utils/hasReturnValue.js.map +1 -1
  87. package/docs/rules/check-tag-names.md +15 -0
  88. package/docs/rules/no-missing-syntax.md +6 -0
  89. package/docs/rules/require-description-complete-sentence.md +525 -289
  90. package/docs/rules/require-description.md +289 -525
  91. package/docs/rules/require-file-overview.md +7 -0
  92. package/docs/rules/require-jsdoc.md +1 -1
  93. package/docs/rules/require-param-description.md +116 -1694
  94. package/docs/rules/require-param-name.md +58 -133
  95. package/docs/rules/require-param-type.md +119 -55
  96. package/docs/rules/require-param.md +1700 -111
  97. package/docs/rules/require-property-description.md +39 -79
  98. package/docs/rules/require-property-name.md +21 -30
  99. package/docs/rules/require-property-type.md +21 -21
  100. package/docs/rules/require-property.md +82 -33
  101. package/docs/rules/require-returns-check.md +636 -747
  102. package/docs/rules/require-returns-description.md +61 -933
  103. package/docs/rules/require-returns-type.md +42 -79
  104. package/docs/rules/require-returns.md +1081 -61
  105. package/docs/rules/require-yields-check.md +238 -517
  106. package/docs/rules/require-yields.md +517 -238
  107. package/docs/rules/valid-types.md +1 -1
  108. package/docs/settings.md +1 -1
  109. package/package.json +5 -4
  110. package/tsconfig.json +2 -3
@@ -42,14 +42,43 @@ const setTagStructure = mode => {
42
42
  * }} FlattendRootInfo
43
43
  */
44
44
 
45
+ /**
46
+ * @typedef {undefined|string|{
47
+ * isRestProperty: boolean|undefined,
48
+ * name: string,
49
+ * restElement: true
50
+ * }|[undefined|string, FlattendRootInfo & {
51
+ * annotationParamName?: string
52
+ * }|{
53
+ * name: Integer,
54
+ * restElement: boolean
55
+ * }[]]} ParamNameInfo
56
+ */
57
+
58
+ /**
59
+ * @typedef {undefined|string|{
60
+ * isRestProperty: boolean,
61
+ * restElement: boolean,
62
+ * name: string
63
+ * }|[string, {
64
+ * hasPropertyRest: boolean,
65
+ * hasRestElement: boolean,
66
+ * names: string[],
67
+ * rests: boolean[],
68
+ * }]|[string, string[]]} ParamInfo
69
+ */
70
+
45
71
  /**
46
72
  * Given a nested array of property names, reduce them to a single array,
47
73
  * appending the name of the root element along the way if present.
48
74
  *
49
- * @param {} params
50
- * @param {string} root
75
+ * @callback FlattenRoots
76
+ * @param {ParamInfo[]} params
77
+ * @param {string} [root]
51
78
  * @returns {FlattendRootInfo}
52
79
  */
80
+
81
+ /** @type {FlattenRoots} */
53
82
  const flattenRoots = (params, root = '') => {
54
83
  let hasRestElement = false;
55
84
  let hasPropertyRest = false;
@@ -58,7 +87,13 @@ const flattenRoots = (params, root = '') => {
58
87
  * @type {boolean[]}
59
88
  */
60
89
  const rests = [];
61
- const names = params.reduce((acc, cur) => {
90
+ const names = params.reduce(
91
+ /**
92
+ * @param {string[]} acc
93
+ * @param {ParamInfo} cur
94
+ * @returns {string[]}
95
+ */
96
+ (acc, cur) => {
62
97
  if (Array.isArray(cur)) {
63
98
  let nms;
64
99
  if (Array.isArray(cur[1])) {
@@ -109,59 +144,68 @@ const flattenRoots = (params, root = '') => {
109
144
  };
110
145
 
111
146
  /**
112
- * @param {ESTreeOrTypeScriptNode} propSignature
113
- * @returns {undefined|Array|string}
147
+ * @param {import('@typescript-eslint/types').TSESTree.TSIndexSignature|
148
+ * import('@typescript-eslint/types').TSESTree.TSConstructSignatureDeclaration|
149
+ * import('@typescript-eslint/types').TSESTree.TSCallSignatureDeclaration|
150
+ * import('@typescript-eslint/types').TSESTree.TSPropertySignature} propSignature
151
+ * @returns {undefined|string|[string, string[]]}
114
152
  */
115
153
  const getPropertiesFromPropertySignature = propSignature => {
116
154
  if (propSignature.type === 'TSIndexSignature' || propSignature.type === 'TSConstructSignatureDeclaration' || propSignature.type === 'TSCallSignatureDeclaration') {
117
155
  return undefined;
118
156
  }
119
157
  if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === 'TSTypeLiteral') {
120
- return [propSignature.key.name, propSignature.typeAnnotation.typeAnnotation.members.map(member => {
121
- return getPropertiesFromPropertySignature(member);
158
+ return [/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */propSignature.key.name, propSignature.typeAnnotation.typeAnnotation.members.map(member => {
159
+ return (/** @type {string} */
160
+ getPropertiesFromPropertySignature( /** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */
161
+ member)
162
+ );
122
163
  })];
123
164
  }
124
- return propSignature.key.name;
165
+ return (/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */propSignature.key.name
166
+ );
125
167
  };
126
168
 
127
169
  /**
128
- * @param {ESTreeOrTypeScriptNode} functionNode
170
+ * @param {ESTreeOrTypeScriptNode|null} functionNode
129
171
  * @param {boolean} [checkDefaultObjects]
130
- * @returns {Array}
172
+ * @throws {Error}
173
+ * @returns {ParamNameInfo[]}
131
174
  */
132
175
  const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
133
176
  var _functionNode$value;
134
177
  /* eslint-disable complexity -- Temporary */
135
178
  /**
136
- * @param {} param
179
+ * @param {import('estree').Identifier|import('estree').AssignmentPattern|
180
+ * import('estree').ObjectPattern|import('estree').Property|
181
+ * import('estree').RestElement|import('estree').ArrayPattern|
182
+ * import('@typescript-eslint/types').TSESTree.TSParameterProperty|
183
+ * import('@typescript-eslint/types').TSESTree.Property|
184
+ * import('@typescript-eslint/types').TSESTree.RestElement
185
+ * } param
137
186
  * @param {boolean} [isProperty]
138
- * @returns {undefined|{
139
- * isRestProperty: boolean|undefined,
140
- * name: string,
141
- * restElement: true
142
- * }|[undefined|string, FlattendRootInfo|{
143
- * name: Integer,
144
- * restElement: boolean
145
- * }[]]}
187
+ * @returns {ParamNameInfo}
146
188
  */
147
189
  const getParamName = (param, isProperty) => {
148
- var _param$left, _param$left3;
190
+ var _param$left2;
149
191
  /* eslint-enable complexity -- Temporary */
150
192
  const hasLeftTypeAnnotation = 'left' in param && 'typeAnnotation' in param.left;
151
193
  if ('typeAnnotation' in param || hasLeftTypeAnnotation) {
152
194
  var _typeAnnotation$typeA;
153
- const typeAnnotation = hasLeftTypeAnnotation ? param.left.typeAnnotation : param.typeAnnotation;
195
+ const typeAnnotation = hasLeftTypeAnnotation ? /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.left.typeAnnotation : /** @type {import('@typescript-eslint/types').TSESTree.Identifier|import('@typescript-eslint/types').TSESTree.ObjectPattern} */
196
+ param.typeAnnotation;
154
197
  if ((typeAnnotation === null || typeAnnotation === void 0 ? void 0 : (_typeAnnotation$typeA = typeAnnotation.typeAnnotation) === null || _typeAnnotation$typeA === void 0 ? void 0 : _typeAnnotation$typeA.type) === 'TSTypeLiteral') {
155
198
  const propertyNames = typeAnnotation.typeAnnotation.members.map(member => {
156
- return getPropertiesFromPropertySignature(member);
199
+ return getPropertiesFromPropertySignature( /** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */
200
+ member);
157
201
  });
158
202
  const flattened = {
159
203
  ...flattenRoots(propertyNames),
160
- annotationParamName: param.name
204
+ annotationParamName: 'name' in param ? param.name : undefined
161
205
  };
162
206
  const hasLeftName = 'left' in param && 'name' in param.left;
163
207
  if ('name' in param || hasLeftName) {
164
- return [hasLeftName ? param.left.name : param.name, flattened];
208
+ return [hasLeftName ? /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.left.name : /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.name, flattened];
165
209
  }
166
210
  return [undefined, flattened];
167
211
  }
@@ -172,9 +216,9 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
172
216
  if ('left' in param && 'name' in param.left) {
173
217
  return param.left.name;
174
218
  }
175
- if (param.type === 'ObjectPattern' || ((_param$left = param.left) === null || _param$left === void 0 ? void 0 : _param$left.type) === 'ObjectPattern') {
176
- var _param$left2;
177
- const properties = param.properties || ((_param$left2 = param.left) === null || _param$left2 === void 0 ? void 0 : _param$left2.properties);
219
+ if (param.type === 'ObjectPattern' || 'left' in param && param.left.type === 'ObjectPattern') {
220
+ var _param$left;
221
+ const properties = /** @type {import('@typescript-eslint/types').TSESTree.ObjectPattern} */param.properties || ( /** @type {import('estree').ObjectPattern} */(_param$left = /** @type {import('@typescript-eslint/types').TSESTree.AssignmentPattern} */param.left) === null || _param$left === void 0 ? void 0 : _param$left.properties);
178
222
  const roots = properties.map(prop => {
179
223
  return getParamName(prop, true);
180
224
  });
@@ -239,9 +283,9 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
239
283
  return undefined;
240
284
  }
241
285
  }
242
- if (param.type === 'ArrayPattern' || ((_param$left3 = param.left) === null || _param$left3 === void 0 ? void 0 : _param$left3.type) === 'ArrayPattern') {
243
- var _param$left4;
244
- const elements = /** @type {import('estree').ArrayPattern} */param.elements || ( /** @type {import('estree').ArrayPattern} */(_param$left4 = param.left) === null || _param$left4 === void 0 ? void 0 : _param$left4.elements);
286
+ if (param.type === 'ArrayPattern' || ((_param$left2 = param.left) === null || _param$left2 === void 0 ? void 0 : _param$left2.type) === 'ArrayPattern') {
287
+ var _param$left3;
288
+ const elements = /** @type {import('estree').ArrayPattern} */param.elements || ( /** @type {import('estree').ArrayPattern} */(_param$left3 = param.left) === null || _param$left3 === void 0 ? void 0 : _param$left3.elements);
245
289
  const roots = elements.map((prop, idx) => {
246
290
  return {
247
291
  name: `"${idx}"`,
@@ -312,7 +356,7 @@ const getJsdocTagsDeep = (jsdoc, targetTagName) => {
312
356
  const modeWarnSettings = (0, _WarnSettings.default)();
313
357
 
314
358
  /**
315
- * @param {ParserMode} mode
359
+ * @param {ParserMode|undefined} mode
316
360
  * @param {import('eslint').Rule.RuleContext} context
317
361
  * @returns {import('./tagNames.js').AliasedTags}
318
362
  */
@@ -346,10 +390,10 @@ const getTagNamesForMode = (mode, context) => {
346
390
 
347
391
  /**
348
392
  * @param {import('eslint').Rule.RuleContext} context
349
- * @param {ParserMode} mode
393
+ * @param {ParserMode|undefined} mode
350
394
  * @param {string} name
351
395
  * @param {TagNamePreference} tagPreference
352
- * @returns {string|boolean|{
396
+ * @returns {string|false|{
353
397
  * message: string;
354
398
  * replacement?: string|undefined;
355
399
  * }}
@@ -385,10 +429,10 @@ const getPreferredTagName = (context, mode, name, tagPreference = {}) => {
385
429
  };
386
430
 
387
431
  /**
388
- * @param context
389
- * @param {ParserMode} mode
432
+ * @param {import('eslint').Rule.RuleContext} context
433
+ * @param {ParserMode|undefined} mode
390
434
  * @param {string} name
391
- * @param {Array} definedTags
435
+ * @param {string[]} definedTags
392
436
  * @returns {boolean}
393
437
  */
394
438
  const isValidTag = (context, mode, name, definedTags) => {
@@ -400,7 +444,9 @@ const isValidTag = (context, mode, name, definedTags) => {
400
444
  };
401
445
 
402
446
  /**
403
- * @param {object} jsdoc
447
+ * @param {import('comment-parser').Block & {
448
+ * inlineTags: import('@es-joy/jsdoccomment').InlineTag[]
449
+ * }} jsdoc
404
450
  * @param {string} targetTagName
405
451
  * @returns {boolean}
406
452
  */
@@ -417,12 +463,11 @@ const hasTag = (jsdoc, targetTagName) => {
417
463
  * @param {import('comment-parser').Block & {
418
464
  * inlineTags: import('@es-joy/jsdoccomment').JsdocInlineTagNoType[]
419
465
  * }} jsdoc
420
- * @param {boolean} includeInlineTags
421
466
  * @returns {(import('comment-parser').Spec|
422
467
  * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
423
468
  */
424
- const getAllTags = (jsdoc, includeInlineTags) => {
425
- return includeInlineTags ? [...jsdoc.tags, ...jsdoc.inlineTags.map(inlineTag => {
469
+ const getAllTags = jsdoc => {
470
+ return [...jsdoc.tags, ...jsdoc.inlineTags.map(inlineTag => {
426
471
  // Tags don't have source or line numbers, so add before returning
427
472
  let line = -1;
428
473
  for (const {
@@ -472,11 +517,11 @@ const getAllTags = (jsdoc, includeInlineTags) => {
472
517
  */
473
518
  tag.inlineTags
474
519
  );
475
- })] : jsdoc.tags;
520
+ })];
476
521
  };
477
522
 
478
523
  /**
479
- * @param {object} jsdoc
524
+ * @param {import('comment-parser').Block} jsdoc
480
525
  * @param {string[]} targetTagNames
481
526
  * @returns {boolean}
482
527
  */
@@ -489,7 +534,7 @@ const hasATag = (jsdoc, targetTagNames) => {
489
534
  /**
490
535
  * Checks if the JSDoc comment has an undefined type.
491
536
  *
492
- * @param {import('comment-parser').Spec} tag
537
+ * @param {import('comment-parser').Spec|null|undefined} tag
493
538
  * the tag which should be checked.
494
539
  * @param {ParserMode} mode
495
540
  * @returns {boolean}
@@ -529,7 +574,7 @@ const mayBeUndefinedTypeTag = (tag, mode) => {
529
574
  /**
530
575
  * @param {import('./getDefaultTagStructureForMode.js').TagStructure} map
531
576
  * @param {string} tag
532
- * @returns {Map<string, string | boolean>}
577
+ * @returns {Map<string, string|string[]|boolean|undefined>}
533
578
  */
534
579
  const ensureMap = (map, tag) => {
535
580
  if (!map.has(tag)) {
@@ -539,20 +584,8 @@ const ensureMap = (map, tag) => {
539
584
  );
540
585
  };
541
586
 
542
- /* eslint-disable jsdoc/valid-types -- Older non-TS version */
543
587
  /**
544
- * @typedef {{
545
- * [tag: string]: {
546
- * name: string|boolean,
547
- * type: string[]|boolean,
548
- * required: string[]
549
- * }
550
- * }} StructuredTags
551
- */
552
- /* eslint-enable jsdoc/valid-types -- Older non-TS version */
553
-
554
- /**
555
- * @param {StructuredTags} structuredTags
588
+ * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
556
589
  * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
557
590
  * @returns {void}
558
591
  */
@@ -588,7 +621,7 @@ const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
588
621
 
589
622
  /**
590
623
  * @param {ParserMode} mode
591
- * @param {StructuredTags} structuredTags
624
+ * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
592
625
  * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
593
626
  */
594
627
  const getTagStructureForMode = (mode, structuredTags) => {
@@ -634,11 +667,12 @@ const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => {
634
667
  /**
635
668
  * @param {string} tag
636
669
  * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
637
- * @returns {boolean}
670
+ * @returns {boolean|undefined}
638
671
  */
639
672
  const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
640
673
  const tagStruct = ensureMap(tagMap, tag);
641
- return tagStruct.get('typeRequired');
674
+ return (/** @type {boolean|undefined} */tagStruct.get('typeRequired')
675
+ );
642
676
  };
643
677
 
644
678
  /**
@@ -680,36 +714,38 @@ const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
680
714
  /**
681
715
  * @param {string} tag
682
716
  * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
683
- * @returns {boolean}
717
+ * @returns {boolean|undefined}
684
718
  */
685
719
  const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
686
720
  const tagStruct = ensureMap(tagMap, tag);
687
- return tagStruct.get('nameRequired');
721
+ return (/** @type {boolean|undefined} */tagStruct.get('nameRequired')
722
+ );
688
723
  };
689
724
 
690
725
  /**
691
- * @param tag
726
+ * @param {string} tag
692
727
  * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
693
728
  * @returns {boolean}
694
729
  */
695
730
  const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
696
- return tagMightHaveTypePosition(tag, tagMap) || tagMightHaveNamepath(tag, tagMap);
731
+ return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNamepath(tag, tagMap);
697
732
  };
698
733
 
699
734
  /**
700
735
  * @param {string} tag
701
736
  * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
702
- * @returns {boolean}
737
+ * @returns {boolean|undefined}
703
738
  */
704
739
  const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => {
705
740
  const tagStruct = ensureMap(tagMap, tag);
706
- return tagStruct.get('typeOrNameRequired');
741
+ return (/** @type {boolean} */tagStruct.get('typeOrNameRequired')
742
+ );
707
743
  };
708
744
 
709
745
  /**
710
- * @param tag
746
+ * @param {import('comment-parser').Spec} tag
711
747
  * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
712
- * @returns {boolean}
748
+ * @returns {boolean|undefined}
713
749
  */
714
750
  const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
715
751
  const mustHaveTypePosition = tagMustHaveTypePosition(tag.tag, tagMap);
@@ -740,6 +776,7 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
740
776
  });
741
777
  }
742
778
 
779
+ // @ts-expect-error In Babel?
743
780
  // istanbul ignore next -- In Babel?
744
781
  case 'OptionalCallExpression':
745
782
  case 'CallExpression':
@@ -817,13 +854,16 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
817
854
  // istanbul ignore next -- In Babel?
818
855
  case 'PropertyDefinition':
819
856
  /* eslint-disable no-fallthrough */
857
+ // @ts-expect-error In Babel?
820
858
  // istanbul ignore next -- In Babel?
821
859
  case 'ObjectProperty':
860
+ // @ts-expect-error In Babel?
822
861
  // istanbul ignore next -- In Babel?
823
862
  case 'ClassProperty':
824
863
  case 'Property':
825
864
  /* eslint-enable no-fallthrough */
826
865
  return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || hasNonFunctionYield(node.value, checkYieldReturnValue);
866
+ // @ts-expect-error In Babel?
827
867
  // istanbul ignore next -- In Babel?
828
868
  case 'ObjectMethod':
829
869
  // istanbul ignore next -- In Babel?
@@ -836,12 +876,14 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
836
876
  case 'TaggedTemplateExpression':
837
877
  return hasNonFunctionYield(node.quasi, checkYieldReturnValue);
838
878
 
879
+ // @ts-expect-error In Babel?
839
880
  // ?.
840
881
  // istanbul ignore next -- In Babel?
841
882
  case 'OptionalMemberExpression':
842
883
  case 'MemberExpression':
843
884
  return hasNonFunctionYield(node.object, checkYieldReturnValue) || hasNonFunctionYield(node.property, checkYieldReturnValue);
844
885
 
886
+ // @ts-expect-error In Babel?
845
887
  // istanbul ignore next -- In Babel?
846
888
  case 'Import':
847
889
  case 'ImportExpression':
@@ -889,7 +931,7 @@ const hasYieldValue = (node, checkYieldReturnValue) => {
889
931
  /**
890
932
  * Checks if a node has a throws statement.
891
933
  *
892
- * @param {ESTreeOrTypeScriptNode} node
934
+ * @param {ESTreeOrTypeScriptNode|null|undefined} node
893
935
  * @param {boolean} [innerFunction]
894
936
  * @returns {boolean}
895
937
  */
@@ -987,8 +1029,10 @@ const parseClosureTemplateTag = tag => {
987
1029
  * ESTree AST types, indicating allowable contexts.
988
1030
  *
989
1031
  * @param {import('eslint').Rule.RuleContext} context
990
- * @param {DefaultContexts} defaultContexts
991
- * @param settings
1032
+ * @param {DefaultContexts|undefined} defaultContexts
1033
+ * @param {{
1034
+ * contexts?: import('./iterateJsdoc.js').Context[]
1035
+ * }} settings
992
1036
  * @returns {string[]}
993
1037
  */
994
1038
  const enforcedContexts = (context, defaultContexts, settings) => {
@@ -998,11 +1042,13 @@ const enforcedContexts = (context, defaultContexts, settings) => {
998
1042
  };
999
1043
 
1000
1044
  /**
1001
- * @param {string[]} contexts
1002
- * @param {Function} checkJsdoc
1003
- * @param {Function} handler
1045
+ * @param {import('./iterateJsdoc.js').Context[]} contexts
1046
+ * @param {import('./iterateJsdoc.js').CheckJsdoc} checkJsdoc
1047
+ * @param {Function} [handler]
1048
+ * @returns {import('eslint').Rule.RuleListener}
1004
1049
  */
1005
1050
  const getContextObject = (contexts, checkJsdoc, handler) => {
1051
+ /** @type {import('eslint').Rule.RuleListener} */
1006
1052
  const properties = {};
1007
1053
  for (const [idx, prop] of contexts.entries()) {
1008
1054
  let property;
@@ -1038,11 +1084,6 @@ const getContextObject = (contexts, checkJsdoc, handler) => {
1038
1084
  }
1039
1085
  return properties;
1040
1086
  };
1041
- const filterTags = (tags, filter) => {
1042
- return tags.filter(tag => {
1043
- return filter(tag);
1044
- });
1045
- };
1046
1087
  const tagsWithNamesAndDescriptions = new Set(['param', 'arg', 'argument', 'property', 'prop', 'template',
1047
1088
  // These two are parsed by our custom parser as though having a `name`
1048
1089
  'returns', 'return']);
@@ -1058,7 +1099,7 @@ const tagsWithNamesAndDescriptions = new Set(['param', 'arg', 'argument', 'prope
1058
1099
 
1059
1100
  /**
1060
1101
  * @param {import('eslint').Rule.RuleContext} context
1061
- * @param {ParserMode} mode
1102
+ * @param {ParserMode|undefined} mode
1062
1103
  * @param {import('comment-parser').Spec[]} tags
1063
1104
  * @param {TagNamePreference} tagPreference
1064
1105
  * @returns {{
@@ -1072,7 +1113,7 @@ const getTagsByType = (context, mode, tags, tagPreference) => {
1072
1113
  * @type {import('comment-parser').Spec[]}
1073
1114
  */
1074
1115
  const tagsWithoutNames = [];
1075
- const tagsWithNames = filterTags(tags, tag => {
1116
+ const tagsWithNames = tags.filter(tag => {
1076
1117
  const {
1077
1118
  tag: tagName
1078
1119
  } = tag;
@@ -1089,7 +1130,9 @@ const getTagsByType = (context, mode, tags, tagPreference) => {
1089
1130
  };
1090
1131
 
1091
1132
  /**
1092
- * @param {import('eslint').SourceCode} sourceCode
1133
+ * @param {import('eslint').SourceCode|{
1134
+ * text: string
1135
+ * }} sourceCode
1093
1136
  * @returns {string}
1094
1137
  */
1095
1138
  const getIndent = sourceCode => {
@@ -1098,64 +1141,87 @@ const getIndent = sourceCode => {
1098
1141
  };
1099
1142
 
1100
1143
  /**
1101
- * @param {ESTreeOrTypeScriptNode} node
1144
+ * @param {import('eslint').Rule.Node|null} node
1102
1145
  * @returns {boolean}
1103
1146
  */
1104
1147
  const isConstructor = node => {
1105
1148
  var _node$parent;
1106
- return (node === null || node === void 0 ? void 0 : node.type) === 'MethodDefinition' && node.kind === 'constructor' || (node === null || node === void 0 ? void 0 : (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.kind) === 'constructor';
1149
+ return (node === null || node === void 0 ? void 0 : node.type) === 'MethodDefinition' && node.kind === 'constructor' || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */(node === null || node === void 0 ? void 0 : (_node$parent = node.parent) === null || _node$parent === void 0 ? void 0 : _node$parent.kind) === 'constructor';
1107
1150
  };
1108
1151
 
1109
1152
  /**
1110
- * @param {ESTreeOrTypeScriptNode} node
1153
+ * @param {import('eslint').Rule.Node|null} node
1111
1154
  * @returns {boolean}
1112
1155
  */
1113
1156
  const isGetter = node => {
1114
1157
  var _node$parent2;
1115
- return node && ((_node$parent2 = node.parent) === null || _node$parent2 === void 0 ? void 0 : _node$parent2.kind) === 'get';
1158
+ return node !== null &&
1159
+ /**
1160
+ * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
1161
+ * import('@typescript-eslint/types').TSESTree.Property}
1162
+ */
1163
+ ((_node$parent2 = node.parent) === null || _node$parent2 === void 0 ? void 0 : _node$parent2.kind) === 'get';
1116
1164
  };
1117
1165
 
1118
1166
  /**
1119
- * @param {ESTreeOrTypeScriptNode} node
1167
+ * @param {import('eslint').Rule.Node|null} node
1120
1168
  * @returns {boolean}
1121
1169
  */
1122
1170
  const isSetter = node => {
1123
1171
  var _node$parent3;
1124
- return node && ((_node$parent3 = node.parent) === null || _node$parent3 === void 0 ? void 0 : _node$parent3.kind) === 'set';
1172
+ return node !== null &&
1173
+ /**
1174
+ * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
1175
+ * import('@typescript-eslint/types').TSESTree.Property}
1176
+ */
1177
+ ((_node$parent3 = node.parent) === null || _node$parent3 === void 0 ? void 0 : _node$parent3.kind) === 'set';
1125
1178
  };
1126
1179
 
1127
1180
  /**
1128
- * @param {ESTreeOrTypeScriptNode} node
1181
+ * @param {import('eslint').Rule.Node} node
1129
1182
  * @returns {boolean}
1130
1183
  */
1131
1184
  const hasAccessorPair = node => {
1132
1185
  const {
1133
1186
  type,
1134
1187
  kind: sourceKind,
1135
- key: {
1136
- name: sourceName
1137
- }
1138
- } = node;
1188
+ key
1189
+ } =
1190
+ /**
1191
+ * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
1192
+ * import('@typescript-eslint/types').TSESTree.Property}
1193
+ */
1194
+ node;
1195
+ const sourceName = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */key.name;
1139
1196
  const oppositeKind = sourceKind === 'get' ? 'set' : 'get';
1140
- const children = type === 'MethodDefinition' ? 'body' : 'properties';
1141
- return node.parent[children].some(({
1142
- kind,
1143
- key: {
1144
- name
1145
- }
1146
- }) => {
1197
+ const sibling = type === 'MethodDefinition' ? /** @type {import('@typescript-eslint/types').TSESTree.ClassBody} */node.parent.body : /** @type {import('@typescript-eslint/types').TSESTree.ObjectExpression} */node.parent.properties;
1198
+ return sibling.some(child => {
1199
+ const {
1200
+ kind,
1201
+ key: ky
1202
+ } =
1203
+ /**
1204
+ * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
1205
+ * import('@typescript-eslint/types').TSESTree.Property}
1206
+ */
1207
+ child;
1208
+ const name = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ky.name;
1147
1209
  return kind === oppositeKind && name === sourceName;
1148
1210
  });
1149
1211
  };
1150
1212
 
1151
1213
  /**
1152
1214
  * @param {import('comment-parser').Block} jsdoc
1153
- * @param {ESTreeOrTypeScriptNode} node
1215
+ * @param {import('eslint').Rule.Node|null} node
1154
1216
  * @param {import('eslint').Rule.RuleContext} context
1155
- * @param {} schema
1217
+ * @param {import('json-schema').JSONSchema4} schema
1156
1218
  * @returns {boolean}
1157
1219
  */
1158
1220
  const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
1221
+ /**
1222
+ * @param {"checkGetters"|"checkSetters"|"checkConstructors"} prop
1223
+ * @returns {boolean|"no-setter"|"no-getter"}
1224
+ */
1159
1225
  const hasSchemaOption = prop => {
1160
1226
  var _context$options$2;
1161
1227
  const schemaProperties = schema[0].properties;
@@ -1163,7 +1229,7 @@ const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
1163
1229
  };
1164
1230
  const checkGetters = hasSchemaOption('checkGetters');
1165
1231
  const checkSetters = hasSchemaOption('checkSetters');
1166
- return !hasSchemaOption('checkConstructors') && (isConstructor(node) || hasATag(jsdoc, ['class', 'constructor'])) || isGetter(node) && (!checkGetters || checkGetters === 'no-setter' && hasAccessorPair(node.parent)) || isSetter(node) && (!checkSetters || checkSetters === 'no-getter' && hasAccessorPair(node.parent));
1232
+ return !hasSchemaOption('checkConstructors') && (isConstructor(node) || hasATag(jsdoc, ['class', 'constructor'])) || isGetter(node) && (!checkGetters || checkGetters === 'no-setter' && hasAccessorPair( /** @type {import('./iterateJsdoc.js').Node} */node.parent)) || isSetter(node) && (!checkSetters || checkSetters === 'no-getter' && hasAccessorPair( /** @type {import('./iterateJsdoc.js').Node} */node.parent));
1167
1233
  };
1168
1234
 
1169
1235
  /**
@@ -1190,17 +1256,20 @@ const comparePaths = name => {
1190
1256
  };
1191
1257
 
1192
1258
  /**
1259
+ * @callback PathDoesNotBeginWith
1193
1260
  * @param {string} name
1194
1261
  * @param {string} otherPathName
1195
1262
  * @returns {boolean}
1196
1263
  */
1264
+
1265
+ /** @type {PathDoesNotBeginWith} */
1197
1266
  const pathDoesNotBeginWith = (name, otherPathName) => {
1198
1267
  return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
1199
1268
  };
1200
1269
 
1201
1270
  /**
1202
1271
  * @param {string} regexString
1203
- * @param {string} requiredFlags
1272
+ * @param {string} [requiredFlags]
1204
1273
  * @returns {RegExp}
1205
1274
  */
1206
1275
  const getRegexFromString = (regexString, requiredFlags) => {
@@ -1222,7 +1291,6 @@ var _default = {
1222
1291
  dropPathSegmentQuotes,
1223
1292
  enforcedContexts,
1224
1293
  exemptSpeciaMethods,
1225
- filterTags,
1226
1294
  flattenRoots,
1227
1295
  getAllTags,
1228
1296
  getContextObject,