eslint-plugin-jsdoc 63.0.9 → 63.0.11

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 (174) hide show
  1. package/dist/WarnSettings.cjs +1 -8
  2. package/dist/WarnSettings.cjs.map +1 -1
  3. package/dist/alignTransform.cjs +6 -10
  4. package/dist/alignTransform.cjs.map +1 -1
  5. package/dist/buildForbidRuleDefinition.cjs +3 -10
  6. package/dist/buildForbidRuleDefinition.cjs.map +1 -1
  7. package/dist/buildRejectOrPreferRuleDefinition.cjs +7 -14
  8. package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -1
  9. package/dist/defaultTagOrder.cjs +1 -8
  10. package/dist/defaultTagOrder.cjs.map +1 -1
  11. package/dist/exportParser.cjs +6 -14
  12. package/dist/exportParser.cjs.map +1 -1
  13. package/dist/generateDocs.cjs +36 -44
  14. package/dist/generateDocs.cjs.map +1 -1
  15. package/dist/generateOptions.cjs +15 -18
  16. package/dist/generateOptions.cjs.map +1 -1
  17. package/dist/generateRule.cjs +24 -24
  18. package/dist/generateRule.cjs.map +1 -1
  19. package/dist/generateRuleTypes.cjs +6 -9
  20. package/dist/generateRuleTypes.cjs.map +1 -1
  21. package/dist/getDefaultTagStructureForMode.cjs +1 -8
  22. package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
  23. package/dist/getJsdocProcessorPlugin.cjs +20 -28
  24. package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
  25. package/dist/index-cjs.cjs +152 -159
  26. package/dist/index-cjs.cjs.map +1 -1
  27. package/dist/index-esm.cjs +16 -27
  28. package/dist/index-esm.cjs.map +1 -1
  29. package/dist/index.cjs +159 -172
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/iterateJsdoc.cjs +22 -32
  32. package/dist/iterateJsdoc.cjs.map +1 -1
  33. package/dist/jsdocUtils.cjs +18 -86
  34. package/dist/jsdocUtils.cjs.map +1 -1
  35. package/dist/rules/checkAccess.cjs +2 -10
  36. package/dist/rules/checkAccess.cjs.map +1 -1
  37. package/dist/rules/checkAlignment.cjs +2 -10
  38. package/dist/rules/checkAlignment.cjs.map +1 -1
  39. package/dist/rules/checkExamples.cjs +6 -15
  40. package/dist/rules/checkExamples.cjs.map +1 -1
  41. package/dist/rules/checkIndentation.cjs +2 -9
  42. package/dist/rules/checkIndentation.cjs.map +1 -1
  43. package/dist/rules/checkLineAlignment.cjs +6 -14
  44. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  45. package/dist/rules/checkParamNames.cjs +2 -9
  46. package/dist/rules/checkParamNames.cjs.map +1 -1
  47. package/dist/rules/checkPropertyNames.cjs +2 -9
  48. package/dist/rules/checkPropertyNames.cjs.map +1 -1
  49. package/dist/rules/checkSyntax.cjs +2 -10
  50. package/dist/rules/checkSyntax.cjs.map +1 -1
  51. package/dist/rules/checkTagNames.cjs +4 -11
  52. package/dist/rules/checkTagNames.cjs.map +1 -1
  53. package/dist/rules/checkTemplateNames.cjs +12 -21
  54. package/dist/rules/checkTemplateNames.cjs.map +1 -1
  55. package/dist/rules/checkTypes.cjs +4 -10
  56. package/dist/rules/checkTypes.cjs.map +1 -1
  57. package/dist/rules/checkValues.cjs +9 -17
  58. package/dist/rules/checkValues.cjs.map +1 -1
  59. package/dist/rules/convertToJsdocComments.cjs +13 -19
  60. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  61. package/dist/rules/emptyTags.cjs +2 -10
  62. package/dist/rules/emptyTags.cjs.map +1 -1
  63. package/dist/rules/escapeInlineTags.cjs +96 -42
  64. package/dist/rules/escapeInlineTags.cjs.map +1 -1
  65. package/dist/rules/implementsOnClasses.cjs +2 -10
  66. package/dist/rules/implementsOnClasses.cjs.map +1 -1
  67. package/dist/rules/importsAsDependencies.cjs +12 -20
  68. package/dist/rules/importsAsDependencies.cjs.map +1 -1
  69. package/dist/rules/informativeDocs.cjs +4 -12
  70. package/dist/rules/informativeDocs.cjs.map +1 -1
  71. package/dist/rules/linesBeforeBlock.cjs +2 -9
  72. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  73. package/dist/rules/matchDescription.cjs +2 -9
  74. package/dist/rules/matchDescription.cjs.map +1 -1
  75. package/dist/rules/matchName.cjs +2 -10
  76. package/dist/rules/matchName.cjs.map +1 -1
  77. package/dist/rules/multilineBlocks.cjs +2 -9
  78. package/dist/rules/multilineBlocks.cjs.map +1 -1
  79. package/dist/rules/noBadBlocks.cjs +4 -11
  80. package/dist/rules/noBadBlocks.cjs.map +1 -1
  81. package/dist/rules/noBlankBlockDescriptions.cjs +2 -10
  82. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
  83. package/dist/rules/noBlankBlocks.cjs +2 -10
  84. package/dist/rules/noBlankBlocks.cjs.map +1 -1
  85. package/dist/rules/noDefaults.cjs +2 -10
  86. package/dist/rules/noDefaults.cjs.map +1 -1
  87. package/dist/rules/noMissingSyntax.cjs +2 -9
  88. package/dist/rules/noMissingSyntax.cjs.map +1 -1
  89. package/dist/rules/noMultiAsterisks.cjs +2 -10
  90. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  91. package/dist/rules/noRestrictedSyntax.cjs +2 -9
  92. package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
  93. package/dist/rules/noTypes.cjs +2 -9
  94. package/dist/rules/noTypes.cjs.map +1 -1
  95. package/dist/rules/noUndefinedTypes.cjs +13 -21
  96. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  97. package/dist/rules/preferImportTag.cjs +21 -28
  98. package/dist/rules/preferImportTag.cjs.map +1 -1
  99. package/dist/rules/requireAsteriskPrefix.cjs +2 -10
  100. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  101. package/dist/rules/requireDescription.cjs +2 -9
  102. package/dist/rules/requireDescription.cjs.map +1 -1
  103. package/dist/rules/requireDescriptionCompleteSentence.cjs +7 -15
  104. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  105. package/dist/rules/requireExample.cjs +2 -10
  106. package/dist/rules/requireExample.cjs.map +1 -1
  107. package/dist/rules/requireFileOverview.cjs +2 -10
  108. package/dist/rules/requireFileOverview.cjs.map +1 -1
  109. package/dist/rules/requireHyphenBeforeParamDescription.cjs +2 -10
  110. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  111. package/dist/rules/requireJsdoc.cjs +17 -25
  112. package/dist/rules/requireJsdoc.cjs.map +1 -1
  113. package/dist/rules/requireParam.cjs +2 -9
  114. package/dist/rules/requireParam.cjs.map +1 -1
  115. package/dist/rules/requireParamDescription.cjs +2 -10
  116. package/dist/rules/requireParamDescription.cjs.map +1 -1
  117. package/dist/rules/requireParamName.cjs +2 -10
  118. package/dist/rules/requireParamName.cjs.map +1 -1
  119. package/dist/rules/requireParamType.cjs +2 -10
  120. package/dist/rules/requireParamType.cjs.map +1 -1
  121. package/dist/rules/requireProperty.cjs +2 -10
  122. package/dist/rules/requireProperty.cjs.map +1 -1
  123. package/dist/rules/requirePropertyDescription.cjs +2 -10
  124. package/dist/rules/requirePropertyDescription.cjs.map +1 -1
  125. package/dist/rules/requirePropertyName.cjs +2 -10
  126. package/dist/rules/requirePropertyName.cjs.map +1 -1
  127. package/dist/rules/requirePropertyType.cjs +2 -10
  128. package/dist/rules/requirePropertyType.cjs.map +1 -1
  129. package/dist/rules/requireRejects.cjs +2 -9
  130. package/dist/rules/requireRejects.cjs.map +1 -1
  131. package/dist/rules/requireReturns.cjs +4 -11
  132. package/dist/rules/requireReturns.cjs.map +1 -1
  133. package/dist/rules/requireReturnsCheck.cjs +8 -15
  134. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  135. package/dist/rules/requireReturnsDescription.cjs +2 -10
  136. package/dist/rules/requireReturnsDescription.cjs.map +1 -1
  137. package/dist/rules/requireReturnsType.cjs +2 -10
  138. package/dist/rules/requireReturnsType.cjs.map +1 -1
  139. package/dist/rules/requireTags.cjs +2 -9
  140. package/dist/rules/requireTags.cjs.map +1 -1
  141. package/dist/rules/requireTemplate.cjs +5 -13
  142. package/dist/rules/requireTemplate.cjs.map +1 -1
  143. package/dist/rules/requireThrows.cjs +2 -9
  144. package/dist/rules/requireThrows.cjs.map +1 -1
  145. package/dist/rules/requireYields.cjs +2 -9
  146. package/dist/rules/requireYields.cjs.map +1 -1
  147. package/dist/rules/requireYieldsCheck.cjs +2 -9
  148. package/dist/rules/requireYieldsCheck.cjs.map +1 -1
  149. package/dist/rules/sortTags.cjs +4 -12
  150. package/dist/rules/sortTags.cjs.map +1 -1
  151. package/dist/rules/tagLines.cjs +2 -9
  152. package/dist/rules/tagLines.cjs.map +1 -1
  153. package/dist/rules/textEscaping.cjs +2 -9
  154. package/dist/rules/textEscaping.cjs.map +1 -1
  155. package/dist/rules/tsMethodSignatureStyle.cjs +10 -18
  156. package/dist/rules/tsMethodSignatureStyle.cjs.map +1 -1
  157. package/dist/rules/tsNoEmptyObjectType.cjs +5 -13
  158. package/dist/rules/tsNoEmptyObjectType.cjs.map +1 -1
  159. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +8 -16
  160. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +1 -1
  161. package/dist/rules/tsPreferFunctionType.cjs +8 -16
  162. package/dist/rules/tsPreferFunctionType.cjs.map +1 -1
  163. package/dist/rules/typeFormatting.cjs +9 -17
  164. package/dist/rules/typeFormatting.cjs.map +1 -1
  165. package/dist/rules/validTypes.cjs +10 -18
  166. package/dist/rules/validTypes.cjs.map +1 -1
  167. package/dist/tagNames.cjs +4 -9
  168. package/dist/tagNames.cjs.map +1 -1
  169. package/dist/utils/hasReturnValue.cjs +1 -8
  170. package/dist/utils/hasReturnValue.cjs.map +1 -1
  171. package/package.json +21 -21
  172. package/src/rules/checkTemplateNames.js +0 -1
  173. package/src/rules/escapeInlineTags.js +142 -45
  174. package/src/rules/requireJsdoc.js +0 -1
@@ -1,12 +1,6 @@
1
- "use strict";
1
+ import exportParser from '../exportParser.js';
2
+ import iterateJsdoc from '../iterateJsdoc.js';
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _exportParser = _interopRequireDefault(require("../exportParser.cjs"));
8
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
4
  /**
11
5
  * We can skip checking for a return value, in case the documentation is inherited
12
6
  * or the method is either a constructor or an abstract method.
@@ -33,7 +27,7 @@ const canSkip = utils => {
33
27
  // This seems to imply a class as well
34
28
  'interface']) || utils.avoidDocs();
35
29
  };
36
- var _default = exports.default = (0, _iterateJsdoc.default)(({
30
+ export default iterateJsdoc(({
37
31
  context,
38
32
  info: {
39
33
  comment
@@ -99,7 +93,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
99
93
  // @ts-expect-error ESLint < 10
100
94
  sourceCode = context.getSourceCode()
101
95
  } = context;
102
- const exported = _exportParser.default.isUncommentedExport(/** @type {import('eslint').Rule.Node} */node, sourceCode, opt, settings);
96
+ const exported = exportParser.isUncommentedExport(/** @type {import('eslint').Rule.Node} */node, sourceCode, opt, settings);
103
97
  if (!exported) {
104
98
  return false;
105
99
  }
@@ -258,5 +252,4 @@ otherwise noted):
258
252
  type: 'suggestion'
259
253
  }
260
254
  });
261
- module.exports = exports.default;
262
255
  //# sourceMappingURL=requireReturns.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"requireReturns.cjs","names":["_exportParser","_interopRequireDefault","require","_iterateJsdoc","e","__esModule","default","canSkip","utils","hasATag","avoidDocs","_default","exports","iterateJsdoc","context","info","comment","node","report","settings","contexts","enableFixer","forceRequireReturn","forceReturnsWithAsync","publicOnly","options","forceRequireReturnContext","foundContext","findContext","tagName","getPreferredTagName","tags","getTags","length","iteratingFunction","isIteratingFunction","tag","missingReturnTag","shouldReport","opt","ancestorsOnly","Boolean","esm","initModuleExports","cjs","initWindow","window","sourceCode","getSourceCode","exported","exportParser","isUncommentedExport","isVirtualFunction","isAsync","hasTag","hasValueOrExecutorHasNonEmptyResolveValue","reportJSDoc","addTag","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","checkConstructors","type","checkGetters","items","anyOf","exemptedBy","oneOf","module"],"sources":["../../src/rules/requireReturns.js"],"sourcesContent":["import exportParser from '../exportParser.js';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a return value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n *\n * In either of these cases the return value is optional or not defined.\n * @param {import('../iterateJsdoc.js').Utils} utils\n * a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean}\n * true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not an error if it declares a return value but does not implement it.\n 'abstract',\n 'virtual',\n\n // Constructors do not have a return value by definition (https://jsdoc.app/tags-class.html)\n // So we can bail out here, too.\n 'class',\n 'constructor',\n\n // Return type is specified by type in @type\n 'type',\n\n // This seems to imply a class as well\n 'interface',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n context,\n info: {\n comment,\n },\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n contexts,\n enableFixer = false,\n forceRequireReturn = false,\n forceReturnsWithAsync = false,\n publicOnly = false,\n } = context.options[0] || {};\n\n // A preflight check. We do not need to run a deep check\n // in case the @returns comment is optional or undefined.\n if (canSkip(utils)) {\n return;\n }\n\n /** @type {boolean|undefined} */\n let forceRequireReturnContext;\n if (contexts) {\n const {\n foundContext,\n } = utils.findContext(contexts, comment);\n if (typeof foundContext === 'object') {\n forceRequireReturnContext = foundContext.forceRequireReturn;\n }\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n }\n\n const iteratingFunction = utils.isIteratingFunction();\n\n // In case the code returns something, we expect a return value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingReturnTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingReturnTag) {\n return false;\n }\n\n if (publicOnly) {\n /** @type {import('./requireJsdoc.js').RequireJsdocOpts} */\n const opt = {\n ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),\n esm: Boolean(publicOnly?.esm ?? true),\n initModuleExports: Boolean(publicOnly?.cjs ?? true),\n initWindow: Boolean(publicOnly?.window ?? false),\n };\n /* c8 ignore next -- Fallback to deprecated method */\n const {\n // @ts-expect-error ESLint < 10\n sourceCode = context.getSourceCode(),\n } = context;\n const exported = exportParser.isUncommentedExport(\n /** @type {import('eslint').Rule.Node} */ (node), sourceCode, opt, settings,\n );\n\n if (!exported) {\n return false;\n }\n }\n\n if ((forceRequireReturn || forceRequireReturnContext) && (\n iteratingFunction || utils.isVirtualFunction()\n )) {\n return true;\n }\n\n const isAsync = !iteratingFunction && utils.hasTag('async') ||\n iteratingFunction && utils.isAsync();\n\n if (forceReturnsWithAsync && isAsync) {\n return true;\n }\n\n return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(\n forceReturnsWithAsync,\n );\n };\n\n if (shouldReport()) {\n utils.reportJSDoc(`Missing JSDoc @${tagName} declaration.`, null, enableFixer ? () => {\n utils.addTag(tagName);\n } : null);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that returns are documented with `@returns`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkConstructors: {\n default: false,\n description: `A value indicating whether \\`constructor\\`s should\nbe checked for \\`@returns\\` tags. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n checkGetters: {\n default: true,\n description: `Boolean to determine whether getter methods should\nbe checked for \\`@returns\\` tags. Defaults to \\`true\\`.`,\n type: 'boolean',\n },\n contexts: {\n description: `Set this to an array of strings representing the AST context\n(or objects with optional \\`context\\` and \\`comment\\` properties) where you wish\nthe rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`). This\nrule will only apply on non-default contexts when there is such a tag\npresent and the \\`forceRequireReturn\\` option is set or if the\n\\`forceReturnsWithAsync\\` option is set with a present \\`@async\\` tag\n(since we are not checking against the actual \\`return\\` values in these\ncases).`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n forceRequireReturn: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n enableFixer: {\n description: `Whether to enable the fixer to add a blank \\`@returns\\`.\nDefaults to \\`false\\`.`,\n type: 'boolean',\n },\n exemptedBy: {\n description: `Array of tags (e.g., \\`['type']\\`) whose presence on the\ndocument block avoids the need for a \\`@returns\\`. Defaults to an array\nwith \\`inheritdoc\\`. If you set this array, it will overwrite the default,\nso be sure to add back \\`inheritdoc\\` if you wish its presence to cause\nexemption of the rule.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n forceRequireReturn: {\n default: false,\n description: `Set to \\`true\\` to always insist on\n\\`@returns\\` documentation regardless of implicit or explicit \\`return\\`'s\nin the function. May be desired to flag that a project is aware of an\n\\`undefined\\`/\\`void\\` return. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n forceReturnsWithAsync: {\n default: false,\n description: `By default \\`async\\` functions that do not explicitly\nreturn a value pass this rule as an \\`async\\` function will always return a\n\\`Promise\\`, even if the \\`Promise\\` resolves to void. You can force all\n\\`async\\` functions (including ones with an explicit \\`Promise\\` but no\ndetected non-\\`undefined\\` \\`resolve\\` value) to require \\`@return\\`\ndocumentation by setting \\`forceReturnsWithAsync\\` to \\`true\\` on the options\nobject. This may be useful for flagging that there has been consideration\nof return type. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n publicOnly: {\n description: `This option will insist that missing \\`@returns\\` are only reported for\nfunction bodies / class declarations that are exported from the module.\nMay be a boolean or object. If set to \\`true\\`, the defaults below will be\nused. If unset, \\`@returns\\` reporting will not be limited to exports.\n\nThis object supports the following optional boolean keys (\\`false\\` unless\notherwise noted):\n\n- \\`ancestorsOnly\\` - Optimization to only check node ancestors to check if node is exported\n- \\`esm\\` - ESM exports are checked for \\`@returns\\` JSDoc comments (Defaults to \\`true\\`)\n- \\`cjs\\` - CommonJS exports are checked for \\`@returns\\` JSDoc comments (Defaults to \\`true\\`)\n- \\`window\\` - Window global exports are checked for \\`@returns\\` JSDoc comments`,\n oneOf: [\n {\n default: false,\n type: 'boolean',\n },\n {\n additionalProperties: false,\n default: {},\n properties: {\n ancestorsOnly: {\n type: 'boolean',\n },\n cjs: {\n type: 'boolean',\n },\n esm: {\n type: 'boolean',\n },\n window: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,OAAO,GAAIC,KAAK,IAAK;EACzB,OAAOA,KAA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C,WAAW,EAAE;UACXwC,WAAW,EAAE;AACzB,uBAAuB;UACXO,IAAI,EAAE;QACR,CAAC;QACDI,UAAU,EAAE;UACVX,WAAW,EAAE;AACzB;AACA;AACA;AACA,uBAAuB;UACXS,KAAK,EAAE;YACLF,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACD9C,kBAAkB,EAAE;UAClBhB,OAAO,EAAE,KAAK;UACduD,WAAW,EAAE;AACzB;AACA;AACA,sDAAsD;UAC1CO,IAAI,EAAE;QACR,CAAC;QACD7C,qBAAqB,EAAE;UACrBjB,OAAO,EAAE,KAAK;UACduD,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA,uCAAuC;UAC3BO,IAAI,EAAE;QACR,CAAC;QACD5C,UAAU,EAAE;UACVqC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iFAAiF;UACrEY,KAAK,EAAE,CACL;YACEnE,OAAO,EAAE,KAAK;YACd8D,IAAI,EAAE;UACR,CAAC,EACD;YACEH,oBAAoB,EAAE,KAAK;YAC3B3D,OAAO,EAAE,CAAC,CAAC;YACX4D,UAAU,EAAE;cACV1B,aAAa,EAAE;gBACb4B,IAAI,EAAE;cACR,CAAC;cACDxB,GAAG,EAAE;gBACHwB,IAAI,EAAE;cACR,CAAC;cACD1B,GAAG,EAAE;gBACH0B,IAAI,EAAE;cACR,CAAC;cACDtB,MAAM,EAAE;gBACNsB,IAAI,EAAE;cACR;YACF,CAAC;YACDA,IAAI,EAAE;UACR,CAAC;QAEL;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAM,MAAA,CAAA9D,OAAA,GAAAA,OAAA,CAAAN,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireReturns.cjs","names":[],"sources":["../../src/rules/requireReturns.js"],"sourcesContent":["import exportParser from '../exportParser.js';\nimport iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a return value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n *\n * In either of these cases the return value is optional or not defined.\n * @param {import('../iterateJsdoc.js').Utils} utils\n * a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean}\n * true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not an error if it declares a return value but does not implement it.\n 'abstract',\n 'virtual',\n\n // Constructors do not have a return value by definition (https://jsdoc.app/tags-class.html)\n // So we can bail out here, too.\n 'class',\n 'constructor',\n\n // Return type is specified by type in @type\n 'type',\n\n // This seems to imply a class as well\n 'interface',\n ]) ||\n utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n context,\n info: {\n comment,\n },\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n contexts,\n enableFixer = false,\n forceRequireReturn = false,\n forceReturnsWithAsync = false,\n publicOnly = false,\n } = context.options[0] || {};\n\n // A preflight check. We do not need to run a deep check\n // in case the @returns comment is optional or undefined.\n if (canSkip(utils)) {\n return;\n }\n\n /** @type {boolean|undefined} */\n let forceRequireReturnContext;\n if (contexts) {\n const {\n foundContext,\n } = utils.findContext(contexts, comment);\n if (typeof foundContext === 'object') {\n forceRequireReturnContext = foundContext.forceRequireReturn;\n }\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n }\n\n const iteratingFunction = utils.isIteratingFunction();\n\n // In case the code returns something, we expect a return value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingReturnTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingReturnTag) {\n return false;\n }\n\n if (publicOnly) {\n /** @type {import('./requireJsdoc.js').RequireJsdocOpts} */\n const opt = {\n ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),\n esm: Boolean(publicOnly?.esm ?? true),\n initModuleExports: Boolean(publicOnly?.cjs ?? true),\n initWindow: Boolean(publicOnly?.window ?? false),\n };\n /* c8 ignore next -- Fallback to deprecated method */\n const {\n // @ts-expect-error ESLint < 10\n sourceCode = context.getSourceCode(),\n } = context;\n const exported = exportParser.isUncommentedExport(\n /** @type {import('eslint').Rule.Node} */ (node), sourceCode, opt, settings,\n );\n\n if (!exported) {\n return false;\n }\n }\n\n if ((forceRequireReturn || forceRequireReturnContext) && (\n iteratingFunction || utils.isVirtualFunction()\n )) {\n return true;\n }\n\n const isAsync = !iteratingFunction && utils.hasTag('async') ||\n iteratingFunction && utils.isAsync();\n\n if (forceReturnsWithAsync && isAsync) {\n return true;\n }\n\n return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(\n forceReturnsWithAsync,\n );\n };\n\n if (shouldReport()) {\n utils.reportJSDoc(`Missing JSDoc @${tagName} declaration.`, null, enableFixer ? () => {\n utils.addTag(tagName);\n } : null);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that returns are documented with `@returns`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n checkConstructors: {\n default: false,\n description: `A value indicating whether \\`constructor\\`s should\nbe checked for \\`@returns\\` tags. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n checkGetters: {\n default: true,\n description: `Boolean to determine whether getter methods should\nbe checked for \\`@returns\\` tags. Defaults to \\`true\\`.`,\n type: 'boolean',\n },\n contexts: {\n description: `Set this to an array of strings representing the AST context\n(or objects with optional \\`context\\` and \\`comment\\` properties) where you wish\nthe rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`). This\nrule will only apply on non-default contexts when there is such a tag\npresent and the \\`forceRequireReturn\\` option is set or if the\n\\`forceReturnsWithAsync\\` option is set with a present \\`@async\\` tag\n(since we are not checking against the actual \\`return\\` values in these\ncases).`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n forceRequireReturn: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n enableFixer: {\n description: `Whether to enable the fixer to add a blank \\`@returns\\`.\nDefaults to \\`false\\`.`,\n type: 'boolean',\n },\n exemptedBy: {\n description: `Array of tags (e.g., \\`['type']\\`) whose presence on the\ndocument block avoids the need for a \\`@returns\\`. Defaults to an array\nwith \\`inheritdoc\\`. If you set this array, it will overwrite the default,\nso be sure to add back \\`inheritdoc\\` if you wish its presence to cause\nexemption of the rule.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n forceRequireReturn: {\n default: false,\n description: `Set to \\`true\\` to always insist on\n\\`@returns\\` documentation regardless of implicit or explicit \\`return\\`'s\nin the function. May be desired to flag that a project is aware of an\n\\`undefined\\`/\\`void\\` return. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n forceReturnsWithAsync: {\n default: false,\n description: `By default \\`async\\` functions that do not explicitly\nreturn a value pass this rule as an \\`async\\` function will always return a\n\\`Promise\\`, even if the \\`Promise\\` resolves to void. You can force all\n\\`async\\` functions (including ones with an explicit \\`Promise\\` but no\ndetected non-\\`undefined\\` \\`resolve\\` value) to require \\`@return\\`\ndocumentation by setting \\`forceReturnsWithAsync\\` to \\`true\\` on the options\nobject. This may be useful for flagging that there has been consideration\nof return type. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n publicOnly: {\n description: `This option will insist that missing \\`@returns\\` are only reported for\nfunction bodies / class declarations that are exported from the module.\nMay be a boolean or object. If set to \\`true\\`, the defaults below will be\nused. If unset, \\`@returns\\` reporting will not be limited to exports.\n\nThis object supports the following optional boolean keys (\\`false\\` unless\notherwise noted):\n\n- \\`ancestorsOnly\\` - Optimization to only check node ancestors to check if node is exported\n- \\`esm\\` - ESM exports are checked for \\`@returns\\` JSDoc comments (Defaults to \\`true\\`)\n- \\`cjs\\` - CommonJS exports are checked for \\`@returns\\` JSDoc comments (Defaults to \\`true\\`)\n- \\`window\\` - Window global exports are checked for \\`@returns\\` JSDoc comments`,\n oneOf: [\n {\n default: false,\n type: 'boolean',\n },\n {\n additionalProperties: false,\n default: {},\n properties: {\n ancestorsOnly: {\n type: 'boolean',\n },\n cjs: {\n type: 'boolean',\n },\n esm: {\n type: 'boolean',\n },\n window: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;AAC7C,OAAO,YAAY,MAAM,oBAAoB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,OAAO,GAAI,KAAK,IAAK;EACzB,OAAO,KAAK,CAAC,OAAO,CAAC;EACnB;EACA;EACA;EACA;EACA;EACA,UAAU,EACV,SAAS;EAET;EACA;EACA,OAAO,EACP,aAAa;EAEb;EACA,MAAM;EAEN;EACA,WAAW,CACZ,CAAC,IACA,KAAK,CAAC,SAAS,CAAC,CAAC;AACrB,CAAC;AAED,eAAe,YAAY,CAAC,CAAC;EAC3B,OAAO;EACP,IAAI,EAAE;IACJ;EACF,CAAC;EACD,IAAI;EACJ,MAAM;EACN,QAAQ;EACR;AACF,CAAC,KAAK;EACJ,MAAM;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;YACd,IAAI,EAAE;UACR,CAAC,EACD;YACE,oBAAoB,EAAE,KAAK;YAC3B,OAAO,EAAE,CAAC,CAAC;YACX,UAAU,EAAE;cACV,aAAa,EAAE;gBACb,IAAI,EAAE;cACR,CAAC;cACD,GAAG,EAAE;gBACH,IAAI,EAAE;cACR,CAAC;cACD,GAAG,EAAE;gBACH,IAAI,EAAE;cACR,CAAC;cACD,MAAM,EAAE;gBACN,IAAI,EAAE;cACR;YACF,CAAC;YACD,IAAI,EAAE;UACR,CAAC;QAEL;MACF,CAAC;MACD,IAAI,EAAE;IACR,CAAC,CACF;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,13 +1,7 @@
1
- "use strict";
1
+ import iterateJsdoc from '../iterateJsdoc.js';
2
+ import { getDocumentNamepathDefiningTags, strictNativeTypes } from '../jsdocUtils.js';
3
+ import { traverse, tryParse as tryParseType } from '@es-joy/jsdoccomment';
2
4
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
8
- var _jsdocUtils = require("../jsdocUtils.cjs");
9
- var _jsdoccomment = require("@es-joy/jsdoccomment");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
5
  /**
12
6
  * @type {Partial<Record<import('../jsdocUtils.js').ParserMode, import('jsdoc-type-pratt-parser').ParseMode[]>>}
13
7
  */
@@ -59,7 +53,7 @@ const getParseMode = (context, mode) => {
59
53
  } = /** @type {{jsdoc?: {mode?: import('../jsdocUtils.js').ParserMode}}} */context.settings;
60
54
  return jsdoc?.mode ?? mode;
61
55
  };
62
- var _default = exports.default = (0, _iterateJsdoc.default)(({
56
+ export default iterateJsdoc(({
63
57
  context,
64
58
  node,
65
59
  report,
@@ -106,7 +100,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
106
100
  return;
107
101
  }
108
102
  const returnNever = type === 'never';
109
- const typedefs = (0, _jsdocUtils.getDocumentNamepathDefiningTags)(sourceCode);
103
+ const typedefs = getDocumentNamepathDefiningTags(sourceCode);
110
104
 
111
105
  /**
112
106
  * @param {import('comment-parser').Spec} returnTag
@@ -119,13 +113,13 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
119
113
  const returnType = returnTag.type.trim();
120
114
  let parsedType;
121
115
  try {
122
- parsedType = (0, _jsdoccomment.tryParse)(returnType, parseTypeModes[parseMode]);
116
+ parsedType = tryParseType(returnType, parseTypeModes[parseMode]);
123
117
  } catch {
124
118
  return false;
125
119
  }
126
120
  const returnTypeLevelNode = getReturnTypeLevelNode(parsedType);
127
121
  let returnIsUndefined = false;
128
- (0, _jsdoccomment.traverse)(returnTypeLevelNode, (nde, parentNode) => {
122
+ traverse(returnTypeLevelNode, (nde, parentNode) => {
129
123
  const isReturnLevelNode = !parentNode || returnTypeLevelNode.type === 'JsdocTypeUnion' && parentNode === returnTypeLevelNode;
130
124
  if (!isReturnLevelNode) {
131
125
  return;
@@ -160,7 +154,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
160
154
  report(`JSDoc @${tagName} declaration set with "never" but return expression is present in function.`);
161
155
  return;
162
156
  }
163
- if (noNativeTypes && isAsync && _jsdocUtils.strictNativeTypes.includes(type)) {
157
+ if (noNativeTypes && isAsync && strictNativeTypes.includes(type)) {
164
158
  report('Function is async or otherwise returns a Promise but the return type is a native type.');
165
159
  return;
166
160
  }
@@ -221,5 +215,4 @@ Unlike \`require-returns\`, with this option in the rule, one can
221
215
  type: 'suggestion'
222
216
  }
223
217
  });
224
- module.exports = exports.default;
225
218
  //# sourceMappingURL=requireReturnsCheck.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"requireReturnsCheck.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_jsdocUtils","_jsdoccomment","e","__esModule","default","parseTypeModes","closure","jsdoc","typescript","canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","getReturnTypeLevelNode","parsedType","type","element","getParseMode","context","_default","exports","iterateJsdoc","node","report","sourceCode","exemptAsync","exemptGenerators","noNativeTypes","reportMissingReturnForUndefinedTypes","options","parseMode","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","trim","test","returnNever","typedefs","getDocumentNamepathDefiningTags","mayReturnUndefined","returnTag","mayBeUndefinedTypeTag","returnType","tryParseType","returnTypeLevelNode","returnIsUndefined","traverse","nde","parentNode","isReturnLevelNode","nodeType","value","referencedTypedef","find","typedefTag","name","hasValueOrExecutorHasNonEmptyResolveValue","strictNativeTypes","includes","Boolean","generator","meta","docs","description","url","schema","additionalProperties","properties","module"],"sources":["../../src/rules/requireReturnsCheck.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n getDocumentNamepathDefiningTags,\n strictNativeTypes,\n} from '../jsdocUtils.js';\nimport {\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\n\n/**\n * @type {Partial<Record<import('../jsdocUtils.js').ParserMode, import('jsdoc-type-pratt-parser').ParseMode[]>>}\n */\nconst parseTypeModes = {\n closure: [\n 'closure',\n ],\n jsdoc: [\n 'jsdoc',\n ],\n typescript: [\n 'typescript',\n ],\n};\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Settings} settings\n * @returns {boolean}\n */\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a return is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing return.\n 'abstract',\n 'virtual',\n\n // A constructor function returns `this` by default, so may be `@returns`\n // tag indicating this but no explicit return\n 'class',\n 'constructor',\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\n/**\n * @param {import('jsdoc-type-pratt-parser').RootResult} parsedType\n * @returns {import('jsdoc-type-pratt-parser').RootResult}\n */\nconst getReturnTypeLevelNode = (parsedType) => {\n return parsedType.type === 'JsdocTypeParenthesis' ?\n parsedType.element :\n parsedType;\n};\n\n/**\n * @param {import('eslint').Rule.RuleContext} context\n * @param {import('../jsdocUtils.js').ParserMode} mode\n * @returns {import('../jsdocUtils.js').ParserMode}\n */\nconst getParseMode = (context, mode) => {\n const {\n jsdoc,\n } = /** @type {{jsdoc?: {mode?: import('../jsdocUtils.js').ParserMode}}} */ (context.settings);\n\n return jsdoc?.mode ?? mode;\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n noNativeTypes = true,\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n const {\n mode,\n } = settings;\n const parseMode = getParseMode(context, mode);\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n const isAsync = utils.isAsync();\n if (exemptAsync && isAsync) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length === 0) {\n return;\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n\n return;\n }\n\n const [\n tag,\n ] = tags;\n\n const type = tag.type.trim();\n\n // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions\n if (/asserts\\s/v.test(type)) {\n return;\n }\n\n const returnNever = type === 'never';\n const typedefs = getDocumentNamepathDefiningTags(sourceCode);\n\n /**\n * @param {import('comment-parser').Spec} returnTag\n * @returns {boolean}\n */\n const mayReturnUndefined = (returnTag) => {\n if (utils.mayBeUndefinedTypeTag(returnTag)) {\n return true;\n }\n\n const returnType = returnTag.type.trim();\n let parsedType;\n try {\n parsedType = tryParseType(returnType, parseTypeModes[parseMode]);\n } catch {\n return false;\n }\n\n const returnTypeLevelNode = getReturnTypeLevelNode(parsedType);\n let returnIsUndefined = false;\n traverse(returnTypeLevelNode, (nde, parentNode) => {\n const isReturnLevelNode = !parentNode ||\n returnTypeLevelNode.type === 'JsdocTypeUnion' && parentNode === returnTypeLevelNode;\n if (!isReturnLevelNode) {\n return;\n }\n\n const {\n type: nodeType,\n } = /** @type {import('jsdoc-type-pratt-parser').RootResult} */ (nde);\n\n if (nodeType === 'JsdocTypeUndefined') {\n returnIsUndefined = true;\n return;\n }\n\n if (nodeType !== 'JsdocTypeName') {\n return;\n }\n\n const {\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n\n if (value === 'void') {\n returnIsUndefined = true;\n return;\n }\n\n const referencedTypedef = typedefs.find((typedefTag) => {\n return typedefTag.name === value;\n });\n\n if (referencedTypedef && utils.mayBeUndefinedTypeTag(referencedTypedef)) {\n returnIsUndefined = true;\n }\n });\n\n return returnIsUndefined;\n };\n\n if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {\n report(`JSDoc @${tagName} declaration set with \"never\" but return expression is present in function.`);\n\n return;\n }\n\n if (noNativeTypes && isAsync && strictNativeTypes.includes(type)) {\n report('Function is async or otherwise returns a Promise but the return type is a native type.');\n return;\n }\n\n // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n !mayReturnUndefined(tag)\n ) &&\n (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n ) ||\n tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n true,\n )) &&\n Boolean(\n !exemptGenerators || !node ||\n !('generator' in /** @type {import('../iterateJsdoc.js').Node} */ (node)) ||\n !(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ (node)).generator,\n )\n ) {\n report(`JSDoc @${tagName} declaration present but return expression not available in function.`);\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a return statement in function body if a `@returns` tag is specified in JSDoc comment(and reports if multiple `@returns` tags are present).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptAsync: {\n default: true,\n description: `By default, functions which return a \\`Promise\\` that are not\ndetected as resolving with a non-\\`undefined\\` value and \\`async\\` functions\n(even ones that do not explicitly return a value, as these are returning a\n\\`Promise\\` implicitly) will be exempted from reporting by this rule.\nIf you wish to insist that only \\`Promise\\`'s which resolve to\nnon-\\`undefined\\` values or \\`async\\` functions with explicit \\`return\\`'s will\nbe exempted from reporting (i.e., that \\`async\\` functions can be reported\nif they lack an explicit (non-\\`undefined\\`) \\`return\\` when a \\`@returns\\` is\npresent), you can set \\`exemptAsync\\` to \\`false\\` on the options object.`,\n type: 'boolean',\n },\n exemptGenerators: {\n description: `Because a generator might be labeled as having a\n\\`IterableIterator\\` \\`@returns\\` value (along with an iterator type\ncorresponding to the type of any \\`yield\\` statements), projects might wish to\nleverage \\`@returns\\` in generators even without a \\`return\\` statement. This\noption is therefore \\`true\\` by default in \\`typescript\\` mode (in \"jsdoc\" mode,\none might be more likely to take advantage of \\`@yields\\`). Set it to \\`false\\`\nif you wish for a missing \\`return\\` to be flagged regardless.`,\n type: 'boolean',\n },\n noNativeTypes: {\n description: `Whether to check that async functions do not\nindicate they return non-native types. Defaults to \\`true\\`.`,\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n description: `If \\`true\\` and no return or\nresolve value is found, this setting will even insist that reporting occur\nwith \\`void\\` or \\`undefined\\` (including as an indicated \\`Promise\\` type).\nUnlike \\`require-returns\\`, with this option in the rule, one can\n*discourage* the labeling of \\`undefined\\` types. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAA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AO,EAAE,IAAI;UACboE,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,0EAA0E;UAC9DpD,IAAI,EAAE;QACR,CAAC;QACDW,gBAAgB,EAAE;UAChByC,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA,+DAA+D;UACnDpD,IAAI,EAAE;QACR,CAAC;QACDY,aAAa,EAAE;UACbwC,WAAW,EAAE;AACzB,6DAA6D;UACjDpD,IAAI,EAAE;QACR,CAAC;QACDa,oCAAoC,EAAE;UACpC7B,OAAO,EAAE,KAAK;UACdoE,WAAW,EAAE;AACzB;AACA;AACA;AACA,yEAAyE;UAC7DpD,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAyD,MAAA,CAAApD,OAAA,GAAAA,OAAA,CAAArB,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireReturnsCheck.cjs","names":[],"sources":["../../src/rules/requireReturnsCheck.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n getDocumentNamepathDefiningTags,\n strictNativeTypes,\n} from '../jsdocUtils.js';\nimport {\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\n\n/**\n * @type {Partial<Record<import('../jsdocUtils.js').ParserMode, import('jsdoc-type-pratt-parser').ParseMode[]>>}\n */\nconst parseTypeModes = {\n closure: [\n 'closure',\n ],\n jsdoc: [\n 'jsdoc',\n ],\n typescript: [\n 'typescript',\n ],\n};\n\n/**\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @param {import('../iterateJsdoc.js').Settings} settings\n * @returns {boolean}\n */\nconst canSkip = (utils, settings) => {\n const voidingTags = [\n // An abstract function is by definition incomplete\n // so it is perfectly fine if a return is documented but\n // not present within the function.\n // A subclass may inherit the doc and implement the\n // missing return.\n 'abstract',\n 'virtual',\n\n // A constructor function returns `this` by default, so may be `@returns`\n // tag indicating this but no explicit return\n 'class',\n 'constructor',\n 'interface',\n ];\n\n if (settings.mode === 'closure') {\n // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned\n voidingTags.push('record');\n }\n\n return utils.hasATag(voidingTags) ||\n utils.isConstructor() ||\n utils.classHasTag('interface') ||\n settings.mode === 'closure' && utils.classHasTag('record');\n};\n\n/**\n * @param {import('jsdoc-type-pratt-parser').RootResult} parsedType\n * @returns {import('jsdoc-type-pratt-parser').RootResult}\n */\nconst getReturnTypeLevelNode = (parsedType) => {\n return parsedType.type === 'JsdocTypeParenthesis' ?\n parsedType.element :\n parsedType;\n};\n\n/**\n * @param {import('eslint').Rule.RuleContext} context\n * @param {import('../jsdocUtils.js').ParserMode} mode\n * @returns {import('../jsdocUtils.js').ParserMode}\n */\nconst getParseMode = (context, mode) => {\n const {\n jsdoc,\n } = /** @type {{jsdoc?: {mode?: import('../jsdocUtils.js').ParserMode}}} */ (context.settings);\n\n return jsdoc?.mode ?? mode;\n};\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n sourceCode,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n noNativeTypes = true,\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n const {\n mode,\n } = settings;\n const parseMode = getParseMode(context, mode);\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n const isAsync = utils.isAsync();\n if (exemptAsync && isAsync) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'returns',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n\n if (tags.length === 0) {\n return;\n }\n\n if (tags.length > 1) {\n report(`Found more than one @${tagName} declaration.`);\n\n return;\n }\n\n const [\n tag,\n ] = tags;\n\n const type = tag.type.trim();\n\n // https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions\n if (/asserts\\s/v.test(type)) {\n return;\n }\n\n const returnNever = type === 'never';\n const typedefs = getDocumentNamepathDefiningTags(sourceCode);\n\n /**\n * @param {import('comment-parser').Spec} returnTag\n * @returns {boolean}\n */\n const mayReturnUndefined = (returnTag) => {\n if (utils.mayBeUndefinedTypeTag(returnTag)) {\n return true;\n }\n\n const returnType = returnTag.type.trim();\n let parsedType;\n try {\n parsedType = tryParseType(returnType, parseTypeModes[parseMode]);\n } catch {\n return false;\n }\n\n const returnTypeLevelNode = getReturnTypeLevelNode(parsedType);\n let returnIsUndefined = false;\n traverse(returnTypeLevelNode, (nde, parentNode) => {\n const isReturnLevelNode = !parentNode ||\n returnTypeLevelNode.type === 'JsdocTypeUnion' && parentNode === returnTypeLevelNode;\n if (!isReturnLevelNode) {\n return;\n }\n\n const {\n type: nodeType,\n } = /** @type {import('jsdoc-type-pratt-parser').RootResult} */ (nde);\n\n if (nodeType === 'JsdocTypeUndefined') {\n returnIsUndefined = true;\n return;\n }\n\n if (nodeType !== 'JsdocTypeName') {\n return;\n }\n\n const {\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n\n if (value === 'void') {\n returnIsUndefined = true;\n return;\n }\n\n const referencedTypedef = typedefs.find((typedefTag) => {\n return typedefTag.name === value;\n });\n\n if (referencedTypedef && utils.mayBeUndefinedTypeTag(referencedTypedef)) {\n returnIsUndefined = true;\n }\n });\n\n return returnIsUndefined;\n };\n\n if (returnNever && utils.hasValueOrExecutorHasNonEmptyResolveValue(false)) {\n report(`JSDoc @${tagName} declaration set with \"never\" but return expression is present in function.`);\n\n return;\n }\n\n if (noNativeTypes && isAsync && strictNativeTypes.includes(type)) {\n report('Function is async or otherwise returns a Promise but the return type is a native type.');\n return;\n }\n\n // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n !mayReturnUndefined(tag)\n ) &&\n (tag.type === '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n ) ||\n tag.type !== '' && !utils.hasValueOrExecutorHasNonEmptyResolveValue(\n exemptAsync,\n true,\n )) &&\n Boolean(\n !exemptGenerators || !node ||\n !('generator' in /** @type {import('../iterateJsdoc.js').Node} */ (node)) ||\n !(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */ (node)).generator,\n )\n ) {\n report(`JSDoc @${tagName} declaration present but return expression not available in function.`);\n }\n}, {\n meta: {\n docs: {\n description: 'Requires a return statement in function body if a `@returns` tag is specified in JSDoc comment(and reports if multiple `@returns` tags are present).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptAsync: {\n default: true,\n description: `By default, functions which return a \\`Promise\\` that are not\ndetected as resolving with a non-\\`undefined\\` value and \\`async\\` functions\n(even ones that do not explicitly return a value, as these are returning a\n\\`Promise\\` implicitly) will be exempted from reporting by this rule.\nIf you wish to insist that only \\`Promise\\`'s which resolve to\nnon-\\`undefined\\` values or \\`async\\` functions with explicit \\`return\\`'s will\nbe exempted from reporting (i.e., that \\`async\\` functions can be reported\nif they lack an explicit (non-\\`undefined\\`) \\`return\\` when a \\`@returns\\` is\npresent), you can set \\`exemptAsync\\` to \\`false\\` on the options object.`,\n type: 'boolean',\n },\n exemptGenerators: {\n description: `Because a generator might be labeled as having a\n\\`IterableIterator\\` \\`@returns\\` value (along with an iterator type\ncorresponding to the type of any \\`yield\\` statements), projects might wish to\nleverage \\`@returns\\` in generators even without a \\`return\\` statement. This\noption is therefore \\`true\\` by default in \\`typescript\\` mode (in \"jsdoc\" mode,\none might be more likely to take advantage of \\`@yields\\`). Set it to \\`false\\`\nif you wish for a missing \\`return\\` to be flagged regardless.`,\n type: 'boolean',\n },\n noNativeTypes: {\n description: `Whether to check that async functions do not\nindicate they return non-native types. Defaults to \\`true\\`.`,\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: false,\n description: `If \\`true\\` and no return or\nresolve value is found, this setting will even insist that reporting occur\nwith \\`void\\` or \\`undefined\\` (including as an indicated \\`Promise\\` type).\nUnlike \\`require-returns\\`, with this option in the rule, one can\n*discourage* the labeling of \\`undefined\\` types. Defaults to \\`false\\`.`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;AAC7C,SACE,+BAA+B,EAC/B,iBAAiB,QACZ,kBAAkB;AACzB,SACE,QAAQ,EACR,QAAQ,IAAI,YAAY,QACnB,sBAAsB;;AAE7B;AACA;AACA;AACA,MAAM,cAAc,GAAG;EACrB,OAAO,EAAE,CACP,SAAS,CACV;EACD,KAAK,EAAE,CACL,OAAO,CACR;EACD,UAAU,EAAE,CACV,YAAY;AAEhB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK;EACnC,MAAM,WAAW,GAAG;EAClB;EACA;EACA;EACA;EACA;EACA,UAAU,EACV,SAAS;EAET;EACA;EACA,OAAO,EACP,aAAa,EACb,WAAW,CACZ;EAED,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE;IAC/B;IACA,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;EAC5B;EAEA,OAAO,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,IAC/B,KAAK,CAAC,aAAa,CAAC,CAAC,IACrB,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,IAC9B,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC;AAC9D,CAAC;;AAED;AACA;AACA;AACA;AACA,MAAM,sBAAsB,GAAI,UAAU,IAAK;EAC7C,OAAO,UAAU,CAAC,IAAI,KAAK,sBAAsB,GAC/C,UAAU,CAAC,OAAO,GAClB,UAAU;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,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;AACA,+DAA+D;UACnD,IAAI,EAAE;QACR,CAAC;QACD,aAAa,EAAE;UACb,WAAW,EAAE;AACzB,6DAA6D;UACjD,IAAI,EAAE;QACR,CAAC;QACD,oCAAoC,EAAE;UACpC,OAAO,EAAE,KAAK;UACd,WAAW,EAAE;AACzB;AACA;AACA;AACA,yEAAyE;UAC7D,IAAI,EAAE;QACR;MACF,CAAC;MACD,IAAI,EAAE;IACR,CAAC,CACF;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,12 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- var _default = exports.default = (0, _iterateJsdoc.default)(({
1
+ import iterateJsdoc from '../iterateJsdoc.js';
2
+ export default iterateJsdoc(({
10
3
  report,
11
4
  utils
12
5
  }) => {
@@ -68,5 +61,4 @@ section of our Advanced docs for more on the expected format.`,
68
61
  type: 'suggestion'
69
62
  }
70
63
  });
71
- module.exports = exports.default;
72
64
  //# sourceMappingURL=requireReturnsDescription.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"requireReturnsDescription.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdocTag","targetTagName","type","trim","includes","description","contextDefaults","meta","docs","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"sources":["../../src/rules/requireReturnsDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => {\n const type = jsdocTag.type && jsdocTag.type.trim();\n\n if ([\n 'Promise<undefined>', 'Promise<void>', 'undefined', 'void',\n ].includes(type)) {\n return;\n }\n\n if (!jsdocTag.description.trim()) {\n report(`Missing JSDoc @${targetTagName} description.`, null, jsdocTag);\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that the `@returns` tag has a `description` value (not including `void`/`undefined` type returns).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`).\n\nSee the [\"AST and Selectors\"](../advanced.md#ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/B,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,MAAM;EACNC;AACF,CAAC,KAAK;EACJA,KAAK,CAACC,mBAAmB,CAAC,SAAS,EAAE,CAACC,QAAQ,EAAEC,aAAa,KAAK;IAChE,MAAMC,IAAI,GAAGF,QAAQ,CAACE,IAAI,IAAIF,QAAQ,CAACE,IAAI,CAACC,IAAI,CAAC,CAAC;IAElD,IAAI,CACF,oBAAoB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,CAC3D,CAACC,QAAQ,CAACF,IAAI,CAAC,EAAE;MAChB;IACF;IAEA,IAAI,CAACF,QAAQ,CAACK,WAAW,CAACF,IAAI,CAAC,CAAC,EAAE;MAChCN,MAAM,CAAC,kBAAkBI,aAAa,eAAe,EAAE,IAAI,EAAED,QAAQ,CAAC;IACxE;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDM,eAAe,EAAE,IAAI;EACrBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJH,WAAW,EAAE,6GAA6G;MAC1HI,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRR,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D;UAClDS,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEb,IAAI,EAAE;YACR,CAAC,EACD;cACES,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVI,OAAO,EAAE;kBACPd,IAAI,EAAE;gBACR,CAAC;gBACDe,OAAO,EAAE;kBACPf,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAgB,MAAA,CAAAvB,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireReturnsDescription.cjs","names":[],"sources":["../../src/rules/requireReturnsDescription.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => {\n const type = jsdocTag.type && jsdocTag.type.trim();\n\n if ([\n 'Promise<undefined>', 'Promise<void>', 'undefined', 'void',\n ].includes(type)) {\n return;\n }\n\n if (!jsdocTag.description.trim()) {\n report(`Missing JSDoc @${targetTagName} description.`, null, jsdocTag);\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that the `@returns` tag has a `description` value (not including `void`/`undefined` type returns).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`).\n\nSee the [\"AST and Selectors\"](../advanced.md#ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;AAE7C,eAAe,YAAY,CAAC,CAAC;EAC3B,MAAM;EACN;AACF,CAAC,KAAK;EACJ,KAAK,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK;IAChE,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAElD,IAAI,CACF,oBAAoB,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,CAC3D,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;MAChB;IACF;IAEA,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE;MAChC,MAAM,CAAC,kBAAkB,aAAa,eAAe,EAAE,IAAI,EAAE,QAAQ,CAAC;IACxE;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACD,eAAe,EAAE,IAAI;EACrB,IAAI,EAAE;IACJ,IAAI,EAAE;MACJ,WAAW,EAAE,6GAA6G;MAC1H,GAAG,EAAE;IACP,CAAC;IACD,MAAM,EAAE,CACN;MACE,oBAAoB,EAAE,KAAK;MAC3B,UAAU,EAAE;QACV,QAAQ,EAAE;UACR,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D;UAClD,KAAK,EAAE;YACL,KAAK,EAAE,CACL;cACE,IAAI,EAAE;YACR,CAAC,EACD;cACE,oBAAoB,EAAE,KAAK;cAC3B,UAAU,EAAE;gBACV,OAAO,EAAE;kBACP,IAAI,EAAE;gBACR,CAAC;gBACD,OAAO,EAAE;kBACP,IAAI,EAAE;gBACR;cACF,CAAC;cACD,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACD,IAAI,EAAE;QACR;MACF,CAAC;MACD,IAAI,EAAE;IACR,CAAC,CACF;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,12 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- var _default = exports.default = (0, _iterateJsdoc.default)(({
1
+ import iterateJsdoc from '../iterateJsdoc.js';
2
+ export default iterateJsdoc(({
10
3
  report,
11
4
  utils
12
5
  }) => {
@@ -64,5 +57,4 @@ section of our Advanced docs for more on the expected format.`,
64
57
  type: 'suggestion'
65
58
  }
66
59
  });
67
- module.exports = exports.default;
68
60
  //# sourceMappingURL=requireReturnsType.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"requireReturnsType.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdocTag","targetTagName","type","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","module"],"sources":["../../src/rules/requireReturnsType.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => {\n if (!jsdocTag.type) {\n report(`Missing JSDoc @${targetTagName} type.`, null, jsdocTag);\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that `@returns` tag has type value (in curly brackets).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`).\n\nSee the [\"AST and Selectors\"](../advanced.md#ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE/B,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,MAAM;EACNC;AACF,CAAC,KAAK;EACJA,KAAK,CAACC,mBAAmB,CAAC,SAAS,EAAE,CAACC,QAAQ,EAAEC,aAAa,KAAK;IAChE,IAAI,CAACD,QAAQ,CAACE,IAAI,EAAE;MAClBL,MAAM,CAAC,kBAAkBI,aAAa,QAAQ,EAAE,IAAI,EAAED,QAAQ,CAAC;IACjE;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDG,eAAe,EAAE,IAAI;EACrBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,kEAAkE;MAC/EC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRL,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D;UAClDM,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEX,IAAI,EAAE;YACR,CAAC,EACD;cACEO,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVI,OAAO,EAAE;kBACPZ,IAAI,EAAE;gBACR,CAAC;gBACDa,OAAO,EAAE;kBACPb,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAc,MAAA,CAAArB,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireReturnsType.cjs","names":[],"sources":["../../src/rules/requireReturnsType.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('returns', (jsdocTag, targetTagName) => {\n if (!jsdocTag.type) {\n report(`Missing JSDoc @${targetTagName} type.`, null, jsdocTag);\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that `@returns` tag has type value (in curly brackets).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`).\n\nSee the [\"AST and Selectors\"](../advanced.md#ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;AAE7C,eAAe,YAAY,CAAC,CAAC;EAC3B,MAAM;EACN;AACF,CAAC,KAAK;EACJ,KAAK,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK;IAChE,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;MAClB,MAAM,CAAC,kBAAkB,aAAa,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC;IACjE;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACD,eAAe,EAAE,IAAI;EACrB,IAAI,EAAE;IACJ,IAAI,EAAE;MACJ,WAAW,EAAE,kEAAkE;MAC/E,GAAG,EAAE;IACP,CAAC;IACD,MAAM,EAAE,CACN;MACE,oBAAoB,EAAE,KAAK;MAC3B,UAAU,EAAE;QACV,QAAQ,EAAE;UACR,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,8DAA8D;UAClD,KAAK,EAAE;YACL,KAAK,EAAE,CACL;cACE,IAAI,EAAE;YACR,CAAC,EACD;cACE,oBAAoB,EAAE,KAAK;cAC3B,UAAU,EAAE;gBACV,OAAO,EAAE;kBACP,IAAI,EAAE;gBACR,CAAC;gBACD,OAAO,EAAE;kBACP,IAAI,EAAE;gBACR;cACF,CAAC;cACD,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACD,IAAI,EAAE;QACR;MACF,CAAC;MACD,IAAI,EAAE;IACR,CAAC,CACF;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,11 +1,5 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _buildForbidRuleDefinition = require("../buildForbidRuleDefinition.cjs");
8
- var _default = exports.default = (0, _buildForbidRuleDefinition.buildForbidRuleDefinition)({
1
+ import { buildForbidRuleDefinition } from '../buildForbidRuleDefinition.js';
2
+ export default buildForbidRuleDefinition({
9
3
  description: 'Requires tags be present, optionally for specific contexts',
10
4
  getContexts(context, report) {
11
5
  // Transformed options to this option in `modifyContext`:
@@ -70,5 +64,4 @@ a string \`tag\` property and \`context\` string property.`,
70
64
  }],
71
65
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-tags.md#repos-sticky-header'
72
66
  });
73
- module.exports = exports.default;
74
67
  //# sourceMappingURL=requireTags.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"requireTags.cjs","names":["_buildForbidRuleDefinition","require","_default","exports","default","buildForbidRuleDefinition","description","getContexts","context","report","options","contexts","modifyContext","tags","cntxts","map","tag","tagName","comment","message","propertyDescriptors","Object","getOwnPropertyDescriptors","create","getPrototypeOf","value","schema","additionalProperties","properties","items","anyOf","type","url","module"],"sources":["../../src/rules/requireTags.js"],"sourcesContent":["import {\n buildForbidRuleDefinition,\n} from '../buildForbidRuleDefinition.js';\n\nexport default buildForbidRuleDefinition({\n description: 'Requires tags be present, optionally for specific contexts',\n getContexts (context, report) {\n // Transformed options to this option in `modifyContext`:\n if (!context.options[0].contexts) {\n report('Rule `require-tags` is missing a `tags` option.');\n return false;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n return contexts;\n },\n modifyContext (context) {\n const tags = /** @type {(string|{tag: string, context: string})[]} */ (\n context.options?.[0]?.tags\n );\n\n const cntxts = tags?.map((tag) => {\n const tagName = typeof tag === 'string' ? tag : tag.tag;\n return {\n comment: `JsdocBlock:not(*:has(JsdocTag[tag=${\n tagName\n }]))`,\n context: typeof tag === 'string' ? 'any' : tag.context,\n message: `Missing required tag \"${tagName}\"`,\n };\n });\n\n // Reproduce context object with our own `contexts`\n const propertyDescriptors = Object.getOwnPropertyDescriptors(context);\n return Object.create(\n Object.getPrototypeOf(context),\n {\n ...propertyDescriptors,\n options: {\n ...propertyDescriptors.options,\n value: [\n {\n contexts: cntxts,\n },\n ],\n },\n },\n );\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n tags: {\n description: `May be an array of either strings or objects with\na string \\`tag\\` property and \\`context\\` string property.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n properties: {\n context: {\n type: 'string',\n },\n tag: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-tags.md#repos-sticky-header',\n});\n"],"mappings":";;;;;;AAAA,IAAAA,0BAAA,GAAAC,OAAA;AAEyC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE1B,IAAAC,oDAAyB,EAAC;EACvCC,WAAW,EAAE,4DAA4D;EACzEC,WAAWA,CAAEC,OAAO,EAAEC,MAAM,EAAE;IAC5B;IACA,IAAI,CAACD,OAAO,CAACE,OAAO,CAAC,CAAC,CAAC,CAACC,QAAQ,EAAE;MAChCF,MAAM,CAAC,iDAAiD,CAAC;MACzD,OAAO,KAAK;IACd;IAEA,MAAM;MACJE;IACF,CAAC,GAAGH,OAAO,CAACE,OAAO,CAAC,CAAC,CAAC;IAEtB,OAAOC,QAAQ;EACjB,CAAC;EACDC,aAAaA,CAAEJ,OAAO,EAAE;IACtB,MAAMK,IAAI,GAAG;IACXL,OAAO,CAACE,OAAO,GAAG,CAAC,CAAC,EAAEG,IACvB;IAED,MAAMC,MAAM,GAAGD,IAAI,EAAEE,GAAG,CAAEC,GAAG,IAAK;MAChC,MAAMC,OAAO,GAAG,OAAOD,GAAG,KAAK,QAAQ,GAAGA,GAAG,GAAGA,GAAG,CAACA,GAAG;MACvD,OAAO;QACLE,OAAO,EAAE,qCACPD,OAAO,KACJ;QACLT,OAAO,EAAE,OAAOQ,GAAG,KAAK,QAAQ,GAAG,KAAK,GAAGA,GAAG,CAACR,OAAO;QACtDW,OAAO,EAAE,yBAAyBF,OAAO;MAC3C,CAAC;IACH,CAAC,CAAC;;IAEF;IACA,MAAMG,mBAAmB,GAAGC,MAAM,CAACC,yBAAyB,CAACd,OAAO,CAAC;IACrE,OAAOa,MAAM,CAACE,MAAM,CAClBF,MAAM,CAACG,cAAc,CAAChB,OAAO,CAAC,EAC9B;MACE,GAAGY,mBAAmB;MACtBV,OAAO,EAAE;QACP,GAAGU,mBAAmB,CAACV,OAAO;QAC9Be,KAAK,EAAE,CACL;UACEd,QAAQ,EAAEG;QACZ,CAAC;MAEL;IACF,CACF,CAAC;EACH,CAAC;EACDY,MAAM,EAAE,CACN;IACEC,oBAAoB,EAAE,KAAK;IAC3BC,UAAU,EAAE;MACVf,IAAI,EAAE;QACJP,WAAW,EAAE;AACvB,2DAA2D;QACjDuB,KAAK,EAAE;UACLC,KAAK,EAAE,CACL;YACEC,IAAI,EAAE;UACR,CAAC,EACD;YACEH,UAAU,EAAE;cACVpB,OAAO,EAAE;gBACPuB,IAAI,EAAE;cACR,CAAC;cACDf,GAAG,EAAE;gBACHe,IAAI,EAAE;cACR;YACF,CAAC;YACDA,IAAI,EAAE;UACR,CAAC;QAEL,CAAC;QACDA,IAAI,EAAE;MACR;IACF,CAAC;IACDA,IAAI,EAAE;EACR,CAAC,CACF;EACDC,GAAG,EAAE;AACP,CAAC,CAAC;AAAAC,MAAA,CAAA9B,OAAA,GAAAA,OAAA,CAAAC,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireTags.cjs","names":[],"sources":["../../src/rules/requireTags.js"],"sourcesContent":["import {\n buildForbidRuleDefinition,\n} from '../buildForbidRuleDefinition.js';\n\nexport default buildForbidRuleDefinition({\n description: 'Requires tags be present, optionally for specific contexts',\n getContexts (context, report) {\n // Transformed options to this option in `modifyContext`:\n if (!context.options[0].contexts) {\n report('Rule `require-tags` is missing a `tags` option.');\n return false;\n }\n\n const {\n contexts,\n } = context.options[0];\n\n return contexts;\n },\n modifyContext (context) {\n const tags = /** @type {(string|{tag: string, context: string})[]} */ (\n context.options?.[0]?.tags\n );\n\n const cntxts = tags?.map((tag) => {\n const tagName = typeof tag === 'string' ? tag : tag.tag;\n return {\n comment: `JsdocBlock:not(*:has(JsdocTag[tag=${\n tagName\n }]))`,\n context: typeof tag === 'string' ? 'any' : tag.context,\n message: `Missing required tag \"${tagName}\"`,\n };\n });\n\n // Reproduce context object with our own `contexts`\n const propertyDescriptors = Object.getOwnPropertyDescriptors(context);\n return Object.create(\n Object.getPrototypeOf(context),\n {\n ...propertyDescriptors,\n options: {\n ...propertyDescriptors.options,\n value: [\n {\n contexts: cntxts,\n },\n ],\n },\n },\n );\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n tags: {\n description: `May be an array of either strings or objects with\na string \\`tag\\` property and \\`context\\` string property.`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n properties: {\n context: {\n type: 'string',\n },\n tag: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-tags.md#repos-sticky-header',\n});\n"],"mappings":"AAAA,SACE,yBAAyB,QACpB,iCAAiC;AAExC,eAAe,yBAAyB,CAAC;EACvC,WAAW,EAAE,4DAA4D;EACzE,WAAW,CAAE,OAAO,EAAE,MAAM,EAAE;IAC5B;IACA,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;MAChC,MAAM,CAAC,iDAAiD,CAAC;MACzD,OAAO,KAAK;IACd;IAEA,MAAM;MACJ;IACF,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAEtB,OAAO,QAAQ;EACjB,CAAC;EACD,aAAa,CAAE,OAAO,EAAE;IACtB,MAAM,IAAI,GAAG;IACX,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,IACvB;IAED,MAAM,MAAM,GAAG,IAAI,EAAE,GAAG,CAAE,GAAG,IAAK;MAChC,MAAM,OAAO,GAAG,OAAO,GAAG,KAAK,QAAQ,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG;MACvD,OAAO;QACL,OAAO,EAAE,qCACP,OAAO,KACJ;QACL,OAAO,EAAE,OAAO,GAAG,KAAK,QAAQ,GAAG,KAAK,GAAG,GAAG,CAAC,OAAO;QACtD,OAAO,EAAE,yBAAyB,OAAO;MAC3C,CAAC;IACH,CAAC,CAAC;;IAEF;IACA,MAAM,mBAAmB,GAAG,MAAM,CAAC,yBAAyB,CAAC,OAAO,CAAC;IACrE,OAAO,MAAM,CAAC,MAAM,CAClB,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,EAC9B;MACE,GAAG,mBAAmB;MACtB,OAAO,EAAE;QACP,GAAG,mBAAmB,CAAC,OAAO;QAC9B,KAAK,EAAE,CACL;UACE,QAAQ,EAAE;QACZ,CAAC;MAEL;IACF,CACF,CAAC;EACH,CAAC;EACD,MAAM,EAAE,CACN;IACE,oBAAoB,EAAE,KAAK;IAC3B,UAAU,EAAE;MACV,IAAI,EAAE;QACJ,WAAW,EAAE;AACvB,2DAA2D;QACjD,KAAK,EAAE;UACL,KAAK,EAAE,CACL;YACE,IAAI,EAAE;UACR,CAAC,EACD;YACE,UAAU,EAAE;cACV,OAAO,EAAE;gBACP,IAAI,EAAE;cACR,CAAC;cACD,GAAG,EAAE;gBACH,IAAI,EAAE;cACR;YACF,CAAC;YACD,IAAI,EAAE;UACR,CAAC;QAEL,CAAC;QACD,IAAI,EAAE;MACR;IACF,CAAC;IACD,IAAI,EAAE;EACR,CAAC,CACF;EACD,GAAG,EAAE;AACP,CAAC,CAAC","ignoreList":[]}
@@ -1,13 +1,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
8
- var _jsdoccomment = require("@es-joy/jsdoccomment");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- var _default = exports.default = (0, _iterateJsdoc.default)(({
1
+ import iterateJsdoc from '../iterateJsdoc.js';
2
+ import { parse as parseType, traverse, tryParse as tryParseType } from '@es-joy/jsdoccomment';
3
+ export default iterateJsdoc(({
11
4
  context,
12
5
  node,
13
6
  report,
@@ -115,11 +108,11 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
115
108
  const checkForUsedTypes = potentialTag => {
116
109
  let parsedType;
117
110
  try {
118
- parsedType = mode === 'permissive' ? (0, _jsdoccomment.tryParse)(/** @type {string} */potentialTag.type) : (0, _jsdoccomment.parse)(/** @type {string} */potentialTag.type, mode);
111
+ parsedType = mode === 'permissive' ? tryParseType(/** @type {string} */potentialTag.type) : parseType(/** @type {string} */potentialTag.type, mode);
119
112
  } catch {
120
113
  return;
121
114
  }
122
- (0, _jsdoccomment.traverse)(parsedType, nde => {
115
+ traverse(parsedType, nde => {
123
116
  if (nde.type === 'JsdocTypeTypeParameter') {
124
117
  templateNames.push(nde.name.value);
125
118
  return;
@@ -216,5 +209,4 @@ Defaults to \`false\`.`,
216
209
  type: 'suggestion'
217
210
  }
218
211
  });
219
- module.exports = exports.default;
220
212
  //# sourceMappingURL=requireTemplate.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"requireTemplate.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","_jsdoccomment","e","__esModule","default","_default","exports","iterateJsdoc","context","node","report","settings","utils","avoidDocs","requireSeparateTemplates","options","mode","usedNames","Set","tgName","getPreferredTagName","tagName","templateTags","getTags","templateNames","flatMap","tag","parseClosureTemplateTag","names","length","checkTypeParams","aliasDeclaration","params","typeParameters","name","add","usedName","includes","handleTypes","nde","type","declaration","usedNameToTag","Map","checkForUsedTypes","potentialTag","parsedType","tryParseType","parseType","traverse","push","value","element","test","has","set","checkTagsAndTemplates","tagNames","preferredTagName","matchingTags","matchingTag","get","callbackTags","functionTags","typedefTags","potentialTypedef","iterateAllJsdocs","meta","docs","description","url","schema","additionalProperties","properties","exemptedBy","items","module"],"sources":["../../src/rules/requireTemplate.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n if (utils.avoidDocs()) {\n return;\n }\n\n const {\n requireSeparateTemplates = false,\n } = context.options[0] || {};\n\n const {\n mode,\n } = settings;\n\n const usedNames = new Set();\n\n const tgName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'template',\n }));\n if (!tgName) {\n return;\n }\n\n const templateTags = utils.getTags(tgName);\n\n const templateNames = templateTags.flatMap((tag) => {\n return utils.parseClosureTemplateTag(tag);\n });\n\n if (requireSeparateTemplates) {\n for (const tag of templateTags) {\n const names = utils.parseClosureTemplateTag(tag);\n if (names.length > 1) {\n report(`Missing separate @${tgName} for ${names[1]}`, null, tag);\n }\n }\n }\n\n /**\n * @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|\n * import('@typescript-eslint/types').TSESTree.ClassDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSDeclareFunction|\n * import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkTypeParams = (aliasDeclaration) => {\n const {\n params,\n /* c8 ignore next -- Guard */\n } = aliasDeclaration.typeParameters ?? {\n /* c8 ignore next -- Guard */\n params: [],\n };\n for (const {\n name: {\n name,\n },\n } of params) {\n usedNames.add(name);\n }\n\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @${tgName} ${usedName}`);\n }\n }\n };\n\n const handleTypes = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n\n switch (nde.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSDeclareFunction':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkTypeParams(nde);\n break;\n case 'ExportDefaultDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSInterfaceDeclaration':\n checkTypeParams(nde.declaration);\n break;\n }\n\n break;\n case 'ExportNamedDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSDeclareFunction':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkTypeParams(nde.declaration);\n break;\n }\n\n break;\n }\n };\n\n const usedNameToTag = new Map();\n\n /**\n * @param {import('comment-parser').Spec} potentialTag\n */\n const checkForUsedTypes = (potentialTag) => {\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialTag.type)) :\n parseType(/** @type {string} */ (potentialTag.type), mode);\n } catch {\n return;\n }\n\n traverse(parsedType, (nde) => {\n if (nde.type === 'JsdocTypeTypeParameter') {\n templateNames.push(nde.name.value);\n return;\n }\n\n if (nde.type === 'JsdocTypeInfer') {\n templateNames.push(nde.element.value);\n return;\n }\n\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n\n if (type === 'JsdocTypeName' && (/^[A-Z]$/v).test(value)) {\n usedNames.add(value);\n if (!usedNameToTag.has(value)) {\n usedNameToTag.set(value, potentialTag);\n }\n }\n });\n };\n\n /**\n * @param {string[]} tagNames\n */\n const checkTagsAndTemplates = (tagNames) => {\n for (const tagName of tagNames) {\n const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName,\n }));\n const matchingTags = utils.getTags(preferredTagName);\n for (const matchingTag of matchingTags) {\n checkForUsedTypes(matchingTag);\n }\n }\n\n // Could check against whitelist/blacklist\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @${tgName} ${usedName}`, null, usedNameToTag.get(usedName));\n }\n }\n };\n\n const callbackTags = utils.getTags('callback');\n const functionTags = utils.getTags('function');\n if (callbackTags.length || functionTags.length) {\n checkTagsAndTemplates([\n 'param', 'returns',\n ]);\n return;\n }\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypes();\n return;\n }\n\n const potentialTypedef = typedefTags[0];\n checkForUsedTypes(potentialTypedef);\n\n checkTagsAndTemplates([\n 'property',\n ]);\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires `@template` tags be present when type parameters are used.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptedBy: {\n description: `Array of tags (e.g., \\`['type']\\`) whose presence on the document\nblock avoids the need for a \\`@template\\`. Defaults to an array with\n\\`inheritdoc\\`. If you set this array, it will overwrite the default,\nso be sure to add back \\`inheritdoc\\` if you wish its presence to cause\nexemption of the rule.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n requireSeparateTemplates: {\n description: `Requires that each template have its own separate line, i.e., preventing\ntemplates of this format:\n\n\\`\\`\\`js\n/**\n * @template T, U, V\n */\n\\`\\`\\`\n\nDefaults to \\`false\\`.`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAI8B,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEf,IAAAG,qBAAY,EAAC,CAAC;EAC3BC,OAAO;EACPC,IAAI;EACJC,MAAM;EACNC,QAAQ;EACRC;AACF,CAAC,KAAK;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,CAAAtE,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireTemplate.cjs","names":[],"sources":["../../src/rules/requireTemplate.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n parse as parseType,\n traverse,\n tryParse as tryParseType,\n} from '@es-joy/jsdoccomment';\n\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n if (utils.avoidDocs()) {\n return;\n }\n\n const {\n requireSeparateTemplates = false,\n } = context.options[0] || {};\n\n const {\n mode,\n } = settings;\n\n const usedNames = new Set();\n\n const tgName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'template',\n }));\n if (!tgName) {\n return;\n }\n\n const templateTags = utils.getTags(tgName);\n\n const templateNames = templateTags.flatMap((tag) => {\n return utils.parseClosureTemplateTag(tag);\n });\n\n if (requireSeparateTemplates) {\n for (const tag of templateTags) {\n const names = utils.parseClosureTemplateTag(tag);\n if (names.length > 1) {\n report(`Missing separate @${tgName} for ${names[1]}`, null, tag);\n }\n }\n }\n\n /**\n * @param {import('@typescript-eslint/types').TSESTree.FunctionDeclaration|\n * import('@typescript-eslint/types').TSESTree.ClassDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSDeclareFunction|\n * import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration|\n * import('@typescript-eslint/types').TSESTree.TSTypeAliasDeclaration} aliasDeclaration\n */\n const checkTypeParams = (aliasDeclaration) => {\n const {\n params,\n /* c8 ignore next -- Guard */\n } = aliasDeclaration.typeParameters ?? {\n /* c8 ignore next -- Guard */\n params: [],\n };\n for (const {\n name: {\n name,\n },\n } of params) {\n usedNames.add(name);\n }\n\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @${tgName} ${usedName}`);\n }\n }\n };\n\n const handleTypes = () => {\n const nde = /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node\n );\n if (!nde) {\n return;\n }\n\n switch (nde.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSDeclareFunction':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkTypeParams(nde);\n break;\n case 'ExportDefaultDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSInterfaceDeclaration':\n checkTypeParams(nde.declaration);\n break;\n }\n\n break;\n case 'ExportNamedDeclaration':\n switch (nde.declaration?.type) {\n case 'ClassDeclaration':\n case 'FunctionDeclaration':\n case 'TSDeclareFunction':\n case 'TSInterfaceDeclaration':\n case 'TSTypeAliasDeclaration':\n checkTypeParams(nde.declaration);\n break;\n }\n\n break;\n }\n };\n\n const usedNameToTag = new Map();\n\n /**\n * @param {import('comment-parser').Spec} potentialTag\n */\n const checkForUsedTypes = (potentialTag) => {\n let parsedType;\n try {\n parsedType = mode === 'permissive' ?\n tryParseType(/** @type {string} */ (potentialTag.type)) :\n parseType(/** @type {string} */ (potentialTag.type), mode);\n } catch {\n return;\n }\n\n traverse(parsedType, (nde) => {\n if (nde.type === 'JsdocTypeTypeParameter') {\n templateNames.push(nde.name.value);\n return;\n }\n\n if (nde.type === 'JsdocTypeInfer') {\n templateNames.push(nde.element.value);\n return;\n }\n\n const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\n\n if (type === 'JsdocTypeName' && (/^[A-Z]$/v).test(value)) {\n usedNames.add(value);\n if (!usedNameToTag.has(value)) {\n usedNameToTag.set(value, potentialTag);\n }\n }\n });\n };\n\n /**\n * @param {string[]} tagNames\n */\n const checkTagsAndTemplates = (tagNames) => {\n for (const tagName of tagNames) {\n const preferredTagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName,\n }));\n const matchingTags = utils.getTags(preferredTagName);\n for (const matchingTag of matchingTags) {\n checkForUsedTypes(matchingTag);\n }\n }\n\n // Could check against whitelist/blacklist\n for (const usedName of usedNames) {\n if (!templateNames.includes(usedName)) {\n report(`Missing @${tgName} ${usedName}`, null, usedNameToTag.get(usedName));\n }\n }\n };\n\n const callbackTags = utils.getTags('callback');\n const functionTags = utils.getTags('function');\n if (callbackTags.length || functionTags.length) {\n checkTagsAndTemplates([\n 'param', 'returns',\n ]);\n return;\n }\n\n const typedefTags = utils.getTags('typedef');\n if (!typedefTags.length || typedefTags.length >= 2) {\n handleTypes();\n return;\n }\n\n const potentialTypedef = typedefTags[0];\n checkForUsedTypes(potentialTypedef);\n\n checkTagsAndTemplates([\n 'property',\n ]);\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires `@template` tags be present when type parameters are used.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n exemptedBy: {\n description: `Array of tags (e.g., \\`['type']\\`) whose presence on the document\nblock avoids the need for a \\`@template\\`. Defaults to an array with\n\\`inheritdoc\\`. If you set this array, it will overwrite the default,\nso be sure to add back \\`inheritdoc\\` if you wish its presence to cause\nexemption of the rule.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n requireSeparateTemplates: {\n description: `Requires that each template have its own separate line, i.e., preventing\ntemplates of this format:\n\n\\`\\`\\`js\n/**\n * @template T, U, V\n */\n\\`\\`\\`\n\nDefaults to \\`false\\`.`,\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;AAC7C,SACE,KAAK,IAAI,SAAS,EAClB,QAAQ,EACR,QAAQ,IAAI,YAAY,QACnB,sBAAsB;AAE7B,eAAe,YAAY,CAAC,CAAC;EAC3B,OAAO;EACP,IAAI;EACJ,MAAM;EACN,QAAQ;EACR;AACF,CAAC,KAAK;EACJ,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE;IACrB;EACF;EAEA,MAAM;IACJ,wBAAwB,GAAG;EAC7B,CAAC,GAAG,OAAO,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EAAE,SAAS,CACnB,CAAC;IACF;EACF;EAEA,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;EAC5C,IAAI,CAAC,WAAW,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE;IAClD,WAAW,CAAC,CAAC;IACb;EACF;EAEA,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,CAAC;EACvC,iBAAiB,CAAC,gBAAgB,CAAC;EAEnC,qBAAqB,CAAC,CACpB,UAAU,CACX,CAAC;AACJ,CAAC,EAAE;EACD,gBAAgB,EAAE,IAAI;EACtB,IAAI,EAAE;IACJ,IAAI,EAAE;MACJ,WAAW,EAAE,qEAAqE;MAClF,GAAG,EAAE;IACP,CAAC;IACD,MAAM,EAAE,CACN;MACE,oBAAoB,EAAE,KAAK;MAC3B,UAAU,EAAE;QACV,UAAU,EAAE;UACV,WAAW,EAAE;AACzB;AACA;AACA;AACA,uBAAuB;UACX,KAAK,EAAE;YACL,IAAI,EAAE;UACR,CAAC;UACD,IAAI,EAAE;QACR,CAAC;QACD,wBAAwB,EAAE;UACxB,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,uBAAuB;UACX,IAAI,EAAE;QACR;MACF,CAAC;MACD,IAAI,EAAE;IACR,CAAC,CACF;IACD,IAAI,EAAE;EACR;AACF,CAAC,CAAC","ignoreList":[]}
@@ -1,11 +1,5 @@
1
- "use strict";
1
+ import iterateJsdoc from '../iterateJsdoc.js';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
3
  /**
10
4
  * We can skip checking for a throws value, in case the documentation is inherited
11
5
  * or the method is either a constructor or an abstract method.
@@ -23,7 +17,7 @@ const canSkip = utils => {
23
17
  // The designated type can itself document `@throws`
24
18
  'type']) || utils.avoidDocs(false);
25
19
  };
26
- var _default = exports.default = (0, _iterateJsdoc.default)(({
20
+ export default iterateJsdoc(({
27
21
  report,
28
22
  utils
29
23
  }) => {
@@ -114,5 +108,4 @@ exemption of the rule.`,
114
108
  type: 'suggestion'
115
109
  }
116
110
  });
117
- module.exports = exports.default;
118
111
  //# sourceMappingURL=requireThrows.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"requireThrows.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","canSkip","utils","hasATag","avoidDocs","_default","exports","iterateJsdoc","report","tagName","getPreferredTagName","tags","getTags","iteratingFunction","isIteratingFunction","tag","missingThrowsTag","shouldReport","type","trim","hasThrowValue","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","exemptedBy","module"],"sources":["../../src/rules/requireThrows.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a throws value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not necessary to document that they throw an error.\n 'abstract',\n 'virtual',\n\n // The designated type can itself document `@throws`\n 'type',\n ]) ||\n utils.avoidDocs(false);\n};\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n // A preflight check. We do not need to run a deep check for abstract\n // functions.\n if (canSkip(utils)) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'throws',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n const iteratingFunction = utils.isIteratingFunction();\n\n // In case the code returns something, we expect a return value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingThrowsTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingThrowsTag) {\n if (tag.type.trim() === 'never' && iteratingFunction && utils.hasThrowValue()) {\n report(`JSDoc @${tagName} declaration set to \"never\" but throw value found.`);\n }\n\n return false;\n }\n\n return iteratingFunction && utils.hasThrowValue();\n };\n\n if (shouldReport()) {\n report(`Missing JSDoc @${tagName} declaration.`);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that throw statements are documented with `@throws` tags.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context\n(or objects with optional \\`context\\` and \\`comment\\` properties) where you wish\nthe rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`).`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n description: `Array of tags (e.g., \\`['type']\\`) whose presence on the\ndocument block avoids the need for a \\`@throws\\`. Defaults to an array\nwith \\`inheritdoc\\`. If you set this array, it will overwrite the default,\nso be sure to add back \\`inheritdoc\\` if you wish its presence to cause\nexemption of the rule.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sB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X,KAAK,CAACkB,aAAa,CAAC,CAAC;EACnD,CAAC;EAED,IAAIH,YAAY,CAAC,CAAC,EAAE;IAClBT,MAAM,CAAC,kBAAkBC,OAAO,eAAe,CAAC;EAClD;AACF,CAAC,EAAE;EACDY,eAAe,EAAE,IAAI;EACrBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,oEAAoE;MACjFC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRL,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,kEAAkE;UACtDM,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACEb,IAAI,EAAE;YACR,CAAC,EACD;cACES,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVI,OAAO,EAAE;kBACPd,IAAI,EAAE;gBACR,CAAC;gBACDe,OAAO,EAAE;kBACPf,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDgB,UAAU,EAAE;UACVV,WAAW,EAAE;AACzB;AACA;AACA;AACA,uBAAuB;UACXM,KAAK,EAAE;YACLZ,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAiB,MAAA,CAAA7B,OAAA,GAAAA,OAAA,CAAAN,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireThrows.cjs","names":[],"sources":["../../src/rules/requireThrows.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * We can skip checking for a throws value, in case the documentation is inherited\n * or the method is either a constructor or an abstract method.\n * @param {import('../iterateJsdoc.js').Utils} utils a reference to the utils which are used to probe if a tag is present or not.\n * @returns {boolean} true in case deep checking can be skipped; otherwise false.\n */\nconst canSkip = (utils) => {\n return utils.hasATag([\n // inheritdoc implies that all documentation is inherited\n // see https://jsdoc.app/tags-inheritdoc.html\n //\n // Abstract methods are by definition incomplete,\n // so it is not necessary to document that they throw an error.\n 'abstract',\n 'virtual',\n\n // The designated type can itself document `@throws`\n 'type',\n ]) ||\n utils.avoidDocs(false);\n};\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n // A preflight check. We do not need to run a deep check for abstract\n // functions.\n if (canSkip(utils)) {\n return;\n }\n\n const tagName = /** @type {string} */ (utils.getPreferredTagName({\n tagName: 'throws',\n }));\n if (!tagName) {\n return;\n }\n\n const tags = utils.getTags(tagName);\n const iteratingFunction = utils.isIteratingFunction();\n\n // In case the code returns something, we expect a return value in JSDoc.\n const [\n tag,\n ] = tags;\n const missingThrowsTag = typeof tag === 'undefined' || tag === null;\n\n const shouldReport = () => {\n if (!missingThrowsTag) {\n if (tag.type.trim() === 'never' && iteratingFunction && utils.hasThrowValue()) {\n report(`JSDoc @${tagName} declaration set to \"never\" but throw value found.`);\n }\n\n return false;\n }\n\n return iteratingFunction && utils.hasThrowValue();\n };\n\n if (shouldReport()) {\n report(`Missing JSDoc @${tagName} declaration.`);\n }\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that throw statements are documented with `@throws` tags.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n description: `Set this to an array of strings representing the AST context\n(or objects with optional \\`context\\` and \\`comment\\` properties) where you wish\nthe rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`). Set to \\`\"any\"\\` if you want\nthe rule to apply to any JSDoc block throughout your files (as is necessary\nfor finding function blocks not attached to a function declaration or\nexpression, i.e., \\`@callback\\` or \\`@function\\` (or its aliases \\`@func\\` or\n\\`@method\\`) (including those associated with an \\`@interface\\`).`,\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n exemptedBy: {\n description: `Array of tags (e.g., \\`['type']\\`) whose presence on the\ndocument block avoids the need for a \\`@throws\\`. Defaults to an array\nwith \\`inheritdoc\\`. If you set this array, it will overwrite the default,\nso be sure to add back \\`inheritdoc\\` if you wish its presence to cause\nexemption of the rule.`,\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":"AAAA,OAAO,YAAY,MAAM,oBAAoB;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,OAAO,GAAI,KAAK,IAAK;EACzB,OAAO,KAAK,CAAC,OAAO,CAAC;EACnB;EACA;EACA;EACA;EACA;EACA,UAAU,EACV,SAAS;EAET;EACA,MAAM,CACP,CAAC,IACA,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC;AAC1B,CAAC;AAED,eAAe,YAAY,CAAC,CAAC;EAC3B,MAAM;EACN;AACF,CAAC,KAAK;EACJ;EACA;EACA,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE;IAClB;EACF;EAEA,MAAM,OAAO,GAAG,qBAAuB,KAAK,CAAC,mBAAmB,CAAC;IAC/D,OAAO,EAAE;EACX,CAAC,CAAE;EACH,IAAI,CAAC,OAAO,EAAE;IACZ;EACF;EAEA,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;EACnC,MAAM,iBAAiB,GAAG,KAAK,CAAC,mBAAmB,CAAC,CAAC;;EAErD;EACA,MAAM,CACJ,GAAG,CACJ,GAAG,IAAI;EACR,MAAM,gBAAgB,GAAG,OAAO,GAA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,CAAC,CAAC","ignoreList":[]}
@@ -1,11 +1,5 @@
1
- "use strict";
1
+ import iterateJsdoc from '../iterateJsdoc.js';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
3
  /**
10
4
  * We can skip checking for a yield value, in case the documentation is inherited
11
5
  * or the method has a constructor or abstract tag.
@@ -55,7 +49,7 @@ const checkTagName = (utils, report, tagName) => {
55
49
  const missingTag = typeof tag === 'undefined' || tag === null;
56
50
  return [preferredTagName, missingTag];
57
51
  };
58
- var _default = exports.default = (0, _iterateJsdoc.default)(({
52
+ export default iterateJsdoc(({
59
53
  context,
60
54
  report,
61
55
  utils
@@ -220,5 +214,4 @@ to catch \`@generator\` with \`@callback\` or such not attached to a function.`,
220
214
  type: 'suggestion'
221
215
  }
222
216
  });
223
- module.exports = exports.default;
224
217
  //# sourceMappingURL=requireYields.cjs.map