eslint-plugin-jsdoc 37.9.1 → 37.9.2

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.
@@ -14,6 +14,10 @@ var _tagNames = require("./tagNames");
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
16
  /* eslint-disable jsdoc/no-undefined-types */
17
+
18
+ /**
19
+ * @typedef {"jsdoc"|"typescript"|"closure"} ParserMode
20
+ */
17
21
  let tagStructure;
18
22
 
19
23
  const setTagStructure = mode => {
@@ -86,6 +90,11 @@ const flattenRoots = (params, root = '') => {
86
90
  rests
87
91
  };
88
92
  };
93
+ /**
94
+ * @param {object} propSignature
95
+ * @returns {undefined|Array|string}
96
+ */
97
+
89
98
 
90
99
  const getPropertiesFromPropertySignature = propSignature => {
91
100
  if (propSignature.type === 'TSIndexSignature' || propSignature.type === 'TSConstructSignatureDeclaration' || propSignature.type === 'TSCallSignatureDeclaration') {
@@ -100,6 +109,12 @@ const getPropertiesFromPropertySignature = propSignature => {
100
109
 
101
110
  return propSignature.key.name;
102
111
  };
112
+ /**
113
+ * @param {object} functionNode
114
+ * @param {boolean} checkDefaultObjects
115
+ * @returns {Array}
116
+ */
117
+
103
118
 
104
119
  const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
105
120
  // eslint-disable-next-line complexity
@@ -243,6 +258,11 @@ const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
243
258
  return getParamName(param);
244
259
  });
245
260
  };
261
+ /**
262
+ * @param {Node} functionNode
263
+ * @returns {Integer}
264
+ */
265
+
246
266
 
247
267
  const hasParams = functionNode => {
248
268
  // Should also check `functionNode.value.params` if supporting `MethodDefinition`
@@ -251,6 +271,10 @@ const hasParams = functionNode => {
251
271
  /**
252
272
  * Gets all names of the target type, including those that refer to a path, e.g.
253
273
  * "@param foo; @param foo.bar".
274
+ *
275
+ * @param {object} jsdoc
276
+ * @param {string} targetTagName
277
+ * @returns {Array<object>}
254
278
  */
255
279
 
256
280
 
@@ -277,6 +301,10 @@ const getJsdocTagsDeep = (jsdoc, targetTagName) => {
277
301
  };
278
302
 
279
303
  const modeWarnSettings = (0, _WarnSettings.default)();
304
+ /**
305
+ * @param {string} mode
306
+ * @param context
307
+ */
280
308
 
281
309
  const getTagNamesForMode = (mode, context) => {
282
310
  switch (mode) {
@@ -308,6 +336,14 @@ const getTagNamesForMode = (mode, context) => {
308
336
  return _tagNames.jsdocTags;
309
337
  }
310
338
  };
339
+ /**
340
+ * @param context
341
+ * @param {ParserMode} mode
342
+ * @param {string} name
343
+ * @param {object} tagPreference
344
+ * @returns {string|object}
345
+ */
346
+
311
347
 
312
348
  const getPreferredTagName = (context, mode, name, tagPreference = {}) => {
313
349
  var _Object$entries$find;
@@ -344,6 +380,14 @@ const getPreferredTagName = (context, mode, name, tagPreference = {}) => {
344
380
 
345
381
  return name;
346
382
  };
383
+ /**
384
+ * @param context
385
+ * @param {ParserMode} mode
386
+ * @param {string} name
387
+ * @param {Array} definedTags
388
+ * @returns {boolean}
389
+ */
390
+
347
391
 
348
392
  const isValidTag = (context, mode, name, definedTags) => {
349
393
  const tagNames = getTagNamesForMode(mode, context);
@@ -352,6 +396,12 @@ const isValidTag = (context, mode, name, definedTags) => {
352
396
  const allTags = validTagNames.concat(additionalTags);
353
397
  return allTags.includes(name);
354
398
  };
399
+ /**
400
+ * @param {object} jsdoc
401
+ * @param {string} targetTagName
402
+ * @returns {boolean}
403
+ */
404
+
355
405
 
356
406
  const hasTag = (jsdoc, targetTagName) => {
357
407
  const targetTagLower = targetTagName.toLowerCase();
@@ -359,6 +409,12 @@ const hasTag = (jsdoc, targetTagName) => {
359
409
  return doc.tag.toLowerCase() === targetTagLower;
360
410
  });
361
411
  };
412
+ /**
413
+ * @param {object} jsdoc
414
+ * @param {Array} targetTagNames
415
+ * @returns {boolean}
416
+ */
417
+
362
418
 
363
419
  const hasATag = (jsdoc, targetTagNames) => {
364
420
  return targetTagNames.some(targetTagName => {
@@ -391,6 +447,12 @@ const hasDefinedTypeTag = tag => {
391
447
 
392
448
  return true;
393
449
  };
450
+ /**
451
+ * @param map
452
+ * @param tag
453
+ * @returns {Map}
454
+ */
455
+
394
456
 
395
457
  const ensureMap = (map, tag) => {
396
458
  if (!map.has(tag)) {
@@ -399,6 +461,11 @@ const ensureMap = (map, tag) => {
399
461
 
400
462
  return map.get(tag);
401
463
  };
464
+ /**
465
+ * @param structuredTags
466
+ * @param tagMap
467
+ */
468
+
402
469
 
403
470
  const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
404
471
  for (const [tag, {
@@ -436,6 +503,12 @@ const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
436
503
  tagStruct.set('typeOrNameRequired', typeOrNameRequired);
437
504
  }
438
505
  };
506
+ /**
507
+ * @param mode
508
+ * @param structuredTags
509
+ * @returns {Map}
510
+ */
511
+
439
512
 
440
513
  const getTagStructureForMode = (mode, structuredTags) => {
441
514
  const tagStruct = (0, _getDefaultTagStructureForMode.default)(mode);
@@ -447,16 +520,34 @@ const getTagStructureForMode = (mode, structuredTags) => {
447
520
 
448
521
  return tagStruct;
449
522
  };
523
+ /**
524
+ * @param tag
525
+ * @param {Map} tagMap
526
+ * @returns {boolean}
527
+ */
528
+
450
529
 
451
530
  const isNamepathDefiningTag = (tag, tagMap = tagStructure) => {
452
531
  const tagStruct = ensureMap(tagMap, tag);
453
532
  return tagStruct.get('nameContents') === 'namepath-defining';
454
533
  };
534
+ /**
535
+ * @param tag
536
+ * @param {Map} tagMap
537
+ * @returns {boolean}
538
+ */
539
+
455
540
 
456
541
  const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
457
542
  const tagStruct = ensureMap(tagMap, tag);
458
543
  return tagStruct.get('typeRequired');
459
544
  };
545
+ /**
546
+ * @param tag
547
+ * @param {Map} tagMap
548
+ * @returns {boolean}
549
+ */
550
+
460
551
 
461
552
  const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
462
553
  if (tagMustHaveTypePosition(tag, tagMap)) {
@@ -469,31 +560,66 @@ const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
469
560
  };
470
561
 
471
562
  const namepathTypes = new Set(['namepath-defining', 'namepath-referencing']);
563
+ /**
564
+ * @param tag
565
+ * @param {Map} tagMap
566
+ * @returns {boolean}
567
+ */
472
568
 
473
569
  const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => {
474
570
  const tagStruct = ensureMap(tagMap, tag);
475
571
  const ret = tagStruct.get('nameContents');
476
572
  return ret === undefined ? true : Boolean(ret);
477
573
  };
574
+ /**
575
+ * @param tag
576
+ * @param {Map} tagMap
577
+ * @returns {boolean}
578
+ */
579
+
478
580
 
479
581
  const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
480
582
  const tagStruct = ensureMap(tagMap, tag);
481
583
  return namepathTypes.has(tagStruct.get('nameContents'));
482
584
  };
585
+ /**
586
+ * @param tag
587
+ * @param {Map} tagMap
588
+ * @returns {boolean}
589
+ */
590
+
483
591
 
484
592
  const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
485
593
  const tagStruct = ensureMap(tagMap, tag);
486
594
  return tagStruct.get('nameRequired');
487
595
  };
596
+ /**
597
+ * @param tag
598
+ * @param {Map} tagMap
599
+ * @returns {boolean}
600
+ */
601
+
488
602
 
489
603
  const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
490
604
  return tagMightHaveTypePosition(tag, tagMap) || tagMightHaveNamepath(tag, tagMap);
491
605
  };
606
+ /**
607
+ * @param tag
608
+ * @param {Map} tagMap
609
+ * @returns {boolean}
610
+ */
611
+
492
612
 
493
613
  const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => {
494
614
  const tagStruct = ensureMap(tagMap, tag);
495
615
  return tagStruct.get('typeOrNameRequired');
496
616
  };
617
+ /**
618
+ * @param tag
619
+ * @param {Map} tagMap
620
+ * @returns {boolean}
621
+ */
622
+
497
623
 
498
624
  const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
499
625
  const mustHaveTypePosition = tagMustHaveTypePosition(tag.tag, tagMap);
@@ -1293,16 +1419,33 @@ const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
1293
1419
  const dropPathSegmentQuotes = str => {
1294
1420
  return str.replace(/\.(['"])(.*)\1/gu, '.$2');
1295
1421
  };
1422
+ /**
1423
+ * @param {string} name
1424
+ * @returns {(otherPathName: string) => void}
1425
+ */
1426
+
1296
1427
 
1297
1428
  const comparePaths = name => {
1298
1429
  return otherPathName => {
1299
1430
  return otherPathName === name || dropPathSegmentQuotes(otherPathName) === dropPathSegmentQuotes(name);
1300
1431
  };
1301
1432
  };
1433
+ /**
1434
+ * @param {string} name
1435
+ * @param {string} otherPathName
1436
+ * @returns {boolean}
1437
+ */
1438
+
1302
1439
 
1303
1440
  const pathDoesNotBeginWith = (name, otherPathName) => {
1304
1441
  return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
1305
1442
  };
1443
+ /**
1444
+ * @param {string} regexString
1445
+ * @param {string} requiredFlags
1446
+ * @returns {RegExp}
1447
+ */
1448
+
1306
1449
 
1307
1450
  const getRegexFromString = (regexString, requiredFlags) => {
1308
1451
  const match = regexString.match(/^\/(.*)\/([gimyus]*)$/us);