eslint-plugin-jsdoc 44.2.1 → 44.2.3

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.
@@ -15,6 +15,10 @@ var _jsdoccomment = require("@es-joy/jsdoccomment");
15
15
  var _commentParser = require("comment-parser");
16
16
  var _jsdocUtils = _interopRequireDefault(require("./jsdocUtils"));
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ /**
19
+ * @typedef {number} Integer
20
+ */
21
+
18
22
  const {
19
23
  rewireSpecs,
20
24
  seedTokens
@@ -49,14 +53,31 @@ const {
49
53
  */
50
54
 
51
55
  const globalState = new Map();
56
+ /**
57
+ * @param {import('eslint').Rule.RuleContext} context
58
+ * @param {{
59
+ * tagNamePreference?: import('./jsdocUtils.js').TagNamePreference,
60
+ * mode?: import('./jsdocUtils.js').ParserMode
61
+ * }} cfg
62
+ * @returns {Utils}
63
+ */
52
64
  const getBasicUtils = (context, {
53
65
  tagNamePreference,
54
66
  mode
55
67
  }) => {
56
68
  const utils = {};
69
+
70
+ /**
71
+ * @param {string} message
72
+ * @returns {void}
73
+ */
57
74
  utils.reportSettings = message => {
58
75
  context.report({
59
76
  loc: {
77
+ end: {
78
+ column: 1,
79
+ line: 1
80
+ },
60
81
  start: {
61
82
  column: 1,
62
83
  line: 1
@@ -65,14 +86,25 @@ const getBasicUtils = (context, {
65
86
  message
66
87
  });
67
88
  };
89
+
90
+ /**
91
+ * @param {import('comment-parser').Spec} tag
92
+ * @returns {string[]}
93
+ */
68
94
  utils.parseClosureTemplateTag = tag => {
69
95
  return _jsdocUtils.default.parseClosureTemplateTag(tag);
70
96
  };
71
97
  utils.pathDoesNotBeginWith = _jsdocUtils.default.pathDoesNotBeginWith;
98
+
99
+ /**
100
+ * @param {{
101
+ * tagName: string
102
+ * }} cfg
103
+ */
72
104
  utils.getPreferredTagNameObject = ({
73
105
  tagName
74
106
  }) => {
75
- const ret = _jsdocUtils.default.getPreferredTagName(context, mode, tagName, tagNamePreference);
107
+ const ret = _jsdocUtils.default.getPreferredTagName(context, /** @type {import('./jsdocUtils.js').ParserMode} */mode, tagName, tagNamePreference);
76
108
  const isObject = ret && typeof ret === 'object';
77
109
  if (ret === false || isObject && !ret.replacement) {
78
110
  return {
@@ -84,6 +116,19 @@ const getBasicUtils = (context, {
84
116
  };
85
117
  return utils;
86
118
  };
119
+
120
+ /**
121
+ * @param {} node
122
+ * @param {import('comment-parser').Block} jsdoc
123
+ * @param {import('@es-joy/jsdoccomment').Token} jsdocNode
124
+ * @param {Settings} settings
125
+ * @param {} report
126
+ * @param {import('eslint').Rule.RuleContext} context
127
+ * @param {boolean} iteratingAll
128
+ * @param {} ruleConfig
129
+ * @param {string} indent
130
+ * @returns {}
131
+ */
87
132
  const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAll, ruleConfig, indent) => {
88
133
  const ancestors = context.getAncestors();
89
134
  const sourceCode = context.getSourceCode();
@@ -98,21 +143,48 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
98
143
  minLines,
99
144
  mode
100
145
  } = settings;
146
+
147
+ /**
148
+ * @returns {boolean}
149
+ */
101
150
  utils.isIteratingFunction = () => {
102
151
  return !iteratingAll || ['MethodDefinition', 'ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(node && node.type);
103
152
  };
153
+
154
+ /**
155
+ * @returns {boolean}
156
+ */
104
157
  utils.isVirtualFunction = () => {
105
158
  return iteratingAll && utils.hasATag(['callback', 'function', 'func', 'method']);
106
159
  };
160
+
161
+ /**
162
+ * @param {import('comment-parser').Block} tagBlock
163
+ * @param {boolean} [specRewire]
164
+ * @returns {string}
165
+ */
107
166
  utils.stringify = (tagBlock, specRewire) => {
108
167
  let block;
109
168
  if (specRewire) {
110
169
  block = rewireSpecs(tagBlock);
111
170
  }
112
- return (0, _commentParser.stringify)(specRewire ? block : tagBlock);
171
+ return (0, _commentParser.stringify)( /** @type {import('comment-parser').Block} */
172
+ specRewire ? block : tagBlock);
113
173
  };
174
+
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
+ */
114
185
  utils.reportJSDoc = (msg, tag, handler, specRewire, data) => {
115
- report(msg, handler ? fixer => {
186
+ /* eslint-enable jsdoc/valid-types -- Old version */
187
+ report(msg, handler ? /** @type {import('eslint').Rule.ReportFixer} */fixer => {
116
188
  handler();
117
189
  const replacement = utils.stringify(jsdoc, specRewire);
118
190
  if (!replacement) {
@@ -126,10 +198,25 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
126
198
  return fixer.replaceText(jsdocNode, replacement);
127
199
  } : null, tag, data);
128
200
  };
201
+
202
+ /**
203
+ * @param {string} str
204
+ * @param {string} requiredFlags
205
+ * @returns {RegExp}
206
+ */
129
207
  utils.getRegexFromString = (str, requiredFlags) => {
130
208
  return _jsdocUtils.default.getRegexFromString(str, requiredFlags);
131
209
  };
210
+
211
+ /**
212
+ * @param {import('comment-parser').Spec} tg
213
+ * @param {boolean} returnArray
214
+ * @returns {string[]|string}
215
+ */
132
216
  utils.getTagDescription = (tg, returnArray) => {
217
+ /**
218
+ * @type {string[]}
219
+ */
133
220
  const descriptions = [];
134
221
  tg.source.some(({
135
222
  tokens: {
@@ -158,6 +245,13 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
158
245
  });
159
246
  return returnArray ? descriptions : descriptions.join('\n');
160
247
  };
248
+
249
+ /**
250
+ * @param {import('comment-parser').Spec} tg
251
+ * @param {RegExp} matcher
252
+ * @param {(description: string) => string} setter
253
+ * @returns {Integer}
254
+ */
161
255
  utils.setTagDescription = (tg, matcher, setter) => {
162
256
  let finalIdx = 0;
163
257
  tg.source.some(({
@@ -174,7 +268,16 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
174
268
  });
175
269
  return finalIdx;
176
270
  };
271
+
272
+ /**
273
+ * @returns {{
274
+ * description: string,
275
+ * descriptions: string[],
276
+ * lastDescriptionLine: Integer
277
+ * }}
278
+ */
177
279
  utils.getDescription = () => {
280
+ /** @type {string[]} */
178
281
  const descriptions = [];
179
282
  let lastDescriptionLine = 0;
180
283
  let tagsBegun = false;
@@ -206,9 +309,33 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
206
309
  lastDescriptionLine
207
310
  };
208
311
  };
312
+
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
+ */
209
328
  utils.setBlockDescription = setter => {
329
+ /* eslint-enable jsdoc/no-undefined-types -- Bug */
330
+ /** @type {string[]} */
210
331
  const descLines = [];
332
+ /**
333
+ * @type {undefined|Integer}
334
+ */
211
335
  let startIdx;
336
+ /**
337
+ * @type {undefined|Integer}
338
+ */
212
339
  let endIdx;
213
340
  let info;
214
341
  jsdoc.source.some(({
@@ -242,9 +369,15 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
242
369
 
243
370
  /* istanbul ignore else -- Won't be called if missing */
244
371
  if (descLines.length) {
245
- jsdoc.source.splice(startIdx, endIdx - startIdx, ...setter(info, seedTokens, descLines));
372
+ jsdoc.source.splice( /** @type {Integer} */startIdx, /** @type {Integer} */endIdx - /** @type {Integer} */startIdx, ...setter(info, seedTokens, descLines));
246
373
  }
247
374
  };
375
+
376
+ /**
377
+ * @param {RegExp} matcher
378
+ * @param {(description: string) => string} setter
379
+ * @returns {Integer}
380
+ */
248
381
  utils.setDescriptionLines = (matcher, setter) => {
249
382
  let finalIdx = 0;
250
383
  jsdoc.source.some(({
@@ -267,6 +400,12 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
267
400
  });
268
401
  return finalIdx;
269
402
  };
403
+
404
+ /**
405
+ * @param {import('comment-parser').Spec} tag
406
+ * @param {import('comment-parser').Tokens[]} tokens
407
+ * @returns {void}
408
+ */
270
409
  utils.changeTag = (tag, ...tokens) => {
271
410
  for (const [idx, src] of tag.source.entries()) {
272
411
  src.tokens = {
@@ -275,10 +414,21 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
275
414
  };
276
415
  }
277
416
  };
417
+
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
+ */
278
426
  utils.setTag = (tag, tokens) => {
427
+ /* eslint-enable jsdoc/no-undefined-types -- TS */
279
428
  tag.source = [{
280
- // Or tag.source[0].number?
281
429
  number: tag.line,
430
+ // Or tag.source[0].number?
431
+ source: '',
282
432
  tokens: seedTokens({
283
433
  delimiter: '*',
284
434
  postDelimiter: ' ',
@@ -288,6 +438,15 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
288
438
  })
289
439
  }];
290
440
  };
441
+
442
+ /**
443
+ * @param {Integer} tagIndex
444
+ * @param {{
445
+ * removeEmptyBlock?: boolean,
446
+ * tagSourceOffset?: Integer
447
+ * }} cfg
448
+ * @returns {void}
449
+ */
291
450
  utils.removeTag = (tagIndex, {
292
451
  removeEmptyBlock = false,
293
452
  tagSourceOffset = 0
@@ -295,6 +454,7 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
295
454
  const {
296
455
  source: tagSource
297
456
  } = jsdoc.tags[tagIndex];
457
+ /** @type {Integer|undefined} */
298
458
  let lastIndex;
299
459
  const firstNumber = jsdoc.source[0].number;
300
460
  tagSource.some(({
@@ -332,7 +492,12 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
332
492
  tokens
333
493
  } = jsdoc.source[spliceIdx];
334
494
  for (const item of ['postDelimiter', 'tag', 'postTag', 'type', 'postType', 'name', 'postName', 'description']) {
335
- tokens[item] = '';
495
+ tokens[
496
+ /**
497
+ * @type {"postDelimiter"|"tag"|"type"|"postType"|
498
+ * "postTag"|"name"|"postName"|"description"}
499
+ */
500
+ item] = '';
336
501
  }
337
502
  } else {
338
503
  jsdoc.source.splice(spliceIdx, spliceCount - tagSourceOffset + (spliceIdx ? 0 : jsdoc.source.length));
@@ -346,14 +511,21 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
346
511
  return false;
347
512
  });
348
513
  for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) {
349
- src.number = firstNumber + lastIndex + idx;
514
+ src.number = firstNumber + /** @type {Integer} */lastIndex + idx;
350
515
  }
351
516
 
352
- // Todo: Once rewiring of tags may be fixed in comment-parser to reflect missing tags,
353
- // this step should be added here (so that, e.g., if accessing `jsdoc.tags`,
354
- // such as to add a new tag, the correct information will be available)
517
+ // Todo: Once rewiring of tags may be fixed in comment-parser to reflect
518
+ // missing tags, this step should be added here (so that, e.g.,
519
+ // if accessing `jsdoc.tags`, such as to add a new tag, the
520
+ // correct information will be available)
355
521
  };
356
522
 
523
+ /**
524
+ * @param {string} targetTagName
525
+ * @param {Integer} number
526
+ * @param {import('comment-parser').Tokens|{}} tokens
527
+ * @returns {void}
528
+ */
357
529
  utils.addTag = (targetTagName, number = ((() => {
358
530
  var _jsdoc$tags, _jsdoc$tags$source$;
359
531
  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;
@@ -379,6 +551,10 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
379
551
  src.number++;
380
552
  }
381
553
  };
554
+
555
+ /**
556
+ * @returns {Integer|undefined}
557
+ */
382
558
  utils.getFirstLine = () => {
383
559
  let firstLine;
384
560
  for (const {
@@ -395,11 +571,29 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
395
571
  return firstLine;
396
572
  };
397
573
  utils.seedTokens = seedTokens;
574
+
575
+ /**
576
+ * Sets tokens to empty string.
577
+ *
578
+ * @param {import('comment-parser').Tokens} tokens
579
+ * @returns {void}
580
+ */
398
581
  utils.emptyTokens = tokens => {
399
582
  for (const prop of ['start', 'postDelimiter', 'tag', 'type', 'postType', 'postTag', 'name', 'postName', 'description', 'end', 'lineEnd']) {
400
- tokens[prop] = '';
583
+ tokens[
584
+ /**
585
+ * @type {"start"|"postDelimiter"|"tag"|"type"|"postType"|
586
+ * "postTag"|"name"|"postName"|"description"|"end"|"lineEnd"}
587
+ */
588
+ prop] = '';
401
589
  }
402
590
  };
591
+
592
+ /**
593
+ * @param {Integer} sourceIndex
594
+ * @param {import('comment-parser').Tokens} tokens
595
+ * @returns {void}
596
+ */
403
597
  utils.addLine = (sourceIndex, tokens) => {
404
598
  var _jsdoc$source;
405
599
  const number = (((_jsdoc$source = jsdoc.source[sourceIndex - 1]) === null || _jsdoc$source === void 0 ? void 0 : _jsdoc$source.number) || 0) + 1;
@@ -415,10 +609,17 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
415
609
  // rewireSource(jsdoc);
416
610
  };
417
611
 
612
+ /**
613
+ * @param {Integer} tagIndex
614
+ * @param {Integer} tagSourceOffset
615
+ * @param {Integer} numLines
616
+ * @returns {void}
617
+ */
418
618
  utils.addLines = (tagIndex, tagSourceOffset, numLines) => {
419
619
  const {
420
620
  source: tagSource
421
621
  } = jsdoc.tags[tagIndex];
622
+ /** @type {Integer|undefined} */
422
623
  let lastIndex;
423
624
  const firstNumber = jsdoc.source[0].number;
424
625
  tagSource.some(({
@@ -464,6 +665,10 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
464
665
  src.number = firstNumber + lastIndex + idx;
465
666
  }
466
667
  };
668
+
669
+ /**
670
+ * @returns {void}
671
+ */
467
672
  utils.makeMultiline = () => {
468
673
  const {
469
674
  source: [{
@@ -517,21 +722,52 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
517
722
  start: indent + ' '
518
723
  });
519
724
  };
725
+
726
+ /**
727
+ * @param {} params
728
+ * @returns {}
729
+ */
520
730
  utils.flattenRoots = params => {
521
731
  return _jsdocUtils.default.flattenRoots(params);
522
732
  };
733
+
734
+ /**
735
+ * @param {boolean} useDefaultObjectProperties
736
+ * @returns {}
737
+ */
523
738
  utils.getFunctionParameterNames = useDefaultObjectProperties => {
524
739
  return _jsdocUtils.default.getFunctionParameterNames(node, useDefaultObjectProperties);
525
740
  };
741
+
742
+ /**
743
+ * @returns {Integer}
744
+ */
526
745
  utils.hasParams = () => {
527
746
  return _jsdocUtils.default.hasParams(node);
528
747
  };
748
+
749
+ /**
750
+ * @returns {boolean}
751
+ */
529
752
  utils.isGenerator = () => {
530
753
  return node && (node.generator || node.type === 'MethodDefinition' && node.value.generator || ['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes(node.type) && node.declaration.generator);
531
754
  };
755
+
756
+ /**
757
+ * @returns {boolean}
758
+ */
532
759
  utils.isConstructor = () => {
533
760
  return _jsdocUtils.default.isConstructor(node);
534
761
  };
762
+
763
+ /**
764
+ * @param {string} tagName
765
+ * @returns {false|{
766
+ * idx: Integer,
767
+ * name: string,
768
+ * type: string
769
+ * }[]}
770
+ */
535
771
  utils.getJsdocTagsDeep = tagName => {
536
772
  const name = utils.getPreferredTagName({
537
773
  tagName
@@ -541,6 +777,15 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
541
777
  }
542
778
  return _jsdocUtils.default.getJsdocTagsDeep(jsdoc, name);
543
779
  };
780
+
781
+ /**
782
+ * @param {{
783
+ * tagName: string,
784
+ * skipReportingBlockedTag?: boolean,
785
+ * allowObjectReturn?: boolean,
786
+ * defaultMessage?: string
787
+ * }} cfg
788
+ */
544
789
  utils.getPreferredTagName = ({
545
790
  tagName,
546
791
  skipReportingBlockedTag = false,
@@ -562,21 +807,51 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
562
807
  }
563
808
  return isObject && !allowObjectReturn ? ret.replacement : ret;
564
809
  };
810
+
811
+ /**
812
+ * @param {string} name
813
+ * @param {string[]} definedTags
814
+ * @returns {boolean}
815
+ */
565
816
  utils.isValidTag = (name, definedTags) => {
566
817
  return _jsdocUtils.default.isValidTag(context, mode, name, definedTags);
567
818
  };
819
+
820
+ /**
821
+ * @param {string[]} names
822
+ * @returns {boolean}
823
+ */
568
824
  utils.hasATag = names => {
569
825
  return _jsdocUtils.default.hasATag(jsdoc, names);
570
826
  };
827
+
828
+ /**
829
+ * @param {string} name
830
+ * @returns {boolean}
831
+ */
571
832
  utils.hasTag = name => {
572
833
  return _jsdocUtils.default.hasTag(jsdoc, name);
573
834
  };
835
+
836
+ /**
837
+ * @param {string} name
838
+ * @returns {}
839
+ */
574
840
  utils.comparePaths = name => {
575
841
  return _jsdocUtils.default.comparePaths(name);
576
842
  };
843
+
844
+ /**
845
+ * @param {string} name
846
+ * @returns {}
847
+ */
577
848
  utils.dropPathSegmentQuotes = name => {
578
849
  return _jsdocUtils.default.dropPathSegmentQuotes(name);
579
850
  };
851
+
852
+ /**
853
+ * @returns {boolean}
854
+ */
580
855
  utils.avoidDocs = () => {
581
856
  var _context$options$;
582
857
  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'))) {
@@ -592,8 +867,16 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
592
867
  return false;
593
868
  };
594
869
  for (const method of ['tagMightHaveNamePosition', 'tagMightHaveTypePosition']) {
595
- utils[method] = (tagName, otherModeMaps) => {
596
- const result = _jsdocUtils.default[method](tagName);
870
+ /**
871
+ * @param {string} tagName
872
+ * @param {import('./getDefaultTagStructureForMode.js').
873
+ * TagStructure[]} [otherModeMaps]
874
+ * @returns {boolean|{otherMode: true}}
875
+ */
876
+ utils[/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
877
+ method] = (tagName, otherModeMaps) => {
878
+ const result = _jsdocUtils.default[/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
879
+ method](tagName);
597
880
  if (result) {
598
881
  return true;
599
882
  }
@@ -601,7 +884,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
601
884
  return false;
602
885
  }
603
886
  const otherResult = otherModeMaps.some(otherModeMap => {
604
- return _jsdocUtils.default[method](tagName, otherModeMap);
887
+ return _jsdocUtils.default[/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
888
+ method](tagName, otherModeMap);
605
889
  });
606
890
  return otherResult ? {
607
891
  otherMode: true
@@ -609,8 +893,16 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
609
893
  };
610
894
  }
611
895
  for (const method of ['tagMustHaveNamePosition', 'tagMustHaveTypePosition', 'tagMissingRequiredTypeOrNamepath']) {
612
- utils[method] = (tagName, otherModeMaps) => {
613
- const result = _jsdocUtils.default[method](tagName);
896
+ /**
897
+ * @param {string} tagName
898
+ * @param {import('./getDefaultTagStructureForMode.js').
899
+ * TagStructure[]} otherModeMaps
900
+ * @returns {}
901
+ */
902
+ utils[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"|"tagMissingRequiredTypeOrNamepath"} */
903
+ method] = (tagName, otherModeMaps) => {
904
+ const result = _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"|"tagMissingRequiredTypeOrNamepath"} */
905
+ method](tagName);
614
906
  if (!result) {
615
907
  return false;
616
908
  }
@@ -618,7 +910,8 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
618
910
  // if (!otherModeMaps) { return true; }
619
911
 
620
912
  const otherResult = otherModeMaps.every(otherModeMap => {
621
- return _jsdocUtils.default[method](tagName, otherModeMap);
913
+ return _jsdocUtils.default[/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"|"tagMissingRequiredTypeOrNamepath"} */
914
+ method](tagName, otherModeMap);
622
915
  });
623
916
  return otherResult ? true : {
624
917
  otherMode: false
@@ -626,31 +919,61 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
626
919
  };
627
920
  }
628
921
  for (const method of ['isNamepathDefiningTag', 'isNamepathReferencingTag', 'isNamepathOrUrlReferencingTag', 'tagMightHaveNamepath']) {
922
+ /**
923
+ * @param {string} tagName
924
+ * @returns {}
925
+ */
629
926
  utils[method] = tagName => {
630
927
  return _jsdocUtils.default[method](tagName);
631
928
  };
632
929
  }
930
+
931
+ /**
932
+ * @param {import('./jsdocUtils.js').ParserMode} mde
933
+ * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
934
+ */
633
935
  utils.getTagStructureForMode = mde => {
634
936
  return _jsdocUtils.default.getTagStructureForMode(mde, settings.structuredTags);
635
937
  };
938
+
939
+ /**
940
+ * @param {} tag
941
+ * @returns {}
942
+ */
636
943
  utils.mayBeUndefinedTypeTag = tag => {
637
944
  return _jsdocUtils.default.mayBeUndefinedTypeTag(tag, settings.mode);
638
945
  };
639
946
  utils.hasValueOrExecutorHasNonEmptyResolveValue = (anyPromiseAsReturn, allBranches) => {
640
947
  return _jsdocUtils.default.hasValueOrExecutorHasNonEmptyResolveValue(node, anyPromiseAsReturn, allBranches);
641
948
  };
949
+
950
+ /**
951
+ * @returns {boolean}
952
+ */
642
953
  utils.hasYieldValue = () => {
643
954
  if (['ExportNamedDeclaration', 'ExportDefaultDeclaration'].includes(node.type)) {
644
955
  return _jsdocUtils.default.hasYieldValue(node.declaration);
645
956
  }
646
957
  return _jsdocUtils.default.hasYieldValue(node);
647
958
  };
959
+
960
+ /**
961
+ * @returns {boolean}
962
+ */
648
963
  utils.hasYieldReturnValue = () => {
649
964
  return _jsdocUtils.default.hasYieldValue(node, true);
650
965
  };
966
+
967
+ /**
968
+ * @returns {boolean}
969
+ */
651
970
  utils.hasThrowValue = () => {
652
971
  return _jsdocUtils.default.hasThrowValue(node);
653
972
  };
973
+
974
+ /**
975
+ * @returns {boolean}
976
+ */
654
977
  utils.isAsync = () => {
655
978
  return node.async;
656
979
  };
@@ -668,9 +991,19 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
668
991
  const tags = _jsdocUtils.default.getAllTags(jsdoc, includeInlineTags);
669
992
  return _jsdocUtils.default.filterTags(tags, filter);
670
993
  };
994
+
995
+ /**
996
+ * @param {import('comment-parser').Spec[]} tags
997
+ * @returns {}
998
+ */
671
999
  utils.getTagsByType = tags => {
672
1000
  return _jsdocUtils.default.getTagsByType(context, mode, tags, tagNamePreference);
673
1001
  };
1002
+
1003
+ /**
1004
+ * @param {string} tagName
1005
+ * @returns {boolean}
1006
+ */
674
1007
  utils.hasOptionTag = tagName => {
675
1008
  const {
676
1009
  tags
@@ -719,6 +1052,21 @@ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, iteratingAl
719
1052
  };
720
1053
  return utils;
721
1054
  };
1055
+
1056
+ /* eslint-disable jsdoc/valid-types -- Old version */
1057
+ /**
1058
+ * Settings from ESLint types.
1059
+ *
1060
+ * @typedef {{
1061
+ * [name: string]: any
1062
+ * }} Settings
1063
+ */
1064
+ /* eslint-enable jsdoc/valid-types -- Old version */
1065
+
1066
+ /**
1067
+ * @param {import('eslint').Rule.RuleContext} context
1068
+ * @returns {Settings}
1069
+ */
722
1070
  const getSettings = context => {
723
1071
  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;
724
1072
  /* eslint-disable canonical/sort-keys */
@@ -770,12 +1118,23 @@ const getSettings = context => {
770
1118
  /**
771
1119
  * Create the report function
772
1120
  *
773
- * @param {object} context
1121
+ * @param {import('eslint').Rule.RuleContext} context
774
1122
  * @param {object} commentNode
775
1123
  */
776
1124
  exports.getSettings = getSettings;
777
1125
  const makeReport = (context, commentNode) => {
778
- const report = (message, fix = null, jsdocLoc = null, data = null) => {
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
+ */
1136
+ const report = (message, fix = null, jsdocLoc = null, data = undefined) => {
1137
+ /* eslint-enable jsdoc/valid-types -- Old version */
779
1138
  let loc;
780
1139
  if (jsdocLoc) {
781
1140
  if (!('line' in jsdocLoc)) {
@@ -815,11 +1174,10 @@ const makeReport = (context, commentNode) => {
815
1174
  /* eslint-disable jsdoc/no-undefined-types -- canonical still using an older version where not defined */
816
1175
  /**
817
1176
  * @typedef {ReturnType<typeof getUtils>} Utils
818
- * @typedef {ReturnType<typeof getSettings>} Settings
819
1177
  * @typedef {(
820
1178
  * arg: {
821
- * context: object,
822
- * sourceCode: object,
1179
+ * context: import('eslint').Rule.RuleContext,
1180
+ * sourceCode: import('eslint').SourceCode,
823
1181
  * indent: string,
824
1182
  * jsdoc: object,
825
1183
  * jsdocNode: object,
@@ -832,6 +1190,21 @@ const makeReport = (context, commentNode) => {
832
1190
  */
833
1191
  /* eslint-enable jsdoc/no-undefined-types -- canonical still using an older version where not defined */
834
1192
 
1193
+ /**
1194
+ * @param {} info
1195
+ * @param {} indent
1196
+ * @param {import('comment-parser').Block} jsdoc
1197
+ * @param {} ruleConfig
1198
+ * @param {import('eslint').Rule.RuleContext} context
1199
+ * @param {} lines
1200
+ * @param {import('@es-joy/jsdoccomment').Token} jsdocNode
1201
+ * @param {} node
1202
+ * @param {Settings} settings
1203
+ * @param {import('eslint').SourceCode} sourceCode
1204
+ * @param {} iterator
1205
+ * @param {} state
1206
+ * @param {boolean} iteratingAll
1207
+ */
835
1208
  const iterate = (info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, node, settings, sourceCode, iterator, state, iteratingAll) => {
836
1209
  const report = makeReport(context, jsdocNode);
837
1210
  const utils = getUtils(node, jsdoc, jsdocNode, settings, report, context, iteratingAll, ruleConfig, indent);
@@ -865,6 +1238,14 @@ const iterate = (info, indent, jsdoc, ruleConfig, context, lines, jsdocNode, nod
865
1238
  utils
866
1239
  });
867
1240
  };
1241
+
1242
+ /**
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
+ * }]}
1248
+ */
868
1249
  const getIndentAndJSDoc = function (lines, jsdocNode) {
869
1250
  const sourceLine = lines[jsdocNode.loc.start.line - 1];
870
1251
  const indnt = sourceLine.charAt(0).repeat(jsdocNode.loc.start.column);
@@ -877,13 +1258,6 @@ const getIndentAndJSDoc = function (lines, jsdocNode) {
877
1258
  * @typedef {{node: Node, state: StateObject}} NonCommentArgs
878
1259
  */
879
1260
 
880
- /**
881
- * Our internal dynamic set of utilities.
882
- *
883
- * @todo Document
884
- * @typedef {any} Utils
885
- */
886
-
887
1261
  /**
888
1262
  * @typedef {object} RuleConfig
889
1263
  * @property {EslintRuleMeta} meta ESLint rule meta
@@ -907,6 +1281,7 @@ const getIndentAndJSDoc = function (lines, jsdocNode) {
907
1281
  * @param {boolean} additiveCommentContexts If true, will have a separate
908
1282
  * iteration for each matching comment context. Otherwise, will iterate
909
1283
  * once if there is a single matching comment context.
1284
+ * @returns {import('eslint').Rule.RuleModule}
910
1285
  */
911
1286
  const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContexts) => {
912
1287
  const trackedJsdocs = new Set();
@@ -1016,6 +1391,7 @@ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContext
1016
1391
  *
1017
1392
  * @param {JsdocVisitor} iterator
1018
1393
  * @param {RuleConfig} ruleConfig
1394
+ * @returns {import('eslint').Rule.RuleModule}
1019
1395
  */
1020
1396
  const checkFile = (iterator, ruleConfig) => {
1021
1397
  return {
@@ -1050,6 +1426,7 @@ const checkFile = (iterator, ruleConfig) => {
1050
1426
  /**
1051
1427
  * @param {JsdocVisitor} iterator
1052
1428
  * @param {RuleConfig} ruleConfig
1429
+ * @returns {import('eslint').Rule.RuleModule}
1053
1430
  */
1054
1431
  function iterateJsdoc(iterator, ruleConfig) {
1055
1432
  var _ruleConfig$meta;
@@ -1066,14 +1443,16 @@ function iterateJsdoc(iterator, ruleConfig) {
1066
1443
  if (ruleConfig.iterateAllJsdocs) {
1067
1444
  return iterateAllJsdocs(iterator, ruleConfig);
1068
1445
  }
1446
+
1447
+ /** @type {import('eslint').Rule.RuleModule} */
1069
1448
  return {
1070
1449
  /**
1071
1450
  * The entrypoint for the JSDoc rule.
1072
1451
  *
1073
- * @param {*} context
1452
+ * @param {import('eslint').Rule.RuleContext} context
1074
1453
  * a reference to the context which hold all important information
1075
1454
  * like settings and the sourcecode to check.
1076
- * @returns {object}
1455
+ * @returns {import('eslint').Rule.RuleListener}
1077
1456
  * a list with parser callback function.
1078
1457
  */
1079
1458
  create(context) {