eslint-plugin-jsdoc 52.0.4 → 53.0.1

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 +18 -35
  2. package/dist/WarnSettings.cjs.map +1 -1
  3. package/dist/WarnSettings.js +20 -0
  4. package/dist/WarnSettings.js.map +1 -0
  5. package/dist/_virtual/rolldown_runtime.cjs +32 -0
  6. package/dist/_virtual/rolldown_runtime.js +11 -0
  7. package/dist/alignTransform.cjs +224 -305
  8. package/dist/alignTransform.cjs.map +1 -1
  9. package/dist/alignTransform.js +241 -0
  10. package/dist/alignTransform.js.map +1 -0
  11. package/dist/defaultTagOrder.cjs +132 -43
  12. package/dist/defaultTagOrder.cjs.map +1 -1
  13. package/dist/defaultTagOrder.js +134 -0
  14. package/dist/defaultTagOrder.js.map +1 -0
  15. package/dist/exportParser.cjs +478 -696
  16. package/dist/exportParser.cjs.map +1 -1
  17. package/dist/exportParser.js +518 -0
  18. package/dist/exportParser.js.map +1 -0
  19. package/dist/getDefaultTagStructureForMode.cjs +184 -288
  20. package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
  21. package/dist/getDefaultTagStructureForMode.js +188 -0
  22. package/dist/getDefaultTagStructureForMode.js.map +1 -0
  23. package/dist/getJsdocProcessorPlugin.cjs +364 -550
  24. package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
  25. package/dist/getJsdocProcessorPlugin.d.cts +70 -0
  26. package/dist/getJsdocProcessorPlugin.d.cts.map +1 -0
  27. package/dist/getJsdocProcessorPlugin.d.ts +68 -65
  28. package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
  29. package/dist/getJsdocProcessorPlugin.js +383 -0
  30. package/dist/getJsdocProcessorPlugin.js.map +1 -0
  31. package/dist/index.cjs +2 -410
  32. package/dist/index.d.cts +2 -0
  33. package/dist/index.d.ts +2 -17
  34. package/dist/index.js +3 -0
  35. package/dist/iterateJsdoc.cjs +1539 -1988
  36. package/dist/iterateJsdoc.cjs.map +1 -1
  37. package/dist/iterateJsdoc.d.cts +472 -0
  38. package/dist/iterateJsdoc.d.cts.map +1 -0
  39. package/dist/iterateJsdoc.d.ts +359 -349
  40. package/dist/iterateJsdoc.d.ts.map +1 -1
  41. package/dist/iterateJsdoc.js +1628 -0
  42. package/dist/iterateJsdoc.js.map +1 -0
  43. package/dist/jsdocUtils.cjs +1009 -1376
  44. package/dist/jsdocUtils.cjs.map +1 -1
  45. package/dist/jsdocUtils.js +1123 -0
  46. package/dist/jsdocUtils.js.map +1 -0
  47. package/dist/plugin.cjs +427 -0
  48. package/dist/plugin.cjs.map +1 -0
  49. package/dist/plugin.js +427 -0
  50. package/dist/plugin.js.map +1 -0
  51. package/dist/rules/checkAccess.cjs +29 -36
  52. package/dist/rules/checkAccess.cjs.map +1 -1
  53. package/dist/rules/checkAccess.js +33 -0
  54. package/dist/rules/checkAccess.js.map +1 -0
  55. package/dist/rules/checkAlignment.cjs +41 -54
  56. package/dist/rules/checkAlignment.cjs.map +1 -1
  57. package/dist/rules/checkAlignment.js +47 -0
  58. package/dist/rules/checkAlignment.js.map +1 -0
  59. package/dist/rules/checkExamples.cjs +327 -484
  60. package/dist/rules/checkExamples.cjs.map +1 -1
  61. package/dist/rules/checkExamples.js +348 -0
  62. package/dist/rules/checkExamples.js.map +1 -0
  63. package/dist/rules/checkIndentation.cjs +50 -65
  64. package/dist/rules/checkIndentation.cjs.map +1 -1
  65. package/dist/rules/checkIndentation.js +59 -0
  66. package/dist/rules/checkIndentation.js.map +1 -0
  67. package/dist/rules/checkLineAlignment.cjs +220 -311
  68. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  69. package/dist/rules/checkLineAlignment.js +229 -0
  70. package/dist/rules/checkLineAlignment.js.map +1 -0
  71. package/dist/rules/checkParamNames.cjs +227 -335
  72. package/dist/rules/checkParamNames.cjs.map +1 -1
  73. package/dist/rules/checkParamNames.js +237 -0
  74. package/dist/rules/checkParamNames.js.map +1 -0
  75. package/dist/rules/checkPropertyNames.cjs +78 -106
  76. package/dist/rules/checkPropertyNames.cjs.map +1 -1
  77. package/dist/rules/checkPropertyNames.js +88 -0
  78. package/dist/rules/checkPropertyNames.js.map +1 -0
  79. package/dist/rules/checkSyntax.cjs +21 -34
  80. package/dist/rules/checkSyntax.cjs.map +1 -1
  81. package/dist/rules/checkSyntax.js +25 -0
  82. package/dist/rules/checkSyntax.js.map +1 -0
  83. package/dist/rules/checkTagNames.cjs +188 -210
  84. package/dist/rules/checkTagNames.cjs.map +1 -1
  85. package/dist/rules/checkTagNames.js +191 -0
  86. package/dist/rules/checkTagNames.js.map +1 -0
  87. package/dist/rules/checkTemplateNames.cjs +121 -178
  88. package/dist/rules/checkTemplateNames.cjs.map +1 -1
  89. package/dist/rules/checkTemplateNames.js +124 -0
  90. package/dist/rules/checkTemplateNames.js.map +1 -0
  91. package/dist/rules/checkTypes.cjs +291 -385
  92. package/dist/rules/checkTypes.cjs.map +1 -1
  93. package/dist/rules/checkTypes.js +299 -0
  94. package/dist/rules/checkTypes.js.map +1 -0
  95. package/dist/rules/checkValues.cjs +100 -146
  96. package/dist/rules/checkValues.cjs.map +1 -1
  97. package/dist/rules/checkValues.js +103 -0
  98. package/dist/rules/checkValues.js.map +1 -0
  99. package/dist/rules/convertToJsdocComments.cjs +228 -306
  100. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  101. package/dist/rules/convertToJsdocComments.js +231 -0
  102. package/dist/rules/convertToJsdocComments.js.map +1 -0
  103. package/dist/rules/emptyTags.cjs +62 -72
  104. package/dist/rules/emptyTags.cjs.map +1 -1
  105. package/dist/rules/emptyTags.js +67 -0
  106. package/dist/rules/emptyTags.js.map +1 -0
  107. package/dist/rules/implementsOnClasses.cjs +36 -56
  108. package/dist/rules/implementsOnClasses.cjs.map +1 -1
  109. package/dist/rules/implementsOnClasses.js +40 -0
  110. package/dist/rules/implementsOnClasses.js.map +1 -0
  111. package/dist/rules/importsAsDependencies.cjs +62 -99
  112. package/dist/rules/importsAsDependencies.cjs.map +1 -1
  113. package/dist/rules/importsAsDependencies.js +68 -0
  114. package/dist/rules/importsAsDependencies.js.map +1 -0
  115. package/dist/rules/informativeDocs.cjs +105 -142
  116. package/dist/rules/informativeDocs.cjs.map +1 -1
  117. package/dist/rules/informativeDocs.js +110 -0
  118. package/dist/rules/informativeDocs.js.map +1 -0
  119. package/dist/rules/linesBeforeBlock.cjs +70 -105
  120. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  121. package/dist/rules/linesBeforeBlock.js +75 -0
  122. package/dist/rules/linesBeforeBlock.js.map +1 -0
  123. package/dist/rules/matchDescription.cjs +160 -222
  124. package/dist/rules/matchDescription.cjs.map +1 -1
  125. package/dist/rules/matchDescription.js +167 -0
  126. package/dist/rules/matchDescription.js.map +1 -0
  127. package/dist/rules/matchName.cjs +73 -128
  128. package/dist/rules/matchName.cjs.map +1 -1
  129. package/dist/rules/matchName.js +77 -0
  130. package/dist/rules/matchName.js.map +1 -0
  131. package/dist/rules/multilineBlocks.cjs +235 -352
  132. package/dist/rules/multilineBlocks.cjs.map +1 -1
  133. package/dist/rules/multilineBlocks.js +245 -0
  134. package/dist/rules/multilineBlocks.js.map +1 -0
  135. package/dist/rules/noBadBlocks.cjs +63 -86
  136. package/dist/rules/noBadBlocks.cjs.map +1 -1
  137. package/dist/rules/noBadBlocks.js +68 -0
  138. package/dist/rules/noBadBlocks.js.map +1 -0
  139. package/dist/rules/noBlankBlockDescriptions.cjs +35 -57
  140. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
  141. package/dist/rules/noBlankBlockDescriptions.js +41 -0
  142. package/dist/rules/noBlankBlockDescriptions.js.map +1 -0
  143. package/dist/rules/noBlankBlocks.cjs +26 -48
  144. package/dist/rules/noBlankBlocks.cjs.map +1 -1
  145. package/dist/rules/noBlankBlocks.js +30 -0
  146. package/dist/rules/noBlankBlocks.js.map +1 -0
  147. package/dist/rules/noDefaults.cjs +52 -79
  148. package/dist/rules/noDefaults.cjs.map +1 -1
  149. package/dist/rules/noDefaults.js +56 -0
  150. package/dist/rules/noDefaults.js.map +1 -0
  151. package/dist/rules/noMissingSyntax.cjs +115 -165
  152. package/dist/rules/noMissingSyntax.cjs.map +1 -1
  153. package/dist/rules/noMissingSyntax.js +126 -0
  154. package/dist/rules/noMissingSyntax.js.map +1 -0
  155. package/dist/rules/noMultiAsterisks.cjs +48 -89
  156. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  157. package/dist/rules/noMultiAsterisks.js +58 -0
  158. package/dist/rules/noMultiAsterisks.js.map +1 -0
  159. package/dist/rules/noRestrictedSyntax.cjs +45 -79
  160. package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
  161. package/dist/rules/noRestrictedSyntax.js +49 -0
  162. package/dist/rules/noRestrictedSyntax.js.map +1 -0
  163. package/dist/rules/noTypes.cjs +59 -80
  164. package/dist/rules/noTypes.cjs.map +1 -1
  165. package/dist/rules/noTypes.js +65 -0
  166. package/dist/rules/noTypes.js.map +1 -0
  167. package/dist/rules/noUndefinedTypes.cjs +297 -388
  168. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  169. package/dist/rules/noUndefinedTypes.js +303 -0
  170. package/dist/rules/noUndefinedTypes.js.map +1 -0
  171. package/dist/rules/requireAsteriskPrefix.cjs +108 -159
  172. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  173. package/dist/rules/requireAsteriskPrefix.js +112 -0
  174. package/dist/rules/requireAsteriskPrefix.js.map +1 -0
  175. package/dist/rules/requireDescription.cjs +89 -129
  176. package/dist/rules/requireDescription.cjs.map +1 -1
  177. package/dist/rules/requireDescription.js +95 -0
  178. package/dist/rules/requireDescription.js.map +1 -0
  179. package/dist/rules/requireDescriptionCompleteSentence.cjs +201 -262
  180. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  181. package/dist/rules/requireDescriptionCompleteSentence.js +220 -0
  182. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -0
  183. package/dist/rules/requireExample.cjs +73 -104
  184. package/dist/rules/requireExample.cjs.map +1 -1
  185. package/dist/rules/requireExample.js +77 -0
  186. package/dist/rules/requireExample.js.map +1 -0
  187. package/dist/rules/requireFileOverview.cjs +75 -129
  188. package/dist/rules/requireFileOverview.cjs.map +1 -1
  189. package/dist/rules/requireFileOverview.js +81 -0
  190. package/dist/rules/requireFileOverview.js.map +1 -0
  191. package/dist/rules/requireHyphenBeforeParamDescription.cjs +85 -133
  192. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  193. package/dist/rules/requireHyphenBeforeParamDescription.js +89 -0
  194. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -0
  195. package/dist/rules/requireJsdoc.cjs +384 -557
  196. package/dist/rules/requireJsdoc.cjs.map +1 -1
  197. package/dist/rules/requireJsdoc.js +404 -0
  198. package/dist/rules/requireJsdoc.js.map +1 -0
  199. package/dist/rules/requireParam.cjs +336 -526
  200. package/dist/rules/requireParam.cjs.map +1 -1
  201. package/dist/rules/requireParam.js +344 -0
  202. package/dist/rules/requireParam.js.map +1 -0
  203. package/dist/rules/requireParamDescription.cjs +55 -80
  204. package/dist/rules/requireParamDescription.cjs.map +1 -1
  205. package/dist/rules/requireParamDescription.js +59 -0
  206. package/dist/rules/requireParamDescription.js.map +1 -0
  207. package/dist/rules/requireParamName.cjs +32 -50
  208. package/dist/rules/requireParamName.cjs.map +1 -1
  209. package/dist/rules/requireParamName.js +36 -0
  210. package/dist/rules/requireParamName.js.map +1 -0
  211. package/dist/rules/requireParamType.cjs +55 -80
  212. package/dist/rules/requireParamType.cjs.map +1 -1
  213. package/dist/rules/requireParamType.js +59 -0
  214. package/dist/rules/requireParamType.js.map +1 -0
  215. package/dist/rules/requireProperty.cjs +31 -42
  216. package/dist/rules/requireProperty.cjs.map +1 -1
  217. package/dist/rules/requireProperty.js +35 -0
  218. package/dist/rules/requireProperty.js.map +1 -0
  219. package/dist/rules/requirePropertyDescription.cjs +17 -25
  220. package/dist/rules/requirePropertyDescription.cjs.map +1 -1
  221. package/dist/rules/requirePropertyDescription.js +21 -0
  222. package/dist/rules/requirePropertyDescription.js.map +1 -0
  223. package/dist/rules/requirePropertyName.cjs +17 -25
  224. package/dist/rules/requirePropertyName.cjs.map +1 -1
  225. package/dist/rules/requirePropertyName.js +21 -0
  226. package/dist/rules/requirePropertyName.js.map +1 -0
  227. package/dist/rules/requirePropertyType.cjs +17 -25
  228. package/dist/rules/requirePropertyType.cjs.map +1 -1
  229. package/dist/rules/requirePropertyType.js +21 -0
  230. package/dist/rules/requirePropertyType.js.map +1 -0
  231. package/dist/rules/requireReturns.cjs +125 -203
  232. package/dist/rules/requireReturns.cjs.map +1 -1
  233. package/dist/rules/requireReturns.js +131 -0
  234. package/dist/rules/requireReturns.js.map +1 -0
  235. package/dist/rules/requireReturnsCheck.cjs +60 -103
  236. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  237. package/dist/rules/requireReturnsCheck.js +66 -0
  238. package/dist/rules/requireReturnsCheck.js.map +1 -0
  239. package/dist/rules/requireReturnsDescription.cjs +39 -54
  240. package/dist/rules/requireReturnsDescription.cjs.map +1 -1
  241. package/dist/rules/requireReturnsDescription.js +43 -0
  242. package/dist/rules/requireReturnsDescription.js.map +1 -0
  243. package/dist/rules/requireReturnsType.cjs +32 -50
  244. package/dist/rules/requireReturnsType.cjs.map +1 -1
  245. package/dist/rules/requireReturnsType.js +36 -0
  246. package/dist/rules/requireReturnsType.js.map +1 -0
  247. package/dist/rules/requireTemplate.cjs +119 -178
  248. package/dist/rules/requireTemplate.cjs.map +1 -1
  249. package/dist/rules/requireTemplate.js +122 -0
  250. package/dist/rules/requireTemplate.js.map +1 -0
  251. package/dist/rules/requireThrows.cjs +61 -95
  252. package/dist/rules/requireThrows.cjs.map +1 -1
  253. package/dist/rules/requireThrows.js +67 -0
  254. package/dist/rules/requireThrows.js.map +1 -0
  255. package/dist/rules/requireYields.cjs +106 -166
  256. package/dist/rules/requireYields.cjs.map +1 -1
  257. package/dist/rules/requireYields.js +115 -0
  258. package/dist/rules/requireYields.js.map +1 -0
  259. package/dist/rules/requireYieldsCheck.cjs +96 -152
  260. package/dist/rules/requireYieldsCheck.cjs.map +1 -1
  261. package/dist/rules/requireYieldsCheck.js +105 -0
  262. package/dist/rules/requireYieldsCheck.js.map +1 -0
  263. package/dist/rules/sortTags.cjs +258 -444
  264. package/dist/rules/sortTags.cjs.map +1 -1
  265. package/dist/rules/sortTags.js +262 -0
  266. package/dist/rules/sortTags.js.map +1 -0
  267. package/dist/rules/tagLines.cjs +179 -266
  268. package/dist/rules/tagLines.cjs.map +1 -1
  269. package/dist/rules/tagLines.js +183 -0
  270. package/dist/rules/tagLines.js.map +1 -0
  271. package/dist/rules/textEscaping.cjs +92 -127
  272. package/dist/rules/textEscaping.cjs.map +1 -1
  273. package/dist/rules/textEscaping.js +102 -0
  274. package/dist/rules/textEscaping.js.map +1 -0
  275. package/dist/rules/validTypes.cjs +252 -265
  276. package/dist/rules/validTypes.cjs.map +1 -1
  277. package/dist/rules/validTypes.js +259 -0
  278. package/dist/rules/validTypes.js.map +1 -0
  279. package/dist/tagNames.cjs +134 -170
  280. package/dist/tagNames.cjs.map +1 -1
  281. package/dist/tagNames.js +144 -0
  282. package/dist/tagNames.js.map +1 -0
  283. package/dist/utils/hasReturnValue.cjs +246 -474
  284. package/dist/utils/hasReturnValue.cjs.map +1 -1
  285. package/dist/utils/hasReturnValue.js +265 -0
  286. package/dist/utils/hasReturnValue.js.map +1 -0
  287. package/package.json +40 -24
  288. package/dist/generateRule.cjs +0 -242
  289. package/dist/generateRule.cjs.map +0 -1
  290. package/dist/index.cjs.map +0 -1
  291. package/dist/index.d.ts.map +0 -1
  292. package/src/WarnSettings.js +0 -34
  293. package/src/alignTransform.js +0 -358
  294. package/src/defaultTagOrder.js +0 -169
  295. package/src/exportParser.js +0 -978
  296. package/src/getDefaultTagStructureForMode.js +0 -969
  297. package/src/getJsdocProcessorPlugin.js +0 -672
  298. package/src/index.js +0 -530
  299. package/src/iterateJsdoc.js +0 -2518
  300. package/src/jsdocUtils.js +0 -1896
  301. package/src/rules/checkAccess.js +0 -45
  302. package/src/rules/checkAlignment.js +0 -63
  303. package/src/rules/checkExamples.js +0 -589
  304. package/src/rules/checkIndentation.js +0 -75
  305. package/src/rules/checkLineAlignment.js +0 -372
  306. package/src/rules/checkParamNames.js +0 -474
  307. package/src/rules/checkPropertyNames.js +0 -152
  308. package/src/rules/checkSyntax.js +0 -30
  309. package/src/rules/checkTagNames.js +0 -314
  310. package/src/rules/checkTemplateNames.js +0 -204
  311. package/src/rules/checkTypes.js +0 -535
  312. package/src/rules/checkValues.js +0 -248
  313. package/src/rules/convertToJsdocComments.js +0 -398
  314. package/src/rules/emptyTags.js +0 -98
  315. package/src/rules/implementsOnClasses.js +0 -64
  316. package/src/rules/importsAsDependencies.js +0 -133
  317. package/src/rules/informativeDocs.js +0 -189
  318. package/src/rules/linesBeforeBlock.js +0 -134
  319. package/src/rules/matchDescription.js +0 -286
  320. package/src/rules/matchName.js +0 -151
  321. package/src/rules/multilineBlocks.js +0 -493
  322. package/src/rules/noBadBlocks.js +0 -119
  323. package/src/rules/noBlankBlockDescriptions.js +0 -69
  324. package/src/rules/noBlankBlocks.js +0 -53
  325. package/src/rules/noDefaults.js +0 -85
  326. package/src/rules/noMissingSyntax.js +0 -195
  327. package/src/rules/noMultiAsterisks.js +0 -134
  328. package/src/rules/noRestrictedSyntax.js +0 -91
  329. package/src/rules/noTypes.js +0 -93
  330. package/src/rules/noUndefinedTypes.js +0 -543
  331. package/src/rules/requireAsteriskPrefix.js +0 -190
  332. package/src/rules/requireDescription.js +0 -161
  333. package/src/rules/requireDescriptionCompleteSentence.js +0 -335
  334. package/src/rules/requireExample.js +0 -118
  335. package/src/rules/requireFileOverview.js +0 -154
  336. package/src/rules/requireHyphenBeforeParamDescription.js +0 -176
  337. package/src/rules/requireJsdoc.js +0 -743
  338. package/src/rules/requireParam.js +0 -602
  339. package/src/rules/requireParamDescription.js +0 -89
  340. package/src/rules/requireParamName.js +0 -55
  341. package/src/rules/requireParamType.js +0 -89
  342. package/src/rules/requireProperty.js +0 -48
  343. package/src/rules/requirePropertyDescription.js +0 -25
  344. package/src/rules/requirePropertyName.js +0 -25
  345. package/src/rules/requirePropertyType.js +0 -25
  346. package/src/rules/requireReturns.js +0 -238
  347. package/src/rules/requireReturnsCheck.js +0 -145
  348. package/src/rules/requireReturnsDescription.js +0 -59
  349. package/src/rules/requireReturnsType.js +0 -51
  350. package/src/rules/requireTemplate.js +0 -201
  351. package/src/rules/requireThrows.js +0 -111
  352. package/src/rules/requireYields.js +0 -216
  353. package/src/rules/requireYieldsCheck.js +0 -208
  354. package/src/rules/sortTags.js +0 -558
  355. package/src/rules/tagLines.js +0 -359
  356. package/src/rules/textEscaping.js +0 -154
  357. package/src/rules/validTypes.js +0 -401
  358. package/src/tagNames.js +0 -238
  359. package/src/utils/hasReturnValue.js +0 -572
@@ -1,1527 +1,1160 @@
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
- }
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
19
56
  });
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 }; }
27
57
  /**
28
- * @typedef {number} Integer
29
- */
58
+ * @typedef {number} Integer
59
+ */
30
60
  /**
31
- * @typedef {import('./utils/hasReturnValue.js').ESTreeOrTypeScriptNode} ESTreeOrTypeScriptNode
32
- */
33
-
61
+ * @typedef {import('./utils/hasReturnValue.js').ESTreeOrTypeScriptNode} ESTreeOrTypeScriptNode
62
+ */
34
63
  /**
35
- * @typedef {"jsdoc"|"typescript"|"closure"|"permissive"} ParserMode
36
- */
37
-
64
+ * @typedef {"jsdoc"|"typescript"|"closure"|"permissive"} ParserMode
65
+ */
38
66
  /**
39
- * @type {import('./getDefaultTagStructureForMode.js').TagStructure}
40
- */
67
+ * @type {import('./getDefaultTagStructureForMode.js').TagStructure}
68
+ */
41
69
  let tagStructure;
42
-
43
70
  /**
44
- * @param {ParserMode} mode
45
- * @returns {void}
46
- */
47
- const setTagStructure = mode => {
48
- tagStructure = (0, _getDefaultTagStructureForMode.default)(mode);
71
+ * @param {ParserMode} mode
72
+ * @returns {void}
73
+ */
74
+ const setTagStructure = (mode) => {
75
+ tagStructure = require_getDefaultTagStructureForMode.default(mode);
49
76
  };
50
-
51
77
  /**
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
- */
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
+ */
64
90
  /**
65
- * @typedef {ParamCommon|[string|undefined, (FlattendRootInfo & {
66
- * annotationParamName?: string,
67
- * })]|NestedParamInfo} ParamNameInfo
68
- */
69
-
91
+ * @typedef {ParamCommon|[string|undefined, (FlattendRootInfo & {
92
+ * annotationParamName?: string,
93
+ * })]|NestedParamInfo} ParamNameInfo
94
+ */
70
95
  /**
71
- * @typedef {{
72
- * hasPropertyRest: boolean,
73
- * hasRestElement: boolean,
74
- * names: string[],
75
- * rests: boolean[],
76
- * }} FlattendRootInfo
77
- */
96
+ * @typedef {{
97
+ * hasPropertyRest: boolean,
98
+ * hasRestElement: boolean,
99
+ * names: string[],
100
+ * rests: boolean[],
101
+ * }} FlattendRootInfo
102
+ */
78
103
  /**
79
- * @typedef {[string, (string[]|ParamInfo[])]} NestedParamInfo
80
- */
104
+ * @typedef {[string, (string[]|ParamInfo[])]} NestedParamInfo
105
+ */
81
106
  /**
82
- * @typedef {ParamCommon|
83
- * [string|undefined, (FlattendRootInfo & {
84
- * annotationParamName?: string
85
- * })]|
86
- * NestedParamInfo} ParamInfo
87
- */
88
-
107
+ * @typedef {ParamCommon|
108
+ * [string|undefined, (FlattendRootInfo & {
109
+ * annotationParamName?: string
110
+ * })]|
111
+ * NestedParamInfo} ParamInfo
112
+ */
89
113
  /**
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
-
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
+ */
98
121
  /** @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
- };
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
+ };
162
172
  };
163
-
164
173
  /**
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;
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;
183
186
  };
184
-
185
187
  /**
186
- * @param {ESTreeOrTypeScriptNode|null} functionNode
187
- * @param {boolean} [checkDefaultObjects]
188
- * @throws {Error}
189
- * @returns {ParamNameInfo[]}
190
- */
188
+ * @param {ESTreeOrTypeScriptNode|null} functionNode
189
+ * @param {boolean} [checkDefaultObjects]
190
+ * @throws {Error}
191
+ * @returns {ParamNameInfo[]}
192
+ */
191
193
  const getFunctionParameterNames = (functionNode, checkDefaultObjects) => {
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
- });
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
+ });
344
299
  };
345
-
346
300
  /**
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;
301
+ * @param {ESTreeOrTypeScriptNode} functionNode
302
+ * @returns {Integer}
303
+ */
304
+ const hasParams = (functionNode) => {
305
+ return functionNode.params.length;
354
306
  };
355
-
356
307
  /**
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;
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
+ */
368
318
  const getJsdocTagsDeep = (jsdoc, targetTagName) => {
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;
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;
385
329
  };
386
- exports.getJsdocTagsDeep = getJsdocTagsDeep;
387
- const modeWarnSettings = (0, _WarnSettings.default)();
388
-
330
+ const modeWarnSettings = require_WarnSettings.default();
389
331
  /**
390
- * @param {ParserMode|undefined} mode
391
- * @param {Reporter} context
392
- * @returns {import('./tagNames.js').AliasedTags}
393
- */
332
+ * @param {ParserMode|undefined} mode
333
+ * @param {Reporter} context
334
+ * @returns {import('./tagNames.js').AliasedTags}
335
+ */
394
336
  const getTagNamesForMode = (mode, context) => {
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
- }
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
+ }
424
361
  };
425
-
426
362
  /**
427
- * @param {import('comment-parser').Spec} tg
428
- * @param {boolean} [returnArray]
429
- * @returns {string[]|string}
430
- */
363
+ * @param {import('comment-parser').Spec} tg
364
+ * @param {boolean} [returnArray]
365
+ * @returns {string[]|string}
366
+ */
431
367
  const getTagDescription = (tg, returnArray) => {
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');
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");
462
382
  };
463
-
464
383
  /**
465
- * @typedef {{
466
- * report: (descriptor: import('eslint').Rule.ReportDescriptor) => void
467
- * }} Reporter
468
- */
469
-
384
+ * @typedef {{
385
+ * report: (descriptor: import('eslint').Rule.ReportDescriptor) => void
386
+ * }} Reporter
387
+ */
470
388
  /**
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;
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;
514
413
  };
515
-
516
414
  /**
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;
415
+ * @param {import('eslint').Rule.RuleContext} context
416
+ * @param {ParserMode|undefined} mode
417
+ * @param {string} name
418
+ * @param {string[]} definedTags
419
+ * @returns {boolean}
420
+ */
524
421
  const isValidTag = (context, mode, name, definedTags) => {
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);
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);
530
427
  };
531
-
532
428
  /**
533
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
534
- * @param {string} targetTagName
535
- * @returns {boolean}
536
- */
537
- exports.isValidTag = isValidTag;
429
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
430
+ * @param {string} targetTagName
431
+ * @returns {boolean}
432
+ */
538
433
  const hasTag = (jsdoc, targetTagName) => {
539
- const targetTagLower = targetTagName.toLowerCase();
540
- return jsdoc.tags.some(doc => {
541
- return doc.tag.toLowerCase() === targetTagLower;
542
- });
434
+ const targetTagLower = targetTagName.toLowerCase();
435
+ return jsdoc.tags.some((doc) => {
436
+ return doc.tag.toLowerCase() === targetTagLower;
437
+ });
543
438
  };
544
-
545
439
  /**
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;
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
+ */
551
444
  const filterTags = (jsdoc, filter) => {
552
- return jsdoc.tags.filter(tag => {
553
- return filter(tag);
554
- });
445
+ return jsdoc.tags.filter((tag) => {
446
+ return filter(tag);
447
+ });
555
448
  };
556
-
557
449
  /**
558
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
559
- * @param {string} tagName
560
- * @returns {import('comment-parser').Spec[]}
561
- */
562
- exports.filterTags = filterTags;
450
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
451
+ * @param {string} tagName
452
+ * @returns {import('comment-parser').Spec[]}
453
+ */
563
454
  const getTags = (jsdoc, tagName) => {
564
- return filterTags(jsdoc, item => {
565
- return item.tag === tagName;
566
- });
455
+ return filterTags(jsdoc, (item) => {
456
+ return item.tag === tagName;
457
+ });
567
458
  };
568
-
569
459
  /**
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;
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;
614
492
  };
615
-
616
493
  /**
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
- }
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);
663
522
  };
664
-
665
523
  /**
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
- })];
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
+ ];
725
559
  };
726
-
727
560
  /**
728
- * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
729
- * @param {string[]} targetTagNames
730
- * @returns {boolean}
731
- */
732
- exports.getAllTags = getAllTags;
561
+ * @param {import('./iterateJsdoc.js').JsdocBlockWithInline} jsdoc
562
+ * @param {string[]} targetTagNames
563
+ * @returns {boolean}
564
+ */
733
565
  const hasATag = (jsdoc, targetTagNames) => {
734
- return targetTagNames.some(targetTagName => {
735
- return hasTag(jsdoc, targetTagName);
736
- });
566
+ return targetTagNames.some((targetTagName) => {
567
+ return hasTag(jsdoc, targetTagName);
568
+ });
737
569
  };
738
-
739
570
  /**
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;
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
+ */
748
578
  const mayBeUndefinedTypeTag = (tag, mode) => {
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;
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;
777
590
  };
778
-
779
591
  /**
780
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} map
781
- * @param {string} tag
782
- * @returns {Map<string, string|string[]|boolean|undefined>}
783
- */
784
- exports.mayBeUndefinedTypeTag = mayBeUndefinedTypeTag;
592
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} map
593
+ * @param {string} tag
594
+ * @returns {Map<string, string|string[]|boolean|undefined>}
595
+ */
785
596
  const ensureMap = (map, tag) => {
786
- if (!map.has(tag)) {
787
- map.set(tag, new Map());
788
- }
789
- return /** @type {Map<string, string | boolean>} */map.get(tag);
597
+ if (!map.has(tag)) map.set(tag, /* @__PURE__ */ new Map());
598
+ return map.get(tag);
790
599
  };
791
-
792
600
  /**
793
- * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
794
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
795
- * @returns {void}
796
- */
601
+ * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
602
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
603
+ * @returns {void}
604
+ */
797
605
  const overrideTagStructure = (structuredTags, tagMap = tagStructure) => {
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
- }
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
+ }
825
621
  };
826
-
827
622
  /**
828
- * @param {ParserMode} mode
829
- * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
830
- * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
831
- */
832
- exports.overrideTagStructure = overrideTagStructure;
623
+ * @param {ParserMode} mode
624
+ * @param {import('./iterateJsdoc.js').StructuredTags} structuredTags
625
+ * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
626
+ */
833
627
  const getTagStructureForMode = (mode, structuredTags) => {
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;
628
+ const tagStruct = require_getDefaultTagStructureForMode.default(mode);
629
+ try {
630
+ overrideTagStructure(structuredTags, tagStruct);
631
+ } catch {}
632
+ return tagStruct;
842
633
  };
843
-
844
634
  /**
845
- * @param {string} tag
846
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
847
- * @returns {boolean}
848
- */
849
- exports.getTagStructureForMode = getTagStructureForMode;
635
+ * @param {string} tag
636
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
637
+ * @returns {boolean}
638
+ */
850
639
  const isNamepathDefiningTag = (tag, tagMap = tagStructure) => {
851
- const tagStruct = ensureMap(tagMap, tag);
852
- return tagStruct.get('namepathRole') === 'namepath-defining';
640
+ const tagStruct = ensureMap(tagMap, tag);
641
+ return tagStruct.get("namepathRole") === "namepath-defining";
853
642
  };
854
-
855
643
  /**
856
- * @param {string} tag
857
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
858
- * @returns {boolean}
859
- */
860
- exports.isNamepathDefiningTag = isNamepathDefiningTag;
644
+ * @param {string} tag
645
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
646
+ * @returns {boolean}
647
+ */
861
648
  const isNamepathReferencingTag = (tag, tagMap = tagStructure) => {
862
- const tagStruct = ensureMap(tagMap, tag);
863
- return tagStruct.get('namepathRole') === 'namepath-referencing';
649
+ const tagStruct = ensureMap(tagMap, tag);
650
+ return tagStruct.get("namepathRole") === "namepath-referencing";
864
651
  };
865
-
866
652
  /**
867
- * @param {string} tag
868
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
869
- * @returns {boolean}
870
- */
871
- exports.isNamepathReferencingTag = isNamepathReferencingTag;
653
+ * @param {string} tag
654
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
655
+ * @returns {boolean}
656
+ */
872
657
  const isNamepathOrUrlReferencingTag = (tag, tagMap = tagStructure) => {
873
- const tagStruct = ensureMap(tagMap, tag);
874
- return tagStruct.get('namepathRole') === 'namepath-or-url-referencing';
658
+ const tagStruct = ensureMap(tagMap, tag);
659
+ return tagStruct.get("namepathRole") === "namepath-or-url-referencing";
875
660
  };
876
-
877
661
  /**
878
- * @param {string} tag
879
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
880
- * @returns {boolean|undefined}
881
- */
882
- exports.isNamepathOrUrlReferencingTag = isNamepathOrUrlReferencingTag;
662
+ * @param {string} tag
663
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
664
+ * @returns {boolean|undefined}
665
+ */
883
666
  const tagMustHaveTypePosition = (tag, tagMap = tagStructure) => {
884
- const tagStruct = ensureMap(tagMap, tag);
885
- return /** @type {boolean|undefined} */tagStruct.get('typeRequired');
667
+ const tagStruct = ensureMap(tagMap, tag);
668
+ return tagStruct.get("typeRequired");
886
669
  };
887
-
888
670
  /**
889
- * @param {string} tag
890
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
891
- * @returns {boolean|string}
892
- */
893
- exports.tagMustHaveTypePosition = tagMustHaveTypePosition;
671
+ * @param {string} tag
672
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
673
+ * @returns {boolean|string}
674
+ */
894
675
  const tagMightHaveTypePosition = (tag, tagMap = tagStructure) => {
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;
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;
901
680
  };
902
- exports.tagMightHaveTypePosition = tagMightHaveTypePosition;
903
- const namepathTypes = new Set(['namepath-defining', 'namepath-referencing']);
904
-
681
+ const namepathTypes = new Set(["namepath-defining", "namepath-referencing"]);
905
682
  /**
906
- * @param {string} tag
907
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
908
- * @returns {boolean}
909
- */
683
+ * @param {string} tag
684
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
685
+ * @returns {boolean}
686
+ */
910
687
  const tagMightHaveNamePosition = (tag, tagMap = tagStructure) => {
911
- const tagStruct = ensureMap(tagMap, tag);
912
- const ret = tagStruct.get('namepathRole');
913
- return ret === undefined ? true : Boolean(ret);
688
+ const tagStruct = ensureMap(tagMap, tag);
689
+ const ret = tagStruct.get("namepathRole");
690
+ return ret === void 0 ? true : Boolean(ret);
914
691
  };
915
-
916
692
  /**
917
- * @param {string} tag
918
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
919
- * @returns {boolean}
920
- */
921
- exports.tagMightHaveNamePosition = tagMightHaveNamePosition;
693
+ * @param {string} tag
694
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
695
+ * @returns {boolean}
696
+ */
922
697
  const tagMightHaveNamepath = (tag, tagMap = tagStructure) => {
923
- const tagStruct = ensureMap(tagMap, tag);
924
- const nampathRole = tagStruct.get('namepathRole');
925
- return nampathRole !== false && namepathTypes.has(/** @type {string} */nampathRole);
698
+ const tagStruct = ensureMap(tagMap, tag);
699
+ const nampathRole = tagStruct.get("namepathRole");
700
+ return nampathRole !== false && namepathTypes.has(nampathRole);
926
701
  };
927
-
928
702
  /**
929
- * @param {string} tag
930
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
931
- * @returns {boolean|undefined}
932
- */
933
- exports.tagMightHaveNamepath = tagMightHaveNamepath;
703
+ * @param {string} tag
704
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
705
+ * @returns {boolean|undefined}
706
+ */
934
707
  const tagMustHaveNamePosition = (tag, tagMap = tagStructure) => {
935
- const tagStruct = ensureMap(tagMap, tag);
936
- return /** @type {boolean|undefined} */tagStruct.get('nameRequired');
708
+ const tagStruct = ensureMap(tagMap, tag);
709
+ return tagStruct.get("nameRequired");
937
710
  };
938
-
939
711
  /**
940
- * @param {string} tag
941
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
942
- * @returns {boolean}
943
- */
944
- exports.tagMustHaveNamePosition = tagMustHaveNamePosition;
712
+ * @param {string} tag
713
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
714
+ * @returns {boolean}
715
+ */
945
716
  const tagMightHaveEitherTypeOrNamePosition = (tag, tagMap) => {
946
- return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNamepath(tag, tagMap);
717
+ return Boolean(tagMightHaveTypePosition(tag, tagMap)) || tagMightHaveNamepath(tag, tagMap);
947
718
  };
948
-
949
719
  /**
950
- * @param {string} tag
951
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
952
- * @returns {boolean|undefined}
953
- */
954
- exports.tagMightHaveEitherTypeOrNamePosition = tagMightHaveEitherTypeOrNamePosition;
720
+ * @param {string} tag
721
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
722
+ * @returns {boolean|undefined}
723
+ */
955
724
  const tagMustHaveEitherTypeOrNamePosition = (tag, tagMap) => {
956
- const tagStruct = ensureMap(tagMap, tag);
957
- return /** @type {boolean} */tagStruct.get('typeOrNameRequired');
725
+ const tagStruct = ensureMap(tagMap, tag);
726
+ return tagStruct.get("typeOrNameRequired");
958
727
  };
959
-
960
728
  /**
961
- * @param {import('comment-parser').Spec} tag
962
- * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
963
- * @returns {boolean|undefined}
964
- */
729
+ * @param {import('comment-parser').Spec} tag
730
+ * @param {import('./getDefaultTagStructureForMode.js').TagStructure} tagMap
731
+ * @returns {boolean|undefined}
732
+ */
965
733
  const tagMissingRequiredTypeOrNamepath = (tag, tagMap = tagStructure) => {
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;
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;
973
741
  };
974
-
975
- /* eslint-disable complexity -- Temporary */
976
742
  /**
977
- * @param {ESTreeOrTypeScriptNode|null|undefined} node
978
- * @param {boolean} [checkYieldReturnValue]
979
- * @returns {boolean}
980
- */
981
- exports.tagMissingRequiredTypeOrNamepath = tagMissingRequiredTypeOrNamepath;
743
+ * @param {ESTreeOrTypeScriptNode|null|undefined} node
744
+ * @param {boolean} [checkYieldReturnValue]
745
+ * @returns {boolean}
746
+ */
982
747
  const hasNonFunctionYield = (node, checkYieldReturnValue) => {
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
- }
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
+ }
1139
826
  };
1140
-
1141
827
  /**
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
- */
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
+ */
1147
833
  const hasYieldValue = (node, checkYieldReturnValue) => {
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));
834
+ return node.generator && (node.expression || hasNonFunctionYield(
835
+ /** @type {import('@typescript-eslint/types').TSESTree.FunctionDeclaration} */
836
+ node.body,
837
+ checkYieldReturnValue
838
+ ));
1150
839
  };
1151
-
1152
840
  /**
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;
841
+ * Checks if a node has a throws statement.
842
+ * @param {ESTreeOrTypeScriptNode|null|undefined} node
843
+ * @param {boolean} [innerFunction]
844
+ * @returns {boolean}
845
+ */
1160
846
  const hasThrowValue = (node, innerFunction) => {
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
- }
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
+ }
1218
872
  };
1219
-
1220
873
  /**
1221
- * @param {string} tag
1222
- */
1223
- /*
1224
- const isInlineTag = (tag) => {
1225
- return /^(@link|@linkcode|@linkplain|@tutorial) /v.test(tag);
1226
- };
874
+ * @param {string} tag
1227
875
  */
1228
-
1229
876
  /**
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
- });
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
+ });
1241
887
  };
1242
-
1243
888
  /**
1244
- * @typedef {true|string[]} DefaultContexts
1245
- */
1246
-
889
+ * @typedef {true|string[]} DefaultContexts
890
+ */
1247
891
  /**
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;
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
+ */
1259
902
  const enforcedContexts = (context, defaultContexts, settings) => {
1260
- const contexts = context.options[0]?.contexts || settings.contexts || (defaultContexts === true ? ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction'] : defaultContexts);
1261
- return contexts;
903
+ const contexts = context.options[0]?.contexts || settings.contexts || (defaultContexts === true ? [
904
+ "ArrowFunctionExpression",
905
+ "FunctionDeclaration",
906
+ "FunctionExpression",
907
+ "TSDeclareFunction"
908
+ ] : defaultContexts);
909
+ return contexts;
1262
910
  };
1263
-
1264
911
  /**
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;
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
+ */
1271
917
  const getContextObject = (contexts, checkJsdoc, handler) => {
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;
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;
1323
960
  };
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
-
961
+ const tagsWithNamesAndDescriptions = new Set([
962
+ "arg",
963
+ "argument",
964
+ "param",
965
+ "prop",
966
+ "property",
967
+ "return",
968
+ "returns",
969
+ "template"
970
+ ]);
1329
971
  /**
1330
- * @typedef {{
1331
- * [key: string]: false|string|
1332
- * {message: string, replacement?: string}
1333
- * }} TagNamePreference
1334
- */
1335
-
972
+ * @typedef {{
973
+ * [key: string]: false|string|
974
+ * {message: string, replacement?: string}
975
+ * }} TagNamePreference
976
+ */
1336
977
  /**
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
- */
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
+ */
1345
986
  const getTagsByType = (context, mode, tags) => {
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
- };
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
+ };
1364
1001
  };
1365
-
1366
1002
  /**
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] ?? '') + ' ';
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] ?? "") + " ";
1375
1010
  };
1376
-
1377
1011
  /**
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';
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";
1384
1017
  };
1385
-
1386
1018
  /**
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';
1019
+ * @param {import('eslint').Rule.Node|null} node
1020
+ * @returns {boolean}
1021
+ */
1022
+ const isGetter = (node) => {
1023
+ return node !== null && node.parent?.kind === "get";
1398
1024
  };
1399
-
1400
1025
  /**
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';
1026
+ * @param {import('eslint').Rule.Node|null} node
1027
+ * @returns {boolean}
1028
+ */
1029
+ const isSetter = (node) => {
1030
+ return node !== null && node.parent?.kind === "set";
1412
1031
  };
1413
-
1414
1032
  /**
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
- });
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
+ });
1446
1046
  };
1447
-
1448
1047
  /**
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
- */
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
+ */
1455
1054
  const exemptSpeciaMethods = (jsdoc, node, context, schema) => {
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));
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
+ ));
1467
1072
  };
1468
-
1469
1073
  /**
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');
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");
1480
1083
  };
1481
-
1482
1084
  /**
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
- };
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
+ };
1491
1092
  };
1492
-
1493
1093
  /**
1494
- * @callback PathDoesNotBeginWith
1495
- * @param {string} name
1496
- * @param {string} otherPathName
1497
- * @returns {boolean}
1498
- */
1499
-
1094
+ * @callback PathDoesNotBeginWith
1095
+ * @param {string} name
1096
+ * @param {string} otherPathName
1097
+ * @returns {boolean}
1098
+ */
1500
1099
  /** @type {PathDoesNotBeginWith} */
1501
- exports.comparePaths = comparePaths;
1502
1100
  const pathDoesNotBeginWith = (name, otherPathName) => {
1503
- return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
1101
+ return !name.startsWith(otherPathName) && !dropPathSegmentQuotes(name).startsWith(dropPathSegmentQuotes(otherPathName));
1504
1102
  };
1505
-
1506
1103
  /**
1507
- * @param {string} regexString
1508
- * @param {string} [requiredFlags]
1509
- * @returns {RegExp}
1510
- */
1511
- exports.pathDoesNotBeginWith = pathDoesNotBeginWith;
1104
+ * @param {string} regexString
1105
+ * @param {string} [requiredFlags]
1106
+ * @returns {RegExp}
1107
+ */
1512
1108
  const getRegexFromString = (regexString, requiredFlags) => {
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);
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);
1525
1119
  };
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;
1526
1136
  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;
1527
1160
  //# sourceMappingURL=jsdocUtils.cjs.map