eslint-plugin-jsdoc 44.2.4 → 44.2.6

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 (125) hide show
  1. package/dist/WarnSettings.js +0 -1
  2. package/dist/WarnSettings.js.map +1 -1
  3. package/dist/alignTransform.js +1 -1
  4. package/dist/alignTransform.js.map +1 -1
  5. package/dist/bin/generateRule.js +5 -4
  6. package/dist/bin/generateRule.js.map +1 -1
  7. package/dist/exportParser.js +206 -135
  8. package/dist/exportParser.js.map +1 -1
  9. package/dist/generateRule.js +5 -4
  10. package/dist/generateRule.js.map +1 -1
  11. package/dist/iterateJsdoc.js +21 -48
  12. package/dist/iterateJsdoc.js.map +1 -1
  13. package/dist/jsdocUtils.js +126 -92
  14. package/dist/jsdocUtils.js.map +1 -1
  15. package/dist/rules/checkAccess.js +1 -1
  16. package/dist/rules/checkAccess.js.map +1 -1
  17. package/dist/rules/checkAlignment.js +1 -1
  18. package/dist/rules/checkAlignment.js.map +1 -1
  19. package/dist/rules/checkExamples.js +4 -4
  20. package/dist/rules/checkExamples.js.map +1 -1
  21. package/dist/rules/checkIndentation.js +2 -2
  22. package/dist/rules/checkIndentation.js.map +1 -1
  23. package/dist/rules/checkLineAlignment.js +4 -4
  24. package/dist/rules/checkLineAlignment.js.map +1 -1
  25. package/dist/rules/checkParamNames.js +18 -5
  26. package/dist/rules/checkParamNames.js.map +1 -1
  27. package/dist/rules/checkPropertyNames.js +1 -1
  28. package/dist/rules/checkPropertyNames.js.map +1 -1
  29. package/dist/rules/checkSyntax.js +1 -1
  30. package/dist/rules/checkSyntax.js.map +1 -1
  31. package/dist/rules/checkTagNames.js +3 -7
  32. package/dist/rules/checkTagNames.js.map +1 -1
  33. package/dist/rules/checkTypes.js +2 -6
  34. package/dist/rules/checkTypes.js.map +1 -1
  35. package/dist/rules/checkValues.js +2 -2
  36. package/dist/rules/checkValues.js.map +1 -1
  37. package/dist/rules/emptyTags.js +1 -1
  38. package/dist/rules/emptyTags.js.map +1 -1
  39. package/dist/rules/implementsOnClasses.js +1 -1
  40. package/dist/rules/implementsOnClasses.js.map +1 -1
  41. package/dist/rules/informativeDocs.js +1 -1
  42. package/dist/rules/informativeDocs.js.map +1 -1
  43. package/dist/rules/matchDescription.js +1 -1
  44. package/dist/rules/matchDescription.js.map +1 -1
  45. package/dist/rules/matchName.js +1 -1
  46. package/dist/rules/matchName.js.map +1 -1
  47. package/dist/rules/multilineBlocks.js +1 -1
  48. package/dist/rules/multilineBlocks.js.map +1 -1
  49. package/dist/rules/noBadBlocks.js +2 -2
  50. package/dist/rules/noBadBlocks.js.map +1 -1
  51. package/dist/rules/noBlankBlockDescriptions.js +1 -1
  52. package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
  53. package/dist/rules/noBlankBlocks.js +1 -1
  54. package/dist/rules/noBlankBlocks.js.map +1 -1
  55. package/dist/rules/noDefaults.js +1 -1
  56. package/dist/rules/noDefaults.js.map +1 -1
  57. package/dist/rules/noMissingSyntax.js +4 -10
  58. package/dist/rules/noMissingSyntax.js.map +1 -1
  59. package/dist/rules/noMultiAsterisks.js +1 -1
  60. package/dist/rules/noMultiAsterisks.js.map +1 -1
  61. package/dist/rules/noRestrictedSyntax.js +4 -10
  62. package/dist/rules/noRestrictedSyntax.js.map +1 -1
  63. package/dist/rules/noTypes.js +1 -1
  64. package/dist/rules/noTypes.js.map +1 -1
  65. package/dist/rules/noUndefinedTypes.js +6 -9
  66. package/dist/rules/noUndefinedTypes.js.map +1 -1
  67. package/dist/rules/requireDescription.js +1 -1
  68. package/dist/rules/requireDescription.js.map +1 -1
  69. package/dist/rules/requireDescriptionCompleteSentence.js +4 -4
  70. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  71. package/dist/rules/requireExample.js +1 -1
  72. package/dist/rules/requireExample.js.map +1 -1
  73. package/dist/rules/requireFileOverview.js +1 -1
  74. package/dist/rules/requireFileOverview.js.map +1 -1
  75. package/dist/rules/requireHyphenBeforeParamDescription.js +4 -7
  76. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  77. package/dist/rules/requireJsdoc.js +13 -8
  78. package/dist/rules/requireJsdoc.js.map +1 -1
  79. package/dist/rules/requireParam.js +84 -22
  80. package/dist/rules/requireParam.js.map +1 -1
  81. package/dist/rules/requireParamDescription.js +1 -1
  82. package/dist/rules/requireParamDescription.js.map +1 -1
  83. package/dist/rules/requireParamName.js +1 -1
  84. package/dist/rules/requireParamName.js.map +1 -1
  85. package/dist/rules/requireParamType.js +1 -1
  86. package/dist/rules/requireParamType.js.map +1 -1
  87. package/dist/rules/requireProperty.js +1 -1
  88. package/dist/rules/requireProperty.js.map +1 -1
  89. package/dist/rules/requirePropertyDescription.js +1 -1
  90. package/dist/rules/requirePropertyDescription.js.map +1 -1
  91. package/dist/rules/requirePropertyName.js +1 -1
  92. package/dist/rules/requirePropertyName.js.map +1 -1
  93. package/dist/rules/requirePropertyType.js +1 -1
  94. package/dist/rules/requirePropertyType.js.map +1 -1
  95. package/dist/rules/requireReturns.js +1 -2
  96. package/dist/rules/requireReturns.js.map +1 -1
  97. package/dist/rules/requireReturnsCheck.js +1 -1
  98. package/dist/rules/requireReturnsCheck.js.map +1 -1
  99. package/dist/rules/requireReturnsDescription.js +1 -1
  100. package/dist/rules/requireReturnsDescription.js.map +1 -1
  101. package/dist/rules/requireReturnsType.js +1 -1
  102. package/dist/rules/requireReturnsType.js.map +1 -1
  103. package/dist/rules/requireThrows.js +1 -2
  104. package/dist/rules/requireThrows.js.map +1 -1
  105. package/dist/rules/requireYields.js +1 -2
  106. package/dist/rules/requireYields.js.map +1 -1
  107. package/dist/rules/requireYieldsCheck.js +1 -1
  108. package/dist/rules/requireYieldsCheck.js.map +1 -1
  109. package/dist/rules/sortTags.js +2 -2
  110. package/dist/rules/sortTags.js.map +1 -1
  111. package/dist/rules/tagLines.js +1 -1
  112. package/dist/rules/tagLines.js.map +1 -1
  113. package/dist/rules/textEscaping.js +3 -3
  114. package/dist/rules/textEscaping.js.map +1 -1
  115. package/dist/rules/validTypes.js +2 -2
  116. package/dist/rules/validTypes.js.map +1 -1
  117. package/dist/tagNames.js +0 -2
  118. package/dist/tagNames.js.map +1 -1
  119. package/dist/utils/hasReturnValue.js +0 -5
  120. package/dist/utils/hasReturnValue.js.map +1 -1
  121. package/docs/rules/check-line-alignment.md +7 -0
  122. package/docs/rules/no-undefined-types.md +6 -0
  123. package/docs/rules/require-param.md +4 -0
  124. package/docs/settings.md +2 -0
  125. package/package.json +9 -9
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _jsdoccomment = require("@es-joy/jsdoccomment");
8
- var _WarnSettings = _interopRequireDefault(require("./WarnSettings"));
9
7
  var _getDefaultTagStructureForMode = _interopRequireDefault(require("./getDefaultTagStructureForMode"));
10
8
  var _tagNames = require("./tagNames");
11
9
  var _hasReturnValue = require("./utils/hasReturnValue");
10
+ var _WarnSettings = _interopRequireDefault(require("./WarnSettings"));
11
+ var _jsdoccomment = require("@es-joy/jsdoccomment");
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
  /**
14
14
  * @typedef {number} Integer
@@ -33,45 +33,47 @@ const setTagStructure = mode => {
33
33
  tagStructure = (0, _getDefaultTagStructureForMode.default)(mode);
34
34
  };
35
35
 
36
- /**
37
- * @typedef {{
38
- * hasPropertyRest: boolean,
39
- * hasRestElement: boolean,
40
- * names: string[],
41
- * rests: boolean[],
42
- * }} FlattendRootInfo
43
- */
44
-
45
36
  /**
46
37
  * @typedef {undefined|string|{
38
+ * name: Integer,
39
+ * restElement: boolean
40
+ * }|{
47
41
  * isRestProperty: boolean|undefined,
48
42
  * name: string,
49
- * restElement: true
50
- * }|[undefined|string, FlattendRootInfo & {
51
- * annotationParamName?: string
43
+ * restElement: boolean
52
44
  * }|{
53
- * name: Integer,
45
+ * name: string,
54
46
  * restElement: boolean
55
- * }[]]} ParamNameInfo
47
+ * }} ParamCommon
48
+ */
49
+ /**
50
+ * @typedef {ParamCommon|[string|undefined, (FlattendRootInfo & {
51
+ * annotationParamName?: string,
52
+ * })]|NestedParamInfo} ParamNameInfo
56
53
  */
57
54
 
58
55
  /**
59
- * @typedef {undefined|string|{
60
- * isRestProperty: boolean,
61
- * restElement: boolean,
62
- * name: string
63
- * }|[string, {
56
+ * @typedef {{
64
57
  * hasPropertyRest: boolean,
65
58
  * hasRestElement: boolean,
66
59
  * names: string[],
67
60
  * rests: boolean[],
68
- * }]|[string, string[]]} ParamInfo
61
+ * }} FlattendRootInfo
62
+ */
63
+ /**
64
+ * @typedef {[string, (string[]|ParamInfo[])]} NestedParamInfo
65
+ */
66
+ /**
67
+ * @typedef {ParamCommon|
68
+ * [string|undefined, (FlattendRootInfo & {
69
+ * annotationParamName?: string
70
+ * })]|
71
+ * NestedParamInfo} ParamInfo
69
72
  */
70
73
 
71
74
  /**
72
75
  * Given a nested array of property names, reduce them to a single array,
73
- * appending the name of the root element along the way if present.
74
- *
76
+ * appending the name of the root element along the way if present.
75
77
  * @callback FlattenRoots
76
78
  * @param {ParamInfo[]} params
77
79
  * @param {string} [root]
@@ -114,21 +116,21 @@ const flattenRoots = (params, root = '') => {
114
116
  if (flattened.hasPropertyRest) {
115
117
  hasPropertyRest = true;
116
118
  }
117
- const inner = [root ? `${root}.${cur[0]}` : cur[0], ...flattened.names].filter(Boolean);
119
+ const inner = /** @type {string[]} */[root ? `${root}.${cur[0]}` : cur[0], ...flattened.names].filter(Boolean);
118
120
  rests.push(false, ...flattened.rests);
119
121
  return acc.concat(inner);
120
122
  }
121
123
  if (typeof cur === 'object') {
122
- if (cur.isRestProperty) {
124
+ if ('isRestProperty' in cur && cur.isRestProperty) {
123
125
  hasPropertyRest = true;
124
126
  rests.push(true);
125
127
  } else {
126
128
  rests.push(false);
127
129
  }
128
- if (cur.restElement) {
130
+ if ('restElement' in cur && cur.restElement) {
129
131
  hasRestElement = true;
130
132
  }
131
- acc.push(root ? `${root}.${cur.name}` : cur.name);
133
+ acc.push(root ? `${root}.${String(cur.name)}` : String(cur.name));
132
134
  } else if (typeof cur !== 'undefined') {
133
135
  rests.push(false);
134
136
  acc.push(root ? `${root}.${cur}` : cur);
@@ -181,10 +183,14 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
181
183
  * import('estree').RestElement|import('estree').ArrayPattern|
182
184
  * import('@typescript-eslint/types').TSESTree.TSParameterProperty|
183
185
  * import('@typescript-eslint/types').TSESTree.Property|
184
- * import('@typescript-eslint/types').TSESTree.RestElement
186
+ * import('@typescript-eslint/types').TSESTree.RestElement|
187
+ * import('@typescript-eslint/types').TSESTree.Identifier|
188
+ * import('@typescript-eslint/types').TSESTree.ObjectPattern|
189
+ * import('@typescript-eslint/types').TSESTree.BindingName|
190
+ * import('@typescript-eslint/types').TSESTree.Parameter
185
191
  * } param
186
192
  * @param {boolean} [isProperty]
187
- * @returns {ParamNameInfo}
193
+ * @returns {ParamNameInfo|[string, ParamNameInfo[]]}
188
194
  */
189
195
  const getParamName = (param, isProperty) => {
190
196
  var _param$left2;
@@ -228,16 +234,22 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
228
234
  // eslint-disable-next-line default-case
229
235
  switch (param.value.type) {
230
236
  case 'ArrayPattern':
231
- return [param.key.name, /** @type {import('estree').ArrayPattern} */param.value.elements.map((prop, idx) => {
232
- return {
233
- name: idx,
234
- restElement: (prop === null || prop === void 0 ? void 0 : prop.type) === 'RestElement'
235
- };
236
- })];
237
+ {
238
+ return [/** @type {import('estree').Identifier} */
239
+ param.key.name, /** @type {import('estree').ArrayPattern} */param.value.elements.map((prop, idx) => {
240
+ return {
241
+ name: idx,
242
+ restElement: (prop === null || prop === void 0 ? void 0 : prop.type) === 'RestElement'
243
+ };
244
+ })];
245
+ }
237
246
  case 'ObjectPattern':
238
- return [param.key.name, /** @type {import('estree').ObjectPattern} */param.value.properties.map(prop => {
239
- return getParamName(prop, isProperty);
240
- })];
247
+ {
248
+ return [/** @type {import('estree').Identifier} */param.key.name, /** @type {import('estree').ObjectPattern} */param.value.properties.map(prop => {
249
+ return (/** @type {string|[string, string[]]} */getParamName(prop, isProperty)
250
+ );
251
+ })];
252
+ }
241
253
  case 'AssignmentPattern':
242
254
  {
243
255
  // eslint-disable-next-line default-case
@@ -245,17 +257,21 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
245
257
  case 'Identifier':
246
258
  // Default parameter
247
259
  if (checkDefaultObjects && param.value.right.type === 'ObjectExpression') {
248
- return [param.key.name, /** @type {import('estree').AssignmentPattern} */param.value.right.properties.map(prop => {
249
- return getParamName(prop, isProperty);
260
+ return [/** @type {import('estree').Identifier} */param.key.name, /** @type {import('estree').AssignmentPattern} */param.value.right.properties.map(prop => {
261
+ return (/** @type {string} */getParamName( /** @type {import('estree').Property} */
262
+ prop, isProperty)
263
+ );
250
264
  })];
251
265
  }
252
266
  break;
253
267
  case 'ObjectPattern':
254
- return [param.key.name, /** @type {import('estree').ObjectPattern} */param.value.left.properties.map(prop => {
268
+ return [/** @type {import('estree').Identifier} */
269
+ param.key.name, /** @type {import('estree').ObjectPattern} */param.value.left.properties.map(prop => {
255
270
  return getParamName(prop, isProperty);
256
271
  })];
257
272
  case 'ArrayPattern':
258
- return [param.key.name, /** @type {import('estree').ArrayPattern} */param.value.left.elements.map((prop, idx) => {
273
+ return [/** @type {import('estree').Identifier} */
274
+ param.key.name, /** @type {import('estree').ArrayPattern} */param.value.left.elements.map((prop, idx) => {
259
275
  return {
260
276
  name: idx,
261
277
  restElement: (prop === null || prop === void 0 ? void 0 : prop.type) === 'RestElement'
@@ -270,9 +286,10 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
270
286
 
271
287
  // The key of an object could also be a string or number
272
288
  case 'Literal':
273
- return param.key.raw ||
274
- // istanbul ignore next -- `raw` may not be present in all parsers
275
- param.key.value;
289
+ return (/** @type {string} */param.key.raw ||
290
+ // istanbul ignore next -- `raw` may not be present in all parsers
291
+ param.key.value
292
+ );
276
293
 
277
294
  // case 'MemberExpression':
278
295
  default:
@@ -283,9 +300,9 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
283
300
  return undefined;
284
301
  }
285
302
  }
286
- if (param.type === 'ArrayPattern' || ((_param$left2 = param.left) === null || _param$left2 === void 0 ? void 0 : _param$left2.type) === 'ArrayPattern') {
303
+ if (param.type === 'ArrayPattern' || /** @type {import('estree').AssignmentPattern} */((_param$left2 = param.left) === null || _param$left2 === void 0 ? void 0 : _param$left2.type) === 'ArrayPattern') {
287
304
  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);
305
+ const elements = /** @type {import('estree').ArrayPattern} */param.elements || ( /** @type {import('estree').ArrayPattern} */(_param$left3 = /** @type {import('estree').AssignmentPattern} */param.left) === null || _param$left3 === void 0 ? void 0 : _param$left3.elements);
289
306
  const roots = elements.map((prop, idx) => {
290
307
  return {
291
308
  name: `"${idx}"`,
@@ -297,19 +314,20 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
297
314
  if (['RestElement', 'ExperimentalRestProperty'].includes(param.type)) {
298
315
  return {
299
316
  isRestProperty: isProperty,
300
- name: param.argument.name,
317
+ name: /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ /** @type {import('@typescript-eslint/types').TSESTree.RestElement} */param.argument.name,
301
318
  restElement: true
302
319
  };
303
320
  }
304
321
  if (param.type === 'TSParameterProperty') {
305
- return getParamName(param.parameter, true);
322
+ return getParamName( /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
323
+ /** @type {import('@typescript-eslint/types').TSESTree.TSParameterProperty} */param.parameter, true);
306
324
  }
307
325
  throw new Error(`Unsupported function signature format: \`${param.type}\`.`);
308
326
  };
309
327
  if (!functionNode) {
310
328
  return [];
311
329
  }
312
- return (functionNode.params || ((_functionNode$value = functionNode.value) === null || _functionNode$value === void 0 ? void 0 : _functionNode$value.params) || []).map(param => {
330
+ return ( /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params || ( /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */(_functionNode$value = functionNode.value) === null || _functionNode$value === void 0 ? void 0 : _functionNode$value.params) || []).map(param => {
313
331
  return getParamName(param);
314
332
  });
315
333
  };
@@ -320,13 +338,13 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
320
338
  */
321
339
  const hasParams = functionNode => {
322
340
  // Should also check `functionNode.value.params` if supporting `MethodDefinition`
323
- return functionNode.params.length;
341
+ return (/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params.length
342
+ );
324
343
  };
325
344
 
326
345
  /**
327
346
  * Gets all names of the target type, including those that refer to a path, e.g.
328
347
  * "@param foo; @param foo.bar".
329
- *
330
348
  * @param {import('comment-parser').Block} jsdoc
331
349
  * @param {string} targetTagName
332
350
  * @returns {{
@@ -373,6 +391,10 @@ const getTagNamesForMode = (mode, context) => {
373
391
  if (!modeWarnSettings.hasBeenWarned(context, 'mode')) {
374
392
  context.report({
375
393
  loc: {
394
+ end: {
395
+ column: 1,
396
+ line: 1
397
+ },
376
398
  start: {
377
399
  column: 1,
378
400
  line: 1
@@ -444,9 +466,7 @@ const isValidTag = (context, mode, name, definedTags) => {
444
466
  };
445
467
 
446
468
  /**
447
- * @param {import('comment-parser').Block & {
448
- * inlineTags: import('@es-joy/jsdoccomment').InlineTag[]
449
- * }} jsdoc
469
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
450
470
  * @param {string} targetTagName
451
471
  * @returns {boolean}
452
472
  */
@@ -459,10 +479,7 @@ const hasTag = (jsdoc, targetTagName) => {
459
479
 
460
480
  /**
461
481
  * Get all tags, inline tags and inline tags in tags
462
- *
463
- * @param {import('comment-parser').Block & {
464
- * inlineTags: import('@es-joy/jsdoccomment').JsdocInlineTagNoType[]
465
- * }} jsdoc
482
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
466
483
  * @returns {(import('comment-parser').Spec|
467
484
  * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
468
485
  */
@@ -495,7 +512,8 @@ const getAllTags = jsdoc => {
495
512
  }
496
513
  }
497
514
  for (const inlineTag of tag.inlineTags) {
498
- let line;
515
+ /** @type {import('./iterateJsdoc.js').Integer} */
516
+ let line = 0;
499
517
  for (const {
500
518
  number,
501
519
  tokens: {
@@ -521,7 +539,7 @@ const getAllTags = jsdoc => {
521
539
  };
522
540
 
523
541
  /**
524
- * @param {import('comment-parser').Block} jsdoc
542
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
525
543
  * @param {string[]} targetTagNames
526
544
  * @returns {boolean}
527
545
  */
@@ -533,7 +551,6 @@ const hasATag = (jsdoc, targetTagNames) => {
533
551
 
534
552
  /**
535
553
  * Checks if the JSDoc comment has an undefined type.
536
- *
537
554
  * @param {import('comment-parser').Spec|null|undefined} tag
538
555
  * the tag which should be checked.
539
556
  * @param {ParserMode} mode
@@ -685,7 +702,7 @@ const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
685
702
  return true;
686
703
  }
687
704
  const tagStruct = ensureMap(tagMap, tag);
688
- const ret = tagStruct.get('typeAllowed');
705
+ const ret = /** @type {boolean|undefined} */tagStruct.get('typeAllowed');
689
706
  return ret === undefined ? true : ret;
690
707
  };
691
708
  const namepathTypes = new Set(['namepath-defining', 'namepath-referencing']);
@@ -708,7 +725,8 @@ const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => {
708
725
  */
709
726
  const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
710
727
  const tagStruct = ensureMap(tagMap, tag);
711
- return namepathTypes.has(tagStruct.get('namepathRole'));
728
+ const nampathRole = tagStruct.get('namepathRole');
729
+ return nampathRole !== false && namepathTypes.has( /** @type {string} */nampathRole);
712
730
  };
713
731
 
714
732
  /**
@@ -759,7 +777,7 @@ const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
759
777
 
760
778
  /* eslint-disable complexity -- Temporary */
761
779
  /**
762
- * @param {ESTreeOrTypeScriptNode} node
780
+ * @param {ESTreeOrTypeScriptNode|null|undefined} node
763
781
  * @param {boolean} [checkYieldReturnValue]
764
782
  * @returns {boolean}
765
783
  */
@@ -805,7 +823,8 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
805
823
  }
806
824
  case 'TryStatement':
807
825
  {
808
- return hasNonFunctionYield(node.block, checkYieldReturnValue) || hasNonFunctionYield(node.handler && node.handler.body, checkYieldReturnValue) || hasNonFunctionYield(node.finalizer, checkYieldReturnValue);
826
+ return hasNonFunctionYield(node.block, checkYieldReturnValue) || hasNonFunctionYield(node.handler && node.handler.body, checkYieldReturnValue) || hasNonFunctionYield( /** @type {import('@typescript-eslint/types').TSESTree.BlockStatement} */
827
+ node.finalizer, checkYieldReturnValue);
809
828
  }
810
829
  case 'SwitchStatement':
811
830
  {
@@ -866,8 +885,11 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
866
885
  // @ts-expect-error In Babel?
867
886
  // istanbul ignore next -- In Babel?
868
887
  case 'ObjectMethod':
888
+ // @ts-expect-error In Babel?
869
889
  // istanbul ignore next -- In Babel?
870
- return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || node.arguments.some(nde => {
890
+ return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) ||
891
+ // @ts-expect-error In Babel?
892
+ node.arguments.some(nde => {
871
893
  return hasNonFunctionYield(nde, checkYieldReturnValue);
872
894
  });
873
895
  case 'SpreadElement':
@@ -898,7 +920,7 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
898
920
  case 'YieldExpression':
899
921
  {
900
922
  if (checkYieldReturnValue) {
901
- if (node.parent.type === 'VariableDeclarator') {
923
+ if ( /** @type {import('eslint').Rule.Node} */node.parent.type === 'VariableDeclarator') {
902
924
  return true;
903
925
  }
904
926
  return false;
@@ -919,18 +941,18 @@ const hasNonFunctionYield = (node, checkYieldReturnValue) => {
919
941
 
920
942
  /**
921
943
  * Checks if a node has a return statement. Void return does not count.
922
- *
923
944
  * @param {ESTreeOrTypeScriptNode} node
924
945
  * @param {boolean} [checkYieldReturnValue]
925
946
  * @returns {boolean}
926
947
  */
927
948
  const hasYieldValue = (node, checkYieldReturnValue) => {
928
- return node.generator && (node.expression || hasNonFunctionYield(node.body, checkYieldReturnValue));
949
+ return (/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */node.generator && ( /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */node.expression || hasNonFunctionYield( /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */
950
+ node.body, checkYieldReturnValue))
951
+ );
929
952
  };
930
953
 
931
954
  /**
932
955
  * Checks if a node has a throws statement.
933
- *
934
956
  * @param {ESTreeOrTypeScriptNode|null|undefined} node
935
957
  * @param {boolean} [innerFunction]
936
958
  * @returns {boolean}
@@ -1007,9 +1029,8 @@ const isInlineTag = (tag) => {
1007
1029
 
1008
1030
  /**
1009
1031
  * Parses GCC Generic/Template types
1010
- *
1011
- * @see {https://github.com/google/closure-compiler/wiki/Generic-Types}
1012
- * @see {https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template}
1032
+ * @see {@link https://github.com/google/closure-compiler/wiki/Generic-Types}
1033
+ * @see {@link https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template}
1013
1034
  * @param {import('comment-parser').Spec} tag
1014
1035
  * @returns {string[]}
1015
1036
  */
@@ -1025,9 +1046,8 @@ const parseClosureTemplateTag = tag => {
1025
1046
 
1026
1047
  /**
1027
1048
  * Checks user option for `contexts` array, defaulting to
1028
- * contexts designated by the rule. Returns an array of
1029
- * ESTree AST types, indicating allowable contexts.
1030
- *
1049
+ * contexts designated by the rule. Returns an array of
1050
+ * ESTree AST types, indicating allowable contexts.
1031
1051
  * @param {import('eslint').Rule.RuleContext} context
1032
1052
  * @param {DefaultContexts|undefined} defaultContexts
1033
1053
  * @param {{
@@ -1044,14 +1064,17 @@ const enforcedContexts = (context, defaultContexts, settings) => {
1044
1064
  /**
1045
1065
  * @param {import('./iterateJsdoc.js').Context[]} contexts
1046
1066
  * @param {import('./iterateJsdoc.js').CheckJsdoc} checkJsdoc
1047
- * @param {Function} [handler]
1067
+ * @param {import('@es-joy/jsdoccomment').CommentHandler} [handler]
1048
1068
  * @returns {import('eslint').Rule.RuleListener}
1049
1069
  */
1050
1070
  const getContextObject = (contexts, checkJsdoc, handler) => {
1051
1071
  /** @type {import('eslint').Rule.RuleListener} */
1052
1072
  const properties = {};
1053
1073
  for (const [idx, prop] of contexts.entries()) {
1074
+ /** @type {string} */
1054
1075
  let property;
1076
+
1077
+ /** @type {(node: import('eslint').Rule.Node) => void} */
1055
1078
  let value;
1056
1079
  if (typeof prop === 'object') {
1057
1080
  const selInfo = {
@@ -1059,13 +1082,18 @@ const getContextObject = (contexts, checkJsdoc, handler) => {
1059
1082
  selector: prop.context
1060
1083
  };
1061
1084
  if (prop.comment) {
1062
- property = prop.context;
1085
+ property = /** @type {string} */prop.context;
1063
1086
  value = checkJsdoc.bind(null, {
1064
1087
  ...selInfo,
1065
1088
  comment: prop.comment
1066
- }, handler.bind(null, prop.comment));
1089
+ },
1090
+ /**
1091
+ * @type {(jsdoc: import('@es-joy/jsdoccomment').JsdocBlockWithInline) => boolean}
1092
+ */
1093
+ /** @type {import('@es-joy/jsdoccomment').CommentHandler} */
1094
+ handler.bind(null, prop.comment));
1067
1095
  } else {
1068
- property = prop.context;
1096
+ property = /** @type {string} */prop.context;
1069
1097
  value = checkJsdoc.bind(null, selInfo, null);
1070
1098
  }
1071
1099
  } else {
@@ -1076,10 +1104,18 @@ const getContextObject = (contexts, checkJsdoc, handler) => {
1076
1104
  property = prop;
1077
1105
  value = checkJsdoc.bind(null, selInfo, null);
1078
1106
  }
1079
- const old = properties[property];
1080
- properties[property] = old ? function (...args) {
1081
- old(...args);
1082
- value(...args);
1107
+ const old =
1108
+ /**
1109
+ * @type {((node: import('eslint').Rule.Node) => void)}
1110
+ */
1111
+ properties[property];
1112
+ properties[property] = old ?
1113
+ /**
1114
+ * @type {((node: import('eslint').Rule.Node) => void)}
1115
+ */
1116
+ function (node) {
1117
+ old(node);
1118
+ value(node);
1083
1119
  } : value;
1084
1120
  }
1085
1121
  return properties;
@@ -1088,10 +1124,9 @@ const tagsWithNamesAndDescriptions = new Set(['param', 'arg', 'argument', 'prope
1088
1124
  // These two are parsed by our custom parser as though having a `name`
1089
1125
  'returns', 'return']);
1090
1126
 
1091
- /* eslint-disable jsdoc/valid-types -- Old version */
1092
1127
  /**
1093
1128
  * @typedef {{
1094
- * [key: string]: false|
1129
+ * [key: string]: false|string|
1095
1130
  * {message: string, replacement?: string}
1096
1131
  * }} TagNamePreference
1097
1132
  */
@@ -1211,7 +1246,7 @@ const hasAccessorPair = node => {
1211
1246
  };
1212
1247
 
1213
1248
  /**
1214
- * @param {import('comment-parser').Block} jsdoc
1249
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
1215
1250
  * @param {import('eslint').Rule.Node|null} node
1216
1251
  * @param {import('eslint').Rule.RuleContext} context
1217
1252
  * @param {import('json-schema').JSONSchema4} schema
@@ -1237,17 +1272,16 @@ const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
1237
1272
  * identifier or numeric literal) or single or double quoted, in either
1238
1273
  * the `@param` or in source, we need to strip the quotes to give a fair
1239
1274
  * comparison.
1240
- *
1241
1275
  * @param {string} str
1242
1276
  * @returns {string}
1243
1277
  */
1244
1278
  const dropPathSegmentQuotes = str => {
1245
- return str.replace(/\.(['"])(.*)\1/gu, '.$2');
1279
+ return str.replaceAll(/\.(['"])(.*)\1/gu, '.$2');
1246
1280
  };
1247
1281
 
1248
1282
  /**
1249
1283
  * @param {string} name
1250
- * @returns {(otherPathName: string) => void}
1284
+ * @returns {(otherPathName: string) => boolean}
1251
1285
  */
1252
1286
  const comparePaths = name => {
1253
1287
  return otherPathName => {