eslint-plugin-jsdoc 53.0.1 → 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 -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 +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 -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
@@ -1,1160 +1,1527 @@
1
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- const require_getDefaultTagStructureForMode = require('./getDefaultTagStructureForMode.cjs');
3
- const require_tagNames = require('./tagNames.cjs');
4
- const require_WarnSettings = require('./WarnSettings.cjs');
5
- const require_hasReturnValue = require('./utils/hasReturnValue.cjs');
6
- const __es_joy_jsdoccomment = require_rolldown_runtime.__toESM(require("@es-joy/jsdoccomment"));
7
-
8
- //#region src/jsdocUtils.js
9
- var jsdocUtils_exports = {};
10
- require_rolldown_runtime.__export(jsdocUtils_exports, {
11
- comparePaths: () => comparePaths,
12
- dropPathSegmentQuotes: () => dropPathSegmentQuotes,
13
- enforcedContexts: () => enforcedContexts,
14
- exemptSpeciaMethods: () => exemptSpeciaMethods,
15
- filterTags: () => filterTags,
16
- flattenRoots: () => flattenRoots,
17
- forEachPreferredTag: () => forEachPreferredTag,
18
- getAllTags: () => getAllTags,
19
- getContextObject: () => getContextObject,
20
- getFunctionParameterNames: () => getFunctionParameterNames,
21
- getIndent: () => getIndent,
22
- getJsdocTagsDeep: () => getJsdocTagsDeep,
23
- getPreferredTagName: () => getPreferredTagName,
24
- getPreferredTagNameSimple: () => getPreferredTagNameSimple,
25
- getRegexFromString: () => getRegexFromString,
26
- getTagDescription: () => getTagDescription,
27
- getTagStructureForMode: () => getTagStructureForMode,
28
- getTags: () => getTags,
29
- getTagsByType: () => getTagsByType,
30
- hasATag: () => hasATag,
31
- hasParams: () => hasParams,
32
- hasReturnValue: () => require_hasReturnValue.hasReturnValue,
33
- hasTag: () => hasTag,
34
- hasThrowValue: () => hasThrowValue,
35
- hasValueOrExecutorHasNonEmptyResolveValue: () => require_hasReturnValue.hasValueOrExecutorHasNonEmptyResolveValue,
36
- hasYieldValue: () => hasYieldValue,
37
- isConstructor: () => isConstructor,
38
- isGetter: () => isGetter,
39
- isNamepathDefiningTag: () => isNamepathDefiningTag,
40
- isNamepathOrUrlReferencingTag: () => isNamepathOrUrlReferencingTag,
41
- isNamepathReferencingTag: () => isNamepathReferencingTag,
42
- isSetter: () => isSetter,
43
- isValidTag: () => isValidTag,
44
- mayBeUndefinedTypeTag: () => mayBeUndefinedTypeTag,
45
- overrideTagStructure: () => overrideTagStructure,
46
- parseClosureTemplateTag: () => parseClosureTemplateTag,
47
- pathDoesNotBeginWith: () => pathDoesNotBeginWith,
48
- setTagStructure: () => setTagStructure,
49
- tagMightHaveEitherTypeOrNamePosition: () => tagMightHaveEitherTypeOrNamePosition,
50
- tagMightHaveNamePosition: () => tagMightHaveNamePosition,
51
- tagMightHaveNamepath: () => tagMightHaveNamepath,
52
- tagMightHaveTypePosition: () => tagMightHaveTypePosition,
53
- tagMissingRequiredTypeOrNamepath: () => tagMissingRequiredTypeOrNamepath,
54
- tagMustHaveNamePosition: () => tagMustHaveNamePosition,
55
- tagMustHaveTypePosition: () => tagMustHaveTypePosition
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasParams = exports.hasATag = exports.getTagsByType = exports.getTags = exports.getTagStructureForMode = exports.getTagDescription = exports.getRegexFromString = exports.getPreferredTagNameSimple = exports.getPreferredTagName = exports.getJsdocTagsDeep = exports.getIndent = exports.getFunctionParameterNames = exports.getContextObject = exports.getAllTags = exports.forEachPreferredTag = exports.flattenRoots = exports.filterTags = exports.exemptSpeciaMethods = exports.enforcedContexts = exports.dropPathSegmentQuotes = exports.comparePaths = void 0;
7
+ Object.defineProperty(exports, "hasReturnValue", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _hasReturnValue.hasReturnValue;
11
+ }
12
+ });
13
+ exports.hasThrowValue = exports.hasTag = void 0;
14
+ Object.defineProperty(exports, "hasValueOrExecutorHasNonEmptyResolveValue", {
15
+ enumerable: true,
16
+ get: function () {
17
+ return _hasReturnValue.hasValueOrExecutorHasNonEmptyResolveValue;
18
+ }
56
19
  });
20
+ exports.tagMustHaveTypePosition = exports.tagMustHaveNamePosition = exports.tagMissingRequiredTypeOrNamepath = exports.tagMightHaveTypePosition = exports.tagMightHaveNamepath = exports.tagMightHaveNamePosition = exports.tagMightHaveEitherTypeOrNamePosition = exports.setTagStructure = exports.pathDoesNotBeginWith = exports.parseClosureTemplateTag = exports.overrideTagStructure = exports.mayBeUndefinedTypeTag = exports.isValidTag = exports.isSetter = exports.isNamepathReferencingTag = exports.isNamepathOrUrlReferencingTag = exports.isNamepathDefiningTag = exports.isGetter = exports.isConstructor = exports.hasYieldValue = void 0;
21
+ var _getDefaultTagStructureForMode = _interopRequireDefault(require("./getDefaultTagStructureForMode.cjs"));
22
+ var _tagNames = require("./tagNames.cjs");
23
+ var _WarnSettings = _interopRequireDefault(require("./WarnSettings.cjs"));
24
+ var _jsdoccomment = require("@es-joy/jsdoccomment");
25
+ var _hasReturnValue = require("./utils/hasReturnValue.cjs");
26
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
57
27
  /**
58
- * @typedef {number} Integer
59
- */
28
+ * @typedef {number} Integer
29
+ */
60
30
  /**
61
- * @typedef {import('./utils/hasReturnValue.js').ESTreeOrTypeScriptNode} ESTreeOrTypeScriptNode
62
- */
31
+ * @typedef {import('./utils/hasReturnValue.js').ESTreeOrTypeScriptNode} ESTreeOrTypeScriptNode
32
+ */
33
+
63
34
  /**
64
- * @typedef {"jsdoc"|"typescript"|"closure"|"permissive"} ParserMode
65
- */
35
+ * @typedef {"jsdoc"|"typescript"|"closure"|"permissive"} ParserMode
36
+ */
37
+
66
38
  /**
67
- * @type {import('./getDefaultTagStructureForMode.js').TagStructure}
68
- */
39
+ * @type {import('./getDefaultTagStructureForMode.js').TagStructure}
40
+ */
69
41
  let tagStructure;
42
+
70
43
  /**
71
- * @param {ParserMode} mode
72
- * @returns {void}
73
- */
74
- const setTagStructure = (mode) => {
75
- tagStructure = require_getDefaultTagStructureForMode.default(mode);
44
+ * @param {ParserMode} mode
45
+ * @returns {void}
46
+ */
47
+ const setTagStructure = mode => {
48
+ tagStructure = (0, _getDefaultTagStructureForMode.default)(mode);
76
49
  };
50
+
77
51
  /**
78
- * @typedef {undefined|string|{
79
- * name: Integer,
80
- * restElement: boolean
81
- * }|{
82
- * isRestProperty: boolean|undefined,
83
- * name: string,
84
- * restElement: boolean
85
- * }|{
86
- * name: string,
87
- * restElement: boolean
88
- * }} ParamCommon
89
- */
52
+ * @typedef {undefined|string|{
53
+ * name: Integer,
54
+ * restElement: boolean
55
+ * }|{
56
+ * isRestProperty: boolean|undefined,
57
+ * name: string,
58
+ * restElement: boolean
59
+ * }|{
60
+ * name: string,
61
+ * restElement: boolean
62
+ * }} ParamCommon
63
+ */
90
64
  /**
91
- * @typedef {ParamCommon|[string|undefined, (FlattendRootInfo & {
92
- * annotationParamName?: string,
93
- * })]|NestedParamInfo} ParamNameInfo
94
- */
65
+ * @typedef {ParamCommon|[string|undefined, (FlattendRootInfo & {
66
+ * annotationParamName?: string,
67
+ * })]|NestedParamInfo} ParamNameInfo
68
+ */
69
+
95
70
  /**
96
- * @typedef {{
97
- * hasPropertyRest: boolean,
98
- * hasRestElement: boolean,
99
- * names: string[],
100
- * rests: boolean[],
101
- * }} FlattendRootInfo
102
- */
71
+ * @typedef {{
72
+ * hasPropertyRest: boolean,
73
+ * hasRestElement: boolean,
74
+ * names: string[],
75
+ * rests: boolean[],
76
+ * }} FlattendRootInfo
77
+ */
103
78
  /**
104
- * @typedef {[string, (string[]|ParamInfo[])]} NestedParamInfo
105
- */
79
+ * @typedef {[string, (string[]|ParamInfo[])]} NestedParamInfo
80
+ */
106
81
  /**
107
- * @typedef {ParamCommon|
108
- * [string|undefined, (FlattendRootInfo & {
109
- * annotationParamName?: string
110
- * })]|
111
- * NestedParamInfo} ParamInfo
112
- */
82
+ * @typedef {ParamCommon|
83
+ * [string|undefined, (FlattendRootInfo & {
84
+ * annotationParamName?: string
85
+ * })]|
86
+ * NestedParamInfo} ParamInfo
87
+ */
88
+
113
89
  /**
114
- * Given a nested array of property names, reduce them to a single array,
115
- * appending the name of the root element along the way if present.
116
- * @callback FlattenRoots
117
- * @param {ParamInfo[]} params
118
- * @param {string} [root]
119
- * @returns {FlattendRootInfo}
120
- */
90
+ * Given a nested array of property names, reduce them to a single array,
91
+ * appending the name of the root element along the way if present.
92
+ * @callback FlattenRoots
93
+ * @param {ParamInfo[]} params
94
+ * @param {string} [root]
95
+ * @returns {FlattendRootInfo}
96
+ */
97
+
121
98
  /** @type {FlattenRoots} */
122
- const flattenRoots = (params, root = "") => {
123
- let hasRestElement = false;
124
- let hasPropertyRest = false;
125
- /**
126
- * @type {boolean[]}
127
- */
128
- const rests = [];
129
- const names = params.reduce(
130
- /**
131
- * @param {string[]} acc
132
- * @param {ParamInfo} cur
133
- * @returns {string[]}
134
- */
135
- (acc, cur) => {
136
- if (Array.isArray(cur)) {
137
- let nms;
138
- if (Array.isArray(cur[1])) nms = cur[1];
139
- else {
140
- if (cur[1].hasRestElement) hasRestElement = true;
141
- if (cur[1].hasPropertyRest) hasPropertyRest = true;
142
- nms = cur[1].names;
143
- }
144
- const flattened = flattenRoots(nms, root ? `${root}.${cur[0]}` : cur[0]);
145
- if (flattened.hasRestElement) hasRestElement = true;
146
- if (flattened.hasPropertyRest) hasPropertyRest = true;
147
- const inner = [root ? `${root}.${cur[0]}` : cur[0], ...flattened.names].filter(Boolean);
148
- rests.push(false, ...flattened.rests);
149
- return acc.concat(inner);
150
- }
151
- if (typeof cur === "object") {
152
- if ("isRestProperty" in cur && cur.isRestProperty) {
153
- hasPropertyRest = true;
154
- rests.push(true);
155
- } else rests.push(false);
156
- if ("restElement" in cur && cur.restElement) hasRestElement = true;
157
- acc.push(root ? `${root}.${String(cur.name)}` : String(cur.name));
158
- } else if (typeof cur !== "undefined") {
159
- rests.push(false);
160
- acc.push(root ? `${root}.${cur}` : cur);
161
- }
162
- return acc;
163
- },
164
- []
165
- );
166
- return {
167
- hasPropertyRest,
168
- hasRestElement,
169
- names,
170
- rests
171
- };
99
+ exports.setTagStructure = setTagStructure;
100
+ const flattenRoots = (params, root = '') => {
101
+ let hasRestElement = false;
102
+ let hasPropertyRest = false;
103
+
104
+ /**
105
+ * @type {boolean[]}
106
+ */
107
+ const rests = [];
108
+ const names = params.reduce(
109
+ /**
110
+ * @param {string[]} acc
111
+ * @param {ParamInfo} cur
112
+ * @returns {string[]}
113
+ */
114
+ (acc, cur) => {
115
+ if (Array.isArray(cur)) {
116
+ let nms;
117
+ if (Array.isArray(cur[1])) {
118
+ nms = cur[1];
119
+ } else {
120
+ if (cur[1].hasRestElement) {
121
+ hasRestElement = true;
122
+ }
123
+ if (cur[1].hasPropertyRest) {
124
+ hasPropertyRest = true;
125
+ }
126
+ nms = cur[1].names;
127
+ }
128
+ const flattened = flattenRoots(nms, root ? `${root}.${cur[0]}` : cur[0]);
129
+ if (flattened.hasRestElement) {
130
+ hasRestElement = true;
131
+ }
132
+ if (flattened.hasPropertyRest) {
133
+ hasPropertyRest = true;
134
+ }
135
+ const inner = /** @type {string[]} */[root ? `${root}.${cur[0]}` : cur[0], ...flattened.names].filter(Boolean);
136
+ rests.push(false, ...flattened.rests);
137
+ return acc.concat(inner);
138
+ }
139
+ if (typeof cur === 'object') {
140
+ if ('isRestProperty' in cur && cur.isRestProperty) {
141
+ hasPropertyRest = true;
142
+ rests.push(true);
143
+ } else {
144
+ rests.push(false);
145
+ }
146
+ if ('restElement' in cur && cur.restElement) {
147
+ hasRestElement = true;
148
+ }
149
+ acc.push(root ? `${root}.${String(cur.name)}` : String(cur.name));
150
+ } else if (typeof cur !== 'undefined') {
151
+ rests.push(false);
152
+ acc.push(root ? `${root}.${cur}` : cur);
153
+ }
154
+ return acc;
155
+ }, []);
156
+ return {
157
+ hasPropertyRest,
158
+ hasRestElement,
159
+ names,
160
+ rests
161
+ };
172
162
  };
163
+
173
164
  /**
174
- * @param {import('@typescript-eslint/types').TSESTree.TSIndexSignature|
175
- * import('@typescript-eslint/types').TSESTree.TSConstructSignatureDeclaration|
176
- * import('@typescript-eslint/types').TSESTree.TSCallSignatureDeclaration|
177
- * import('@typescript-eslint/types').TSESTree.TSPropertySignature} propSignature
178
- * @returns {undefined|string|[string, string[]]}
179
- */
180
- const getPropertiesFromPropertySignature = (propSignature) => {
181
- if (propSignature.type === "TSIndexSignature" || propSignature.type === "TSConstructSignatureDeclaration" || propSignature.type === "TSCallSignatureDeclaration") return void 0;
182
- if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === "TSTypeLiteral") return [propSignature.key.name, propSignature.typeAnnotation.typeAnnotation.members.map((member) => {
183
- return getPropertiesFromPropertySignature(member);
184
- })];
185
- return propSignature.key.name;
165
+ * @param {import('@typescript-eslint/types').TSESTree.TSIndexSignature|
166
+ * import('@typescript-eslint/types').TSESTree.TSConstructSignatureDeclaration|
167
+ * import('@typescript-eslint/types').TSESTree.TSCallSignatureDeclaration|
168
+ * import('@typescript-eslint/types').TSESTree.TSPropertySignature} propSignature
169
+ * @returns {undefined|string|[string, string[]]}
170
+ */
171
+ exports.flattenRoots = flattenRoots;
172
+ const getPropertiesFromPropertySignature = propSignature => {
173
+ if (propSignature.type === 'TSIndexSignature' || propSignature.type === 'TSConstructSignatureDeclaration' || propSignature.type === 'TSCallSignatureDeclaration') {
174
+ return undefined;
175
+ }
176
+ if (propSignature.typeAnnotation && propSignature.typeAnnotation.typeAnnotation.type === 'TSTypeLiteral') {
177
+ return [/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */propSignature.key.name, propSignature.typeAnnotation.typeAnnotation.members.map(member => {
178
+ return /** @type {string} */getPropertiesFromPropertySignature(/** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */
179
+ member);
180
+ })];
181
+ }
182
+ return /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */propSignature.key.name;
186
183
  };
184
+
187
185
  /**
188
- * @param {ESTreeOrTypeScriptNode|null} functionNode
189
- * @param {boolean} [checkDefaultObjects]
190
- * @throws {Error}
191
- * @returns {ParamNameInfo[]}
192
- */
186
+ * @param {ESTreeOrTypeScriptNode|null} functionNode
187
+ * @param {boolean} [checkDefaultObjects]
188
+ * @throws {Error}
189
+ * @returns {ParamNameInfo[]}
190
+ */
193
191
  const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
194
- /**
195
- * @param {import('estree').Identifier|import('estree').AssignmentPattern|
196
- * import('estree').ObjectPattern|import('estree').Property|
197
- * import('estree').RestElement|import('estree').ArrayPattern|
198
- * import('@typescript-eslint/types').TSESTree.TSParameterProperty|
199
- * import('@typescript-eslint/types').TSESTree.Property|
200
- * import('@typescript-eslint/types').TSESTree.RestElement|
201
- * import('@typescript-eslint/types').TSESTree.Identifier|
202
- * import('@typescript-eslint/types').TSESTree.ObjectPattern|
203
- * import('@typescript-eslint/types').TSESTree.BindingName|
204
- * import('@typescript-eslint/types').TSESTree.Parameter
205
- * } param
206
- * @param {boolean} [isProperty]
207
- * @returns {ParamNameInfo|[string, ParamNameInfo[]]}
208
- */
209
- const getParamName = (param, isProperty) => {
210
- const hasLeftTypeAnnotation = "left" in param && "typeAnnotation" in param.left;
211
- if ("typeAnnotation" in param || hasLeftTypeAnnotation) {
212
- const typeAnnotation = hasLeftTypeAnnotation ? param.left.typeAnnotation : param.typeAnnotation;
213
- if (typeAnnotation?.typeAnnotation?.type === "TSTypeLiteral") {
214
- const propertyNames = typeAnnotation.typeAnnotation.members.map((member) => {
215
- return getPropertiesFromPropertySignature(member);
216
- });
217
- const flattened = {
218
- ...flattenRoots(propertyNames),
219
- annotationParamName: "name" in param ? param.name : void 0
220
- };
221
- const hasLeftName = "left" in param && "name" in param.left;
222
- if ("name" in param || hasLeftName) return [hasLeftName ? param.left.name : param.name, flattened];
223
- return [void 0, flattened];
224
- }
225
- }
226
- if ("name" in param) return param.name;
227
- if ("left" in param && "name" in param.left) return param.left.name;
228
- if (param.type === "ObjectPattern" || "left" in param && param.left.type === "ObjectPattern") {
229
- const properties = param.properties || param.left?.properties;
230
- const roots = properties.map((prop) => {
231
- return getParamName(prop, true);
232
- });
233
- return [void 0, flattenRoots(roots)];
234
- }
235
- if (param.type === "Property") {
236
- switch (param.value.type) {
237
- case "ArrayPattern": return [param.key.name, param.value.elements.map((prop, idx) => {
238
- return {
239
- name: idx,
240
- restElement: prop?.type === "RestElement"
241
- };
242
- })];
243
- case "ObjectPattern": return [param.key.name, param.value.properties.map((prop) => {
244
- return getParamName(prop, isProperty);
245
- })];
246
- case "AssignmentPattern": switch (param.value.left.type) {
247
- case "ArrayPattern": return [param.key.name, param.value.left.elements.map((prop, idx) => {
248
- return {
249
- name: idx,
250
- restElement: prop?.type === "RestElement"
251
- };
252
- })];
253
- case "Identifier":
254
- if (checkDefaultObjects && param.value.right.type === "ObjectExpression") return [param.key.name, param.value.right.properties.map((prop) => {
255
- return getParamName(prop, isProperty);
256
- })];
257
- break;
258
- case "ObjectPattern": return [param.key.name, param.value.left.properties.map((prop) => {
259
- return getParamName(prop, isProperty);
260
- })];
261
- }
262
- }
263
- switch (param.key.type) {
264
- case "Identifier": return param.key.name;
265
- case "Literal":
266
- /* c8 ignore next 2 -- `raw` may not be present in all parsers */
267
- return param.key.raw || param.key.value;
268
- default: return void 0;
269
- }
270
- }
271
- if (param.type === "ArrayPattern" || param.left?.type === "ArrayPattern") {
272
- const elements = param.elements || param.left?.elements;
273
- const roots = elements.map((prop, idx) => {
274
- return {
275
- name: `"${idx}"`,
276
- restElement: prop?.type === "RestElement"
277
- };
278
- });
279
- return [void 0, flattenRoots(roots)];
280
- }
281
- if (["ExperimentalRestProperty", "RestElement"].includes(param.type)) return {
282
- isRestProperty: isProperty,
283
- name: param.argument.name ?? param?.argument?.elements?.map(({ name }) => {
284
- return name;
285
- }),
286
- restElement: true
287
- };
288
- if (param.type === "TSParameterProperty") return getParamName(
289
- /** @type {import('@typescript-eslint/types').TSESTree.TSParameterProperty} */
290
- param.parameter,
291
- true
292
- );
293
- throw new Error(`Unsupported function signature format: \`${param.type}\`.`);
294
- };
295
- if (!functionNode) return [];
296
- return (functionNode.params || functionNode.value?.params || []).map((param) => {
297
- return getParamName(param);
298
- });
192
+ /* eslint-disable complexity -- Temporary */
193
+ /**
194
+ * @param {import('estree').Identifier|import('estree').AssignmentPattern|
195
+ * import('estree').ObjectPattern|import('estree').Property|
196
+ * import('estree').RestElement|import('estree').ArrayPattern|
197
+ * import('@typescript-eslint/types').TSESTree.TSParameterProperty|
198
+ * import('@typescript-eslint/types').TSESTree.Property|
199
+ * import('@typescript-eslint/types').TSESTree.RestElement|
200
+ * import('@typescript-eslint/types').TSESTree.Identifier|
201
+ * import('@typescript-eslint/types').TSESTree.ObjectPattern|
202
+ * import('@typescript-eslint/types').TSESTree.BindingName|
203
+ * import('@typescript-eslint/types').TSESTree.Parameter
204
+ * } param
205
+ * @param {boolean} [isProperty]
206
+ * @returns {ParamNameInfo|[string, ParamNameInfo[]]}
207
+ */
208
+ const getParamName = (param, isProperty) => {
209
+ /* eslint-enable complexity -- Temporary */
210
+ const hasLeftTypeAnnotation = 'left' in param && 'typeAnnotation' in param.left;
211
+ if ('typeAnnotation' in param || hasLeftTypeAnnotation) {
212
+ const typeAnnotation = hasLeftTypeAnnotation ? /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.left.typeAnnotation : /** @type {import('@typescript-eslint/types').TSESTree.Identifier|import('@typescript-eslint/types').TSESTree.ObjectPattern} */
213
+ param.typeAnnotation;
214
+ if (typeAnnotation?.typeAnnotation?.type === 'TSTypeLiteral') {
215
+ const propertyNames = typeAnnotation.typeAnnotation.members.map(member => {
216
+ return getPropertiesFromPropertySignature(/** @type {import('@typescript-eslint/types').TSESTree.TSPropertySignature} */
217
+ member);
218
+ });
219
+ const flattened = {
220
+ ...flattenRoots(propertyNames),
221
+ annotationParamName: 'name' in param ? param.name : undefined
222
+ };
223
+ const hasLeftName = 'left' in param && 'name' in param.left;
224
+ if ('name' in param || hasLeftName) {
225
+ return [hasLeftName ? /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.left.name : /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */param.name, flattened];
226
+ }
227
+ return [undefined, flattened];
228
+ }
229
+ }
230
+ if ('name' in param) {
231
+ return param.name;
232
+ }
233
+ if ('left' in param && 'name' in param.left) {
234
+ return param.left.name;
235
+ }
236
+ if (param.type === 'ObjectPattern' || 'left' in param && param.left.type === 'ObjectPattern') {
237
+ const properties = /** @type {import('@typescript-eslint/types').TSESTree.ObjectPattern} */param.properties || /** @type {import('estree').ObjectPattern} */
238
+ (/** @type {import('@typescript-eslint/types').TSESTree.AssignmentPattern} */param.left)?.properties;
239
+ const roots = properties.map(prop => {
240
+ return getParamName(prop, true);
241
+ });
242
+ return [undefined, flattenRoots(roots)];
243
+ }
244
+ if (param.type === 'Property') {
245
+ switch (param.value.type) {
246
+ case 'ArrayPattern':
247
+ {
248
+ return [/** @type {import('estree').Identifier} */
249
+ param.key.name, /** @type {import('estree').ArrayPattern} */param.value.elements.map((prop, idx) => {
250
+ return {
251
+ name: idx,
252
+ restElement: prop?.type === 'RestElement'
253
+ };
254
+ })];
255
+ }
256
+ case 'ObjectPattern':
257
+ {
258
+ return [/** @type {import('estree').Identifier} */param.key.name, /** @type {import('estree').ObjectPattern} */param.value.properties.map(prop => {
259
+ return /** @type {string|[string, string[]]} */getParamName(prop, isProperty);
260
+ })];
261
+ }
262
+ case 'AssignmentPattern':
263
+ {
264
+ switch (param.value.left.type) {
265
+ case 'ArrayPattern':
266
+ return [/** @type {import('estree').Identifier} */
267
+ param.key.name, /** @type {import('estree').ArrayPattern} */param.value.left.elements.map((prop, idx) => {
268
+ return {
269
+ name: idx,
270
+ restElement: prop?.type === 'RestElement'
271
+ };
272
+ })];
273
+ case 'Identifier':
274
+ // Default parameter
275
+ if (checkDefaultObjects && param.value.right.type === 'ObjectExpression') {
276
+ return [/** @type {import('estree').Identifier} */param.key.name, /** @type {import('estree').AssignmentPattern} */param.value.right.properties.map(prop => {
277
+ return /** @type {string} */getParamName(/** @type {import('estree').Property} */
278
+ prop, isProperty);
279
+ })];
280
+ }
281
+ break;
282
+ case 'ObjectPattern':
283
+ return [/** @type {import('estree').Identifier} */
284
+ param.key.name, /** @type {import('estree').ObjectPattern} */param.value.left.properties.map(prop => {
285
+ return getParamName(prop, isProperty);
286
+ })];
287
+ }
288
+ }
289
+ }
290
+ switch (param.key.type) {
291
+ case 'Identifier':
292
+ return param.key.name;
293
+
294
+ // The key of an object could also be a string or number
295
+ case 'Literal':
296
+ /* c8 ignore next 2 -- `raw` may not be present in all parsers */
297
+ return /** @type {string} */param.key.raw || param.key.value;
298
+
299
+ // case 'MemberExpression':
300
+ default:
301
+ // Todo: We should really create a structure (and a corresponding
302
+ // option analogous to `checkRestProperty`) which allows for
303
+ // (and optionally requires) dynamic properties to have a single
304
+ // line of documentation
305
+ return undefined;
306
+ }
307
+ }
308
+ if (param.type === 'ArrayPattern' || /** @type {import('estree').AssignmentPattern} */param.left?.type === 'ArrayPattern') {
309
+ const elements = /** @type {import('estree').ArrayPattern} */param.elements || /** @type {import('estree').ArrayPattern} */(/** @type {import('estree').AssignmentPattern} */param.left)?.elements;
310
+ const roots = elements.map((prop, idx) => {
311
+ return {
312
+ name: `"${idx}"`,
313
+ restElement: prop?.type === 'RestElement'
314
+ };
315
+ });
316
+ return [undefined, flattenRoots(roots)];
317
+ }
318
+ if (['ExperimentalRestProperty', 'RestElement'].includes(param.type)) {
319
+ return {
320
+ isRestProperty: isProperty,
321
+ name: /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */(/** @type {import('@typescript-eslint/types').TSESTree.RestElement} */param
322
+ // @ts-expect-error Ok
323
+ .argument).name ?? param?.argument?.elements?.map(({
324
+ // @ts-expect-error Ok
325
+ name
326
+ }) => {
327
+ return name;
328
+ }),
329
+ restElement: true
330
+ };
331
+ }
332
+ if (param.type === 'TSParameterProperty') {
333
+ return getParamName(/** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
334
+ /** @type {import('@typescript-eslint/types').TSESTree.TSParameterProperty} */param.parameter, true);
335
+ }
336
+ throw new Error(`Unsupported function signature format: \`${param.type}\`.`);
337
+ };
338
+ if (!functionNode) {
339
+ return [];
340
+ }
341
+ return (/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */functionNode.value?.params || []).map(param => {
342
+ return getParamName(param);
343
+ });
299
344
  };
345
+
300
346
  /**
301
- * @param {ESTreeOrTypeScriptNode} functionNode
302
- * @returns {Integer}
303
- */
304
- const hasParams = (functionNode) => {
305
- return functionNode.params.length;
347
+ * @param {ESTreeOrTypeScriptNode} functionNode
348
+ * @returns {Integer}
349
+ */
350
+ exports.getFunctionParameterNames = getFunctionParameterNames;
351
+ const hasParams = functionNode => {
352
+ // Should also check `functionNode.value.params` if supporting `MethodDefinition`
353
+ return /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */functionNode.params.length;
306
354
  };
355
+
307
356
  /**
308
- * Gets all names of the target type, including those that refer to a path, e.g.
309
- * `foo` or `foo.bar`.
310
- * @param {import('comment-parser').Block} jsdoc
311
- * @param {string} targetTagName
312
- * @returns {{
313
- * idx: Integer,
314
- * name: string,
315
- * type: string
316
- * }[]}
317
- */
357
+ * Gets all names of the target type, including those that refer to a path, e.g.
358
+ * `foo` or `foo.bar`.
359
+ * @param {import('comment-parser').Block} jsdoc
360
+ * @param {string} targetTagName
361
+ * @returns {{
362
+ * idx: Integer,
363
+ * name: string,
364
+ * type: string
365
+ * }[]}
366
+ */
367
+ exports.hasParams = hasParams;
318
368
  const getJsdocTagsDeep = (jsdoc, targetTagName) => {
319
- const ret = [];
320
- for (const [idx, { name, tag, type }] of jsdoc.tags.entries()) {
321
- if (tag !== targetTagName) continue;
322
- ret.push({
323
- idx,
324
- name,
325
- type
326
- });
327
- }
328
- return ret;
369
+ const ret = [];
370
+ for (const [idx, {
371
+ name,
372
+ tag,
373
+ type
374
+ }] of jsdoc.tags.entries()) {
375
+ if (tag !== targetTagName) {
376
+ continue;
377
+ }
378
+ ret.push({
379
+ idx,
380
+ name,
381
+ type
382
+ });
383
+ }
384
+ return ret;
329
385
  };
330
- const modeWarnSettings = require_WarnSettings.default();
386
+ exports.getJsdocTagsDeep = getJsdocTagsDeep;
387
+ const modeWarnSettings = (0, _WarnSettings.default)();
388
+
331
389
  /**
332
- * @param {ParserMode|undefined} mode
333
- * @param {Reporter} context
334
- * @returns {import('./tagNames.js').AliasedTags}
335
- */
390
+ * @param {ParserMode|undefined} mode
391
+ * @param {Reporter} context
392
+ * @returns {import('./tagNames.js').AliasedTags}
393
+ */
336
394
  const getTagNamesForMode = (mode, context) => {
337
- switch (mode) {
338
- case "closure":
339
- case "permissive": return require_tagNames.closureTags;
340
- case "jsdoc": return require_tagNames.jsdocTags;
341
- case "typescript": return require_tagNames.typeScriptTags;
342
- default:
343
- if (!modeWarnSettings.hasBeenWarned(context, "mode")) {
344
- context.report({
345
- loc: {
346
- end: {
347
- column: 1,
348
- line: 1
349
- },
350
- start: {
351
- column: 1,
352
- line: 1
353
- }
354
- },
355
- message: `Unrecognized value \`${mode}\` for \`settings.jsdoc.mode\`.`
356
- });
357
- modeWarnSettings.markSettingAsWarned(context, "mode");
358
- }
359
- return require_tagNames.jsdocTags;
360
- }
395
+ switch (mode) {
396
+ case 'closure':
397
+ case 'permissive':
398
+ return _tagNames.closureTags;
399
+ case 'jsdoc':
400
+ return _tagNames.jsdocTags;
401
+ case 'typescript':
402
+ return _tagNames.typeScriptTags;
403
+ default:
404
+ if (!modeWarnSettings.hasBeenWarned(context, 'mode')) {
405
+ context.report({
406
+ loc: {
407
+ end: {
408
+ column: 1,
409
+ line: 1
410
+ },
411
+ start: {
412
+ column: 1,
413
+ line: 1
414
+ }
415
+ },
416
+ message: `Unrecognized value \`${mode}\` for \`settings.jsdoc.mode\`.`
417
+ });
418
+ modeWarnSettings.markSettingAsWarned(context, 'mode');
419
+ }
420
+
421
+ // We'll avoid breaking too many other rules
422
+ return _tagNames.jsdocTags;
423
+ }
361
424
  };
425
+
362
426
  /**
363
- * @param {import('comment-parser').Spec} tg
364
- * @param {boolean} [returnArray]
365
- * @returns {string[]|string}
366
- */
427
+ * @param {import('comment-parser').Spec} tg
428
+ * @param {boolean} [returnArray]
429
+ * @returns {string[]|string}
430
+ */
367
431
  const getTagDescription = (tg, returnArray) => {
368
- /**
369
- * @type {string[]}
370
- */
371
- const descriptions = [];
372
- tg.source.some(({ tokens: { description, end, lineEnd, name, postDelimiter, postTag, tag, type } }) => {
373
- const desc = (tag && postTag || !tag && !name && !type && postDelimiter || "").slice(1) + (description || "") + (lineEnd || "");
374
- if (end) {
375
- if (desc) descriptions.push(desc);
376
- return true;
377
- }
378
- descriptions.push(desc);
379
- return false;
380
- });
381
- return returnArray ? descriptions : descriptions.join("\n");
432
+ /**
433
+ * @type {string[]}
434
+ */
435
+ const descriptions = [];
436
+ tg.source.some(({
437
+ tokens: {
438
+ description,
439
+ end,
440
+ lineEnd,
441
+ name,
442
+ postDelimiter,
443
+ postTag,
444
+ tag,
445
+ type
446
+ }
447
+ }) => {
448
+ const desc = (tag && postTag || !tag && !name && !type && postDelimiter || ''
449
+
450
+ // Remove space
451
+ ).slice(1) + (description || '') + (lineEnd || '');
452
+ if (end) {
453
+ if (desc) {
454
+ descriptions.push(desc);
455
+ }
456
+ return true;
457
+ }
458
+ descriptions.push(desc);
459
+ return false;
460
+ });
461
+ return returnArray ? descriptions : descriptions.join('\n');
382
462
  };
463
+
383
464
  /**
384
- * @typedef {{
385
- * report: (descriptor: import('eslint').Rule.ReportDescriptor) => void
386
- * }} Reporter
387
- */
465
+ * @typedef {{
466
+ * report: (descriptor: import('eslint').Rule.ReportDescriptor) => void
467
+ * }} Reporter
468
+ */
469
+
388
470
  /**
389
- * @param {string} name
390
- * @param {ParserMode|undefined} mode
391
- * @param {TagNamePreference} tagPreference
392
- * @param {Reporter} context
393
- * @returns {string|false|{
394
- * message: string;
395
- * replacement?: string|undefined;
396
- * }}
397
- */
398
- const getPreferredTagNameSimple = (name, mode, tagPreference = {}, context = { report() {} }) => {
399
- const prefValues = Object.values(tagPreference);
400
- if (prefValues.includes(name) || prefValues.some((prefVal) => {
401
- return prefVal && typeof prefVal === "object" && prefVal.replacement === name;
402
- })) return name;
403
- const tagPreferenceFixed = Object.fromEntries(Object.entries(tagPreference).map(([key, value]) => {
404
- return [key.replace(/^tag /v, ""), value];
405
- }));
406
- if (Object.hasOwn(tagPreferenceFixed, name)) return tagPreferenceFixed[name];
407
- const tagNames = getTagNamesForMode(mode, context);
408
- const preferredTagName = Object.entries(tagNames).find(([, aliases]) => {
409
- return aliases.includes(name);
410
- })?.[0];
411
- if (preferredTagName) return preferredTagName;
412
- return name;
471
+ * @param {string} name
472
+ * @param {ParserMode|undefined} mode
473
+ * @param {TagNamePreference} tagPreference
474
+ * @param {Reporter} context
475
+ * @returns {string|false|{
476
+ * message: string;
477
+ * replacement?: string|undefined;
478
+ * }}
479
+ */
480
+ exports.getTagDescription = getTagDescription;
481
+ const getPreferredTagNameSimple = (name, mode, tagPreference = {},
482
+ // eslint-disable-next-line unicorn/no-object-as-default-parameter -- Ok
483
+ context = {
484
+ report() {
485
+ // No-op
486
+ }
487
+ }) => {
488
+ const prefValues = Object.values(tagPreference);
489
+ if (prefValues.includes(name) || prefValues.some(prefVal => {
490
+ return prefVal && typeof prefVal === 'object' && prefVal.replacement === name;
491
+ })) {
492
+ return name;
493
+ }
494
+
495
+ // Allow keys to have a 'tag ' prefix to avoid upstream bug in ESLint
496
+ // that disallows keys that conflict with Object.prototype,
497
+ // e.g. 'tag constructor' for 'constructor':
498
+ // https://github.com/eslint/eslint/issues/13289
499
+ // https://github.com/gajus/eslint-plugin-jsdoc/issues/537
500
+ const tagPreferenceFixed = Object.fromEntries(Object.entries(tagPreference).map(([key, value]) => {
501
+ return [key.replace(/^tag /v, ''), value];
502
+ }));
503
+ if (Object.hasOwn(tagPreferenceFixed, name)) {
504
+ return tagPreferenceFixed[name];
505
+ }
506
+ const tagNames = getTagNamesForMode(mode, context);
507
+ const preferredTagName = Object.entries(tagNames).find(([, aliases]) => {
508
+ return aliases.includes(name);
509
+ })?.[0];
510
+ if (preferredTagName) {
511
+ return preferredTagName;
512
+ }
513
+ return name;
413
514
  };
515
+
414
516
  /**
415
- * @param {import('eslint').Rule.RuleContext} context
416
- * @param {ParserMode|undefined} mode
417
- * @param {string} name
418
- * @param {string[]} definedTags
419
- * @returns {boolean}
420
- */
517
+ * @param {import('eslint').Rule.RuleContext} context
518
+ * @param {ParserMode|undefined} mode
519
+ * @param {string} name
520
+ * @param {string[]} definedTags
521
+ * @returns {boolean}
522
+ */
523
+ exports.getPreferredTagNameSimple = getPreferredTagNameSimple;
421
524
  const isValidTag = (context, mode, name, definedTags) => {
422
- const tagNames = getTagNamesForMode(mode, context);
423
- const validTagNames = Object.keys(tagNames).concat(Object.values(tagNames).flat());
424
- const additionalTags = definedTags;
425
- const allTags = validTagNames.concat(additionalTags);
426
- return allTags.includes(name);
525
+ const tagNames = getTagNamesForMode(mode, context);
526
+ const validTagNames = Object.keys(tagNames).concat(Object.values(tagNames).flat());
527
+ const additionalTags = definedTags;
528
+ const allTags = validTagNames.concat(additionalTags);
529
+ return allTags.includes(name);
427
530
  };
531
+
428
532
  /**
429
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
430
- * @param {string} targetTagName
431
- * @returns {boolean}
432
- */
533
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
534
+ * @param {string} targetTagName
535
+ * @returns {boolean}
536
+ */
537
+ exports.isValidTag = isValidTag;
433
538
  const hasTag = (jsdoc, targetTagName) => {
434
- const targetTagLower = targetTagName.toLowerCase();
435
- return jsdoc.tags.some((doc) => {
436
- return doc.tag.toLowerCase() === targetTagLower;
437
- });
539
+ const targetTagLower = targetTagName.toLowerCase();
540
+ return jsdoc.tags.some(doc => {
541
+ return doc.tag.toLowerCase() === targetTagLower;
542
+ });
438
543
  };
544
+
439
545
  /**
440
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
441
- * @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter
442
- * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
443
- */
546
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
547
+ * @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter
548
+ * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
549
+ */
550
+ exports.hasTag = hasTag;
444
551
  const filterTags = (jsdoc, filter) => {
445
- return jsdoc.tags.filter((tag) => {
446
- return filter(tag);
447
- });
552
+ return jsdoc.tags.filter(tag => {
553
+ return filter(tag);
554
+ });
448
555
  };
556
+
449
557
  /**
450
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
451
- * @param {string} tagName
452
- * @returns {import('comment-parser').Spec[]}
453
- */
558
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
559
+ * @param {string} tagName
560
+ * @returns {import('comment-parser').Spec[]}
561
+ */
562
+ exports.filterTags = filterTags;
454
563
  const getTags = (jsdoc, tagName) => {
455
- return filterTags(jsdoc, (item) => {
456
- return item.tag === tagName;
457
- });
564
+ return filterTags(jsdoc, item => {
565
+ return item.tag === tagName;
566
+ });
458
567
  };
568
+
459
569
  /**
460
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
461
- * @param {{
462
- * tagName: string,
463
- * context?: import('eslint').Rule.RuleContext,
464
- * mode?: ParserMode,
465
- * report?: import('./iterateJsdoc.js').Report
466
- * tagNamePreference?: TagNamePreference
467
- * skipReportingBlockedTag?: boolean,
468
- * allowObjectReturn?: boolean,
469
- * defaultMessage?: string,
470
- * }} cfg
471
- * @returns {string|undefined|false|{
472
- * message: string;
473
- * replacement?: string|undefined;
474
- * }|{
475
- * blocked: true,
476
- * tagName: string
477
- * }}
478
- */
479
- const getPreferredTagName = (jsdoc, { allowObjectReturn = false, context, tagName, defaultMessage = `Unexpected tag \`@${tagName}\``, mode, report = () => {}, skipReportingBlockedTag = false, tagNamePreference }) => {
480
- const ret = getPreferredTagNameSimple(tagName, mode, tagNamePreference, context);
481
- const isObject = ret && typeof ret === "object";
482
- if (hasTag(jsdoc, tagName) && (ret === false || isObject && !ret.replacement)) {
483
- if (skipReportingBlockedTag) return {
484
- blocked: true,
485
- tagName
486
- };
487
- const message = isObject && ret.message || defaultMessage;
488
- report(message, null, getTags(jsdoc, tagName)[0]);
489
- return false;
490
- }
491
- return isObject && !allowObjectReturn ? ret.replacement : ret;
570
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
571
+ * @param {{
572
+ * tagName: string,
573
+ * context?: import('eslint').Rule.RuleContext,
574
+ * mode?: ParserMode,
575
+ * report?: import('./iterateJsdoc.js').Report
576
+ * tagNamePreference?: TagNamePreference
577
+ * skipReportingBlockedTag?: boolean,
578
+ * allowObjectReturn?: boolean,
579
+ * defaultMessage?: string,
580
+ * }} cfg
581
+ * @returns {string|undefined|false|{
582
+ * message: string;
583
+ * replacement?: string|undefined;
584
+ * }|{
585
+ * blocked: true,
586
+ * tagName: string
587
+ * }}
588
+ */
589
+ exports.getTags = getTags;
590
+ const getPreferredTagName = (jsdoc, {
591
+ allowObjectReturn = false,
592
+ context,
593
+ tagName,
594
+ defaultMessage = `Unexpected tag \`@${tagName}\``,
595
+ mode,
596
+ report = () => {},
597
+ skipReportingBlockedTag = false,
598
+ tagNamePreference
599
+ }) => {
600
+ const ret = getPreferredTagNameSimple(tagName, mode, tagNamePreference, context);
601
+ const isObject = ret && typeof ret === 'object';
602
+ if (hasTag(jsdoc, tagName) && (ret === false || isObject && !ret.replacement)) {
603
+ if (skipReportingBlockedTag) {
604
+ return {
605
+ blocked: true,
606
+ tagName
607
+ };
608
+ }
609
+ const message = isObject && ret.message || defaultMessage;
610
+ report(message, null, getTags(jsdoc, tagName)[0]);
611
+ return false;
612
+ }
613
+ return isObject && !allowObjectReturn ? ret.replacement : ret;
492
614
  };
615
+
493
616
  /**
494
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
495
- * @param {string} tagName
496
- * @param {(
497
- * matchingJsdocTag: import('@es-joy/jsdoccomment').JsdocTagWithInline,
498
- * targetTagName: string
499
- * ) => void} arrayHandler
500
- * @param {object} cfg
501
- * @param {import('eslint').Rule.RuleContext} [cfg.context]
502
- * @param {ParserMode} [cfg.mode]
503
- * @param {import('./iterateJsdoc.js').Report} [cfg.report]
504
- * @param {TagNamePreference} [cfg.tagNamePreference]
505
- * @param {boolean} [cfg.skipReportingBlockedTag]
506
- * @returns {void}
507
- */
508
- const forEachPreferredTag = (jsdoc, tagName, arrayHandler, { context, mode, report, skipReportingBlockedTag = false, tagNamePreference } = {}) => {
509
- const targetTagName = getPreferredTagName(jsdoc, {
510
- context,
511
- mode,
512
- report,
513
- skipReportingBlockedTag,
514
- tagName,
515
- tagNamePreference
516
- });
517
- if (!targetTagName || skipReportingBlockedTag && targetTagName && typeof targetTagName === "object") return;
518
- const matchingJsdocTags = jsdoc.tags.filter(({ tag }) => {
519
- return tag === targetTagName;
520
- });
521
- for (const matchingJsdocTag of matchingJsdocTags) arrayHandler(matchingJsdocTag, targetTagName);
617
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
618
+ * @param {string} tagName
619
+ * @param {(
620
+ * matchingJsdocTag: import('@es-joy/jsdoccomment').JsdocTagWithInline,
621
+ * targetTagName: string
622
+ * ) => void} arrayHandler
623
+ * @param {object} cfg
624
+ * @param {import('eslint').Rule.RuleContext} [cfg.context]
625
+ * @param {ParserMode} [cfg.mode]
626
+ * @param {import('./iterateJsdoc.js').Report} [cfg.report]
627
+ * @param {TagNamePreference} [cfg.tagNamePreference]
628
+ * @param {boolean} [cfg.skipReportingBlockedTag]
629
+ * @returns {void}
630
+ */
631
+ exports.getPreferredTagName = getPreferredTagName;
632
+ const forEachPreferredTag = (jsdoc, tagName, arrayHandler, {
633
+ context,
634
+ mode,
635
+ report,
636
+ skipReportingBlockedTag = false,
637
+ tagNamePreference
638
+ } = {}) => {
639
+ const targetTagName = /** @type {string|false} */
640
+ getPreferredTagName(jsdoc, {
641
+ context,
642
+ mode,
643
+ report,
644
+ skipReportingBlockedTag,
645
+ tagName,
646
+ tagNamePreference
647
+ });
648
+ if (!targetTagName || skipReportingBlockedTag && targetTagName && typeof targetTagName === 'object') {
649
+ return;
650
+ }
651
+ const matchingJsdocTags = jsdoc.tags.filter(({
652
+ tag
653
+ }) => {
654
+ return tag === targetTagName;
655
+ });
656
+ for (const matchingJsdocTag of matchingJsdocTags) {
657
+ arrayHandler(
658
+ /**
659
+ * @type {import('@es-joy/jsdoccomment').JsdocTagWithInline}
660
+ */
661
+ matchingJsdocTag, targetTagName);
662
+ }
522
663
  };
664
+
523
665
  /**
524
- * Get all tags, inline tags and inline tags in tags
525
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
526
- * @returns {(import('comment-parser').Spec|
527
- * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
528
- */
529
- const getAllTags = (jsdoc) => {
530
- return [
531
- ...jsdoc.tags,
532
- ...jsdoc.inlineTags.map((inlineTag) => {
533
- let line = -1;
534
- for (const { tokens: { description } } of jsdoc.source) {
535
- line++;
536
- if (description && description.includes(`{@${inlineTag.tag}`)) break;
537
- }
538
- inlineTag.line = line;
539
- return inlineTag;
540
- }),
541
- ...jsdoc.tags.flatMap((tag) => {
542
- let tagBegins = -1;
543
- for (const { tokens: { tag: tg } } of jsdoc.source) {
544
- tagBegins++;
545
- if (tg) break;
546
- }
547
- for (const inlineTag of tag.inlineTags) {
548
- /** @type {import('./iterateJsdoc.js').Integer} */
549
- let line = 0;
550
- for (const { number, tokens: { description } } of tag.source) if (description && description.includes(`{@${inlineTag.tag}`)) {
551
- line = number;
552
- break;
553
- }
554
- inlineTag.line = tagBegins + line - 1;
555
- }
556
- return tag.inlineTags;
557
- })
558
- ];
666
+ * Get all tags, inline tags and inline tags in tags
667
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
668
+ * @returns {(import('comment-parser').Spec|
669
+ * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
670
+ */
671
+ exports.forEachPreferredTag = forEachPreferredTag;
672
+ const getAllTags = jsdoc => {
673
+ return [...jsdoc.tags, ...jsdoc.inlineTags.map(inlineTag => {
674
+ // Tags don't have source or line numbers, so add before returning
675
+ let line = -1;
676
+ for (const {
677
+ tokens: {
678
+ description
679
+ }
680
+ } of jsdoc.source) {
681
+ line++;
682
+ if (description && description.includes(`{@${inlineTag.tag}`)) {
683
+ break;
684
+ }
685
+ }
686
+ inlineTag.line = line;
687
+ return inlineTag;
688
+ }), ...jsdoc.tags.flatMap(tag => {
689
+ let tagBegins = -1;
690
+ for (const {
691
+ tokens: {
692
+ tag: tg
693
+ }
694
+ } of jsdoc.source) {
695
+ tagBegins++;
696
+ if (tg) {
697
+ break;
698
+ }
699
+ }
700
+ for (const inlineTag of tag.inlineTags) {
701
+ /** @type {import('./iterateJsdoc.js').Integer} */
702
+ let line = 0;
703
+ for (const {
704
+ number,
705
+ tokens: {
706
+ description
707
+ }
708
+ } of tag.source) {
709
+ if (description && description.includes(`{@${inlineTag.tag}`)) {
710
+ line = number;
711
+ break;
712
+ }
713
+ }
714
+ inlineTag.line = tagBegins + line - 1;
715
+ }
716
+ return (
717
+ /**
718
+ * @type {import('comment-parser').Spec & {
719
+ * inlineTags: import('@es-joy/jsdoccomment').JsdocInlineTagNoType[]
720
+ * }}
721
+ */
722
+ tag.inlineTags
723
+ );
724
+ })];
559
725
  };
726
+
560
727
  /**
561
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
562
- * @param {string[]} targetTagNames
563
- * @returns {boolean}
564
- */
728
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
729
+ * @param {string[]} targetTagNames
730
+ * @returns {boolean}
731
+ */
732
+ exports.getAllTags = getAllTags;
565
733
  const hasATag = (jsdoc, targetTagNames) => {
566
- return targetTagNames.some((targetTagName) => {
567
- return hasTag(jsdoc, targetTagName);
568
- });
734
+ return targetTagNames.some(targetTagName => {
735
+ return hasTag(jsdoc, targetTagName);
736
+ });
569
737
  };
738
+
570
739
  /**
571
- * Checks if the JSDoc comment has an undefined type.
572
- * @param {import('comment-parser').Spec|null|undefined} tag
573
- * the tag which should be checked.
574
- * @param {ParserMode} mode
575
- * @returns {boolean}
576
- * true in case a defined type is undeclared; otherwise false.
577
- */
740
+ * Checks if the JSDoc comment has an undefined type.
741
+ * @param {import('comment-parser').Spec|null|undefined} tag
742
+ * the tag which should be checked.
743
+ * @param {ParserMode} mode
744
+ * @returns {boolean}
745
+ * true in case a defined type is undeclared; otherwise false.
746
+ */
747
+ exports.hasATag = hasATag;
578
748
  const mayBeUndefinedTypeTag = (tag, mode) => {
579
- if (typeof tag === "undefined" || tag === null) return true;
580
- const tagType = tag.type.trim();
581
- if (tagType === "undefined" || tagType === "void" || tagType === "*" || tagType === "any") return true;
582
- let parsedTypes;
583
- try {
584
- parsedTypes = (0, __es_joy_jsdoccomment.tryParse)(tagType, mode === "permissive" ? void 0 : [mode]);
585
- } catch {}
586
- if (parsedTypes && parsedTypes.type === "JsdocTypeUnion" && parsedTypes.elements.find((elem) => {
587
- return elem.type === "JsdocTypeUndefined" || elem.type === "JsdocTypeName" && elem.value === "void";
588
- })) return true;
589
- return false;
749
+ // The function should not continue in the event the type is not defined...
750
+ if (typeof tag === 'undefined' || tag === null) {
751
+ return true;
752
+ }
753
+
754
+ // .. same applies if it declares an `{undefined}` or `{void}` type
755
+ const tagType = tag.type.trim();
756
+
757
+ // Exit early if matching
758
+ if (tagType === 'undefined' || tagType === 'void' || tagType === '*' || tagType === 'any') {
759
+ return true;
760
+ }
761
+ let parsedTypes;
762
+ try {
763
+ parsedTypes = (0, _jsdoccomment.tryParse)(tagType, mode === 'permissive' ? undefined : [mode]);
764
+ } catch {
765
+ // Ignore
766
+ }
767
+ if (
768
+ // We do not traverse deeply as it could be, e.g., `Promise<void>`
769
+ parsedTypes && parsedTypes.type === 'JsdocTypeUnion' && parsedTypes.elements.find(elem => {
770
+ return elem.type === 'JsdocTypeUndefined' || elem.type === 'JsdocTypeName' && elem.value === 'void';
771
+ })) {
772
+ return true;
773
+ }
774
+
775
+ // In any other case, a type is present
776
+ return false;
590
777
  };
778
+
591
779
  /**
592
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} map
593
- * @param {string} tag
594
- * @returns {Map<string, string|string[]|boolean|undefined>}
595
- */
780
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} map
781
+ * @param {string} tag
782
+ * @returns {Map<string, string|string[]|boolean|undefined>}
783
+ */
784
+ exports.mayBeUndefinedTypeTag = mayBeUndefinedTypeTag;
596
785
  const ensureMap = (map, tag) => {
597
- if (!map.has(tag)) map.set(tag, /* @__PURE__ */ new Map());
598
- return map.get(tag);
786
+ if (!map.has(tag)) {
787
+ map.set(tag, new Map());
788
+ }
789
+ return /** @type {Map<string, string | boolean>} */map.get(tag);
599
790
  };
791
+
600
792
  /**
601
- * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
602
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
603
- * @returns {void}
604
- */
793
+ * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
794
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
795
+ * @returns {void}
796
+ */
605
797
  const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
606
- for (const [tag, { name, required = [], type }] of Object.entries(structuredTags)) {
607
- const tagStruct = ensureMap(tagMap, tag);
608
- tagStruct.set("namepathRole", name);
609
- tagStruct.set("typeAllowed", type);
610
- const requiredName = required.includes("name");
611
- if (requiredName && name === false) throw new Error("Cannot add \"name\" to `require` with the tag's `name` set to `false`");
612
- tagStruct.set("nameRequired", requiredName);
613
- const requiredType = required.includes("type");
614
- if (requiredType && type === false) throw new Error("Cannot add \"type\" to `require` with the tag's `type` set to `false`");
615
- tagStruct.set("typeRequired", requiredType);
616
- const typeOrNameRequired = required.includes("typeOrNameRequired");
617
- if (typeOrNameRequired && name === false) throw new Error("Cannot add \"typeOrNameRequired\" to `require` with the tag's `name` set to `false`");
618
- if (typeOrNameRequired && type === false) throw new Error("Cannot add \"typeOrNameRequired\" to `require` with the tag's `type` set to `false`");
619
- tagStruct.set("typeOrNameRequired", typeOrNameRequired);
620
- }
798
+ for (const [tag, {
799
+ name,
800
+ required = [],
801
+ type
802
+ }] of Object.entries(structuredTags)) {
803
+ const tagStruct = ensureMap(tagMap, tag);
804
+ tagStruct.set('namepathRole', name);
805
+ tagStruct.set('typeAllowed', type);
806
+ const requiredName = required.includes('name');
807
+ if (requiredName && name === false) {
808
+ throw new Error('Cannot add "name" to `require` with the tag\'s `name` set to `false`');
809
+ }
810
+ tagStruct.set('nameRequired', requiredName);
811
+ const requiredType = required.includes('type');
812
+ if (requiredType && type === false) {
813
+ throw new Error('Cannot add "type" to `require` with the tag\'s `type` set to `false`');
814
+ }
815
+ tagStruct.set('typeRequired', requiredType);
816
+ const typeOrNameRequired = required.includes('typeOrNameRequired');
817
+ if (typeOrNameRequired && name === false) {
818
+ throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `name` set to `false`');
819
+ }
820
+ if (typeOrNameRequired && type === false) {
821
+ throw new Error('Cannot add "typeOrNameRequired" to `require` with the tag\'s `type` set to `false`');
822
+ }
823
+ tagStruct.set('typeOrNameRequired', typeOrNameRequired);
824
+ }
621
825
  };
826
+
622
827
  /**
623
- * @param {ParserMode} mode
624
- * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
625
- * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
626
- */
828
+ * @param {ParserMode} mode
829
+ * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
830
+ * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
831
+ */
832
+ exports.overrideTagStructure = overrideTagStructure;
627
833
  const getTagStructureForMode = (mode, structuredTags) => {
628
- const tagStruct = require_getDefaultTagStructureForMode.default(mode);
629
- try {
630
- overrideTagStructure(structuredTags, tagStruct);
631
- } catch {}
632
- return tagStruct;
834
+ const tagStruct = (0, _getDefaultTagStructureForMode.default)(mode);
835
+ try {
836
+ overrideTagStructure(structuredTags, tagStruct);
837
+ /* c8 ignore next 3 */
838
+ } catch {
839
+ //
840
+ }
841
+ return tagStruct;
633
842
  };
843
+
634
844
  /**
635
- * @param {string} tag
636
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
637
- * @returns {boolean}
638
- */
845
+ * @param {string} tag
846
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
847
+ * @returns {boolean}
848
+ */
849
+ exports.getTagStructureForMode = getTagStructureForMode;
639
850
  const isNamepathDefiningTag = (tag, tagMap = tagStructure) => {
640
- const tagStruct = ensureMap(tagMap, tag);
641
- return tagStruct.get("namepathRole") === "namepath-defining";
851
+ const tagStruct = ensureMap(tagMap, tag);
852
+ return tagStruct.get('namepathRole') === 'namepath-defining';
642
853
  };
854
+
643
855
  /**
644
- * @param {string} tag
645
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
646
- * @returns {boolean}
647
- */
856
+ * @param {string} tag
857
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
858
+ * @returns {boolean}
859
+ */
860
+ exports.isNamepathDefiningTag = isNamepathDefiningTag;
648
861
  const isNamepathReferencingTag = (tag, tagMap = tagStructure) => {
649
- const tagStruct = ensureMap(tagMap, tag);
650
- return tagStruct.get("namepathRole") === "namepath-referencing";
862
+ const tagStruct = ensureMap(tagMap, tag);
863
+ return tagStruct.get('namepathRole') === 'namepath-referencing';
651
864
  };
865
+
652
866
  /**
653
- * @param {string} tag
654
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
655
- * @returns {boolean}
656
- */
867
+ * @param {string} tag
868
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
869
+ * @returns {boolean}
870
+ */
871
+ exports.isNamepathReferencingTag = isNamepathReferencingTag;
657
872
  const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => {
658
- const tagStruct = ensureMap(tagMap, tag);
659
- return tagStruct.get("namepathRole") === "namepath-or-url-referencing";
873
+ const tagStruct = ensureMap(tagMap, tag);
874
+ return tagStruct.get('namepathRole') === 'namepath-or-url-referencing';
660
875
  };
876
+
661
877
  /**
662
- * @param {string} tag
663
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
664
- * @returns {boolean|undefined}
665
- */
878
+ * @param {string} tag
879
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
880
+ * @returns {boolean|undefined}
881
+ */
882
+ exports.isNamepathOrUrlReferencingTag = isNamepathOrUrlReferencingTag;
666
883
  const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
667
- const tagStruct = ensureMap(tagMap, tag);
668
- return tagStruct.get("typeRequired");
884
+ const tagStruct = ensureMap(tagMap, tag);
885
+ return /** @type {boolean|undefined} */tagStruct.get('typeRequired');
669
886
  };
887
+
670
888
  /**
671
- * @param {string} tag
672
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
673
- * @returns {boolean|string}
674
- */
889
+ * @param {string} tag
890
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
891
+ * @returns {boolean|string}
892
+ */
893
+ exports.tagMustHaveTypePosition = tagMustHaveTypePosition;
675
894
  const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
676
- if (tagMustHaveTypePosition(tag, tagMap)) return true;
677
- const tagStruct = ensureMap(tagMap, tag);
678
- const ret = tagStruct.get("typeAllowed");
679
- return ret === void 0 ? true : ret;
895
+ if (tagMustHaveTypePosition(tag, tagMap)) {
896
+ return true;
897
+ }
898
+ const tagStruct = ensureMap(tagMap, tag);
899
+ const ret = /** @type {boolean|undefined} */tagStruct.get('typeAllowed');
900
+ return ret === undefined ? true : ret;
680
901
  };
681
- const namepathTypes = new Set(["namepath-defining", "namepath-referencing"]);
902
+ exports.tagMightHaveTypePosition = tagMightHaveTypePosition;
903
+ const namepathTypes = new Set(['namepath-defining', 'namepath-referencing']);
904
+
682
905
  /**
683
- * @param {string} tag
684
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
685
- * @returns {boolean}
686
- */
906
+ * @param {string} tag
907
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
908
+ * @returns {boolean}
909
+ */
687
910
  const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => {
688
- const tagStruct = ensureMap(tagMap, tag);
689
- const ret = tagStruct.get("namepathRole");
690
- return ret === void 0 ? true : Boolean(ret);
911
+ const tagStruct = ensureMap(tagMap, tag);
912
+ const ret = tagStruct.get('namepathRole');
913
+ return ret === undefined ? true : Boolean(ret);
691
914
  };
915
+
692
916
  /**
693
- * @param {string} tag
694
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
695
- * @returns {boolean}
696
- */
917
+ * @param {string} tag
918
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
919
+ * @returns {boolean}
920
+ */
921
+ exports.tagMightHaveNamePosition = tagMightHaveNamePosition;
697
922
  const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
698
- const tagStruct = ensureMap(tagMap, tag);
699
- const nampathRole = tagStruct.get("namepathRole");
700
- return nampathRole !== false && namepathTypes.has(nampathRole);
923
+ const tagStruct = ensureMap(tagMap, tag);
924
+ const nampathRole = tagStruct.get('namepathRole');
925
+ return nampathRole !== false && namepathTypes.has(/** @type {string} */nampathRole);
701
926
  };
927
+
702
928
  /**
703
- * @param {string} tag
704
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
705
- * @returns {boolean|undefined}
706
- */
929
+ * @param {string} tag
930
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
931
+ * @returns {boolean|undefined}
932
+ */
933
+ exports.tagMightHaveNamepath = tagMightHaveNamepath;
707
934
  const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
708
- const tagStruct = ensureMap(tagMap, tag);
709
- return tagStruct.get("nameRequired");
935
+ const tagStruct = ensureMap(tagMap, tag);
936
+ return /** @type {boolean|undefined} */tagStruct.get('nameRequired');
710
937
  };
938
+
711
939
  /**
712
- * @param {string} tag
713
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
714
- * @returns {boolean}
715
- */
940
+ * @param {string} tag
941
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
942
+ * @returns {boolean}
943
+ */
944
+ exports.tagMustHaveNamePosition = tagMustHaveNamePosition;
716
945
  const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
717
- return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNamepath(tag, tagMap);
946
+ return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNamepath(tag, tagMap);
718
947
  };
948
+
719
949
  /**
720
- * @param {string} tag
721
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
722
- * @returns {boolean|undefined}
723
- */
950
+ * @param {string} tag
951
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
952
+ * @returns {boolean|undefined}
953
+ */
954
+ exports.tagMightHaveEitherTypeOrNamePosition = tagMightHaveEitherTypeOrNamePosition;
724
955
  const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => {
725
- const tagStruct = ensureMap(tagMap, tag);
726
- return tagStruct.get("typeOrNameRequired");
956
+ const tagStruct = ensureMap(tagMap, tag);
957
+ return /** @type {boolean} */tagStruct.get('typeOrNameRequired');
727
958
  };
959
+
728
960
  /**
729
- * @param {import('comment-parser').Spec} tag
730
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
731
- * @returns {boolean|undefined}
732
- */
961
+ * @param {import('comment-parser').Spec} tag
962
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
963
+ * @returns {boolean|undefined}
964
+ */
733
965
  const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
734
- const mustHaveTypePosition = tagMustHaveTypePosition(tag.tag, tagMap);
735
- const mightHaveTypePosition = tagMightHaveTypePosition(tag.tag, tagMap);
736
- const hasTypePosition = mightHaveTypePosition && Boolean(tag.type);
737
- const hasNameOrNamepathPosition = (tagMustHaveNamePosition(tag.tag, tagMap) || tagMightHaveNamepath(tag.tag, tagMap)) && Boolean(tag.name);
738
- const mustHaveEither = tagMustHaveEitherTypeOrNamePosition(tag.tag, tagMap);
739
- const hasEither = tagMightHaveEitherTypeOrNamePosition(tag.tag, tagMap) && (hasTypePosition || hasNameOrNamepathPosition);
740
- return mustHaveEither && !hasEither && !mustHaveTypePosition;
966
+ const mustHaveTypePosition = tagMustHaveTypePosition(tag.tag, tagMap);
967
+ const mightHaveTypePosition = tagMightHaveTypePosition(tag.tag, tagMap);
968
+ const hasTypePosition = mightHaveTypePosition && Boolean(tag.type);
969
+ const hasNameOrNamepathPosition = (tagMustHaveNamePosition(tag.tag, tagMap) || tagMightHaveNamepath(tag.tag, tagMap)) && Boolean(tag.name);
970
+ const mustHaveEither = tagMustHaveEitherTypeOrNamePosition(tag.tag, tagMap);
971
+ const hasEither = tagMightHaveEitherTypeOrNamePosition(tag.tag, tagMap) && (hasTypePosition || hasNameOrNamepathPosition);
972
+ return mustHaveEither && !hasEither && !mustHaveTypePosition;
741
973
  };
974
+
975
+ /* eslint-disable complexity -- Temporary */
742
976
  /**
743
- * @param {ESTreeOrTypeScriptNode|null|undefined} node
744
- * @param {boolean} [checkYieldReturnValue]
745
- * @returns {boolean}
746
- */
977
+ * @param {ESTreeOrTypeScriptNode|null|undefined} node
978
+ * @param {boolean} [checkYieldReturnValue]
979
+ * @returns {boolean}
980
+ */
981
+ exports.tagMissingRequiredTypeOrNamepath = tagMissingRequiredTypeOrNamepath;
747
982
  const hasNonFunctionYield = (node, checkYieldReturnValue) => {
748
- if (!node) return false;
749
- switch (node.type) {
750
- case "ArrayExpression":
751
- case "ArrayPattern": return node.elements.some((element) => {
752
- return hasNonFunctionYield(element, checkYieldReturnValue);
753
- });
754
- case "AssignmentExpression":
755
- case "BinaryExpression":
756
- case "LogicalExpression": return hasNonFunctionYield(node.left, checkYieldReturnValue) || hasNonFunctionYield(node.right, checkYieldReturnValue);
757
- case "AssignmentPattern": return hasNonFunctionYield(node.right, checkYieldReturnValue);
758
- case "BlockStatement": return node.body.some((bodyNode) => {
759
- return ![
760
- "ArrowFunctionExpression",
761
- "FunctionDeclaration",
762
- "FunctionExpression"
763
- ].includes(bodyNode.type) && hasNonFunctionYield(bodyNode, checkYieldReturnValue);
764
- });
765
- case "CallExpression":
766
- case "OptionalCallExpression": return node.arguments.some((element) => {
767
- return hasNonFunctionYield(element, checkYieldReturnValue);
768
- });
769
- case "ChainExpression":
770
- case "ExpressionStatement": return hasNonFunctionYield(node.expression, checkYieldReturnValue);
771
- case "ClassProperty":
772
- case "ObjectProperty":
773
- case "Property":
774
- case "PropertyDefinition": return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || hasNonFunctionYield(node.value, checkYieldReturnValue);
775
- case "ConditionalExpression":
776
- case "IfStatement": return hasNonFunctionYield(node.test, checkYieldReturnValue) || hasNonFunctionYield(node.consequent, checkYieldReturnValue) || hasNonFunctionYield(node.alternate, checkYieldReturnValue);
777
- case "DoWhileStatement":
778
- case "ForInStatement":
779
- case "ForOfStatement":
780
- case "ForStatement":
781
- case "LabeledStatement":
782
- case "WhileStatement":
783
- case "WithStatement": return hasNonFunctionYield(node.body, checkYieldReturnValue);
784
- case "Import":
785
- case "ImportExpression": return hasNonFunctionYield(node.source, checkYieldReturnValue);
786
- case "MemberExpression":
787
- case "OptionalMemberExpression": return hasNonFunctionYield(node.object, checkYieldReturnValue) || hasNonFunctionYield(node.property, checkYieldReturnValue);
788
- case "ObjectExpression":
789
- case "ObjectPattern": return node.properties.some((property) => {
790
- return hasNonFunctionYield(property, checkYieldReturnValue);
791
- });
792
- case "ObjectMethod":
793
- /* c8 ignore next 6 -- In Babel? */
794
- return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || node.arguments.some((nde) => {
795
- return hasNonFunctionYield(nde, checkYieldReturnValue);
796
- });
797
- case "ReturnStatement":
798
- if (node.argument === null) return false;
799
- return hasNonFunctionYield(node.argument, checkYieldReturnValue);
800
- case "SequenceExpression":
801
- case "TemplateLiteral": return node.expressions.some((subExpression) => {
802
- return hasNonFunctionYield(subExpression, checkYieldReturnValue);
803
- });
804
- case "SpreadElement":
805
- case "UnaryExpression": return hasNonFunctionYield(node.argument, checkYieldReturnValue);
806
- case "SwitchStatement": return node.cases.some((someCase) => {
807
- return someCase.consequent.some((nde) => {
808
- return hasNonFunctionYield(nde, checkYieldReturnValue);
809
- });
810
- });
811
- case "TaggedTemplateExpression": return hasNonFunctionYield(node.quasi, checkYieldReturnValue);
812
- case "TryStatement": return hasNonFunctionYield(node.block, checkYieldReturnValue) || hasNonFunctionYield(node.handler && node.handler.body, checkYieldReturnValue) || hasNonFunctionYield(node.finalizer, checkYieldReturnValue);
813
- case "VariableDeclaration": return node.declarations.some((nde) => {
814
- return hasNonFunctionYield(nde, checkYieldReturnValue);
815
- });
816
- case "VariableDeclarator": return hasNonFunctionYield(node.id, checkYieldReturnValue) || hasNonFunctionYield(node.init, checkYieldReturnValue);
817
- case "YieldExpression":
818
- if (checkYieldReturnValue) {
819
- if (node.parent.type === "VariableDeclarator") return true;
820
- return false;
821
- }
822
- if (node.argument === null) return false;
823
- return true;
824
- default: return false;
825
- }
983
+ /* eslint-enable complexity -- Temporary */
984
+ if (!node) {
985
+ return false;
986
+ }
987
+ switch (node.type) {
988
+ case 'ArrayExpression':
989
+ case 'ArrayPattern':
990
+ return node.elements.some(element => {
991
+ return hasNonFunctionYield(element, checkYieldReturnValue);
992
+ });
993
+ case 'AssignmentExpression':
994
+ case 'BinaryExpression':
995
+ case 'LogicalExpression':
996
+ {
997
+ return hasNonFunctionYield(node.left, checkYieldReturnValue) || hasNonFunctionYield(node.right, checkYieldReturnValue);
998
+ }
999
+ case 'AssignmentPattern':
1000
+ return hasNonFunctionYield(node.right, checkYieldReturnValue);
1001
+ case 'BlockStatement':
1002
+ {
1003
+ return node.body.some(bodyNode => {
1004
+ return !['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression'].includes(bodyNode.type) && hasNonFunctionYield(bodyNode, checkYieldReturnValue);
1005
+ });
1006
+ }
1007
+
1008
+ /* c8 ignore next 2 -- In Babel? */
1009
+ case 'CallExpression':
1010
+ // @ts-expect-error In Babel?
1011
+ case 'OptionalCallExpression':
1012
+ return node.arguments.some(element => {
1013
+ return hasNonFunctionYield(element, checkYieldReturnValue);
1014
+ });
1015
+ case 'ChainExpression':
1016
+ case 'ExpressionStatement':
1017
+ {
1018
+ return hasNonFunctionYield(node.expression, checkYieldReturnValue);
1019
+ }
1020
+
1021
+ /* c8 ignore next 2 -- In Babel? */
1022
+ // @ts-expect-error In Babel?
1023
+ case 'ClassProperty':
1024
+
1025
+ /* c8 ignore next 2 -- In Babel? */
1026
+ // @ts-expect-error In Babel?
1027
+ case 'ObjectProperty':
1028
+ /* c8 ignore next 2 -- In Babel? */
1029
+ case 'Property':
1030
+ case 'PropertyDefinition':
1031
+ return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) || hasNonFunctionYield(node.value, checkYieldReturnValue);
1032
+ case 'ConditionalExpression':
1033
+ case 'IfStatement':
1034
+ {
1035
+ return hasNonFunctionYield(node.test, checkYieldReturnValue) || hasNonFunctionYield(node.consequent, checkYieldReturnValue) || hasNonFunctionYield(node.alternate, checkYieldReturnValue);
1036
+ }
1037
+ case 'DoWhileStatement':
1038
+ case 'ForInStatement':
1039
+ case 'ForOfStatement':
1040
+ case 'ForStatement':
1041
+ case 'LabeledStatement':
1042
+ case 'WhileStatement':
1043
+ case 'WithStatement':
1044
+ {
1045
+ return hasNonFunctionYield(node.body, checkYieldReturnValue);
1046
+ }
1047
+
1048
+ /* c8 ignore next 2 -- In Babel? */
1049
+ // @ts-expect-error In Babel?
1050
+ case 'Import':
1051
+ case 'ImportExpression':
1052
+ return hasNonFunctionYield(node.source, checkYieldReturnValue);
1053
+
1054
+ // ?.
1055
+ /* c8 ignore next 2 -- In Babel? */
1056
+ case 'MemberExpression':
1057
+ // @ts-expect-error In Babel?
1058
+ case 'OptionalMemberExpression':
1059
+ return hasNonFunctionYield(node.object, checkYieldReturnValue) || hasNonFunctionYield(node.property, checkYieldReturnValue);
1060
+ case 'ObjectExpression':
1061
+ /* eslint-disable no-fallthrough */
1062
+ case 'ObjectPattern':
1063
+ /* eslint-enable no-fallthrough */
1064
+ return node.properties.some(property => {
1065
+ return hasNonFunctionYield(property, checkYieldReturnValue);
1066
+ });
1067
+ /* c8 ignore next 2 -- In Babel? */
1068
+ // @ts-expect-error In Babel?
1069
+ case 'ObjectMethod':
1070
+ /* c8 ignore next 6 -- In Babel? */
1071
+ // @ts-expect-error In Babel?
1072
+ return node.computed && hasNonFunctionYield(node.key, checkYieldReturnValue) ||
1073
+ // @ts-expect-error In Babel?
1074
+ node.arguments.some(nde => {
1075
+ return hasNonFunctionYield(nde, checkYieldReturnValue);
1076
+ });
1077
+ case 'ReturnStatement':
1078
+ {
1079
+ if (node.argument === null) {
1080
+ return false;
1081
+ }
1082
+ return hasNonFunctionYield(node.argument, checkYieldReturnValue);
1083
+ }
1084
+
1085
+ // Comma
1086
+ case 'SequenceExpression':
1087
+ case 'TemplateLiteral':
1088
+ return node.expressions.some(subExpression => {
1089
+ return hasNonFunctionYield(subExpression, checkYieldReturnValue);
1090
+ });
1091
+ case 'SpreadElement':
1092
+ case 'UnaryExpression':
1093
+ return hasNonFunctionYield(node.argument, checkYieldReturnValue);
1094
+ case 'SwitchStatement':
1095
+ {
1096
+ return node.cases.some(someCase => {
1097
+ return someCase.consequent.some(nde => {
1098
+ return hasNonFunctionYield(nde, checkYieldReturnValue);
1099
+ });
1100
+ });
1101
+ }
1102
+ case 'TaggedTemplateExpression':
1103
+ return hasNonFunctionYield(node.quasi, checkYieldReturnValue);
1104
+ case 'TryStatement':
1105
+ {
1106
+ return hasNonFunctionYield(node.block, checkYieldReturnValue) || hasNonFunctionYield(node.handler && node.handler.body, checkYieldReturnValue) || hasNonFunctionYield(/** @type {import('@typescript-eslint/types').TSESTree.BlockStatement} */
1107
+ node.finalizer, checkYieldReturnValue);
1108
+ }
1109
+ case 'VariableDeclaration':
1110
+ {
1111
+ return node.declarations.some(nde => {
1112
+ return hasNonFunctionYield(nde, checkYieldReturnValue);
1113
+ });
1114
+ }
1115
+ case 'VariableDeclarator':
1116
+ {
1117
+ return hasNonFunctionYield(node.id, checkYieldReturnValue) || hasNonFunctionYield(node.init, checkYieldReturnValue);
1118
+ }
1119
+ case 'YieldExpression':
1120
+ {
1121
+ if (checkYieldReturnValue) {
1122
+ if (/** @type {import('eslint').Rule.Node} */node.parent.type === 'VariableDeclarator') {
1123
+ return true;
1124
+ }
1125
+ return false;
1126
+ }
1127
+
1128
+ // void return does not count.
1129
+ if (node.argument === null) {
1130
+ return false;
1131
+ }
1132
+ return true;
1133
+ }
1134
+ default:
1135
+ {
1136
+ return false;
1137
+ }
1138
+ }
826
1139
  };
1140
+
827
1141
  /**
828
- * Checks if a node has a return statement. Void return does not count.
829
- * @param {ESTreeOrTypeScriptNode} node
830
- * @param {boolean} [checkYieldReturnValue]
831
- * @returns {boolean}
832
- */
1142
+ * Checks if a node has a return statement. Void return does not count.
1143
+ * @param {ESTreeOrTypeScriptNode} node
1144
+ * @param {boolean} [checkYieldReturnValue]
1145
+ * @returns {boolean}
1146
+ */
833
1147
  const hasYieldValue = (node, checkYieldReturnValue) => {
834
- return node.generator && (node.expression || hasNonFunctionYield(
835
- /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */
836
- node.body,
837
- checkYieldReturnValue
838
- ));
1148
+ return /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */node.generator && (/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */node.expression || hasNonFunctionYield(/** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */
1149
+ node.body, checkYieldReturnValue));
839
1150
  };
1151
+
840
1152
  /**
841
- * Checks if a node has a throws statement.
842
- * @param {ESTreeOrTypeScriptNode|null|undefined} node
843
- * @param {boolean} [innerFunction]
844
- * @returns {boolean}
845
- */
1153
+ * Checks if a node has a throws statement.
1154
+ * @param {ESTreeOrTypeScriptNode|null|undefined} node
1155
+ * @param {boolean} [innerFunction]
1156
+ * @returns {boolean}
1157
+ */
1158
+ // eslint-disable-next-line complexity
1159
+ exports.hasYieldValue = hasYieldValue;
846
1160
  const hasThrowValue = (node, innerFunction) => {
847
- if (!node) return false;
848
- switch (node.type) {
849
- case "ArrowFunctionExpression":
850
- case "FunctionDeclaration":
851
- case "FunctionExpression": return !innerFunction && !node.async && hasThrowValue(node.body, true);
852
- case "BlockStatement": return node.body.some((bodyNode) => {
853
- return bodyNode.type !== "FunctionDeclaration" && hasThrowValue(bodyNode);
854
- });
855
- case "DoWhileStatement":
856
- case "ForInStatement":
857
- case "ForOfStatement":
858
- case "ForStatement":
859
- case "LabeledStatement":
860
- case "WhileStatement":
861
- case "WithStatement": return hasThrowValue(node.body);
862
- case "IfStatement": return hasThrowValue(node.consequent) || hasThrowValue(node.alternate);
863
- case "SwitchStatement": return node.cases.some((someCase) => {
864
- return someCase.consequent.some((nde) => {
865
- return hasThrowValue(nde);
866
- });
867
- });
868
- case "ThrowStatement": return true;
869
- case "TryStatement": return hasThrowValue(node.handler && node.handler.body) || hasThrowValue(node.finalizer);
870
- default: return false;
871
- }
1161
+ if (!node) {
1162
+ return false;
1163
+ }
1164
+
1165
+ // There are cases where a function may execute its inner function which
1166
+ // throws, but we're treating functions atomically rather than trying to
1167
+ // follow them
1168
+ switch (node.type) {
1169
+ case 'ArrowFunctionExpression':
1170
+ case 'FunctionDeclaration':
1171
+ case 'FunctionExpression':
1172
+ {
1173
+ return !innerFunction && !node.async && hasThrowValue(node.body, true);
1174
+ }
1175
+ case 'BlockStatement':
1176
+ {
1177
+ return node.body.some(bodyNode => {
1178
+ return bodyNode.type !== 'FunctionDeclaration' && hasThrowValue(bodyNode);
1179
+ });
1180
+ }
1181
+ case 'DoWhileStatement':
1182
+ case 'ForInStatement':
1183
+ case 'ForOfStatement':
1184
+ case 'ForStatement':
1185
+ case 'LabeledStatement':
1186
+ case 'WhileStatement':
1187
+ case 'WithStatement':
1188
+ {
1189
+ return hasThrowValue(node.body);
1190
+ }
1191
+ case 'IfStatement':
1192
+ {
1193
+ return hasThrowValue(node.consequent) || hasThrowValue(node.alternate);
1194
+ }
1195
+ case 'SwitchStatement':
1196
+ {
1197
+ return node.cases.some(someCase => {
1198
+ return someCase.consequent.some(nde => {
1199
+ return hasThrowValue(nde);
1200
+ });
1201
+ });
1202
+ }
1203
+ case 'ThrowStatement':
1204
+ {
1205
+ return true;
1206
+ }
1207
+
1208
+ // We only consider it to throw an error if the catch or finally blocks throw an error.
1209
+ case 'TryStatement':
1210
+ {
1211
+ return hasThrowValue(node.handler && node.handler.body) || hasThrowValue(node.finalizer);
1212
+ }
1213
+ default:
1214
+ {
1215
+ return false;
1216
+ }
1217
+ }
872
1218
  };
1219
+
873
1220
  /**
874
- * @param {string} tag
1221
+ * @param {string} tag
1222
+ */
1223
+ /*
1224
+ const isInlineTag = (tag) => {
1225
+ return /^(@link|@linkcode|@linkplain|@tutorial) /v.test(tag);
1226
+ };
875
1227
  */
1228
+
876
1229
  /**
877
- * Parses GCC Generic/Template types
878
- * @see {@link https://github.com/google/closure-compiler/wiki/Generic-Types}
879
- * @see {@link https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template}
880
- * @param {import('comment-parser').Spec} tag
881
- * @returns {string[]}
882
- */
883
- const parseClosureTemplateTag = (tag) => {
884
- return tag.name.split(",").map((type) => {
885
- return type.trim().replace(/^\[?(?<name>.*?)=.*$/v, "$<name>");
886
- });
1230
+ * Parses GCC Generic/Template types
1231
+ * @see {@link https://github.com/google/closure-compiler/wiki/Generic-Types}
1232
+ * @see {@link https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#template}
1233
+ * @param {import('comment-parser').Spec} tag
1234
+ * @returns {string[]}
1235
+ */
1236
+ exports.hasThrowValue = hasThrowValue;
1237
+ const parseClosureTemplateTag = tag => {
1238
+ return tag.name.split(',').map(type => {
1239
+ return type.trim().replace(/^\[?(?<name>.*?)=.*$/v, '$<name>');
1240
+ });
887
1241
  };
1242
+
888
1243
  /**
889
- * @typedef {true|string[]} DefaultContexts
890
- */
1244
+ * @typedef {true|string[]} DefaultContexts
1245
+ */
1246
+
891
1247
  /**
892
- * Checks user option for `contexts` array, defaulting to
893
- * contexts designated by the rule. Returns an array of
894
- * ESTree AST types, indicating allowable contexts.
895
- * @param {import('eslint').Rule.RuleContext} context
896
- * @param {DefaultContexts|undefined} defaultContexts
897
- * @param {{
898
- * contexts?: import('./iterateJsdoc.js').Context[]
899
- * }} settings
900
- * @returns {(string|import('./iterateJsdoc.js').ContextObject)[]}
901
- */
1248
+ * Checks user option for `contexts` array, defaulting to
1249
+ * contexts designated by the rule. Returns an array of
1250
+ * ESTree AST types, indicating allowable contexts.
1251
+ * @param {import('eslint').Rule.RuleContext} context
1252
+ * @param {DefaultContexts|undefined} defaultContexts
1253
+ * @param {{
1254
+ * contexts?: import('./iterateJsdoc.js').Context[]
1255
+ * }} settings
1256
+ * @returns {(string|import('./iterateJsdoc.js').ContextObject)[]}
1257
+ */
1258
+ exports.parseClosureTemplateTag = parseClosureTemplateTag;
902
1259
  const enforcedContexts = (context, defaultContexts, settings) => {
903
- const contexts = context.options[0]?.contexts || settings.contexts || (defaultContexts === true ? [
904
- "ArrowFunctionExpression",
905
- "FunctionDeclaration",
906
- "FunctionExpression",
907
- "TSDeclareFunction"
908
- ] : defaultContexts);
909
- return contexts;
1260
+ const contexts = context.options[0]?.contexts || settings.contexts || (defaultContexts === true ? ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction'] : defaultContexts);
1261
+ return contexts;
910
1262
  };
1263
+
911
1264
  /**
912
- * @param {import('./iterateJsdoc.js').Context[]} contexts
913
- * @param {import('./iterateJsdoc.js').CheckJsdoc} checkJsdoc
914
- * @param {import('@es-joy/jsdoccomment').CommentHandler} [handler]
915
- * @returns {import('eslint').Rule.RuleListener}
916
- */
1265
+ * @param {import('./iterateJsdoc.js').Context[]} contexts
1266
+ * @param {import('./iterateJsdoc.js').CheckJsdoc} checkJsdoc
1267
+ * @param {import('@es-joy/jsdoccomment').CommentHandler} [handler]
1268
+ * @returns {import('eslint').Rule.RuleListener}
1269
+ */
1270
+ exports.enforcedContexts = enforcedContexts;
917
1271
  const getContextObject = (contexts, checkJsdoc, handler) => {
918
- /** @type {import('eslint').Rule.RuleListener} */
919
- const properties = {};
920
- for (const [idx, prop] of contexts.entries()) {
921
- /** @type {string} */
922
- let property;
923
- /** @type {(node: import('eslint').Rule.Node) => void} */
924
- let value;
925
- if (typeof prop === "object") {
926
- const selInfo = {
927
- lastIndex: idx,
928
- selector: prop.context
929
- };
930
- if (prop.comment) {
931
- property = prop.context;
932
- value = checkJsdoc.bind(
933
- null,
934
- {
935
- ...selInfo,
936
- comment: prop.comment
937
- },
938
- /** @type {import('@es-joy/jsdoccomment').CommentHandler} */
939
- handler.bind(null, prop.comment)
940
- );
941
- } else {
942
- property = prop.context;
943
- value = checkJsdoc.bind(null, selInfo, null);
944
- }
945
- } else {
946
- const selInfo = {
947
- lastIndex: idx,
948
- selector: prop
949
- };
950
- property = prop;
951
- value = checkJsdoc.bind(null, selInfo, null);
952
- }
953
- const old = properties[property];
954
- properties[property] = old ? function(node) {
955
- old(node);
956
- value(node);
957
- } : value;
958
- }
959
- return properties;
1272
+ /** @type {import('eslint').Rule.RuleListener} */
1273
+ const properties = {};
1274
+ for (const [idx, prop] of contexts.entries()) {
1275
+ /** @type {string} */
1276
+ let property;
1277
+
1278
+ /** @type {(node: import('eslint').Rule.Node) => void} */
1279
+ let value;
1280
+ if (typeof prop === 'object') {
1281
+ const selInfo = {
1282
+ lastIndex: idx,
1283
+ selector: prop.context
1284
+ };
1285
+ if (prop.comment) {
1286
+ property = /** @type {string} */prop.context;
1287
+ value = checkJsdoc.bind(null, {
1288
+ ...selInfo,
1289
+ comment: prop.comment
1290
+ },
1291
+ /**
1292
+ * @type {(jsdoc: import('@es-joy/jsdoccomment').JsdocBlockWithInline) => boolean}
1293
+ */
1294
+ /** @type {import('@es-joy/jsdoccomment').CommentHandler} */
1295
+ handler.bind(null, prop.comment));
1296
+ } else {
1297
+ property = /** @type {string} */prop.context;
1298
+ value = checkJsdoc.bind(null, selInfo, null);
1299
+ }
1300
+ } else {
1301
+ const selInfo = {
1302
+ lastIndex: idx,
1303
+ selector: prop
1304
+ };
1305
+ property = prop;
1306
+ value = checkJsdoc.bind(null, selInfo, null);
1307
+ }
1308
+ const old =
1309
+ /**
1310
+ * @type {((node: import('eslint').Rule.Node) => void)}
1311
+ */
1312
+ properties[property];
1313
+ properties[property] = old ?
1314
+ /**
1315
+ * @type {((node: import('eslint').Rule.Node) => void)}
1316
+ */
1317
+ function (node) {
1318
+ old(node);
1319
+ value(node);
1320
+ } : value;
1321
+ }
1322
+ return properties;
960
1323
  };
961
- const tagsWithNamesAndDescriptions = new Set([
962
- "arg",
963
- "argument",
964
- "param",
965
- "prop",
966
- "property",
967
- "return",
968
- "returns",
969
- "template"
970
- ]);
1324
+ exports.getContextObject = getContextObject;
1325
+ const tagsWithNamesAndDescriptions = new Set(['arg', 'argument', 'param', 'prop', 'property', 'return',
1326
+ // These two are parsed by our custom parser as though having a `name`
1327
+ 'returns', 'template']);
1328
+
971
1329
  /**
972
- * @typedef {{
973
- * [key: string]: false|string|
974
- * {message: string, replacement?: string}
975
- * }} TagNamePreference
976
- */
1330
+ * @typedef {{
1331
+ * [key: string]: false|string|
1332
+ * {message: string, replacement?: string}
1333
+ * }} TagNamePreference
1334
+ */
1335
+
977
1336
  /**
978
- * @param {import('eslint').Rule.RuleContext} context
979
- * @param {ParserMode|undefined} mode
980
- * @param {import('comment-parser').Spec[]} tags
981
- * @returns {{
982
- * tagsWithNames: import('comment-parser').Spec[],
983
- * tagsWithoutNames: import('comment-parser').Spec[]
984
- * }}
985
- */
1337
+ * @param {import('eslint').Rule.RuleContext} context
1338
+ * @param {ParserMode|undefined} mode
1339
+ * @param {import('comment-parser').Spec[]} tags
1340
+ * @returns {{
1341
+ * tagsWithNames: import('comment-parser').Spec[],
1342
+ * tagsWithoutNames: import('comment-parser').Spec[]
1343
+ * }}
1344
+ */
986
1345
  const getTagsByType = (context, mode, tags) => {
987
- /**
988
- * @type {import('comment-parser').Spec[]}
989
- */
990
- const tagsWithoutNames = [];
991
- const tagsWithNames = tags.filter((tag) => {
992
- const { tag: tagName } = tag;
993
- const tagWithName = tagsWithNamesAndDescriptions.has(tagName);
994
- if (!tagWithName) tagsWithoutNames.push(tag);
995
- return tagWithName;
996
- });
997
- return {
998
- tagsWithNames,
999
- tagsWithoutNames
1000
- };
1346
+ /**
1347
+ * @type {import('comment-parser').Spec[]}
1348
+ */
1349
+ const tagsWithoutNames = [];
1350
+ const tagsWithNames = tags.filter(tag => {
1351
+ const {
1352
+ tag: tagName
1353
+ } = tag;
1354
+ const tagWithName = tagsWithNamesAndDescriptions.has(tagName);
1355
+ if (!tagWithName) {
1356
+ tagsWithoutNames.push(tag);
1357
+ }
1358
+ return tagWithName;
1359
+ });
1360
+ return {
1361
+ tagsWithNames,
1362
+ tagsWithoutNames
1363
+ };
1001
1364
  };
1365
+
1002
1366
  /**
1003
- * @param {import('eslint').SourceCode|{
1004
- * text: string
1005
- * }} sourceCode
1006
- * @returns {string}
1007
- */
1008
- const getIndent = (sourceCode) => {
1009
- return (sourceCode.text.match(/^\n*([ \t]+)/v)?.[1] ?? "") + " ";
1367
+ * @param {import('eslint').SourceCode|{
1368
+ * text: string
1369
+ * }} sourceCode
1370
+ * @returns {string}
1371
+ */
1372
+ exports.getTagsByType = getTagsByType;
1373
+ const getIndent = sourceCode => {
1374
+ return (sourceCode.text.match(/^\n*([ \t]+)/v)?.[1] ?? '') + ' ';
1010
1375
  };
1376
+
1011
1377
  /**
1012
- * @param {import('eslint').Rule.Node|null} node
1013
- * @returns {boolean}
1014
- */
1015
- const isConstructor = (node) => {
1016
- return node?.type === "MethodDefinition" && node.kind === "constructor" || (node?.parent)?.kind === "constructor";
1378
+ * @param {import('eslint').Rule.Node|null} node
1379
+ * @returns {boolean}
1380
+ */
1381
+ exports.getIndent = getIndent;
1382
+ const isConstructor = node => {
1383
+ return node?.type === 'MethodDefinition' && node.kind === 'constructor' || /** @type {import('@typescript-eslint/types').TSESTree.MethodDefinition} */node?.parent?.kind === 'constructor';
1017
1384
  };
1385
+
1018
1386
  /**
1019
- * @param {import('eslint').Rule.Node|null} node
1020
- * @returns {boolean}
1021
- */
1022
- const isGetter = (node) => {
1023
- return node !== null && node.parent?.kind === "get";
1387
+ * @param {import('eslint').Rule.Node|null} node
1388
+ * @returns {boolean}
1389
+ */
1390
+ exports.isConstructor = isConstructor;
1391
+ const isGetter = node => {
1392
+ return node !== null &&
1393
+ /**
1394
+ * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
1395
+ * import('@typescript-eslint/types').TSESTree.Property}
1396
+ */
1397
+ node.parent?.kind === 'get';
1024
1398
  };
1399
+
1025
1400
  /**
1026
- * @param {import('eslint').Rule.Node|null} node
1027
- * @returns {boolean}
1028
- */
1029
- const isSetter = (node) => {
1030
- return node !== null && node.parent?.kind === "set";
1401
+ * @param {import('eslint').Rule.Node|null} node
1402
+ * @returns {boolean}
1403
+ */
1404
+ exports.isGetter = isGetter;
1405
+ const isSetter = node => {
1406
+ return node !== null &&
1407
+ /**
1408
+ * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
1409
+ * import('@typescript-eslint/types').TSESTree.Property}
1410
+ */
1411
+ node.parent?.kind === 'set';
1031
1412
  };
1413
+
1032
1414
  /**
1033
- * @param {import('eslint').Rule.Node} node
1034
- * @returns {boolean}
1035
- */
1036
- const hasAccessorPair = (node) => {
1037
- const { key, kind: sourceKind, type } = node;
1038
- const sourceName = key.name;
1039
- const oppositeKind = sourceKind === "get" ? "set" : "get";
1040
- const sibling = type === "MethodDefinition" ? node.parent.body : node.parent.properties;
1041
- return sibling.some((child) => {
1042
- const { key: ky, kind } = child;
1043
- const name = ky.name;
1044
- return kind === oppositeKind && name === sourceName;
1045
- });
1415
+ * @param {import('eslint').Rule.Node} node
1416
+ * @returns {boolean}
1417
+ */
1418
+ exports.isSetter = isSetter;
1419
+ const hasAccessorPair = node => {
1420
+ const {
1421
+ key,
1422
+ kind: sourceKind,
1423
+ type
1424
+ } =
1425
+ /**
1426
+ * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
1427
+ * import('@typescript-eslint/types').TSESTree.Property}
1428
+ */
1429
+ node;
1430
+ const sourceName = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */key.name;
1431
+ const oppositeKind = sourceKind === 'get' ? 'set' : 'get';
1432
+ const sibling = type === 'MethodDefinition' ? /** @type {import('@typescript-eslint/types').TSESTree.ClassBody} */node.parent.body : /** @type {import('@typescript-eslint/types').TSESTree.ObjectExpression} */node.parent.properties;
1433
+ return sibling.some(child => {
1434
+ const {
1435
+ key: ky,
1436
+ kind
1437
+ } =
1438
+ /**
1439
+ * @type {import('@typescript-eslint/types').TSESTree.MethodDefinition|
1440
+ * import('@typescript-eslint/types').TSESTree.Property}
1441
+ */
1442
+ child;
1443
+ const name = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ky.name;
1444
+ return kind === oppositeKind && name === sourceName;
1445
+ });
1046
1446
  };
1447
+
1047
1448
  /**
1048
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
1049
- * @param {import('eslint').Rule.Node|null} node
1050
- * @param {import('eslint').Rule.RuleContext} context
1051
- * @param {import('json-schema').JSONSchema4} schema
1052
- * @returns {boolean}
1053
- */
1449
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
1450
+ * @param {import('eslint').Rule.Node|null} node
1451
+ * @param {import('eslint').Rule.RuleContext} context
1452
+ * @param {import('json-schema').JSONSchema4} schema
1453
+ * @returns {boolean}
1454
+ */
1054
1455
  const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
1055
- /**
1056
- * @param {"checkGetters"|"checkSetters"|"checkConstructors"} prop
1057
- * @returns {boolean|"no-setter"|"no-getter"}
1058
- */
1059
- const hasSchemaOption = (prop) => {
1060
- const schemaProperties = schema[0].properties;
1061
- return context.options[0]?.[prop] ?? (schemaProperties[prop] && schemaProperties[prop].default);
1062
- };
1063
- const checkGetters = hasSchemaOption("checkGetters");
1064
- const checkSetters = hasSchemaOption("checkSetters");
1065
- return !hasSchemaOption("checkConstructors") && (isConstructor(node) || hasATag(jsdoc, ["class", "constructor"])) || isGetter(node) && (!checkGetters || checkGetters === "no-setter" && hasAccessorPair(
1066
- /** @type {import('./iterateJsdoc.js').Node} */
1067
- node.parent
1068
- )) || isSetter(node) && (!checkSetters || checkSetters === "no-getter" && hasAccessorPair(
1069
- /** @type {import('./iterateJsdoc.js').Node} */
1070
- node.parent
1071
- ));
1456
+ /**
1457
+ * @param {"checkGetters"|"checkSetters"|"checkConstructors"} prop
1458
+ * @returns {boolean|"no-setter"|"no-getter"}
1459
+ */
1460
+ const hasSchemaOption = prop => {
1461
+ const schemaProperties = schema[0].properties;
1462
+ return context.options[0]?.[prop] ?? (schemaProperties[prop] && schemaProperties[prop].default);
1463
+ };
1464
+ const checkGetters = hasSchemaOption('checkGetters');
1465
+ const checkSetters = hasSchemaOption('checkSetters');
1466
+ return !hasSchemaOption('checkConstructors') && (isConstructor(node) || hasATag(jsdoc, ['class', 'constructor'])) || isGetter(node) && (!checkGetters || checkGetters === 'no-setter' && hasAccessorPair(/** @type {import('./iterateJsdoc.js').Node} */node.parent)) || isSetter(node) && (!checkSetters || checkSetters === 'no-getter' && hasAccessorPair(/** @type {import('./iterateJsdoc.js').Node} */node.parent));
1072
1467
  };
1468
+
1073
1469
  /**
1074
- * Since path segments may be unquoted (if matching a reserved word,
1075
- * identifier or numeric literal) or single or double quoted, in either
1076
- * the `@param` or in source, we need to strip the quotes to give a fair
1077
- * comparison.
1078
- * @param {string} str
1079
- * @returns {string}
1080
- */
1081
- const dropPathSegmentQuotes = (str) => {
1082
- return str.replaceAll(/\.(['"])(.*)\1/gv, ".$2");
1470
+ * Since path segments may be unquoted (if matching a reserved word,
1471
+ * identifier or numeric literal) or single or double quoted, in either
1472
+ * the `@param` or in source, we need to strip the quotes to give a fair
1473
+ * comparison.
1474
+ * @param {string} str
1475
+ * @returns {string}
1476
+ */
1477
+ exports.exemptSpeciaMethods = exemptSpeciaMethods;
1478
+ const dropPathSegmentQuotes = str => {
1479
+ return str.replaceAll(/\.(['"])(.*)\1/gv, '.$2');
1083
1480
  };
1481
+
1084
1482
  /**
1085
- * @param {string} name
1086
- * @returns {(otherPathName: string) => boolean}
1087
- */
1088
- const comparePaths = (name) => {
1089
- return (otherPathName) => {
1090
- return otherPathName === name || dropPathSegmentQuotes(otherPathName) === dropPathSegmentQuotes(name);
1091
- };
1483
+ * @param {string} name
1484
+ * @returns {(otherPathName: string) => boolean}
1485
+ */
1486
+ exports.dropPathSegmentQuotes = dropPathSegmentQuotes;
1487
+ const comparePaths = name => {
1488
+ return otherPathName => {
1489
+ return otherPathName === name || dropPathSegmentQuotes(otherPathName) === dropPathSegmentQuotes(name);
1490
+ };
1092
1491
  };
1492
+
1093
1493
  /**
1094
- * @callback PathDoesNotBeginWith
1095
- * @param {string} name
1096
- * @param {string} otherPathName
1097
- * @returns {boolean}
1098
- */
1494
+ * @callback PathDoesNotBeginWith
1495
+ * @param {string} name
1496
+ * @param {string} otherPathName
1497
+ * @returns {boolean}
1498
+ */
1499
+
1099
1500
  /** @type {PathDoesNotBeginWith} */
1501
+ exports.comparePaths = comparePaths;
1100
1502
  const pathDoesNotBeginWith = (name, otherPathName) => {
1101
- return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
1503
+ return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
1102
1504
  };
1505
+
1103
1506
  /**
1104
- * @param {string} regexString
1105
- * @param {string} [requiredFlags]
1106
- * @returns {RegExp}
1107
- */
1507
+ * @param {string} regexString
1508
+ * @param {string} [requiredFlags]
1509
+ * @returns {RegExp}
1510
+ */
1511
+ exports.pathDoesNotBeginWith = pathDoesNotBeginWith;
1108
1512
  const getRegexFromString = (regexString, requiredFlags) => {
1109
- const match = regexString.match(/^\/(.*)\/([gimyvus]*)$/sv);
1110
- let flags = "v";
1111
- let regex = regexString;
1112
- if (match) {
1113
- [, regex, flags] = match;
1114
- if (!flags) flags = "v";
1115
- }
1116
- const uniqueFlags = [...new Set(flags + (requiredFlags || ""))];
1117
- flags = uniqueFlags.join("");
1118
- return new RegExp(regex, flags);
1513
+ const match = regexString.match(/^\/(.*)\/([gimyvus]*)$/vs);
1514
+ let flags = 'v';
1515
+ let regex = regexString;
1516
+ if (match) {
1517
+ [, regex, flags] = match;
1518
+ if (!flags) {
1519
+ flags = 'v';
1520
+ }
1521
+ }
1522
+ const uniqueFlags = [...new Set(flags + (requiredFlags || ''))];
1523
+ flags = uniqueFlags.join('');
1524
+ return new RegExp(regex, flags);
1119
1525
  };
1120
-
1121
- //#endregion
1122
- exports.comparePaths = comparePaths;
1123
- exports.dropPathSegmentQuotes = dropPathSegmentQuotes;
1124
- exports.enforcedContexts = enforcedContexts;
1125
- exports.exemptSpeciaMethods = exemptSpeciaMethods;
1126
- exports.filterTags = filterTags;
1127
- exports.flattenRoots = flattenRoots;
1128
- exports.forEachPreferredTag = forEachPreferredTag;
1129
- exports.getAllTags = getAllTags;
1130
- exports.getContextObject = getContextObject;
1131
- exports.getFunctionParameterNames = getFunctionParameterNames;
1132
- exports.getIndent = getIndent;
1133
- exports.getJsdocTagsDeep = getJsdocTagsDeep;
1134
- exports.getPreferredTagName = getPreferredTagName;
1135
- exports.getPreferredTagNameSimple = getPreferredTagNameSimple;
1136
1526
  exports.getRegexFromString = getRegexFromString;
1137
- exports.getTagDescription = getTagDescription;
1138
- exports.getTagStructureForMode = getTagStructureForMode;
1139
- exports.getTags = getTags;
1140
- exports.getTagsByType = getTagsByType;
1141
- exports.hasATag = hasATag;
1142
- exports.hasParams = hasParams;
1143
- exports.hasTag = hasTag;
1144
- exports.hasThrowValue = hasThrowValue;
1145
- exports.hasYieldValue = hasYieldValue;
1146
- exports.isConstructor = isConstructor;
1147
- exports.isValidTag = isValidTag;
1148
- Object.defineProperty(exports, 'jsdocUtils_exports', {
1149
- enumerable: true,
1150
- get: function () {
1151
- return jsdocUtils_exports;
1152
- }
1153
- });
1154
- exports.mayBeUndefinedTypeTag = mayBeUndefinedTypeTag;
1155
- exports.overrideTagStructure = overrideTagStructure;
1156
- exports.parseClosureTemplateTag = parseClosureTemplateTag;
1157
- exports.pathDoesNotBeginWith = pathDoesNotBeginWith;
1158
- exports.setTagStructure = setTagStructure;
1159
- exports.tagMissingRequiredTypeOrNamepath = tagMissingRequiredTypeOrNamepath;
1160
1527
  //# sourceMappingURL=jsdocUtils.cjs.map