@depup/eslint-plugin-jsdoc 62.8.0-depup.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 (430) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +33 -0
  3. package/changes.json +18 -0
  4. package/dist/WarnSettings.cjs +38 -0
  5. package/dist/WarnSettings.cjs.map +1 -0
  6. package/dist/WarnSettings.d.ts +17 -0
  7. package/dist/alignTransform.cjs +402 -0
  8. package/dist/alignTransform.cjs.map +1 -0
  9. package/dist/alignTransform.d.ts +34 -0
  10. package/dist/buildForbidRuleDefinition.cjs +101 -0
  11. package/dist/buildForbidRuleDefinition.cjs.map +1 -0
  12. package/dist/buildForbidRuleDefinition.d.ts +15 -0
  13. package/dist/buildRejectOrPreferRuleDefinition.cjs +352 -0
  14. package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -0
  15. package/dist/buildRejectOrPreferRuleDefinition.d.ts +9 -0
  16. package/dist/cjs/WarnSettings.d.ts +16 -0
  17. package/dist/cjs/alignTransform.d.ts +33 -0
  18. package/dist/cjs/buildForbidRuleDefinition.d.ts +14 -0
  19. package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +8 -0
  20. package/dist/cjs/defaultTagOrder.d.ts +4 -0
  21. package/dist/cjs/exportParser.d.ts +40 -0
  22. package/dist/cjs/getDefaultTagStructureForMode.d.ts +10 -0
  23. package/dist/cjs/getJsdocProcessorPlugin.d.cts +5 -0
  24. package/dist/cjs/getJsdocProcessorPlugin.d.ts +66 -0
  25. package/dist/cjs/index-cjs.d.ts +23 -0
  26. package/dist/cjs/index.cjs.d.cts +2 -0
  27. package/dist/cjs/iterateJsdoc.d.cts +7 -0
  28. package/dist/cjs/iterateJsdoc.d.ts +495 -0
  29. package/dist/cjs/jsdocUtils.d.ts +493 -0
  30. package/dist/cjs/rules/checkAccess.d.ts +2 -0
  31. package/dist/cjs/rules/checkAlignment.d.ts +2 -0
  32. package/dist/cjs/rules/checkExamples.d.ts +3 -0
  33. package/dist/cjs/rules/checkIndentation.d.ts +2 -0
  34. package/dist/cjs/rules/checkLineAlignment.d.ts +9 -0
  35. package/dist/cjs/rules/checkParamNames.d.ts +2 -0
  36. package/dist/cjs/rules/checkPropertyNames.d.ts +2 -0
  37. package/dist/cjs/rules/checkSyntax.d.ts +2 -0
  38. package/dist/cjs/rules/checkTagNames.d.ts +2 -0
  39. package/dist/cjs/rules/checkTemplateNames.d.ts +2 -0
  40. package/dist/cjs/rules/checkTypes.d.ts +7 -0
  41. package/dist/cjs/rules/checkValues.d.ts +2 -0
  42. package/dist/cjs/rules/convertToJsdocComments.d.ts +266 -0
  43. package/dist/cjs/rules/emptyTags.d.ts +2 -0
  44. package/dist/cjs/rules/escapeInlineTags.d.ts +2 -0
  45. package/dist/cjs/rules/implementsOnClasses.d.ts +2 -0
  46. package/dist/cjs/rules/importsAsDependencies.d.ts +2 -0
  47. package/dist/cjs/rules/informativeDocs.d.ts +2 -0
  48. package/dist/cjs/rules/linesBeforeBlock.d.ts +2 -0
  49. package/dist/cjs/rules/matchDescription.d.ts +2 -0
  50. package/dist/cjs/rules/matchName.d.ts +2 -0
  51. package/dist/cjs/rules/multilineBlocks.d.ts +2 -0
  52. package/dist/cjs/rules/noBadBlocks.d.ts +2 -0
  53. package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +2 -0
  54. package/dist/cjs/rules/noBlankBlocks.d.ts +2 -0
  55. package/dist/cjs/rules/noDefaults.d.ts +2 -0
  56. package/dist/cjs/rules/noMissingSyntax.d.ts +9 -0
  57. package/dist/cjs/rules/noMultiAsterisks.d.ts +2 -0
  58. package/dist/cjs/rules/noRestrictedSyntax.d.ts +2 -0
  59. package/dist/cjs/rules/noTypes.d.ts +2 -0
  60. package/dist/cjs/rules/noUndefinedTypes.d.ts +2 -0
  61. package/dist/cjs/rules/preferImportTag.d.ts +2 -0
  62. package/dist/cjs/rules/requireAsteriskPrefix.d.ts +2 -0
  63. package/dist/cjs/rules/requireDescription.d.ts +2 -0
  64. package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +2 -0
  65. package/dist/cjs/rules/requireExample.d.ts +2 -0
  66. package/dist/cjs/rules/requireFileOverview.d.ts +2 -0
  67. package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +2 -0
  68. package/dist/cjs/rules/requireJsdoc.d.ts +24 -0
  69. package/dist/cjs/rules/requireParam.d.ts +3 -0
  70. package/dist/cjs/rules/requireParamDescription.d.ts +2 -0
  71. package/dist/cjs/rules/requireParamName.d.ts +2 -0
  72. package/dist/cjs/rules/requireParamType.d.ts +2 -0
  73. package/dist/cjs/rules/requireProperty.d.ts +2 -0
  74. package/dist/cjs/rules/requirePropertyDescription.d.ts +2 -0
  75. package/dist/cjs/rules/requirePropertyName.d.ts +2 -0
  76. package/dist/cjs/rules/requirePropertyType.d.ts +2 -0
  77. package/dist/cjs/rules/requireRejects.d.ts +2 -0
  78. package/dist/cjs/rules/requireReturns.d.ts +2 -0
  79. package/dist/cjs/rules/requireReturnsCheck.d.ts +2 -0
  80. package/dist/cjs/rules/requireReturnsDescription.d.ts +2 -0
  81. package/dist/cjs/rules/requireReturnsType.d.ts +2 -0
  82. package/dist/cjs/rules/requireTags.d.ts +2 -0
  83. package/dist/cjs/rules/requireTemplate.d.ts +2 -0
  84. package/dist/cjs/rules/requireThrows.d.ts +2 -0
  85. package/dist/cjs/rules/requireYields.d.ts +2 -0
  86. package/dist/cjs/rules/requireYieldsCheck.d.ts +2 -0
  87. package/dist/cjs/rules/sortTags.d.ts +2 -0
  88. package/dist/cjs/rules/tagLines.d.ts +2 -0
  89. package/dist/cjs/rules/textEscaping.d.ts +2 -0
  90. package/dist/cjs/rules/tsMethodSignatureStyle.d.ts +2 -0
  91. package/dist/cjs/rules/tsNoEmptyObjectType.d.ts +2 -0
  92. package/dist/cjs/rules/tsNoUnnecessaryTemplateExpression.d.ts +2 -0
  93. package/dist/cjs/rules/tsPreferFunctionType.d.ts +2 -0
  94. package/dist/cjs/rules/typeFormatting.d.ts +2 -0
  95. package/dist/cjs/rules/validTypes.d.ts +2 -0
  96. package/dist/cjs/tagNames.d.ts +15 -0
  97. package/dist/cjs/utils/hasReturnValue.d.ts +19 -0
  98. package/dist/defaultTagOrder.cjs +46 -0
  99. package/dist/defaultTagOrder.cjs.map +1 -0
  100. package/dist/defaultTagOrder.d.ts +5 -0
  101. package/dist/exportParser.cjs +732 -0
  102. package/dist/exportParser.cjs.map +1 -0
  103. package/dist/exportParser.d.ts +41 -0
  104. package/dist/generateDocs.cjs +342 -0
  105. package/dist/generateDocs.cjs.map +1 -0
  106. package/dist/generateOptions.cjs +62 -0
  107. package/dist/generateOptions.cjs.map +1 -0
  108. package/dist/generateRule.cjs +248 -0
  109. package/dist/generateRule.cjs.map +1 -0
  110. package/dist/generateRuleTypes.cjs +24 -0
  111. package/dist/generateRuleTypes.cjs.map +1 -0
  112. package/dist/getDefaultTagStructureForMode.cjs +289 -0
  113. package/dist/getDefaultTagStructureForMode.cjs.map +1 -0
  114. package/dist/getDefaultTagStructureForMode.d.ts +11 -0
  115. package/dist/getJsdocProcessorPlugin.cjs +587 -0
  116. package/dist/getJsdocProcessorPlugin.cjs.map +1 -0
  117. package/dist/getJsdocProcessorPlugin.cts +5 -0
  118. package/dist/getJsdocProcessorPlugin.d.ts +67 -0
  119. package/dist/index-cjs.cjs +595 -0
  120. package/dist/index-cjs.cjs.map +1 -0
  121. package/dist/index-cjs.d.ts +24 -0
  122. package/dist/index-esm.cjs +162 -0
  123. package/dist/index-esm.cjs.map +1 -0
  124. package/dist/index-esm.d.ts +72 -0
  125. package/dist/index.cjs +743 -0
  126. package/dist/index.cjs.cts +3 -0
  127. package/dist/index.cjs.map +1 -0
  128. package/dist/index.d.ts +93 -0
  129. package/dist/iterateJsdoc.cjs +2150 -0
  130. package/dist/iterateJsdoc.cjs.map +1 -0
  131. package/dist/iterateJsdoc.cts +7 -0
  132. package/dist/iterateJsdoc.d.ts +496 -0
  133. package/dist/jsdocUtils.cjs +1725 -0
  134. package/dist/jsdocUtils.cjs.map +1 -0
  135. package/dist/jsdocUtils.d.ts +494 -0
  136. package/dist/rules/checkAccess.cjs +40 -0
  137. package/dist/rules/checkAccess.cjs.map +1 -0
  138. package/dist/rules/checkAccess.d.ts +3 -0
  139. package/dist/rules/checkAlignment.cjs +78 -0
  140. package/dist/rules/checkAlignment.cjs.map +1 -0
  141. package/dist/rules/checkAlignment.d.ts +3 -0
  142. package/dist/rules/checkExamples.cjs +521 -0
  143. package/dist/rules/checkExamples.cjs.map +1 -0
  144. package/dist/rules/checkExamples.d.ts +4 -0
  145. package/dist/rules/checkIndentation.cjs +170 -0
  146. package/dist/rules/checkIndentation.cjs.map +1 -0
  147. package/dist/rules/checkIndentation.d.ts +3 -0
  148. package/dist/rules/checkLineAlignment.cjs +398 -0
  149. package/dist/rules/checkLineAlignment.cjs.map +1 -0
  150. package/dist/rules/checkLineAlignment.d.ts +10 -0
  151. package/dist/rules/checkParamNames.cjs +407 -0
  152. package/dist/rules/checkParamNames.cjs.map +1 -0
  153. package/dist/rules/checkParamNames.d.ts +3 -0
  154. package/dist/rules/checkPropertyNames.cjs +135 -0
  155. package/dist/rules/checkPropertyNames.cjs.map +1 -0
  156. package/dist/rules/checkPropertyNames.d.ts +3 -0
  157. package/dist/rules/checkSyntax.cjs +38 -0
  158. package/dist/rules/checkSyntax.cjs.map +1 -0
  159. package/dist/rules/checkSyntax.d.ts +3 -0
  160. package/dist/rules/checkTagNames.cjs +312 -0
  161. package/dist/rules/checkTagNames.cjs.map +1 -0
  162. package/dist/rules/checkTagNames.d.ts +3 -0
  163. package/dist/rules/checkTemplateNames.cjs +185 -0
  164. package/dist/rules/checkTemplateNames.cjs.map +1 -0
  165. package/dist/rules/checkTemplateNames.d.ts +3 -0
  166. package/dist/rules/checkTypes.cjs +111 -0
  167. package/dist/rules/checkTypes.cjs.map +1 -0
  168. package/dist/rules/checkTypes.d.ts +8 -0
  169. package/dist/rules/checkValues.cjs +166 -0
  170. package/dist/rules/checkValues.cjs.map +1 -0
  171. package/dist/rules/checkValues.d.ts +3 -0
  172. package/dist/rules/convertToJsdocComments.cjs +356 -0
  173. package/dist/rules/convertToJsdocComments.cjs.map +1 -0
  174. package/dist/rules/convertToJsdocComments.d.ts +267 -0
  175. package/dist/rules/emptyTags.cjs +85 -0
  176. package/dist/rules/emptyTags.cjs.map +1 -0
  177. package/dist/rules/emptyTags.d.ts +3 -0
  178. package/dist/rules/escapeInlineTags.cjs +149 -0
  179. package/dist/rules/escapeInlineTags.cjs.map +1 -0
  180. package/dist/rules/escapeInlineTags.d.ts +3 -0
  181. package/dist/rules/implementsOnClasses.cjs +74 -0
  182. package/dist/rules/implementsOnClasses.cjs.map +1 -0
  183. package/dist/rules/implementsOnClasses.d.ts +3 -0
  184. package/dist/rules/importsAsDependencies.cjs +104 -0
  185. package/dist/rules/importsAsDependencies.cjs.map +1 -0
  186. package/dist/rules/importsAsDependencies.d.ts +3 -0
  187. package/dist/rules/informativeDocs.cjs +187 -0
  188. package/dist/rules/informativeDocs.cjs.map +1 -0
  189. package/dist/rules/informativeDocs.d.ts +3 -0
  190. package/dist/rules/linesBeforeBlock.cjs +120 -0
  191. package/dist/rules/linesBeforeBlock.cjs.map +1 -0
  192. package/dist/rules/linesBeforeBlock.d.ts +3 -0
  193. package/dist/rules/matchDescription.cjs +356 -0
  194. package/dist/rules/matchDescription.cjs.map +1 -0
  195. package/dist/rules/matchDescription.d.ts +3 -0
  196. package/dist/rules/matchName.cjs +160 -0
  197. package/dist/rules/matchName.cjs.map +1 -0
  198. package/dist/rules/matchName.d.ts +3 -0
  199. package/dist/rules/multilineBlocks.cjs +431 -0
  200. package/dist/rules/multilineBlocks.cjs.map +1 -0
  201. package/dist/rules/multilineBlocks.d.ts +3 -0
  202. package/dist/rules/noBadBlocks.cjs +100 -0
  203. package/dist/rules/noBadBlocks.cjs.map +1 -0
  204. package/dist/rules/noBadBlocks.d.ts +3 -0
  205. package/dist/rules/noBlankBlockDescriptions.cjs +63 -0
  206. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -0
  207. package/dist/rules/noBlankBlockDescriptions.d.ts +3 -0
  208. package/dist/rules/noBlankBlocks.cjs +54 -0
  209. package/dist/rules/noBlankBlocks.cjs.map +1 -0
  210. package/dist/rules/noBlankBlocks.d.ts +3 -0
  211. package/dist/rules/noDefaults.cjs +102 -0
  212. package/dist/rules/noDefaults.cjs.map +1 -0
  213. package/dist/rules/noDefaults.d.ts +3 -0
  214. package/dist/rules/noMissingSyntax.cjs +196 -0
  215. package/dist/rules/noMissingSyntax.cjs.map +1 -0
  216. package/dist/rules/noMissingSyntax.d.ts +10 -0
  217. package/dist/rules/noMultiAsterisks.cjs +126 -0
  218. package/dist/rules/noMultiAsterisks.cjs.map +1 -0
  219. package/dist/rules/noMultiAsterisks.d.ts +3 -0
  220. package/dist/rules/noRestrictedSyntax.cjs +68 -0
  221. package/dist/rules/noRestrictedSyntax.cjs.map +1 -0
  222. package/dist/rules/noRestrictedSyntax.d.ts +3 -0
  223. package/dist/rules/noTypes.cjs +101 -0
  224. package/dist/rules/noTypes.cjs.map +1 -0
  225. package/dist/rules/noTypes.d.ts +3 -0
  226. package/dist/rules/noUndefinedTypes.cjs +588 -0
  227. package/dist/rules/noUndefinedTypes.cjs.map +1 -0
  228. package/dist/rules/noUndefinedTypes.d.ts +3 -0
  229. package/dist/rules/preferImportTag.cjs +362 -0
  230. package/dist/rules/preferImportTag.cjs.map +1 -0
  231. package/dist/rules/preferImportTag.d.ts +3 -0
  232. package/dist/rules/requireAsteriskPrefix.cjs +190 -0
  233. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -0
  234. package/dist/rules/requireAsteriskPrefix.d.ts +3 -0
  235. package/dist/rules/requireDescription.cjs +164 -0
  236. package/dist/rules/requireDescription.cjs.map +1 -0
  237. package/dist/rules/requireDescription.d.ts +3 -0
  238. package/dist/rules/requireDescriptionCompleteSentence.cjs +321 -0
  239. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -0
  240. package/dist/rules/requireDescriptionCompleteSentence.d.ts +3 -0
  241. package/dist/rules/requireExample.cjs +133 -0
  242. package/dist/rules/requireExample.cjs.map +1 -0
  243. package/dist/rules/requireExample.d.ts +3 -0
  244. package/dist/rules/requireFileOverview.cjs +194 -0
  245. package/dist/rules/requireFileOverview.cjs.map +1 -0
  246. package/dist/rules/requireFileOverview.d.ts +3 -0
  247. package/dist/rules/requireHyphenBeforeParamDescription.cjs +166 -0
  248. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -0
  249. package/dist/rules/requireHyphenBeforeParamDescription.d.ts +3 -0
  250. package/dist/rules/requireJsdoc.cjs +722 -0
  251. package/dist/rules/requireJsdoc.cjs.map +1 -0
  252. package/dist/rules/requireJsdoc.d.ts +25 -0
  253. package/dist/rules/requireParam.cjs +772 -0
  254. package/dist/rules/requireParam.cjs.map +1 -0
  255. package/dist/rules/requireParam.d.ts +4 -0
  256. package/dist/rules/requireParamDescription.cjs +105 -0
  257. package/dist/rules/requireParamDescription.cjs.map +1 -0
  258. package/dist/rules/requireParamDescription.d.ts +3 -0
  259. package/dist/rules/requireParamName.cjs +68 -0
  260. package/dist/rules/requireParamName.cjs.map +1 -0
  261. package/dist/rules/requireParamName.d.ts +3 -0
  262. package/dist/rules/requireParamType.cjs +104 -0
  263. package/dist/rules/requireParamType.cjs.map +1 -0
  264. package/dist/rules/requireParamType.d.ts +3 -0
  265. package/dist/rules/requireProperty.cjs +63 -0
  266. package/dist/rules/requireProperty.cjs.map +1 -0
  267. package/dist/rules/requireProperty.d.ts +3 -0
  268. package/dist/rules/requirePropertyDescription.cjs +29 -0
  269. package/dist/rules/requirePropertyDescription.cjs.map +1 -0
  270. package/dist/rules/requirePropertyDescription.d.ts +3 -0
  271. package/dist/rules/requirePropertyName.cjs +29 -0
  272. package/dist/rules/requirePropertyName.cjs.map +1 -0
  273. package/dist/rules/requirePropertyName.d.ts +3 -0
  274. package/dist/rules/requirePropertyType.cjs +29 -0
  275. package/dist/rules/requirePropertyType.cjs.map +1 -0
  276. package/dist/rules/requirePropertyType.d.ts +3 -0
  277. package/dist/rules/requireRejects.cjs +226 -0
  278. package/dist/rules/requireRejects.cjs.map +1 -0
  279. package/dist/rules/requireRejects.d.ts +3 -0
  280. package/dist/rules/requireReturns.cjs +262 -0
  281. package/dist/rules/requireReturns.cjs.map +1 -0
  282. package/dist/rules/requireReturns.d.ts +3 -0
  283. package/dist/rules/requireReturnsCheck.cjs +140 -0
  284. package/dist/rules/requireReturnsCheck.cjs.map +1 -0
  285. package/dist/rules/requireReturnsCheck.d.ts +3 -0
  286. package/dist/rules/requireReturnsDescription.cjs +72 -0
  287. package/dist/rules/requireReturnsDescription.cjs.map +1 -0
  288. package/dist/rules/requireReturnsDescription.d.ts +3 -0
  289. package/dist/rules/requireReturnsType.cjs +68 -0
  290. package/dist/rules/requireReturnsType.cjs.map +1 -0
  291. package/dist/rules/requireReturnsType.d.ts +3 -0
  292. package/dist/rules/requireTags.cjs +74 -0
  293. package/dist/rules/requireTags.cjs.map +1 -0
  294. package/dist/rules/requireTags.d.ts +3 -0
  295. package/dist/rules/requireTemplate.cjs +220 -0
  296. package/dist/rules/requireTemplate.cjs.map +1 -0
  297. package/dist/rules/requireTemplate.d.ts +3 -0
  298. package/dist/rules/requireThrows.cjs +118 -0
  299. package/dist/rules/requireThrows.cjs.map +1 -0
  300. package/dist/rules/requireThrows.d.ts +3 -0
  301. package/dist/rules/requireYields.cjs +224 -0
  302. package/dist/rules/requireYields.cjs.map +1 -0
  303. package/dist/rules/requireYields.d.ts +3 -0
  304. package/dist/rules/requireYieldsCheck.cjs +179 -0
  305. package/dist/rules/requireYieldsCheck.cjs.map +1 -0
  306. package/dist/rules/requireYieldsCheck.d.ts +3 -0
  307. package/dist/rules/sortTags.cjs +656 -0
  308. package/dist/rules/sortTags.cjs.map +1 -0
  309. package/dist/rules/sortTags.d.ts +3 -0
  310. package/dist/rules/tagLines.cjs +374 -0
  311. package/dist/rules/tagLines.cjs.map +1 -0
  312. package/dist/rules/tagLines.d.ts +3 -0
  313. package/dist/rules/textEscaping.cjs +141 -0
  314. package/dist/rules/textEscaping.cjs.map +1 -0
  315. package/dist/rules/textEscaping.d.ts +3 -0
  316. package/dist/rules/tsMethodSignatureStyle.cjs +240 -0
  317. package/dist/rules/tsMethodSignatureStyle.cjs.map +1 -0
  318. package/dist/rules/tsMethodSignatureStyle.d.ts +3 -0
  319. package/dist/rules/tsNoEmptyObjectType.cjs +62 -0
  320. package/dist/rules/tsNoEmptyObjectType.cjs.map +1 -0
  321. package/dist/rules/tsNoEmptyObjectType.d.ts +3 -0
  322. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +104 -0
  323. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +1 -0
  324. package/dist/rules/tsNoUnnecessaryTemplateExpression.d.ts +3 -0
  325. package/dist/rules/tsPreferFunctionType.cjs +110 -0
  326. package/dist/rules/tsPreferFunctionType.cjs.map +1 -0
  327. package/dist/rules/tsPreferFunctionType.d.ts +3 -0
  328. package/dist/rules/typeFormatting.cjs +607 -0
  329. package/dist/rules/typeFormatting.cjs.map +1 -0
  330. package/dist/rules/typeFormatting.d.ts +3 -0
  331. package/dist/rules/validTypes.cjs +328 -0
  332. package/dist/rules/validTypes.cjs.map +1 -0
  333. package/dist/rules/validTypes.d.ts +3 -0
  334. package/dist/rules.d.ts +3203 -0
  335. package/dist/tagNames.cjs +244 -0
  336. package/dist/tagNames.cjs.map +1 -0
  337. package/dist/tagNames.d.ts +16 -0
  338. package/dist/to-valid-identifier.cjs +263 -0
  339. package/dist/utils/hasReturnValue.cjs +495 -0
  340. package/dist/utils/hasReturnValue.cjs.map +1 -0
  341. package/dist/utils/hasReturnValue.d.ts +20 -0
  342. package/package.json +220 -0
  343. package/rollup.config.js +16 -0
  344. package/src/WarnSettings.js +34 -0
  345. package/src/alignTransform.js +444 -0
  346. package/src/buildForbidRuleDefinition.js +106 -0
  347. package/src/buildRejectOrPreferRuleDefinition.js +481 -0
  348. package/src/defaultTagOrder.js +169 -0
  349. package/src/exportParser.js +973 -0
  350. package/src/getDefaultTagStructureForMode.js +968 -0
  351. package/src/getJsdocProcessorPlugin.cts +5 -0
  352. package/src/getJsdocProcessorPlugin.js +692 -0
  353. package/src/index-cjs.js +755 -0
  354. package/src/index-esm.js +196 -0
  355. package/src/index.cjs.cts +3 -0
  356. package/src/index.js +940 -0
  357. package/src/iterateJsdoc.cts +7 -0
  358. package/src/iterateJsdoc.js +2612 -0
  359. package/src/jsdocUtils.js +2158 -0
  360. package/src/rules/checkAccess.js +45 -0
  361. package/src/rules/checkAlignment.js +82 -0
  362. package/src/rules/checkExamples.js +613 -0
  363. package/src/rules/checkIndentation.js +176 -0
  364. package/src/rules/checkLineAlignment.js +453 -0
  365. package/src/rules/checkParamNames.js +541 -0
  366. package/src/rules/checkPropertyNames.js +174 -0
  367. package/src/rules/checkSyntax.js +30 -0
  368. package/src/rules/checkTagNames.js +414 -0
  369. package/src/rules/checkTemplateNames.js +208 -0
  370. package/src/rules/checkTypes.js +130 -0
  371. package/src/rules/checkValues.js +264 -0
  372. package/src/rules/convertToJsdocComments.js +444 -0
  373. package/src/rules/emptyTags.js +106 -0
  374. package/src/rules/escapeInlineTags.js +189 -0
  375. package/src/rules/implementsOnClasses.js +78 -0
  376. package/src/rules/importsAsDependencies.js +132 -0
  377. package/src/rules/informativeDocs.js +228 -0
  378. package/src/rules/linesBeforeBlock.js +144 -0
  379. package/src/rules/matchDescription.js +413 -0
  380. package/src/rules/matchName.js +179 -0
  381. package/src/rules/multilineBlocks.js +562 -0
  382. package/src/rules/noBadBlocks.js +127 -0
  383. package/src/rules/noBlankBlockDescriptions.js +69 -0
  384. package/src/rules/noBlankBlocks.js +55 -0
  385. package/src/rules/noDefaults.js +104 -0
  386. package/src/rules/noMissingSyntax.js +215 -0
  387. package/src/rules/noMultiAsterisks.js +162 -0
  388. package/src/rules/noRestrictedSyntax.js +72 -0
  389. package/src/rules/noTypes.js +108 -0
  390. package/src/rules/noUndefinedTypes.js +797 -0
  391. package/src/rules/preferImportTag.js +521 -0
  392. package/src/rules/requireAsteriskPrefix.js +217 -0
  393. package/src/rules/requireDescription.js +190 -0
  394. package/src/rules/requireDescriptionCompleteSentence.js +376 -0
  395. package/src/rules/requireExample.js +143 -0
  396. package/src/rules/requireFileOverview.js +213 -0
  397. package/src/rules/requireHyphenBeforeParamDescription.js +210 -0
  398. package/src/rules/requireJsdoc.js +897 -0
  399. package/src/rules/requireParam.js +848 -0
  400. package/src/rules/requireParamDescription.js +110 -0
  401. package/src/rules/requireParamName.js +69 -0
  402. package/src/rules/requireParamType.js +109 -0
  403. package/src/rules/requireProperty.js +66 -0
  404. package/src/rules/requirePropertyDescription.js +25 -0
  405. package/src/rules/requirePropertyName.js +25 -0
  406. package/src/rules/requirePropertyType.js +25 -0
  407. package/src/rules/requireRejects.js +246 -0
  408. package/src/rules/requireReturns.js +291 -0
  409. package/src/rules/requireReturnsCheck.js +180 -0
  410. package/src/rules/requireReturnsDescription.js +73 -0
  411. package/src/rules/requireReturnsType.js +65 -0
  412. package/src/rules/requireTags.js +85 -0
  413. package/src/rules/requireTemplate.js +246 -0
  414. package/src/rules/requireThrows.js +128 -0
  415. package/src/rules/requireYields.js +265 -0
  416. package/src/rules/requireYieldsCheck.js +226 -0
  417. package/src/rules/sortTags.js +766 -0
  418. package/src/rules/tagLines.js +486 -0
  419. package/src/rules/textEscaping.js +158 -0
  420. package/src/rules/tsMethodSignatureStyle.js +300 -0
  421. package/src/rules/tsNoEmptyObjectType.js +61 -0
  422. package/src/rules/tsNoUnnecessaryTemplateExpression.js +130 -0
  423. package/src/rules/tsPreferFunctionType.js +127 -0
  424. package/src/rules/typeFormatting.js +690 -0
  425. package/src/rules/validTypes.js +466 -0
  426. package/src/rules.d.ts +3203 -0
  427. package/src/tagNames.js +301 -0
  428. package/src/utils/hasReturnValue.js +572 -0
  429. package/typings/babel__eslint-parser.d.ts +1 -0
  430. package/typings/gitdown.d.ts +16 -0
@@ -0,0 +1,897 @@
1
+ import exportParser from '../exportParser.js';
2
+ import {
3
+ getSettings,
4
+ } from '../iterateJsdoc.js';
5
+ import {
6
+ enforcedContexts,
7
+ exemptSpeciaMethods,
8
+ getContextObject,
9
+ getFunctionParameterNames,
10
+ getIndent,
11
+ hasReturnValue,
12
+ isConstructor,
13
+ } from '../jsdocUtils.js';
14
+ import {
15
+ getDecorator,
16
+ getJSDocComment,
17
+ getReducedASTNode,
18
+ } from '@es-joy/jsdoccomment';
19
+
20
+ /**
21
+ * @typedef {{
22
+ * ancestorsOnly: boolean,
23
+ * esm: boolean,
24
+ * initModuleExports: boolean,
25
+ * initWindow: boolean
26
+ * }} RequireJsdocOpts
27
+ */
28
+
29
+ /**
30
+ * @typedef {import('eslint').Rule.Node|
31
+ * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
32
+ */
33
+
34
+ /** @type {import('json-schema').JSONSchema4} */
35
+ const OPTIONS_SCHEMA = {
36
+ additionalProperties: false,
37
+ description: 'Has the following optional keys.\n',
38
+ properties: {
39
+ checkAllFunctionExpressions: {
40
+ default: false,
41
+ description: `Normally, when \`FunctionExpression\` is checked, additional checks are
42
+ added to check the parent contexts where reporting is likely to be desired. If you really
43
+ want to check *all* function expressions, then set this to \`true\`.`,
44
+ type: 'boolean',
45
+ },
46
+ checkConstructors: {
47
+ default: true,
48
+ description: `A value indicating whether \`constructor\`s should be checked. Defaults to
49
+ \`true\`. When \`true\`, \`exemptEmptyConstructors\` may still avoid reporting when
50
+ no parameters or return values are found.`,
51
+ type: 'boolean',
52
+ },
53
+ checkGetters: {
54
+ anyOf: [
55
+ {
56
+ type: 'boolean',
57
+ },
58
+ {
59
+ enum: [
60
+ 'no-setter',
61
+ ],
62
+ type: 'string',
63
+ },
64
+ ],
65
+ default: true,
66
+ description: `A value indicating whether getters should be checked. Besides setting as a
67
+ boolean, this option can be set to the string \`"no-setter"\` to indicate that
68
+ getters should be checked but only when there is no setter. This may be useful
69
+ if one only wishes documentation on one of the two accessors. Defaults to
70
+ \`false\`.`,
71
+ },
72
+ checkSetters: {
73
+ anyOf: [
74
+ {
75
+ type: 'boolean',
76
+ },
77
+ {
78
+ enum: [
79
+ 'no-getter',
80
+ ],
81
+ type: 'string',
82
+ },
83
+ ],
84
+ default: true,
85
+ description: `A value indicating whether setters should be checked. Besides setting as a
86
+ boolean, this option can be set to the string \`"no-getter"\` to indicate that
87
+ setters should be checked but only when there is no getter. This may be useful
88
+ if one only wishes documentation on one of the two accessors. Defaults to
89
+ \`false\`.`,
90
+ },
91
+ contexts: {
92
+ description: `Set this to an array of strings or objects representing the additional AST
93
+ contexts where you wish the rule to be applied (e.g., \`Property\` for
94
+ properties). If specified as an object, it should have a \`context\` property
95
+ and can have an \`inlineCommentBlock\` property which, if set to \`true\`, will
96
+ add an inline \`/** */\` instead of the regular, multi-line, indented jsdoc
97
+ block which will otherwise be added. Defaults to an empty array. Contexts
98
+ may also have their own \`minLineCount\` property which is an integer
99
+ indicating a minimum number of lines expected for a node in order
100
+ for it to require documentation.
101
+
102
+ Note that you may need to disable \`require\` items (e.g., \`MethodDefinition\`)
103
+ if you are specifying a more precise form in \`contexts\` (e.g., \`MethodDefinition:not([accessibility="private"] > FunctionExpression\`).
104
+
105
+ See the ["AST and Selectors"](../#advanced-ast-and-selectors)
106
+ section of our Advanced docs for more on the expected format.`,
107
+ items: {
108
+ anyOf: [
109
+ {
110
+ type: 'string',
111
+ },
112
+ {
113
+ additionalProperties: false,
114
+ properties: {
115
+ context: {
116
+ type: 'string',
117
+ },
118
+ inlineCommentBlock: {
119
+ type: 'boolean',
120
+ },
121
+ minLineCount: {
122
+ type: 'integer',
123
+ },
124
+ },
125
+ type: 'object',
126
+ },
127
+ ],
128
+ },
129
+ type: 'array',
130
+ },
131
+ enableFixer: {
132
+ default: true,
133
+ description: `A boolean on whether to enable the fixer (which adds an empty JSDoc block).
134
+ Defaults to \`true\`.`,
135
+ type: 'boolean',
136
+ },
137
+ exemptEmptyConstructors: {
138
+ default: false,
139
+ description: `When \`true\`, the rule will not report missing JSDoc blocks above constructors
140
+ with no parameters or return values (this is enabled by default as the class
141
+ name or description should be seen as sufficient to convey intent).
142
+
143
+ Defaults to \`true\`.`,
144
+ type: 'boolean',
145
+ },
146
+ exemptEmptyFunctions: {
147
+ default: false,
148
+ description: `When \`true\`, the rule will not report missing JSDoc blocks above
149
+ functions/methods with no parameters or return values (intended where
150
+ function/method names are sufficient for themselves as documentation).
151
+
152
+ Defaults to \`false\`.`,
153
+ type: 'boolean',
154
+ },
155
+ exemptOverloadedImplementations: {
156
+ default: false,
157
+ description: `If set to \`true\` will avoid checking an overloaded function's implementation.
158
+
159
+ Defaults to \`false\`.`,
160
+ type: 'boolean',
161
+ },
162
+ fixerMessage: {
163
+ default: '',
164
+ description: `An optional message to add to the inserted JSDoc block. Defaults to the
165
+ empty string.`,
166
+ type: 'string',
167
+ },
168
+ minLineCount: {
169
+ description: `An integer to indicate a minimum number of lines expected for a node in order
170
+ for it to require documentation. Defaults to \`undefined\`. This option will
171
+ apply to any context; see \`contexts\` for line counts specific to a context.`,
172
+ type: 'integer',
173
+ },
174
+ publicOnly: {
175
+ description: `This option will insist that missing JSDoc blocks are only reported for
176
+ function bodies / class declarations that are exported from the module.
177
+ May be a boolean or object. If set to \`true\`, the defaults below will be
178
+ used. If unset, JSDoc block reporting will not be limited to exports.
179
+
180
+ This object supports the following optional boolean keys (\`false\` unless
181
+ otherwise noted):
182
+
183
+ - \`ancestorsOnly\` - Optimization to only check node ancestors to check if node is exported
184
+ - \`esm\` - ESM exports are checked for JSDoc comments (Defaults to \`true\`)
185
+ - \`cjs\` - CommonJS exports are checked for JSDoc comments (Defaults to \`true\`)
186
+ - \`window\` - Window global exports are checked for JSDoc comments`,
187
+ oneOf: [
188
+ {
189
+ default: false,
190
+ type: 'boolean',
191
+ },
192
+ {
193
+ additionalProperties: false,
194
+ default: {},
195
+ properties: {
196
+ ancestorsOnly: {
197
+ type: 'boolean',
198
+ },
199
+ cjs: {
200
+ type: 'boolean',
201
+ },
202
+ esm: {
203
+ type: 'boolean',
204
+ },
205
+ window: {
206
+ type: 'boolean',
207
+ },
208
+ },
209
+ type: 'object',
210
+ },
211
+ ],
212
+ },
213
+ require: {
214
+ additionalProperties: false,
215
+ default: {},
216
+ description: `An object with the following optional boolean keys which all default to
217
+ \`false\` except for \`FunctionDeclaration\` which defaults to \`true\`.`,
218
+ properties: {
219
+ ArrowFunctionExpression: {
220
+ default: false,
221
+ description: 'Whether to check arrow functions like `() => {}`',
222
+ type: 'boolean',
223
+ },
224
+ ClassDeclaration: {
225
+ default: false,
226
+ description: 'Whether to check declarations like `class A {}`',
227
+ type: 'boolean',
228
+ },
229
+ ClassExpression: {
230
+ default: false,
231
+ description: 'Whether to check class expressions like `const myClass = class {}`',
232
+ type: 'boolean',
233
+ },
234
+ FunctionDeclaration: {
235
+ default: true,
236
+ description: 'Whether to check function declarations like `function a {}`',
237
+ type: 'boolean',
238
+ },
239
+ FunctionExpression: {
240
+ default: false,
241
+ description: 'Whether to check function expressions like `const a = function {}`',
242
+ type: 'boolean',
243
+ },
244
+ MethodDefinition: {
245
+ default: false,
246
+ description: 'Whether to check method definitions like `class A { someMethodDefinition () {} }`',
247
+ type: 'boolean',
248
+ },
249
+ },
250
+ type: 'object',
251
+ },
252
+ skipInterveningOverloadedDeclarations: {
253
+ default: true,
254
+ description: `If \`true\`, will skip above uncommented overloaded functions to check
255
+ for a comment block (e.g., at the top of a set of overloaded functions).
256
+
257
+ If \`false\`, will force each overloaded function to be checked for a
258
+ comment block.
259
+
260
+ Defaults to \`true\`.`,
261
+ type: 'boolean',
262
+ },
263
+ },
264
+ type: 'object',
265
+ };
266
+
267
+ /**
268
+ * @param {string} interfaceName
269
+ * @param {string} methodName
270
+ * @param {import("eslint").Scope.Scope | null} scope
271
+ * @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
272
+ */
273
+ const getMethodOnInterface = (interfaceName, methodName, scope) => {
274
+ let scp = scope;
275
+ while (scp) {
276
+ for (const {
277
+ identifiers,
278
+ name,
279
+ } of scp.variables) {
280
+ if (interfaceName !== name) {
281
+ continue;
282
+ }
283
+
284
+ for (const identifier of identifiers) {
285
+ const interfaceDeclaration = /** @type {import('@typescript-eslint/types').TSESTree.Identifier & {parent: import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration}} */ (
286
+ identifier
287
+ ).parent;
288
+ /* c8 ignore next 3 -- TS */
289
+ if (interfaceDeclaration.type !== 'TSInterfaceDeclaration') {
290
+ continue;
291
+ }
292
+
293
+ for (const bodyItem of interfaceDeclaration.body.body) {
294
+ const methodSig = /** @type {import('@typescript-eslint/types').TSESTree.TSMethodSignature} */ (
295
+ bodyItem
296
+ );
297
+ if (methodName === /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
298
+ methodSig.key
299
+ ).name) {
300
+ return methodSig;
301
+ }
302
+ }
303
+ }
304
+ }
305
+
306
+ scp = scp.upper;
307
+ }
308
+
309
+ return null;
310
+ };
311
+
312
+ /**
313
+ * @param {import('eslint').Rule.Node} node
314
+ * @param {import('eslint').SourceCode} sourceCode
315
+ * @param {import('eslint').Rule.RuleContext} context
316
+ * @param {import('../iterateJsdoc.js').Settings} settings
317
+ */
318
+ const isExemptedImplementer = (node, sourceCode, context, settings) => {
319
+ if (node.type === 'FunctionExpression' &&
320
+ node.parent.type === 'MethodDefinition' &&
321
+ node.parent.parent.type === 'ClassBody' &&
322
+ node.parent.parent.parent.type === 'ClassDeclaration' &&
323
+ 'implements' in node.parent.parent.parent
324
+ ) {
325
+ const implments = /** @type {import('@typescript-eslint/types').TSESTree.TSClassImplements[]} */ (
326
+ node.parent.parent.parent.implements
327
+ );
328
+
329
+ const {
330
+ name: methodName,
331
+ } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
332
+ node.parent.key
333
+ );
334
+
335
+ for (const impl of implments) {
336
+ const {
337
+ name: interfaceName,
338
+ } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
339
+ impl.expression
340
+ );
341
+
342
+ const interfaceMethodNode = getMethodOnInterface(interfaceName, methodName, node && (
343
+ (sourceCode.getScope &&
344
+ /* c8 ignore next 3 */
345
+ sourceCode.getScope(node)) ||
346
+ // @ts-expect-error ESLint 8
347
+ context.getScope()
348
+ ));
349
+ if (interfaceMethodNode) {
350
+ // @ts-expect-error Ok
351
+ const comment = getJSDocComment(sourceCode, interfaceMethodNode, settings);
352
+ if (comment) {
353
+ return true;
354
+ }
355
+ }
356
+ }
357
+ }
358
+
359
+ return false;
360
+ };
361
+
362
+ /**
363
+ * @param {import('eslint').Rule.RuleContext} context
364
+ * @param {import('json-schema').JSONSchema4Object} baseObject
365
+ * @param {string} option
366
+ * @param {string} key
367
+ * @returns {boolean|undefined}
368
+ */
369
+ const getOption = (context, baseObject, option, key) => {
370
+ if (context.options[0] && option in context.options[0] &&
371
+ // Todo: boolean shouldn't be returning property, but
372
+ // tests currently require
373
+ (typeof context.options[0][option] === 'boolean' ||
374
+ key in context.options[0][option])
375
+ ) {
376
+ return context.options[0][option][key];
377
+ }
378
+
379
+ return /** @type {{[key: string]: {default?: boolean|undefined}}} */ (
380
+ baseObject.properties
381
+ )[key].default;
382
+ };
383
+
384
+ /**
385
+ * @param {import('eslint').Rule.RuleContext} context
386
+ * @param {import('../iterateJsdoc.js').Settings} settings
387
+ * @returns {{
388
+ * checkAllFunctionExpressions: boolean,
389
+ * contexts: (string|{
390
+ * context: string,
391
+ * inlineCommentBlock: boolean,
392
+ * minLineCount: import('../iterateJsdoc.js').Integer
393
+ * })[],
394
+ * enableFixer: boolean,
395
+ * exemptEmptyConstructors: boolean,
396
+ * exemptEmptyFunctions: boolean,
397
+ * skipInterveningOverloadedDeclarations: boolean,
398
+ * exemptOverloadedImplementations: boolean,
399
+ * fixerMessage: string,
400
+ * minLineCount: undefined|import('../iterateJsdoc.js').Integer,
401
+ * publicOnly: boolean|{[key: string]: boolean|undefined}
402
+ * require: {[key: string]: boolean|undefined}
403
+ * }}
404
+ */
405
+ const getOptions = (context, settings) => {
406
+ const {
407
+ checkAllFunctionExpressions = false,
408
+ contexts = settings.contexts || [],
409
+ enableFixer = true,
410
+ exemptEmptyConstructors = true,
411
+ exemptEmptyFunctions = false,
412
+ exemptOverloadedImplementations = false,
413
+ fixerMessage = '',
414
+ minLineCount = undefined,
415
+ publicOnly,
416
+ skipInterveningOverloadedDeclarations = true,
417
+ } = context.options[0] || {};
418
+
419
+ return {
420
+ checkAllFunctionExpressions,
421
+ contexts,
422
+ enableFixer,
423
+ exemptEmptyConstructors,
424
+ exemptEmptyFunctions,
425
+ exemptOverloadedImplementations,
426
+ fixerMessage,
427
+ minLineCount,
428
+ publicOnly: ((baseObj) => {
429
+ if (!publicOnly) {
430
+ return false;
431
+ }
432
+
433
+ /** @type {{[key: string]: boolean|undefined}} */
434
+ const properties = {};
435
+ for (const prop of Object.keys(
436
+ /** @type {import('json-schema').JSONSchema4Object} */ (
437
+ /** @type {import('json-schema').JSONSchema4Object} */ (
438
+ baseObj
439
+ ).properties),
440
+ )) {
441
+ const opt = getOption(
442
+ context,
443
+ /** @type {import('json-schema').JSONSchema4Object} */ (baseObj),
444
+ 'publicOnly',
445
+ prop,
446
+ );
447
+
448
+ properties[prop] = opt;
449
+ }
450
+
451
+ return properties;
452
+ })(
453
+ /** @type {import('json-schema').JSONSchema4Object} */
454
+ (
455
+ /** @type {import('json-schema').JSONSchema4Object} */
456
+ (
457
+ /** @type {import('json-schema').JSONSchema4Object} */
458
+ (
459
+ OPTIONS_SCHEMA.properties
460
+ ).publicOnly
461
+ ).oneOf
462
+ )[1],
463
+ ),
464
+ require: ((baseObj) => {
465
+ /** @type {{[key: string]: boolean|undefined}} */
466
+ const properties = {};
467
+ for (const prop of Object.keys(
468
+ /** @type {import('json-schema').JSONSchema4Object} */ (
469
+ /** @type {import('json-schema').JSONSchema4Object} */ (
470
+ baseObj
471
+ ).properties),
472
+ )) {
473
+ const opt = getOption(
474
+ context,
475
+ /** @type {import('json-schema').JSONSchema4Object} */
476
+ (baseObj),
477
+ 'require',
478
+ prop,
479
+ );
480
+ properties[prop] = opt;
481
+ }
482
+
483
+ return properties;
484
+ })(
485
+ /** @type {import('json-schema').JSONSchema4Object} */
486
+ (OPTIONS_SCHEMA.properties).require,
487
+ ),
488
+ skipInterveningOverloadedDeclarations,
489
+ };
490
+ };
491
+
492
+ /**
493
+ * @param {ESLintOrTSNode} node
494
+ */
495
+ const isFunctionWithOverload = (node) => {
496
+ if (node.type !== 'FunctionDeclaration') {
497
+ return false;
498
+ }
499
+
500
+ let parent;
501
+ let child;
502
+
503
+ if (node.parent?.type === 'Program') {
504
+ parent = node.parent;
505
+ child = node;
506
+ } else if (node.parent?.type === 'ExportNamedDeclaration' &&
507
+ node.parent?.parent.type === 'Program') {
508
+ parent = node.parent?.parent;
509
+ child = node.parent;
510
+ }
511
+
512
+ if (!child || !parent) {
513
+ return false;
514
+ }
515
+
516
+ const functionName = node.id?.name;
517
+
518
+ const idx = parent.body.indexOf(child);
519
+ const prevSibling = parent.body[idx - 1];
520
+
521
+ return (
522
+ // @ts-expect-error Should be ok
523
+ (prevSibling?.type === 'TSDeclareFunction' &&
524
+ // @ts-expect-error Should be ok
525
+ functionName === prevSibling.id.name) ||
526
+ (prevSibling?.type === 'ExportNamedDeclaration' &&
527
+ // @ts-expect-error Should be ok
528
+ prevSibling.declaration?.type === 'TSDeclareFunction' &&
529
+ // @ts-expect-error Should be ok
530
+ prevSibling.declaration?.id?.name === functionName)
531
+ );
532
+ };
533
+
534
+ /** @type {import('eslint').Rule.RuleModule} */
535
+ export default {
536
+ create (context) {
537
+ /* c8 ignore next -- Fallback to deprecated method */
538
+ const {
539
+ // @ts-expect-error ESLint < 10
540
+ sourceCode = context.getSourceCode(),
541
+ } = context;
542
+ const settings = getSettings(context);
543
+ if (!settings) {
544
+ return {};
545
+ }
546
+
547
+ const opts = getOptions(context, settings);
548
+
549
+ const {
550
+ checkAllFunctionExpressions,
551
+ contexts,
552
+ enableFixer,
553
+ exemptEmptyConstructors,
554
+ exemptEmptyFunctions,
555
+ exemptOverloadedImplementations,
556
+ fixerMessage,
557
+ minLineCount,
558
+ require: requireOption,
559
+ skipInterveningOverloadedDeclarations,
560
+ } = opts;
561
+
562
+ const publicOnly =
563
+
564
+ /**
565
+ * @type {{
566
+ * [key: string]: boolean | undefined;
567
+ * }}
568
+ */ (
569
+ opts.publicOnly
570
+ );
571
+
572
+ /**
573
+ * @type {import('../iterateJsdoc.js').CheckJsdoc}
574
+ */
575
+ const checkJsDoc = (info, _handler, node) => {
576
+ if (
577
+ // Optimize
578
+ minLineCount !== undefined || contexts.some((ctxt) => {
579
+ if (typeof ctxt === 'string') {
580
+ return false;
581
+ }
582
+
583
+ const {
584
+ minLineCount: count,
585
+ } = ctxt;
586
+ return count !== undefined;
587
+ })
588
+ ) {
589
+ /**
590
+ * @param {undefined|import('../iterateJsdoc.js').Integer} count
591
+ */
592
+ const underMinLine = (count) => {
593
+ return count !== undefined && count >
594
+ (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
595
+ };
596
+
597
+ if (underMinLine(minLineCount)) {
598
+ return;
599
+ }
600
+
601
+ const {
602
+ minLineCount: contextMinLineCount,
603
+ } =
604
+ /**
605
+ * @type {{
606
+ * context: string;
607
+ * inlineCommentBlock: boolean;
608
+ * minLineCount: number;
609
+ * }}
610
+ */ (contexts.find((ctxt) => {
611
+ if (typeof ctxt === 'string') {
612
+ return false;
613
+ }
614
+
615
+ const {
616
+ context: ctx,
617
+ } = ctxt;
618
+ return ctx === (info.selector || node.type);
619
+ })) || {};
620
+ if (underMinLine(contextMinLineCount)) {
621
+ return;
622
+ }
623
+ }
624
+
625
+ if (exemptOverloadedImplementations && isFunctionWithOverload(node)) {
626
+ return;
627
+ }
628
+
629
+ const jsDocNode = getJSDocComment(
630
+ sourceCode, node, settings, {
631
+ checkOverloads: skipInterveningOverloadedDeclarations,
632
+ },
633
+ );
634
+
635
+ if (jsDocNode) {
636
+ return;
637
+ }
638
+
639
+ // For those who have options configured against ANY constructors (or
640
+ // setters or getters) being reported
641
+ if (exemptSpeciaMethods(
642
+ {
643
+ description: '',
644
+ inlineTags: [],
645
+ problems: [],
646
+ source: [],
647
+ tags: [],
648
+ },
649
+ node,
650
+ context,
651
+ [
652
+ OPTIONS_SCHEMA,
653
+ ],
654
+ )) {
655
+ return;
656
+ }
657
+
658
+ if (
659
+ // Avoid reporting param-less, return-less functions (when
660
+ // `exemptEmptyFunctions` option is set)
661
+ exemptEmptyFunctions && info.isFunctionContext ||
662
+
663
+ // Avoid reporting param-less, return-less constructor methods (when
664
+ // `exemptEmptyConstructors` option is set)
665
+ exemptEmptyConstructors && isConstructor(node)
666
+ ) {
667
+ const functionParameterNames = getFunctionParameterNames(node);
668
+ if (!functionParameterNames.length && !hasReturnValue(node)) {
669
+ return;
670
+ }
671
+ }
672
+
673
+ if (isExemptedImplementer(node, sourceCode, context, settings)) {
674
+ return;
675
+ }
676
+
677
+ const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
678
+ // Default to one line break if the `minLines`/`maxLines` settings allow
679
+ const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
680
+ /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
681
+ let baseNode = getReducedASTNode(node, sourceCode);
682
+
683
+ const decorator = getDecorator(
684
+ /** @type {import('eslint').Rule.Node} */
685
+ (baseNode),
686
+ );
687
+ if (decorator) {
688
+ baseNode = decorator;
689
+ }
690
+
691
+ const indent = getIndent({
692
+ text: sourceCode.getText(
693
+ /** @type {import('eslint').Rule.Node} */ (baseNode),
694
+ /** @type {import('eslint').AST.SourceLocation} */
695
+ (
696
+ /** @type {import('eslint').Rule.Node} */ (baseNode).loc
697
+ ).start.column,
698
+ ),
699
+ });
700
+
701
+ const {
702
+ inlineCommentBlock,
703
+ } =
704
+ /**
705
+ * @type {{
706
+ * context: string,
707
+ * inlineCommentBlock: boolean,
708
+ * minLineCount: import('../iterateJsdoc.js').Integer
709
+ * }}
710
+ */ (contexts.find((contxt) => {
711
+ if (typeof contxt === 'string') {
712
+ return false;
713
+ }
714
+
715
+ const {
716
+ context: ctxt,
717
+ } = contxt;
718
+ return ctxt === node.type;
719
+ })) || {};
720
+ const insertion = (inlineCommentBlock ?
721
+ `/** ${fixerMessage}` :
722
+ `/**\n${indent}*${fixerMessage}\n${indent}`) +
723
+ `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`;
724
+
725
+ return fixer.insertTextBefore(
726
+ /** @type {import('eslint').Rule.Node} */
727
+ (baseNode),
728
+ insertion,
729
+ );
730
+ };
731
+
732
+ const report = () => {
733
+ const {
734
+ start,
735
+ } = /** @type {import('eslint').AST.SourceLocation} */ (node.loc);
736
+ const loc = {
737
+ end: {
738
+ column: 0,
739
+ line: start.line + 1,
740
+ },
741
+ start,
742
+ };
743
+ context.report({
744
+ fix: enableFixer ? fix : null,
745
+ loc,
746
+ messageId: 'missingJsDoc',
747
+ node,
748
+ });
749
+ };
750
+
751
+ if (publicOnly) {
752
+ /** @type {RequireJsdocOpts} */
753
+ const opt = {
754
+ ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
755
+ esm: Boolean(publicOnly?.esm ?? true),
756
+ initModuleExports: Boolean(publicOnly?.cjs ?? true),
757
+ initWindow: Boolean(publicOnly?.window ?? false),
758
+ };
759
+ const exported = exportParser.isUncommentedExport(node, sourceCode, opt, settings);
760
+
761
+ if (exported) {
762
+ report();
763
+ }
764
+ } else {
765
+ report();
766
+ }
767
+ };
768
+
769
+ /**
770
+ * @param {string} prop
771
+ * @returns {boolean}
772
+ */
773
+ const hasOption = (prop) => {
774
+ return requireOption[prop] || contexts.some((ctxt) => {
775
+ return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop;
776
+ });
777
+ };
778
+
779
+ return {
780
+ ...getContextObject(
781
+ enforcedContexts(context, [], settings),
782
+ checkJsDoc,
783
+ ),
784
+ ArrowFunctionExpression (node) {
785
+ if (!hasOption('ArrowFunctionExpression')) {
786
+ return;
787
+ }
788
+
789
+ if (
790
+ [
791
+ 'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
792
+ ].includes(node.parent.type) ||
793
+ [
794
+ 'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
795
+ ].includes(node.parent.type) &&
796
+ node ===
797
+ /**
798
+ * @type {import('@typescript-eslint/types').TSESTree.Property|
799
+ * import('@typescript-eslint/types').TSESTree.PropertyDefinition
800
+ * }
801
+ */
802
+ (node.parent).value
803
+ ) {
804
+ checkJsDoc({
805
+ isFunctionContext: true,
806
+ }, null, node);
807
+ }
808
+ },
809
+
810
+ ClassDeclaration (node) {
811
+ if (!hasOption('ClassDeclaration')) {
812
+ return;
813
+ }
814
+
815
+ checkJsDoc({
816
+ isFunctionContext: false,
817
+ }, null, node);
818
+ },
819
+
820
+ ClassExpression (node) {
821
+ if (!hasOption('ClassExpression')) {
822
+ return;
823
+ }
824
+
825
+ checkJsDoc({
826
+ isFunctionContext: false,
827
+ }, null, node);
828
+ },
829
+
830
+ FunctionDeclaration (node) {
831
+ if (!hasOption('FunctionDeclaration')) {
832
+ return;
833
+ }
834
+
835
+ checkJsDoc({
836
+ isFunctionContext: true,
837
+ }, null, node);
838
+ },
839
+
840
+ FunctionExpression (node) {
841
+ if (!hasOption('FunctionExpression')) {
842
+ return;
843
+ }
844
+
845
+ if (checkAllFunctionExpressions ||
846
+ [
847
+ 'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
848
+ ].includes(node.parent.type) ||
849
+ [
850
+ 'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
851
+ ].includes(node.parent.type) &&
852
+ node ===
853
+ /**
854
+ * @type {import('@typescript-eslint/types').TSESTree.Property|
855
+ * import('@typescript-eslint/types').TSESTree.PropertyDefinition
856
+ * }
857
+ */
858
+ (node.parent).value
859
+ ) {
860
+ checkJsDoc({
861
+ isFunctionContext: true,
862
+ }, null, node);
863
+ }
864
+ },
865
+
866
+ MethodDefinition (node) {
867
+ if (!hasOption('MethodDefinition')) {
868
+ return;
869
+ }
870
+
871
+ checkJsDoc({
872
+ isFunctionContext: true,
873
+ selector: 'MethodDefinition',
874
+ }, null, /** @type {import('eslint').Rule.Node} */ (node.value));
875
+ },
876
+ };
877
+ },
878
+ meta: {
879
+ docs: {
880
+ description: 'Checks for presence of JSDoc comments, on functions and potentially other contexts (optionally limited to exports).',
881
+ recommended: true,
882
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header',
883
+ },
884
+
885
+ fixable: 'code',
886
+
887
+ messages: {
888
+ missingJsDoc: 'Missing JSDoc comment.',
889
+ },
890
+
891
+ schema: [
892
+ OPTIONS_SCHEMA,
893
+ ],
894
+
895
+ type: 'suggestion',
896
+ },
897
+ };