eslint-plugin-jsdoc 53.0.0 → 54.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 (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 +2005 -1528
  22. package/dist/iterateJsdoc.cjs.map +1 -1
  23. package/dist/iterateJsdoc.d.ts +350 -358
  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 +388 -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 +557 -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 +24 -40
  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 +2541 -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 +543 -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 +743 -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 -471
  233. package/dist/iterateJsdoc.d.cts.map +0 -1
  234. package/dist/iterateJsdoc.js +0 -1617
  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,743 @@
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 2 */
254
+ sourceCode.getScope(node)) ||
255
+ context.getScope()
256
+ ));
257
+ if (interfaceMethodNode) {
258
+ // @ts-expect-error Ok
259
+ const comment = getJSDocComment(sourceCode, interfaceMethodNode, settings);
260
+ if (comment) {
261
+ return true;
262
+ }
263
+ }
264
+ }
265
+ }
266
+
267
+ return false;
268
+ };
269
+
270
+ /**
271
+ * @param {import('eslint').Rule.RuleContext} context
272
+ * @param {import('json-schema').JSONSchema4Object} baseObject
273
+ * @param {string} option
274
+ * @param {string} key
275
+ * @returns {boolean|undefined}
276
+ */
277
+ const getOption = (context, baseObject, option, key) => {
278
+ if (context.options[0] && option in context.options[0] &&
279
+ // Todo: boolean shouldn't be returning property, but
280
+ // tests currently require
281
+ (typeof context.options[0][option] === 'boolean' ||
282
+ key in context.options[0][option])
283
+ ) {
284
+ return context.options[0][option][key];
285
+ }
286
+
287
+ return /** @type {{[key: string]: {default?: boolean|undefined}}} */ (
288
+ baseObject.properties
289
+ )[key].default;
290
+ };
291
+
292
+ /**
293
+ * @param {import('eslint').Rule.RuleContext} context
294
+ * @param {import('../iterateJsdoc.js').Settings} settings
295
+ * @returns {{
296
+ * contexts: (string|{
297
+ * context: string,
298
+ * inlineCommentBlock: boolean,
299
+ * minLineCount: import('../iterateJsdoc.js').Integer
300
+ * })[],
301
+ * enableFixer: boolean,
302
+ * exemptEmptyConstructors: boolean,
303
+ * exemptEmptyFunctions: boolean,
304
+ * fixerMessage: string,
305
+ * minLineCount: undefined|import('../iterateJsdoc.js').Integer,
306
+ * publicOnly: boolean|{[key: string]: boolean|undefined}
307
+ * require: {[key: string]: boolean|undefined}
308
+ * }}
309
+ */
310
+ const getOptions = (context, settings) => {
311
+ const {
312
+ contexts = settings.contexts || [],
313
+ enableFixer = true,
314
+ exemptEmptyConstructors = true,
315
+ exemptEmptyFunctions = false,
316
+ fixerMessage = '',
317
+ minLineCount = undefined,
318
+ publicOnly,
319
+ } = context.options[0] || {};
320
+
321
+ return {
322
+ contexts,
323
+ enableFixer,
324
+ exemptEmptyConstructors,
325
+ exemptEmptyFunctions,
326
+ fixerMessage,
327
+ minLineCount,
328
+ publicOnly: ((baseObj) => {
329
+ if (!publicOnly) {
330
+ return false;
331
+ }
332
+
333
+ /** @type {{[key: string]: boolean|undefined}} */
334
+ const properties = {};
335
+ for (const prop of Object.keys(
336
+ /** @type {import('json-schema').JSONSchema4Object} */ (
337
+ /** @type {import('json-schema').JSONSchema4Object} */ (
338
+ baseObj
339
+ ).properties),
340
+ )) {
341
+ const opt = getOption(
342
+ context,
343
+ /** @type {import('json-schema').JSONSchema4Object} */ (baseObj),
344
+ 'publicOnly',
345
+ prop,
346
+ );
347
+
348
+ properties[prop] = opt;
349
+ }
350
+
351
+ return properties;
352
+ })(
353
+ /** @type {import('json-schema').JSONSchema4Object} */
354
+ (
355
+ /** @type {import('json-schema').JSONSchema4Object} */
356
+ (
357
+ /** @type {import('json-schema').JSONSchema4Object} */
358
+ (
359
+ OPTIONS_SCHEMA.properties
360
+ ).publicOnly
361
+ ).oneOf
362
+ )[1],
363
+ ),
364
+ require: ((baseObj) => {
365
+ /** @type {{[key: string]: boolean|undefined}} */
366
+ const properties = {};
367
+ for (const prop of Object.keys(
368
+ /** @type {import('json-schema').JSONSchema4Object} */ (
369
+ /** @type {import('json-schema').JSONSchema4Object} */ (
370
+ baseObj
371
+ ).properties),
372
+ )) {
373
+ const opt = getOption(
374
+ context,
375
+ /** @type {import('json-schema').JSONSchema4Object} */
376
+ (baseObj),
377
+ 'require',
378
+ prop,
379
+ );
380
+ properties[prop] = opt;
381
+ }
382
+
383
+ return properties;
384
+ })(
385
+ /** @type {import('json-schema').JSONSchema4Object} */
386
+ (OPTIONS_SCHEMA.properties).require,
387
+ ),
388
+ };
389
+ };
390
+
391
+ /** @type {import('eslint').Rule.RuleModule} */
392
+ export default {
393
+ create (context) {
394
+ /* c8 ignore next -- Fallback to deprecated method */
395
+ const {
396
+ sourceCode = context.getSourceCode(),
397
+ } = context;
398
+ const settings = getSettings(context);
399
+ if (!settings) {
400
+ return {};
401
+ }
402
+
403
+ const opts = getOptions(context, settings);
404
+
405
+ const {
406
+ contexts,
407
+ enableFixer,
408
+ exemptEmptyConstructors,
409
+ exemptEmptyFunctions,
410
+ fixerMessage,
411
+ minLineCount,
412
+ require: requireOption,
413
+ } = opts;
414
+
415
+ const publicOnly =
416
+
417
+ /**
418
+ * @type {{
419
+ * [key: string]: boolean | undefined;
420
+ * }}
421
+ */ (
422
+ opts.publicOnly
423
+ );
424
+
425
+ /**
426
+ * @type {import('../iterateJsdoc.js').CheckJsdoc}
427
+ */
428
+ const checkJsDoc = (info, _handler, node) => {
429
+ if (
430
+ // Optimize
431
+ minLineCount !== undefined || contexts.some((ctxt) => {
432
+ if (typeof ctxt === 'string') {
433
+ return false;
434
+ }
435
+
436
+ const {
437
+ minLineCount: count,
438
+ } = ctxt;
439
+ return count !== undefined;
440
+ })
441
+ ) {
442
+ /**
443
+ * @param {undefined|import('../iterateJsdoc.js').Integer} count
444
+ */
445
+ const underMinLine = (count) => {
446
+ return count !== undefined && count >
447
+ (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
448
+ };
449
+
450
+ if (underMinLine(minLineCount)) {
451
+ return;
452
+ }
453
+
454
+ const {
455
+ minLineCount: contextMinLineCount,
456
+ } =
457
+ /**
458
+ * @type {{
459
+ * context: string;
460
+ * inlineCommentBlock: boolean;
461
+ * minLineCount: number;
462
+ * }}
463
+ */ (contexts.find((ctxt) => {
464
+ if (typeof ctxt === 'string') {
465
+ return false;
466
+ }
467
+
468
+ const {
469
+ context: ctx,
470
+ } = ctxt;
471
+ return ctx === (info.selector || node.type);
472
+ })) || {};
473
+ if (underMinLine(contextMinLineCount)) {
474
+ return;
475
+ }
476
+ }
477
+
478
+ const jsDocNode = getJSDocComment(sourceCode, node, settings);
479
+
480
+ if (jsDocNode) {
481
+ return;
482
+ }
483
+
484
+ // For those who have options configured against ANY constructors (or
485
+ // setters or getters) being reported
486
+ if (exemptSpeciaMethods(
487
+ {
488
+ description: '',
489
+ inlineTags: [],
490
+ problems: [],
491
+ source: [],
492
+ tags: [],
493
+ },
494
+ node,
495
+ context,
496
+ [
497
+ OPTIONS_SCHEMA,
498
+ ],
499
+ )) {
500
+ return;
501
+ }
502
+
503
+ if (
504
+ // Avoid reporting param-less, return-less functions (when
505
+ // `exemptEmptyFunctions` option is set)
506
+ exemptEmptyFunctions && info.isFunctionContext ||
507
+
508
+ // Avoid reporting param-less, return-less constructor methods (when
509
+ // `exemptEmptyConstructors` option is set)
510
+ exemptEmptyConstructors && isConstructor(node)
511
+ ) {
512
+ const functionParameterNames = getFunctionParameterNames(node);
513
+ if (!functionParameterNames.length && !hasReturnValue(node)) {
514
+ return;
515
+ }
516
+ }
517
+
518
+ if (isExemptedImplementer(node, sourceCode, context, settings)) {
519
+ return;
520
+ }
521
+
522
+ const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
523
+ // Default to one line break if the `minLines`/`maxLines` settings allow
524
+ const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
525
+ /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
526
+ let baseNode = getReducedASTNode(node, sourceCode);
527
+
528
+ const decorator = getDecorator(
529
+ /** @type {import('eslint').Rule.Node} */
530
+ (baseNode),
531
+ );
532
+ if (decorator) {
533
+ baseNode = decorator;
534
+ }
535
+
536
+ const indent = getIndent({
537
+ text: sourceCode.getText(
538
+ /** @type {import('eslint').Rule.Node} */ (baseNode),
539
+ /** @type {import('eslint').AST.SourceLocation} */
540
+ (
541
+ /** @type {import('eslint').Rule.Node} */ (baseNode).loc
542
+ ).start.column,
543
+ ),
544
+ });
545
+
546
+ const {
547
+ inlineCommentBlock,
548
+ } =
549
+ /**
550
+ * @type {{
551
+ * context: string,
552
+ * inlineCommentBlock: boolean,
553
+ * minLineCount: import('../iterateJsdoc.js').Integer
554
+ * }}
555
+ */ (contexts.find((contxt) => {
556
+ if (typeof contxt === 'string') {
557
+ return false;
558
+ }
559
+
560
+ const {
561
+ context: ctxt,
562
+ } = contxt;
563
+ return ctxt === node.type;
564
+ })) || {};
565
+ const insertion = (inlineCommentBlock ?
566
+ `/** ${fixerMessage}` :
567
+ `/**\n${indent}*${fixerMessage}\n${indent}`) +
568
+ `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`;
569
+
570
+ return fixer.insertTextBefore(
571
+ /** @type {import('eslint').Rule.Node} */
572
+ (baseNode),
573
+ insertion,
574
+ );
575
+ };
576
+
577
+ const report = () => {
578
+ const {
579
+ start,
580
+ } = /** @type {import('eslint').AST.SourceLocation} */ (node.loc);
581
+ const loc = {
582
+ end: {
583
+ column: 0,
584
+ line: start.line + 1,
585
+ },
586
+ start,
587
+ };
588
+ context.report({
589
+ fix: enableFixer ? fix : null,
590
+ loc,
591
+ messageId: 'missingJsDoc',
592
+ node,
593
+ });
594
+ };
595
+
596
+ if (publicOnly) {
597
+ /** @type {RequireJsdocOpts} */
598
+ const opt = {
599
+ ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
600
+ esm: Boolean(publicOnly?.esm ?? true),
601
+ initModuleExports: Boolean(publicOnly?.cjs ?? true),
602
+ initWindow: Boolean(publicOnly?.window ?? false),
603
+ };
604
+ const exported = exportParser.isUncommentedExport(node, sourceCode, opt, settings);
605
+
606
+ if (exported) {
607
+ report();
608
+ }
609
+ } else {
610
+ report();
611
+ }
612
+ };
613
+
614
+ /**
615
+ * @param {string} prop
616
+ * @returns {boolean}
617
+ */
618
+ const hasOption = (prop) => {
619
+ return requireOption[prop] || contexts.some((ctxt) => {
620
+ return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop;
621
+ });
622
+ };
623
+
624
+ return {
625
+ ...getContextObject(
626
+ enforcedContexts(context, [], settings),
627
+ checkJsDoc,
628
+ ),
629
+ ArrowFunctionExpression (node) {
630
+ if (!hasOption('ArrowFunctionExpression')) {
631
+ return;
632
+ }
633
+
634
+ if (
635
+ [
636
+ 'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
637
+ ].includes(node.parent.type) ||
638
+ [
639
+ 'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
640
+ ].includes(node.parent.type) &&
641
+ node ===
642
+ /**
643
+ * @type {import('@typescript-eslint/types').TSESTree.Property|
644
+ * import('@typescript-eslint/types').TSESTree.PropertyDefinition
645
+ * }
646
+ */
647
+ (node.parent).value
648
+ ) {
649
+ checkJsDoc({
650
+ isFunctionContext: true,
651
+ }, null, node);
652
+ }
653
+ },
654
+
655
+ ClassDeclaration (node) {
656
+ if (!hasOption('ClassDeclaration')) {
657
+ return;
658
+ }
659
+
660
+ checkJsDoc({
661
+ isFunctionContext: false,
662
+ }, null, node);
663
+ },
664
+
665
+ ClassExpression (node) {
666
+ if (!hasOption('ClassExpression')) {
667
+ return;
668
+ }
669
+
670
+ checkJsDoc({
671
+ isFunctionContext: false,
672
+ }, null, node);
673
+ },
674
+
675
+ FunctionDeclaration (node) {
676
+ if (!hasOption('FunctionDeclaration')) {
677
+ return;
678
+ }
679
+
680
+ checkJsDoc({
681
+ isFunctionContext: true,
682
+ }, null, node);
683
+ },
684
+
685
+ FunctionExpression (node) {
686
+ if (!hasOption('FunctionExpression')) {
687
+ return;
688
+ }
689
+
690
+ if (
691
+ [
692
+ 'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
693
+ ].includes(node.parent.type) ||
694
+ [
695
+ 'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
696
+ ].includes(node.parent.type) &&
697
+ node ===
698
+ /**
699
+ * @type {import('@typescript-eslint/types').TSESTree.Property|
700
+ * import('@typescript-eslint/types').TSESTree.PropertyDefinition
701
+ * }
702
+ */
703
+ (node.parent).value
704
+ ) {
705
+ checkJsDoc({
706
+ isFunctionContext: true,
707
+ }, null, node);
708
+ }
709
+ },
710
+
711
+ MethodDefinition (node) {
712
+ if (!hasOption('MethodDefinition')) {
713
+ return;
714
+ }
715
+
716
+ checkJsDoc({
717
+ isFunctionContext: true,
718
+ selector: 'MethodDefinition',
719
+ }, null, /** @type {import('eslint').Rule.Node} */ (node.value));
720
+ },
721
+ };
722
+ },
723
+ meta: {
724
+ docs: {
725
+ category: 'Stylistic Issues',
726
+ description: 'Require JSDoc comments',
727
+ recommended: true,
728
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header',
729
+ },
730
+
731
+ fixable: 'code',
732
+
733
+ messages: {
734
+ missingJsDoc: 'Missing JSDoc comment.',
735
+ },
736
+
737
+ schema: [
738
+ OPTIONS_SCHEMA,
739
+ ],
740
+
741
+ type: 'suggestion',
742
+ },
743
+ };