eslint-plugin-jsdoc 53.0.1 → 54.1.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 (359) hide show
  1. package/dist/WarnSettings.cjs +35 -18
  2. package/dist/WarnSettings.cjs.map +1 -1
  3. package/dist/alignTransform.cjs +305 -224
  4. package/dist/alignTransform.cjs.map +1 -1
  5. package/dist/defaultTagOrder.cjs +43 -132
  6. package/dist/defaultTagOrder.cjs.map +1 -1
  7. package/dist/exportParser.cjs +696 -478
  8. package/dist/exportParser.cjs.map +1 -1
  9. package/dist/generateRule.cjs +242 -0
  10. package/dist/generateRule.cjs.map +1 -0
  11. package/dist/getDefaultTagStructureForMode.cjs +288 -184
  12. package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
  13. package/dist/getJsdocProcessorPlugin.cjs +550 -364
  14. package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
  15. package/dist/getJsdocProcessorPlugin.d.ts +65 -68
  16. package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
  17. package/dist/index.cjs +410 -2
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.ts +17 -2
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/iterateJsdoc.cjs +2007 -1539
  22. package/dist/iterateJsdoc.cjs.map +1 -1
  23. package/dist/iterateJsdoc.d.ts +350 -359
  24. package/dist/iterateJsdoc.d.ts.map +1 -1
  25. package/dist/jsdocUtils.cjs +1376 -1009
  26. package/dist/jsdocUtils.cjs.map +1 -1
  27. package/dist/rules/checkAccess.cjs +36 -29
  28. package/dist/rules/checkAccess.cjs.map +1 -1
  29. package/dist/rules/checkAlignment.cjs +54 -41
  30. package/dist/rules/checkAlignment.cjs.map +1 -1
  31. package/dist/rules/checkExamples.cjs +484 -327
  32. package/dist/rules/checkExamples.cjs.map +1 -1
  33. package/dist/rules/checkIndentation.cjs +65 -50
  34. package/dist/rules/checkIndentation.cjs.map +1 -1
  35. package/dist/rules/checkLineAlignment.cjs +311 -220
  36. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  37. package/dist/rules/checkParamNames.cjs +335 -227
  38. package/dist/rules/checkParamNames.cjs.map +1 -1
  39. package/dist/rules/checkPropertyNames.cjs +106 -78
  40. package/dist/rules/checkPropertyNames.cjs.map +1 -1
  41. package/dist/rules/checkSyntax.cjs +34 -21
  42. package/dist/rules/checkSyntax.cjs.map +1 -1
  43. package/dist/rules/checkTagNames.cjs +210 -188
  44. package/dist/rules/checkTagNames.cjs.map +1 -1
  45. package/dist/rules/checkTemplateNames.cjs +178 -121
  46. package/dist/rules/checkTemplateNames.cjs.map +1 -1
  47. package/dist/rules/checkTypes.cjs +385 -291
  48. package/dist/rules/checkTypes.cjs.map +1 -1
  49. package/dist/rules/checkValues.cjs +146 -100
  50. package/dist/rules/checkValues.cjs.map +1 -1
  51. package/dist/rules/convertToJsdocComments.cjs +306 -228
  52. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  53. package/dist/rules/emptyTags.cjs +72 -62
  54. package/dist/rules/emptyTags.cjs.map +1 -1
  55. package/dist/rules/implementsOnClasses.cjs +56 -36
  56. package/dist/rules/implementsOnClasses.cjs.map +1 -1
  57. package/dist/rules/importsAsDependencies.cjs +99 -62
  58. package/dist/rules/importsAsDependencies.cjs.map +1 -1
  59. package/dist/rules/informativeDocs.cjs +142 -105
  60. package/dist/rules/informativeDocs.cjs.map +1 -1
  61. package/dist/rules/linesBeforeBlock.cjs +105 -70
  62. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  63. package/dist/rules/matchDescription.cjs +222 -160
  64. package/dist/rules/matchDescription.cjs.map +1 -1
  65. package/dist/rules/matchName.cjs +128 -73
  66. package/dist/rules/matchName.cjs.map +1 -1
  67. package/dist/rules/multilineBlocks.cjs +352 -235
  68. package/dist/rules/multilineBlocks.cjs.map +1 -1
  69. package/dist/rules/noBadBlocks.cjs +86 -63
  70. package/dist/rules/noBadBlocks.cjs.map +1 -1
  71. package/dist/rules/noBlankBlockDescriptions.cjs +57 -35
  72. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
  73. package/dist/rules/noBlankBlocks.cjs +48 -26
  74. package/dist/rules/noBlankBlocks.cjs.map +1 -1
  75. package/dist/rules/noDefaults.cjs +79 -52
  76. package/dist/rules/noDefaults.cjs.map +1 -1
  77. package/dist/rules/noMissingSyntax.cjs +165 -115
  78. package/dist/rules/noMissingSyntax.cjs.map +1 -1
  79. package/dist/rules/noMultiAsterisks.cjs +89 -48
  80. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  81. package/dist/rules/noRestrictedSyntax.cjs +79 -45
  82. package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
  83. package/dist/rules/noTypes.cjs +80 -59
  84. package/dist/rules/noTypes.cjs.map +1 -1
  85. package/dist/rules/noUndefinedTypes.cjs +391 -297
  86. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  87. package/dist/rules/requireAsteriskPrefix.cjs +159 -108
  88. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  89. package/dist/rules/requireDescription.cjs +129 -89
  90. package/dist/rules/requireDescription.cjs.map +1 -1
  91. package/dist/rules/requireDescriptionCompleteSentence.cjs +262 -201
  92. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  93. package/dist/rules/requireExample.cjs +104 -73
  94. package/dist/rules/requireExample.cjs.map +1 -1
  95. package/dist/rules/requireFileOverview.cjs +129 -75
  96. package/dist/rules/requireFileOverview.cjs.map +1 -1
  97. package/dist/rules/requireHyphenBeforeParamDescription.cjs +133 -85
  98. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  99. package/dist/rules/requireJsdoc.cjs +559 -384
  100. package/dist/rules/requireJsdoc.cjs.map +1 -1
  101. package/dist/rules/requireParam.cjs +526 -336
  102. package/dist/rules/requireParam.cjs.map +1 -1
  103. package/dist/rules/requireParamDescription.cjs +80 -55
  104. package/dist/rules/requireParamDescription.cjs.map +1 -1
  105. package/dist/rules/requireParamName.cjs +50 -32
  106. package/dist/rules/requireParamName.cjs.map +1 -1
  107. package/dist/rules/requireParamType.cjs +80 -55
  108. package/dist/rules/requireParamType.cjs.map +1 -1
  109. package/dist/rules/requireProperty.cjs +42 -31
  110. package/dist/rules/requireProperty.cjs.map +1 -1
  111. package/dist/rules/requirePropertyDescription.cjs +25 -17
  112. package/dist/rules/requirePropertyDescription.cjs.map +1 -1
  113. package/dist/rules/requirePropertyName.cjs +25 -17
  114. package/dist/rules/requirePropertyName.cjs.map +1 -1
  115. package/dist/rules/requirePropertyType.cjs +25 -17
  116. package/dist/rules/requirePropertyType.cjs.map +1 -1
  117. package/dist/rules/requireReturns.cjs +203 -125
  118. package/dist/rules/requireReturns.cjs.map +1 -1
  119. package/dist/rules/requireReturnsCheck.cjs +103 -60
  120. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  121. package/dist/rules/requireReturnsDescription.cjs +54 -39
  122. package/dist/rules/requireReturnsDescription.cjs.map +1 -1
  123. package/dist/rules/requireReturnsType.cjs +50 -32
  124. package/dist/rules/requireReturnsType.cjs.map +1 -1
  125. package/dist/rules/requireTemplate.cjs +178 -119
  126. package/dist/rules/requireTemplate.cjs.map +1 -1
  127. package/dist/rules/requireThrows.cjs +95 -61
  128. package/dist/rules/requireThrows.cjs.map +1 -1
  129. package/dist/rules/requireYields.cjs +166 -106
  130. package/dist/rules/requireYields.cjs.map +1 -1
  131. package/dist/rules/requireYieldsCheck.cjs +152 -96
  132. package/dist/rules/requireYieldsCheck.cjs.map +1 -1
  133. package/dist/rules/sortTags.cjs +444 -258
  134. package/dist/rules/sortTags.cjs.map +1 -1
  135. package/dist/rules/tagLines.cjs +266 -179
  136. package/dist/rules/tagLines.cjs.map +1 -1
  137. package/dist/rules/textEscaping.cjs +127 -92
  138. package/dist/rules/textEscaping.cjs.map +1 -1
  139. package/dist/rules/validTypes.cjs +265 -252
  140. package/dist/rules/validTypes.cjs.map +1 -1
  141. package/dist/tagNames.cjs +170 -134
  142. package/dist/tagNames.cjs.map +1 -1
  143. package/dist/utils/hasReturnValue.cjs +474 -246
  144. package/dist/utils/hasReturnValue.cjs.map +1 -1
  145. package/package.json +41 -57
  146. package/src/WarnSettings.js +34 -0
  147. package/src/alignTransform.js +358 -0
  148. package/src/defaultTagOrder.js +169 -0
  149. package/src/exportParser.js +978 -0
  150. package/src/getDefaultTagStructureForMode.js +969 -0
  151. package/src/getJsdocProcessorPlugin.js +672 -0
  152. package/src/index.js +530 -0
  153. package/src/iterateJsdoc.js +2542 -0
  154. package/src/jsdocUtils.js +1896 -0
  155. package/src/rules/checkAccess.js +45 -0
  156. package/src/rules/checkAlignment.js +63 -0
  157. package/src/rules/checkExamples.js +589 -0
  158. package/src/rules/checkIndentation.js +75 -0
  159. package/src/rules/checkLineAlignment.js +372 -0
  160. package/src/rules/checkParamNames.js +474 -0
  161. package/src/rules/checkPropertyNames.js +152 -0
  162. package/src/rules/checkSyntax.js +30 -0
  163. package/src/rules/checkTagNames.js +314 -0
  164. package/src/rules/checkTemplateNames.js +204 -0
  165. package/src/rules/checkTypes.js +535 -0
  166. package/src/rules/checkValues.js +248 -0
  167. package/src/rules/convertToJsdocComments.js +398 -0
  168. package/src/rules/emptyTags.js +98 -0
  169. package/src/rules/implementsOnClasses.js +64 -0
  170. package/src/rules/importsAsDependencies.js +133 -0
  171. package/src/rules/informativeDocs.js +189 -0
  172. package/src/rules/linesBeforeBlock.js +134 -0
  173. package/src/rules/matchDescription.js +286 -0
  174. package/src/rules/matchName.js +151 -0
  175. package/src/rules/multilineBlocks.js +493 -0
  176. package/src/rules/noBadBlocks.js +119 -0
  177. package/src/rules/noBlankBlockDescriptions.js +69 -0
  178. package/src/rules/noBlankBlocks.js +53 -0
  179. package/src/rules/noDefaults.js +85 -0
  180. package/src/rules/noMissingSyntax.js +195 -0
  181. package/src/rules/noMultiAsterisks.js +134 -0
  182. package/src/rules/noRestrictedSyntax.js +91 -0
  183. package/src/rules/noTypes.js +93 -0
  184. package/src/rules/noUndefinedTypes.js +545 -0
  185. package/src/rules/requireAsteriskPrefix.js +190 -0
  186. package/src/rules/requireDescription.js +161 -0
  187. package/src/rules/requireDescriptionCompleteSentence.js +335 -0
  188. package/src/rules/requireExample.js +118 -0
  189. package/src/rules/requireFileOverview.js +154 -0
  190. package/src/rules/requireHyphenBeforeParamDescription.js +176 -0
  191. package/src/rules/requireJsdoc.js +744 -0
  192. package/src/rules/requireParam.js +602 -0
  193. package/src/rules/requireParamDescription.js +89 -0
  194. package/src/rules/requireParamName.js +55 -0
  195. package/src/rules/requireParamType.js +89 -0
  196. package/src/rules/requireProperty.js +48 -0
  197. package/src/rules/requirePropertyDescription.js +25 -0
  198. package/src/rules/requirePropertyName.js +25 -0
  199. package/src/rules/requirePropertyType.js +25 -0
  200. package/src/rules/requireReturns.js +238 -0
  201. package/src/rules/requireReturnsCheck.js +145 -0
  202. package/src/rules/requireReturnsDescription.js +59 -0
  203. package/src/rules/requireReturnsType.js +51 -0
  204. package/src/rules/requireTemplate.js +201 -0
  205. package/src/rules/requireThrows.js +111 -0
  206. package/src/rules/requireYields.js +216 -0
  207. package/src/rules/requireYieldsCheck.js +208 -0
  208. package/src/rules/sortTags.js +558 -0
  209. package/src/rules/tagLines.js +359 -0
  210. package/src/rules/textEscaping.js +154 -0
  211. package/src/rules/validTypes.js +401 -0
  212. package/src/tagNames.js +238 -0
  213. package/src/utils/hasReturnValue.js +572 -0
  214. package/dist/WarnSettings.js +0 -20
  215. package/dist/WarnSettings.js.map +0 -1
  216. package/dist/_virtual/rolldown_runtime.cjs +0 -32
  217. package/dist/_virtual/rolldown_runtime.js +0 -11
  218. package/dist/alignTransform.js +0 -241
  219. package/dist/alignTransform.js.map +0 -1
  220. package/dist/defaultTagOrder.js +0 -134
  221. package/dist/defaultTagOrder.js.map +0 -1
  222. package/dist/exportParser.js +0 -518
  223. package/dist/exportParser.js.map +0 -1
  224. package/dist/getDefaultTagStructureForMode.js +0 -188
  225. package/dist/getDefaultTagStructureForMode.js.map +0 -1
  226. package/dist/getJsdocProcessorPlugin.d.cts +0 -70
  227. package/dist/getJsdocProcessorPlugin.d.cts.map +0 -1
  228. package/dist/getJsdocProcessorPlugin.js +0 -383
  229. package/dist/getJsdocProcessorPlugin.js.map +0 -1
  230. package/dist/index.d.cts +0 -2
  231. package/dist/index.js +0 -3
  232. package/dist/iterateJsdoc.d.cts +0 -472
  233. package/dist/iterateJsdoc.d.cts.map +0 -1
  234. package/dist/iterateJsdoc.js +0 -1628
  235. package/dist/iterateJsdoc.js.map +0 -1
  236. package/dist/jsdocUtils.js +0 -1123
  237. package/dist/jsdocUtils.js.map +0 -1
  238. package/dist/plugin.cjs +0 -427
  239. package/dist/plugin.cjs.map +0 -1
  240. package/dist/plugin.js +0 -427
  241. package/dist/plugin.js.map +0 -1
  242. package/dist/rules/checkAccess.js +0 -33
  243. package/dist/rules/checkAccess.js.map +0 -1
  244. package/dist/rules/checkAlignment.js +0 -47
  245. package/dist/rules/checkAlignment.js.map +0 -1
  246. package/dist/rules/checkExamples.js +0 -348
  247. package/dist/rules/checkExamples.js.map +0 -1
  248. package/dist/rules/checkIndentation.js +0 -59
  249. package/dist/rules/checkIndentation.js.map +0 -1
  250. package/dist/rules/checkLineAlignment.js +0 -229
  251. package/dist/rules/checkLineAlignment.js.map +0 -1
  252. package/dist/rules/checkParamNames.js +0 -237
  253. package/dist/rules/checkParamNames.js.map +0 -1
  254. package/dist/rules/checkPropertyNames.js +0 -88
  255. package/dist/rules/checkPropertyNames.js.map +0 -1
  256. package/dist/rules/checkSyntax.js +0 -25
  257. package/dist/rules/checkSyntax.js.map +0 -1
  258. package/dist/rules/checkTagNames.js +0 -191
  259. package/dist/rules/checkTagNames.js.map +0 -1
  260. package/dist/rules/checkTemplateNames.js +0 -124
  261. package/dist/rules/checkTemplateNames.js.map +0 -1
  262. package/dist/rules/checkTypes.js +0 -299
  263. package/dist/rules/checkTypes.js.map +0 -1
  264. package/dist/rules/checkValues.js +0 -103
  265. package/dist/rules/checkValues.js.map +0 -1
  266. package/dist/rules/convertToJsdocComments.js +0 -231
  267. package/dist/rules/convertToJsdocComments.js.map +0 -1
  268. package/dist/rules/emptyTags.js +0 -67
  269. package/dist/rules/emptyTags.js.map +0 -1
  270. package/dist/rules/implementsOnClasses.js +0 -40
  271. package/dist/rules/implementsOnClasses.js.map +0 -1
  272. package/dist/rules/importsAsDependencies.js +0 -68
  273. package/dist/rules/importsAsDependencies.js.map +0 -1
  274. package/dist/rules/informativeDocs.js +0 -110
  275. package/dist/rules/informativeDocs.js.map +0 -1
  276. package/dist/rules/linesBeforeBlock.js +0 -75
  277. package/dist/rules/linesBeforeBlock.js.map +0 -1
  278. package/dist/rules/matchDescription.js +0 -167
  279. package/dist/rules/matchDescription.js.map +0 -1
  280. package/dist/rules/matchName.js +0 -77
  281. package/dist/rules/matchName.js.map +0 -1
  282. package/dist/rules/multilineBlocks.js +0 -245
  283. package/dist/rules/multilineBlocks.js.map +0 -1
  284. package/dist/rules/noBadBlocks.js +0 -68
  285. package/dist/rules/noBadBlocks.js.map +0 -1
  286. package/dist/rules/noBlankBlockDescriptions.js +0 -41
  287. package/dist/rules/noBlankBlockDescriptions.js.map +0 -1
  288. package/dist/rules/noBlankBlocks.js +0 -30
  289. package/dist/rules/noBlankBlocks.js.map +0 -1
  290. package/dist/rules/noDefaults.js +0 -56
  291. package/dist/rules/noDefaults.js.map +0 -1
  292. package/dist/rules/noMissingSyntax.js +0 -126
  293. package/dist/rules/noMissingSyntax.js.map +0 -1
  294. package/dist/rules/noMultiAsterisks.js +0 -58
  295. package/dist/rules/noMultiAsterisks.js.map +0 -1
  296. package/dist/rules/noRestrictedSyntax.js +0 -49
  297. package/dist/rules/noRestrictedSyntax.js.map +0 -1
  298. package/dist/rules/noTypes.js +0 -65
  299. package/dist/rules/noTypes.js.map +0 -1
  300. package/dist/rules/noUndefinedTypes.js +0 -303
  301. package/dist/rules/noUndefinedTypes.js.map +0 -1
  302. package/dist/rules/requireAsteriskPrefix.js +0 -112
  303. package/dist/rules/requireAsteriskPrefix.js.map +0 -1
  304. package/dist/rules/requireDescription.js +0 -95
  305. package/dist/rules/requireDescription.js.map +0 -1
  306. package/dist/rules/requireDescriptionCompleteSentence.js +0 -220
  307. package/dist/rules/requireDescriptionCompleteSentence.js.map +0 -1
  308. package/dist/rules/requireExample.js +0 -77
  309. package/dist/rules/requireExample.js.map +0 -1
  310. package/dist/rules/requireFileOverview.js +0 -81
  311. package/dist/rules/requireFileOverview.js.map +0 -1
  312. package/dist/rules/requireHyphenBeforeParamDescription.js +0 -89
  313. package/dist/rules/requireHyphenBeforeParamDescription.js.map +0 -1
  314. package/dist/rules/requireJsdoc.js +0 -404
  315. package/dist/rules/requireJsdoc.js.map +0 -1
  316. package/dist/rules/requireParam.js +0 -344
  317. package/dist/rules/requireParam.js.map +0 -1
  318. package/dist/rules/requireParamDescription.js +0 -59
  319. package/dist/rules/requireParamDescription.js.map +0 -1
  320. package/dist/rules/requireParamName.js +0 -36
  321. package/dist/rules/requireParamName.js.map +0 -1
  322. package/dist/rules/requireParamType.js +0 -59
  323. package/dist/rules/requireParamType.js.map +0 -1
  324. package/dist/rules/requireProperty.js +0 -35
  325. package/dist/rules/requireProperty.js.map +0 -1
  326. package/dist/rules/requirePropertyDescription.js +0 -21
  327. package/dist/rules/requirePropertyDescription.js.map +0 -1
  328. package/dist/rules/requirePropertyName.js +0 -21
  329. package/dist/rules/requirePropertyName.js.map +0 -1
  330. package/dist/rules/requirePropertyType.js +0 -21
  331. package/dist/rules/requirePropertyType.js.map +0 -1
  332. package/dist/rules/requireReturns.js +0 -131
  333. package/dist/rules/requireReturns.js.map +0 -1
  334. package/dist/rules/requireReturnsCheck.js +0 -66
  335. package/dist/rules/requireReturnsCheck.js.map +0 -1
  336. package/dist/rules/requireReturnsDescription.js +0 -43
  337. package/dist/rules/requireReturnsDescription.js.map +0 -1
  338. package/dist/rules/requireReturnsType.js +0 -36
  339. package/dist/rules/requireReturnsType.js.map +0 -1
  340. package/dist/rules/requireTemplate.js +0 -122
  341. package/dist/rules/requireTemplate.js.map +0 -1
  342. package/dist/rules/requireThrows.js +0 -67
  343. package/dist/rules/requireThrows.js.map +0 -1
  344. package/dist/rules/requireYields.js +0 -115
  345. package/dist/rules/requireYields.js.map +0 -1
  346. package/dist/rules/requireYieldsCheck.js +0 -105
  347. package/dist/rules/requireYieldsCheck.js.map +0 -1
  348. package/dist/rules/sortTags.js +0 -262
  349. package/dist/rules/sortTags.js.map +0 -1
  350. package/dist/rules/tagLines.js +0 -183
  351. package/dist/rules/tagLines.js.map +0 -1
  352. package/dist/rules/textEscaping.js +0 -102
  353. package/dist/rules/textEscaping.js.map +0 -1
  354. package/dist/rules/validTypes.js +0 -259
  355. package/dist/rules/validTypes.js.map +0 -1
  356. package/dist/tagNames.js +0 -144
  357. package/dist/tagNames.js.map +0 -1
  358. package/dist/utils/hasReturnValue.js +0 -265
  359. package/dist/utils/hasReturnValue.js.map +0 -1
@@ -0,0 +1,744 @@
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
+ properties: {
38
+ checkConstructors: {
39
+ default: true,
40
+ type: 'boolean',
41
+ },
42
+ checkGetters: {
43
+ anyOf: [
44
+ {
45
+ type: 'boolean',
46
+ },
47
+ {
48
+ enum: [
49
+ 'no-setter',
50
+ ],
51
+ type: 'string',
52
+ },
53
+ ],
54
+ default: true,
55
+ },
56
+ checkSetters: {
57
+ anyOf: [
58
+ {
59
+ type: 'boolean',
60
+ },
61
+ {
62
+ enum: [
63
+ 'no-getter',
64
+ ],
65
+ type: 'string',
66
+ },
67
+ ],
68
+ default: true,
69
+ },
70
+ contexts: {
71
+ items: {
72
+ anyOf: [
73
+ {
74
+ type: 'string',
75
+ },
76
+ {
77
+ additionalProperties: false,
78
+ properties: {
79
+ context: {
80
+ type: 'string',
81
+ },
82
+ inlineCommentBlock: {
83
+ type: 'boolean',
84
+ },
85
+ minLineCount: {
86
+ type: 'integer',
87
+ },
88
+ },
89
+ type: 'object',
90
+ },
91
+ ],
92
+ },
93
+ type: 'array',
94
+ },
95
+ enableFixer: {
96
+ default: true,
97
+ type: 'boolean',
98
+ },
99
+ exemptEmptyConstructors: {
100
+ default: false,
101
+ type: 'boolean',
102
+ },
103
+ exemptEmptyFunctions: {
104
+ default: false,
105
+ type: 'boolean',
106
+ },
107
+ fixerMessage: {
108
+ default: '',
109
+ type: 'string',
110
+ },
111
+ minLineCount: {
112
+ type: 'integer',
113
+ },
114
+ publicOnly: {
115
+ oneOf: [
116
+ {
117
+ default: false,
118
+ type: 'boolean',
119
+ },
120
+ {
121
+ additionalProperties: false,
122
+ default: {},
123
+ properties: {
124
+ ancestorsOnly: {
125
+ type: 'boolean',
126
+ },
127
+ cjs: {
128
+ type: 'boolean',
129
+ },
130
+ esm: {
131
+ type: 'boolean',
132
+ },
133
+ window: {
134
+ type: 'boolean',
135
+ },
136
+ },
137
+ type: 'object',
138
+ },
139
+ ],
140
+ },
141
+ require: {
142
+ additionalProperties: false,
143
+ default: {},
144
+ properties: {
145
+ ArrowFunctionExpression: {
146
+ default: false,
147
+ type: 'boolean',
148
+ },
149
+ ClassDeclaration: {
150
+ default: false,
151
+ type: 'boolean',
152
+ },
153
+ ClassExpression: {
154
+ default: false,
155
+ type: 'boolean',
156
+ },
157
+ FunctionDeclaration: {
158
+ default: true,
159
+ type: 'boolean',
160
+ },
161
+ FunctionExpression: {
162
+ default: false,
163
+ type: 'boolean',
164
+ },
165
+ MethodDefinition: {
166
+ default: false,
167
+ type: 'boolean',
168
+ },
169
+ },
170
+ type: 'object',
171
+ },
172
+ },
173
+ type: 'object',
174
+ };
175
+
176
+ /**
177
+ * @param {string} interfaceName
178
+ * @param {string} methodName
179
+ * @param {import("eslint").Scope.Scope | null} scope
180
+ * @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
181
+ */
182
+ const getMethodOnInterface = (interfaceName, methodName, scope) => {
183
+ let scp = scope;
184
+ while (scp) {
185
+ for (const {
186
+ identifiers,
187
+ name,
188
+ } of scp.variables) {
189
+ if (interfaceName !== name) {
190
+ continue;
191
+ }
192
+
193
+ for (const identifier of identifiers) {
194
+ const interfaceDeclaration = /** @type {import('@typescript-eslint/types').TSESTree.Identifier & {parent: import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration}} */ (
195
+ identifier
196
+ ).parent;
197
+ /* c8 ignore next 3 -- TS */
198
+ if (interfaceDeclaration.type !== 'TSInterfaceDeclaration') {
199
+ continue;
200
+ }
201
+
202
+ for (const bodyItem of interfaceDeclaration.body.body) {
203
+ const methodSig = /** @type {import('@typescript-eslint/types').TSESTree.TSMethodSignature} */ (
204
+ bodyItem
205
+ );
206
+ if (methodName === /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
207
+ methodSig.key
208
+ ).name) {
209
+ return methodSig;
210
+ }
211
+ }
212
+ }
213
+ }
214
+
215
+ scp = scp.upper;
216
+ }
217
+
218
+ return null;
219
+ };
220
+
221
+ /**
222
+ * @param {import('eslint').Rule.Node} node
223
+ * @param {import('eslint').SourceCode} sourceCode
224
+ * @param {import('eslint').Rule.RuleContext} context
225
+ * @param {import('../iterateJsdoc.js').Settings} settings
226
+ */
227
+ const isExemptedImplementer = (node, sourceCode, context, settings) => {
228
+ if (node.type === 'FunctionExpression' &&
229
+ node.parent.type === 'MethodDefinition' &&
230
+ node.parent.parent.type === 'ClassBody' &&
231
+ node.parent.parent.parent.type === 'ClassDeclaration' &&
232
+ 'implements' in node.parent.parent.parent
233
+ ) {
234
+ const implments = /** @type {import('@typescript-eslint/types').TSESTree.TSClassImplements[]} */ (
235
+ node.parent.parent.parent.implements
236
+ );
237
+
238
+ const {
239
+ name: methodName,
240
+ } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
241
+ node.parent.key
242
+ );
243
+
244
+ for (const impl of implments) {
245
+ const {
246
+ name: interfaceName,
247
+ } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
248
+ impl.expression
249
+ );
250
+
251
+ const interfaceMethodNode = getMethodOnInterface(interfaceName, methodName, node && (
252
+ (sourceCode.getScope &&
253
+ /* c8 ignore next 3 */
254
+ sourceCode.getScope(node)) ||
255
+ // @ts-expect-error ESLint 8
256
+ context.getScope()
257
+ ));
258
+ if (interfaceMethodNode) {
259
+ // @ts-expect-error Ok
260
+ const comment = getJSDocComment(sourceCode, interfaceMethodNode, settings);
261
+ if (comment) {
262
+ return true;
263
+ }
264
+ }
265
+ }
266
+ }
267
+
268
+ return false;
269
+ };
270
+
271
+ /**
272
+ * @param {import('eslint').Rule.RuleContext} context
273
+ * @param {import('json-schema').JSONSchema4Object} baseObject
274
+ * @param {string} option
275
+ * @param {string} key
276
+ * @returns {boolean|undefined}
277
+ */
278
+ const getOption = (context, baseObject, option, key) => {
279
+ if (context.options[0] && option in context.options[0] &&
280
+ // Todo: boolean shouldn't be returning property, but
281
+ // tests currently require
282
+ (typeof context.options[0][option] === 'boolean' ||
283
+ key in context.options[0][option])
284
+ ) {
285
+ return context.options[0][option][key];
286
+ }
287
+
288
+ return /** @type {{[key: string]: {default?: boolean|undefined}}} */ (
289
+ baseObject.properties
290
+ )[key].default;
291
+ };
292
+
293
+ /**
294
+ * @param {import('eslint').Rule.RuleContext} context
295
+ * @param {import('../iterateJsdoc.js').Settings} settings
296
+ * @returns {{
297
+ * contexts: (string|{
298
+ * context: string,
299
+ * inlineCommentBlock: boolean,
300
+ * minLineCount: import('../iterateJsdoc.js').Integer
301
+ * })[],
302
+ * enableFixer: boolean,
303
+ * exemptEmptyConstructors: boolean,
304
+ * exemptEmptyFunctions: boolean,
305
+ * fixerMessage: string,
306
+ * minLineCount: undefined|import('../iterateJsdoc.js').Integer,
307
+ * publicOnly: boolean|{[key: string]: boolean|undefined}
308
+ * require: {[key: string]: boolean|undefined}
309
+ * }}
310
+ */
311
+ const getOptions = (context, settings) => {
312
+ const {
313
+ contexts = settings.contexts || [],
314
+ enableFixer = true,
315
+ exemptEmptyConstructors = true,
316
+ exemptEmptyFunctions = false,
317
+ fixerMessage = '',
318
+ minLineCount = undefined,
319
+ publicOnly,
320
+ } = context.options[0] || {};
321
+
322
+ return {
323
+ contexts,
324
+ enableFixer,
325
+ exemptEmptyConstructors,
326
+ exemptEmptyFunctions,
327
+ fixerMessage,
328
+ minLineCount,
329
+ publicOnly: ((baseObj) => {
330
+ if (!publicOnly) {
331
+ return false;
332
+ }
333
+
334
+ /** @type {{[key: string]: boolean|undefined}} */
335
+ const properties = {};
336
+ for (const prop of Object.keys(
337
+ /** @type {import('json-schema').JSONSchema4Object} */ (
338
+ /** @type {import('json-schema').JSONSchema4Object} */ (
339
+ baseObj
340
+ ).properties),
341
+ )) {
342
+ const opt = getOption(
343
+ context,
344
+ /** @type {import('json-schema').JSONSchema4Object} */ (baseObj),
345
+ 'publicOnly',
346
+ prop,
347
+ );
348
+
349
+ properties[prop] = opt;
350
+ }
351
+
352
+ return properties;
353
+ })(
354
+ /** @type {import('json-schema').JSONSchema4Object} */
355
+ (
356
+ /** @type {import('json-schema').JSONSchema4Object} */
357
+ (
358
+ /** @type {import('json-schema').JSONSchema4Object} */
359
+ (
360
+ OPTIONS_SCHEMA.properties
361
+ ).publicOnly
362
+ ).oneOf
363
+ )[1],
364
+ ),
365
+ require: ((baseObj) => {
366
+ /** @type {{[key: string]: boolean|undefined}} */
367
+ const properties = {};
368
+ for (const prop of Object.keys(
369
+ /** @type {import('json-schema').JSONSchema4Object} */ (
370
+ /** @type {import('json-schema').JSONSchema4Object} */ (
371
+ baseObj
372
+ ).properties),
373
+ )) {
374
+ const opt = getOption(
375
+ context,
376
+ /** @type {import('json-schema').JSONSchema4Object} */
377
+ (baseObj),
378
+ 'require',
379
+ prop,
380
+ );
381
+ properties[prop] = opt;
382
+ }
383
+
384
+ return properties;
385
+ })(
386
+ /** @type {import('json-schema').JSONSchema4Object} */
387
+ (OPTIONS_SCHEMA.properties).require,
388
+ ),
389
+ };
390
+ };
391
+
392
+ /** @type {import('eslint').Rule.RuleModule} */
393
+ export default {
394
+ create (context) {
395
+ /* c8 ignore next -- Fallback to deprecated method */
396
+ const {
397
+ sourceCode = context.getSourceCode(),
398
+ } = context;
399
+ const settings = getSettings(context);
400
+ if (!settings) {
401
+ return {};
402
+ }
403
+
404
+ const opts = getOptions(context, settings);
405
+
406
+ const {
407
+ contexts,
408
+ enableFixer,
409
+ exemptEmptyConstructors,
410
+ exemptEmptyFunctions,
411
+ fixerMessage,
412
+ minLineCount,
413
+ require: requireOption,
414
+ } = opts;
415
+
416
+ const publicOnly =
417
+
418
+ /**
419
+ * @type {{
420
+ * [key: string]: boolean | undefined;
421
+ * }}
422
+ */ (
423
+ opts.publicOnly
424
+ );
425
+
426
+ /**
427
+ * @type {import('../iterateJsdoc.js').CheckJsdoc}
428
+ */
429
+ const checkJsDoc = (info, _handler, node) => {
430
+ if (
431
+ // Optimize
432
+ minLineCount !== undefined || contexts.some((ctxt) => {
433
+ if (typeof ctxt === 'string') {
434
+ return false;
435
+ }
436
+
437
+ const {
438
+ minLineCount: count,
439
+ } = ctxt;
440
+ return count !== undefined;
441
+ })
442
+ ) {
443
+ /**
444
+ * @param {undefined|import('../iterateJsdoc.js').Integer} count
445
+ */
446
+ const underMinLine = (count) => {
447
+ return count !== undefined && count >
448
+ (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
449
+ };
450
+
451
+ if (underMinLine(minLineCount)) {
452
+ return;
453
+ }
454
+
455
+ const {
456
+ minLineCount: contextMinLineCount,
457
+ } =
458
+ /**
459
+ * @type {{
460
+ * context: string;
461
+ * inlineCommentBlock: boolean;
462
+ * minLineCount: number;
463
+ * }}
464
+ */ (contexts.find((ctxt) => {
465
+ if (typeof ctxt === 'string') {
466
+ return false;
467
+ }
468
+
469
+ const {
470
+ context: ctx,
471
+ } = ctxt;
472
+ return ctx === (info.selector || node.type);
473
+ })) || {};
474
+ if (underMinLine(contextMinLineCount)) {
475
+ return;
476
+ }
477
+ }
478
+
479
+ const jsDocNode = getJSDocComment(sourceCode, node, settings);
480
+
481
+ if (jsDocNode) {
482
+ return;
483
+ }
484
+
485
+ // For those who have options configured against ANY constructors (or
486
+ // setters or getters) being reported
487
+ if (exemptSpeciaMethods(
488
+ {
489
+ description: '',
490
+ inlineTags: [],
491
+ problems: [],
492
+ source: [],
493
+ tags: [],
494
+ },
495
+ node,
496
+ context,
497
+ [
498
+ OPTIONS_SCHEMA,
499
+ ],
500
+ )) {
501
+ return;
502
+ }
503
+
504
+ if (
505
+ // Avoid reporting param-less, return-less functions (when
506
+ // `exemptEmptyFunctions` option is set)
507
+ exemptEmptyFunctions && info.isFunctionContext ||
508
+
509
+ // Avoid reporting param-less, return-less constructor methods (when
510
+ // `exemptEmptyConstructors` option is set)
511
+ exemptEmptyConstructors && isConstructor(node)
512
+ ) {
513
+ const functionParameterNames = getFunctionParameterNames(node);
514
+ if (!functionParameterNames.length && !hasReturnValue(node)) {
515
+ return;
516
+ }
517
+ }
518
+
519
+ if (isExemptedImplementer(node, sourceCode, context, settings)) {
520
+ return;
521
+ }
522
+
523
+ const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
524
+ // Default to one line break if the `minLines`/`maxLines` settings allow
525
+ const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
526
+ /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
527
+ let baseNode = getReducedASTNode(node, sourceCode);
528
+
529
+ const decorator = getDecorator(
530
+ /** @type {import('eslint').Rule.Node} */
531
+ (baseNode),
532
+ );
533
+ if (decorator) {
534
+ baseNode = decorator;
535
+ }
536
+
537
+ const indent = getIndent({
538
+ text: sourceCode.getText(
539
+ /** @type {import('eslint').Rule.Node} */ (baseNode),
540
+ /** @type {import('eslint').AST.SourceLocation} */
541
+ (
542
+ /** @type {import('eslint').Rule.Node} */ (baseNode).loc
543
+ ).start.column,
544
+ ),
545
+ });
546
+
547
+ const {
548
+ inlineCommentBlock,
549
+ } =
550
+ /**
551
+ * @type {{
552
+ * context: string,
553
+ * inlineCommentBlock: boolean,
554
+ * minLineCount: import('../iterateJsdoc.js').Integer
555
+ * }}
556
+ */ (contexts.find((contxt) => {
557
+ if (typeof contxt === 'string') {
558
+ return false;
559
+ }
560
+
561
+ const {
562
+ context: ctxt,
563
+ } = contxt;
564
+ return ctxt === node.type;
565
+ })) || {};
566
+ const insertion = (inlineCommentBlock ?
567
+ `/** ${fixerMessage}` :
568
+ `/**\n${indent}*${fixerMessage}\n${indent}`) +
569
+ `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`;
570
+
571
+ return fixer.insertTextBefore(
572
+ /** @type {import('eslint').Rule.Node} */
573
+ (baseNode),
574
+ insertion,
575
+ );
576
+ };
577
+
578
+ const report = () => {
579
+ const {
580
+ start,
581
+ } = /** @type {import('eslint').AST.SourceLocation} */ (node.loc);
582
+ const loc = {
583
+ end: {
584
+ column: 0,
585
+ line: start.line + 1,
586
+ },
587
+ start,
588
+ };
589
+ context.report({
590
+ fix: enableFixer ? fix : null,
591
+ loc,
592
+ messageId: 'missingJsDoc',
593
+ node,
594
+ });
595
+ };
596
+
597
+ if (publicOnly) {
598
+ /** @type {RequireJsdocOpts} */
599
+ const opt = {
600
+ ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
601
+ esm: Boolean(publicOnly?.esm ?? true),
602
+ initModuleExports: Boolean(publicOnly?.cjs ?? true),
603
+ initWindow: Boolean(publicOnly?.window ?? false),
604
+ };
605
+ const exported = exportParser.isUncommentedExport(node, sourceCode, opt, settings);
606
+
607
+ if (exported) {
608
+ report();
609
+ }
610
+ } else {
611
+ report();
612
+ }
613
+ };
614
+
615
+ /**
616
+ * @param {string} prop
617
+ * @returns {boolean}
618
+ */
619
+ const hasOption = (prop) => {
620
+ return requireOption[prop] || contexts.some((ctxt) => {
621
+ return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop;
622
+ });
623
+ };
624
+
625
+ return {
626
+ ...getContextObject(
627
+ enforcedContexts(context, [], settings),
628
+ checkJsDoc,
629
+ ),
630
+ ArrowFunctionExpression (node) {
631
+ if (!hasOption('ArrowFunctionExpression')) {
632
+ return;
633
+ }
634
+
635
+ if (
636
+ [
637
+ 'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
638
+ ].includes(node.parent.type) ||
639
+ [
640
+ 'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
641
+ ].includes(node.parent.type) &&
642
+ node ===
643
+ /**
644
+ * @type {import('@typescript-eslint/types').TSESTree.Property|
645
+ * import('@typescript-eslint/types').TSESTree.PropertyDefinition
646
+ * }
647
+ */
648
+ (node.parent).value
649
+ ) {
650
+ checkJsDoc({
651
+ isFunctionContext: true,
652
+ }, null, node);
653
+ }
654
+ },
655
+
656
+ ClassDeclaration (node) {
657
+ if (!hasOption('ClassDeclaration')) {
658
+ return;
659
+ }
660
+
661
+ checkJsDoc({
662
+ isFunctionContext: false,
663
+ }, null, node);
664
+ },
665
+
666
+ ClassExpression (node) {
667
+ if (!hasOption('ClassExpression')) {
668
+ return;
669
+ }
670
+
671
+ checkJsDoc({
672
+ isFunctionContext: false,
673
+ }, null, node);
674
+ },
675
+
676
+ FunctionDeclaration (node) {
677
+ if (!hasOption('FunctionDeclaration')) {
678
+ return;
679
+ }
680
+
681
+ checkJsDoc({
682
+ isFunctionContext: true,
683
+ }, null, node);
684
+ },
685
+
686
+ FunctionExpression (node) {
687
+ if (!hasOption('FunctionExpression')) {
688
+ return;
689
+ }
690
+
691
+ if (
692
+ [
693
+ 'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
694
+ ].includes(node.parent.type) ||
695
+ [
696
+ 'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
697
+ ].includes(node.parent.type) &&
698
+ node ===
699
+ /**
700
+ * @type {import('@typescript-eslint/types').TSESTree.Property|
701
+ * import('@typescript-eslint/types').TSESTree.PropertyDefinition
702
+ * }
703
+ */
704
+ (node.parent).value
705
+ ) {
706
+ checkJsDoc({
707
+ isFunctionContext: true,
708
+ }, null, node);
709
+ }
710
+ },
711
+
712
+ MethodDefinition (node) {
713
+ if (!hasOption('MethodDefinition')) {
714
+ return;
715
+ }
716
+
717
+ checkJsDoc({
718
+ isFunctionContext: true,
719
+ selector: 'MethodDefinition',
720
+ }, null, /** @type {import('eslint').Rule.Node} */ (node.value));
721
+ },
722
+ };
723
+ },
724
+ meta: {
725
+ docs: {
726
+ category: 'Stylistic Issues',
727
+ description: 'Require JSDoc comments',
728
+ recommended: true,
729
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header',
730
+ },
731
+
732
+ fixable: 'code',
733
+
734
+ messages: {
735
+ missingJsDoc: 'Missing JSDoc comment.',
736
+ },
737
+
738
+ schema: [
739
+ OPTIONS_SCHEMA,
740
+ ],
741
+
742
+ type: 'suggestion',
743
+ },
744
+ };