eslint-plugin-jsdoc 53.0.1 → 54.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/dist/WarnSettings.cjs +35 -18
  2. package/dist/WarnSettings.cjs.map +1 -1
  3. package/dist/alignTransform.cjs +305 -224
  4. package/dist/alignTransform.cjs.map +1 -1
  5. package/dist/defaultTagOrder.cjs +43 -132
  6. package/dist/defaultTagOrder.cjs.map +1 -1
  7. package/dist/exportParser.cjs +696 -478
  8. package/dist/exportParser.cjs.map +1 -1
  9. package/dist/generateRule.cjs +242 -0
  10. package/dist/generateRule.cjs.map +1 -0
  11. package/dist/getDefaultTagStructureForMode.cjs +288 -184
  12. package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
  13. package/dist/getJsdocProcessorPlugin.cjs +550 -364
  14. package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
  15. package/dist/getJsdocProcessorPlugin.d.ts +65 -68
  16. package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
  17. package/dist/index.cjs +410 -2
  18. package/dist/index.cjs.map +1 -0
  19. package/dist/index.d.ts +17 -2
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/iterateJsdoc.cjs +2005 -1539
  22. package/dist/iterateJsdoc.cjs.map +1 -1
  23. package/dist/iterateJsdoc.d.ts +350 -359
  24. package/dist/iterateJsdoc.d.ts.map +1 -1
  25. package/dist/jsdocUtils.cjs +1376 -1009
  26. package/dist/jsdocUtils.cjs.map +1 -1
  27. package/dist/rules/checkAccess.cjs +36 -29
  28. package/dist/rules/checkAccess.cjs.map +1 -1
  29. package/dist/rules/checkAlignment.cjs +54 -41
  30. package/dist/rules/checkAlignment.cjs.map +1 -1
  31. package/dist/rules/checkExamples.cjs +484 -327
  32. package/dist/rules/checkExamples.cjs.map +1 -1
  33. package/dist/rules/checkIndentation.cjs +65 -50
  34. package/dist/rules/checkIndentation.cjs.map +1 -1
  35. package/dist/rules/checkLineAlignment.cjs +311 -220
  36. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  37. package/dist/rules/checkParamNames.cjs +335 -227
  38. package/dist/rules/checkParamNames.cjs.map +1 -1
  39. package/dist/rules/checkPropertyNames.cjs +106 -78
  40. package/dist/rules/checkPropertyNames.cjs.map +1 -1
  41. package/dist/rules/checkSyntax.cjs +34 -21
  42. package/dist/rules/checkSyntax.cjs.map +1 -1
  43. package/dist/rules/checkTagNames.cjs +210 -188
  44. package/dist/rules/checkTagNames.cjs.map +1 -1
  45. package/dist/rules/checkTemplateNames.cjs +178 -121
  46. package/dist/rules/checkTemplateNames.cjs.map +1 -1
  47. package/dist/rules/checkTypes.cjs +385 -291
  48. package/dist/rules/checkTypes.cjs.map +1 -1
  49. package/dist/rules/checkValues.cjs +146 -100
  50. package/dist/rules/checkValues.cjs.map +1 -1
  51. package/dist/rules/convertToJsdocComments.cjs +306 -228
  52. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  53. package/dist/rules/emptyTags.cjs +72 -62
  54. package/dist/rules/emptyTags.cjs.map +1 -1
  55. package/dist/rules/implementsOnClasses.cjs +56 -36
  56. package/dist/rules/implementsOnClasses.cjs.map +1 -1
  57. package/dist/rules/importsAsDependencies.cjs +99 -62
  58. package/dist/rules/importsAsDependencies.cjs.map +1 -1
  59. package/dist/rules/informativeDocs.cjs +142 -105
  60. package/dist/rules/informativeDocs.cjs.map +1 -1
  61. package/dist/rules/linesBeforeBlock.cjs +105 -70
  62. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  63. package/dist/rules/matchDescription.cjs +222 -160
  64. package/dist/rules/matchDescription.cjs.map +1 -1
  65. package/dist/rules/matchName.cjs +128 -73
  66. package/dist/rules/matchName.cjs.map +1 -1
  67. package/dist/rules/multilineBlocks.cjs +352 -235
  68. package/dist/rules/multilineBlocks.cjs.map +1 -1
  69. package/dist/rules/noBadBlocks.cjs +86 -63
  70. package/dist/rules/noBadBlocks.cjs.map +1 -1
  71. package/dist/rules/noBlankBlockDescriptions.cjs +57 -35
  72. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
  73. package/dist/rules/noBlankBlocks.cjs +48 -26
  74. package/dist/rules/noBlankBlocks.cjs.map +1 -1
  75. package/dist/rules/noDefaults.cjs +79 -52
  76. package/dist/rules/noDefaults.cjs.map +1 -1
  77. package/dist/rules/noMissingSyntax.cjs +165 -115
  78. package/dist/rules/noMissingSyntax.cjs.map +1 -1
  79. package/dist/rules/noMultiAsterisks.cjs +89 -48
  80. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  81. package/dist/rules/noRestrictedSyntax.cjs +79 -45
  82. package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
  83. package/dist/rules/noTypes.cjs +80 -59
  84. package/dist/rules/noTypes.cjs.map +1 -1
  85. package/dist/rules/noUndefinedTypes.cjs +388 -297
  86. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  87. package/dist/rules/requireAsteriskPrefix.cjs +159 -108
  88. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  89. package/dist/rules/requireDescription.cjs +129 -89
  90. package/dist/rules/requireDescription.cjs.map +1 -1
  91. package/dist/rules/requireDescriptionCompleteSentence.cjs +262 -201
  92. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  93. package/dist/rules/requireExample.cjs +104 -73
  94. package/dist/rules/requireExample.cjs.map +1 -1
  95. package/dist/rules/requireFileOverview.cjs +129 -75
  96. package/dist/rules/requireFileOverview.cjs.map +1 -1
  97. package/dist/rules/requireHyphenBeforeParamDescription.cjs +133 -85
  98. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  99. package/dist/rules/requireJsdoc.cjs +557 -384
  100. package/dist/rules/requireJsdoc.cjs.map +1 -1
  101. package/dist/rules/requireParam.cjs +526 -336
  102. package/dist/rules/requireParam.cjs.map +1 -1
  103. package/dist/rules/requireParamDescription.cjs +80 -55
  104. package/dist/rules/requireParamDescription.cjs.map +1 -1
  105. package/dist/rules/requireParamName.cjs +50 -32
  106. package/dist/rules/requireParamName.cjs.map +1 -1
  107. package/dist/rules/requireParamType.cjs +80 -55
  108. package/dist/rules/requireParamType.cjs.map +1 -1
  109. package/dist/rules/requireProperty.cjs +42 -31
  110. package/dist/rules/requireProperty.cjs.map +1 -1
  111. package/dist/rules/requirePropertyDescription.cjs +25 -17
  112. package/dist/rules/requirePropertyDescription.cjs.map +1 -1
  113. package/dist/rules/requirePropertyName.cjs +25 -17
  114. package/dist/rules/requirePropertyName.cjs.map +1 -1
  115. package/dist/rules/requirePropertyType.cjs +25 -17
  116. package/dist/rules/requirePropertyType.cjs.map +1 -1
  117. package/dist/rules/requireReturns.cjs +203 -125
  118. package/dist/rules/requireReturns.cjs.map +1 -1
  119. package/dist/rules/requireReturnsCheck.cjs +103 -60
  120. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  121. package/dist/rules/requireReturnsDescription.cjs +54 -39
  122. package/dist/rules/requireReturnsDescription.cjs.map +1 -1
  123. package/dist/rules/requireReturnsType.cjs +50 -32
  124. package/dist/rules/requireReturnsType.cjs.map +1 -1
  125. package/dist/rules/requireTemplate.cjs +178 -119
  126. package/dist/rules/requireTemplate.cjs.map +1 -1
  127. package/dist/rules/requireThrows.cjs +95 -61
  128. package/dist/rules/requireThrows.cjs.map +1 -1
  129. package/dist/rules/requireYields.cjs +166 -106
  130. package/dist/rules/requireYields.cjs.map +1 -1
  131. package/dist/rules/requireYieldsCheck.cjs +152 -96
  132. package/dist/rules/requireYieldsCheck.cjs.map +1 -1
  133. package/dist/rules/sortTags.cjs +444 -258
  134. package/dist/rules/sortTags.cjs.map +1 -1
  135. package/dist/rules/tagLines.cjs +266 -179
  136. package/dist/rules/tagLines.cjs.map +1 -1
  137. package/dist/rules/textEscaping.cjs +127 -92
  138. package/dist/rules/textEscaping.cjs.map +1 -1
  139. package/dist/rules/validTypes.cjs +265 -252
  140. package/dist/rules/validTypes.cjs.map +1 -1
  141. package/dist/tagNames.cjs +170 -134
  142. package/dist/tagNames.cjs.map +1 -1
  143. package/dist/utils/hasReturnValue.cjs +474 -246
  144. package/dist/utils/hasReturnValue.cjs.map +1 -1
  145. package/package.json +24 -40
  146. package/src/WarnSettings.js +34 -0
  147. package/src/alignTransform.js +358 -0
  148. package/src/defaultTagOrder.js +169 -0
  149. package/src/exportParser.js +978 -0
  150. package/src/getDefaultTagStructureForMode.js +969 -0
  151. package/src/getJsdocProcessorPlugin.js +672 -0
  152. package/src/index.js +530 -0
  153. package/src/iterateJsdoc.js +2541 -0
  154. package/src/jsdocUtils.js +1896 -0
  155. package/src/rules/checkAccess.js +45 -0
  156. package/src/rules/checkAlignment.js +63 -0
  157. package/src/rules/checkExamples.js +589 -0
  158. package/src/rules/checkIndentation.js +75 -0
  159. package/src/rules/checkLineAlignment.js +372 -0
  160. package/src/rules/checkParamNames.js +474 -0
  161. package/src/rules/checkPropertyNames.js +152 -0
  162. package/src/rules/checkSyntax.js +30 -0
  163. package/src/rules/checkTagNames.js +314 -0
  164. package/src/rules/checkTemplateNames.js +204 -0
  165. package/src/rules/checkTypes.js +535 -0
  166. package/src/rules/checkValues.js +248 -0
  167. package/src/rules/convertToJsdocComments.js +398 -0
  168. package/src/rules/emptyTags.js +98 -0
  169. package/src/rules/implementsOnClasses.js +64 -0
  170. package/src/rules/importsAsDependencies.js +133 -0
  171. package/src/rules/informativeDocs.js +189 -0
  172. package/src/rules/linesBeforeBlock.js +134 -0
  173. package/src/rules/matchDescription.js +286 -0
  174. package/src/rules/matchName.js +151 -0
  175. package/src/rules/multilineBlocks.js +493 -0
  176. package/src/rules/noBadBlocks.js +119 -0
  177. package/src/rules/noBlankBlockDescriptions.js +69 -0
  178. package/src/rules/noBlankBlocks.js +53 -0
  179. package/src/rules/noDefaults.js +85 -0
  180. package/src/rules/noMissingSyntax.js +195 -0
  181. package/src/rules/noMultiAsterisks.js +134 -0
  182. package/src/rules/noRestrictedSyntax.js +91 -0
  183. package/src/rules/noTypes.js +93 -0
  184. package/src/rules/noUndefinedTypes.js +543 -0
  185. package/src/rules/requireAsteriskPrefix.js +190 -0
  186. package/src/rules/requireDescription.js +161 -0
  187. package/src/rules/requireDescriptionCompleteSentence.js +335 -0
  188. package/src/rules/requireExample.js +118 -0
  189. package/src/rules/requireFileOverview.js +154 -0
  190. package/src/rules/requireHyphenBeforeParamDescription.js +176 -0
  191. package/src/rules/requireJsdoc.js +743 -0
  192. package/src/rules/requireParam.js +602 -0
  193. package/src/rules/requireParamDescription.js +89 -0
  194. package/src/rules/requireParamName.js +55 -0
  195. package/src/rules/requireParamType.js +89 -0
  196. package/src/rules/requireProperty.js +48 -0
  197. package/src/rules/requirePropertyDescription.js +25 -0
  198. package/src/rules/requirePropertyName.js +25 -0
  199. package/src/rules/requirePropertyType.js +25 -0
  200. package/src/rules/requireReturns.js +238 -0
  201. package/src/rules/requireReturnsCheck.js +145 -0
  202. package/src/rules/requireReturnsDescription.js +59 -0
  203. package/src/rules/requireReturnsType.js +51 -0
  204. package/src/rules/requireTemplate.js +201 -0
  205. package/src/rules/requireThrows.js +111 -0
  206. package/src/rules/requireYields.js +216 -0
  207. package/src/rules/requireYieldsCheck.js +208 -0
  208. package/src/rules/sortTags.js +558 -0
  209. package/src/rules/tagLines.js +359 -0
  210. package/src/rules/textEscaping.js +154 -0
  211. package/src/rules/validTypes.js +401 -0
  212. package/src/tagNames.js +238 -0
  213. package/src/utils/hasReturnValue.js +572 -0
  214. package/dist/WarnSettings.js +0 -20
  215. package/dist/WarnSettings.js.map +0 -1
  216. package/dist/_virtual/rolldown_runtime.cjs +0 -32
  217. package/dist/_virtual/rolldown_runtime.js +0 -11
  218. package/dist/alignTransform.js +0 -241
  219. package/dist/alignTransform.js.map +0 -1
  220. package/dist/defaultTagOrder.js +0 -134
  221. package/dist/defaultTagOrder.js.map +0 -1
  222. package/dist/exportParser.js +0 -518
  223. package/dist/exportParser.js.map +0 -1
  224. package/dist/getDefaultTagStructureForMode.js +0 -188
  225. package/dist/getDefaultTagStructureForMode.js.map +0 -1
  226. package/dist/getJsdocProcessorPlugin.d.cts +0 -70
  227. package/dist/getJsdocProcessorPlugin.d.cts.map +0 -1
  228. package/dist/getJsdocProcessorPlugin.js +0 -383
  229. package/dist/getJsdocProcessorPlugin.js.map +0 -1
  230. package/dist/index.d.cts +0 -2
  231. package/dist/index.js +0 -3
  232. package/dist/iterateJsdoc.d.cts +0 -472
  233. package/dist/iterateJsdoc.d.cts.map +0 -1
  234. package/dist/iterateJsdoc.js +0 -1628
  235. package/dist/iterateJsdoc.js.map +0 -1
  236. package/dist/jsdocUtils.js +0 -1123
  237. package/dist/jsdocUtils.js.map +0 -1
  238. package/dist/plugin.cjs +0 -427
  239. package/dist/plugin.cjs.map +0 -1
  240. package/dist/plugin.js +0 -427
  241. package/dist/plugin.js.map +0 -1
  242. package/dist/rules/checkAccess.js +0 -33
  243. package/dist/rules/checkAccess.js.map +0 -1
  244. package/dist/rules/checkAlignment.js +0 -47
  245. package/dist/rules/checkAlignment.js.map +0 -1
  246. package/dist/rules/checkExamples.js +0 -348
  247. package/dist/rules/checkExamples.js.map +0 -1
  248. package/dist/rules/checkIndentation.js +0 -59
  249. package/dist/rules/checkIndentation.js.map +0 -1
  250. package/dist/rules/checkLineAlignment.js +0 -229
  251. package/dist/rules/checkLineAlignment.js.map +0 -1
  252. package/dist/rules/checkParamNames.js +0 -237
  253. package/dist/rules/checkParamNames.js.map +0 -1
  254. package/dist/rules/checkPropertyNames.js +0 -88
  255. package/dist/rules/checkPropertyNames.js.map +0 -1
  256. package/dist/rules/checkSyntax.js +0 -25
  257. package/dist/rules/checkSyntax.js.map +0 -1
  258. package/dist/rules/checkTagNames.js +0 -191
  259. package/dist/rules/checkTagNames.js.map +0 -1
  260. package/dist/rules/checkTemplateNames.js +0 -124
  261. package/dist/rules/checkTemplateNames.js.map +0 -1
  262. package/dist/rules/checkTypes.js +0 -299
  263. package/dist/rules/checkTypes.js.map +0 -1
  264. package/dist/rules/checkValues.js +0 -103
  265. package/dist/rules/checkValues.js.map +0 -1
  266. package/dist/rules/convertToJsdocComments.js +0 -231
  267. package/dist/rules/convertToJsdocComments.js.map +0 -1
  268. package/dist/rules/emptyTags.js +0 -67
  269. package/dist/rules/emptyTags.js.map +0 -1
  270. package/dist/rules/implementsOnClasses.js +0 -40
  271. package/dist/rules/implementsOnClasses.js.map +0 -1
  272. package/dist/rules/importsAsDependencies.js +0 -68
  273. package/dist/rules/importsAsDependencies.js.map +0 -1
  274. package/dist/rules/informativeDocs.js +0 -110
  275. package/dist/rules/informativeDocs.js.map +0 -1
  276. package/dist/rules/linesBeforeBlock.js +0 -75
  277. package/dist/rules/linesBeforeBlock.js.map +0 -1
  278. package/dist/rules/matchDescription.js +0 -167
  279. package/dist/rules/matchDescription.js.map +0 -1
  280. package/dist/rules/matchName.js +0 -77
  281. package/dist/rules/matchName.js.map +0 -1
  282. package/dist/rules/multilineBlocks.js +0 -245
  283. package/dist/rules/multilineBlocks.js.map +0 -1
  284. package/dist/rules/noBadBlocks.js +0 -68
  285. package/dist/rules/noBadBlocks.js.map +0 -1
  286. package/dist/rules/noBlankBlockDescriptions.js +0 -41
  287. package/dist/rules/noBlankBlockDescriptions.js.map +0 -1
  288. package/dist/rules/noBlankBlocks.js +0 -30
  289. package/dist/rules/noBlankBlocks.js.map +0 -1
  290. package/dist/rules/noDefaults.js +0 -56
  291. package/dist/rules/noDefaults.js.map +0 -1
  292. package/dist/rules/noMissingSyntax.js +0 -126
  293. package/dist/rules/noMissingSyntax.js.map +0 -1
  294. package/dist/rules/noMultiAsterisks.js +0 -58
  295. package/dist/rules/noMultiAsterisks.js.map +0 -1
  296. package/dist/rules/noRestrictedSyntax.js +0 -49
  297. package/dist/rules/noRestrictedSyntax.js.map +0 -1
  298. package/dist/rules/noTypes.js +0 -65
  299. package/dist/rules/noTypes.js.map +0 -1
  300. package/dist/rules/noUndefinedTypes.js +0 -303
  301. package/dist/rules/noUndefinedTypes.js.map +0 -1
  302. package/dist/rules/requireAsteriskPrefix.js +0 -112
  303. package/dist/rules/requireAsteriskPrefix.js.map +0 -1
  304. package/dist/rules/requireDescription.js +0 -95
  305. package/dist/rules/requireDescription.js.map +0 -1
  306. package/dist/rules/requireDescriptionCompleteSentence.js +0 -220
  307. package/dist/rules/requireDescriptionCompleteSentence.js.map +0 -1
  308. package/dist/rules/requireExample.js +0 -77
  309. package/dist/rules/requireExample.js.map +0 -1
  310. package/dist/rules/requireFileOverview.js +0 -81
  311. package/dist/rules/requireFileOverview.js.map +0 -1
  312. package/dist/rules/requireHyphenBeforeParamDescription.js +0 -89
  313. package/dist/rules/requireHyphenBeforeParamDescription.js.map +0 -1
  314. package/dist/rules/requireJsdoc.js +0 -404
  315. package/dist/rules/requireJsdoc.js.map +0 -1
  316. package/dist/rules/requireParam.js +0 -344
  317. package/dist/rules/requireParam.js.map +0 -1
  318. package/dist/rules/requireParamDescription.js +0 -59
  319. package/dist/rules/requireParamDescription.js.map +0 -1
  320. package/dist/rules/requireParamName.js +0 -36
  321. package/dist/rules/requireParamName.js.map +0 -1
  322. package/dist/rules/requireParamType.js +0 -59
  323. package/dist/rules/requireParamType.js.map +0 -1
  324. package/dist/rules/requireProperty.js +0 -35
  325. package/dist/rules/requireProperty.js.map +0 -1
  326. package/dist/rules/requirePropertyDescription.js +0 -21
  327. package/dist/rules/requirePropertyDescription.js.map +0 -1
  328. package/dist/rules/requirePropertyName.js +0 -21
  329. package/dist/rules/requirePropertyName.js.map +0 -1
  330. package/dist/rules/requirePropertyType.js +0 -21
  331. package/dist/rules/requirePropertyType.js.map +0 -1
  332. package/dist/rules/requireReturns.js +0 -131
  333. package/dist/rules/requireReturns.js.map +0 -1
  334. package/dist/rules/requireReturnsCheck.js +0 -66
  335. package/dist/rules/requireReturnsCheck.js.map +0 -1
  336. package/dist/rules/requireReturnsDescription.js +0 -43
  337. package/dist/rules/requireReturnsDescription.js.map +0 -1
  338. package/dist/rules/requireReturnsType.js +0 -36
  339. package/dist/rules/requireReturnsType.js.map +0 -1
  340. package/dist/rules/requireTemplate.js +0 -122
  341. package/dist/rules/requireTemplate.js.map +0 -1
  342. package/dist/rules/requireThrows.js +0 -67
  343. package/dist/rules/requireThrows.js.map +0 -1
  344. package/dist/rules/requireYields.js +0 -115
  345. package/dist/rules/requireYields.js.map +0 -1
  346. package/dist/rules/requireYieldsCheck.js +0 -105
  347. package/dist/rules/requireYieldsCheck.js.map +0 -1
  348. package/dist/rules/sortTags.js +0 -262
  349. package/dist/rules/sortTags.js.map +0 -1
  350. package/dist/rules/tagLines.js +0 -183
  351. package/dist/rules/tagLines.js.map +0 -1
  352. package/dist/rules/textEscaping.js +0 -102
  353. package/dist/rules/textEscaping.js.map +0 -1
  354. package/dist/rules/validTypes.js +0 -259
  355. package/dist/rules/validTypes.js.map +0 -1
  356. package/dist/tagNames.js +0 -144
  357. package/dist/tagNames.js.map +0 -1
  358. package/dist/utils/hasReturnValue.js +0 -265
  359. package/dist/utils/hasReturnValue.js.map +0 -1
@@ -1,231 +0,0 @@
1
- import { enforcedContexts, getContextObject, getIndent } from "../jsdocUtils.js";
2
- import { getSettings } from "../iterateJsdoc.js";
3
- import { getDecorator, getFollowingComment, getNonJsdocComment, getReducedASTNode } from "@es-joy/jsdoccomment";
4
-
5
- //#region src/rules/convertToJsdocComments.js
6
- /** @type {import('eslint').Rule.RuleModule} */
7
- var convertToJsdocComments_default = {
8
- create(context) {
9
- /**
10
- * @typedef {import('eslint').AST.Token | import('estree').Comment | {
11
- * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang",
12
- * range: [number, number],
13
- * value: string
14
- * }} Token
15
- */
16
- /**
17
- * @callback AddComment
18
- * @param {boolean|undefined} inlineCommentBlock
19
- * @param {Token} comment
20
- * @param {string} indent
21
- * @param {number} lines
22
- * @param {import('eslint').Rule.RuleFixer} fixer
23
- */
24
- /* c8 ignore next -- Fallback to deprecated method */
25
- const { sourceCode = context.getSourceCode() } = context;
26
- const settings = getSettings(context);
27
- if (!settings) return {};
28
- const { allowedPrefixes = [
29
- "@ts-",
30
- "istanbul ",
31
- "c8 ",
32
- "v8 ",
33
- "eslint",
34
- "prettier-"
35
- ], contexts = settings.contexts || [], contextsAfter = [], contextsBeforeAndAfter = [
36
- "VariableDeclarator",
37
- "TSPropertySignature",
38
- "PropertyDefinition"
39
- ], enableFixer = true, enforceJsdocLineStyle = "multi", lineOrBlockStyle = "both" } = context.options[0] ?? {};
40
- let reportingNonJsdoc = false;
41
- /**
42
- * @param {string} messageId
43
- * @param {import('estree').Comment|Token} comment
44
- * @param {import('eslint').Rule.Node} node
45
- * @param {import('eslint').Rule.ReportFixer} fixer
46
- */
47
- const report = (messageId, comment, node, fixer) => {
48
- const loc = {
49
- end: {
50
- column: 0,
51
- line: comment.loc?.start?.line ?? 1
52
- },
53
- start: {
54
- column: 0,
55
- line: comment.loc?.start?.line ?? 1
56
- }
57
- };
58
- context.report({
59
- fix: enableFixer ? fixer : null,
60
- loc,
61
- messageId,
62
- node
63
- });
64
- };
65
- /**
66
- * @param {import('eslint').Rule.Node} node
67
- * @param {import('eslint').AST.Token | import('estree').Comment | {
68
- * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang",
69
- * range: [number, number],
70
- * value: string
71
- * }} comment
72
- * @param {AddComment} addComment
73
- * @param {import('../iterateJsdoc.js').Context[]} ctxts
74
- */
75
- const getFixer = (node, comment, addComment, ctxts) => {
76
- return (fixer) => {
77
- const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
78
- let baseNode = getReducedASTNode(node, sourceCode);
79
- const decorator = getDecorator(baseNode);
80
- if (decorator) baseNode = decorator;
81
- const indent = getIndent({ text: sourceCode.getText(
82
- baseNode,
83
- /** @type {import('eslint').AST.SourceLocation} */
84
- baseNode.loc.start.column
85
- ) });
86
- const { inlineCommentBlock } = ctxts.find((contxt) => {
87
- if (typeof contxt === "string") return false;
88
- const { context: ctxt } = contxt;
89
- return ctxt === node.type;
90
- }) || {};
91
- return addComment(inlineCommentBlock, comment, indent, lines, fixer);
92
- };
93
- };
94
- /**
95
- * @param {import('eslint').AST.Token | import('estree').Comment | {
96
- * type: import('eslint').AST.TokenType|"Line"|"Block"|"Shebang",
97
- * range: [number, number],
98
- * value: string
99
- * }} comment
100
- * @param {import('eslint').Rule.Node} node
101
- * @param {AddComment} addComment
102
- * @param {import('../iterateJsdoc.js').Context[]} ctxts
103
- */
104
- const reportings = (comment, node, addComment, ctxts) => {
105
- const fixer = getFixer(node, comment, addComment, ctxts);
106
- if (comment.type === "Block") {
107
- if (lineOrBlockStyle === "line") return;
108
- report("blockCommentsJsdocStyle", comment, node, fixer);
109
- return;
110
- }
111
- if (comment.type === "Line") {
112
- if (lineOrBlockStyle === "block") return;
113
- report("lineCommentsJsdocStyle", comment, node, fixer);
114
- }
115
- };
116
- /**
117
- * @type {import('../iterateJsdoc.js').CheckJsdoc}
118
- */
119
- const checkNonJsdoc = (_info, _handler, node) => {
120
- const comment = getNonJsdocComment(sourceCode, node, settings);
121
- if (!comment || allowedPrefixes.some((prefix) => {
122
- return comment.value.trimStart().startsWith(prefix);
123
- })) return;
124
- reportingNonJsdoc = true;
125
- /** @type {AddComment} */
126
- const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {
127
- const insertion = (inlineCommentBlock || enforceJsdocLineStyle === "single" ? `/** ${commentToAdd.value.trim()} ` : `/**\n${indent}*${commentToAdd.value.trimEnd()}\n${indent}`) + `*/${"\n".repeat((lines || 1) - 1)}`;
128
- return fixer.replaceText(commentToAdd, insertion);
129
- };
130
- reportings(comment, node, addComment, contexts);
131
- };
132
- /**
133
- * @param {import('eslint').Rule.Node} node
134
- * @param {import('../iterateJsdoc.js').Context[]} ctxts
135
- */
136
- const checkNonJsdocAfter = (node, ctxts) => {
137
- const comment = getFollowingComment(sourceCode, node);
138
- if (!comment || comment.value.startsWith("*") || allowedPrefixes.some((prefix) => {
139
- return comment.value.trimStart().startsWith(prefix);
140
- })) return;
141
- /** @type {AddComment} */
142
- const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {
143
- const insertion = (inlineCommentBlock || enforceJsdocLineStyle === "single" ? `/** ${commentToAdd.value.trim()} ` : `/**\n${indent}*${commentToAdd.value.trimEnd()}\n${indent}`) + `*/${"\n".repeat((lines || 1) - 1)}${lines ? `\n${indent.slice(1)}` : " "}`;
144
- return [fixer.remove(commentToAdd), fixer.insertTextBefore(node.type === "VariableDeclarator" ? node.parent : node, insertion)];
145
- };
146
- reportings(comment, node, addComment, ctxts);
147
- };
148
- return {
149
- ...getContextObject(enforcedContexts(context, true, settings), checkNonJsdoc),
150
- ...getContextObject(contextsAfter, (_info, _handler, node) => {
151
- checkNonJsdocAfter(node, contextsAfter);
152
- }),
153
- ...getContextObject(contextsBeforeAndAfter, (_info, _handler, node) => {
154
- checkNonJsdoc({}, null, node);
155
- if (!reportingNonJsdoc) checkNonJsdocAfter(node, contextsBeforeAndAfter);
156
- })
157
- };
158
- },
159
- meta: {
160
- docs: {
161
- description: "Converts non-JSDoc comments preceding or following nodes into JSDoc ones",
162
- url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header"
163
- },
164
- fixable: "code",
165
- messages: {
166
- blockCommentsJsdocStyle: "Block comments should be JSDoc-style.",
167
- lineCommentsJsdocStyle: "Line comments should be JSDoc-style."
168
- },
169
- schema: [{
170
- additionalProperties: false,
171
- properties: {
172
- allowedPrefixes: {
173
- items: { type: "string" },
174
- type: "array"
175
- },
176
- contexts: {
177
- items: { anyOf: [{ type: "string" }, {
178
- additionalProperties: false,
179
- properties: {
180
- context: { type: "string" },
181
- inlineCommentBlock: { type: "boolean" }
182
- },
183
- type: "object"
184
- }] },
185
- type: "array"
186
- },
187
- contextsAfter: {
188
- items: { anyOf: [{ type: "string" }, {
189
- additionalProperties: false,
190
- properties: {
191
- context: { type: "string" },
192
- inlineCommentBlock: { type: "boolean" }
193
- },
194
- type: "object"
195
- }] },
196
- type: "array"
197
- },
198
- contextsBeforeAndAfter: {
199
- items: { anyOf: [{ type: "string" }, {
200
- additionalProperties: false,
201
- properties: {
202
- context: { type: "string" },
203
- inlineCommentBlock: { type: "boolean" }
204
- },
205
- type: "object"
206
- }] },
207
- type: "array"
208
- },
209
- enableFixer: { type: "boolean" },
210
- enforceJsdocLineStyle: {
211
- enum: ["multi", "single"],
212
- type: "string"
213
- },
214
- lineOrBlockStyle: {
215
- enum: [
216
- "block",
217
- "line",
218
- "both"
219
- ],
220
- type: "string"
221
- }
222
- },
223
- type: "object"
224
- }],
225
- type: "suggestion"
226
- }
227
- };
228
-
229
- //#endregion
230
- export { convertToJsdocComments_default as default };
231
- //# sourceMappingURL=convertToJsdocComments.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertToJsdocComments.js","names":[],"sources":["../../src/rules/convertToJsdocComments.js"],"sourcesContent":["import {\n getSettings,\n} from '../iterateJsdoc.js';\nimport {\n enforcedContexts,\n getContextObject,\n getIndent,\n} from '../jsdocUtils.js';\nimport {\n getDecorator,\n getFollowingComment,\n getNonJsdocComment,\n getReducedASTNode,\n} from '@es-joy/jsdoccomment';\n\n/** @type {import('eslint').Rule.RuleModule} */\nexport default {\n create (context) {\n /**\n * @typedef {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} Token\n */\n\n /**\n * @callback AddComment\n * @param {boolean|undefined} inlineCommentBlock\n * @param {Token} comment\n * @param {string} indent\n * @param {number} lines\n * @param {import('eslint').Rule.RuleFixer} fixer\n */\n\n /* c8 ignore next -- Fallback to deprecated method */\n const {\n sourceCode = context.getSourceCode(),\n } = context;\n const settings = getSettings(context);\n if (!settings) {\n return {};\n }\n\n const {\n allowedPrefixes = [\n '@ts-', 'istanbul ', 'c8 ', 'v8 ', 'eslint', 'prettier-',\n ],\n contexts = settings.contexts || [],\n contextsAfter = /** @type {string[]} */ ([]),\n contextsBeforeAndAfter = [\n 'VariableDeclarator', 'TSPropertySignature', 'PropertyDefinition',\n ],\n enableFixer = true,\n enforceJsdocLineStyle = 'multi',\n lineOrBlockStyle = 'both',\n } = context.options[0] ?? {};\n\n let reportingNonJsdoc = false;\n\n /**\n * @param {string} messageId\n * @param {import('estree').Comment|Token} comment\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').Rule.ReportFixer} fixer\n */\n const report = (messageId, comment, node, fixer) => {\n const loc = {\n end: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n start: {\n column: 0,\n /* c8 ignore next 2 -- Guard */\n // @ts-expect-error Ok\n line: (comment.loc?.start?.line ?? 1),\n },\n };\n\n context.report({\n fix: enableFixer ? fixer : null,\n loc,\n messageId,\n node,\n });\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const getFixer = (node, comment, addComment, ctxts) => {\n return /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {\n // Default to one line break if the `minLines`/`maxLines` settings allow\n const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;\n let baseNode =\n /**\n * @type {import('@typescript-eslint/types').TSESTree.Node|import('eslint').Rule.Node}\n */ (\n getReducedASTNode(node, sourceCode)\n );\n\n const decorator = getDecorator(\n /** @type {import('eslint').Rule.Node} */\n (baseNode),\n );\n if (decorator) {\n baseNode = /** @type {import('@typescript-eslint/types').TSESTree.Decorator} */ (\n decorator\n );\n }\n\n const indent = getIndent({\n text: sourceCode.getText(\n /** @type {import('eslint').Rule.Node} */ (baseNode),\n /** @type {import('eslint').AST.SourceLocation} */\n (\n /** @type {import('eslint').Rule.Node} */ (baseNode).loc\n ).start.column,\n ),\n });\n\n const {\n inlineCommentBlock,\n } =\n /**\n * @type {{\n * context: string,\n * inlineCommentBlock: boolean,\n * minLineCount: import('../iterateJsdoc.js').Integer\n * }[]}\n */ (ctxts).find((contxt) => {\n if (typeof contxt === 'string') {\n return false;\n }\n\n const {\n context: ctxt,\n } = contxt;\n return ctxt === node.type;\n }) || {};\n\n return addComment(inlineCommentBlock, comment, indent, lines, fixer);\n };\n };\n\n /**\n * @param {import('eslint').AST.Token | import('estree').Comment | {\n * type: import('eslint').AST.TokenType|\"Line\"|\"Block\"|\"Shebang\",\n * range: [number, number],\n * value: string\n * }} comment\n * @param {import('eslint').Rule.Node} node\n * @param {AddComment} addComment\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const reportings = (comment, node, addComment, ctxts) => {\n const fixer = getFixer(node, comment, addComment, ctxts);\n\n if (comment.type === 'Block') {\n if (lineOrBlockStyle === 'line') {\n return;\n }\n\n report('blockCommentsJsdocStyle', comment, node, fixer);\n return;\n }\n\n if (comment.type === 'Line') {\n if (lineOrBlockStyle === 'block') {\n return;\n }\n\n report('lineCommentsJsdocStyle', comment, node, fixer);\n }\n };\n\n /**\n * @type {import('../iterateJsdoc.js').CheckJsdoc}\n */\n const checkNonJsdoc = (_info, _handler, node) => {\n const comment = getNonJsdocComment(sourceCode, node, settings);\n\n if (\n !comment ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n reportingNonJsdoc = true;\n\n /** @type {AddComment} */\n // eslint-disable-next-line unicorn/consistent-function-scoping -- Avoid conflicts\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}`;\n\n return fixer.replaceText(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n insertion,\n );\n };\n\n reportings(comment, node, addComment, contexts);\n };\n\n /**\n * @param {import('eslint').Rule.Node} node\n * @param {import('../iterateJsdoc.js').Context[]} ctxts\n */\n const checkNonJsdocAfter = (node, ctxts) => {\n const comment = getFollowingComment(sourceCode, node);\n\n if (\n !comment ||\n comment.value.startsWith('*') ||\n /** @type {string[]} */\n (allowedPrefixes).some((prefix) => {\n return comment.value.trimStart().startsWith(prefix);\n })\n ) {\n return;\n }\n\n /** @type {AddComment} */\n const addComment = (inlineCommentBlock, commentToAdd, indent, lines, fixer) => {\n const insertion = (\n inlineCommentBlock || enforceJsdocLineStyle === 'single' ?\n `/** ${commentToAdd.value.trim()} ` :\n `/**\\n${indent}*${commentToAdd.value.trimEnd()}\\n${indent}`\n ) +\n `*/${'\\n'.repeat((lines || 1) - 1)}${lines ? `\\n${indent.slice(1)}` : ' '}`;\n\n return [\n fixer.remove(\n /** @type {import('eslint').AST.Token} */\n (commentToAdd),\n ), fixer.insertTextBefore(\n node.type === 'VariableDeclarator' ? node.parent : node,\n insertion,\n ),\n ];\n };\n\n reportings(comment, node, addComment, ctxts);\n };\n\n // Todo: add contexts to check after (and handle if want both before and after)\n return {\n ...getContextObject(\n enforcedContexts(context, true, settings),\n checkNonJsdoc,\n ),\n ...getContextObject(\n contextsAfter,\n (_info, _handler, node) => {\n checkNonJsdocAfter(node, contextsAfter);\n },\n ),\n ...getContextObject(\n contextsBeforeAndAfter,\n (_info, _handler, node) => {\n checkNonJsdoc({}, null, node);\n if (!reportingNonJsdoc) {\n checkNonJsdocAfter(node, contextsBeforeAndAfter);\n }\n },\n ),\n };\n },\n meta: {\n docs: {\n description: 'Converts non-JSDoc comments preceding or following nodes into JSDoc ones',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/convert-to-jsdoc-comments.md#repos-sticky-header',\n },\n\n fixable: 'code',\n\n messages: {\n blockCommentsJsdocStyle: 'Block comments should be JSDoc-style.',\n lineCommentsJsdocStyle: 'Line comments should be JSDoc-style.',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n allowedPrefixes: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsAfter: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n contextsBeforeAndAfter: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n context: {\n type: 'string',\n },\n inlineCommentBlock: {\n type: 'boolean',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n enableFixer: {\n type: 'boolean',\n },\n enforceJsdocLineStyle: {\n enum: [\n 'multi', 'single',\n ],\n type: 'string',\n },\n lineOrBlockStyle: {\n enum: [\n 'block', 'line', 'both',\n ],\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n};\n"],"mappings":";;;;;;AAgBA,qCAAe;CACb,OAAQ,SAAS;;;;;;;;;;;;;;;;;EAmBf,MAAM,EACJ,aAAa,QAAQ,eAAe,EACrC,GAAG;EACJ,MAAM,WAAW,YAAY,QAAQ;AACrC,MAAI,CAAC,SACH,QAAO,CAAE;EAGX,MAAM,EACJ,kBAAkB;GAChB;GAAQ;GAAa;GAAO;GAAO;GAAU;EAC9C,GACD,WAAW,SAAS,YAAY,CAAE,GAClC,gBAAyC,CAAE,GAC3C,yBAAyB;GACvB;GAAsB;GAAuB;EAC9C,GACD,cAAc,MACd,wBAAwB,SACxB,mBAAmB,QACpB,GAAG,QAAQ,QAAQ,MAAM,CAAE;EAE5B,IAAI,oBAAoB;;;;;;;EAQxB,MAAM,SAAS,CAAC,WAAW,SAAS,MAAM,UAAU;GAClD,MAAM,MAAM;IACV,KAAK;KACH,QAAQ;KAGR,MAAO,QAAQ,KAAK,OAAO,QAAQ;IACpC;IACD,OAAO;KACL,QAAQ;KAGR,MAAO,QAAQ,KAAK,OAAO,QAAQ;IACpC;GACF;GAED,QAAQ,OAAO;IACb,KAAK,cAAc,QAAQ;IAC3B;IACA;IACA;GACD,EAAC;EACH;;;;;;;;;;;EAYD,MAAM,WAAW,CAAC,MAAM,SAAS,YAAY,UAAU;AACrD,UAAwD,CAAC,UAAU;IAEjE,MAAM,QAAQ,SAAS,aAAa,KAAK,SAAS,YAAY,IAAI,IAAI,SAAS;IAC/E,IAAI,WAIA,kBAAkB,MAAM,WAAW;IAGvC,MAAM,YAAY,aAEf,SACF;AACD,QAAI,WACF,WACE;IAIJ,MAAM,SAAS,UAAU,EACvB,MAAM,WAAW;KAC4B;;KAGE,SAAU,IACrD,MAAM;KACT,CACF,EAAC;IAEF,MAAM,EACJ,oBACD,GAOM,MAAO,KAAK,CAAC,WAAW;AAC3B,SAAI,OAAO,WAAW,SACpB,QAAO;KAGT,MAAM,EACJ,SAAS,MACV,GAAG;AACJ,YAAO,SAAS,KAAK;IACtB,EAAC,IAAI,CAAE;AAEV,WAAO,WAAW,oBAAoB,SAAS,QAAQ,OAAO,MAAM;GACrE;EACF;;;;;;;;;;;EAYD,MAAM,aAAa,CAAC,SAAS,MAAM,YAAY,UAAU;GACvD,MAAM,QAAQ,SAAS,MAAM,SAAS,YAAY,MAAM;AAExD,OAAI,QAAQ,SAAS,SAAS;AAC5B,QAAI,qBAAqB,OACvB;IAGF,OAAO,2BAA2B,SAAS,MAAM,MAAM;AACvD;GACD;AAED,OAAI,QAAQ,SAAS,QAAQ;AAC3B,QAAI,qBAAqB,QACvB;IAGF,OAAO,0BAA0B,SAAS,MAAM,MAAM;GACvD;EACF;;;;EAKD,MAAM,gBAAgB,CAAC,OAAO,UAAU,SAAS;GAC/C,MAAM,UAAU,mBAAmB,YAAY,MAAM,SAAS;AAE9D,OACE,CAAC,WAEA,gBAAiB,KAAK,CAAC,WAAW;AACjC,WAAO,QAAQ,MAAM,WAAW,CAAC,WAAW,OAAO;GACpD,EAAC,CAEF;GAGF,oBAAoB;;GAIpB,MAAM,aAAa,CAAC,oBAAoB,cAAc,QAAQ,OAAO,UAAU;IAC7E,MAAM,aACJ,sBAAsB,0BAA0B,WAC9C,CAAC,IAAI,EAAE,aAAa,MAAM,MAAM,CAAC,CAAC,CAAC,GACnC,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,aAAa,MAAM,SAAS,CAAC,EAAE,EAAE,QAAQ,IAE3D,CAAC,EAAE,EAAE,KAAK,QAAQ,SAAS,KAAK,EAAE,EAAE;AAExC,WAAO,MAAM,YAEV,cACD,UACD;GACF;GAED,WAAW,SAAS,MAAM,YAAY,SAAS;EAChD;;;;;EAMD,MAAM,qBAAqB,CAAC,MAAM,UAAU;GAC1C,MAAM,UAAU,oBAAoB,YAAY,KAAK;AAErD,OACE,CAAC,WACD,QAAQ,MAAM,WAAW,IAAI,IAE5B,gBAAiB,KAAK,CAAC,WAAW;AACjC,WAAO,QAAQ,MAAM,WAAW,CAAC,WAAW,OAAO;GACpD,EAAC,CAEF;;GAIF,MAAM,aAAa,CAAC,oBAAoB,cAAc,QAAQ,OAAO,UAAU;IAC7E,MAAM,aACJ,sBAAsB,0BAA0B,WAC9C,CAAC,IAAI,EAAE,aAAa,MAAM,MAAM,CAAC,CAAC,CAAC,GACnC,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,aAAa,MAAM,SAAS,CAAC,EAAE,EAAE,QAAQ,IAE3D,CAAC,EAAE,EAAE,KAAK,QAAQ,SAAS,KAAK,EAAE,GAAG,QAAQ,CAAC,EAAE,EAAE,OAAO,MAAM,EAAE,EAAE,GAAG,KAAK;AAE/E,WAAO,CACL,MAAM,OAEH,aACF,EAAE,MAAM,iBACP,KAAK,SAAS,uBAAuB,KAAK,SAAS,MACnD,UACD,AACF;GACF;GAED,WAAW,SAAS,MAAM,YAAY,MAAM;EAC7C;AAGD,SAAO;GACL,GAAG,iBACD,iBAAiB,SAAS,MAAM,SAAS,EACzC,cACD;GACD,GAAG,iBACD,eACA,CAAC,OAAO,UAAU,SAAS;IACzB,mBAAmB,MAAM,cAAc;GACxC,EACF;GACD,GAAG,iBACD,wBACA,CAAC,OAAO,UAAU,SAAS;IACzB,cAAc,CAAE,GAAE,MAAM,KAAK;AAC7B,QAAI,CAAC,mBACH,mBAAmB,MAAM,uBAAuB;GAEnD,EACF;EACF;CACF;CACD,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EAED,SAAS;EAET,UAAU;GACR,yBAAyB;GACzB,wBAAwB;EACzB;EACD,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY;IACV,iBAAiB;KACf,OAAO,EACL,MAAM,SACP;KACD,MAAM;IACP;IACD,UAAU;KACR,OAAO,EACL,OAAO,CACL,EACE,MAAM,SACP,GACD;MACE,sBAAsB;MACtB,YAAY;OACV,SAAS,EACP,MAAM,SACP;OACD,oBAAoB,EAClB,MAAM,UACP;MACF;MACD,MAAM;KACP,CACF,EACF;KACD,MAAM;IACP;IACD,eAAe;KACb,OAAO,EACL,OAAO,CACL,EACE,MAAM,SACP,GACD;MACE,sBAAsB;MACtB,YAAY;OACV,SAAS,EACP,MAAM,SACP;OACD,oBAAoB,EAClB,MAAM,UACP;MACF;MACD,MAAM;KACP,CACF,EACF;KACD,MAAM;IACP;IACD,wBAAwB;KACtB,OAAO,EACL,OAAO,CACL,EACE,MAAM,SACP,GACD;MACE,sBAAsB;MACtB,YAAY;OACV,SAAS,EACP,MAAM,SACP;OACD,oBAAoB,EAClB,MAAM,UACP;MACF;MACD,MAAM;KACP,CACF,EACF;KACD,MAAM;IACP;IACD,aAAa,EACX,MAAM,UACP;IACD,uBAAuB;KACrB,MAAM,CACJ,SAAS,QACV;KACD,MAAM;IACP;IACD,kBAAkB;KAChB,MAAM;MACJ;MAAS;MAAQ;KAClB;KACD,MAAM;IACP;GACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF"}
@@ -1,67 +0,0 @@
1
- import iterateJsdoc from "../iterateJsdoc.js";
2
-
3
- //#region src/rules/emptyTags.js
4
- const defaultEmptyTags = new Set([
5
- "abstract",
6
- "async",
7
- "generator",
8
- "global",
9
- "hideconstructor",
10
- "ignore",
11
- "inheritDoc",
12
- "inner",
13
- "instance",
14
- "internal",
15
- "overload",
16
- "override",
17
- "readonly"
18
- ]);
19
- const emptyIfNotClosure = new Set([
20
- "inheritdoc",
21
- "package",
22
- "private",
23
- "protected",
24
- "public",
25
- "static"
26
- ]);
27
- const emptyIfClosure = new Set(["interface"]);
28
- var emptyTags_default = iterateJsdoc(({ jsdoc, settings, utils }) => {
29
- const emptyTags = utils.filterTags(({ tag: tagName }) => {
30
- return defaultEmptyTags.has(tagName) || utils.hasOptionTag(tagName) && jsdoc.tags.some(({ tag }) => {
31
- return tag === tagName;
32
- }) || settings.mode === "closure" && emptyIfClosure.has(tagName) || settings.mode !== "closure" && emptyIfNotClosure.has(tagName);
33
- });
34
- for (const [key, tag] of emptyTags.entries()) {
35
- const content = tag.name || tag.description || tag.type;
36
- if (content.trim() && (key !== emptyTags.length - 1 || !/^\s*\*+$/v.test(content))) {
37
- const fix = () => {
38
- utils.setTag(tag);
39
- };
40
- utils.reportJSDoc(`@${tag.tag} should be empty.`, tag, fix, true);
41
- }
42
- }
43
- }, {
44
- checkInternal: true,
45
- checkPrivate: true,
46
- iterateAllJsdocs: true,
47
- meta: {
48
- docs: {
49
- description: "Expects specific tags to be empty of any content.",
50
- url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/empty-tags.md#repos-sticky-header"
51
- },
52
- fixable: "code",
53
- schema: [{
54
- additionalProperties: false,
55
- properties: { tags: {
56
- items: { type: "string" },
57
- type: "array"
58
- } },
59
- type: "object"
60
- }],
61
- type: "suggestion"
62
- }
63
- });
64
-
65
- //#endregion
66
- export { emptyTags_default as default };
67
- //# sourceMappingURL=emptyTags.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"emptyTags.js","names":[],"sources":["../../src/rules/emptyTags.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nconst defaultEmptyTags = new Set([\n 'abstract', 'async', 'generator', 'global', 'hideconstructor',\n\n // jsdoc doesn't use this form in its docs, but allow for compatibility with\n // TypeScript which allows and Closure which requires\n 'ignore',\n\n // jsdoc doesn't use but allow for TypeScript\n 'inheritDoc', 'inner', 'instance',\n 'internal',\n\n 'overload',\n\n 'override',\n 'readonly',\n]);\n\nconst emptyIfNotClosure = new Set([\n // Closure doesn't allow with this casing\n 'inheritdoc', 'package', 'private', 'protected', 'public',\n\n 'static',\n]);\n\nconst emptyIfClosure = new Set([\n 'interface',\n]);\n\nexport default iterateJsdoc(({\n jsdoc,\n settings,\n utils,\n}) => {\n const emptyTags = utils.filterTags(({\n tag: tagName,\n }) => {\n return defaultEmptyTags.has(tagName) ||\n utils.hasOptionTag(tagName) && jsdoc.tags.some(({\n tag,\n }) => {\n return tag === tagName;\n }) ||\n settings.mode === 'closure' && emptyIfClosure.has(tagName) ||\n settings.mode !== 'closure' && emptyIfNotClosure.has(tagName);\n });\n\n for (const [\n key,\n tag,\n ] of emptyTags.entries()) {\n const content = tag.name || tag.description || tag.type;\n if (content.trim() && (\n // Allow for JSDoc-block final asterisks\n key !== emptyTags.length - 1 || !(/^\\s*\\*+$/v).test(content)\n )) {\n const fix = () => {\n // By time of call in fixer, `tag` will have `line` added\n utils.setTag(\n /**\n * @type {import('comment-parser').Spec & {\n * line: import('../iterateJsdoc.js').Integer\n * }}\n */ (tag),\n );\n };\n\n utils.reportJSDoc(`@${tag.tag} should be empty.`, tag, fix, true);\n }\n }\n}, {\n checkInternal: true,\n checkPrivate: true,\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Expects specific tags to be empty of any content.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/empty-tags.md#repos-sticky-header',\n },\n fixable: 'code',\n schema: [\n {\n additionalProperties: false,\n properties: {\n tags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;AAEA,MAAM,mBAAmB,IAAI,IAAI;CAC/B;CAAY;CAAS;CAAa;CAAU;CAI5C;CAGA;CAAc;CAAS;CACvB;CAEA;CAEA;CACA;AACD;AAED,MAAM,oBAAoB,IAAI,IAAI;CAEhC;CAAc;CAAW;CAAW;CAAa;CAEjD;AACD;AAED,MAAM,iBAAiB,IAAI,IAAI,CAC7B,WACD;AAED,wBAAe,aAAa,CAAC,EAC3B,OACA,UACA,OACD,KAAK;CACJ,MAAM,YAAY,MAAM,WAAW,CAAC,EAClC,KAAK,SACN,KAAK;AACJ,SAAO,iBAAiB,IAAI,QAAQ,IAClC,MAAM,aAAa,QAAQ,IAAI,MAAM,KAAK,KAAK,CAAC,EAC9C,KACD,KAAK;AACJ,UAAO,QAAQ;EAChB,EAAC,IACF,SAAS,SAAS,aAAa,eAAe,IAAI,QAAQ,IAC1D,SAAS,SAAS,aAAa,kBAAkB,IAAI,QAAQ;CAChE,EAAC;AAEF,MAAK,MAAM,CACT,KACA,IACD,IAAI,UAAU,SAAS,EAAE;EACxB,MAAM,UAAU,IAAI,QAAQ,IAAI,eAAe,IAAI;AACnD,MAAI,QAAQ,MAAM,KAEhB,QAAQ,UAAU,SAAS,KAAK,CAAE,YAAa,KAAK,QAAQ,GAC3D;GACD,MAAM,MAAM,MAAM;IAEhB,MAAM,OAKC,IACN;GACF;GAED,MAAM,YAAY,CAAC,CAAC,EAAE,IAAI,IAAI,iBAAiB,CAAC,EAAE,KAAK,KAAK,KAAK;EAClE;CACF;AACF,GAAE;CACD,eAAe;CACf,cAAc;CACd,kBAAkB;CAClB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,SAAS;EACT,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY,EACV,MAAM;IACJ,OAAO,EACL,MAAM,SACP;IACD,MAAM;GACP,EACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}
@@ -1,40 +0,0 @@
1
- import iterateJsdoc from "../iterateJsdoc.js";
2
-
3
- //#region src/rules/implementsOnClasses.js
4
- var implementsOnClasses_default = iterateJsdoc(({ report, utils }) => {
5
- const iteratingFunction = utils.isIteratingFunctionOrVariable();
6
- if (iteratingFunction) {
7
- if (utils.hasATag(["class", "constructor"]) || utils.isConstructor()) return;
8
- } else if (!utils.isVirtualFunction()) return;
9
- utils.forEachPreferredTag("implements", (tag) => {
10
- report("@implements used on a non-constructor function", null, tag);
11
- });
12
- }, {
13
- contextDefaults: true,
14
- meta: {
15
- docs: {
16
- description: "Reports an issue with any non-constructor function using `@implements`.",
17
- url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/implements-on-classes.md#repos-sticky-header"
18
- },
19
- schema: [{
20
- additionalProperties: false,
21
- properties: { contexts: {
22
- items: { anyOf: [{ type: "string" }, {
23
- additionalProperties: false,
24
- properties: {
25
- comment: { type: "string" },
26
- context: { type: "string" }
27
- },
28
- type: "object"
29
- }] },
30
- type: "array"
31
- } },
32
- type: "object"
33
- }],
34
- type: "suggestion"
35
- }
36
- });
37
-
38
- //#endregion
39
- export { implementsOnClasses_default as default };
40
- //# sourceMappingURL=implementsOnClasses.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"implementsOnClasses.js","names":[],"sources":["../../src/rules/implementsOnClasses.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\nexport default iterateJsdoc(({\n report,\n utils,\n}) => {\n const iteratingFunction = utils.isIteratingFunctionOrVariable();\n\n if (iteratingFunction) {\n if (utils.hasATag([\n 'class',\n 'constructor',\n ]) ||\n utils.isConstructor()\n ) {\n return;\n }\n } else if (!utils.isVirtualFunction()) {\n return;\n }\n\n utils.forEachPreferredTag('implements', (tag) => {\n report('@implements used on a non-constructor function', null, tag);\n });\n}, {\n contextDefaults: true,\n meta: {\n docs: {\n description: 'Reports an issue with any non-constructor function using `@implements`.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/implements-on-classes.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n contexts: {\n items: {\n anyOf: [\n {\n type: 'string',\n },\n {\n additionalProperties: false,\n properties: {\n comment: {\n type: 'string',\n },\n context: {\n type: 'string',\n },\n },\n type: 'object',\n },\n ],\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;AAEA,kCAAe,aAAa,CAAC,EAC3B,QACA,OACD,KAAK;CACJ,MAAM,oBAAoB,MAAM,+BAA+B;AAE/D,KAAI,mBACF;MAAI,MAAM,QAAQ,CAChB,SACA,aACD,EAAC,IACA,MAAM,eAAe,CAErB;CACD,WACQ,CAAC,MAAM,mBAAmB,CACnC;CAGF,MAAM,oBAAoB,cAAc,CAAC,QAAQ;EAC/C,OAAO,kDAAkD,MAAM,IAAI;CACpE,EAAC;AACH,GAAE;CACD,iBAAiB;CACjB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY,EACV,UAAU;IACR,OAAO,EACL,OAAO,CACL,EACE,MAAM,SACP,GACD;KACE,sBAAsB;KACtB,YAAY;MACV,SAAS,EACP,MAAM,SACP;MACD,SAAS,EACP,MAAM,SACP;KACF;KACD,MAAM;IACP,CACF,EACF;IACD,MAAM;GACP,EACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}
@@ -1,68 +0,0 @@
1
- import iterateJsdoc from "../iterateJsdoc.js";
2
- import { isBuiltin } from "node:module";
3
- import { parse, traverse, tryParse } from "@es-joy/jsdoccomment";
4
- import { readFileSync } from "fs";
5
- import { join } from "path";
6
-
7
- //#region src/rules/importsAsDependencies.js
8
- /**
9
- * @type {Set<string>|null}
10
- */
11
- let deps;
12
- const setDeps = function() {
13
- try {
14
- const pkg = JSON.parse(readFileSync(join(process.cwd(), "./package.json")));
15
- deps = new Set([...pkg.dependencies ? Object.keys(pkg.dependencies) : [], ...pkg.devDependencies ? Object.keys(pkg.devDependencies) : []]);
16
- } catch (error) {
17
- /* c8 ignore next -- our package.json exists */
18
- deps = null;
19
- /* c8 ignore next 4 -- our package.json exists */
20
- console.log(error);
21
- }
22
- };
23
- const moduleCheck = /* @__PURE__ */ new Map();
24
- var importsAsDependencies_default = iterateJsdoc(({ jsdoc, settings, utils }) => {
25
- if (deps === void 0) setDeps();
26
- /* c8 ignore next 3 -- our package.json exists */
27
- if (deps === null) return;
28
- const { mode } = settings;
29
- for (const tag of jsdoc.tags) {
30
- let typeAst;
31
- try {
32
- typeAst = mode === "permissive" ? tryParse(tag.type) : parse(tag.type, mode);
33
- } catch {
34
- continue;
35
- }
36
- traverse(typeAst, (nde) => {
37
- /* c8 ignore next 3 -- TS guard */
38
- if (deps === null) return;
39
- if (nde.type === "JsdocTypeImport") {
40
- let mod = nde.element.value.replace(/^(@[^\/]+\/[^\/]+|[^\/]+).*$/v, "$1");
41
- if (/^[.\/]/v.test(mod)) return;
42
- if (isBuiltin(mod)) return;
43
- else if (!moduleCheck.has(mod)) {
44
- let pkg;
45
- try {
46
- pkg = JSON.parse(readFileSync(join(process.cwd(), "node_modules", mod, "./package.json")));
47
- } catch {}
48
- if (!pkg || !pkg.types && !pkg.typings) mod = `@types/${mod}`;
49
- moduleCheck.set(mod, !deps.has(mod));
50
- }
51
- if (moduleCheck.get(mod)) utils.reportJSDoc("import points to package which is not found in dependencies", tag);
52
- }
53
- });
54
- }
55
- }, {
56
- iterateAllJsdocs: true,
57
- meta: {
58
- docs: {
59
- description: "Reports if JSDoc `import()` statements point to a package which is not listed in `dependencies` or `devDependencies`",
60
- url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/imports-as-dependencies.md#repos-sticky-header"
61
- },
62
- type: "suggestion"
63
- }
64
- });
65
-
66
- //#endregion
67
- export { importsAsDependencies_default as default };
68
- //# sourceMappingURL=importsAsDependencies.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"importsAsDependencies.js","names":["isBuiltinModule"],"sources":["../../src/rules/importsAsDependencies.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n parse,\n traverse,\n tryParse,\n} from '@es-joy/jsdoccomment';\nimport {\n readFileSync,\n} from 'fs';\nimport {\n isBuiltin as isBuiltinModule,\n} from 'node:module';\nimport {\n join,\n} from 'path';\n\n/**\n * @type {Set<string>|null}\n */\nlet deps;\n\nconst setDeps = function () {\n try {\n const pkg = JSON.parse(\n // @ts-expect-error It's ok\n readFileSync(join(process.cwd(), './package.json')),\n );\n deps = new Set([\n ...(pkg.dependencies ?\n /* c8 ignore next 2 */\n Object.keys(pkg.dependencies) :\n []),\n ...(pkg.devDependencies ?\n /* c8 ignore next 2 */\n Object.keys(pkg.devDependencies) :\n []),\n ]);\n /* c8 ignore next -- our package.json exists */\n } catch (error) {\n /* c8 ignore next -- our package.json exists */\n deps = null;\n /* c8 ignore next 4 -- our package.json exists */\n /* eslint-disable no-console -- Inform user */\n console.log(error);\n /* eslint-enable no-console -- Inform user */\n }\n};\n\nconst moduleCheck = new Map();\n\nexport default iterateJsdoc(({\n jsdoc,\n settings,\n utils,\n}) => {\n if (deps === undefined) {\n setDeps();\n }\n\n /* c8 ignore next 3 -- our package.json exists */\n if (deps === null) {\n return;\n }\n\n const {\n mode,\n } = settings;\n\n for (const tag of jsdoc.tags) {\n let typeAst;\n try {\n typeAst = mode === 'permissive' ? tryParse(tag.type) : parse(tag.type, mode);\n } catch {\n continue;\n }\n\n // eslint-disable-next-line no-loop-func -- Safe\n traverse(typeAst, (nde) => {\n /* c8 ignore next 3 -- TS guard */\n if (deps === null) {\n return;\n }\n\n if (nde.type === 'JsdocTypeImport') {\n let mod = nde.element.value.replace(\n /^(@[^\\/]+\\/[^\\/]+|[^\\/]+).*$/v, '$1',\n );\n\n if ((/^[.\\/]/v).test(mod)) {\n return;\n }\n\n if (isBuiltinModule(mod)) {\n // mod = '@types/node';\n // moduleCheck.set(mod, !deps.has(mod));\n return;\n } else if (!moduleCheck.has(mod)) {\n let pkg;\n try {\n pkg = JSON.parse(\n // @ts-expect-error It's ok\n readFileSync(join(process.cwd(), 'node_modules', mod, './package.json')),\n );\n } catch {\n // Ignore\n }\n\n if (!pkg || (!pkg.types && !pkg.typings)) {\n mod = `@types/${mod}`;\n }\n\n moduleCheck.set(mod, !deps.has(mod));\n }\n\n if (moduleCheck.get(mod)) {\n utils.reportJSDoc(\n 'import points to package which is not found in dependencies',\n tag,\n );\n }\n }\n });\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description: 'Reports if JSDoc `import()` statements point to a package which is not listed in `dependencies` or `devDependencies`',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/imports-as-dependencies.md#repos-sticky-header',\n },\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;;;;;;;AAmBA,IAAI;AAEJ,MAAM,UAAU,WAAY;AAC1B,KAAI;EACF,MAAM,MAAM,KAAK,MAEf,aAAa,KAAK,QAAQ,KAAK,EAAE,iBAAiB,CAAC,CACpD;EACD,OAAO,IAAI,IAAI,CACb,GAAI,IAAI,eAEN,OAAO,KAAK,IAAI,aAAa,GAC7B,CAAE,GACJ,GAAI,IAAI,kBAEN,OAAO,KAAK,IAAI,gBAAgB,GAChC,CAAE,CACL;CAEF,SAAQ,OAAO;;EAEd,OAAO;;EAGP,QAAQ,IAAI,MAAM;CAEnB;AACF;AAED,MAAM,8BAAc,IAAI;AAExB,oCAAe,aAAa,CAAC,EAC3B,OACA,UACA,OACD,KAAK;AACJ,KAAI,SAAS,QACX,SAAS;;AAIX,KAAI,SAAS,KACX;CAGF,MAAM,EACJ,MACD,GAAG;AAEJ,MAAK,MAAM,OAAO,MAAM,MAAM;EAC5B,IAAI;AACJ,MAAI;GACF,UAAU,SAAS,eAAe,SAAS,IAAI,KAAK,GAAG,MAAM,IAAI,MAAM,KAAK;EAC7E,QAAO;AACN;EACD;EAGD,SAAS,SAAS,CAAC,QAAQ;;AAEzB,OAAI,SAAS,KACX;AAGF,OAAI,IAAI,SAAS,mBAAmB;IAClC,IAAI,MAAM,IAAI,QAAQ,MAAM,QAC1B,iCAAiC,KAClC;AAED,QAAK,UAAW,KAAK,IAAI,CACvB;AAGF,QAAIA,UAAgB,IAAI,CAGtB;aACS,CAAC,YAAY,IAAI,IAAI,EAAE;KAChC,IAAI;AACJ,SAAI;MACF,MAAM,KAAK,MAET,aAAa,KAAK,QAAQ,KAAK,EAAE,gBAAgB,KAAK,iBAAiB,CAAC,CACzE;KACF,QAAO,CAEP;AAED,SAAI,CAAC,OAAQ,CAAC,IAAI,SAAS,CAAC,IAAI,SAC9B,MAAM,CAAC,OAAO,EAAE,KAAK;KAGvB,YAAY,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,CAAC;IACrC;AAED,QAAI,YAAY,IAAI,IAAI,EACtB,MAAM,YACJ,+DACA,IACD;GAEJ;EACF,EAAC;CACH;AACF,GAAE;CACD,kBAAkB;CAClB,MAAM;EACJ,MAAM;GACJ,aAAa;GACb,KAAK;EACN;EACD,MAAM;CACP;AACF,EAAC"}
@@ -1,110 +0,0 @@
1
- import iterateJsdoc from "../iterateJsdoc.js";
2
- import { areDocsInformative } from "are-docs-informative";
3
-
4
- //#region src/rules/informativeDocs.js
5
- const defaultAliases = { a: ["an", "our"] };
6
- const defaultUselessWords = [
7
- "a",
8
- "an",
9
- "i",
10
- "in",
11
- "of",
12
- "s",
13
- "the"
14
- ];
15
- /**
16
- * @param {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node|null|undefined} node
17
- * @returns {string[]}
18
- */
19
- const getNamesFromNode = (node) => {
20
- switch (node?.type) {
21
- case "AccessorProperty":
22
- case "MethodDefinition":
23
- case "PropertyDefinition":
24
- case "TSAbstractAccessorProperty":
25
- case "TSAbstractMethodDefinition":
26
- case "TSAbstractPropertyDefinition": return [...getNamesFromNode(
27
- /** @type {import('@typescript-eslint/types').TSESTree.Node} */
28
- node.parent.parent
29
- ), ...getNamesFromNode(node.key)];
30
- case "ClassDeclaration":
31
- case "ClassExpression":
32
- case "FunctionDeclaration":
33
- case "FunctionExpression":
34
- case "TSDeclareFunction":
35
- case "TSEnumDeclaration":
36
- case "TSEnumMember":
37
- case "TSInterfaceDeclaration":
38
- case "TSMethodSignature":
39
- case "TSModuleDeclaration":
40
- case "TSTypeAliasDeclaration": return getNamesFromNode(
41
- /** @type {import('@typescript-eslint/types').TSESTree.ClassDeclaration} */
42
- node.id
43
- );
44
- case "ExportDefaultDeclaration":
45
- case "ExportNamedDeclaration": return getNamesFromNode(
46
- /** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */
47
- node.declaration
48
- );
49
- case "Identifier": return [node.name];
50
- case "Property": return getNamesFromNode(node.key);
51
- case "VariableDeclaration": return getNamesFromNode(node.declarations[0]);
52
- case "VariableDeclarator": return [...getNamesFromNode(node.id), ...getNamesFromNode(node.init)].filter(Boolean);
53
- default: return [];
54
- }
55
- };
56
- var informativeDocs_default = iterateJsdoc(({ context, jsdoc, node, report, utils }) => {
57
- const { aliases = defaultAliases, excludedTags = [], uselessWords = defaultUselessWords } = context.options[0] || {};
58
- const nodeNames = getNamesFromNode(node);
59
- /**
60
- * @param {string} text
61
- * @param {string} extraName
62
- * @returns {boolean}
63
- */
64
- const descriptionIsRedundant = (text, extraName = "") => {
65
- const textTrimmed = text.trim();
66
- return Boolean(textTrimmed) && !areDocsInformative(textTrimmed, [extraName, nodeNames].filter(Boolean).join(" "), {
67
- aliases,
68
- uselessWords
69
- });
70
- };
71
- const { description, lastDescriptionLine } = utils.getDescription();
72
- let descriptionReported = false;
73
- for (const tag of jsdoc.tags) {
74
- if (excludedTags.includes(tag.tag)) continue;
75
- if (descriptionIsRedundant(tag.description, tag.name)) utils.reportJSDoc("This tag description only repeats the name it describes.", tag);
76
- descriptionReported ||= tag.description === description && tag.line === lastDescriptionLine;
77
- }
78
- if (!descriptionReported && descriptionIsRedundant(description)) report("This description only repeats the name it describes.");
79
- }, {
80
- iterateAllJsdocs: true,
81
- meta: {
82
- docs: {
83
- description: "This rule reports doc comments that only restate their attached name.",
84
- url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/informative-docs.md#repos-sticky-header"
85
- },
86
- schema: [{
87
- additionalProperties: false,
88
- properties: {
89
- aliases: { patternProperties: { ".*": {
90
- items: { type: "string" },
91
- type: "array"
92
- } } },
93
- excludedTags: {
94
- items: { type: "string" },
95
- type: "array"
96
- },
97
- uselessWords: {
98
- items: { type: "string" },
99
- type: "array"
100
- }
101
- },
102
- type: "object"
103
- }],
104
- type: "suggestion"
105
- }
106
- });
107
-
108
- //#endregion
109
- export { informativeDocs_default as default };
110
- //# sourceMappingURL=informativeDocs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"informativeDocs.js","names":[],"sources":["../../src/rules/informativeDocs.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\nimport {\n areDocsInformative,\n} from 'are-docs-informative';\n\nconst defaultAliases = {\n a: [\n 'an', 'our',\n ],\n};\n\nconst defaultUselessWords = [\n 'a', 'an', 'i', 'in', 'of', 's', 'the',\n];\n\n/* eslint-disable complexity -- Temporary */\n\n/**\n * @param {import('eslint').Rule.Node|import('@typescript-eslint/types').TSESTree.Node|null|undefined} node\n * @returns {string[]}\n */\nconst getNamesFromNode = (node) => {\n switch (node?.type) {\n case 'AccessorProperty':\n case 'MethodDefinition':\n case 'PropertyDefinition':\n case 'TSAbstractAccessorProperty':\n case 'TSAbstractMethodDefinition':\n case 'TSAbstractPropertyDefinition':\n return [\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */ (\n node.parent\n ).parent,\n ),\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.key),\n ),\n ];\n\n case 'ClassDeclaration':\n case 'ClassExpression':\n case 'FunctionDeclaration':\n case 'FunctionExpression':\n case 'TSDeclareFunction':\n case 'TSEnumDeclaration':\n case 'TSEnumMember':\n case 'TSInterfaceDeclaration':\n case 'TSMethodSignature':\n case 'TSModuleDeclaration':\n case 'TSTypeAliasDeclaration':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.ClassDeclaration} */\n (node).id,\n );\n case 'ExportDefaultDeclaration':\n case 'ExportNamedDeclaration':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.ExportNamedDeclaration} */\n (node).declaration,\n );\n case 'Identifier':\n return [\n node.name,\n ];\n case 'Property':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.key),\n );\n case 'VariableDeclaration':\n return getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.declarations[0]),\n );\n case 'VariableDeclarator':\n return [\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.id),\n ),\n ...getNamesFromNode(\n /** @type {import('@typescript-eslint/types').TSESTree.Node} */\n (node.init),\n ),\n ].filter(Boolean);\n default:\n return [];\n }\n};\n/* eslint-enable complexity -- Temporary */\n\nexport default iterateJsdoc(({\n context,\n jsdoc,\n node,\n report,\n utils,\n}) => {\n const /** @type {{aliases: {[key: string]: string[]}, excludedTags: string[], uselessWords: string[]}} */ {\n aliases = defaultAliases,\n excludedTags = [],\n uselessWords = defaultUselessWords,\n } = context.options[0] || {};\n const nodeNames = getNamesFromNode(node);\n\n /**\n * @param {string} text\n * @param {string} extraName\n * @returns {boolean}\n */\n const descriptionIsRedundant = (text, extraName = '') => {\n const textTrimmed = text.trim();\n return Boolean(textTrimmed) && !areDocsInformative(textTrimmed, [\n extraName, nodeNames,\n ].filter(Boolean).join(' '), {\n aliases,\n uselessWords,\n });\n };\n\n const {\n description,\n lastDescriptionLine,\n } = utils.getDescription();\n let descriptionReported = false;\n\n for (const tag of jsdoc.tags) {\n if (excludedTags.includes(tag.tag)) {\n continue;\n }\n\n if (descriptionIsRedundant(tag.description, tag.name)) {\n utils.reportJSDoc(\n 'This tag description only repeats the name it describes.',\n tag,\n );\n }\n\n descriptionReported ||= tag.description === description &&\n /** @type {import('comment-parser').Spec & {line: import('../iterateJsdoc.js').Integer}} */\n (tag).line === lastDescriptionLine;\n }\n\n if (!descriptionReported && descriptionIsRedundant(description)) {\n report('This description only repeats the name it describes.');\n }\n}, {\n iterateAllJsdocs: true,\n meta: {\n docs: {\n description:\n 'This rule reports doc comments that only restate their attached name.',\n url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/informative-docs.md#repos-sticky-header',\n },\n schema: [\n {\n additionalProperties: false,\n properties: {\n aliases: {\n patternProperties: {\n '.*': {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n },\n excludedTags: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n uselessWords: {\n items: {\n type: 'string',\n },\n type: 'array',\n },\n },\n type: 'object',\n },\n ],\n type: 'suggestion',\n },\n});\n"],"mappings":";;;;AAKA,MAAM,iBAAiB,EACrB,GAAG,CACD,MAAM,KACP,EACF;AAED,MAAM,sBAAsB;CAC1B;CAAK;CAAM;CAAK;CAAM;CAAM;CAAK;AAClC;;;;;AAQD,MAAM,mBAAmB,CAAC,SAAS;AACjC,SAAQ,MAAM,MAAd;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,+BACH,QAAO,CACL,GAAG;;GAEC,KAAK,OACL;GACH,EACD,GAAG,iBAEA,KAAK,IACP,AACF;EAEH,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,yBACH,QAAO;;GAEJ,KAAM;GACR;EACH,KAAK;EACL,KAAK,yBACH,QAAO;;GAEJ,KAAM;GACR;EACH,KAAK,aACH,QAAO,CACL,KAAK,IACN;EACH,KAAK,WACH,QAAO,iBAEJ,KAAK,IACP;EACH,KAAK,sBACH,QAAO,iBAEJ,KAAK,aAAa,GACpB;EACH,KAAK,qBACH,QAAO,CACL,GAAG,iBAEA,KAAK,GACP,EACD,GAAG,iBAEA,KAAK,KACP,AACF,EAAC,OAAO,QAAQ;EACnB,QACE,QAAO,CAAE;CACZ;AACF;AAGD,8BAAe,aAAa,CAAC,EAC3B,SACA,OACA,MACA,QACA,OACD,KAAK;CACJ,MAA0G,EACxG,UAAU,gBACV,eAAe,CAAE,GACjB,eAAe,qBAChB,GAAG,QAAQ,QAAQ,MAAM,CAAE;CAC5B,MAAM,YAAY,iBAAiB,KAAK;;;;;;CAOxC,MAAM,yBAAyB,CAAC,MAAM,YAAY,OAAO;EACvD,MAAM,cAAc,KAAK,MAAM;AAC/B,SAAO,QAAQ,YAAY,IAAI,CAAC,mBAAmB,aAAa,CAC9D,WAAW,SACZ,EAAC,OAAO,QAAQ,CAAC,KAAK,IAAI,EAAE;GAC3B;GACA;EACD,EAAC;CACH;CAED,MAAM,EACJ,aACA,qBACD,GAAG,MAAM,gBAAgB;CAC1B,IAAI,sBAAsB;AAE1B,MAAK,MAAM,OAAO,MAAM,MAAM;AAC5B,MAAI,aAAa,SAAS,IAAI,IAAI,CAChC;AAGF,MAAI,uBAAuB,IAAI,aAAa,IAAI,KAAK,EACnD,MAAM,YACJ,4DACA,IACD;EAGH,wBAAwB,IAAI,gBAAgB,eAEzC,IAAK,SAAS;CAClB;AAED,KAAI,CAAC,uBAAuB,uBAAuB,YAAY,EAC7D,OAAO,uDAAuD;AAEjE,GAAE;CACD,kBAAkB;CAClB,MAAM;EACJ,MAAM;GACJ,aACE;GACF,KAAK;EACN;EACD,QAAQ,CACN;GACE,sBAAsB;GACtB,YAAY;IACV,SAAS,EACP,mBAAmB,EACjB,MAAM;KACJ,OAAO,EACL,MAAM,SACP;KACD,MAAM;IACP,EACF,EACF;IACD,cAAc;KACZ,OAAO,EACL,MAAM,SACP;KACD,MAAM;IACP;IACD,cAAc;KACZ,OAAO,EACL,MAAM,SACP;KACD,MAAM;IACP;GACF;GACD,MAAM;EACP,CACF;EACD,MAAM;CACP;AACF,EAAC"}