eslint-plugin-jsdoc 61.1.11 → 61.2.0

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 (50) hide show
  1. package/dist/buildForbidRuleDefinition.cjs +1 -3
  2. package/dist/buildForbidRuleDefinition.cjs.map +1 -1
  3. package/dist/buildForbidRuleDefinition.d.ts +1 -1
  4. package/dist/buildRejectOrPreferRuleDefinition.cjs +1 -3
  5. package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -1
  6. package/dist/buildRejectOrPreferRuleDefinition.d.ts +1 -1
  7. package/dist/cjs/buildForbidRuleDefinition.d.ts +1 -1
  8. package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +1 -1
  9. package/dist/cjs/iterateJsdoc.d.ts +2 -4
  10. package/dist/cjs/rules/checkTypes.d.ts +1 -1
  11. package/dist/cjs/rules/convertToJsdocComments.d.ts +105 -97
  12. package/dist/cjs/rules/noRestrictedSyntax.d.ts +1 -1
  13. package/dist/cjs/rules/requireTags.d.ts +1 -1
  14. package/dist/exportParser.cjs +1 -0
  15. package/dist/exportParser.cjs.map +1 -1
  16. package/dist/iterateJsdoc.cjs +3 -7
  17. package/dist/iterateJsdoc.cjs.map +1 -1
  18. package/dist/iterateJsdoc.d.ts +2 -4
  19. package/dist/jsdocUtils.cjs +4 -2
  20. package/dist/jsdocUtils.cjs.map +1 -1
  21. package/dist/rules/checkTypes.d.ts +1 -1
  22. package/dist/rules/convertToJsdocComments.cjs +1 -0
  23. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  24. package/dist/rules/convertToJsdocComments.d.ts +105 -97
  25. package/dist/rules/noRestrictedSyntax.d.ts +1 -1
  26. package/dist/rules/noUndefinedTypes.cjs +10 -1
  27. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  28. package/dist/rules/requireFileOverview.cjs +1 -1
  29. package/dist/rules/requireFileOverview.cjs.map +1 -1
  30. package/dist/rules/requireJsdoc.cjs +1 -0
  31. package/dist/rules/requireJsdoc.cjs.map +1 -1
  32. package/dist/rules/requireParam.cjs +1 -1
  33. package/dist/rules/requireParam.cjs.map +1 -1
  34. package/dist/rules/requireTags.d.ts +1 -1
  35. package/dist/rules/sortTags.cjs +13 -1
  36. package/dist/rules/sortTags.cjs.map +1 -1
  37. package/dist/rules.d.ts +10 -0
  38. package/package.json +7 -7
  39. package/src/buildForbidRuleDefinition.js +1 -3
  40. package/src/buildRejectOrPreferRuleDefinition.js +1 -3
  41. package/src/exportParser.js +1 -0
  42. package/src/iterateJsdoc.js +3 -7
  43. package/src/jsdocUtils.js +9 -3
  44. package/src/rules/convertToJsdocComments.js +1 -0
  45. package/src/rules/noUndefinedTypes.js +11 -0
  46. package/src/rules/requireFileOverview.js +1 -1
  47. package/src/rules/requireJsdoc.js +1 -0
  48. package/src/rules/requireParam.js +1 -1
  49. package/src/rules/sortTags.js +13 -1
  50. package/src/rules.d.ts +10 -0
@@ -466,6 +466,16 @@ export default iterateJsdoc(({
466
466
  return utils.isNamepathOrUrlReferencingTag(tag);
467
467
  }).map(tagToParsedType('namepathOrURL'));
468
468
 
469
+ const definedNamesAndNamepaths = new Set(utils.filterTags(({
470
+ tag,
471
+ }) => {
472
+ return utils.isNameOrNamepathDefiningTag(tag);
473
+ }).map(({
474
+ name,
475
+ }) => {
476
+ return name;
477
+ }));
478
+
469
479
  const tagsWithTypes = /** @type {TypeAndTagInfo[]} */ ([
470
480
  ...typeTags,
471
481
  ...namepathReferencingTags,
@@ -520,6 +530,7 @@ export default iterateJsdoc(({
520
530
  if (type === 'JsdocTypeName') {
521
531
  const structuredTypes = structuredTags[tag.tag]?.type;
522
532
  if (!allDefinedTypes.has(val) &&
533
+ !definedNamesAndNamepaths.has(val) &&
523
534
  (!Array.isArray(structuredTypes) || !structuredTypes.includes(val))
524
535
  ) {
525
536
  const parent =
@@ -207,7 +207,7 @@ will be checked, but you must use \`file\` on the configuration object).`,
207
207
  state,
208
208
  }) {
209
209
  if (!state.hasNonComment) {
210
- state.hasNonComment = node.range[0];
210
+ state.hasNonComment = /** @type {[number, number]} */ (node.range)?.[0];
211
211
  }
212
212
  },
213
213
  });
@@ -670,6 +670,7 @@ export default {
670
670
 
671
671
  const decorator = getDecorator(
672
672
  /** @type {import('eslint').Rule.Node} */
673
+ // @ts-expect-error Bug?
673
674
  (baseNode),
674
675
  );
675
676
  if (decorator) {
@@ -74,7 +74,7 @@ export default iterateJsdoc(({
74
74
  return;
75
75
  }
76
76
 
77
- if (node && node.parent.type === 'VariableDeclarator' &&
77
+ if (node && node.parent?.type === 'VariableDeclarator' &&
78
78
  'typeAnnotation' in node.parent.id && node.parent.id.typeAnnotation) {
79
79
  return;
80
80
  }
@@ -5,11 +5,13 @@ export default iterateJsdoc(({
5
5
  context,
6
6
  jsdoc,
7
7
  utils,
8
+ // eslint-disable-next-line complexity -- Temporary
8
9
  }) => {
9
10
  const
10
11
  /**
11
12
  * @type {{
12
13
  * linesBetween: import('../iterateJsdoc.js').Integer,
14
+ * tagExceptions: Record<string, number>,
13
15
  * tagSequence: {
14
16
  * tags: string[]
15
17
  * }[],
@@ -22,6 +24,7 @@ export default iterateJsdoc(({
22
24
  linesBetween = 1,
23
25
  reportIntraTagGroupSpacing = true,
24
26
  reportTagGroupSpacing = true,
27
+ tagExceptions = {},
25
28
  tagSequence = defaultTagOrder,
26
29
  } = context.options[0] || {};
27
30
 
@@ -328,7 +331,7 @@ export default iterateJsdoc(({
328
331
  }
329
332
 
330
333
  const ct = countTagEmptyLines(tag);
331
- if (ct) {
334
+ if (ct && (!tagExceptions[tag.tag] || tagExceptions[tag.tag] < ct)) {
332
335
  const fixer = () => {
333
336
  let foundFirstTag = false;
334
337
 
@@ -548,6 +551,15 @@ will not have spacing applied regardless. For adding line breaks there, you
548
551
  may wish to use the \`endLines\` option of the \`tag-lines\` rule.`,
549
552
  type: 'boolean',
550
553
  },
554
+ tagExceptions: {
555
+ description: 'Allows specification by tag of a specific higher maximum number of lines. Keys are tags and values are the maximum number of lines allowed for such tags. Overrides `linesBetween`. Defaults to no special exceptions per tag.',
556
+ patternProperties: {
557
+ '.*': {
558
+ type: 'number',
559
+ },
560
+ },
561
+ type: 'object',
562
+ },
551
563
  tagSequence: {
552
564
  description: `An array of tag group objects indicating the preferred sequence for sorting tags.
553
565
 
package/src/rules.d.ts CHANGED
@@ -2660,6 +2660,16 @@ export interface Rules {
2660
2660
  * may wish to use the `endLines` option of the `tag-lines` rule.
2661
2661
  */
2662
2662
  reportTagGroupSpacing?: boolean;
2663
+ /**
2664
+ * Allows specification by tag of a specific higher maximum number of lines. Keys are tags and values are the maximum number of lines allowed for such tags. Overrides `linesBetween`. Defaults to no special exceptions per tag.
2665
+ */
2666
+ tagExceptions?: {
2667
+ /**
2668
+ * This interface was referenced by `undefined`'s JSON-Schema definition
2669
+ * via the `patternProperty` ".*".
2670
+ */
2671
+ [k: string]: number;
2672
+ };
2663
2673
  /**
2664
2674
  * An array of tag group objects indicating the preferred sequence for sorting tags.
2665
2675
  *