@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,690 @@
1
+ import iterateJsdoc from '../iterateJsdoc.js';
2
+ import {
3
+ rewireByParsedType,
4
+ } from '../jsdocUtils.js';
5
+ import {
6
+ parse as parseType,
7
+ stringify,
8
+ traverse,
9
+ tryParse as tryParseType,
10
+ } from '@es-joy/jsdoccomment';
11
+
12
+ const digitRegex = (/^(\d+(\.\d*)?|\.\d+)([eE][\-+]?\d+)?$/v);
13
+
14
+ export default iterateJsdoc(({
15
+ context,
16
+ indent,
17
+ jsdoc,
18
+ settings,
19
+ utils,
20
+ // eslint-disable-next-line complexity -- Todo
21
+ }) => {
22
+ const {
23
+ arrayBrackets = 'square',
24
+ arrowFunctionPostReturnMarkerSpacing = ' ',
25
+ arrowFunctionPreReturnMarkerSpacing = ' ',
26
+ enableFixer = true,
27
+ functionOrClassParameterSpacing = ' ',
28
+ functionOrClassPostGenericSpacing = '',
29
+ functionOrClassPostReturnMarkerSpacing = ' ',
30
+ functionOrClassPreReturnMarkerSpacing = '',
31
+ functionOrClassTypeParameterSpacing = ' ',
32
+ genericAndTupleElementSpacing = ' ',
33
+ genericDot = false,
34
+ keyValuePostColonSpacing = ' ',
35
+ keyValuePostKeySpacing = '',
36
+ keyValuePostOptionalSpacing = '',
37
+ keyValuePostVariadicSpacing = '',
38
+ methodQuotes = 'double',
39
+ objectFieldIndent = '',
40
+ objectFieldQuote = null,
41
+ objectFieldSeparator = 'comma',
42
+ objectFieldSeparatorOptionalLinebreak = true,
43
+ objectFieldSeparatorTrailingPunctuation = false,
44
+ objectTypeBracketSpacing = '',
45
+ parameterDefaultValueSpacing = ' ',
46
+ postMethodNameSpacing = '',
47
+ postNewSpacing = ' ',
48
+ // propertyQuotes = null,
49
+ separatorForSingleObjectField = false,
50
+ stringQuotes = 'double',
51
+ trailingPunctuationMultilineOnly = false,
52
+ typeBracketSpacing = '',
53
+ unionSpacing = ' ',
54
+ } = context.options[0] || {};
55
+
56
+ const {
57
+ mode,
58
+ } = settings;
59
+
60
+ /**
61
+ * @param {import('@es-joy/jsdoccomment').JsdocTagWithInline} tag
62
+ */
63
+ const checkTypeFormats = (tag) => {
64
+ const potentialType = tag.type;
65
+ let parsedType;
66
+ try {
67
+ parsedType = mode === 'permissive' ?
68
+ tryParseType(/** @type {string} */ (potentialType)) :
69
+ parseType(/** @type {string} */ (potentialType), mode);
70
+ } catch {
71
+ return;
72
+ }
73
+
74
+ const fix = () => {
75
+ rewireByParsedType(jsdoc, tag, parsedType, indent, typeBracketSpacing);
76
+ };
77
+
78
+ /** @type {string[]} */
79
+ const errorMessages = [];
80
+
81
+ if (typeBracketSpacing && (!tag.type.startsWith(typeBracketSpacing) || !tag.type.endsWith(typeBracketSpacing))) {
82
+ errorMessages.push(`Must have initial and final "${typeBracketSpacing}" spacing`);
83
+ } else if (!typeBracketSpacing && ((/^\s/v).test(tag.type) || (/\s$/v).test(tag.type))) {
84
+ errorMessages.push('Must have no initial spacing');
85
+ }
86
+
87
+ // eslint-disable-next-line complexity -- Todo
88
+ traverse(parsedType, (nde) => {
89
+ let errorMessage = '';
90
+
91
+ /**
92
+ * @param {Partial<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
93
+ * postNewSpacing?: string,
94
+ * postMethodNameSpacing?: string
95
+ * }} meta
96
+ * @returns {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
97
+ * postNewSpacing?: string,
98
+ * postMethodNameSpacing?: string
99
+ * }}
100
+ */
101
+ const conditionalAdds = (meta) => {
102
+ const typNode =
103
+ /**
104
+ * @type {import('jsdoc-type-pratt-parser').FunctionResult|
105
+ * import('jsdoc-type-pratt-parser').CallSignatureResult|
106
+ * import('jsdoc-type-pratt-parser').ComputedMethodResult|
107
+ * import('jsdoc-type-pratt-parser').ConstructorSignatureResult|
108
+ * import('jsdoc-type-pratt-parser').MethodSignatureResult
109
+ * }
110
+ */ (nde);
111
+
112
+ /**
113
+ * @type {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
114
+ * postNewSpacing?: string,
115
+ * postMethodNameSpacing?: string
116
+ * }}
117
+ */
118
+ const newMeta = {
119
+ parameterSpacing: meta.parameterSpacing ?? typNode.meta?.parameterSpacing ?? ' ',
120
+ postGenericSpacing: meta.postGenericSpacing ?? typNode.meta?.postGenericSpacing ?? '',
121
+ postReturnMarkerSpacing: meta.postReturnMarkerSpacing ?? typNode.meta?.postReturnMarkerSpacing ?? ' ',
122
+ preReturnMarkerSpacing: meta.preReturnMarkerSpacing ?? typNode.meta?.preReturnMarkerSpacing ?? '',
123
+ typeParameterSpacing: meta.typeParameterSpacing ?? typNode.meta?.typeParameterSpacing ?? ' ',
124
+ };
125
+
126
+ if (typNode.type === 'JsdocTypeConstructorSignature') {
127
+ newMeta.postNewSpacing = meta.postNewSpacing;
128
+ }
129
+
130
+ if (typNode.type === 'JsdocTypeMethodSignature') {
131
+ newMeta.postMethodNameSpacing = meta.postMethodNameSpacing ?? typNode.meta?.postMethodNameSpacing ?? '';
132
+ }
133
+
134
+ return newMeta;
135
+ };
136
+
137
+ switch (nde.type) {
138
+ case 'JsdocTypeConstructorSignature': {
139
+ const typeNode = /** @type {import('jsdoc-type-pratt-parser').ConstructorSignatureResult} */ (nde);
140
+ /* c8 ignore next -- Guard */
141
+ if ((typeNode.meta?.postNewSpacing ?? ' ') !== postNewSpacing) {
142
+ typeNode.meta =
143
+ /**
144
+ * @type {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
145
+ * postNewSpacing: string,
146
+ * }}
147
+ */ (conditionalAdds({
148
+ postNewSpacing,
149
+ }));
150
+ errorMessage = `Post-\`new\` spacing should be "${postNewSpacing}"`;
151
+ break;
152
+ }
153
+ }
154
+
155
+ case 'JsdocTypeFunction': {
156
+ const typeNode =
157
+ /**
158
+ * @type {import('jsdoc-type-pratt-parser').FunctionResult}
159
+ */ nde;
160
+ if ('arrow' in typeNode && typeNode.arrow) {
161
+ /* c8 ignore next -- Guard */
162
+ if ((typeNode.meta?.postReturnMarkerSpacing ?? ' ') !== arrowFunctionPostReturnMarkerSpacing) {
163
+ typeNode.meta =
164
+ /**
165
+ * @type {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
166
+ * postNewSpacing: string,
167
+ * }}
168
+ */ (conditionalAdds({
169
+ postReturnMarkerSpacing: arrowFunctionPostReturnMarkerSpacing,
170
+ /* c8 ignore next -- Guard */
171
+ preReturnMarkerSpacing: typeNode.meta?.preReturnMarkerSpacing ?? ' ',
172
+ }));
173
+ errorMessage = `Post-return-marker spacing should be "${arrowFunctionPostReturnMarkerSpacing}"`;
174
+ break;
175
+ /* c8 ignore next -- Guard */
176
+ } else if ((typeNode.meta?.preReturnMarkerSpacing ?? ' ') !== arrowFunctionPreReturnMarkerSpacing) {
177
+ typeNode.meta =
178
+ /**
179
+ * @type {Required<import('jsdoc-type-pratt-parser').FunctionResult['meta']> & {
180
+ * postNewSpacing: string,
181
+ * }}
182
+ */ (conditionalAdds({
183
+ /* c8 ignore next -- Guard */
184
+ postReturnMarkerSpacing: typeNode.meta?.postReturnMarkerSpacing ?? ' ',
185
+ preReturnMarkerSpacing: arrowFunctionPreReturnMarkerSpacing,
186
+ }));
187
+ errorMessage = `Pre-return-marker spacing should be "${arrowFunctionPreReturnMarkerSpacing}"`;
188
+ break;
189
+ }
190
+
191
+ break;
192
+ }
193
+ }
194
+
195
+ case 'JsdocTypeCallSignature':
196
+ case 'JsdocTypeComputedMethod':
197
+ case 'JsdocTypeMethodSignature': {
198
+ const typeNode =
199
+ /**
200
+ * @type {import('jsdoc-type-pratt-parser').FunctionResult|
201
+ * import('jsdoc-type-pratt-parser').CallSignatureResult|
202
+ * import('jsdoc-type-pratt-parser').ComputedMethodResult|
203
+ * import('jsdoc-type-pratt-parser').ConstructorSignatureResult|
204
+ * import('jsdoc-type-pratt-parser').MethodSignatureResult
205
+ * }
206
+ */ (nde);
207
+ if (typeNode.type === 'JsdocTypeMethodSignature' &&
208
+ (typeNode.meta?.postMethodNameSpacing ?? '') !== postMethodNameSpacing
209
+ ) {
210
+ typeNode.meta = {
211
+ quote: typeNode.meta.quote,
212
+ ...conditionalAdds({
213
+ postMethodNameSpacing,
214
+ }),
215
+ };
216
+ errorMessage = `Post-method-name spacing should be "${postMethodNameSpacing}"`;
217
+ break;
218
+ } else if (typeNode.type === 'JsdocTypeMethodSignature' &&
219
+ typeNode.meta.quote !== undefined &&
220
+ typeNode.meta.quote !== methodQuotes
221
+ ) {
222
+ typeNode.meta = {
223
+ ...conditionalAdds({
224
+ postMethodNameSpacing: typeNode.meta.postMethodNameSpacing ?? '',
225
+ }),
226
+ quote: methodQuotes,
227
+ };
228
+ errorMessage = `Method quoting style should be "${methodQuotes}"`;
229
+ break;
230
+ }
231
+
232
+ if ((typeNode.meta?.parameterSpacing ?? ' ') !== functionOrClassParameterSpacing) {
233
+ typeNode.meta = conditionalAdds({
234
+ parameterSpacing: functionOrClassParameterSpacing,
235
+ });
236
+ errorMessage = `Parameter spacing should be "${functionOrClassParameterSpacing}"`;
237
+ } else if ((typeNode.meta?.postGenericSpacing ?? '') !== functionOrClassPostGenericSpacing) {
238
+ typeNode.meta = conditionalAdds({
239
+ postGenericSpacing: functionOrClassPostGenericSpacing,
240
+ });
241
+ errorMessage = `Post-generic spacing should be "${functionOrClassPostGenericSpacing}"`;
242
+ } else if ((typeNode.meta?.postReturnMarkerSpacing ?? ' ') !== functionOrClassPostReturnMarkerSpacing) {
243
+ typeNode.meta = conditionalAdds({
244
+ postReturnMarkerSpacing: functionOrClassPostReturnMarkerSpacing,
245
+ });
246
+ errorMessage = `Post-return-marker spacing should be "${functionOrClassPostReturnMarkerSpacing}"`;
247
+ } else if ((typeNode.meta?.preReturnMarkerSpacing ?? '') !== functionOrClassPreReturnMarkerSpacing) {
248
+ typeNode.meta = conditionalAdds({
249
+ preReturnMarkerSpacing: functionOrClassPreReturnMarkerSpacing,
250
+ });
251
+ errorMessage = `Pre-return-marker spacing should be "${functionOrClassPreReturnMarkerSpacing}"`;
252
+ } else if ((typeNode.meta?.typeParameterSpacing ?? ' ') !== functionOrClassTypeParameterSpacing) {
253
+ typeNode.meta = conditionalAdds({
254
+ typeParameterSpacing: functionOrClassTypeParameterSpacing,
255
+ });
256
+ errorMessage = `Type parameter spacing should be "${functionOrClassTypeParameterSpacing}"`;
257
+ }
258
+
259
+ break;
260
+ }
261
+
262
+ case 'JsdocTypeGeneric': {
263
+ const typeNode = /** @type {import('jsdoc-type-pratt-parser').GenericResult} */ (nde);
264
+ if ('value' in typeNode.left && typeNode.left.value === 'Array') {
265
+ if (typeNode.meta.brackets !== arrayBrackets) {
266
+ typeNode.meta.brackets = arrayBrackets;
267
+ errorMessage = `Array bracket style should be ${arrayBrackets}`;
268
+ }
269
+ } else if (typeNode.meta.dot !== genericDot) {
270
+ typeNode.meta.dot = genericDot;
271
+ errorMessage = `Dot usage should be ${genericDot}`;
272
+ } else if ((typeNode.meta.elementSpacing ?? ' ') !== genericAndTupleElementSpacing) {
273
+ typeNode.meta.elementSpacing = genericAndTupleElementSpacing;
274
+ errorMessage = `Element spacing should be "${genericAndTupleElementSpacing}"`;
275
+ }
276
+
277
+ break;
278
+ }
279
+
280
+ case 'JsdocTypeKeyValue': {
281
+ const typeNode = /** @type {import('jsdoc-type-pratt-parser').KeyValueResult} */ (nde);
282
+ /* c8 ignore next -- Guard */
283
+ if ((typeNode.meta?.postKeySpacing ?? '') !== keyValuePostKeySpacing) {
284
+ typeNode.meta = {
285
+ /* c8 ignore next -- Guard */
286
+ postColonSpacing: typeNode.meta?.postColonSpacing ?? ' ',
287
+ postKeySpacing: keyValuePostKeySpacing,
288
+ /* c8 ignore next 2 -- Guard */
289
+ postOptionalSpacing: typeNode.meta?.postOptionalSpacing ?? '',
290
+ postVariadicSpacing: typeNode.meta?.postVariadicSpacing ?? '',
291
+ };
292
+ errorMessage = `Post key spacing should be "${keyValuePostKeySpacing}"`;
293
+ /* c8 ignore next -- Guard */
294
+ } else if ((typeNode.meta?.postColonSpacing ?? ' ') !== keyValuePostColonSpacing) {
295
+ typeNode.meta = {
296
+ postColonSpacing: keyValuePostColonSpacing,
297
+ /* c8 ignore next 3 -- Guard */
298
+ postKeySpacing: typeNode.meta?.postKeySpacing ?? '',
299
+ postOptionalSpacing: typeNode.meta?.postOptionalSpacing ?? '',
300
+ postVariadicSpacing: typeNode.meta?.postVariadicSpacing ?? '',
301
+ };
302
+ errorMessage = `Post colon spacing should be "${keyValuePostColonSpacing}"`;
303
+ /* c8 ignore next -- Guard */
304
+ } else if ((typeNode.meta?.postOptionalSpacing ?? '') !== keyValuePostOptionalSpacing) {
305
+ typeNode.meta = {
306
+ /* c8 ignore next 2 -- Guard */
307
+ postColonSpacing: typeNode.meta?.postColonSpacing ?? ' ',
308
+ postKeySpacing: typeNode.meta?.postKeySpacing ?? '',
309
+ postOptionalSpacing: keyValuePostOptionalSpacing,
310
+ /* c8 ignore next -- Guard */
311
+ postVariadicSpacing: typeNode.meta?.postVariadicSpacing ?? '',
312
+ };
313
+ errorMessage = `Post optional (\`?\`) spacing should be "${keyValuePostOptionalSpacing}"`;
314
+ /* c8 ignore next -- Guard */
315
+ } else if (typeNode.variadic && (typeNode.meta?.postVariadicSpacing ?? '') !== keyValuePostVariadicSpacing) {
316
+ typeNode.meta = {
317
+ /* c8 ignore next 3 -- Guard */
318
+ postColonSpacing: typeNode.meta?.postColonSpacing ?? ' ',
319
+ postKeySpacing: typeNode.meta?.postKeySpacing ?? '',
320
+ postOptionalSpacing: typeNode.meta?.postOptionalSpacing ?? '',
321
+ postVariadicSpacing: keyValuePostVariadicSpacing,
322
+ };
323
+ errorMessage = `Post variadic (\`...\`) spacing should be "${keyValuePostVariadicSpacing}"`;
324
+ }
325
+
326
+ break;
327
+ }
328
+
329
+ case 'JsdocTypeObject': {
330
+ const typeNode = /** @type {import('jsdoc-type-pratt-parser').ObjectResult} */ (nde);
331
+ /* c8 ignore next -- Guard */
332
+ const separator = typeNode.meta.separator ?? 'comma';
333
+
334
+ if (
335
+ (separator !== objectFieldSeparator &&
336
+ (!objectFieldSeparatorOptionalLinebreak ||
337
+ !(objectFieldSeparator.endsWith('-linebreak') &&
338
+ objectFieldSeparator.startsWith(separator)))) ||
339
+ (typeNode.meta.separatorForSingleObjectField ?? false) !== separatorForSingleObjectField ||
340
+ ((typeNode.meta.propertyIndent ?? '') !== objectFieldIndent &&
341
+ separator.endsWith('-linebreak')) ||
342
+ /* c8 ignore next 5 -- jsdoc-type-pratt-parser doesn't encode as should */
343
+ ((typeNode.meta.trailingPunctuation ?? false) !== objectFieldSeparatorTrailingPunctuation &&
344
+ ((typeNode.meta.trailingPunctuation && (!trailingPunctuationMultilineOnly ||
345
+ !stringify(typeNode).includes('\n'))) ||
346
+ (!typeNode.meta.trailingPunctuation && (!trailingPunctuationMultilineOnly ||
347
+ stringify(typeNode).includes('\n')))))
348
+ ) {
349
+ typeNode.meta.separator = objectFieldSeparatorOptionalLinebreak && !separator.endsWith('and-linebreak') ?
350
+ objectFieldSeparator.replace(/-and-linebreak$/v, '') :
351
+ objectFieldSeparator;
352
+ typeNode.meta.separatorForSingleObjectField = separatorForSingleObjectField;
353
+ typeNode.meta.propertyIndent = objectFieldIndent;
354
+ typeNode.meta.trailingPunctuation = objectFieldSeparatorTrailingPunctuation;
355
+ errorMessage = `Inconsistent ${objectFieldSeparator} separator usage`;
356
+ } else if ((typeNode.meta.bracketSpacing ?? '') !== objectTypeBracketSpacing) {
357
+ typeNode.meta.bracketSpacing = objectTypeBracketSpacing;
358
+ // This might not be the cause
359
+ // errorMessage = `Object type bracket spacing should be "${objectTypeBracketSpacing}"`;
360
+ }
361
+
362
+ break;
363
+ }
364
+
365
+ case 'JsdocTypeObjectField': {
366
+ const typeNode = /** @type {import('jsdoc-type-pratt-parser').ObjectFieldResult} */ (nde);
367
+ if ((objectFieldQuote ||
368
+ (typeof typeNode.key === 'string' &&
369
+ (
370
+ (/^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/v).test(typeNode.key) ||
371
+ digitRegex.test(typeNode.key)
372
+ )
373
+ )) &&
374
+ typeNode.meta.quote !== (objectFieldQuote ?? undefined) &&
375
+ (typeof typeNode.key !== 'string' ||
376
+ !digitRegex.test(typeNode.key))
377
+ ) {
378
+ typeNode.meta.quote = objectFieldQuote ?? undefined;
379
+ errorMessage = `Inconsistent object field quotes ${objectFieldQuote}`;
380
+ } else if ((typeNode.meta?.postKeySpacing ?? '') !== keyValuePostKeySpacing) {
381
+ typeNode.meta.postKeySpacing = keyValuePostKeySpacing;
382
+ errorMessage = `Post key spacing should be "${keyValuePostKeySpacing}"`;
383
+ } else if ((typeNode.meta?.postColonSpacing ?? ' ') !== keyValuePostColonSpacing) {
384
+ typeNode.meta.postColonSpacing = keyValuePostColonSpacing;
385
+ errorMessage = `Post colon spacing should be "${keyValuePostColonSpacing}"`;
386
+ } else if ((typeNode.meta?.postOptionalSpacing ?? '') !== keyValuePostOptionalSpacing) {
387
+ typeNode.meta.postOptionalSpacing = keyValuePostOptionalSpacing;
388
+ errorMessage = `Post optional (\`?\`) spacing should be "${keyValuePostOptionalSpacing}"`;
389
+ }
390
+
391
+ break;
392
+ }
393
+
394
+ case 'JsdocTypeStringValue': {
395
+ const typeNode = /** @type {import('jsdoc-type-pratt-parser').StringValueResult} */ (nde);
396
+ if (typeNode.meta.quote !== stringQuotes) {
397
+ typeNode.meta.quote = stringQuotes;
398
+ errorMessage = `Inconsistent ${stringQuotes} string quotes usage`;
399
+ }
400
+
401
+ break;
402
+ }
403
+
404
+ // Only suitable for namepaths (and would need changes); see https://github.com/gajus/eslint-plugin-jsdoc/issues/1524
405
+ // case 'JsdocTypeProperty': {
406
+ // const typeNode = /** @type {import('jsdoc-type-pratt-parser').PropertyResult} */ (nde);
407
+
408
+ // if ((propertyQuotes ||
409
+ // (typeof typeNode.value === 'string' && !(/\s/v).test(typeNode.value))) &&
410
+ // typeNode.meta.quote !== (propertyQuotes ?? undefined)
411
+ // ) {
412
+ // typeNode.meta.quote = propertyQuotes ?? undefined;
413
+ // errorMessage = `Inconsistent ${propertyQuotes} property quotes usage`;
414
+ // }
415
+
416
+ // break;
417
+ // }
418
+
419
+ case 'JsdocTypeTuple': {
420
+ const typeNode = /** @type {import('jsdoc-type-pratt-parser').TupleResult} */ (nde);
421
+ /* c8 ignore next -- Guard */
422
+ if ((typeNode.meta?.elementSpacing ?? ' ') !== genericAndTupleElementSpacing) {
423
+ typeNode.meta = {
424
+ elementSpacing: genericAndTupleElementSpacing,
425
+ };
426
+ errorMessage = `Element spacing should be "${genericAndTupleElementSpacing}"`;
427
+ }
428
+
429
+ break;
430
+ }
431
+
432
+ case 'JsdocTypeTypeParameter': {
433
+ const typeNode = /** @type {import('jsdoc-type-pratt-parser').TypeParameterResult} */ (nde);
434
+ /* c8 ignore next -- Guard */
435
+ if (typeNode.defaultValue && (typeNode.meta?.defaultValueSpacing ?? ' ') !== parameterDefaultValueSpacing) {
436
+ typeNode.meta = {
437
+ defaultValueSpacing: parameterDefaultValueSpacing,
438
+ };
439
+ errorMessage = `Default value spacing should be "${parameterDefaultValueSpacing}"`;
440
+ }
441
+
442
+ break;
443
+ }
444
+
445
+ case 'JsdocTypeUnion': {
446
+ const typeNode = /** @type {import('jsdoc-type-pratt-parser').UnionResult} */ (nde);
447
+ /* c8 ignore next -- Guard */
448
+ if ((typeNode.meta?.spacing ?? ' ') !== unionSpacing) {
449
+ typeNode.meta = {
450
+ spacing: unionSpacing,
451
+ };
452
+ errorMessage = `Inconsistent "${unionSpacing}" union spacing usage`;
453
+ }
454
+
455
+ break;
456
+ }
457
+
458
+ default:
459
+ break;
460
+ }
461
+
462
+ if (errorMessage) {
463
+ errorMessages.push(errorMessage);
464
+ }
465
+ });
466
+
467
+ const differentResult = tag.type !==
468
+ typeBracketSpacing + stringify(parsedType) + typeBracketSpacing;
469
+
470
+ if (errorMessages.length && differentResult) {
471
+ for (const errorMessage of errorMessages) {
472
+ utils.reportJSDoc(
473
+ errorMessage, tag, enableFixer ? fix : null,
474
+ );
475
+ }
476
+ // Stringification may have been equal previously (and thus no error reported)
477
+ // because the stringification doesn't preserve everything
478
+ } else if (differentResult) {
479
+ utils.reportJSDoc(
480
+ 'There was an error with type formatting', tag, enableFixer ? fix : null,
481
+ );
482
+ }
483
+ };
484
+
485
+ const tags = utils.getPresentTags([
486
+ 'param',
487
+ 'property',
488
+ 'returns',
489
+ 'this',
490
+ 'throws',
491
+ 'type',
492
+ 'typedef',
493
+ 'yields',
494
+ ]);
495
+ for (const tag of tags) {
496
+ if (tag.type) {
497
+ checkTypeFormats(tag);
498
+ }
499
+ }
500
+ }, {
501
+ iterateAllJsdocs: true,
502
+ meta: {
503
+ docs: {
504
+ description: 'Formats JSDoc type values.',
505
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/type-formatting.md#repos-sticky-header',
506
+ },
507
+ fixable: 'code',
508
+ schema: [
509
+ {
510
+ additionalProperties: false,
511
+ properties: {
512
+ arrayBrackets: {
513
+ description: 'Determines how array generics are represented. Set to `angle` for the style `Array<type>` or `square` for the style `type[]`. Defaults to "square".',
514
+ enum: [
515
+ 'angle',
516
+ 'square',
517
+ ],
518
+ type: 'string',
519
+ },
520
+ arrowFunctionPostReturnMarkerSpacing: {
521
+ description: 'The space character (if any) to use after return markers (`=>`). Defaults to " ".',
522
+ type: 'string',
523
+ },
524
+ arrowFunctionPreReturnMarkerSpacing: {
525
+ description: 'The space character (if any) to use before return markers (`=>`). Defaults to " ".',
526
+ type: 'string',
527
+ },
528
+ enableFixer: {
529
+ description: 'Whether to enable the fixer. Defaults to `true`.',
530
+ type: 'boolean',
531
+ },
532
+ functionOrClassParameterSpacing: {
533
+ description: 'The space character (if any) to use between function or class parameters. Defaults to " ".',
534
+ type: 'string',
535
+ },
536
+ functionOrClassPostGenericSpacing: {
537
+ description: 'The space character (if any) to use after a generic expression in a function or class. Defaults to "".',
538
+ type: 'string',
539
+ },
540
+ functionOrClassPostReturnMarkerSpacing: {
541
+ description: 'The space character (if any) to use after return markers (`:`). Defaults to "".',
542
+ type: 'string',
543
+ },
544
+ functionOrClassPreReturnMarkerSpacing: {
545
+ description: 'The space character (if any) to use before return markers (`:`). Defaults to "".',
546
+ type: 'string',
547
+ },
548
+ functionOrClassTypeParameterSpacing: {
549
+ description: 'The space character (if any) to use between type parameters in a function or class. Defaults to " ".',
550
+ type: 'string',
551
+ },
552
+ genericAndTupleElementSpacing: {
553
+ description: 'The space character (if any) to use between elements in generics and tuples. Defaults to " ".',
554
+ type: 'string',
555
+ },
556
+ genericDot: {
557
+ description: 'Boolean value of whether to use a dot before the angled brackets of a generic (e.g., `SomeType.<AnotherType>`). Defaults to `false`.',
558
+ type: 'boolean',
559
+ },
560
+ keyValuePostColonSpacing: {
561
+ description: 'The amount of spacing (if any) after the colon of a key-value or object-field pair. Defaults to " ".',
562
+ type: 'string',
563
+ },
564
+ keyValuePostKeySpacing: {
565
+ description: 'The amount of spacing (if any) immediately after keys in a key-value or object-field pair. Defaults to "".',
566
+ type: 'string',
567
+ },
568
+ keyValuePostOptionalSpacing: {
569
+ description: 'The amount of spacing (if any) after the optional operator (`?`) in a key-value or object-field pair. Defaults to "".',
570
+ type: 'string',
571
+ },
572
+ keyValuePostVariadicSpacing: {
573
+ description: 'The amount of spacing (if any) after a variadic operator (`...`) in a key-value pair. Defaults to "".',
574
+ type: 'string',
575
+ },
576
+ methodQuotes: {
577
+ description: 'The style of quotation mark for surrounding method names when quoted. Defaults to `double`',
578
+ enum: [
579
+ 'double',
580
+ 'single',
581
+ ],
582
+ type: 'string',
583
+ },
584
+ objectFieldIndent: {
585
+ description: `A string indicating the whitespace to be added on each line preceding an
586
+ object property-value field. Defaults to the empty string.`,
587
+ type: 'string',
588
+ },
589
+ objectFieldQuote: {
590
+ description: `Whether and how object field properties should be quoted (e.g., \`{"a": string}\`).
591
+ Set to \`single\`, \`double\`, or \`null\`. Defaults to \`null\` (no quotes unless
592
+ required due to special characters within the field). Digits will be kept as is,
593
+ regardless of setting (they can either represent a digit or a string digit).`,
594
+ enum: [
595
+ 'double',
596
+ 'single',
597
+ null,
598
+ ],
599
+ },
600
+ objectFieldSeparator: {
601
+ description: `For object properties, specify whether a "semicolon", "comma", "linebreak",
602
+ "semicolon-and-linebreak", or "comma-and-linebreak" should be used after
603
+ each object property-value pair.
604
+
605
+ Defaults to \`"comma"\`.`,
606
+ enum: [
607
+ 'comma',
608
+ 'comma-and-linebreak',
609
+ 'linebreak',
610
+ 'semicolon',
611
+ 'semicolon-and-linebreak',
612
+ ],
613
+ type: 'string',
614
+ },
615
+ objectFieldSeparatorOptionalLinebreak: {
616
+ description: `Whether \`objectFieldSeparator\` set to \`"semicolon-and-linebreak"\` or
617
+ \`"comma-and-linebreak"\` should be allowed to optionally drop the linebreak.
618
+
619
+ Defaults to \`true\`.`,
620
+ type: 'boolean',
621
+ },
622
+ objectFieldSeparatorTrailingPunctuation: {
623
+ description: `If \`separatorForSingleObjectField\` is not in effect (i.e., if it is \`false\`
624
+ or there are multiple property-value object fields present), this property
625
+ will determine whether to add punctuation corresponding to the
626
+ \`objectFieldSeparator\` (e.g., a semicolon) to the final object field.
627
+ Defaults to \`false\`.`,
628
+ type: 'boolean',
629
+ },
630
+ objectTypeBracketSpacing: {
631
+ description: 'The space character (if any) to add after an object\'s initial curly bracket and before its ending curly bracket',
632
+ type: 'string',
633
+ },
634
+ parameterDefaultValueSpacing: {
635
+ description: 'The space character (if any) to use between the equal signs of a default value. Defaults to " ".',
636
+ type: 'string',
637
+ },
638
+ postMethodNameSpacing: {
639
+ description: 'The space character (if any) to add after a method name. Defaults to "".',
640
+ type: 'string',
641
+ },
642
+ postNewSpacing: {
643
+ description: 'The space character (if any) to add after "new" in a constructor. Defaults to " ".',
644
+ type: 'string',
645
+ },
646
+ // propertyQuotes: {
647
+ // description: `Whether and how namepath properties should be quoted (e.g., \`ab."cd"."ef"\`).
648
+ // Set to \`single\`, \`double\`, or \`null\`. Defaults to \`null\` (no quotes unless
649
+ // required due to whitespace within the property).`,
650
+ // enum: [
651
+ // 'double',
652
+ // 'single',
653
+ // null,
654
+ // ],
655
+ // },
656
+ separatorForSingleObjectField: {
657
+ description: `Whether to apply the \`objectFieldSeparator\` (e.g., a semicolon) when there
658
+ is only one property-value object field present. Defaults to \`false\`.`,
659
+ type: 'boolean',
660
+ },
661
+ stringQuotes: {
662
+ description: `How string literals should be quoted (e.g., \`"abc"\`). Set to \`single\`
663
+ or \`double\`. Defaults to 'double'.`,
664
+ enum: [
665
+ 'double',
666
+ 'single',
667
+ ],
668
+ type: 'string',
669
+ },
670
+ trailingPunctuationMultilineOnly: {
671
+ description: 'If `objectFieldSeparatorTrailingPunctuation` is set, this will determine whether the trailing puncutation is only added when the type is multiline',
672
+ type: 'boolean',
673
+ },
674
+ typeBracketSpacing: {
675
+ description: `A string of spaces that will be added immediately after the type's initial
676
+ curly bracket and immediately before its ending curly bracket. Defaults
677
+ to the empty string.`,
678
+ type: 'string',
679
+ },
680
+ unionSpacing: {
681
+ description: 'Determines the spacing to add to unions (`|`). Defaults to a single space (`" "`).',
682
+ type: 'string',
683
+ },
684
+ },
685
+ type: 'object',
686
+ },
687
+ ],
688
+ type: 'suggestion',
689
+ },
690
+ });