@depup/eslint-plugin-jsdoc 62.8.0-depup.0

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