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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +33 -0
  3. package/changes.json +18 -0
  4. package/dist/WarnSettings.cjs +38 -0
  5. package/dist/WarnSettings.cjs.map +1 -0
  6. package/dist/WarnSettings.d.ts +17 -0
  7. package/dist/alignTransform.cjs +402 -0
  8. package/dist/alignTransform.cjs.map +1 -0
  9. package/dist/alignTransform.d.ts +34 -0
  10. package/dist/buildForbidRuleDefinition.cjs +101 -0
  11. package/dist/buildForbidRuleDefinition.cjs.map +1 -0
  12. package/dist/buildForbidRuleDefinition.d.ts +15 -0
  13. package/dist/buildRejectOrPreferRuleDefinition.cjs +352 -0
  14. package/dist/buildRejectOrPreferRuleDefinition.cjs.map +1 -0
  15. package/dist/buildRejectOrPreferRuleDefinition.d.ts +9 -0
  16. package/dist/cjs/WarnSettings.d.ts +16 -0
  17. package/dist/cjs/alignTransform.d.ts +33 -0
  18. package/dist/cjs/buildForbidRuleDefinition.d.ts +14 -0
  19. package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +8 -0
  20. package/dist/cjs/defaultTagOrder.d.ts +4 -0
  21. package/dist/cjs/exportParser.d.ts +40 -0
  22. package/dist/cjs/getDefaultTagStructureForMode.d.ts +10 -0
  23. package/dist/cjs/getJsdocProcessorPlugin.d.cts +5 -0
  24. package/dist/cjs/getJsdocProcessorPlugin.d.ts +66 -0
  25. package/dist/cjs/index-cjs.d.ts +23 -0
  26. package/dist/cjs/index.cjs.d.cts +2 -0
  27. package/dist/cjs/iterateJsdoc.d.cts +7 -0
  28. package/dist/cjs/iterateJsdoc.d.ts +495 -0
  29. package/dist/cjs/jsdocUtils.d.ts +493 -0
  30. package/dist/cjs/rules/checkAccess.d.ts +2 -0
  31. package/dist/cjs/rules/checkAlignment.d.ts +2 -0
  32. package/dist/cjs/rules/checkExamples.d.ts +3 -0
  33. package/dist/cjs/rules/checkIndentation.d.ts +2 -0
  34. package/dist/cjs/rules/checkLineAlignment.d.ts +9 -0
  35. package/dist/cjs/rules/checkParamNames.d.ts +2 -0
  36. package/dist/cjs/rules/checkPropertyNames.d.ts +2 -0
  37. package/dist/cjs/rules/checkSyntax.d.ts +2 -0
  38. package/dist/cjs/rules/checkTagNames.d.ts +2 -0
  39. package/dist/cjs/rules/checkTemplateNames.d.ts +2 -0
  40. package/dist/cjs/rules/checkTypes.d.ts +7 -0
  41. package/dist/cjs/rules/checkValues.d.ts +2 -0
  42. package/dist/cjs/rules/convertToJsdocComments.d.ts +266 -0
  43. package/dist/cjs/rules/emptyTags.d.ts +2 -0
  44. package/dist/cjs/rules/escapeInlineTags.d.ts +2 -0
  45. package/dist/cjs/rules/implementsOnClasses.d.ts +2 -0
  46. package/dist/cjs/rules/importsAsDependencies.d.ts +2 -0
  47. package/dist/cjs/rules/informativeDocs.d.ts +2 -0
  48. package/dist/cjs/rules/linesBeforeBlock.d.ts +2 -0
  49. package/dist/cjs/rules/matchDescription.d.ts +2 -0
  50. package/dist/cjs/rules/matchName.d.ts +2 -0
  51. package/dist/cjs/rules/multilineBlocks.d.ts +2 -0
  52. package/dist/cjs/rules/noBadBlocks.d.ts +2 -0
  53. package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +2 -0
  54. package/dist/cjs/rules/noBlankBlocks.d.ts +2 -0
  55. package/dist/cjs/rules/noDefaults.d.ts +2 -0
  56. package/dist/cjs/rules/noMissingSyntax.d.ts +9 -0
  57. package/dist/cjs/rules/noMultiAsterisks.d.ts +2 -0
  58. package/dist/cjs/rules/noRestrictedSyntax.d.ts +2 -0
  59. package/dist/cjs/rules/noTypes.d.ts +2 -0
  60. package/dist/cjs/rules/noUndefinedTypes.d.ts +2 -0
  61. package/dist/cjs/rules/preferImportTag.d.ts +2 -0
  62. package/dist/cjs/rules/requireAsteriskPrefix.d.ts +2 -0
  63. package/dist/cjs/rules/requireDescription.d.ts +2 -0
  64. package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +2 -0
  65. package/dist/cjs/rules/requireExample.d.ts +2 -0
  66. package/dist/cjs/rules/requireFileOverview.d.ts +2 -0
  67. package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +2 -0
  68. package/dist/cjs/rules/requireJsdoc.d.ts +24 -0
  69. package/dist/cjs/rules/requireParam.d.ts +3 -0
  70. package/dist/cjs/rules/requireParamDescription.d.ts +2 -0
  71. package/dist/cjs/rules/requireParamName.d.ts +2 -0
  72. package/dist/cjs/rules/requireParamType.d.ts +2 -0
  73. package/dist/cjs/rules/requireProperty.d.ts +2 -0
  74. package/dist/cjs/rules/requirePropertyDescription.d.ts +2 -0
  75. package/dist/cjs/rules/requirePropertyName.d.ts +2 -0
  76. package/dist/cjs/rules/requirePropertyType.d.ts +2 -0
  77. package/dist/cjs/rules/requireRejects.d.ts +2 -0
  78. package/dist/cjs/rules/requireReturns.d.ts +2 -0
  79. package/dist/cjs/rules/requireReturnsCheck.d.ts +2 -0
  80. package/dist/cjs/rules/requireReturnsDescription.d.ts +2 -0
  81. package/dist/cjs/rules/requireReturnsType.d.ts +2 -0
  82. package/dist/cjs/rules/requireTags.d.ts +2 -0
  83. package/dist/cjs/rules/requireTemplate.d.ts +2 -0
  84. package/dist/cjs/rules/requireThrows.d.ts +2 -0
  85. package/dist/cjs/rules/requireYields.d.ts +2 -0
  86. package/dist/cjs/rules/requireYieldsCheck.d.ts +2 -0
  87. package/dist/cjs/rules/sortTags.d.ts +2 -0
  88. package/dist/cjs/rules/tagLines.d.ts +2 -0
  89. package/dist/cjs/rules/textEscaping.d.ts +2 -0
  90. package/dist/cjs/rules/tsMethodSignatureStyle.d.ts +2 -0
  91. package/dist/cjs/rules/tsNoEmptyObjectType.d.ts +2 -0
  92. package/dist/cjs/rules/tsNoUnnecessaryTemplateExpression.d.ts +2 -0
  93. package/dist/cjs/rules/tsPreferFunctionType.d.ts +2 -0
  94. package/dist/cjs/rules/typeFormatting.d.ts +2 -0
  95. package/dist/cjs/rules/validTypes.d.ts +2 -0
  96. package/dist/cjs/tagNames.d.ts +15 -0
  97. package/dist/cjs/utils/hasReturnValue.d.ts +19 -0
  98. package/dist/defaultTagOrder.cjs +46 -0
  99. package/dist/defaultTagOrder.cjs.map +1 -0
  100. package/dist/defaultTagOrder.d.ts +5 -0
  101. package/dist/exportParser.cjs +732 -0
  102. package/dist/exportParser.cjs.map +1 -0
  103. package/dist/exportParser.d.ts +41 -0
  104. package/dist/generateDocs.cjs +342 -0
  105. package/dist/generateDocs.cjs.map +1 -0
  106. package/dist/generateOptions.cjs +62 -0
  107. package/dist/generateOptions.cjs.map +1 -0
  108. package/dist/generateRule.cjs +248 -0
  109. package/dist/generateRule.cjs.map +1 -0
  110. package/dist/generateRuleTypes.cjs +24 -0
  111. package/dist/generateRuleTypes.cjs.map +1 -0
  112. package/dist/getDefaultTagStructureForMode.cjs +289 -0
  113. package/dist/getDefaultTagStructureForMode.cjs.map +1 -0
  114. package/dist/getDefaultTagStructureForMode.d.ts +11 -0
  115. package/dist/getJsdocProcessorPlugin.cjs +587 -0
  116. package/dist/getJsdocProcessorPlugin.cjs.map +1 -0
  117. package/dist/getJsdocProcessorPlugin.cts +5 -0
  118. package/dist/getJsdocProcessorPlugin.d.ts +67 -0
  119. package/dist/index-cjs.cjs +595 -0
  120. package/dist/index-cjs.cjs.map +1 -0
  121. package/dist/index-cjs.d.ts +24 -0
  122. package/dist/index-esm.cjs +162 -0
  123. package/dist/index-esm.cjs.map +1 -0
  124. package/dist/index-esm.d.ts +72 -0
  125. package/dist/index.cjs +743 -0
  126. package/dist/index.cjs.cts +3 -0
  127. package/dist/index.cjs.map +1 -0
  128. package/dist/index.d.ts +93 -0
  129. package/dist/iterateJsdoc.cjs +2150 -0
  130. package/dist/iterateJsdoc.cjs.map +1 -0
  131. package/dist/iterateJsdoc.cts +7 -0
  132. package/dist/iterateJsdoc.d.ts +496 -0
  133. package/dist/jsdocUtils.cjs +1725 -0
  134. package/dist/jsdocUtils.cjs.map +1 -0
  135. package/dist/jsdocUtils.d.ts +494 -0
  136. package/dist/rules/checkAccess.cjs +40 -0
  137. package/dist/rules/checkAccess.cjs.map +1 -0
  138. package/dist/rules/checkAccess.d.ts +3 -0
  139. package/dist/rules/checkAlignment.cjs +78 -0
  140. package/dist/rules/checkAlignment.cjs.map +1 -0
  141. package/dist/rules/checkAlignment.d.ts +3 -0
  142. package/dist/rules/checkExamples.cjs +521 -0
  143. package/dist/rules/checkExamples.cjs.map +1 -0
  144. package/dist/rules/checkExamples.d.ts +4 -0
  145. package/dist/rules/checkIndentation.cjs +170 -0
  146. package/dist/rules/checkIndentation.cjs.map +1 -0
  147. package/dist/rules/checkIndentation.d.ts +3 -0
  148. package/dist/rules/checkLineAlignment.cjs +398 -0
  149. package/dist/rules/checkLineAlignment.cjs.map +1 -0
  150. package/dist/rules/checkLineAlignment.d.ts +10 -0
  151. package/dist/rules/checkParamNames.cjs +407 -0
  152. package/dist/rules/checkParamNames.cjs.map +1 -0
  153. package/dist/rules/checkParamNames.d.ts +3 -0
  154. package/dist/rules/checkPropertyNames.cjs +135 -0
  155. package/dist/rules/checkPropertyNames.cjs.map +1 -0
  156. package/dist/rules/checkPropertyNames.d.ts +3 -0
  157. package/dist/rules/checkSyntax.cjs +38 -0
  158. package/dist/rules/checkSyntax.cjs.map +1 -0
  159. package/dist/rules/checkSyntax.d.ts +3 -0
  160. package/dist/rules/checkTagNames.cjs +312 -0
  161. package/dist/rules/checkTagNames.cjs.map +1 -0
  162. package/dist/rules/checkTagNames.d.ts +3 -0
  163. package/dist/rules/checkTemplateNames.cjs +185 -0
  164. package/dist/rules/checkTemplateNames.cjs.map +1 -0
  165. package/dist/rules/checkTemplateNames.d.ts +3 -0
  166. package/dist/rules/checkTypes.cjs +111 -0
  167. package/dist/rules/checkTypes.cjs.map +1 -0
  168. package/dist/rules/checkTypes.d.ts +8 -0
  169. package/dist/rules/checkValues.cjs +166 -0
  170. package/dist/rules/checkValues.cjs.map +1 -0
  171. package/dist/rules/checkValues.d.ts +3 -0
  172. package/dist/rules/convertToJsdocComments.cjs +356 -0
  173. package/dist/rules/convertToJsdocComments.cjs.map +1 -0
  174. package/dist/rules/convertToJsdocComments.d.ts +267 -0
  175. package/dist/rules/emptyTags.cjs +85 -0
  176. package/dist/rules/emptyTags.cjs.map +1 -0
  177. package/dist/rules/emptyTags.d.ts +3 -0
  178. package/dist/rules/escapeInlineTags.cjs +149 -0
  179. package/dist/rules/escapeInlineTags.cjs.map +1 -0
  180. package/dist/rules/escapeInlineTags.d.ts +3 -0
  181. package/dist/rules/implementsOnClasses.cjs +74 -0
  182. package/dist/rules/implementsOnClasses.cjs.map +1 -0
  183. package/dist/rules/implementsOnClasses.d.ts +3 -0
  184. package/dist/rules/importsAsDependencies.cjs +104 -0
  185. package/dist/rules/importsAsDependencies.cjs.map +1 -0
  186. package/dist/rules/importsAsDependencies.d.ts +3 -0
  187. package/dist/rules/informativeDocs.cjs +187 -0
  188. package/dist/rules/informativeDocs.cjs.map +1 -0
  189. package/dist/rules/informativeDocs.d.ts +3 -0
  190. package/dist/rules/linesBeforeBlock.cjs +120 -0
  191. package/dist/rules/linesBeforeBlock.cjs.map +1 -0
  192. package/dist/rules/linesBeforeBlock.d.ts +3 -0
  193. package/dist/rules/matchDescription.cjs +356 -0
  194. package/dist/rules/matchDescription.cjs.map +1 -0
  195. package/dist/rules/matchDescription.d.ts +3 -0
  196. package/dist/rules/matchName.cjs +160 -0
  197. package/dist/rules/matchName.cjs.map +1 -0
  198. package/dist/rules/matchName.d.ts +3 -0
  199. package/dist/rules/multilineBlocks.cjs +431 -0
  200. package/dist/rules/multilineBlocks.cjs.map +1 -0
  201. package/dist/rules/multilineBlocks.d.ts +3 -0
  202. package/dist/rules/noBadBlocks.cjs +100 -0
  203. package/dist/rules/noBadBlocks.cjs.map +1 -0
  204. package/dist/rules/noBadBlocks.d.ts +3 -0
  205. package/dist/rules/noBlankBlockDescriptions.cjs +63 -0
  206. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -0
  207. package/dist/rules/noBlankBlockDescriptions.d.ts +3 -0
  208. package/dist/rules/noBlankBlocks.cjs +54 -0
  209. package/dist/rules/noBlankBlocks.cjs.map +1 -0
  210. package/dist/rules/noBlankBlocks.d.ts +3 -0
  211. package/dist/rules/noDefaults.cjs +102 -0
  212. package/dist/rules/noDefaults.cjs.map +1 -0
  213. package/dist/rules/noDefaults.d.ts +3 -0
  214. package/dist/rules/noMissingSyntax.cjs +196 -0
  215. package/dist/rules/noMissingSyntax.cjs.map +1 -0
  216. package/dist/rules/noMissingSyntax.d.ts +10 -0
  217. package/dist/rules/noMultiAsterisks.cjs +126 -0
  218. package/dist/rules/noMultiAsterisks.cjs.map +1 -0
  219. package/dist/rules/noMultiAsterisks.d.ts +3 -0
  220. package/dist/rules/noRestrictedSyntax.cjs +68 -0
  221. package/dist/rules/noRestrictedSyntax.cjs.map +1 -0
  222. package/dist/rules/noRestrictedSyntax.d.ts +3 -0
  223. package/dist/rules/noTypes.cjs +101 -0
  224. package/dist/rules/noTypes.cjs.map +1 -0
  225. package/dist/rules/noTypes.d.ts +3 -0
  226. package/dist/rules/noUndefinedTypes.cjs +588 -0
  227. package/dist/rules/noUndefinedTypes.cjs.map +1 -0
  228. package/dist/rules/noUndefinedTypes.d.ts +3 -0
  229. package/dist/rules/preferImportTag.cjs +362 -0
  230. package/dist/rules/preferImportTag.cjs.map +1 -0
  231. package/dist/rules/preferImportTag.d.ts +3 -0
  232. package/dist/rules/requireAsteriskPrefix.cjs +190 -0
  233. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -0
  234. package/dist/rules/requireAsteriskPrefix.d.ts +3 -0
  235. package/dist/rules/requireDescription.cjs +164 -0
  236. package/dist/rules/requireDescription.cjs.map +1 -0
  237. package/dist/rules/requireDescription.d.ts +3 -0
  238. package/dist/rules/requireDescriptionCompleteSentence.cjs +321 -0
  239. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -0
  240. package/dist/rules/requireDescriptionCompleteSentence.d.ts +3 -0
  241. package/dist/rules/requireExample.cjs +133 -0
  242. package/dist/rules/requireExample.cjs.map +1 -0
  243. package/dist/rules/requireExample.d.ts +3 -0
  244. package/dist/rules/requireFileOverview.cjs +194 -0
  245. package/dist/rules/requireFileOverview.cjs.map +1 -0
  246. package/dist/rules/requireFileOverview.d.ts +3 -0
  247. package/dist/rules/requireHyphenBeforeParamDescription.cjs +166 -0
  248. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -0
  249. package/dist/rules/requireHyphenBeforeParamDescription.d.ts +3 -0
  250. package/dist/rules/requireJsdoc.cjs +722 -0
  251. package/dist/rules/requireJsdoc.cjs.map +1 -0
  252. package/dist/rules/requireJsdoc.d.ts +25 -0
  253. package/dist/rules/requireParam.cjs +772 -0
  254. package/dist/rules/requireParam.cjs.map +1 -0
  255. package/dist/rules/requireParam.d.ts +4 -0
  256. package/dist/rules/requireParamDescription.cjs +105 -0
  257. package/dist/rules/requireParamDescription.cjs.map +1 -0
  258. package/dist/rules/requireParamDescription.d.ts +3 -0
  259. package/dist/rules/requireParamName.cjs +68 -0
  260. package/dist/rules/requireParamName.cjs.map +1 -0
  261. package/dist/rules/requireParamName.d.ts +3 -0
  262. package/dist/rules/requireParamType.cjs +104 -0
  263. package/dist/rules/requireParamType.cjs.map +1 -0
  264. package/dist/rules/requireParamType.d.ts +3 -0
  265. package/dist/rules/requireProperty.cjs +63 -0
  266. package/dist/rules/requireProperty.cjs.map +1 -0
  267. package/dist/rules/requireProperty.d.ts +3 -0
  268. package/dist/rules/requirePropertyDescription.cjs +29 -0
  269. package/dist/rules/requirePropertyDescription.cjs.map +1 -0
  270. package/dist/rules/requirePropertyDescription.d.ts +3 -0
  271. package/dist/rules/requirePropertyName.cjs +29 -0
  272. package/dist/rules/requirePropertyName.cjs.map +1 -0
  273. package/dist/rules/requirePropertyName.d.ts +3 -0
  274. package/dist/rules/requirePropertyType.cjs +29 -0
  275. package/dist/rules/requirePropertyType.cjs.map +1 -0
  276. package/dist/rules/requirePropertyType.d.ts +3 -0
  277. package/dist/rules/requireRejects.cjs +226 -0
  278. package/dist/rules/requireRejects.cjs.map +1 -0
  279. package/dist/rules/requireRejects.d.ts +3 -0
  280. package/dist/rules/requireReturns.cjs +262 -0
  281. package/dist/rules/requireReturns.cjs.map +1 -0
  282. package/dist/rules/requireReturns.d.ts +3 -0
  283. package/dist/rules/requireReturnsCheck.cjs +140 -0
  284. package/dist/rules/requireReturnsCheck.cjs.map +1 -0
  285. package/dist/rules/requireReturnsCheck.d.ts +3 -0
  286. package/dist/rules/requireReturnsDescription.cjs +72 -0
  287. package/dist/rules/requireReturnsDescription.cjs.map +1 -0
  288. package/dist/rules/requireReturnsDescription.d.ts +3 -0
  289. package/dist/rules/requireReturnsType.cjs +68 -0
  290. package/dist/rules/requireReturnsType.cjs.map +1 -0
  291. package/dist/rules/requireReturnsType.d.ts +3 -0
  292. package/dist/rules/requireTags.cjs +74 -0
  293. package/dist/rules/requireTags.cjs.map +1 -0
  294. package/dist/rules/requireTags.d.ts +3 -0
  295. package/dist/rules/requireTemplate.cjs +220 -0
  296. package/dist/rules/requireTemplate.cjs.map +1 -0
  297. package/dist/rules/requireTemplate.d.ts +3 -0
  298. package/dist/rules/requireThrows.cjs +118 -0
  299. package/dist/rules/requireThrows.cjs.map +1 -0
  300. package/dist/rules/requireThrows.d.ts +3 -0
  301. package/dist/rules/requireYields.cjs +224 -0
  302. package/dist/rules/requireYields.cjs.map +1 -0
  303. package/dist/rules/requireYields.d.ts +3 -0
  304. package/dist/rules/requireYieldsCheck.cjs +179 -0
  305. package/dist/rules/requireYieldsCheck.cjs.map +1 -0
  306. package/dist/rules/requireYieldsCheck.d.ts +3 -0
  307. package/dist/rules/sortTags.cjs +656 -0
  308. package/dist/rules/sortTags.cjs.map +1 -0
  309. package/dist/rules/sortTags.d.ts +3 -0
  310. package/dist/rules/tagLines.cjs +374 -0
  311. package/dist/rules/tagLines.cjs.map +1 -0
  312. package/dist/rules/tagLines.d.ts +3 -0
  313. package/dist/rules/textEscaping.cjs +141 -0
  314. package/dist/rules/textEscaping.cjs.map +1 -0
  315. package/dist/rules/textEscaping.d.ts +3 -0
  316. package/dist/rules/tsMethodSignatureStyle.cjs +240 -0
  317. package/dist/rules/tsMethodSignatureStyle.cjs.map +1 -0
  318. package/dist/rules/tsMethodSignatureStyle.d.ts +3 -0
  319. package/dist/rules/tsNoEmptyObjectType.cjs +62 -0
  320. package/dist/rules/tsNoEmptyObjectType.cjs.map +1 -0
  321. package/dist/rules/tsNoEmptyObjectType.d.ts +3 -0
  322. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +104 -0
  323. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +1 -0
  324. package/dist/rules/tsNoUnnecessaryTemplateExpression.d.ts +3 -0
  325. package/dist/rules/tsPreferFunctionType.cjs +110 -0
  326. package/dist/rules/tsPreferFunctionType.cjs.map +1 -0
  327. package/dist/rules/tsPreferFunctionType.d.ts +3 -0
  328. package/dist/rules/typeFormatting.cjs +607 -0
  329. package/dist/rules/typeFormatting.cjs.map +1 -0
  330. package/dist/rules/typeFormatting.d.ts +3 -0
  331. package/dist/rules/validTypes.cjs +328 -0
  332. package/dist/rules/validTypes.cjs.map +1 -0
  333. package/dist/rules/validTypes.d.ts +3 -0
  334. package/dist/rules.d.ts +3203 -0
  335. package/dist/tagNames.cjs +244 -0
  336. package/dist/tagNames.cjs.map +1 -0
  337. package/dist/tagNames.d.ts +16 -0
  338. package/dist/to-valid-identifier.cjs +263 -0
  339. package/dist/utils/hasReturnValue.cjs +495 -0
  340. package/dist/utils/hasReturnValue.cjs.map +1 -0
  341. package/dist/utils/hasReturnValue.d.ts +20 -0
  342. package/package.json +220 -0
  343. package/rollup.config.js +16 -0
  344. package/src/WarnSettings.js +34 -0
  345. package/src/alignTransform.js +444 -0
  346. package/src/buildForbidRuleDefinition.js +106 -0
  347. package/src/buildRejectOrPreferRuleDefinition.js +481 -0
  348. package/src/defaultTagOrder.js +169 -0
  349. package/src/exportParser.js +973 -0
  350. package/src/getDefaultTagStructureForMode.js +968 -0
  351. package/src/getJsdocProcessorPlugin.cts +5 -0
  352. package/src/getJsdocProcessorPlugin.js +692 -0
  353. package/src/index-cjs.js +755 -0
  354. package/src/index-esm.js +196 -0
  355. package/src/index.cjs.cts +3 -0
  356. package/src/index.js +940 -0
  357. package/src/iterateJsdoc.cts +7 -0
  358. package/src/iterateJsdoc.js +2612 -0
  359. package/src/jsdocUtils.js +2158 -0
  360. package/src/rules/checkAccess.js +45 -0
  361. package/src/rules/checkAlignment.js +82 -0
  362. package/src/rules/checkExamples.js +613 -0
  363. package/src/rules/checkIndentation.js +176 -0
  364. package/src/rules/checkLineAlignment.js +453 -0
  365. package/src/rules/checkParamNames.js +541 -0
  366. package/src/rules/checkPropertyNames.js +174 -0
  367. package/src/rules/checkSyntax.js +30 -0
  368. package/src/rules/checkTagNames.js +414 -0
  369. package/src/rules/checkTemplateNames.js +208 -0
  370. package/src/rules/checkTypes.js +130 -0
  371. package/src/rules/checkValues.js +264 -0
  372. package/src/rules/convertToJsdocComments.js +444 -0
  373. package/src/rules/emptyTags.js +106 -0
  374. package/src/rules/escapeInlineTags.js +189 -0
  375. package/src/rules/implementsOnClasses.js +78 -0
  376. package/src/rules/importsAsDependencies.js +132 -0
  377. package/src/rules/informativeDocs.js +228 -0
  378. package/src/rules/linesBeforeBlock.js +144 -0
  379. package/src/rules/matchDescription.js +413 -0
  380. package/src/rules/matchName.js +179 -0
  381. package/src/rules/multilineBlocks.js +562 -0
  382. package/src/rules/noBadBlocks.js +127 -0
  383. package/src/rules/noBlankBlockDescriptions.js +69 -0
  384. package/src/rules/noBlankBlocks.js +55 -0
  385. package/src/rules/noDefaults.js +104 -0
  386. package/src/rules/noMissingSyntax.js +215 -0
  387. package/src/rules/noMultiAsterisks.js +162 -0
  388. package/src/rules/noRestrictedSyntax.js +72 -0
  389. package/src/rules/noTypes.js +108 -0
  390. package/src/rules/noUndefinedTypes.js +797 -0
  391. package/src/rules/preferImportTag.js +521 -0
  392. package/src/rules/requireAsteriskPrefix.js +217 -0
  393. package/src/rules/requireDescription.js +190 -0
  394. package/src/rules/requireDescriptionCompleteSentence.js +376 -0
  395. package/src/rules/requireExample.js +143 -0
  396. package/src/rules/requireFileOverview.js +213 -0
  397. package/src/rules/requireHyphenBeforeParamDescription.js +210 -0
  398. package/src/rules/requireJsdoc.js +897 -0
  399. package/src/rules/requireParam.js +848 -0
  400. package/src/rules/requireParamDescription.js +110 -0
  401. package/src/rules/requireParamName.js +69 -0
  402. package/src/rules/requireParamType.js +109 -0
  403. package/src/rules/requireProperty.js +66 -0
  404. package/src/rules/requirePropertyDescription.js +25 -0
  405. package/src/rules/requirePropertyName.js +25 -0
  406. package/src/rules/requirePropertyType.js +25 -0
  407. package/src/rules/requireRejects.js +246 -0
  408. package/src/rules/requireReturns.js +291 -0
  409. package/src/rules/requireReturnsCheck.js +180 -0
  410. package/src/rules/requireReturnsDescription.js +73 -0
  411. package/src/rules/requireReturnsType.js +65 -0
  412. package/src/rules/requireTags.js +85 -0
  413. package/src/rules/requireTemplate.js +246 -0
  414. package/src/rules/requireThrows.js +128 -0
  415. package/src/rules/requireYields.js +265 -0
  416. package/src/rules/requireYieldsCheck.js +226 -0
  417. package/src/rules/sortTags.js +766 -0
  418. package/src/rules/tagLines.js +486 -0
  419. package/src/rules/textEscaping.js +158 -0
  420. package/src/rules/tsMethodSignatureStyle.js +300 -0
  421. package/src/rules/tsNoEmptyObjectType.js +61 -0
  422. package/src/rules/tsNoUnnecessaryTemplateExpression.js +130 -0
  423. package/src/rules/tsPreferFunctionType.js +127 -0
  424. package/src/rules/typeFormatting.js +690 -0
  425. package/src/rules/validTypes.js +466 -0
  426. package/src/rules.d.ts +3203 -0
  427. package/src/tagNames.js +301 -0
  428. package/src/utils/hasReturnValue.js +572 -0
  429. package/typings/babel__eslint-parser.d.ts +1 -0
  430. package/typings/gitdown.d.ts +16 -0
@@ -0,0 +1,2150 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = iterateJsdoc;
7
+ exports.getSettings = void 0;
8
+ Object.defineProperty(exports, "parseComment", {
9
+ enumerable: true,
10
+ get: function () {
11
+ return _jsdoccomment.parseComment;
12
+ }
13
+ });
14
+ var jsdocUtils = _interopRequireWildcard(require("./jsdocUtils.cjs"));
15
+ var _jsdoccomment = require("@es-joy/jsdoccomment");
16
+ var _commentParser = require("comment-parser");
17
+ var _esquery = _interopRequireDefault(require("esquery"));
18
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
19
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
20
+ /**
21
+ * @typedef {number} Integer
22
+ */
23
+
24
+ /**
25
+ * @typedef {import('@es-joy/jsdoccomment').JsdocBlockWithInline} JsdocBlockWithInline
26
+ */
27
+
28
+ /**
29
+ * @typedef {{
30
+ * disallowName?: string,
31
+ * allowName?: string,
32
+ * context?: string,
33
+ * comment?: string,
34
+ * tags?: string[],
35
+ * replacement?: string,
36
+ * minimum?: Integer,
37
+ * message?: string,
38
+ * forceRequireReturn?: boolean
39
+ * }} ContextObject
40
+ */
41
+ /**
42
+ * @typedef {string|ContextObject} Context
43
+ */
44
+
45
+ /**
46
+ * @callback CheckJsdoc
47
+ * @param {{
48
+ * lastIndex?: Integer,
49
+ * isFunctionContext?: boolean,
50
+ * selector?: string,
51
+ * comment?: string
52
+ * }} info
53
+ * @param {null|((jsdoc: import('@es-joy/jsdoccomment').JsdocBlockWithInline) => boolean|undefined)} handler
54
+ * @param {import('eslint').Rule.Node} node
55
+ * @returns {void}
56
+ */
57
+
58
+ /**
59
+ * @callback ForEachPreferredTag
60
+ * @param {string} tagName
61
+ * @param {(
62
+ * matchingJsdocTag: import('@es-joy/jsdoccomment').JsdocTagWithInline,
63
+ * targetTagName: string
64
+ * ) => void} arrayHandler
65
+ * @param {boolean} [skipReportingBlockedTag]
66
+ * @returns {void}
67
+ */
68
+
69
+ /**
70
+ * @callback ReportSettings
71
+ * @param {string} message
72
+ * @returns {void}
73
+ */
74
+
75
+ /**
76
+ * @callback ParseClosureTemplateTag
77
+ * @param {import('comment-parser').Spec} tag
78
+ * @returns {string[]}
79
+ */
80
+
81
+ /**
82
+ * @callback GetPreferredTagNameObject
83
+ * @param {{
84
+ * tagName: string
85
+ * }} cfg
86
+ * @returns {string|false|{
87
+ * message: string;
88
+ * replacement?: string|undefined
89
+ * }|{
90
+ * blocked: true,
91
+ * tagName: string
92
+ * }}
93
+ */
94
+
95
+ /**
96
+ * @typedef {{
97
+ * forEachPreferredTag: ForEachPreferredTag,
98
+ * reportSettings: ReportSettings,
99
+ * parseClosureTemplateTag: ParseClosureTemplateTag,
100
+ * getPreferredTagNameObject: GetPreferredTagNameObject,
101
+ * pathDoesNotBeginWith: import('./jsdocUtils.js').PathDoesNotBeginWith
102
+ * isNameOrNamepathDefiningTag: IsNamepathX,
103
+ * isNamepathReferencingTag: IsNamepathX,
104
+ * isNamepathOrUrlReferencingTag: IsNamepathX,
105
+ * tagMightHaveNameOrNamepath: IsNamepathX,
106
+ * tagMightHaveName: IsNamepathX
107
+ * }} BasicUtils
108
+ */
109
+
110
+ /**
111
+ * @callback IsIteratingFunction
112
+ * @returns {boolean}
113
+ */
114
+
115
+ /**
116
+ * @callback IsVirtualFunction
117
+ * @returns {boolean}
118
+ */
119
+
120
+ /**
121
+ * @callback Stringify
122
+ * @param {import('comment-parser').Block} tagBlock
123
+ * @param {boolean} [specRewire]
124
+ * @returns {string}
125
+ */
126
+
127
+ /**
128
+ * @callback ReportJSDoc
129
+ * @param {string} msg
130
+ * @param {null|import('comment-parser').Spec|{line: Integer, column?: Integer}} [tag]
131
+ * @param {((fixer: import('eslint').Rule.RuleFixer) => import('eslint').Rule.Fix|void)|null} [handler]
132
+ * @param {boolean} [specRewire]
133
+ * @param {undefined|{
134
+ * [key: string]: string
135
+ * }} [data]
136
+ */
137
+
138
+ /**
139
+ * @callback GetRegexFromString
140
+ * @param {string} str
141
+ * @param {string} [requiredFlags]
142
+ * @returns {RegExp}
143
+ */
144
+
145
+ /**
146
+ * @callback GetTagDescription
147
+ * @param {import('comment-parser').Spec} tg
148
+ * @param {boolean} [returnArray]
149
+ * @returns {string[]|string}
150
+ */
151
+
152
+ /**
153
+ * @callback SetTagDescription
154
+ * @param {import('comment-parser').Spec} tg
155
+ * @param {RegExp} matcher
156
+ * @param {(description: string) => string} setter
157
+ * @returns {Integer}
158
+ */
159
+
160
+ /**
161
+ * @callback GetDescription
162
+ * @returns {{
163
+ * description: string,
164
+ * descriptions: string[],
165
+ * lastDescriptionLine: Integer
166
+ * }}
167
+ */
168
+
169
+ /**
170
+ * @callback SetBlockDescription
171
+ * @param {(
172
+ * info: {
173
+ * delimiter: string,
174
+ * postDelimiter: string,
175
+ * start: string
176
+ * },
177
+ * seedTokens: (
178
+ * tokens?: Partial<import('comment-parser').Tokens>
179
+ * ) => import('comment-parser').Tokens,
180
+ * descLines: string[],
181
+ * postDelims: string[]
182
+ * ) => import('comment-parser').Line[]} setter
183
+ * @returns {void}
184
+ */
185
+
186
+ /**
187
+ * @callback SetDescriptionLines
188
+ * @param {RegExp} matcher
189
+ * @param {(description: string) => string} setter
190
+ * @returns {Integer}
191
+ */
192
+
193
+ /**
194
+ * @callback ChangeTag
195
+ * @param {import('comment-parser').Spec} tag
196
+ * @param {...Partial<import('comment-parser').Tokens>} tokens
197
+ * @returns {void}
198
+ */
199
+
200
+ /**
201
+ * @callback SetTag
202
+ * @param {import('comment-parser').Spec & {
203
+ * line: Integer
204
+ * }} tag
205
+ * @param {Partial<import('comment-parser').Tokens>} [tokens]
206
+ * @returns {void}
207
+ */
208
+
209
+ /**
210
+ * @callback RemoveTag
211
+ * @param {Integer} tagIndex
212
+ * @param {{
213
+ * removeEmptyBlock?: boolean,
214
+ * tagSourceOffset?: Integer
215
+ * }} [cfg]
216
+ * @returns {void}
217
+ */
218
+
219
+ /**
220
+ * @callback AddTag
221
+ * @param {string} targetTagName
222
+ * @param {Integer} [number]
223
+ * @param {Partial<import('comment-parser').Tokens>} [tokens]
224
+ * @returns {void}
225
+ */
226
+
227
+ /**
228
+ * @callback GetFirstLine
229
+ * @returns {Integer|undefined}
230
+ */
231
+
232
+ /**
233
+ * @typedef {(
234
+ * tokens?: Partial<import('comment-parser').Tokens> | undefined
235
+ * ) => import('comment-parser').Tokens} SeedTokens
236
+ */
237
+
238
+ /**
239
+ * Sets tokens to empty string.
240
+ * @callback EmptyTokens
241
+ * @param {import('comment-parser').Tokens} tokens
242
+ * @returns {void}
243
+ */
244
+
245
+ /**
246
+ * @callback AddLine
247
+ * @param {Integer} sourceIndex
248
+ * @param {Partial<import('comment-parser').Tokens>} tokens
249
+ * @returns {void}
250
+ */
251
+
252
+ /**
253
+ * @callback AddLines
254
+ * @param {Integer} tagIndex
255
+ * @param {Integer} tagSourceOffset
256
+ * @param {Integer} numLines
257
+ * @returns {void}
258
+ */
259
+
260
+ /**
261
+ * @callback MakeMultiline
262
+ * @returns {void}
263
+ */
264
+
265
+ /**
266
+ * @callback GetFunctionParameterNames
267
+ * @param {boolean} [useDefaultObjectProperties]
268
+ * @param {boolean} [ignoreInterfacedParameters]
269
+ * @returns {import('./jsdocUtils.js').ParamNameInfo[]}
270
+ */
271
+
272
+ /**
273
+ * @callback HasParams
274
+ * @returns {Integer}
275
+ */
276
+
277
+ /**
278
+ * @callback IsGenerator
279
+ * @returns {boolean}
280
+ */
281
+
282
+ /**
283
+ * @callback IsConstructor
284
+ * @returns {boolean}
285
+ */
286
+
287
+ /**
288
+ * @callback GetJsdocTagsDeep
289
+ * @param {string} tagName
290
+ * @returns {false|{
291
+ * idx: Integer,
292
+ * name: string,
293
+ * type: string
294
+ * }[]}
295
+ */
296
+
297
+ /**
298
+ * @callback GetPreferredTagName
299
+ * @param {{
300
+ * tagName: string,
301
+ * skipReportingBlockedTag?: boolean,
302
+ * allowObjectReturn?: boolean,
303
+ * defaultMessage?: string
304
+ * }} cfg
305
+ * @returns {string|undefined|false|{
306
+ * message: string;
307
+ * replacement?: string|undefined;
308
+ * }|{
309
+ * blocked: true,
310
+ * tagName: string
311
+ * }}
312
+ */
313
+
314
+ /**
315
+ * @callback IsValidTag
316
+ * @param {string} name
317
+ * @param {string[]} definedTags
318
+ * @returns {boolean}
319
+ */
320
+
321
+ /**
322
+ * @callback HasATag
323
+ * @param {string[]} names
324
+ * @returns {boolean}
325
+ */
326
+
327
+ /**
328
+ * @callback HasTag
329
+ * @param {string} name
330
+ * @returns {boolean}
331
+ */
332
+
333
+ /**
334
+ * @callback ComparePaths
335
+ * @param {string} name
336
+ * @returns {(otherPathName: string) => boolean}
337
+ */
338
+
339
+ /**
340
+ * @callback DropPathSegmentQuotes
341
+ * @param {string} name
342
+ * @returns {string}
343
+ */
344
+
345
+ /**
346
+ * @callback AvoidDocs
347
+ * @returns {boolean}
348
+ */
349
+
350
+ /**
351
+ * @callback TagMightHaveNamePositionTypePosition
352
+ * @param {string} tagName
353
+ * @param {import('./getDefaultTagStructureForMode.js').
354
+ * TagStructure[]} [otherModeMaps]
355
+ * @returns {boolean|{otherMode: true}}
356
+ */
357
+
358
+ /**
359
+ * @callback TagMustHave
360
+ * @param {string} tagName
361
+ * @param {import('./getDefaultTagStructureForMode.js').
362
+ * TagStructure[]} otherModeMaps
363
+ * @returns {boolean|{
364
+ * otherMode: false
365
+ * }}
366
+ */
367
+
368
+ /**
369
+ * @callback TagMissingRequiredTypeOrNamepath
370
+ * @param {import('comment-parser').Spec} tag
371
+ * @param {import('./getDefaultTagStructureForMode.js').
372
+ * TagStructure[]} otherModeMaps
373
+ * @returns {boolean|{
374
+ * otherMode: false
375
+ * }}
376
+ */
377
+
378
+ /**
379
+ * @callback IsNamepathX
380
+ * @param {string} tagName
381
+ * @returns {boolean}
382
+ */
383
+
384
+ /**
385
+ * @callback GetTagStructureForMode
386
+ * @param {import('./jsdocUtils.js').ParserMode} mde
387
+ * @returns {import('./getDefaultTagStructureForMode.js').TagStructure}
388
+ */
389
+
390
+ /**
391
+ * @callback MayBeUndefinedTypeTag
392
+ * @param {import('comment-parser').Spec} tag
393
+ * @returns {boolean}
394
+ */
395
+
396
+ /**
397
+ * @callback HasValueOrExecutorHasNonEmptyResolveValue
398
+ * @param {boolean} anyPromiseAsReturn
399
+ * @param {boolean} [allBranches]
400
+ * @returns {boolean}
401
+ */
402
+
403
+ /**
404
+ * @callback HasYieldValue
405
+ * @returns {boolean}
406
+ */
407
+
408
+ /**
409
+ * @callback HasYieldReturnValue
410
+ * @returns {boolean}
411
+ */
412
+
413
+ /**
414
+ * @callback HasThrowValue
415
+ * @returns {boolean}
416
+ */
417
+
418
+ /**
419
+ * @callback IsAsync
420
+ * @returns {boolean|undefined}
421
+ */
422
+
423
+ /**
424
+ * @callback GetTags
425
+ * @param {string} tagName
426
+ * @returns {import('comment-parser').Spec[]}
427
+ */
428
+
429
+ /**
430
+ * @callback GetPresentTags
431
+ * @param {string[]} tagList
432
+ * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
433
+ */
434
+
435
+ /**
436
+ * @callback FilterTags
437
+ * @param {(tag: import('@es-joy/jsdoccomment').JsdocTagWithInline) => boolean} filter
438
+ * @returns {import('@es-joy/jsdoccomment').JsdocTagWithInline[]}
439
+ */
440
+
441
+ /**
442
+ * @callback FilterAllTags
443
+ * @param {(tag: (import('comment-parser').Spec|
444
+ * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)) => boolean} filter
445
+ * @returns {(import('comment-parser').Spec|
446
+ * import('@es-joy/jsdoccomment').JsdocInlineTagNoType)[]}
447
+ */
448
+
449
+ /**
450
+ * @callback getInlineTags
451
+ * @returns {(import('comment-parser').Spec|
452
+ * import('@es-joy/jsdoccomment').JsdocInlineTagNoType & {
453
+ * line?: number | undefined; column?: number | undefined;
454
+ * })[]}
455
+ */
456
+
457
+ /**
458
+ * @callback GetTagsByType
459
+ * @param {import('comment-parser').Spec[]} tags
460
+ * @returns {{
461
+ * tagsWithNames: import('comment-parser').Spec[],
462
+ * tagsWithoutNames: import('comment-parser').Spec[]
463
+ * }}
464
+ */
465
+
466
+ /**
467
+ * @callback HasOptionTag
468
+ * @param {string} tagName
469
+ * @returns {boolean}
470
+ */
471
+
472
+ /**
473
+ * @callback GetClassNode
474
+ * @returns {Node|null}
475
+ */
476
+
477
+ /**
478
+ * @callback GetClassJsdoc
479
+ * @returns {null|JsdocBlockWithInline}
480
+ */
481
+
482
+ /**
483
+ * @callback ClassHasTag
484
+ * @param {string} tagName
485
+ * @returns {boolean}
486
+ */
487
+
488
+ /**
489
+ * @callback FindContext
490
+ * @param {Context[]} contexts
491
+ * @param {string|undefined} comment
492
+ * @returns {{
493
+ * foundContext: Context|undefined,
494
+ * contextStr: string
495
+ * }}
496
+ */
497
+
498
+ /**
499
+ * @typedef {BasicUtils & {
500
+ * isIteratingFunction: IsIteratingFunction,
501
+ * isIteratingFunctionOrVariable: IsIteratingFunction,
502
+ * isVirtualFunction: IsVirtualFunction,
503
+ * stringify: Stringify,
504
+ * reportJSDoc: ReportJSDoc,
505
+ * getRegexFromString: GetRegexFromString,
506
+ * getTagDescription: GetTagDescription,
507
+ * setTagDescription: SetTagDescription,
508
+ * getDescription: GetDescription,
509
+ * setBlockDescription: SetBlockDescription,
510
+ * setDescriptionLines: SetDescriptionLines,
511
+ * changeTag: ChangeTag,
512
+ * setTag: SetTag,
513
+ * removeTag: RemoveTag,
514
+ * addTag: AddTag,
515
+ * getFirstLine: GetFirstLine,
516
+ * seedTokens: SeedTokens,
517
+ * emptyTokens: EmptyTokens,
518
+ * addLine: AddLine,
519
+ * addLines: AddLines,
520
+ * makeMultiline: MakeMultiline,
521
+ * flattenRoots: import('./jsdocUtils.js').FlattenRoots,
522
+ * getFunctionParameterNames: GetFunctionParameterNames,
523
+ * hasParams: HasParams,
524
+ * isGenerator: IsGenerator,
525
+ * isConstructor: IsConstructor,
526
+ * getJsdocTagsDeep: GetJsdocTagsDeep,
527
+ * getPreferredTagName: GetPreferredTagName,
528
+ * isValidTag: IsValidTag,
529
+ * hasATag: HasATag,
530
+ * hasTag: HasTag,
531
+ * comparePaths: ComparePaths,
532
+ * dropPathSegmentQuotes: DropPathSegmentQuotes,
533
+ * avoidDocs: AvoidDocs,
534
+ * tagMightHaveNamePosition: TagMightHaveNamePositionTypePosition,
535
+ * tagMightHaveTypePosition: TagMightHaveNamePositionTypePosition,
536
+ * tagMustHaveNamePosition: TagMustHave,
537
+ * tagMustHaveTypePosition: TagMustHave,
538
+ * tagMissingRequiredTypeOrNamepath: TagMissingRequiredTypeOrNamepath,
539
+ * isNameOrNamepathDefiningTag: IsNamepathX,
540
+ * isNamepathReferencingTag: IsNamepathX,
541
+ * isNamepathOrUrlReferencingTag: IsNamepathX,
542
+ * tagMightHaveNameOrNamepath: IsNamepathX,
543
+ * tagMightHaveName: IsNamepathX,
544
+ * tagMightHaveNamepath: IsNamepathX,
545
+ * getTagStructureForMode: GetTagStructureForMode,
546
+ * mayBeUndefinedTypeTag: MayBeUndefinedTypeTag,
547
+ * hasValueOrExecutorHasNonEmptyResolveValue: HasValueOrExecutorHasNonEmptyResolveValue,
548
+ * hasYieldValue: HasYieldValue,
549
+ * hasYieldReturnValue: HasYieldReturnValue,
550
+ * hasThrowValue: HasThrowValue,
551
+ * isAsync: IsAsync,
552
+ * getTags: GetTags,
553
+ * getPresentTags: GetPresentTags,
554
+ * filterTags: FilterTags,
555
+ * filterAllTags: FilterAllTags,
556
+ * getInlineTags: getInlineTags,
557
+ * getTagsByType: GetTagsByType,
558
+ * hasOptionTag: HasOptionTag,
559
+ * getClassNode: GetClassNode,
560
+ * getClassJsdoc: GetClassJsdoc,
561
+ * classHasTag: ClassHasTag,
562
+ * findContext: FindContext
563
+ * }} Utils
564
+ */
565
+
566
+ const {
567
+ rewireSpecs,
568
+ seedTokens
569
+ } = _commentParser.util;
570
+
571
+ /**
572
+ * Should use ESLint rule's typing.
573
+ * @typedef {import('eslint').Rule.RuleMetaData} EslintRuleMeta
574
+ */
575
+
576
+ /**
577
+ * A plain object for tracking state as needed by rules across iterations.
578
+ * @typedef {{
579
+ * globalTags: boolean,
580
+ * hasDuplicates: {
581
+ * [key: string]: boolean
582
+ * },
583
+ * selectorMap: {
584
+ * [selector: string]: {
585
+ * [comment: string]: Integer
586
+ * }
587
+ * },
588
+ * hasTag: {
589
+ * [key: string]: boolean
590
+ * },
591
+ * hasNonComment: number,
592
+ * hasNonCommentBeforeTag: {
593
+ * [key: string]: boolean|number
594
+ * },
595
+ * foundTypedefValues: string[]
596
+ * }} StateObject
597
+ */
598
+
599
+ /**
600
+ * The Node AST as supplied by the parser.
601
+ * @typedef {import('eslint').Rule.Node} Node
602
+ */
603
+
604
+ /*
605
+ const {
606
+ align as commentAlign,
607
+ flow: commentFlow,
608
+ indent: commentIndent,
609
+ } = transforms;
610
+ */
611
+
612
+ const globalState = new Map();
613
+ /**
614
+ * @param {import('eslint').Rule.RuleContext} context
615
+ * @param {{
616
+ * tagNamePreference?: import('./jsdocUtils.js').TagNamePreference,
617
+ * mode?: import('./jsdocUtils.js').ParserMode
618
+ * }} cfg
619
+ * @returns {BasicUtils}
620
+ */
621
+ const getBasicUtils = (context, {
622
+ mode,
623
+ tagNamePreference
624
+ }) => {
625
+ /** @type {BasicUtils} */
626
+ const utils = {};
627
+ for (const method of ['isNameOrNamepathDefiningTag', 'isNamepathReferencingTag', 'isNamepathOrUrlReferencingTag', 'tagMightHaveNameOrNamepath', 'tagMightHaveName', 'tagMightHaveNamepath']) {
628
+ /** @type {IsNamepathX} */
629
+ utils[(/** @type {"isNameOrNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNameOrNamepath"|"tagMightHaveName"} */
630
+ method)] = tagName => {
631
+ return jsdocUtils[(/** @type {"isNameOrNamepathDefiningTag"|"isNamepathReferencingTag"|"isNamepathOrUrlReferencingTag"|"tagMightHaveNameOrNamepath"|"tagMightHaveName"} */
632
+ method)](tagName);
633
+ };
634
+ }
635
+
636
+ /** @type {ReportSettings} */
637
+ utils.reportSettings = message => {
638
+ context.report({
639
+ loc: {
640
+ end: {
641
+ column: 1,
642
+ line: 1
643
+ },
644
+ start: {
645
+ column: 1,
646
+ line: 1
647
+ }
648
+ },
649
+ message
650
+ });
651
+ };
652
+
653
+ /** @type {ParseClosureTemplateTag} */
654
+ utils.parseClosureTemplateTag = tag => {
655
+ return jsdocUtils.parseClosureTemplateTag(tag);
656
+ };
657
+ utils.pathDoesNotBeginWith = jsdocUtils.pathDoesNotBeginWith;
658
+
659
+ /** @type {GetPreferredTagNameObject} */
660
+ utils.getPreferredTagNameObject = ({
661
+ tagName
662
+ }) => {
663
+ const ret = jsdocUtils.getPreferredTagNameSimple(tagName, /** @type {import('./jsdocUtils.js').ParserMode} */mode, tagNamePreference, context);
664
+ const isObject = ret && typeof ret === 'object';
665
+ if (ret === false || isObject && !ret.replacement) {
666
+ return {
667
+ blocked: true,
668
+ tagName
669
+ };
670
+ }
671
+ return ret;
672
+ };
673
+ return utils;
674
+ };
675
+
676
+ /**
677
+ * @callback Report
678
+ * @param {string} message
679
+ * @param {import('@eslint/core').RuleFixer|null} [fix]
680
+ * @param {null|
681
+ * {line?: Integer, column?: Integer}|
682
+ * import('comment-parser').Spec & {line?: Integer}
683
+ * } [jsdocLoc]
684
+ * @param {undefined|{
685
+ * [key: string]: string
686
+ * }} [data]
687
+ * @returns {void}
688
+ */
689
+
690
+ /**
691
+ * @param {Node|null} node
692
+ * @param {JsdocBlockWithInline} jsdoc
693
+ * @param {import('eslint').AST.Token} jsdocNode
694
+ * @param {Settings} settings
695
+ * @param {Report} report
696
+ * @param {import('eslint').Rule.RuleContext} context
697
+ * @param {import('eslint').SourceCode} sc
698
+ * @param {boolean|undefined} iteratingAll
699
+ * @param {RuleConfig} ruleConfig
700
+ * @param {string} indent
701
+ * @returns {Utils}
702
+ */
703
+ const getUtils = (node, jsdoc, jsdocNode, settings, report, context, sc, iteratingAll, ruleConfig, indent) => {
704
+ const ancestors = /** @type {import('eslint').Rule.Node[]} */node ? sc.getAncestors ? sc.getAncestors(node)
705
+ /* c8 ignore next 5 */ :
706
+ // @ts-expect-error ESLint 8
707
+ context.getAncestors() : [];
708
+
709
+ /* c8 ignore next -- Fallback to deprecated method */
710
+ const {
711
+ // @ts-expect-error ESLint < 10
712
+ sourceCode = context.getSourceCode()
713
+ } = context;
714
+ const utils = /** @type {Utils} */getBasicUtils(context, settings);
715
+ const {
716
+ augmentsExtendsReplacesDocs,
717
+ ignoreReplacesDocs,
718
+ implementsReplacesDocs,
719
+ maxLines,
720
+ minLines,
721
+ mode,
722
+ overrideReplacesDocs,
723
+ tagNamePreference
724
+ } = settings;
725
+ const functionTypes = ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'MethodDefinition'];
726
+
727
+ /** @type {IsIteratingFunction} */
728
+ utils.isIteratingFunction = () => {
729
+ return !iteratingAll || functionTypes.includes(String(node?.type));
730
+ };
731
+
732
+ /** @type {IsIteratingFunction} */
733
+ utils.isIteratingFunctionOrVariable = () => {
734
+ if (utils.isIteratingFunction()) {
735
+ return true;
736
+ }
737
+
738
+ /** @type {import('estree').VariableDeclarator[]} */
739
+ const declarations = node?.type === 'VariableDeclaration' ? node.declarations : node?.type === 'ExportNamedDeclaration' && node.declaration?.type === 'VariableDeclaration' ? node.declaration.declarations : [];
740
+ return declarations.some(({
741
+ init
742
+ }) => {
743
+ return functionTypes.includes(String(init?.type));
744
+ });
745
+ };
746
+
747
+ /** @type {IsVirtualFunction} */
748
+ utils.isVirtualFunction = () => {
749
+ return Boolean(iteratingAll) && utils.hasATag(['callback', 'function', 'func', 'method']);
750
+ };
751
+
752
+ /** @type {Stringify} */
753
+ utils.stringify = (tagBlock, specRewire) => {
754
+ let block;
755
+ if (specRewire) {
756
+ block = rewireSpecs(tagBlock);
757
+ }
758
+ return (0, _commentParser.stringify)(/** @type {import('comment-parser').Block} */
759
+ specRewire ? block : tagBlock);
760
+ };
761
+
762
+ /** @type {ReportJSDoc} */
763
+ utils.reportJSDoc = (msg, tag, handler, specRewire, data) => {
764
+ report(msg, handler ? /** @type {import('eslint').Rule.ReportFixer} */fixer => {
765
+ const extraFix = handler(fixer);
766
+ const replacement = utils.stringify(jsdoc, specRewire);
767
+ if (!replacement) {
768
+ const text = sourceCode.getText();
769
+ const lastLineBreakPos = text.slice(0, jsdocNode.range[0]).search(/\n[ \t]*$/v);
770
+ if (lastLineBreakPos > -1) {
771
+ return [fixer.removeRange([lastLineBreakPos, jsdocNode.range[1]]), /* c8 ignore next 2 -- Guard */
772
+ ...(extraFix ? [extraFix] : [])];
773
+ }
774
+ return [fixer.removeRange(/\s/v.test(text.charAt(jsdocNode.range[1])) ? [jsdocNode.range[0], jsdocNode.range[1] + 1] : jsdocNode.range), /* c8 ignore next 2 -- Guard */
775
+ ...(extraFix ? [extraFix] : [])];
776
+ }
777
+ return [fixer.replaceText(jsdocNode, replacement), ...(extraFix ? [extraFix] : [])];
778
+ } : null, tag, data);
779
+ };
780
+
781
+ /** @type {GetRegexFromString} */
782
+ utils.getRegexFromString = (str, requiredFlags) => {
783
+ return jsdocUtils.getRegexFromString(str, requiredFlags);
784
+ };
785
+
786
+ /** @type {GetTagDescription} */
787
+ utils.getTagDescription = (tg, returnArray) => {
788
+ return jsdocUtils.getTagDescription(tg, returnArray);
789
+ };
790
+
791
+ /** @type {SetTagDescription} */
792
+ utils.setTagDescription = (tg, matcher, setter) => {
793
+ let finalIdx = 0;
794
+ tg.source.some(({
795
+ tokens: {
796
+ description
797
+ }
798
+ }, idx) => {
799
+ if (description && matcher.test(description)) {
800
+ tg.source[idx].tokens.description = setter(description);
801
+ finalIdx = idx;
802
+ return true;
803
+ }
804
+ return false;
805
+ });
806
+ return finalIdx;
807
+ };
808
+
809
+ /** @type {GetDescription} */
810
+ utils.getDescription = () => {
811
+ /** @type {string[]} */
812
+ const descriptions = [];
813
+ let lastDescriptionLine = 0;
814
+ let tagsBegun = false;
815
+ jsdoc.source.some(({
816
+ tokens: {
817
+ description,
818
+ end,
819
+ tag
820
+ }
821
+ }, idx) => {
822
+ if (tag) {
823
+ tagsBegun = true;
824
+ }
825
+ if (idx && (tag || end)) {
826
+ lastDescriptionLine = idx - 1;
827
+ if (!tagsBegun && description) {
828
+ descriptions.push(description);
829
+ }
830
+ return true;
831
+ }
832
+ if (!tagsBegun && (idx || description)) {
833
+ descriptions.push(description || (descriptions.length ? '' : '\n'));
834
+ }
835
+ return false;
836
+ });
837
+ return {
838
+ description: descriptions.join('\n'),
839
+ descriptions,
840
+ lastDescriptionLine
841
+ };
842
+ };
843
+
844
+ /** @type {SetBlockDescription} */
845
+ utils.setBlockDescription = setter => {
846
+ /** @type {string[]} */
847
+ const descLines = [];
848
+ /** @type {string[]} */
849
+ const postDelims = [];
850
+ /**
851
+ * @type {undefined|Integer}
852
+ */
853
+ let startIdx;
854
+ /**
855
+ * @type {undefined|Integer}
856
+ */
857
+ let endIdx;
858
+
859
+ /**
860
+ * @type {undefined|{
861
+ * delimiter: string,
862
+ * postDelimiter: string,
863
+ * start: string
864
+ * }}
865
+ */
866
+ let info;
867
+ jsdoc.source.some(({
868
+ tokens: {
869
+ delimiter,
870
+ description,
871
+ end,
872
+ postDelimiter,
873
+ start,
874
+ tag
875
+ }
876
+ }, idx) => {
877
+ if (delimiter === '/**') {
878
+ return false;
879
+ }
880
+ if (startIdx === undefined) {
881
+ startIdx = idx;
882
+ info = {
883
+ delimiter,
884
+ postDelimiter,
885
+ start
886
+ };
887
+ }
888
+ if (tag || end) {
889
+ endIdx = idx;
890
+ return true;
891
+ }
892
+ postDelims.push(postDelimiter);
893
+ descLines.push(description);
894
+ return false;
895
+ });
896
+
897
+ /* c8 ignore else -- Won't be called if missing */
898
+ if (descLines.length) {
899
+ jsdoc.source.splice(/** @type {Integer} */startIdx, /** @type {Integer} */endIdx - (/** @type {Integer} */startIdx), ...setter(
900
+ /**
901
+ * @type {{
902
+ * delimiter: string,
903
+ * postDelimiter: string,
904
+ * start: string
905
+ * }}
906
+ */
907
+ info, seedTokens, descLines, postDelims));
908
+ }
909
+ };
910
+
911
+ /** @type {SetDescriptionLines} */
912
+ utils.setDescriptionLines = (matcher, setter) => {
913
+ let finalIdx = 0;
914
+ jsdoc.source.some(({
915
+ tokens: {
916
+ description,
917
+ end,
918
+ tag
919
+ }
920
+ }, idx) => {
921
+ /* c8 ignore next 3 -- Already checked */
922
+ if (idx && (tag || end)) {
923
+ return true;
924
+ }
925
+ if (description && matcher.test(description)) {
926
+ jsdoc.source[idx].tokens.description = setter(description);
927
+ finalIdx = idx;
928
+ return true;
929
+ }
930
+ return false;
931
+ });
932
+ return finalIdx;
933
+ };
934
+
935
+ /** @type {ChangeTag} */
936
+ utils.changeTag = (tag, ...tokens) => {
937
+ for (const [idx, src] of tag.source.entries()) {
938
+ src.tokens = {
939
+ ...src.tokens,
940
+ ...tokens[idx]
941
+ };
942
+ }
943
+ };
944
+
945
+ /** @type {SetTag} */
946
+ utils.setTag = (tag, tokens) => {
947
+ tag.source = [{
948
+ number: tag.line,
949
+ // Or tag.source[0].number?
950
+ source: '',
951
+ tokens: seedTokens({
952
+ delimiter: '*',
953
+ postDelimiter: ' ',
954
+ start: indent + ' ',
955
+ tag: '@' + tag.tag,
956
+ ...tokens
957
+ })
958
+ }];
959
+ };
960
+
961
+ /** @type {RemoveTag} */
962
+ utils.removeTag = (tagIndex, {
963
+ removeEmptyBlock = false,
964
+ tagSourceOffset = 0
965
+ } = {}) => {
966
+ const {
967
+ source: tagSource
968
+ } = jsdoc.tags[tagIndex];
969
+ /** @type {Integer|undefined} */
970
+ let lastIndex;
971
+ const firstNumber = jsdoc.source[0].number;
972
+ tagSource.some(({
973
+ number
974
+ }, tagIdx) => {
975
+ const sourceIndex = jsdoc.source.findIndex(({
976
+ number: srcNumber
977
+ }) => {
978
+ return number === srcNumber;
979
+ });
980
+ // c8 ignore else
981
+ if (sourceIndex > -1) {
982
+ let spliceCount = 1;
983
+ tagSource.slice(tagIdx + 1).some(({
984
+ tokens: {
985
+ end: ending,
986
+ tag
987
+ }
988
+ }) => {
989
+ if (!tag && !ending) {
990
+ spliceCount++;
991
+ return false;
992
+ }
993
+ return true;
994
+ });
995
+ const spliceIdx = sourceIndex + tagSourceOffset;
996
+ const {
997
+ delimiter,
998
+ end
999
+ } = jsdoc.source[spliceIdx].tokens;
1000
+ if (spliceIdx === 0 && jsdoc.tags.length >= 2 || !removeEmptyBlock && (end || delimiter === '/**')) {
1001
+ const {
1002
+ tokens
1003
+ } = jsdoc.source[spliceIdx];
1004
+ for (const item of ['postDelimiter', 'tag', 'postTag', 'type', 'postType', 'name', 'postName', 'description']) {
1005
+ tokens[(
1006
+ /**
1007
+ * @type {"postDelimiter"|"tag"|"type"|"postType"|
1008
+ * "postTag"|"name"|"postName"|"description"}
1009
+ */
1010
+ item)] = '';
1011
+ }
1012
+ } else {
1013
+ jsdoc.source.splice(spliceIdx, spliceCount - tagSourceOffset + (spliceIdx ? 0 : jsdoc.source.length));
1014
+ tagSource.splice(tagIdx + tagSourceOffset, spliceCount - tagSourceOffset + (spliceIdx ? 0 : jsdoc.source.length));
1015
+ }
1016
+ lastIndex = sourceIndex;
1017
+ return true;
1018
+ }
1019
+ /* c8 ignore next 2 */
1020
+ // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
1021
+ return false;
1022
+ });
1023
+ for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) {
1024
+ src.number = firstNumber + (/** @type {Integer} */lastIndex) + idx;
1025
+ }
1026
+
1027
+ // Todo: Once rewiring of tags may be fixed in comment-parser to reflect
1028
+ // missing tags, this step should be added here (so that, e.g.,
1029
+ // if accessing `jsdoc.tags`, such as to add a new tag, the
1030
+ // correct information will be available)
1031
+ };
1032
+
1033
+ /** @type {AddTag} */
1034
+ utils.addTag = (targetTagName, number = (jsdoc.tags[jsdoc.tags.length - 1]?.source[0]?.number ?? jsdoc.source.findIndex(({
1035
+ tokens: {
1036
+ tag
1037
+ }
1038
+ }) => {
1039
+ return tag;
1040
+ }) - 1) + 1, tokens = {}) => {
1041
+ jsdoc.source.splice(number, 0, {
1042
+ number,
1043
+ source: '',
1044
+ tokens: seedTokens({
1045
+ delimiter: '*',
1046
+ postDelimiter: ' ',
1047
+ start: indent + ' ',
1048
+ tag: `@${targetTagName}`,
1049
+ ...tokens
1050
+ })
1051
+ });
1052
+ for (const src of jsdoc.source.slice(number + 1)) {
1053
+ src.number++;
1054
+ }
1055
+ };
1056
+
1057
+ /** @type {GetFirstLine} */
1058
+ utils.getFirstLine = () => {
1059
+ let firstLine;
1060
+ for (const {
1061
+ number,
1062
+ tokens: {
1063
+ tag
1064
+ }
1065
+ } of jsdoc.source) {
1066
+ if (tag) {
1067
+ firstLine = number;
1068
+ break;
1069
+ }
1070
+ }
1071
+ return firstLine;
1072
+ };
1073
+
1074
+ /** @type {SeedTokens} */
1075
+ utils.seedTokens = seedTokens;
1076
+
1077
+ /** @type {EmptyTokens} */
1078
+ utils.emptyTokens = tokens => {
1079
+ for (const prop of ['start', 'postDelimiter', 'tag', 'type', 'postType', 'postTag', 'name', 'postName', 'description', 'end', 'lineEnd']) {
1080
+ tokens[(
1081
+ /**
1082
+ * @type {"start"|"postDelimiter"|"tag"|"type"|"postType"|
1083
+ * "postTag"|"name"|"postName"|"description"|"end"|"lineEnd"}
1084
+ */
1085
+ prop)] = '';
1086
+ }
1087
+ };
1088
+
1089
+ /** @type {AddLine} */
1090
+ utils.addLine = (sourceIndex, tokens) => {
1091
+ const number = (jsdoc.source[sourceIndex - 1]?.number || 0) + 1;
1092
+ jsdoc.source.splice(sourceIndex, 0, {
1093
+ number,
1094
+ source: '',
1095
+ tokens: seedTokens(tokens)
1096
+ });
1097
+ for (const src of jsdoc.source.slice(number + 1)) {
1098
+ src.number++;
1099
+ }
1100
+ // If necessary, we can rewire the tags (misnamed method)
1101
+ // rewireSource(jsdoc);
1102
+ };
1103
+
1104
+ /** @type {AddLines} */
1105
+ utils.addLines = (tagIndex, tagSourceOffset, numLines) => {
1106
+ const {
1107
+ source: tagSource
1108
+ } = jsdoc.tags[tagIndex];
1109
+ /** @type {Integer|undefined} */
1110
+ let lastIndex;
1111
+ const firstNumber = jsdoc.source[0].number;
1112
+ tagSource.some(({
1113
+ number
1114
+ }) => {
1115
+ const makeLine = () => {
1116
+ return {
1117
+ number,
1118
+ source: '',
1119
+ tokens: seedTokens({
1120
+ delimiter: '*',
1121
+ start: indent + ' '
1122
+ })
1123
+ };
1124
+ };
1125
+ const makeLines = () => {
1126
+ return Array.from({
1127
+ length: numLines
1128
+ }, makeLine);
1129
+ };
1130
+ const sourceIndex = jsdoc.source.findIndex(({
1131
+ number: srcNumber,
1132
+ tokens: {
1133
+ end
1134
+ }
1135
+ }) => {
1136
+ return number === srcNumber && !end;
1137
+ });
1138
+ // c8 ignore else
1139
+ if (sourceIndex > -1) {
1140
+ const lines = makeLines();
1141
+ jsdoc.source.splice(sourceIndex + tagSourceOffset, 0, ...lines);
1142
+
1143
+ // tagSource.splice(tagIdx + 1, 0, ...makeLines());
1144
+ lastIndex = sourceIndex;
1145
+ return true;
1146
+ }
1147
+ /* c8 ignore next 2 */
1148
+ // eslint-disable-next-line @stylistic/padding-line-between-statements -- c8
1149
+ return false;
1150
+ });
1151
+ for (const [idx, src] of jsdoc.source.slice(lastIndex).entries()) {
1152
+ src.number = firstNumber + (/** @type {Integer} */lastIndex) + idx;
1153
+ }
1154
+ };
1155
+
1156
+ /** @type {MakeMultiline} */
1157
+ utils.makeMultiline = () => {
1158
+ const {
1159
+ source: [{
1160
+ tokens
1161
+ }]
1162
+ } = jsdoc;
1163
+ const {
1164
+ description,
1165
+ lineEnd,
1166
+ name,
1167
+ postDelimiter,
1168
+ tag,
1169
+ type
1170
+ } = tokens;
1171
+ let {
1172
+ tokens: {
1173
+ postName,
1174
+ postTag,
1175
+ postType
1176
+ }
1177
+ } = jsdoc.source[0];
1178
+
1179
+ // Strip trailing leftovers from single line ending
1180
+ if (!description) {
1181
+ if (postName) {
1182
+ postName = '';
1183
+ } else if (postType) {
1184
+ postType = '';
1185
+ } else /* c8 ignore else -- `comment-parser` prevents empty blocks currently per https://github.com/syavorsky/comment-parser/issues/128 */if (postTag) {
1186
+ postTag = '';
1187
+ }
1188
+ }
1189
+ utils.emptyTokens(tokens);
1190
+ utils.addLine(1, {
1191
+ delimiter: '*',
1192
+ // If a description were present, it may have whitespace attached
1193
+ // due to being at the end of the single line
1194
+ description: description.trimEnd(),
1195
+ name,
1196
+ postDelimiter,
1197
+ postName,
1198
+ postTag,
1199
+ postType,
1200
+ start: indent + ' ',
1201
+ tag,
1202
+ type
1203
+ });
1204
+ utils.addLine(2, {
1205
+ end: '*/',
1206
+ lineEnd,
1207
+ start: indent + ' '
1208
+ });
1209
+ };
1210
+
1211
+ /**
1212
+ * @type {import('./jsdocUtils.js').FlattenRoots}
1213
+ */
1214
+ utils.flattenRoots = jsdocUtils.flattenRoots;
1215
+
1216
+ /** @type {GetFunctionParameterNames} */
1217
+ utils.getFunctionParameterNames = (useDefaultObjectProperties, ignoreInterfacedParameters) => {
1218
+ return jsdocUtils.getFunctionParameterNames(node, useDefaultObjectProperties, ignoreInterfacedParameters);
1219
+ };
1220
+
1221
+ /** @type {HasParams} */
1222
+ utils.hasParams = () => {
1223
+ return jsdocUtils.hasParams(/** @type {Node} */node);
1224
+ };
1225
+
1226
+ /** @type {IsGenerator} */
1227
+ utils.isGenerator = () => {
1228
+ return node !== null && Boolean(
1229
+ /**
1230
+ * @type {import('estree').FunctionDeclaration|
1231
+ * import('estree').FunctionExpression}
1232
+ */
1233
+ node.generator || node.type === 'MethodDefinition' && node.value.generator || ['ExportDefaultDeclaration', 'ExportNamedDeclaration'].includes(node.type) && /** @type {import('estree').FunctionDeclaration} */
1234
+ (
1235
+ /**
1236
+ * @type {import('estree').ExportNamedDeclaration|
1237
+ * import('estree').ExportDefaultDeclaration}
1238
+ */
1239
+ node.declaration)?.generator);
1240
+ };
1241
+
1242
+ /** @type {IsConstructor} */
1243
+ utils.isConstructor = () => {
1244
+ return jsdocUtils.isConstructor(/** @type {Node} */node);
1245
+ };
1246
+
1247
+ /** @type {GetJsdocTagsDeep} */
1248
+ utils.getJsdocTagsDeep = tagName => {
1249
+ const name = /** @type {string|false} */utils.getPreferredTagName({
1250
+ tagName
1251
+ });
1252
+ if (!name) {
1253
+ return false;
1254
+ }
1255
+ return jsdocUtils.getJsdocTagsDeep(jsdoc, name);
1256
+ };
1257
+
1258
+ /** @type {GetPreferredTagName} */
1259
+ utils.getPreferredTagName = args => {
1260
+ return jsdocUtils.getPreferredTagName(jsdoc, {
1261
+ ...args,
1262
+ context,
1263
+ mode,
1264
+ report,
1265
+ tagNamePreference
1266
+ });
1267
+ };
1268
+
1269
+ /** @type {IsValidTag} */
1270
+ utils.isValidTag = (name, definedTags) => {
1271
+ return jsdocUtils.isValidTag(context, mode, name, definedTags);
1272
+ };
1273
+
1274
+ /** @type {HasATag} */
1275
+ utils.hasATag = names => {
1276
+ return jsdocUtils.hasATag(jsdoc, names);
1277
+ };
1278
+
1279
+ /** @type {HasTag} */
1280
+ utils.hasTag = name => {
1281
+ return jsdocUtils.hasTag(jsdoc, name);
1282
+ };
1283
+
1284
+ /** @type {ComparePaths} */
1285
+ utils.comparePaths = name => {
1286
+ return jsdocUtils.comparePaths(name);
1287
+ };
1288
+
1289
+ /** @type {DropPathSegmentQuotes} */
1290
+ utils.dropPathSegmentQuotes = name => {
1291
+ return jsdocUtils.dropPathSegmentQuotes(name);
1292
+ };
1293
+
1294
+ /** @type {AvoidDocs} */
1295
+ utils.avoidDocs = () => {
1296
+ if (ignoreReplacesDocs !== false && (utils.hasTag('ignore') || utils.classHasTag('ignore')) || overrideReplacesDocs !== false && (utils.hasTag('override') || utils.classHasTag('override')) || implementsReplacesDocs !== false && (utils.hasTag('implements') || utils.classHasTag('implements')) || augmentsExtendsReplacesDocs && (utils.hasATag(['augments', 'extends']) || utils.classHasTag('augments') || utils.classHasTag('extends'))) {
1297
+ return true;
1298
+ }
1299
+ if (jsdocUtils.exemptSpeciaMethods(jsdoc, node, context, /** @type {import('json-schema').JSONSchema4|import('json-schema').JSONSchema4[]} */
1300
+ ruleConfig.meta.schema)) {
1301
+ return true;
1302
+ }
1303
+ const exemptedBy = context.options[0]?.exemptedBy ?? ['inheritDoc', ...(mode === 'closure' ? [] : ['inheritdoc'])];
1304
+ if (exemptedBy.length && utils.getPresentTags(exemptedBy).length) {
1305
+ return true;
1306
+ }
1307
+ return false;
1308
+ };
1309
+ for (const method of ['tagMightHaveNamePosition', 'tagMightHaveTypePosition']) {
1310
+ /** @type {TagMightHaveNamePositionTypePosition} */
1311
+ utils[(/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
1312
+ method)] = (tagName, otherModeMaps) => {
1313
+ const result = jsdocUtils[(/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
1314
+ method)](tagName);
1315
+ if (result) {
1316
+ return true;
1317
+ }
1318
+ if (!otherModeMaps) {
1319
+ return false;
1320
+ }
1321
+ const otherResult = otherModeMaps.some(otherModeMap => {
1322
+ return jsdocUtils[(/** @type {"tagMightHaveNamePosition"|"tagMightHaveTypePosition"} */
1323
+ method)](tagName, otherModeMap);
1324
+ });
1325
+ return otherResult ? {
1326
+ otherMode: true
1327
+ } : false;
1328
+ };
1329
+ }
1330
+
1331
+ /** @type {TagMissingRequiredTypeOrNamepath} */
1332
+ utils.tagMissingRequiredTypeOrNamepath = (tagName, otherModeMaps) => {
1333
+ const result = jsdocUtils.tagMissingRequiredTypeOrNamepath(tagName);
1334
+ if (!result) {
1335
+ return false;
1336
+ }
1337
+ const otherResult = otherModeMaps.every(otherModeMap => {
1338
+ return jsdocUtils.tagMissingRequiredTypeOrNamepath(tagName, otherModeMap);
1339
+ });
1340
+ return otherResult ? true : {
1341
+ otherMode: false
1342
+ };
1343
+ };
1344
+ for (const method of ['tagMustHaveNamePosition', 'tagMustHaveTypePosition']) {
1345
+ /** @type {TagMustHave} */
1346
+ utils[(/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
1347
+ method)] = (tagName, otherModeMaps) => {
1348
+ const result = jsdocUtils[(/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
1349
+ method)](tagName);
1350
+ if (!result) {
1351
+ return false;
1352
+ }
1353
+
1354
+ // if (!otherModeMaps) { return true; }
1355
+
1356
+ const otherResult = otherModeMaps.every(otherModeMap => {
1357
+ return jsdocUtils[(/** @type {"tagMustHaveNamePosition"|"tagMustHaveTypePosition"} */
1358
+ method)](tagName, otherModeMap);
1359
+ });
1360
+ return otherResult ? true : {
1361
+ otherMode: false
1362
+ };
1363
+ };
1364
+ }
1365
+
1366
+ /** @type {GetTagStructureForMode} */
1367
+ utils.getTagStructureForMode = mde => {
1368
+ return jsdocUtils.getTagStructureForMode(mde, settings.structuredTags);
1369
+ };
1370
+
1371
+ /** @type {MayBeUndefinedTypeTag} */
1372
+ utils.mayBeUndefinedTypeTag = tag => {
1373
+ return jsdocUtils.mayBeUndefinedTypeTag(tag, settings.mode);
1374
+ };
1375
+
1376
+ /** @type {HasValueOrExecutorHasNonEmptyResolveValue} */
1377
+ utils.hasValueOrExecutorHasNonEmptyResolveValue = (anyPromiseAsReturn, allBranches) => {
1378
+ return jsdocUtils.hasValueOrExecutorHasNonEmptyResolveValue(/** @type {Node} */node, anyPromiseAsReturn, allBranches);
1379
+ };
1380
+
1381
+ /** @type {HasYieldValue} */
1382
+ utils.hasYieldValue = () => {
1383
+ if (['ExportDefaultDeclaration', 'ExportNamedDeclaration'].includes(/** @type {Node} */node.type)) {
1384
+ return jsdocUtils.hasYieldValue(/** @type {import('estree').Declaration|import('estree').Expression} */
1385
+ /** @type {import('estree').ExportNamedDeclaration|import('estree').ExportDefaultDeclaration} */
1386
+ node.declaration);
1387
+ }
1388
+ return jsdocUtils.hasYieldValue(/** @type {Node} */node);
1389
+ };
1390
+
1391
+ /** @type {HasYieldReturnValue} */
1392
+ utils.hasYieldReturnValue = () => {
1393
+ return jsdocUtils.hasYieldValue(/** @type {Node} */node, true);
1394
+ };
1395
+
1396
+ /** @type {HasThrowValue} */
1397
+ utils.hasThrowValue = () => {
1398
+ return jsdocUtils.hasThrowValue(node);
1399
+ };
1400
+
1401
+ /** @type {IsAsync} */
1402
+ utils.isAsync = () => {
1403
+ return Boolean(node && 'async' in node && node.async);
1404
+ };
1405
+
1406
+ /** @type {GetTags} */
1407
+ utils.getTags = tagName => {
1408
+ return jsdocUtils.getTags(jsdoc, tagName);
1409
+ };
1410
+
1411
+ /** @type {GetPresentTags} */
1412
+ utils.getPresentTags = tagList => {
1413
+ return jsdocUtils.filterTags(jsdoc, tag => {
1414
+ return tagList.includes(tag.tag);
1415
+ });
1416
+ };
1417
+
1418
+ /** @type {FilterTags} */
1419
+ utils.filterTags = filter => {
1420
+ return jsdocUtils.filterTags(jsdoc, tag => {
1421
+ return filter(tag);
1422
+ });
1423
+ };
1424
+
1425
+ /** @type {FilterAllTags} */
1426
+ utils.filterAllTags = filter => {
1427
+ const tags = jsdocUtils.getAllTags(jsdoc);
1428
+ return tags.filter(tag => {
1429
+ return filter(tag);
1430
+ });
1431
+ };
1432
+ utils.getInlineTags = () => {
1433
+ return jsdocUtils.getInlineTags(jsdoc);
1434
+ };
1435
+
1436
+ /** @type {GetTagsByType} */
1437
+ utils.getTagsByType = tags => {
1438
+ return jsdocUtils.getTagsByType(context, mode, tags);
1439
+ };
1440
+
1441
+ /** @type {HasOptionTag} */
1442
+ utils.hasOptionTag = tagName => {
1443
+ const {
1444
+ tags
1445
+ } = context.options[0] ?? {};
1446
+ return Boolean(tags && tags.includes(tagName));
1447
+ };
1448
+
1449
+ /** @type {GetClassNode} */
1450
+ utils.getClassNode = () => {
1451
+ return [...ancestors, node].toReversed().find(parent => {
1452
+ return parent && ['ClassDeclaration', 'ClassExpression'].includes(parent.type);
1453
+ }) ?? null;
1454
+ };
1455
+
1456
+ /** @type {GetClassJsdoc} */
1457
+ utils.getClassJsdoc = () => {
1458
+ const classNode = utils.getClassNode();
1459
+ if (!classNode) {
1460
+ return null;
1461
+ }
1462
+ const classJsdocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, classNode, {
1463
+ maxLines,
1464
+ minLines
1465
+ });
1466
+ if (classJsdocNode) {
1467
+ return (0, _jsdoccomment.parseComment)(classJsdocNode, '');
1468
+ }
1469
+ return null;
1470
+ };
1471
+
1472
+ /** @type {ClassHasTag} */
1473
+ utils.classHasTag = tagName => {
1474
+ const classJsdoc = utils.getClassJsdoc();
1475
+ return classJsdoc !== null && jsdocUtils.hasTag(classJsdoc, tagName);
1476
+ };
1477
+
1478
+ /** @type {ForEachPreferredTag} */
1479
+ utils.forEachPreferredTag = (tagName, arrayHandler, skipReportingBlockedTag) => {
1480
+ return jsdocUtils.forEachPreferredTag(jsdoc, tagName, arrayHandler, {
1481
+ context,
1482
+ mode,
1483
+ report,
1484
+ skipReportingBlockedTag,
1485
+ tagNamePreference
1486
+ });
1487
+ };
1488
+
1489
+ /** @type {FindContext} */
1490
+ utils.findContext = (contexts, comment) => {
1491
+ const foundContext = contexts.find(cntxt => {
1492
+ return typeof cntxt === 'string' ? _esquery.default.matches(/** @type {Node} */node, _esquery.default.parse(cntxt), undefined, {
1493
+ visitorKeys: sourceCode.visitorKeys
1494
+ }) : (!cntxt.context || cntxt.context === 'any' || _esquery.default.matches(/** @type {Node} */node, _esquery.default.parse(cntxt.context), undefined, {
1495
+ visitorKeys: sourceCode.visitorKeys
1496
+ })) && comment === cntxt.comment;
1497
+ });
1498
+ const contextStr = typeof foundContext === 'object' ? foundContext.context ?? 'any' : String(foundContext);
1499
+ return {
1500
+ contextStr,
1501
+ foundContext
1502
+ };
1503
+ };
1504
+ return utils;
1505
+ };
1506
+
1507
+ /**
1508
+ * @typedef {{
1509
+ * [key: string]: false|string|{
1510
+ * message: string,
1511
+ * replacement?: false|string
1512
+ * skipRootChecking?: boolean
1513
+ * unifyParentAndChildTypeChecks?: boolean
1514
+ * }
1515
+ * }} PreferredTypes
1516
+ */
1517
+ /**
1518
+ * @typedef {{
1519
+ * [key: string]: {
1520
+ * name?: "text"|"name-defining"|"namepath-defining"|"namepath-referencing"|false,
1521
+ * type?: boolean|string[],
1522
+ * required?: ("name"|"type"|"typeOrNameRequired")[]
1523
+ * }
1524
+ * }} StructuredTags
1525
+ */
1526
+ /**
1527
+ * Settings from ESLint types.
1528
+ * @typedef {{
1529
+ * maxLines: Integer,
1530
+ * minLines: Integer,
1531
+ * tagNamePreference: import('./jsdocUtils.js').TagNamePreference,
1532
+ * mode: import('./jsdocUtils.js').ParserMode,
1533
+ * preferredTypes: PreferredTypes,
1534
+ * structuredTags: StructuredTags,
1535
+ * contexts?: Context[],
1536
+ * augmentsExtendsReplacesDocs?: boolean,
1537
+ * ignoreReplacesDocs?: boolean,
1538
+ * implementsReplacesDocs?: boolean,
1539
+ * overrideReplacesDocs?: boolean,
1540
+ * ignoreInternal?: boolean,
1541
+ * ignorePrivate?: boolean,
1542
+ * exemptDestructuredRootsFromChecks?: boolean,
1543
+ * skipInvokedExpressionsForCommentFinding?: boolean
1544
+ * }} Settings
1545
+ */
1546
+
1547
+ /**
1548
+ * @typedef {{
1549
+ * settings?: {
1550
+ * jsdoc?: {
1551
+ * ignorePrivate: boolean,
1552
+ * ignoreInternal: boolean,
1553
+ * maxLines: Integer,
1554
+ * minLines: Integer,
1555
+ * tagNamePreference: import('./jsdocUtils.js').TagNamePreference,
1556
+ * preferredTypes: PreferredTypes,
1557
+ * structuredTags: StructuredTags,
1558
+ * overrideReplacesDocs: boolean,
1559
+ * ignoreReplacesDocs: boolean,
1560
+ * implementsReplacesDocs: boolean,
1561
+ * augmentsExtendsReplacesDocs: boolean,
1562
+ * exemptDestructuredRootsFromChecks: boolean,
1563
+ * skipInvokedExpressionsForCommentFinding: boolean,
1564
+ * mode: import('./jsdocUtils.js').ParserMode,
1565
+ * contexts: Context[],
1566
+ * }
1567
+ * }
1568
+ * }} JSDocSettings
1569
+ */
1570
+
1571
+ /**
1572
+ * @param {import('eslint').Rule.RuleContext & JSDocSettings} context
1573
+ * @returns {Settings|false}
1574
+ */
1575
+ const getSettings = context => {
1576
+ /* eslint-disable perfectionist/sort-objects */
1577
+ const settings = {
1578
+ // All rules
1579
+ ignorePrivate: Boolean(context.settings.jsdoc?.ignorePrivate),
1580
+ ignoreInternal: Boolean(context.settings.jsdoc?.ignoreInternal),
1581
+ maxLines: Number(context.settings.jsdoc?.maxLines ?? 1),
1582
+ minLines: Number(context.settings.jsdoc?.minLines ?? 0),
1583
+ skipInvokedExpressionsForCommentFinding: Boolean(context.settings.jsdoc?.skipInvokedExpressionsForCommentFinding),
1584
+ // `check-tag-names` and many returns/param rules
1585
+ tagNamePreference: context.settings.jsdoc?.tagNamePreference ?? {},
1586
+ // `check-types` and `no-undefined-types`
1587
+ preferredTypes: context.settings.jsdoc?.preferredTypes ?? {},
1588
+ // `check-types`, `no-undefined-types`, `valid-types`
1589
+ structuredTags: context.settings.jsdoc?.structuredTags ?? {},
1590
+ // `require-param`, `require-description`, `require-example`,
1591
+ // `require-returns`, `require-throw`, `require-yields`
1592
+ overrideReplacesDocs: context.settings.jsdoc?.overrideReplacesDocs,
1593
+ ignoreReplacesDocs: context.settings.jsdoc?.ignoreReplacesDocs,
1594
+ implementsReplacesDocs: context.settings.jsdoc?.implementsReplacesDocs,
1595
+ augmentsExtendsReplacesDocs: context.settings.jsdoc?.augmentsExtendsReplacesDocs,
1596
+ // `require-param-type`, `require-param-description`
1597
+ exemptDestructuredRootsFromChecks: context.settings.jsdoc?.exemptDestructuredRootsFromChecks,
1598
+ // Many rules, e.g., `check-tag-names`
1599
+ mode: context.settings.jsdoc?.mode ?? 'typescript',
1600
+ // Many rules
1601
+ contexts: context.settings.jsdoc?.contexts
1602
+ };
1603
+ /* eslint-enable perfectionist/sort-objects */
1604
+
1605
+ jsdocUtils.setTagStructure(settings.mode);
1606
+ try {
1607
+ jsdocUtils.overrideTagStructure(settings.structuredTags);
1608
+ } catch (error) {
1609
+ context.report({
1610
+ loc: {
1611
+ end: {
1612
+ column: 1,
1613
+ line: 1
1614
+ },
1615
+ start: {
1616
+ column: 1,
1617
+ line: 1
1618
+ }
1619
+ },
1620
+ message: /** @type {Error} */error.message
1621
+ });
1622
+ return false;
1623
+ }
1624
+ return settings;
1625
+ };
1626
+
1627
+ /**
1628
+ * Create the report function
1629
+ * @callback MakeReport
1630
+ * @param {import('eslint').Rule.RuleContext} context
1631
+ * @param {import('estree').Node} commentNode
1632
+ * @returns {Report}
1633
+ */
1634
+
1635
+ /** @type {MakeReport} */
1636
+ exports.getSettings = getSettings;
1637
+ const makeReport = (context, commentNode) => {
1638
+ /** @type {Report} */
1639
+ const report = (message, fix = null, jsdocLoc = null, data = undefined) => {
1640
+ let loc;
1641
+ if (jsdocLoc) {
1642
+ if (!('line' in jsdocLoc)) {
1643
+ jsdocLoc.line = /** @type {import('comment-parser').Spec & {line?: Integer}} */jsdocLoc.source[0].number;
1644
+ }
1645
+ const lineNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.line + (/** @type {Integer} */jsdocLoc.line);
1646
+ loc = {
1647
+ end: {
1648
+ column: 0,
1649
+ line: lineNumber
1650
+ },
1651
+ start: {
1652
+ column: 0,
1653
+ line: lineNumber
1654
+ }
1655
+ };
1656
+ if ('column' in jsdocLoc && typeof jsdocLoc.column === 'number') {
1657
+ const colNumber = /** @type {import('eslint').AST.SourceLocation} */commentNode.loc.start.column + jsdocLoc.column;
1658
+ loc.end.column = colNumber;
1659
+ loc.start.column = colNumber;
1660
+ }
1661
+ }
1662
+ context.report({
1663
+ data,
1664
+ fix,
1665
+ loc,
1666
+ message,
1667
+ node: commentNode
1668
+ });
1669
+ };
1670
+ return report;
1671
+ };
1672
+
1673
+ /**
1674
+ * @typedef {(
1675
+ * arg: {
1676
+ * context: import('eslint').Rule.RuleContext,
1677
+ * sourceCode: import('eslint').SourceCode,
1678
+ * indent?: string,
1679
+ * info?: {
1680
+ * comment?: string|undefined,
1681
+ * lastIndex?: Integer|undefined
1682
+ * },
1683
+ * state?: StateObject,
1684
+ * globalState?: Map<string, Map<string, string>>,
1685
+ * jsdoc?: JsdocBlockWithInline,
1686
+ * jsdocNode?: import('eslint').Rule.Node & {
1687
+ * range: [number, number]
1688
+ * },
1689
+ * node?: Node,
1690
+ * allComments?: import('estree').Node[]
1691
+ * report?: Report,
1692
+ * makeReport?: MakeReport,
1693
+ * settings: Settings,
1694
+ * utils: BasicUtils,
1695
+ * }
1696
+ * ) => void } JsdocVisitorBasic
1697
+ */
1698
+ /**
1699
+ * @typedef {(
1700
+ * arg: {
1701
+ * context: import('eslint').Rule.RuleContext,
1702
+ * sourceCode: import('eslint').SourceCode,
1703
+ * indent: string,
1704
+ * info: {
1705
+ * comment?: string|undefined,
1706
+ * lastIndex?: Integer|undefined
1707
+ * },
1708
+ * state: StateObject,
1709
+ * globalState: Map<string, Map<string, string>>,
1710
+ * jsdoc: JsdocBlockWithInline,
1711
+ * jsdocNode: import('eslint').Rule.Node & {
1712
+ * range: [number, number]
1713
+ * },
1714
+ * node: Node|null,
1715
+ * allComments?: import('estree').Node[]
1716
+ * report: Report,
1717
+ * makeReport?: MakeReport,
1718
+ * settings: Settings,
1719
+ * utils: Utils,
1720
+ * }
1721
+ * ) => void } JsdocVisitor
1722
+ */
1723
+
1724
+ /**
1725
+ * @param {{
1726
+ * comment?: string,
1727
+ * lastIndex?: Integer,
1728
+ * selector?: string,
1729
+ * isFunctionContext?: boolean,
1730
+ * }} info
1731
+ * @param {string} indent
1732
+ * @param {JsdocBlockWithInline} jsdoc
1733
+ * @param {RuleConfig} ruleConfig
1734
+ * @param {import('eslint').Rule.RuleContext} context
1735
+ * @param {import('@es-joy/jsdoccomment').Token} jsdocNode
1736
+ * @param {Node|null} node
1737
+ * @param {Settings} settings
1738
+ * @param {import('eslint').SourceCode} sourceCode
1739
+ * @param {JsdocVisitor} iterator
1740
+ * @param {StateObject} state
1741
+ * @param {boolean} [iteratingAll]
1742
+ * @returns {void}
1743
+ */
1744
+ const iterate = (info, indent, jsdoc, ruleConfig, context, jsdocNode, node, settings, sourceCode, iterator, state, iteratingAll) => {
1745
+ const jsdocNde = /** @type {unknown} */jsdocNode;
1746
+ const report = makeReport(context, /** @type {import('estree').Node} */
1747
+ jsdocNde);
1748
+ const utils = getUtils(node, jsdoc, /** @type {import('eslint').AST.Token} */
1749
+ jsdocNode, settings, report, context, sourceCode, iteratingAll, ruleConfig, indent);
1750
+ if (!ruleConfig.checkInternal && settings.ignoreInternal && utils.hasTag('internal')) {
1751
+ return;
1752
+ }
1753
+ if (!ruleConfig.checkPrivate && settings.ignorePrivate && (utils.hasTag('private') || jsdocUtils.filterTags(jsdoc, ({
1754
+ tag
1755
+ }) => {
1756
+ return tag === 'access';
1757
+ }).some(({
1758
+ description
1759
+ }) => {
1760
+ return description === 'private';
1761
+ }))) {
1762
+ return;
1763
+ }
1764
+ iterator({
1765
+ context,
1766
+ globalState,
1767
+ indent,
1768
+ info,
1769
+ jsdoc,
1770
+ jsdocNode: (
1771
+ /**
1772
+ * @type {import('eslint').Rule.Node & {
1773
+ * range: [number, number];}}
1774
+ */
1775
+ jsdocNde),
1776
+ node,
1777
+ report,
1778
+ settings,
1779
+ sourceCode,
1780
+ state,
1781
+ utils
1782
+ });
1783
+ };
1784
+
1785
+ /**
1786
+ * @param {string[]} lines
1787
+ * @param {import('estree').Comment} jsdocNode
1788
+ * @returns {[indent: string, jsdoc: JsdocBlockWithInline]}
1789
+ */
1790
+ const getIndentAndJSDoc = function (lines, jsdocNode) {
1791
+ const sourceLine = lines[/** @type {import('estree').SourceLocation} */
1792
+ jsdocNode.loc.start.line - 1];
1793
+ let indentChar = sourceLine.charAt(0);
1794
+ if (indentChar !== ' ' && indentChar !== '\t') {
1795
+ indentChar = ' ';
1796
+ }
1797
+ const indnt = indentChar.repeat(/** @type {import('estree').SourceLocation} */
1798
+ jsdocNode.loc.start.column);
1799
+ const jsdc = (0, _jsdoccomment.parseComment)(jsdocNode, '');
1800
+ return [indnt, jsdc];
1801
+ };
1802
+
1803
+ /**
1804
+ *
1805
+ * @typedef {{node: Node, state: StateObject}} NonCommentArgs
1806
+ */
1807
+
1808
+ /**
1809
+ * @typedef {object} RuleConfig
1810
+ * @property {EslintRuleMeta} meta ESLint rule meta
1811
+ * @property {import('./jsdocUtils.js').DefaultContexts} [contextDefaults] Any default contexts
1812
+ * @property {true} [contextSelected] Whether to force a `contexts` check
1813
+ * @property {(context: import('eslint').Rule.RuleContext) => import('eslint').Rule.RuleContext} [modifyContext] Modify the rule's context object
1814
+ * @property {true} [iterateAllJsdocs] Whether to iterate all JSDoc blocks by default
1815
+ * regardless of context
1816
+ * @property {true} [checkPrivate] Whether to check `@private` blocks (normally exempted)
1817
+ * @property {true} [checkInternal] Whether to check `@internal` blocks (normally exempted)
1818
+ * @property {true} [checkFile] Whether to iterates over all JSDoc blocks regardless of attachment
1819
+ * @property {true} [nonGlobalSettings] Whether to avoid relying on settings for global contexts
1820
+ * @property {true} [noTracking] Whether to disable the tracking of visited comment nodes (as
1821
+ * non-tracked may conduct further actions)
1822
+ * @property {true} [matchContext] Whether the rule expects contexts to be based on a match option
1823
+ * @property {(args: {
1824
+ * context: import('eslint').Rule.RuleContext,
1825
+ * state: StateObject,
1826
+ * settings: Settings,
1827
+ * utils: BasicUtils
1828
+ * }) => void} [exit] Handler to be executed upon exiting iteration of program AST
1829
+ * @property {(nca: NonCommentArgs) => void} [nonComment] Handler to be executed if rule wishes
1830
+ * to be supplied nodes without comments
1831
+ */
1832
+
1833
+ /**
1834
+ * Create an eslint rule that iterates over all JSDocs, regardless of whether
1835
+ * they are attached to a function-like node.
1836
+ * @param {JsdocVisitor} iterator
1837
+ * @param {RuleConfig} ruleConfig The rule's configuration
1838
+ * @param {ContextObject[]|null} [contexts] The `contexts` containing relevant `comment` info.
1839
+ * @param {boolean} [additiveCommentContexts] If true, will have a separate
1840
+ * iteration for each matching comment context. Otherwise, will iterate
1841
+ * once if there is a single matching comment context.
1842
+ * @returns {import('eslint').Rule.RuleModule}
1843
+ */
1844
+ const iterateAllJsdocs = (iterator, ruleConfig, contexts, additiveCommentContexts) => {
1845
+ const trackedJsdocs = new Set();
1846
+
1847
+ /** @type {import('@es-joy/jsdoccomment').CommentHandler} */
1848
+ let handler;
1849
+
1850
+ /** @type {Settings|false} */
1851
+ let settings;
1852
+
1853
+ /**
1854
+ * @param {import('eslint').Rule.RuleContext} context
1855
+ * @param {Node|null} node
1856
+ * @param {import('estree').Comment[]} jsdocNodes
1857
+ * @param {StateObject} state
1858
+ * @param {boolean} [lastCall]
1859
+ * @returns {void}
1860
+ */
1861
+ const callIterator = (context, node, jsdocNodes, state, lastCall) => {
1862
+ /* c8 ignore next -- Fallback to deprecated method */
1863
+ const {
1864
+ // @ts-expect-error ESLint < 10
1865
+ sourceCode = context.getSourceCode()
1866
+ } = context;
1867
+ const {
1868
+ lines
1869
+ } = sourceCode;
1870
+ const utils = getBasicUtils(context, /** @type {Settings} */settings);
1871
+ for (const jsdocNode of jsdocNodes) {
1872
+ const jsdocNde = /** @type {unknown} */jsdocNode;
1873
+ if (!/^\/\*\*\s/v.test(sourceCode.getText(/** @type {import('estree').Node} */
1874
+ jsdocNde))) {
1875
+ continue;
1876
+ }
1877
+ const [indent, jsdoc] = getIndentAndJSDoc(lines, jsdocNode);
1878
+ if (additiveCommentContexts) {
1879
+ for (const [idx, {
1880
+ comment
1881
+ }] of /** @type {ContextObject[]} */contexts.entries()) {
1882
+ if (comment && handler(comment, jsdoc) === false) {
1883
+ continue;
1884
+ }
1885
+ iterate({
1886
+ comment,
1887
+ lastIndex: idx,
1888
+ selector: node?.type
1889
+ }, indent, jsdoc, ruleConfig, context, jsdocNode, /** @type {Node} */
1890
+ node, /** @type {Settings} */
1891
+ settings, sourceCode, iterator, state, true);
1892
+ }
1893
+ continue;
1894
+ }
1895
+ let lastComment;
1896
+ let lastIndex;
1897
+ // eslint-disable-next-line no-loop-func
1898
+ if (contexts && contexts.every(({
1899
+ comment
1900
+ }, idx) => {
1901
+ lastComment = comment;
1902
+ lastIndex = idx;
1903
+ return comment && handler(comment, jsdoc) === false;
1904
+ })) {
1905
+ continue;
1906
+ }
1907
+ iterate(lastComment ? {
1908
+ comment: lastComment,
1909
+ lastIndex,
1910
+ selector: node?.type
1911
+ } : {
1912
+ lastIndex,
1913
+ selector: node?.type
1914
+ }, indent, jsdoc, ruleConfig, context, jsdocNode, node, /** @type {Settings} */
1915
+ settings, sourceCode, iterator, state, true);
1916
+ }
1917
+ const settngs = /** @type {Settings} */settings;
1918
+ if (lastCall && ruleConfig.exit) {
1919
+ ruleConfig.exit({
1920
+ context,
1921
+ settings: settngs,
1922
+ state,
1923
+ utils
1924
+ });
1925
+ }
1926
+ };
1927
+ return {
1928
+ create(context) {
1929
+ /* c8 ignore next -- Fallback to deprecated method */
1930
+ const {
1931
+ // @ts-expect-error ESLint < 10
1932
+ sourceCode = context.getSourceCode()
1933
+ } = context;
1934
+ settings = getSettings(context);
1935
+ if (!settings) {
1936
+ return {};
1937
+ }
1938
+ if (contexts) {
1939
+ handler = (0, _jsdoccomment.commentHandler)({
1940
+ ...settings,
1941
+ mode: settings.mode === 'permissive' ? 'typescript' : settings.mode
1942
+ });
1943
+ }
1944
+ const state = {};
1945
+ return {
1946
+ /**
1947
+ * @param {import('eslint').Rule.Node} node
1948
+ * @returns {void}
1949
+ */
1950
+ '*:not(Program)'(node) {
1951
+ const commentNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, /** @type {Settings} */settings);
1952
+ if (!ruleConfig.noTracking && trackedJsdocs.has(commentNode)) {
1953
+ return;
1954
+ }
1955
+ if (!commentNode) {
1956
+ if (ruleConfig.nonComment) {
1957
+ const ste = /** @type {StateObject} */state;
1958
+ ruleConfig.nonComment({
1959
+ node,
1960
+ state: ste
1961
+ });
1962
+ }
1963
+ return;
1964
+ }
1965
+ trackedJsdocs.add(commentNode);
1966
+ callIterator(context, node, [(/** @type {import('estree').Comment} */
1967
+ commentNode)], /** @type {StateObject} */state);
1968
+ },
1969
+ 'Program:exit'() {
1970
+ const allComments = /** @type {import('estree').Comment[]} */
1971
+ sourceCode.getAllComments();
1972
+ const untrackedJSdoc = allComments.filter(node => {
1973
+ return !trackedJsdocs.has(node);
1974
+ });
1975
+ callIterator(context, null, untrackedJSdoc, /** @type {StateObject} */
1976
+ state, true);
1977
+ }
1978
+ };
1979
+ },
1980
+ meta: ruleConfig.meta
1981
+ };
1982
+ };
1983
+
1984
+ /**
1985
+ * Create an eslint rule that iterates over all JSDocs, regardless of whether
1986
+ * they are attached to a function-like node.
1987
+ * @param {JsdocVisitorBasic} iterator
1988
+ * @param {RuleConfig} ruleConfig
1989
+ * @returns {import('eslint').Rule.RuleModule}
1990
+ */
1991
+ const checkFile = (iterator, ruleConfig) => {
1992
+ return {
1993
+ create(context) {
1994
+ /* c8 ignore next -- Fallback to deprecated method */
1995
+ const {
1996
+ // @ts-expect-error ESLint < 10
1997
+ sourceCode = context.getSourceCode()
1998
+ } = context;
1999
+ const settings = getSettings(context);
2000
+ if (!settings) {
2001
+ return {};
2002
+ }
2003
+ return {
2004
+ 'Program:exit'() {
2005
+ const allComms = /** @type {unknown} */sourceCode.getAllComments();
2006
+ const utils = getBasicUtils(context, settings);
2007
+ iterator({
2008
+ allComments: (/** @type {import('estree').Node[]} */allComms),
2009
+ context,
2010
+ makeReport,
2011
+ settings,
2012
+ sourceCode,
2013
+ utils
2014
+ });
2015
+ }
2016
+ };
2017
+ },
2018
+ meta: ruleConfig.meta
2019
+ };
2020
+ };
2021
+ /**
2022
+ * @param {JsdocVisitor} iterator
2023
+ * @param {RuleConfig} ruleConfig
2024
+ * @returns {import('eslint').Rule.RuleModule}
2025
+ */
2026
+ function iterateJsdoc(iterator, ruleConfig) {
2027
+ const metaType = ruleConfig?.meta?.type;
2028
+ if (!metaType || !['layout', 'problem', 'suggestion'].includes(metaType)) {
2029
+ throw new TypeError('Rule must include `meta.type` option (with value "problem", "suggestion", or "layout")');
2030
+ }
2031
+ if (typeof iterator !== 'function') {
2032
+ throw new TypeError('The iterator argument must be a function.');
2033
+ }
2034
+ if (ruleConfig.checkFile) {
2035
+ return checkFile(/** @type {JsdocVisitorBasic} */iterator, ruleConfig);
2036
+ }
2037
+ if (ruleConfig.iterateAllJsdocs) {
2038
+ return iterateAllJsdocs(iterator, ruleConfig);
2039
+ }
2040
+
2041
+ /** @type {import('eslint').Rule.RuleModule} */
2042
+ return {
2043
+ /**
2044
+ * The entrypoint for the JSDoc rule.
2045
+ * @param {import('eslint').Rule.RuleContext} ctx
2046
+ * a reference to the context which hold all important information
2047
+ * like settings and the sourcecode to check.
2048
+ * @returns {import('eslint').Rule.RuleListener}
2049
+ * a listener with parser callback function.
2050
+ */
2051
+ create(ctx) {
2052
+ const context = ruleConfig.modifyContext ? ruleConfig.modifyContext(ctx) : ctx;
2053
+ const settings = getSettings(context);
2054
+ if (!settings) {
2055
+ return {};
2056
+ }
2057
+
2058
+ /**
2059
+ * @type {Context[]|undefined}
2060
+ */
2061
+ let contexts;
2062
+ if (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext) {
2063
+ contexts = ruleConfig.matchContext && context.options[0]?.match ? context.options[0].match : jsdocUtils.enforcedContexts(context, ruleConfig.contextDefaults, ruleConfig.nonGlobalSettings ? {} : settings);
2064
+ if (contexts) {
2065
+ contexts = contexts.map(obj => {
2066
+ if (typeof obj === 'object' && !obj.context) {
2067
+ return {
2068
+ ...obj,
2069
+ context: 'any'
2070
+ };
2071
+ }
2072
+ return obj;
2073
+ });
2074
+ }
2075
+ const hasPlainAny = contexts?.includes('any');
2076
+ const hasObjectAny = !hasPlainAny && contexts?.find(ctxt => {
2077
+ if (typeof ctxt === 'string') {
2078
+ return false;
2079
+ }
2080
+ return ctxt?.context === 'any';
2081
+ });
2082
+ if (hasPlainAny || hasObjectAny) {
2083
+ return iterateAllJsdocs(iterator, ruleConfig, hasObjectAny ? (/** @type {ContextObject[]} */contexts) : null, ruleConfig.matchContext).create(context);
2084
+ }
2085
+ }
2086
+
2087
+ /* c8 ignore next -- Fallback to deprecated method */
2088
+ const {
2089
+ // @ts-expect-error ESLint < 10
2090
+ sourceCode = context.getSourceCode()
2091
+ } = context;
2092
+ const {
2093
+ lines
2094
+ } = sourceCode;
2095
+
2096
+ /** @type {Partial<StateObject>} */
2097
+ const state = {};
2098
+
2099
+ /** @type {CheckJsdoc} */
2100
+ const checkJsdoc = (info, handler, node) => {
2101
+ const jsdocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings);
2102
+ if (!jsdocNode) {
2103
+ return;
2104
+ }
2105
+ const [indent, jsdoc] = getIndentAndJSDoc(lines, /** @type {import('estree').Comment} */
2106
+ jsdocNode);
2107
+ if (
2108
+ // Note, `handler` should already be bound in its first argument
2109
+ // with these only to be called after the value of
2110
+ // `comment`
2111
+ handler && handler(jsdoc) === false) {
2112
+ return;
2113
+ }
2114
+ iterate(info, indent, jsdoc, ruleConfig, context, jsdocNode, node, settings, sourceCode, iterator, /** @type {StateObject} */
2115
+ state);
2116
+ };
2117
+
2118
+ /** @type {import('eslint').Rule.RuleListener} */
2119
+ let contextObject = {};
2120
+ if (contexts && (ruleConfig.contextDefaults || ruleConfig.contextSelected || ruleConfig.matchContext)) {
2121
+ contextObject = jsdocUtils.getContextObject(contexts, checkJsdoc, (0, _jsdoccomment.commentHandler)({
2122
+ ...settings,
2123
+ mode: settings.mode === 'permissive' ? 'typescript' : settings.mode
2124
+ }));
2125
+ } else {
2126
+ for (const prop of ['ArrowFunctionExpression', 'FunctionDeclaration', 'FunctionExpression', 'TSDeclareFunction']) {
2127
+ contextObject[prop] = checkJsdoc.bind(null, {
2128
+ selector: prop
2129
+ }, null);
2130
+ }
2131
+ }
2132
+ if (typeof ruleConfig.exit === 'function') {
2133
+ contextObject['Program:exit'] = () => {
2134
+ const ste = /** @type {StateObject} */state;
2135
+
2136
+ // @ts-expect-error `utils` not needed at this point
2137
+ /** @type {Required<RuleConfig>} */
2138
+ ruleConfig.exit({
2139
+ context,
2140
+ settings,
2141
+ state: ste
2142
+ });
2143
+ };
2144
+ }
2145
+ return contextObject;
2146
+ },
2147
+ meta: ruleConfig.meta
2148
+ };
2149
+ }
2150
+ //# sourceMappingURL=iterateJsdoc.cjs.map