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
@@ -1,405 +1,578 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_hasReturnValue = require('../utils/hasReturnValue.cjs');
3
- const require_jsdocUtils = require('../jsdocUtils.cjs');
4
- const require_iterateJsdoc = require('../iterateJsdoc.cjs');
5
- const require_exportParser = require('../exportParser.cjs');
6
- const __es_joy_jsdoccomment = require_rolldown_runtime.__toESM(require("@es-joy/jsdoccomment"));
1
+ "use strict";
7
2
 
8
- //#region src/rules/requireJsdoc.js
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _exportParser = _interopRequireDefault(require("../exportParser.cjs"));
8
+ var _iterateJsdoc = require("../iterateJsdoc.cjs");
9
+ var _jsdocUtils = require("../jsdocUtils.cjs");
10
+ var _jsdoccomment = require("@es-joy/jsdoccomment");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
12
  /**
10
- * @typedef {{
11
- * ancestorsOnly: boolean,
12
- * esm: boolean,
13
- * initModuleExports: boolean,
14
- * initWindow: boolean
15
- * }} RequireJsdocOpts
16
- */
13
+ * @typedef {{
14
+ * ancestorsOnly: boolean,
15
+ * esm: boolean,
16
+ * initModuleExports: boolean,
17
+ * initWindow: boolean
18
+ * }} RequireJsdocOpts
19
+ */
20
+
17
21
  /**
18
- * @typedef {import('eslint').Rule.Node|
19
- * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
20
- */
22
+ * @typedef {import('eslint').Rule.Node|
23
+ * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
24
+ */
25
+
21
26
  /** @type {import('json-schema').JSONSchema4} */
22
27
  const OPTIONS_SCHEMA = {
23
- additionalProperties: false,
24
- properties: {
25
- checkConstructors: {
26
- default: true,
27
- type: "boolean"
28
- },
29
- checkGetters: {
30
- anyOf: [{ type: "boolean" }, {
31
- enum: ["no-setter"],
32
- type: "string"
33
- }],
34
- default: true
35
- },
36
- checkSetters: {
37
- anyOf: [{ type: "boolean" }, {
38
- enum: ["no-getter"],
39
- type: "string"
40
- }],
41
- default: true
42
- },
43
- contexts: {
44
- items: { anyOf: [{ type: "string" }, {
45
- additionalProperties: false,
46
- properties: {
47
- context: { type: "string" },
48
- inlineCommentBlock: { type: "boolean" },
49
- minLineCount: { type: "integer" }
50
- },
51
- type: "object"
52
- }] },
53
- type: "array"
54
- },
55
- enableFixer: {
56
- default: true,
57
- type: "boolean"
58
- },
59
- exemptEmptyConstructors: {
60
- default: false,
61
- type: "boolean"
62
- },
63
- exemptEmptyFunctions: {
64
- default: false,
65
- type: "boolean"
66
- },
67
- fixerMessage: {
68
- default: "",
69
- type: "string"
70
- },
71
- minLineCount: { type: "integer" },
72
- publicOnly: { oneOf: [{
73
- default: false,
74
- type: "boolean"
75
- }, {
76
- additionalProperties: false,
77
- default: {},
78
- properties: {
79
- ancestorsOnly: { type: "boolean" },
80
- cjs: { type: "boolean" },
81
- esm: { type: "boolean" },
82
- window: { type: "boolean" }
83
- },
84
- type: "object"
85
- }] },
86
- require: {
87
- additionalProperties: false,
88
- default: {},
89
- properties: {
90
- ArrowFunctionExpression: {
91
- default: false,
92
- type: "boolean"
93
- },
94
- ClassDeclaration: {
95
- default: false,
96
- type: "boolean"
97
- },
98
- ClassExpression: {
99
- default: false,
100
- type: "boolean"
101
- },
102
- FunctionDeclaration: {
103
- default: true,
104
- type: "boolean"
105
- },
106
- FunctionExpression: {
107
- default: false,
108
- type: "boolean"
109
- },
110
- MethodDefinition: {
111
- default: false,
112
- type: "boolean"
113
- }
114
- },
115
- type: "object"
116
- }
117
- },
118
- type: "object"
28
+ additionalProperties: false,
29
+ properties: {
30
+ checkConstructors: {
31
+ default: true,
32
+ type: 'boolean'
33
+ },
34
+ checkGetters: {
35
+ anyOf: [{
36
+ type: 'boolean'
37
+ }, {
38
+ enum: ['no-setter'],
39
+ type: 'string'
40
+ }],
41
+ default: true
42
+ },
43
+ checkSetters: {
44
+ anyOf: [{
45
+ type: 'boolean'
46
+ }, {
47
+ enum: ['no-getter'],
48
+ type: 'string'
49
+ }],
50
+ default: true
51
+ },
52
+ contexts: {
53
+ items: {
54
+ anyOf: [{
55
+ type: 'string'
56
+ }, {
57
+ additionalProperties: false,
58
+ properties: {
59
+ context: {
60
+ type: 'string'
61
+ },
62
+ inlineCommentBlock: {
63
+ type: 'boolean'
64
+ },
65
+ minLineCount: {
66
+ type: 'integer'
67
+ }
68
+ },
69
+ type: 'object'
70
+ }]
71
+ },
72
+ type: 'array'
73
+ },
74
+ enableFixer: {
75
+ default: true,
76
+ type: 'boolean'
77
+ },
78
+ exemptEmptyConstructors: {
79
+ default: false,
80
+ type: 'boolean'
81
+ },
82
+ exemptEmptyFunctions: {
83
+ default: false,
84
+ type: 'boolean'
85
+ },
86
+ fixerMessage: {
87
+ default: '',
88
+ type: 'string'
89
+ },
90
+ minLineCount: {
91
+ type: 'integer'
92
+ },
93
+ publicOnly: {
94
+ oneOf: [{
95
+ default: false,
96
+ type: 'boolean'
97
+ }, {
98
+ additionalProperties: false,
99
+ default: {},
100
+ properties: {
101
+ ancestorsOnly: {
102
+ type: 'boolean'
103
+ },
104
+ cjs: {
105
+ type: 'boolean'
106
+ },
107
+ esm: {
108
+ type: 'boolean'
109
+ },
110
+ window: {
111
+ type: 'boolean'
112
+ }
113
+ },
114
+ type: 'object'
115
+ }]
116
+ },
117
+ require: {
118
+ additionalProperties: false,
119
+ default: {},
120
+ properties: {
121
+ ArrowFunctionExpression: {
122
+ default: false,
123
+ type: 'boolean'
124
+ },
125
+ ClassDeclaration: {
126
+ default: false,
127
+ type: 'boolean'
128
+ },
129
+ ClassExpression: {
130
+ default: false,
131
+ type: 'boolean'
132
+ },
133
+ FunctionDeclaration: {
134
+ default: true,
135
+ type: 'boolean'
136
+ },
137
+ FunctionExpression: {
138
+ default: false,
139
+ type: 'boolean'
140
+ },
141
+ MethodDefinition: {
142
+ default: false,
143
+ type: 'boolean'
144
+ }
145
+ },
146
+ type: 'object'
147
+ }
148
+ },
149
+ type: 'object'
119
150
  };
151
+
120
152
  /**
121
- * @param {string} interfaceName
122
- * @param {string} methodName
123
- * @param {import("eslint").Scope.Scope | null} scope
124
- * @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
125
- */
153
+ * @param {string} interfaceName
154
+ * @param {string} methodName
155
+ * @param {import("eslint").Scope.Scope | null} scope
156
+ * @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
157
+ */
126
158
  const getMethodOnInterface = (interfaceName, methodName, scope) => {
127
- let scp = scope;
128
- while (scp) {
129
- for (const { identifiers, name } of scp.variables) {
130
- if (interfaceName !== name) continue;
131
- for (const identifier of identifiers) {
132
- const interfaceDeclaration = identifier.parent;
133
- /* c8 ignore next 3 -- TS */
134
- if (interfaceDeclaration.type !== "TSInterfaceDeclaration") continue;
135
- for (const bodyItem of interfaceDeclaration.body.body) {
136
- const methodSig = bodyItem;
137
- if (methodName === methodSig.key.name) return methodSig;
138
- }
139
- }
140
- }
141
- scp = scp.upper;
142
- }
143
- return null;
159
+ let scp = scope;
160
+ while (scp) {
161
+ for (const {
162
+ identifiers,
163
+ name
164
+ } of scp.variables) {
165
+ if (interfaceName !== name) {
166
+ continue;
167
+ }
168
+ for (const identifier of identifiers) {
169
+ const interfaceDeclaration = /** @type {import('@typescript-eslint/types').TSESTree.Identifier & {parent: import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration}} */identifier.parent;
170
+ /* c8 ignore next 3 -- TS */
171
+ if (interfaceDeclaration.type !== 'TSInterfaceDeclaration') {
172
+ continue;
173
+ }
174
+ for (const bodyItem of interfaceDeclaration.body.body) {
175
+ const methodSig = /** @type {import('@typescript-eslint/types').TSESTree.TSMethodSignature} */
176
+ bodyItem;
177
+ if (methodName === /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */methodSig.key.name) {
178
+ return methodSig;
179
+ }
180
+ }
181
+ }
182
+ }
183
+ scp = scp.upper;
184
+ }
185
+ return null;
144
186
  };
187
+
145
188
  /**
146
- * @param {import('eslint').Rule.Node} node
147
- * @param {import('eslint').SourceCode} sourceCode
148
- * @param {import('eslint').Rule.RuleContext} context
149
- * @param {import('../iterateJsdoc.js').Settings} settings
150
- */
189
+ * @param {import('eslint').Rule.Node} node
190
+ * @param {import('eslint').SourceCode} sourceCode
191
+ * @param {import('eslint').Rule.RuleContext} context
192
+ * @param {import('../iterateJsdoc.js').Settings} settings
193
+ */
151
194
  const isExemptedImplementer = (node, sourceCode, context, settings) => {
152
- if (node.type === "FunctionExpression" && node.parent.type === "MethodDefinition" && node.parent.parent.type === "ClassBody" && node.parent.parent.parent.type === "ClassDeclaration" && "implements" in node.parent.parent.parent) {
153
- const implments = node.parent.parent.parent.implements;
154
- const { name: methodName } = node.parent.key;
155
- for (const impl of implments) {
156
- const { name: interfaceName } = impl.expression;
157
- const interfaceMethodNode = getMethodOnInterface(interfaceName, methodName, node && (sourceCode.getScope && sourceCode.getScope(node) || context.getScope()));
158
- if (interfaceMethodNode) {
159
- const comment = (0, __es_joy_jsdoccomment.getJSDocComment)(sourceCode, interfaceMethodNode, settings);
160
- if (comment) return true;
161
- }
162
- }
163
- }
164
- return false;
195
+ if (node.type === 'FunctionExpression' && node.parent.type === 'MethodDefinition' && node.parent.parent.type === 'ClassBody' && node.parent.parent.parent.type === 'ClassDeclaration' && 'implements' in node.parent.parent.parent) {
196
+ const implments = /** @type {import('@typescript-eslint/types').TSESTree.TSClassImplements[]} */
197
+ node.parent.parent.parent.implements;
198
+ const {
199
+ name: methodName
200
+ } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
201
+ node.parent.key;
202
+ for (const impl of implments) {
203
+ const {
204
+ name: interfaceName
205
+ } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
206
+ impl.expression;
207
+ const interfaceMethodNode = getMethodOnInterface(interfaceName, methodName, node && (sourceCode.getScope && /* c8 ignore next 2 */
208
+ sourceCode.getScope(node) || context.getScope()));
209
+ if (interfaceMethodNode) {
210
+ // @ts-expect-error Ok
211
+ const comment = (0, _jsdoccomment.getJSDocComment)(sourceCode, interfaceMethodNode, settings);
212
+ if (comment) {
213
+ return true;
214
+ }
215
+ }
216
+ }
217
+ }
218
+ return false;
165
219
  };
220
+
166
221
  /**
167
- * @param {import('eslint').Rule.RuleContext} context
168
- * @param {import('json-schema').JSONSchema4Object} baseObject
169
- * @param {string} option
170
- * @param {string} key
171
- * @returns {boolean|undefined}
172
- */
222
+ * @param {import('eslint').Rule.RuleContext} context
223
+ * @param {import('json-schema').JSONSchema4Object} baseObject
224
+ * @param {string} option
225
+ * @param {string} key
226
+ * @returns {boolean|undefined}
227
+ */
173
228
  const getOption = (context, baseObject, option, key) => {
174
- if (context.options[0] && option in context.options[0] && (typeof context.options[0][option] === "boolean" || key in context.options[0][option])) return context.options[0][option][key];
175
- return baseObject.properties[key].default;
229
+ if (context.options[0] && option in context.options[0] && (
230
+ // Todo: boolean shouldn't be returning property, but
231
+ // tests currently require
232
+ typeof context.options[0][option] === 'boolean' || key in context.options[0][option])) {
233
+ return context.options[0][option][key];
234
+ }
235
+ return /** @type {{[key: string]: {default?: boolean|undefined}}} */baseObject.properties[key].default;
176
236
  };
237
+
177
238
  /**
178
- * @param {import('eslint').Rule.RuleContext} context
179
- * @param {import('../iterateJsdoc.js').Settings} settings
180
- * @returns {{
181
- * contexts: (string|{
182
- * context: string,
183
- * inlineCommentBlock: boolean,
184
- * minLineCount: import('../iterateJsdoc.js').Integer
185
- * })[],
186
- * enableFixer: boolean,
187
- * exemptEmptyConstructors: boolean,
188
- * exemptEmptyFunctions: boolean,
189
- * fixerMessage: string,
190
- * minLineCount: undefined|import('../iterateJsdoc.js').Integer,
191
- * publicOnly: boolean|{[key: string]: boolean|undefined}
192
- * require: {[key: string]: boolean|undefined}
193
- * }}
194
- */
239
+ * @param {import('eslint').Rule.RuleContext} context
240
+ * @param {import('../iterateJsdoc.js').Settings} settings
241
+ * @returns {{
242
+ * contexts: (string|{
243
+ * context: string,
244
+ * inlineCommentBlock: boolean,
245
+ * minLineCount: import('../iterateJsdoc.js').Integer
246
+ * })[],
247
+ * enableFixer: boolean,
248
+ * exemptEmptyConstructors: boolean,
249
+ * exemptEmptyFunctions: boolean,
250
+ * fixerMessage: string,
251
+ * minLineCount: undefined|import('../iterateJsdoc.js').Integer,
252
+ * publicOnly: boolean|{[key: string]: boolean|undefined}
253
+ * require: {[key: string]: boolean|undefined}
254
+ * }}
255
+ */
195
256
  const getOptions = (context, settings) => {
196
- const { contexts = settings.contexts || [], enableFixer = true, exemptEmptyConstructors = true, exemptEmptyFunctions = false, fixerMessage = "", minLineCount = void 0, publicOnly } = context.options[0] || {};
197
- return {
198
- contexts,
199
- enableFixer,
200
- exemptEmptyConstructors,
201
- exemptEmptyFunctions,
202
- fixerMessage,
203
- minLineCount,
204
- publicOnly: ((baseObj) => {
205
- if (!publicOnly) return false;
206
- /** @type {{[key: string]: boolean|undefined}} */
207
- const properties = {};
208
- for (const prop of Object.keys(
209
- /** @type {import('json-schema').JSONSchema4Object} */
210
- baseObj.properties
211
- )) {
212
- const opt = getOption(context, baseObj, "publicOnly", prop);
213
- properties[prop] = opt;
214
- }
215
- return properties;
216
- })(
217
- /** @type {import('json-schema').JSONSchema4Object} */
218
- OPTIONS_SCHEMA.properties.publicOnly.oneOf[1]
219
- ),
220
- require: ((baseObj) => {
221
- /** @type {{[key: string]: boolean|undefined}} */
222
- const properties = {};
223
- for (const prop of Object.keys(
224
- /** @type {import('json-schema').JSONSchema4Object} */
225
- baseObj.properties
226
- )) {
227
- const opt = getOption(context, baseObj, "require", prop);
228
- properties[prop] = opt;
229
- }
230
- return properties;
231
- })(
232
- /** @type {import('json-schema').JSONSchema4Object} */
233
- OPTIONS_SCHEMA.properties.require
234
- )
235
- };
257
+ const {
258
+ contexts = settings.contexts || [],
259
+ enableFixer = true,
260
+ exemptEmptyConstructors = true,
261
+ exemptEmptyFunctions = false,
262
+ fixerMessage = '',
263
+ minLineCount = undefined,
264
+ publicOnly
265
+ } = context.options[0] || {};
266
+ return {
267
+ contexts,
268
+ enableFixer,
269
+ exemptEmptyConstructors,
270
+ exemptEmptyFunctions,
271
+ fixerMessage,
272
+ minLineCount,
273
+ publicOnly: (baseObj => {
274
+ if (!publicOnly) {
275
+ return false;
276
+ }
277
+
278
+ /** @type {{[key: string]: boolean|undefined}} */
279
+ const properties = {};
280
+ for (const prop of Object.keys(/** @type {import('json-schema').JSONSchema4Object} */
281
+ /** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) {
282
+ const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */baseObj, 'publicOnly', prop);
283
+ properties[prop] = opt;
284
+ }
285
+ return properties;
286
+ })(/** @type {import('json-schema').JSONSchema4Object} */
287
+ (/** @type {import('json-schema').JSONSchema4Object} */
288
+ (/** @type {import('json-schema').JSONSchema4Object} */
289
+ OPTIONS_SCHEMA.properties.publicOnly).oneOf)[1]),
290
+ require: (baseObj => {
291
+ /** @type {{[key: string]: boolean|undefined}} */
292
+ const properties = {};
293
+ for (const prop of Object.keys(/** @type {import('json-schema').JSONSchema4Object} */
294
+ /** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) {
295
+ const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */
296
+ baseObj, 'require', prop);
297
+ properties[prop] = opt;
298
+ }
299
+ return properties;
300
+ })(/** @type {import('json-schema').JSONSchema4Object} */
301
+ OPTIONS_SCHEMA.properties.require)
302
+ };
236
303
  };
304
+
237
305
  /** @type {import('eslint').Rule.RuleModule} */
238
- var requireJsdoc_default = {
239
- create(context) {
240
- /* c8 ignore next -- Fallback to deprecated method */
241
- const { sourceCode = context.getSourceCode() } = context;
242
- const settings = require_iterateJsdoc.getSettings(context);
243
- if (!settings) return {};
244
- const opts = getOptions(context, settings);
245
- const { contexts, enableFixer, exemptEmptyConstructors, exemptEmptyFunctions, fixerMessage, minLineCount, require: requireOption } = opts;
246
- const publicOnly = opts.publicOnly;
247
- /**
248
- * @type {import('../iterateJsdoc.js').CheckJsdoc}
249
- */
250
- const checkJsDoc = (info, _handler, node) => {
251
- if (minLineCount !== void 0 || contexts.some((ctxt) => {
252
- if (typeof ctxt === "string") return false;
253
- const { minLineCount: count } = ctxt;
254
- return count !== void 0;
255
- })) {
256
- /**
257
- * @param {undefined|import('../iterateJsdoc.js').Integer} count
258
- */
259
- const underMinLine = (count) => {
260
- return count !== void 0 && count > (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
261
- };
262
- if (underMinLine(minLineCount)) return;
263
- const { minLineCount: contextMinLineCount } = contexts.find((ctxt) => {
264
- if (typeof ctxt === "string") return false;
265
- const { context: ctx } = ctxt;
266
- return ctx === (info.selector || node.type);
267
- }) || {};
268
- if (underMinLine(contextMinLineCount)) return;
269
- }
270
- const jsDocNode = (0, __es_joy_jsdoccomment.getJSDocComment)(sourceCode, node, settings);
271
- if (jsDocNode) return;
272
- if (require_jsdocUtils.exemptSpeciaMethods({
273
- description: "",
274
- inlineTags: [],
275
- problems: [],
276
- source: [],
277
- tags: []
278
- }, node, context, [OPTIONS_SCHEMA])) return;
279
- if (exemptEmptyFunctions && info.isFunctionContext || exemptEmptyConstructors && require_jsdocUtils.isConstructor(node)) {
280
- const functionParameterNames = require_jsdocUtils.getFunctionParameterNames(node);
281
- if (!functionParameterNames.length && !require_hasReturnValue.hasReturnValue(node)) return;
282
- }
283
- if (isExemptedImplementer(node, sourceCode, context, settings)) return;
284
- const fix = (fixer) => {
285
- const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
286
- /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
287
- let baseNode = (0, __es_joy_jsdoccomment.getReducedASTNode)(node, sourceCode);
288
- const decorator = (0, __es_joy_jsdoccomment.getDecorator)(baseNode);
289
- if (decorator) baseNode = decorator;
290
- const indent = require_jsdocUtils.getIndent({ text: sourceCode.getText(
291
- baseNode,
292
- /** @type {import('eslint').AST.SourceLocation} */
293
- baseNode.loc.start.column
294
- ) });
295
- const { inlineCommentBlock } = contexts.find((contxt) => {
296
- if (typeof contxt === "string") return false;
297
- const { context: ctxt } = contxt;
298
- return ctxt === node.type;
299
- }) || {};
300
- const insertion = (inlineCommentBlock ? `/** ${fixerMessage}` : `/**\n${indent}*${fixerMessage}\n${indent}`) + `*/${"\n".repeat(lines)}${indent.slice(0, -1)}`;
301
- return fixer.insertTextBefore(baseNode, insertion);
302
- };
303
- const report = () => {
304
- const { start } = node.loc;
305
- const loc = {
306
- end: {
307
- column: 0,
308
- line: start.line + 1
309
- },
310
- start
311
- };
312
- context.report({
313
- fix: enableFixer ? fix : null,
314
- loc,
315
- messageId: "missingJsDoc",
316
- node
317
- });
318
- };
319
- if (publicOnly) {
320
- /** @type {RequireJsdocOpts} */
321
- const opt = {
322
- ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
323
- esm: Boolean(publicOnly?.esm ?? true),
324
- initModuleExports: Boolean(publicOnly?.cjs ?? true),
325
- initWindow: Boolean(publicOnly?.window ?? false)
326
- };
327
- const exported = require_exportParser.default.isUncommentedExport(node, sourceCode, opt, settings);
328
- if (exported) report();
329
- } else report();
330
- };
331
- /**
332
- * @param {string} prop
333
- * @returns {boolean}
334
- */
335
- const hasOption = (prop) => {
336
- return requireOption[prop] || contexts.some((ctxt) => {
337
- return typeof ctxt === "object" ? ctxt.context === prop : ctxt === prop;
338
- });
339
- };
340
- return {
341
- ...require_jsdocUtils.getContextObject(require_jsdocUtils.enforcedContexts(context, [], settings), checkJsDoc),
342
- ArrowFunctionExpression(node) {
343
- if (!hasOption("ArrowFunctionExpression")) return;
344
- if ([
345
- "AssignmentExpression",
346
- "ExportDefaultDeclaration",
347
- "VariableDeclarator"
348
- ].includes(node.parent.type) || [
349
- "ClassProperty",
350
- "ObjectProperty",
351
- "Property",
352
- "PropertyDefinition"
353
- ].includes(node.parent.type) && node === node.parent.value) checkJsDoc({ isFunctionContext: true }, null, node);
354
- },
355
- ClassDeclaration(node) {
356
- if (!hasOption("ClassDeclaration")) return;
357
- checkJsDoc({ isFunctionContext: false }, null, node);
358
- },
359
- ClassExpression(node) {
360
- if (!hasOption("ClassExpression")) return;
361
- checkJsDoc({ isFunctionContext: false }, null, node);
362
- },
363
- FunctionDeclaration(node) {
364
- if (!hasOption("FunctionDeclaration")) return;
365
- checkJsDoc({ isFunctionContext: true }, null, node);
366
- },
367
- FunctionExpression(node) {
368
- if (!hasOption("FunctionExpression")) return;
369
- if ([
370
- "AssignmentExpression",
371
- "ExportDefaultDeclaration",
372
- "VariableDeclarator"
373
- ].includes(node.parent.type) || [
374
- "ClassProperty",
375
- "ObjectProperty",
376
- "Property",
377
- "PropertyDefinition"
378
- ].includes(node.parent.type) && node === node.parent.value) checkJsDoc({ isFunctionContext: true }, null, node);
379
- },
380
- MethodDefinition(node) {
381
- if (!hasOption("MethodDefinition")) return;
382
- checkJsDoc({
383
- isFunctionContext: true,
384
- selector: "MethodDefinition"
385
- }, null, node.value);
386
- }
387
- };
388
- },
389
- meta: {
390
- docs: {
391
- category: "Stylistic Issues",
392
- description: "Require JSDoc comments",
393
- recommended: true,
394
- url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header"
395
- },
396
- fixable: "code",
397
- messages: { missingJsDoc: "Missing JSDoc comment." },
398
- schema: [OPTIONS_SCHEMA],
399
- type: "suggestion"
400
- }
401
- };
306
+ var _default = exports.default = {
307
+ create(context) {
308
+ /* c8 ignore next -- Fallback to deprecated method */
309
+ const {
310
+ sourceCode = context.getSourceCode()
311
+ } = context;
312
+ const settings = (0, _iterateJsdoc.getSettings)(context);
313
+ if (!settings) {
314
+ return {};
315
+ }
316
+ const opts = getOptions(context, settings);
317
+ const {
318
+ contexts,
319
+ enableFixer,
320
+ exemptEmptyConstructors,
321
+ exemptEmptyFunctions,
322
+ fixerMessage,
323
+ minLineCount,
324
+ require: requireOption
325
+ } = opts;
326
+ const publicOnly =
327
+ /**
328
+ * @type {{
329
+ * [key: string]: boolean | undefined;
330
+ * }}
331
+ */
332
+ opts.publicOnly;
402
333
 
403
- //#endregion
404
- exports.default = requireJsdoc_default;
334
+ /**
335
+ * @type {import('../iterateJsdoc.js').CheckJsdoc}
336
+ */
337
+ const checkJsDoc = (info, _handler, node) => {
338
+ if (
339
+ // Optimize
340
+ minLineCount !== undefined || contexts.some(ctxt => {
341
+ if (typeof ctxt === 'string') {
342
+ return false;
343
+ }
344
+ const {
345
+ minLineCount: count
346
+ } = ctxt;
347
+ return count !== undefined;
348
+ })) {
349
+ /**
350
+ * @param {undefined|import('../iterateJsdoc.js').Integer} count
351
+ */
352
+ const underMinLine = count => {
353
+ return count !== undefined && count > (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
354
+ };
355
+ if (underMinLine(minLineCount)) {
356
+ return;
357
+ }
358
+ const {
359
+ minLineCount: contextMinLineCount
360
+ } =
361
+ /**
362
+ * @type {{
363
+ * context: string;
364
+ * inlineCommentBlock: boolean;
365
+ * minLineCount: number;
366
+ * }}
367
+ */
368
+ contexts.find(ctxt => {
369
+ if (typeof ctxt === 'string') {
370
+ return false;
371
+ }
372
+ const {
373
+ context: ctx
374
+ } = ctxt;
375
+ return ctx === (info.selector || node.type);
376
+ }) || {};
377
+ if (underMinLine(contextMinLineCount)) {
378
+ return;
379
+ }
380
+ }
381
+ const jsDocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings);
382
+ if (jsDocNode) {
383
+ return;
384
+ }
385
+
386
+ // For those who have options configured against ANY constructors (or
387
+ // setters or getters) being reported
388
+ if ((0, _jsdocUtils.exemptSpeciaMethods)({
389
+ description: '',
390
+ inlineTags: [],
391
+ problems: [],
392
+ source: [],
393
+ tags: []
394
+ }, node, context, [OPTIONS_SCHEMA])) {
395
+ return;
396
+ }
397
+ if (
398
+ // Avoid reporting param-less, return-less functions (when
399
+ // `exemptEmptyFunctions` option is set)
400
+ exemptEmptyFunctions && info.isFunctionContext ||
401
+ // Avoid reporting param-less, return-less constructor methods (when
402
+ // `exemptEmptyConstructors` option is set)
403
+ exemptEmptyConstructors && (0, _jsdocUtils.isConstructor)(node)) {
404
+ const functionParameterNames = (0, _jsdocUtils.getFunctionParameterNames)(node);
405
+ if (!functionParameterNames.length && !(0, _jsdocUtils.hasReturnValue)(node)) {
406
+ return;
407
+ }
408
+ }
409
+ if (isExemptedImplementer(node, sourceCode, context, settings)) {
410
+ return;
411
+ }
412
+ const fix = /** @type {import('eslint').Rule.ReportFixer} */fixer => {
413
+ // Default to one line break if the `minLines`/`maxLines` settings allow
414
+ const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
415
+ /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
416
+ let baseNode = (0, _jsdoccomment.getReducedASTNode)(node, sourceCode);
417
+ const decorator = (0, _jsdoccomment.getDecorator)(/** @type {import('eslint').Rule.Node} */
418
+ baseNode);
419
+ if (decorator) {
420
+ baseNode = decorator;
421
+ }
422
+ const indent = (0, _jsdocUtils.getIndent)({
423
+ text: sourceCode.getText(/** @type {import('eslint').Rule.Node} */baseNode, /** @type {import('eslint').AST.SourceLocation} */
424
+ (/** @type {import('eslint').Rule.Node} */baseNode.loc).start.column)
425
+ });
426
+ const {
427
+ inlineCommentBlock
428
+ } =
429
+ /**
430
+ * @type {{
431
+ * context: string,
432
+ * inlineCommentBlock: boolean,
433
+ * minLineCount: import('../iterateJsdoc.js').Integer
434
+ * }}
435
+ */
436
+ contexts.find(contxt => {
437
+ if (typeof contxt === 'string') {
438
+ return false;
439
+ }
440
+ const {
441
+ context: ctxt
442
+ } = contxt;
443
+ return ctxt === node.type;
444
+ }) || {};
445
+ const insertion = (inlineCommentBlock ? `/** ${fixerMessage}` : `/**\n${indent}*${fixerMessage}\n${indent}`) + `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`;
446
+ return fixer.insertTextBefore(/** @type {import('eslint').Rule.Node} */
447
+ baseNode, insertion);
448
+ };
449
+ const report = () => {
450
+ const {
451
+ start
452
+ } = /** @type {import('eslint').AST.SourceLocation} */node.loc;
453
+ const loc = {
454
+ end: {
455
+ column: 0,
456
+ line: start.line + 1
457
+ },
458
+ start
459
+ };
460
+ context.report({
461
+ fix: enableFixer ? fix : null,
462
+ loc,
463
+ messageId: 'missingJsDoc',
464
+ node
465
+ });
466
+ };
467
+ if (publicOnly) {
468
+ /** @type {RequireJsdocOpts} */
469
+ const opt = {
470
+ ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
471
+ esm: Boolean(publicOnly?.esm ?? true),
472
+ initModuleExports: Boolean(publicOnly?.cjs ?? true),
473
+ initWindow: Boolean(publicOnly?.window ?? false)
474
+ };
475
+ const exported = _exportParser.default.isUncommentedExport(node, sourceCode, opt, settings);
476
+ if (exported) {
477
+ report();
478
+ }
479
+ } else {
480
+ report();
481
+ }
482
+ };
483
+
484
+ /**
485
+ * @param {string} prop
486
+ * @returns {boolean}
487
+ */
488
+ const hasOption = prop => {
489
+ return requireOption[prop] || contexts.some(ctxt => {
490
+ return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop;
491
+ });
492
+ };
493
+ return {
494
+ ...(0, _jsdocUtils.getContextObject)((0, _jsdocUtils.enforcedContexts)(context, [], settings), checkJsDoc),
495
+ ArrowFunctionExpression(node) {
496
+ if (!hasOption('ArrowFunctionExpression')) {
497
+ return;
498
+ }
499
+ if (['AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator'].includes(node.parent.type) || ['ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition'].includes(node.parent.type) && node ===
500
+ /**
501
+ * @type {import('@typescript-eslint/types').TSESTree.Property|
502
+ * import('@typescript-eslint/types').TSESTree.PropertyDefinition
503
+ * }
504
+ */
505
+ node.parent.value) {
506
+ checkJsDoc({
507
+ isFunctionContext: true
508
+ }, null, node);
509
+ }
510
+ },
511
+ ClassDeclaration(node) {
512
+ if (!hasOption('ClassDeclaration')) {
513
+ return;
514
+ }
515
+ checkJsDoc({
516
+ isFunctionContext: false
517
+ }, null, node);
518
+ },
519
+ ClassExpression(node) {
520
+ if (!hasOption('ClassExpression')) {
521
+ return;
522
+ }
523
+ checkJsDoc({
524
+ isFunctionContext: false
525
+ }, null, node);
526
+ },
527
+ FunctionDeclaration(node) {
528
+ if (!hasOption('FunctionDeclaration')) {
529
+ return;
530
+ }
531
+ checkJsDoc({
532
+ isFunctionContext: true
533
+ }, null, node);
534
+ },
535
+ FunctionExpression(node) {
536
+ if (!hasOption('FunctionExpression')) {
537
+ return;
538
+ }
539
+ if (['AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator'].includes(node.parent.type) || ['ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition'].includes(node.parent.type) && node ===
540
+ /**
541
+ * @type {import('@typescript-eslint/types').TSESTree.Property|
542
+ * import('@typescript-eslint/types').TSESTree.PropertyDefinition
543
+ * }
544
+ */
545
+ node.parent.value) {
546
+ checkJsDoc({
547
+ isFunctionContext: true
548
+ }, null, node);
549
+ }
550
+ },
551
+ MethodDefinition(node) {
552
+ if (!hasOption('MethodDefinition')) {
553
+ return;
554
+ }
555
+ checkJsDoc({
556
+ isFunctionContext: true,
557
+ selector: 'MethodDefinition'
558
+ }, null, /** @type {import('eslint').Rule.Node} */node.value);
559
+ }
560
+ };
561
+ },
562
+ meta: {
563
+ docs: {
564
+ category: 'Stylistic Issues',
565
+ description: 'Require JSDoc comments',
566
+ recommended: true,
567
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header'
568
+ },
569
+ fixable: 'code',
570
+ messages: {
571
+ missingJsDoc: 'Missing JSDoc comment.'
572
+ },
573
+ schema: [OPTIONS_SCHEMA],
574
+ type: 'suggestion'
575
+ }
576
+ };
577
+ module.exports = exports.default;
405
578
  //# sourceMappingURL=requireJsdoc.cjs.map