eslint-plugin-jsdoc 58.1.1 → 59.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/README.md +66 -62
  2. package/dist/buildForbidRuleDefinition.cjs +0 -1
  3. package/dist/buildForbidRuleDefinition.cjs.map +1 -1
  4. package/dist/buildRejectOrPreferRuleDefinition.cjs +7 -2
  5. package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -1
  6. package/dist/cjs/rules/convertToJsdocComments.d.ts +7 -0
  7. package/dist/generateDocs.cjs +129 -3
  8. package/dist/generateDocs.cjs.map +1 -1
  9. package/dist/generateRule.cjs +3 -1
  10. package/dist/generateRule.cjs.map +1 -1
  11. package/dist/generateRuleTypes.cjs +5 -5
  12. package/dist/generateRuleTypes.cjs.map +1 -1
  13. package/dist/index-cjs.cjs +30 -0
  14. package/dist/index-cjs.cjs.map +1 -1
  15. package/dist/index.cjs +30 -0
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/rules/checkAccess.cjs +1 -1
  18. package/dist/rules/checkAccess.cjs.map +1 -1
  19. package/dist/rules/checkAlignment.cjs +4 -1
  20. package/dist/rules/checkAlignment.cjs.map +1 -1
  21. package/dist/rules/checkExamples.cjs +1 -1
  22. package/dist/rules/checkExamples.cjs.map +1 -1
  23. package/dist/rules/checkIndentation.cjs +19 -0
  24. package/dist/rules/checkIndentation.cjs.map +1 -1
  25. package/dist/rules/checkLineAlignment.cjs +25 -1
  26. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  27. package/dist/rules/checkParamNames.cjs +62 -1
  28. package/dist/rules/checkParamNames.cjs.map +1 -1
  29. package/dist/rules/checkPropertyNames.cjs +6 -0
  30. package/dist/rules/checkPropertyNames.cjs.map +1 -1
  31. package/dist/rules/checkTagNames.cjs +71 -0
  32. package/dist/rules/checkTagNames.cjs.map +1 -1
  33. package/dist/rules/checkTypes.cjs +16 -1
  34. package/dist/rules/checkTypes.cjs.map +1 -1
  35. package/dist/rules/checkValues.cjs +17 -1
  36. package/dist/rules/checkValues.cjs.map +1 -1
  37. package/dist/rules/convertToJsdocComments.cjs +48 -0
  38. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  39. package/dist/rules/convertToJsdocComments.d.ts +7 -0
  40. package/dist/rules/emptyTags.cjs +10 -1
  41. package/dist/rules/emptyTags.cjs.map +1 -1
  42. package/dist/rules/implementsOnClasses.cjs +15 -1
  43. package/dist/rules/implementsOnClasses.cjs.map +1 -1
  44. package/dist/rules/informativeDocs.cjs +45 -0
  45. package/dist/rules/informativeDocs.cjs.map +1 -1
  46. package/dist/rules/linesBeforeBlock.cjs +14 -0
  47. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  48. package/dist/rules/matchDescription.cjs +129 -0
  49. package/dist/rules/matchDescription.cjs.map +1 -1
  50. package/dist/rules/matchName.cjs +30 -0
  51. package/dist/rules/matchName.cjs.map +1 -1
  52. package/dist/rules/multilineBlocks.cjs +78 -6
  53. package/dist/rules/multilineBlocks.cjs.map +1 -1
  54. package/dist/rules/noBadBlocks.cjs +11 -2
  55. package/dist/rules/noBadBlocks.cjs.map +1 -1
  56. package/dist/rules/noBlankBlockDescriptions.cjs +1 -1
  57. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
  58. package/dist/rules/noBlankBlocks.cjs +3 -1
  59. package/dist/rules/noBlankBlocks.cjs.map +1 -1
  60. package/dist/rules/noDefaults.cjs +19 -0
  61. package/dist/rules/noDefaults.cjs.map +1 -1
  62. package/dist/rules/noMissingSyntax.cjs +22 -2
  63. package/dist/rules/noMissingSyntax.cjs.map +1 -1
  64. package/dist/rules/noMultiAsterisks.cjs +29 -0
  65. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  66. package/dist/rules/noRestrictedSyntax.cjs +17 -1
  67. package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
  68. package/dist/rules/noTypes.cjs +17 -1
  69. package/dist/rules/noTypes.cjs.map +1 -1
  70. package/dist/rules/noUndefinedTypes.cjs +11 -1
  71. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  72. package/dist/rules/requireAsteriskPrefix.cjs +28 -0
  73. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  74. package/dist/rules/requireDescription.cjs +30 -1
  75. package/dist/rules/requireDescription.cjs.map +1 -1
  76. package/dist/rules/requireDescriptionCompleteSentence.cjs +27 -0
  77. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  78. package/dist/rules/requireExample.cjs +26 -1
  79. package/dist/rules/requireExample.cjs.map +1 -1
  80. package/dist/rules/requireFileOverview.cjs +61 -0
  81. package/dist/rules/requireFileOverview.cjs.map +1 -1
  82. package/dist/rules/requireHyphenBeforeParamDescription.cjs +20 -2
  83. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  84. package/dist/rules/requireJsdoc.cjs +82 -3
  85. package/dist/rules/requireJsdoc.cjs.map +1 -1
  86. package/dist/rules/requireParam.cjs +213 -1
  87. package/dist/rules/requireParam.cjs.map +1 -1
  88. package/dist/rules/requireParamDescription.cjs +21 -0
  89. package/dist/rules/requireParamDescription.cjs.map +1 -1
  90. package/dist/rules/requireParamName.cjs +16 -1
  91. package/dist/rules/requireParamName.cjs.map +1 -1
  92. package/dist/rules/requireParamType.cjs +21 -1
  93. package/dist/rules/requireParamType.cjs.map +1 -1
  94. package/dist/rules/requirePropertyName.cjs +1 -1
  95. package/dist/rules/requirePropertyName.cjs.map +1 -1
  96. package/dist/rules/requirePropertyType.cjs +1 -1
  97. package/dist/rules/requirePropertyType.cjs.map +1 -1
  98. package/dist/rules/requireReturns.cjs +54 -1
  99. package/dist/rules/requireReturns.cjs.map +1 -1
  100. package/dist/rules/requireReturnsCheck.cjs +22 -1
  101. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  102. package/dist/rules/requireReturnsDescription.cjs +15 -1
  103. package/dist/rules/requireReturnsDescription.cjs.map +1 -1
  104. package/dist/rules/requireReturnsType.cjs +15 -1
  105. package/dist/rules/requireReturnsType.cjs.map +1 -1
  106. package/dist/rules/requireTemplate.cjs +17 -1
  107. package/dist/rules/requireTemplate.cjs.map +1 -1
  108. package/dist/rules/requireThrows.cjs +18 -1
  109. package/dist/rules/requireThrows.cjs.map +1 -1
  110. package/dist/rules/requireYields.cjs +50 -1
  111. package/dist/rules/requireYields.cjs.map +1 -1
  112. package/dist/rules/requireYieldsCheck.cjs +25 -7
  113. package/dist/rules/requireYieldsCheck.cjs.map +1 -1
  114. package/dist/rules/sortTags.cjs +200 -1
  115. package/dist/rules/sortTags.cjs.map +1 -1
  116. package/dist/rules/tagLines.cjs +32 -2
  117. package/dist/rules/tagLines.cjs.map +1 -1
  118. package/dist/rules/textEscaping.cjs +5 -1
  119. package/dist/rules/textEscaping.cjs.map +1 -1
  120. package/dist/rules/typeFormatting.cjs +47 -10
  121. package/dist/rules/typeFormatting.cjs.map +1 -1
  122. package/dist/rules/validTypes.cjs +8 -1
  123. package/dist/rules/validTypes.cjs.map +1 -1
  124. package/dist/rules.d.ts +2130 -32
  125. package/package.json +1 -1
  126. package/src/buildForbidRuleDefinition.js +0 -1
  127. package/src/buildRejectOrPreferRuleDefinition.js +12 -2
  128. package/src/index-cjs.js +36 -0
  129. package/src/index.js +36 -0
  130. package/src/rules/checkAccess.js +1 -1
  131. package/src/rules/checkAlignment.js +3 -0
  132. package/src/rules/checkExamples.js +1 -1
  133. package/src/rules/checkIndentation.js +19 -0
  134. package/src/rules/checkLineAlignment.js +24 -0
  135. package/src/rules/checkParamNames.js +62 -1
  136. package/src/rules/checkPropertyNames.js +6 -0
  137. package/src/rules/checkTagNames.js +71 -0
  138. package/src/rules/checkTypes.js +16 -1
  139. package/src/rules/checkValues.js +16 -0
  140. package/src/rules/convertToJsdocComments.js +48 -0
  141. package/src/rules/emptyTags.js +10 -1
  142. package/src/rules/implementsOnClasses.js +15 -1
  143. package/src/rules/informativeDocs.js +45 -0
  144. package/src/rules/linesBeforeBlock.js +14 -0
  145. package/src/rules/matchDescription.js +129 -0
  146. package/src/rules/matchName.js +30 -0
  147. package/src/rules/multilineBlocks.js +77 -5
  148. package/src/rules/noBadBlocks.js +11 -2
  149. package/src/rules/noBlankBlockDescriptions.js +1 -1
  150. package/src/rules/noBlankBlocks.js +2 -0
  151. package/src/rules/noDefaults.js +19 -0
  152. package/src/rules/noMissingSyntax.js +22 -2
  153. package/src/rules/noMultiAsterisks.js +29 -0
  154. package/src/rules/noRestrictedSyntax.js +17 -1
  155. package/src/rules/noTypes.js +17 -1
  156. package/src/rules/noUndefinedTypes.js +11 -1
  157. package/src/rules/requireAsteriskPrefix.js +28 -0
  158. package/src/rules/requireDescription.js +30 -1
  159. package/src/rules/requireDescriptionCompleteSentence.js +27 -0
  160. package/src/rules/requireExample.js +26 -1
  161. package/src/rules/requireFileOverview.js +61 -0
  162. package/src/rules/requireHyphenBeforeParamDescription.js +19 -1
  163. package/src/rules/requireJsdoc.js +80 -1
  164. package/src/rules/requireParam.js +213 -1
  165. package/src/rules/requireParamDescription.js +21 -0
  166. package/src/rules/requireParamName.js +16 -1
  167. package/src/rules/requireParamType.js +21 -1
  168. package/src/rules/requirePropertyName.js +1 -1
  169. package/src/rules/requirePropertyType.js +1 -1
  170. package/src/rules/requireReturns.js +54 -1
  171. package/src/rules/requireReturnsCheck.js +22 -1
  172. package/src/rules/requireReturnsDescription.js +15 -1
  173. package/src/rules/requireReturnsType.js +15 -1
  174. package/src/rules/requireTemplate.js +17 -1
  175. package/src/rules/requireThrows.js +18 -1
  176. package/src/rules/requireYields.js +50 -1
  177. package/src/rules/requireYieldsCheck.js +25 -7
  178. package/src/rules/sortTags.js +200 -1
  179. package/src/rules/tagLines.js +30 -0
  180. package/src/rules/textEscaping.js +5 -1
  181. package/src/rules/typeFormatting.js +44 -7
  182. package/src/rules/validTypes.js +8 -1
  183. package/src/rules.d.ts +2130 -32
  184. package/typings/gitdown.d.ts +4 -0
@@ -1 +1 @@
1
- {"version":3,"file":"requireParamType.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","report","settings","utils","defaultDestructuredRootType","setDefaultDestructuredRootType","options","functionParameterNames","getFunctionParameterNames","rootCount","forEachPreferredTag","jsdocParameter","targetTagName","name","includes","type","Array","isArray","exemptDestructuredRootsFromChecks","reportJSDoc","changeTag","postType","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","comment","module"],"sources":["../../src/rules/requireParamType.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n report,\n settings,\n utils,\n}) => {\n const {\n defaultDestructuredRootType = 'object',\n setDefaultDestructuredRootType = false,\n } = context.options[0] || {};\n\n const functionParameterNames = utils.getFunctionParameterNames();\n\n let rootCount = -1;\n utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => {\n rootCount += jsdocParameter.name.includes('.') ? 0 : 1;\n if (!jsdocParameter.type) {\n if (Array.isArray(functionParameterNames[rootCount])) {\n if (settings.exemptDestructuredRootsFromChecks) {\n return;\n }\n\n if (setDefaultDestructuredRootType) {\n utils.reportJSDoc(`Missing root type for @${targetTagName}.`, jsdocParameter, () => {\n utils.changeTag(jsdocParameter, {\n postType: ' ',\n type: `{${defaultDestructuredRootType}}`,\n });\n });\n return;\n }\n }\n\n report(\n `Missing JSDoc @${targetTagName} \"${jsdocParameter.name}\" type.`,\n null,\n jsdocParameter,\n );\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that each `@param` tag has a `type` value.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-type.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\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 defaultDestructuredRootType: {\n type: 'string',\n },\n setDefaultDestructuredRootType: {\n type: 'boolean',\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,OAAO;EACPC,MAAM;EACNC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC,2BAA2B,GAAG,QAAQ;IACtCC,8BAA8B,GAAG;EACnC,CAAC,GAAGL,OAAO,CAACM,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAMC,sBAAsB,GAAGJ,KAAK,CAACK,yBAAyB,CAAC,CAAC;EAEhE,IAAIC,SAAS,GAAG,CAAC,CAAC;EAClBN,KAAK,CAACO,mBAAmB,CAAC,OAAO,EAAE,CAACC,cAAc,EAAEC,aAAa,KAAK;IACpEH,SAAS,IAAIE,cAAc,CAACE,IAAI,CAACC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;IACtD,IAAI,CAACH,cAAc,CAACI,IAAI,EAAE;MACxB,IAAIC,KAAK,CAACC,OAAO,CAACV,sBAAsB,CAACE,SAAS,CAAC,CAAC,EAAE;QACpD,IAAIP,QAAQ,CAACgB,iCAAiC,EAAE;UAC9C;QACF;QAEA,IAAIb,8BAA8B,EAAE;UAClCF,KAAK,CAACgB,WAAW,CAAC,0BAA0BP,aAAa,GAAG,EAAED,cAAc,EAAE,MAAM;YAClFR,KAAK,CAACiB,SAAS,CAACT,cAAc,EAAE;cAC9BU,QAAQ,EAAE,GAAG;cACbN,IAAI,EAAE,IAAIX,2BAA2B;YACvC,CAAC,CAAC;UACJ,CAAC,CAAC;UACF;QACF;MACF;MAEAH,MAAM,CACJ,kBAAkBW,aAAa,KAAKD,cAAc,CAACE,IAAI,SAAS,EAChE,IAAI,EACJF,cACF,CAAC;IACH;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDW,eAAe,EAAE,IAAI;EACrBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,qDAAqD;MAClEC,GAAG,EAAE;IACP,CAAC;IACDC,OAAO,EAAE,MAAM;IACfC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRC,KAAK,EAAE;YACLC,KAAK,EAAE,CACL;cACElB,IAAI,EAAE;YACR,CAAC,EACD;cACEc,oBAAoB,EAAE,KAAK;cAC3BC,UAAU,EAAE;gBACVI,OAAO,EAAE;kBACPnB,IAAI,EAAE;gBACR,CAAC;gBACDf,OAAO,EAAE;kBACPe,IAAI,EAAE;gBACR;cACF,CAAC;cACDA,IAAI,EAAE;YACR,CAAC;UAEL,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDX,2BAA2B,EAAE;UAC3BW,IAAI,EAAE;QACR,CAAC;QACDV,8BAA8B,EAAE;UAC9BU,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAoB,MAAA,CAAArC,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireParamType.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","context","report","settings","utils","defaultDestructuredRootType","setDefaultDestructuredRootType","options","functionParameterNames","getFunctionParameterNames","rootCount","forEachPreferredTag","jsdocParameter","targetTagName","name","includes","type","Array","isArray","exemptDestructuredRootsFromChecks","reportJSDoc","changeTag","postType","contextDefaults","meta","docs","description","url","fixable","schema","additionalProperties","properties","contexts","items","anyOf","comment","module"],"sources":["../../src/rules/requireParamType.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n context,\n report,\n settings,\n utils,\n}) => {\n const {\n defaultDestructuredRootType = 'object',\n setDefaultDestructuredRootType = false,\n } = context.options[0] || {};\n\n const functionParameterNames = utils.getFunctionParameterNames();\n\n let rootCount = -1;\n utils.forEachPreferredTag('param', (jsdocParameter, targetTagName) => {\n rootCount += jsdocParameter.name.includes('.') ? 0 : 1;\n if (!jsdocParameter.type) {\n if (Array.isArray(functionParameterNames[rootCount])) {\n if (settings.exemptDestructuredRootsFromChecks) {\n return;\n }\n\n if (setDefaultDestructuredRootType) {\n utils.reportJSDoc(`Missing root type for @${targetTagName}.`, jsdocParameter, () => {\n utils.changeTag(jsdocParameter, {\n postType: ' ',\n type: `{${defaultDestructuredRootType}}`,\n });\n });\n return;\n }\n }\n\n report(\n `Missing JSDoc @${targetTagName} \"${jsdocParameter.name}\" type.`,\n null,\n jsdocParameter,\n );\n }\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Requires that each `@param` tag has a type value (in curly brackets).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-param-type.md#repos-sticky-header',\n },\n fixable: 'code',\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-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 defaultDestructuredRootType: {\n description: 'The type string to set by default for destructured roots. Defaults to \"object\".',\n type: 'string',\n },\n setDefaultDestructuredRootType: {\n description: `Whether to set a default destructured root type. For example, you may wish\nto avoid manually having to set the type for a \\`@param\\`\ncorresponding to a destructured root object as it is always going to be an\nobject. Uses \\`defaultDestructuredRootType\\` for the type string. Defaults to\n\\`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;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,OAAO;EACPC,MAAM;EACNC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAM;IACJC,2BAA2B,GAAG,QAAQ;IACtCC,8BAA8B,GAAG;EACnC,CAAC,GAAGL,OAAO,CAACM,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAMC,sBAAsB,GAAGJ,KAAK,CAACK,yBAAyB,CAAC,CAAC;EAEhE,IAAIC,SAAS,GAAG,CAAC,CAAC;EAClBN,KAAK,CAACO,mBAAmB,CAAC,OAAO,EAAE,CAACC,cAAc,EAAEC,aAAa,KAAK;IACpEH,SAAS,IAAIE,cAAc,CAACE,IAAI,CAACC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;IACtD,IAAI,CAACH,cAAc,CAACI,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ACR,CAAC;QACDV,8BAA8B,EAAE;UAC9BoB,WAAW,EAAE;AACzB;AACA;AACA;AACA,WAAW;UACCV,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAoB,MAAA,CAAArC,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
@@ -19,7 +19,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
19
19
  iterateAllJsdocs: true,
20
20
  meta: {
21
21
  docs: {
22
- description: 'Requires that all function `@property` tags have names.',
22
+ description: 'Requires that all `@property` tags have names.',
23
23
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-name.md#repos-sticky-header'
24
24
  },
25
25
  type: 'suggestion'
@@ -1 +1 @@
1
- {"version":3,"file":"requirePropertyName.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdoc","targetTagName","tag","name","type","iterateAllJsdocs","meta","docs","description","url","module"],"sources":["../../src/rules/requirePropertyName.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('property', (jsdoc, targetTagName) => {\n if (jsdoc.tag && jsdoc.name === '') {\n report(\n `There must be an identifier after @${targetTagName} ${jsdoc.type === '' ? 'type' : 'tag'}.`,\n null,\n jsdoc,\n );\n }\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that all function `@property` tags have names.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-name.md#repos-sticky-header',\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,UAAU,EAAE,CAACC,KAAK,EAAEC,aAAa,KAAK;IAC9D,IAAID,KAAK,CAACE,GAAG,IAAIF,KAAK,CAACG,IAAI,KAAK,EAAE,EAAE;MAClCN,MAAM,CACJ,sCAAsCI,aAAa,IAAID,KAAK,CAACI,IAAI,KAAK,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,EAC5F,IAAI,EACJJ,KACF,CAAC;IACH;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDK,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,yDAAyD;MACtEC,GAAG,EAAE;IACP,CAAC;IACDL,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAM,MAAA,CAAAf,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requirePropertyName.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdoc","targetTagName","tag","name","type","iterateAllJsdocs","meta","docs","description","url","module"],"sources":["../../src/rules/requirePropertyName.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('property', (jsdoc, targetTagName) => {\n if (jsdoc.tag && jsdoc.name === '') {\n report(\n `There must be an identifier after @${targetTagName} ${jsdoc.type === '' ? 'type' : 'tag'}.`,\n null,\n jsdoc,\n );\n }\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that all `@property` tags have names.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-name.md#repos-sticky-header',\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,UAAU,EAAE,CAACC,KAAK,EAAEC,aAAa,KAAK;IAC9D,IAAID,KAAK,CAACE,GAAG,IAAIF,KAAK,CAACG,IAAI,KAAK,EAAE,EAAE;MAClCN,MAAM,CACJ,sCAAsCI,aAAa,IAAID,KAAK,CAACI,IAAI,KAAK,EAAE,GAAG,MAAM,GAAG,KAAK,GAAG,EAC5F,IAAI,EACJJ,KACF,CAAC;IACH;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDK,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,gDAAgD;MAC7DC,GAAG,EAAE;IACP,CAAC;IACDL,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAM,MAAA,CAAAf,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
@@ -19,7 +19,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
19
19
  iterateAllJsdocs: true,
20
20
  meta: {
21
21
  docs: {
22
- description: 'Requires that each `@property` tag has a `type` value.',
22
+ description: 'Requires that each `@property` tag has a type value (in curly brackets).',
23
23
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-type.md#repos-sticky-header'
24
24
  },
25
25
  type: 'suggestion'
@@ -1 +1 @@
1
- {"version":3,"file":"requirePropertyType.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdoc","targetTagName","type","name","iterateAllJsdocs","meta","docs","description","url","module"],"sources":["../../src/rules/requirePropertyType.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('property', (jsdoc, targetTagName) => {\n if (!jsdoc.type) {\n report(\n `Missing JSDoc @${targetTagName} \"${jsdoc.name}\" type.`,\n null,\n jsdoc,\n );\n }\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that each `@property` tag has a `type` value.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-type.md#repos-sticky-header',\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,UAAU,EAAE,CAACC,KAAK,EAAEC,aAAa,KAAK;IAC9D,IAAI,CAACD,KAAK,CAACE,IAAI,EAAE;MACfL,MAAM,CACJ,kBAAkBI,aAAa,KAAKD,KAAK,CAACG,IAAI,SAAS,EACvD,IAAI,EACJH,KACF,CAAC;IACH;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDI,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,wDAAwD;MACrEC,GAAG,EAAE;IACP,CAAC;IACDN,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAO,MAAA,CAAAd,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requirePropertyType.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","_default","exports","iterateJsdoc","report","utils","forEachPreferredTag","jsdoc","targetTagName","type","name","iterateAllJsdocs","meta","docs","description","url","module"],"sources":["../../src/rules/requirePropertyType.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n utils.forEachPreferredTag('property', (jsdoc, targetTagName) => {\n if (!jsdoc.type) {\n report(\n `Missing JSDoc @${targetTagName} \"${jsdoc.name}\" type.`,\n null,\n jsdoc,\n );\n }\n });\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Requires that each `@property` tag has a type value (in curly brackets).',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property-type.md#repos-sticky-header',\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,UAAU,EAAE,CAACC,KAAK,EAAEC,aAAa,KAAK;IAC9D,IAAI,CAACD,KAAK,CAACE,IAAI,EAAE;MACfL,MAAM,CACJ,kBAAkBI,aAAa,KAAKD,KAAK,CAACG,IAAI,SAAS,EACvD,IAAI,EACJH,KACF,CAAC;IACH;EACF,CAAC,CAAC;AACJ,CAAC,EAAE;EACDI,gBAAgB,EAAE,IAAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,0EAA0E;MACvFC,GAAG,EAAE;IACP,CAAC;IACDN,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAO,MAAA,CAAAd,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
@@ -121,7 +121,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
121
121
  contextDefaults: true,
122
122
  meta: {
123
123
  docs: {
124
- description: 'Requires that returns are documented.',
124
+ description: 'Requires that returns are documented with `@returns`.',
125
125
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns.md#repos-sticky-header'
126
126
  },
127
127
  fixable: 'code',
@@ -130,13 +130,34 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
130
130
  properties: {
131
131
  checkConstructors: {
132
132
  default: false,
133
+ description: `A value indicating whether \`constructor\`s should
134
+ be checked for \`@returns\` tags. Defaults to \`false\`.`,
133
135
  type: 'boolean'
134
136
  },
135
137
  checkGetters: {
136
138
  default: true,
139
+ description: `Boolean to determine whether getter methods should
140
+ be checked for \`@returns\` tags. Defaults to \`true\`.`,
137
141
  type: 'boolean'
138
142
  },
139
143
  contexts: {
144
+ description: `Set this to an array of strings representing the AST context
145
+ (or objects with optional \`context\` and \`comment\` properties) where you wish
146
+ the rule to be applied.
147
+
148
+ \`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
149
+
150
+ Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
151
+ \`FunctionExpression\`). Set to \`"any"\` if you want
152
+ the rule to apply to any JSDoc block throughout your files (as is necessary
153
+ for finding function blocks not attached to a function declaration or
154
+ expression, i.e., \`@callback\` or \`@function\` (or its aliases \`@func\` or
155
+ \`@method\`) (including those associated with an \`@interface\`). This
156
+ rule will only apply on non-default contexts when there is such a tag
157
+ present and the \`forceRequireReturn\` option is set or if the
158
+ \`forceReturnsWithAsync\` option is set with a present \`@async\` tag
159
+ (since we are not checking against the actual \`return\` values in these
160
+ cases).`,
140
161
  items: {
141
162
  anyOf: [{
142
163
  type: 'string'
@@ -159,9 +180,16 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
159
180
  type: 'array'
160
181
  },
161
182
  enableFixer: {
183
+ description: `Whether to enable the fixer to add a blank \`@returns\`.
184
+ Defaults to \`false\`.`,
162
185
  type: 'boolean'
163
186
  },
164
187
  exemptedBy: {
188
+ description: `Array of tags (e.g., \`['type']\`) whose presence on the
189
+ document block avoids the need for a \`@returns\`. Defaults to an array
190
+ with \`inheritdoc\`. If you set this array, it will overwrite the default,
191
+ so be sure to add back \`inheritdoc\` if you wish its presence to cause
192
+ exemption of the rule.`,
165
193
  items: {
166
194
  type: 'string'
167
195
  },
@@ -169,13 +197,38 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
169
197
  },
170
198
  forceRequireReturn: {
171
199
  default: false,
200
+ description: `Set to \`true\` to always insist on
201
+ \`@returns\` documentation regardless of implicit or explicit \`return\`'s
202
+ in the function. May be desired to flag that a project is aware of an
203
+ \`undefined\`/\`void\` return. Defaults to \`false\`.`,
172
204
  type: 'boolean'
173
205
  },
174
206
  forceReturnsWithAsync: {
175
207
  default: false,
208
+ description: `By default \`async\` functions that do not explicitly
209
+ return a value pass this rule as an \`async\` function will always return a
210
+ \`Promise\`, even if the \`Promise\` resolves to void. You can force all
211
+ \`async\` functions (including ones with an explicit \`Promise\` but no
212
+ detected non-\`undefined\` \`resolve\` value) to require \`@return\`
213
+ documentation by setting \`forceReturnsWithAsync\` to \`true\` on the options
214
+ object. This may be useful for flagging that there has been consideration
215
+ of return type. Defaults to \`false\`.`,
176
216
  type: 'boolean'
177
217
  },
178
218
  publicOnly: {
219
+ description: `This option will insist that missing \`@returns\` are only reported for
220
+ function bodies / class declarations that are exported from the module.
221
+ May be a boolean or object. If set to \`true\`, the defaults below will be
222
+ used. If unset, \`@returns\` reporting will not be limited to exports.
223
+
224
+ This object supports the following optional boolean keys (\`false\` unless
225
+ otherwise noted):
226
+
227
+ - \`ancestorsOnly\` - Optimization to only check node ancestors to check if node is exported
228
+ - \`esm\` - ESM exports are checked for \`@returns\` JSDoc comments (Defaults to \`true\`)
229
+ - \`cjs\` - CommonJS exports are checked for \`@returns\` JSDoc comments (Defaults to \`true\`)
230
+ - \`window\` - Window global exports are checked for \`@returns\` JSDoc comments
231
+ `,
179
232
  oneOf: [{
180
233
  default: false,
181
234
  type: 'boolean'
@@ -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 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.',\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 type: 'boolean',\n },\n checkGetters: {\n default: true,\n type: 'boolean',\n },\n contexts: {\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 type: 'boolean',\n },\n exemptedBy: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n forceRequireReturn: {\n default: false,\n type: 'boolean',\n },\n forceReturnsWithAsync: {\n default: false,\n type: 'boolean',\n },\n publicOnly: {\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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;QACR,CAAC;QACDI,UAAU,EAAE;UACVF,KAAK,EAAE;YACLF,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACD9C,kBAAkB,EAAE;UAClBhB,OAAO,EAAE,KAAK;UACd8D,IAAI,EAAE;QACR,CAAC;QACD7C,qBAAqB,EAAE;UACrBjB,OAAO,EAAE,KAAK;UACd8D,IAAI,EAAE;QACR,CAAC;QACD5C,UAAU,EAAE;UACViD,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":["_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 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`,\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,KAAK,CAACC,OAAO,CAAC;EACnB;EACA;EACA;EAC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uB;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;AACA,CAAC;UACWY,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":[]}
@@ -80,7 +80,7 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
80
80
  }, {
81
81
  meta: {
82
82
  docs: {
83
- description: 'Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.',
83
+ 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).',
84
84
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-check.md#repos-sticky-header'
85
85
  },
86
86
  schema: [{
@@ -88,13 +88,34 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
88
88
  properties: {
89
89
  exemptAsync: {
90
90
  default: true,
91
+ description: `By default, functions which return a \`Promise\` that are not
92
+ detected as resolving with a non-\`undefined\` value and \`async\` functions
93
+ (even ones that do not explicitly return a value, as these are returning a
94
+ \`Promise\` implicitly) will be exempted from reporting by this rule.
95
+ If you wish to insist that only \`Promise\`'s which resolve to
96
+ non-\`undefined\` values or \`async\` functions with explicit \`return\`'s will
97
+ be exempted from reporting (i.e., that \`async\` functions can be reported
98
+ if they lack an explicit (non-\`undefined\`) \`return\` when a \`@returns\` is
99
+ present), you can set \`exemptAsync\` to \`false\` on the options object.`,
91
100
  type: 'boolean'
92
101
  },
93
102
  exemptGenerators: {
103
+ description: `Because a generator might be labeled as having a
104
+ \`IterableIterator\` \`@returns\` value (along with an iterator type
105
+ corresponding to the type of any \`yield\` statements), projects might wish to
106
+ leverage \`@returns\` in generators even without a \`return\` statement. This
107
+ option is therefore \`true\` by default in \`typescript\` mode (in "jsdoc" mode,
108
+ one might be more likely to take advantage of \`@yields\`). Set it to \`false\`
109
+ if you wish for a missing \`return\` to be flagged regardless.`,
94
110
  type: 'boolean'
95
111
  },
96
112
  reportMissingReturnForUndefinedTypes: {
97
113
  default: false,
114
+ description: `If \`true\` and no return or
115
+ resolve value is found, this setting will even insist that reporting occur
116
+ with \`void\` or \`undefined\` (including as an indicated \`Promise\` type).
117
+ Unlike \`require-returns\`, with this option in the rule, one can
118
+ *discourage* the labeling of \`undefined\` types. Defaults to \`false\`.`,
98
119
  type: 'boolean'
99
120
  }
100
121
  },
@@ -1 +1 @@
1
- {"version":3,"file":"requireReturnsCheck.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","_default","exports","iterateJsdoc","context","node","report","exemptAsync","exemptGenerators","reportMissingReturnForUndefinedTypes","options","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","type","trim","test","returnNever","hasValueOrExecutorHasNonEmptyResolveValue","mayBeUndefinedTypeTag","Boolean","generator","meta","docs","description","url","schema","additionalProperties","properties","module"],"sources":["../../src/rules/requireReturnsCheck.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\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\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n if (exemptAsync && utils.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\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 // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n !utils.mayBeUndefinedTypeTag(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.',\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 type: 'boolean',\n },\n exemptGenerators: {\n type: 'boolean',\n },\n reportMissingReturnForUndefinedTypes: {\n default: 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;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA;AACA;AACA,MAAMG,OAAO,GAAGA,CAACC,KAAK,EAAEC,Q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AC;QACDV,gBAAgB,EAAE;UAChBU,IAAI,EAAE;QACR,CAAC;QACDT,oCAAoC,EAAE;UACpClB,OAAO,EAAE,KAAK;UACd2B,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAe,MAAA,CAAA/B,OAAA,GAAAA,OAAA,CAAAX,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"requireReturnsCheck.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","canSkip","utils","settings","voidingTags","mode","push","hasATag","isConstructor","classHasTag","_default","exports","iterateJsdoc","context","node","report","exemptAsync","exemptGenerators","reportMissingReturnForUndefinedTypes","options","isAsync","tagName","getPreferredTagName","tags","getTags","length","tag","type","trim","test","returnNever","hasValueOrExecutorHasNonEmptyResolveValue","mayBeUndefinedTypeTag","Boolean","generator","meta","docs","description","url","schema","additionalProperties","properties","module"],"sources":["../../src/rules/requireReturnsCheck.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\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\nexport default iterateJsdoc(({\n context,\n node,\n report,\n settings,\n utils,\n}) => {\n const {\n exemptAsync = true,\n exemptGenerators = settings.mode === 'typescript',\n reportMissingReturnForUndefinedTypes = false,\n } = context.options[0] || {};\n\n if (canSkip(utils, settings)) {\n return;\n }\n\n if (exemptAsync && utils.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\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 // In case a return value is declared in JSDoc, we also expect one in the code.\n if (\n !returnNever &&\n (\n reportMissingReturnForUndefinedTypes ||\n !utils.mayBeUndefinedTypeTag(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 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,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA;AACA;AACA,MAAMG,OAAO,GAAGA,CAACC,KAAK,EAAEC,QAAQ,KAAK;EACnC,MAAMC,WAAW,GAAG;EAClB;EACA;EACA;EACA;EACA;EACA,UAAU,EACV,SAAS;EAET;EACA;EACA,OAAO,EACP,a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E;AACzB;AACA;AACA;AACA;AACA;AACA,+DAA+D;UACnDV,IAAI,EAAE;QACR,CAAC;QACDT,oCAAoC,EAAE;UACpClB,OAAO,EAAE,KAAK;UACdqC,WAAW,EAAE;AACzB;AACA;AACA;AACA,yEAAyE;UAC7DV,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAe,MAAA,CAAA/B,OAAA,GAAAA,OAAA,CAAAX,OAAA","ignoreList":[]}
@@ -23,13 +23,27 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
23
23
  contextDefaults: true,
24
24
  meta: {
25
25
  docs: {
26
- description: 'Requires that the `@returns` tag has a `description` value.',
26
+ description: 'Requires that the `@returns` tag has a `description` value (not including `void`/`undefined` type returns).',
27
27
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-description.md#repos-sticky-header'
28
28
  },
29
29
  schema: [{
30
30
  additionalProperties: false,
31
31
  properties: {
32
32
  contexts: {
33
+ description: `Set this to an array of strings representing the AST context (or an object with
34
+ optional \`context\` and \`comment\` properties) where you wish the rule to be applied.
35
+
36
+ \`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
37
+
38
+ Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
39
+ \`FunctionExpression\`). Set to \`"any"\` if you want
40
+ the rule to apply to any JSDoc block throughout your files (as is necessary
41
+ for finding function blocks not attached to a function declaration or
42
+ expression, i.e., \`@callback\` or \`@function\` (or its aliases \`@func\` or
43
+ \`@method\`) (including those associated with an \`@interface\`).
44
+
45
+ See the ["AST and Selectors"](../#advanced-ast-and-selectors)
46
+ section of our Advanced docs for more on the expected format.`,
33
47
  items: {
34
48
  anyOf: [{
35
49
  type: 'string'
@@ -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.',\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 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,6DAA6D;MAC1EI,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRC,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":["_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-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;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,EAAE;EACR;AACF,CAAC,CAAC;AAAAgB,MAAA,CAAAvB,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
@@ -19,13 +19,27 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
19
19
  contextDefaults: true,
20
20
  meta: {
21
21
  docs: {
22
- description: 'Requires that `@returns` tag has `type` value.',
22
+ description: 'Requires that `@returns` tag has type value (in curly brackets).',
23
23
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-returns-type.md#repos-sticky-header'
24
24
  },
25
25
  schema: [{
26
26
  additionalProperties: false,
27
27
  properties: {
28
28
  contexts: {
29
+ description: `Set this to an array of strings representing the AST context (or an object with
30
+ optional \`context\` and \`comment\` properties) where you wish the rule to be applied.
31
+
32
+ \`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
33
+
34
+ Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
35
+ \`FunctionExpression\`). Set to \`"any"\` if you want
36
+ the rule to apply to any JSDoc block throughout your files (as is necessary
37
+ for finding function blocks not attached to a function declaration or
38
+ expression, i.e., \`@callback\` or \`@function\` (or its aliases \`@func\` or
39
+ \`@method\`) (including those associated with an \`@interface\`).
40
+
41
+ See the ["AST and Selectors"](../#advanced-ast-and-selectors)
42
+ section of our Advanced docs for more on the expected format.`,
29
43
  items: {
30
44
  anyOf: [{
31
45
  type: 'string'
@@ -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.',\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 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,gDAAgD;MAC7DC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,QAAQ,EAAE;UACRC,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":["_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-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":[]}
@@ -166,19 +166,35 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
166
166
  iterateAllJsdocs: true,
167
167
  meta: {
168
168
  docs: {
169
- description: 'Requires template tags for each generic type parameter',
169
+ description: 'Requires `@template` tags be present when type parameters are used.',
170
170
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-template.md#repos-sticky-header'
171
171
  },
172
172
  schema: [{
173
173
  additionalProperties: false,
174
174
  properties: {
175
175
  exemptedBy: {
176
+ description: `Array of tags (e.g., \`['type']\`) whose presence on the document
177
+ block avoids the need for a \`@template\`. Defaults to an array with
178
+ \`inheritdoc\`. If you set this array, it will overwrite the default,
179
+ so be sure to add back \`inheritdoc\` if you wish its presence to cause
180
+ exemption of the rule.`,
176
181
  items: {
177
182
  type: 'string'
178
183
  },
179
184
  type: 'array'
180
185
  },
181
186
  requireSeparateTemplates: {
187
+ description: `Requires that each template have its own separate line, i.e., preventing
188
+ templates of this format:
189
+
190
+ \`\`\`js
191
+ /**
192
+ * @template T, U, V
193
+ */
194
+ \`\`\`
195
+
196
+ Defaults to \`false\`.
197
+ `,
182
198
  type: 'boolean'
183
199
  }
184
200
  },
@@ -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","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","value","test","has","set","checkTagsAndTemplates","tagNames","tagName","preferredTagName","getPreferredTagName","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 const templateTags = utils.getTags('template');\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 @template 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 @template ${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 const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\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 @template ${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 for each generic type parameter',\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 items: {\n type: 'string',\n },\n type: 'array',\n },\n requireSeparateTemplates: {\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;EACJ,IAAIA,KAAK,CAACC,SAAS,CAAC,CAAC,EAAE;IACrB;EACF;EAEA,MAAM;IACJC,wBAAwB,GAAG;EAC7B,CAAC,GAAGN,OAAO,CAACO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAM;IACJC;EACF,CAAC,GAAGL,QAAQ;EAEZ,MAAMM,SAAS,GAAG,IAAIC,GAAG,CAAC,C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AAI;EACtBC,IAAI,EAAE;IACJC,IAAI,EAAE;MACJC,WAAW,EAAE,wDAAwD;MACrEC,GAAG,EAAE;IACP,CAAC;IACDC,MAAM,EAAE,CACN;MACEC,oBAAoB,EAAE,KAAK;MAC3BC,UAAU,EAAE;QACVC,UAAU,EAAE;UACVC,KAAK,EAAE;YACLnC,IAAI,EAAE;UACR,CAAC;UACDA,IAAI,EAAE;QACR,CAAC;QACDvB,wBAAwB,EAAE;UACxBuB,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAoC,MAAA,CAAAnE,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
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","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","value","test","has","set","checkTagsAndTemplates","tagNames","tagName","preferredTagName","getPreferredTagName","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 const templateTags = utils.getTags('template');\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 @template 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 @template ${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 const {\n type,\n value,\n } = /** @type {import('jsdoc-type-pratt-parser').NameResult} */ (nde);\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 @template ${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`,\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;EACJ,IAAIA,KAAK,CAACC,SAAS,CAAC,CAAC,EAAE;IACrB;EACF;EAEA,MAAM;IACJC,wBAAwB,GAAG;EAC7B,CAAC,GAAGN,OAAO,CAACO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EAE5B,MAAM;IACJC;EACF,CAAC,GAAGL,QAAQ;EAEZ,MAAMM,SAAS,GAAG,IAAIC,GAAG,CAAC,CAAC;EAC3B,MAAMC,YAAY,GAAGP,KAAK,CAACQ,OAAO,CAAC,UAAU,CAAC;EAC9C,MAAMC,aAAa,GAAGF,YAAY,CAACG,OAAO,CAAEC,GAAG,IAAK;IAClD,OAAOX,KAAK,CAACY,uBAAuB,CAACD,GAAG,CAAC;EAC3C,CAAC,CAAC;EAEF,IAAIT,wBAAwB,EAAE;IAC5B,KAAK,MAAMS,GAAG,IAAIJ,YAAY,EAAE;MAC9B,MAAMM,KAAK,GAAGb,KAAK,CAACY,uBAAuB,CAAC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UACxBoD,WAAW,EAAE;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;UACW7B,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC,CACF;IACDA,IAAI,EAAE;EACR;AACF,CAAC,CAAC;AAAAoC,MAAA,CAAAnE,OAAA,GAAAA,OAAA,CAAAF,OAAA","ignoreList":[]}
@@ -60,13 +60,25 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
60
60
  contextDefaults: true,
61
61
  meta: {
62
62
  docs: {
63
- description: 'Requires that throw statements are documented.',
63
+ description: 'Requires that throw statements are documented with `@throws` tags.',
64
64
  url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-throws.md#repos-sticky-header'
65
65
  },
66
66
  schema: [{
67
67
  additionalProperties: false,
68
68
  properties: {
69
69
  contexts: {
70
+ description: `Set this to an array of strings representing the AST context
71
+ (or objects with optional \`context\` and \`comment\` properties) where you wish
72
+ the rule to be applied.
73
+
74
+ \`context\` defaults to \`any\` and \`comment\` defaults to no specific comment context.
75
+
76
+ Overrides the default contexts (\`ArrowFunctionExpression\`, \`FunctionDeclaration\`,
77
+ \`FunctionExpression\`). Set to \`"any"\` if you want
78
+ the rule to apply to any JSDoc block throughout your files (as is necessary
79
+ for finding function blocks not attached to a function declaration or
80
+ expression, i.e., \`@callback\` or \`@function\` (or its aliases \`@func\` or
81
+ \`@method\`) (including those associated with an \`@interface\`).`,
70
82
  items: {
71
83
  anyOf: [{
72
84
  type: 'string'
@@ -86,6 +98,11 @@ var _default = exports.default = (0, _iterateJsdoc.default)(({
86
98
  type: 'array'
87
99
  },
88
100
  exemptedBy: {
101
+ description: `Array of tags (e.g., \`['type']\`) whose presence on the
102
+ document block avoids the need for a \`@throws\`. Defaults to an array
103
+ with \`inheritdoc\`. If you set this array, it will overwrite the default,
104
+ so be sure to add back \`inheritdoc\` if you wish its presence to cause
105
+ exemption of the rule.`,
89
106
  items: {
90
107
  type: 'string'
91
108
  },