eslint-plugin-jsdoc 52.0.2 → 52.0.3

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 (357) hide show
  1. package/dist/WarnSettings.cjs +18 -35
  2. package/dist/WarnSettings.cjs.map +1 -1
  3. package/dist/WarnSettings.js +20 -0
  4. package/dist/WarnSettings.js.map +1 -0
  5. package/dist/_virtual/rolldown_runtime.cjs +32 -0
  6. package/dist/_virtual/rolldown_runtime.js +11 -0
  7. package/dist/alignTransform.cjs +224 -305
  8. package/dist/alignTransform.cjs.map +1 -1
  9. package/dist/alignTransform.js +241 -0
  10. package/dist/alignTransform.js.map +1 -0
  11. package/dist/defaultTagOrder.cjs +132 -43
  12. package/dist/defaultTagOrder.cjs.map +1 -1
  13. package/dist/defaultTagOrder.js +134 -0
  14. package/dist/defaultTagOrder.js.map +1 -0
  15. package/dist/exportParser.cjs +478 -696
  16. package/dist/exportParser.cjs.map +1 -1
  17. package/dist/exportParser.js +518 -0
  18. package/dist/exportParser.js.map +1 -0
  19. package/dist/getDefaultTagStructureForMode.cjs +184 -288
  20. package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
  21. package/dist/getDefaultTagStructureForMode.js +188 -0
  22. package/dist/getDefaultTagStructureForMode.js.map +1 -0
  23. package/dist/getJsdocProcessorPlugin.cjs +364 -550
  24. package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
  25. package/dist/getJsdocProcessorPlugin.d.cts +70 -0
  26. package/dist/getJsdocProcessorPlugin.d.cts.map +1 -0
  27. package/dist/getJsdocProcessorPlugin.d.ts +68 -65
  28. package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
  29. package/dist/getJsdocProcessorPlugin.js +383 -0
  30. package/dist/getJsdocProcessorPlugin.js.map +1 -0
  31. package/dist/index.cjs +398 -383
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +22 -0
  34. package/dist/index.d.cts.map +1 -0
  35. package/dist/index.d.ts +11 -6
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +425 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/iterateJsdoc.cjs +1528 -1988
  40. package/dist/iterateJsdoc.cjs.map +1 -1
  41. package/dist/iterateJsdoc.d.cts +471 -0
  42. package/dist/iterateJsdoc.d.cts.map +1 -0
  43. package/dist/iterateJsdoc.d.ts +358 -349
  44. package/dist/iterateJsdoc.d.ts.map +1 -1
  45. package/dist/iterateJsdoc.js +1617 -0
  46. package/dist/iterateJsdoc.js.map +1 -0
  47. package/dist/jsdocUtils.cjs +1009 -1376
  48. package/dist/jsdocUtils.cjs.map +1 -1
  49. package/dist/jsdocUtils.js +1123 -0
  50. package/dist/jsdocUtils.js.map +1 -0
  51. package/dist/rules/checkAccess.cjs +29 -36
  52. package/dist/rules/checkAccess.cjs.map +1 -1
  53. package/dist/rules/checkAccess.js +33 -0
  54. package/dist/rules/checkAccess.js.map +1 -0
  55. package/dist/rules/checkAlignment.cjs +41 -54
  56. package/dist/rules/checkAlignment.cjs.map +1 -1
  57. package/dist/rules/checkAlignment.js +47 -0
  58. package/dist/rules/checkAlignment.js.map +1 -0
  59. package/dist/rules/checkExamples.cjs +327 -484
  60. package/dist/rules/checkExamples.cjs.map +1 -1
  61. package/dist/rules/checkExamples.js +348 -0
  62. package/dist/rules/checkExamples.js.map +1 -0
  63. package/dist/rules/checkIndentation.cjs +50 -65
  64. package/dist/rules/checkIndentation.cjs.map +1 -1
  65. package/dist/rules/checkIndentation.js +59 -0
  66. package/dist/rules/checkIndentation.js.map +1 -0
  67. package/dist/rules/checkLineAlignment.cjs +220 -311
  68. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  69. package/dist/rules/checkLineAlignment.js +229 -0
  70. package/dist/rules/checkLineAlignment.js.map +1 -0
  71. package/dist/rules/checkParamNames.cjs +227 -335
  72. package/dist/rules/checkParamNames.cjs.map +1 -1
  73. package/dist/rules/checkParamNames.js +237 -0
  74. package/dist/rules/checkParamNames.js.map +1 -0
  75. package/dist/rules/checkPropertyNames.cjs +78 -106
  76. package/dist/rules/checkPropertyNames.cjs.map +1 -1
  77. package/dist/rules/checkPropertyNames.js +88 -0
  78. package/dist/rules/checkPropertyNames.js.map +1 -0
  79. package/dist/rules/checkSyntax.cjs +21 -34
  80. package/dist/rules/checkSyntax.cjs.map +1 -1
  81. package/dist/rules/checkSyntax.js +25 -0
  82. package/dist/rules/checkSyntax.js.map +1 -0
  83. package/dist/rules/checkTagNames.cjs +188 -210
  84. package/dist/rules/checkTagNames.cjs.map +1 -1
  85. package/dist/rules/checkTagNames.js +191 -0
  86. package/dist/rules/checkTagNames.js.map +1 -0
  87. package/dist/rules/checkTemplateNames.cjs +121 -178
  88. package/dist/rules/checkTemplateNames.cjs.map +1 -1
  89. package/dist/rules/checkTemplateNames.js +124 -0
  90. package/dist/rules/checkTemplateNames.js.map +1 -0
  91. package/dist/rules/checkTypes.cjs +291 -385
  92. package/dist/rules/checkTypes.cjs.map +1 -1
  93. package/dist/rules/checkTypes.js +299 -0
  94. package/dist/rules/checkTypes.js.map +1 -0
  95. package/dist/rules/checkValues.cjs +100 -146
  96. package/dist/rules/checkValues.cjs.map +1 -1
  97. package/dist/rules/checkValues.js +103 -0
  98. package/dist/rules/checkValues.js.map +1 -0
  99. package/dist/rules/convertToJsdocComments.cjs +228 -306
  100. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  101. package/dist/rules/convertToJsdocComments.js +231 -0
  102. package/dist/rules/convertToJsdocComments.js.map +1 -0
  103. package/dist/rules/emptyTags.cjs +62 -72
  104. package/dist/rules/emptyTags.cjs.map +1 -1
  105. package/dist/rules/emptyTags.js +67 -0
  106. package/dist/rules/emptyTags.js.map +1 -0
  107. package/dist/rules/implementsOnClasses.cjs +36 -56
  108. package/dist/rules/implementsOnClasses.cjs.map +1 -1
  109. package/dist/rules/implementsOnClasses.js +40 -0
  110. package/dist/rules/implementsOnClasses.js.map +1 -0
  111. package/dist/rules/importsAsDependencies.cjs +62 -99
  112. package/dist/rules/importsAsDependencies.cjs.map +1 -1
  113. package/dist/rules/importsAsDependencies.js +68 -0
  114. package/dist/rules/importsAsDependencies.js.map +1 -0
  115. package/dist/rules/informativeDocs.cjs +105 -142
  116. package/dist/rules/informativeDocs.cjs.map +1 -1
  117. package/dist/rules/informativeDocs.js +110 -0
  118. package/dist/rules/informativeDocs.js.map +1 -0
  119. package/dist/rules/linesBeforeBlock.cjs +70 -105
  120. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  121. package/dist/rules/linesBeforeBlock.js +75 -0
  122. package/dist/rules/linesBeforeBlock.js.map +1 -0
  123. package/dist/rules/matchDescription.cjs +160 -222
  124. package/dist/rules/matchDescription.cjs.map +1 -1
  125. package/dist/rules/matchDescription.js +167 -0
  126. package/dist/rules/matchDescription.js.map +1 -0
  127. package/dist/rules/matchName.cjs +73 -128
  128. package/dist/rules/matchName.cjs.map +1 -1
  129. package/dist/rules/matchName.js +77 -0
  130. package/dist/rules/matchName.js.map +1 -0
  131. package/dist/rules/multilineBlocks.cjs +235 -352
  132. package/dist/rules/multilineBlocks.cjs.map +1 -1
  133. package/dist/rules/multilineBlocks.js +245 -0
  134. package/dist/rules/multilineBlocks.js.map +1 -0
  135. package/dist/rules/noBadBlocks.cjs +63 -86
  136. package/dist/rules/noBadBlocks.cjs.map +1 -1
  137. package/dist/rules/noBadBlocks.js +68 -0
  138. package/dist/rules/noBadBlocks.js.map +1 -0
  139. package/dist/rules/noBlankBlockDescriptions.cjs +35 -57
  140. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
  141. package/dist/rules/noBlankBlockDescriptions.js +41 -0
  142. package/dist/rules/noBlankBlockDescriptions.js.map +1 -0
  143. package/dist/rules/noBlankBlocks.cjs +26 -48
  144. package/dist/rules/noBlankBlocks.cjs.map +1 -1
  145. package/dist/rules/noBlankBlocks.js +30 -0
  146. package/dist/rules/noBlankBlocks.js.map +1 -0
  147. package/dist/rules/noDefaults.cjs +52 -79
  148. package/dist/rules/noDefaults.cjs.map +1 -1
  149. package/dist/rules/noDefaults.js +56 -0
  150. package/dist/rules/noDefaults.js.map +1 -0
  151. package/dist/rules/noMissingSyntax.cjs +115 -165
  152. package/dist/rules/noMissingSyntax.cjs.map +1 -1
  153. package/dist/rules/noMissingSyntax.js +126 -0
  154. package/dist/rules/noMissingSyntax.js.map +1 -0
  155. package/dist/rules/noMultiAsterisks.cjs +48 -89
  156. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  157. package/dist/rules/noMultiAsterisks.js +58 -0
  158. package/dist/rules/noMultiAsterisks.js.map +1 -0
  159. package/dist/rules/noRestrictedSyntax.cjs +45 -79
  160. package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
  161. package/dist/rules/noRestrictedSyntax.js +49 -0
  162. package/dist/rules/noRestrictedSyntax.js.map +1 -0
  163. package/dist/rules/noTypes.cjs +59 -80
  164. package/dist/rules/noTypes.cjs.map +1 -1
  165. package/dist/rules/noTypes.js +65 -0
  166. package/dist/rules/noTypes.js.map +1 -0
  167. package/dist/rules/noUndefinedTypes.cjs +297 -388
  168. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  169. package/dist/rules/noUndefinedTypes.js +303 -0
  170. package/dist/rules/noUndefinedTypes.js.map +1 -0
  171. package/dist/rules/requireAsteriskPrefix.cjs +108 -159
  172. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  173. package/dist/rules/requireAsteriskPrefix.js +112 -0
  174. package/dist/rules/requireAsteriskPrefix.js.map +1 -0
  175. package/dist/rules/requireDescription.cjs +89 -129
  176. package/dist/rules/requireDescription.cjs.map +1 -1
  177. package/dist/rules/requireDescription.js +95 -0
  178. package/dist/rules/requireDescription.js.map +1 -0
  179. package/dist/rules/requireDescriptionCompleteSentence.cjs +201 -262
  180. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  181. package/dist/rules/requireDescriptionCompleteSentence.js +220 -0
  182. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -0
  183. package/dist/rules/requireExample.cjs +73 -104
  184. package/dist/rules/requireExample.cjs.map +1 -1
  185. package/dist/rules/requireExample.js +77 -0
  186. package/dist/rules/requireExample.js.map +1 -0
  187. package/dist/rules/requireFileOverview.cjs +75 -129
  188. package/dist/rules/requireFileOverview.cjs.map +1 -1
  189. package/dist/rules/requireFileOverview.js +81 -0
  190. package/dist/rules/requireFileOverview.js.map +1 -0
  191. package/dist/rules/requireHyphenBeforeParamDescription.cjs +85 -133
  192. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  193. package/dist/rules/requireHyphenBeforeParamDescription.js +89 -0
  194. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -0
  195. package/dist/rules/requireJsdoc.cjs +384 -557
  196. package/dist/rules/requireJsdoc.cjs.map +1 -1
  197. package/dist/rules/requireJsdoc.js +404 -0
  198. package/dist/rules/requireJsdoc.js.map +1 -0
  199. package/dist/rules/requireParam.cjs +336 -526
  200. package/dist/rules/requireParam.cjs.map +1 -1
  201. package/dist/rules/requireParam.js +344 -0
  202. package/dist/rules/requireParam.js.map +1 -0
  203. package/dist/rules/requireParamDescription.cjs +55 -80
  204. package/dist/rules/requireParamDescription.cjs.map +1 -1
  205. package/dist/rules/requireParamDescription.js +59 -0
  206. package/dist/rules/requireParamDescription.js.map +1 -0
  207. package/dist/rules/requireParamName.cjs +32 -50
  208. package/dist/rules/requireParamName.cjs.map +1 -1
  209. package/dist/rules/requireParamName.js +36 -0
  210. package/dist/rules/requireParamName.js.map +1 -0
  211. package/dist/rules/requireParamType.cjs +55 -80
  212. package/dist/rules/requireParamType.cjs.map +1 -1
  213. package/dist/rules/requireParamType.js +59 -0
  214. package/dist/rules/requireParamType.js.map +1 -0
  215. package/dist/rules/requireProperty.cjs +31 -42
  216. package/dist/rules/requireProperty.cjs.map +1 -1
  217. package/dist/rules/requireProperty.js +35 -0
  218. package/dist/rules/requireProperty.js.map +1 -0
  219. package/dist/rules/requirePropertyDescription.cjs +17 -25
  220. package/dist/rules/requirePropertyDescription.cjs.map +1 -1
  221. package/dist/rules/requirePropertyDescription.js +21 -0
  222. package/dist/rules/requirePropertyDescription.js.map +1 -0
  223. package/dist/rules/requirePropertyName.cjs +17 -25
  224. package/dist/rules/requirePropertyName.cjs.map +1 -1
  225. package/dist/rules/requirePropertyName.js +21 -0
  226. package/dist/rules/requirePropertyName.js.map +1 -0
  227. package/dist/rules/requirePropertyType.cjs +17 -25
  228. package/dist/rules/requirePropertyType.cjs.map +1 -1
  229. package/dist/rules/requirePropertyType.js +21 -0
  230. package/dist/rules/requirePropertyType.js.map +1 -0
  231. package/dist/rules/requireReturns.cjs +125 -203
  232. package/dist/rules/requireReturns.cjs.map +1 -1
  233. package/dist/rules/requireReturns.js +131 -0
  234. package/dist/rules/requireReturns.js.map +1 -0
  235. package/dist/rules/requireReturnsCheck.cjs +60 -103
  236. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  237. package/dist/rules/requireReturnsCheck.js +66 -0
  238. package/dist/rules/requireReturnsCheck.js.map +1 -0
  239. package/dist/rules/requireReturnsDescription.cjs +39 -54
  240. package/dist/rules/requireReturnsDescription.cjs.map +1 -1
  241. package/dist/rules/requireReturnsDescription.js +43 -0
  242. package/dist/rules/requireReturnsDescription.js.map +1 -0
  243. package/dist/rules/requireReturnsType.cjs +32 -50
  244. package/dist/rules/requireReturnsType.cjs.map +1 -1
  245. package/dist/rules/requireReturnsType.js +36 -0
  246. package/dist/rules/requireReturnsType.js.map +1 -0
  247. package/dist/rules/requireTemplate.cjs +119 -178
  248. package/dist/rules/requireTemplate.cjs.map +1 -1
  249. package/dist/rules/requireTemplate.js +122 -0
  250. package/dist/rules/requireTemplate.js.map +1 -0
  251. package/dist/rules/requireThrows.cjs +61 -95
  252. package/dist/rules/requireThrows.cjs.map +1 -1
  253. package/dist/rules/requireThrows.js +67 -0
  254. package/dist/rules/requireThrows.js.map +1 -0
  255. package/dist/rules/requireYields.cjs +106 -166
  256. package/dist/rules/requireYields.cjs.map +1 -1
  257. package/dist/rules/requireYields.js +115 -0
  258. package/dist/rules/requireYields.js.map +1 -0
  259. package/dist/rules/requireYieldsCheck.cjs +96 -152
  260. package/dist/rules/requireYieldsCheck.cjs.map +1 -1
  261. package/dist/rules/requireYieldsCheck.js +105 -0
  262. package/dist/rules/requireYieldsCheck.js.map +1 -0
  263. package/dist/rules/sortTags.cjs +258 -444
  264. package/dist/rules/sortTags.cjs.map +1 -1
  265. package/dist/rules/sortTags.js +262 -0
  266. package/dist/rules/sortTags.js.map +1 -0
  267. package/dist/rules/tagLines.cjs +179 -266
  268. package/dist/rules/tagLines.cjs.map +1 -1
  269. package/dist/rules/tagLines.js +183 -0
  270. package/dist/rules/tagLines.js.map +1 -0
  271. package/dist/rules/textEscaping.cjs +92 -127
  272. package/dist/rules/textEscaping.cjs.map +1 -1
  273. package/dist/rules/textEscaping.js +102 -0
  274. package/dist/rules/textEscaping.js.map +1 -0
  275. package/dist/rules/validTypes.cjs +252 -265
  276. package/dist/rules/validTypes.cjs.map +1 -1
  277. package/dist/rules/validTypes.js +259 -0
  278. package/dist/rules/validTypes.js.map +1 -0
  279. package/dist/tagNames.cjs +134 -170
  280. package/dist/tagNames.cjs.map +1 -1
  281. package/dist/tagNames.js +144 -0
  282. package/dist/tagNames.js.map +1 -0
  283. package/dist/utils/hasReturnValue.cjs +246 -474
  284. package/dist/utils/hasReturnValue.cjs.map +1 -1
  285. package/dist/utils/hasReturnValue.js +265 -0
  286. package/dist/utils/hasReturnValue.js.map +1 -0
  287. package/package.json +40 -24
  288. package/dist/generateRule.cjs +0 -242
  289. package/dist/generateRule.cjs.map +0 -1
  290. package/src/WarnSettings.js +0 -34
  291. package/src/alignTransform.js +0 -358
  292. package/src/defaultTagOrder.js +0 -169
  293. package/src/exportParser.js +0 -978
  294. package/src/getDefaultTagStructureForMode.js +0 -969
  295. package/src/getJsdocProcessorPlugin.js +0 -672
  296. package/src/index.js +0 -530
  297. package/src/iterateJsdoc.js +0 -2518
  298. package/src/jsdocUtils.js +0 -1896
  299. package/src/rules/checkAccess.js +0 -45
  300. package/src/rules/checkAlignment.js +0 -63
  301. package/src/rules/checkExamples.js +0 -589
  302. package/src/rules/checkIndentation.js +0 -75
  303. package/src/rules/checkLineAlignment.js +0 -372
  304. package/src/rules/checkParamNames.js +0 -474
  305. package/src/rules/checkPropertyNames.js +0 -152
  306. package/src/rules/checkSyntax.js +0 -30
  307. package/src/rules/checkTagNames.js +0 -314
  308. package/src/rules/checkTemplateNames.js +0 -204
  309. package/src/rules/checkTypes.js +0 -535
  310. package/src/rules/checkValues.js +0 -248
  311. package/src/rules/convertToJsdocComments.js +0 -398
  312. package/src/rules/emptyTags.js +0 -98
  313. package/src/rules/implementsOnClasses.js +0 -64
  314. package/src/rules/importsAsDependencies.js +0 -133
  315. package/src/rules/informativeDocs.js +0 -189
  316. package/src/rules/linesBeforeBlock.js +0 -134
  317. package/src/rules/matchDescription.js +0 -286
  318. package/src/rules/matchName.js +0 -151
  319. package/src/rules/multilineBlocks.js +0 -493
  320. package/src/rules/noBadBlocks.js +0 -119
  321. package/src/rules/noBlankBlockDescriptions.js +0 -69
  322. package/src/rules/noBlankBlocks.js +0 -53
  323. package/src/rules/noDefaults.js +0 -85
  324. package/src/rules/noMissingSyntax.js +0 -195
  325. package/src/rules/noMultiAsterisks.js +0 -134
  326. package/src/rules/noRestrictedSyntax.js +0 -91
  327. package/src/rules/noTypes.js +0 -93
  328. package/src/rules/noUndefinedTypes.js +0 -543
  329. package/src/rules/requireAsteriskPrefix.js +0 -190
  330. package/src/rules/requireDescription.js +0 -161
  331. package/src/rules/requireDescriptionCompleteSentence.js +0 -335
  332. package/src/rules/requireExample.js +0 -118
  333. package/src/rules/requireFileOverview.js +0 -154
  334. package/src/rules/requireHyphenBeforeParamDescription.js +0 -176
  335. package/src/rules/requireJsdoc.js +0 -743
  336. package/src/rules/requireParam.js +0 -602
  337. package/src/rules/requireParamDescription.js +0 -89
  338. package/src/rules/requireParamName.js +0 -55
  339. package/src/rules/requireParamType.js +0 -89
  340. package/src/rules/requireProperty.js +0 -48
  341. package/src/rules/requirePropertyDescription.js +0 -25
  342. package/src/rules/requirePropertyName.js +0 -25
  343. package/src/rules/requirePropertyType.js +0 -25
  344. package/src/rules/requireReturns.js +0 -238
  345. package/src/rules/requireReturnsCheck.js +0 -145
  346. package/src/rules/requireReturnsDescription.js +0 -59
  347. package/src/rules/requireReturnsType.js +0 -51
  348. package/src/rules/requireTemplate.js +0 -201
  349. package/src/rules/requireThrows.js +0 -111
  350. package/src/rules/requireYields.js +0 -216
  351. package/src/rules/requireYieldsCheck.js +0 -208
  352. package/src/rules/sortTags.js +0 -558
  353. package/src/rules/tagLines.js +0 -359
  354. package/src/rules/textEscaping.js +0 -154
  355. package/src/rules/validTypes.js +0 -401
  356. package/src/tagNames.js +0 -238
  357. package/src/utils/hasReturnValue.js +0 -572
@@ -1,570 +1,384 @@
1
- "use strict";
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_jsdocUtils = require('./jsdocUtils.cjs');
3
+ const __es_joy_jsdoccomment = require_rolldown_runtime.__toESM(require("@es-joy/jsdoccomment"));
4
+ const espree = require_rolldown_runtime.__toESM(require("espree"));
5
+ const node_fs = require_rolldown_runtime.__toESM(require("node:fs"));
6
+ const node_path = require_rolldown_runtime.__toESM(require("node:path"));
2
7
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getJsdocProcessorPlugin = void 0;
7
- var _jsdocUtils = require("./jsdocUtils.cjs");
8
- var _jsdoccomment = require("@es-joy/jsdoccomment");
9
- var espree = _interopRequireWildcard(require("espree"));
10
- var _nodeFs = require("node:fs");
11
- var _nodePath = require("node:path");
12
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
8
+ //#region src/getJsdocProcessorPlugin.js
13
9
  /**
14
- * @import {
15
- * Integer,
16
- * JsdocBlockWithInline,
17
- * } from './iterateJsdoc.js';
18
- * @import {
19
- * ESLint,
20
- * Linter,
21
- * } from 'eslint';
22
- */
23
-
24
- const {
25
- version
26
- } = JSON.parse(
27
- // @ts-expect-error `Buffer` is ok for `JSON.parse`
28
- (0, _nodeFs.readFileSync)((0, _nodePath.join)(__dirname, '../package.json')));
29
-
30
- // const zeroBasedLineIndexAdjust = -1;
10
+ * @import {
11
+ * Integer,
12
+ * JsdocBlockWithInline,
13
+ * } from './iterateJsdoc.js';
14
+ * @import {
15
+ * ESLint,
16
+ * Linter,
17
+ * } from 'eslint';
18
+ */
19
+ const { version } = JSON.parse((0, node_fs.readFileSync)((0, node_path.join)(__dirname, "../package.json")));
31
20
  const likelyNestedJSDocIndentSpace = 1;
32
21
  const preTagSpaceLength = 1;
33
-
34
- // If a space is present, we should ignore it
35
22
  const firstLinePrefixLength = preTagSpaceLength;
36
23
  const hasCaptionRegex = /^\s*<caption>([\s\S]*?)<\/caption>/v;
37
-
38
24
  /**
39
- * @param {string} str
40
- * @returns {string}
41
- */
42
- const escapeStringRegexp = str => {
43
- return str.replaceAll(/[.*+?^$\{\}\(\)\|\[\]\\]/gv, '\\$&');
25
+ * @param {string} str
26
+ * @returns {string}
27
+ */
28
+ const escapeStringRegexp = (str) => {
29
+ return str.replaceAll(/[.*+?^$\{\}\(\)\|\[\]\\]/gv, "\\$&");
44
30
  };
45
-
46
31
  /**
47
- * @param {string} str
48
- * @param {string} ch
49
- * @returns {Integer}
50
- */
32
+ * @param {string} str
33
+ * @param {string} ch
34
+ * @returns {Integer}
35
+ */
51
36
  const countChars = (str, ch) => {
52
- return (str.match(new RegExp(escapeStringRegexp(ch), 'gv')) || []).length;
37
+ return (str.match(new RegExp(escapeStringRegexp(ch), "gv")) || []).length;
53
38
  };
54
-
55
39
  /**
56
- * @param {string} text
57
- * @returns {[
58
- * Integer,
59
- * Integer
60
- * ]}
61
- */
62
- const getLinesCols = text => {
63
- const matchLines = countChars(text, '\n');
64
- const colDelta = matchLines ? text.slice(text.lastIndexOf('\n') + 1).length : text.length;
65
- return [matchLines, colDelta];
40
+ * @param {string} text
41
+ * @returns {[
42
+ * Integer,
43
+ * Integer
44
+ * ]}
45
+ */
46
+ const getLinesCols = (text) => {
47
+ const matchLines = countChars(text, "\n");
48
+ const colDelta = matchLines ? text.slice(text.lastIndexOf("\n") + 1).length : text.length;
49
+ return [matchLines, colDelta];
66
50
  };
67
-
68
51
  /**
69
- * @typedef {number} Integer
70
- */
71
-
52
+ * @typedef {number} Integer
53
+ */
72
54
  /**
73
- * @typedef {object} JsdocProcessorOptions
74
- * @property {boolean} [captionRequired] Require captions for example tags
75
- * @property {Integer} [paddedIndent] See docs
76
- * @property {boolean} [checkDefaults] See docs
77
- * @property {boolean} [checkParams] See docs
78
- * @property {boolean} [checkExamples] See docs
79
- * @property {boolean} [checkProperties] See docs
80
- * @property {string} [matchingFileName] See docs
81
- * @property {string} [matchingFileNameDefaults] See docs
82
- * @property {string} [matchingFileNameParams] See docs
83
- * @property {string} [matchingFileNameProperties] See docs
84
- * @property {string|RegExp} [exampleCodeRegex] See docs
85
- * @property {string|RegExp} [rejectExampleCodeRegex] See docs
86
- * @property {string[]} [allowedLanguagesToProcess] See docs
87
- * @property {"script"|"module"} [sourceType] See docs
88
- * @property {import('eslint').Linter.ESTreeParser|import('eslint').Linter.NonESTreeParser} [parser] See docs
89
- */
90
-
55
+ * @typedef {object} JsdocProcessorOptions
56
+ * @property {boolean} [captionRequired] Require captions for example tags
57
+ * @property {Integer} [paddedIndent] See docs
58
+ * @property {boolean} [checkDefaults] See docs
59
+ * @property {boolean} [checkParams] See docs
60
+ * @property {boolean} [checkExamples] See docs
61
+ * @property {boolean} [checkProperties] See docs
62
+ * @property {string} [matchingFileName] See docs
63
+ * @property {string} [matchingFileNameDefaults] See docs
64
+ * @property {string} [matchingFileNameParams] See docs
65
+ * @property {string} [matchingFileNameProperties] See docs
66
+ * @property {string|RegExp} [exampleCodeRegex] See docs
67
+ * @property {string|RegExp} [rejectExampleCodeRegex] See docs
68
+ * @property {string[]} [allowedLanguagesToProcess] See docs
69
+ * @property {"script"|"module"} [sourceType] See docs
70
+ * @property {import('eslint').Linter.ESTreeParser|import('eslint').Linter.NonESTreeParser} [parser] See docs
71
+ */
91
72
  /**
92
- * We use a function for the ability of the user to pass in a config, but
93
- * without requiring all users of the plugin to do so.
94
- * @param {JsdocProcessorOptions} [options]
95
- * @returns {ESLint.Plugin}
96
- */
73
+ * We use a function for the ability of the user to pass in a config, but
74
+ * without requiring all users of the plugin to do so.
75
+ * @param {JsdocProcessorOptions} [options]
76
+ * @returns {ESLint.Plugin}
77
+ */
97
78
  const getJsdocProcessorPlugin = (options = {}) => {
98
- const {
99
- allowedLanguagesToProcess = ['js', 'ts', 'javascript', 'typescript'],
100
- captionRequired = false,
101
- checkDefaults = false,
102
- checkExamples = true,
103
- checkParams = false,
104
- checkProperties = false,
105
- exampleCodeRegex = null,
106
- matchingFileName = null,
107
- matchingFileNameDefaults = null,
108
- matchingFileNameParams = null,
109
- matchingFileNameProperties = null,
110
- paddedIndent = 0,
111
- parser = undefined,
112
- rejectExampleCodeRegex = null,
113
- sourceType = 'module'
114
- } = options;
115
-
116
- /** @type {RegExp} */
117
- let exampleCodeRegExp;
118
- /** @type {RegExp} */
119
- let rejectExampleCodeRegExp;
120
- if (exampleCodeRegex) {
121
- exampleCodeRegExp = typeof exampleCodeRegex === 'string' ? (0, _jsdocUtils.getRegexFromString)(exampleCodeRegex) : exampleCodeRegex;
122
- }
123
- if (rejectExampleCodeRegex) {
124
- rejectExampleCodeRegExp = typeof rejectExampleCodeRegex === 'string' ? (0, _jsdocUtils.getRegexFromString)(rejectExampleCodeRegex) : rejectExampleCodeRegex;
125
- }
126
-
127
- /**
128
- * @type {{
129
- * targetTagName: string,
130
- * ext: string,
131
- * codeStartLine: number,
132
- * codeStartCol: number,
133
- * nonJSPrefacingCols: number,
134
- * commentLineCols: [number, number]
135
- * }[]}
136
- */
137
- const otherInfo = [];
138
-
139
- /** @type {import('eslint').Linter.LintMessage[]} */
140
- let extraMessages = [];
141
-
142
- /**
143
- * @param {JsdocBlockWithInline} jsdoc
144
- * @param {string} jsFileName
145
- * @param {[number, number]} commentLineCols
146
- */
147
- const getTextsAndFileNames = (jsdoc, jsFileName, commentLineCols) => {
148
- /**
149
- * @type {{
150
- * text: string,
151
- * filename: string|null|undefined
152
- * }[]}
153
- */
154
- const textsAndFileNames = [];
155
-
156
- /**
157
- * @param {{
158
- * filename: string|null,
159
- * defaultFileName: string|undefined,
160
- * source: string,
161
- * targetTagName: string,
162
- * rules?: import('eslint').Linter.RulesRecord|undefined,
163
- * lines?: Integer,
164
- * cols?: Integer,
165
- * skipInit?: boolean,
166
- * ext: string,
167
- * sources?: {
168
- * nonJSPrefacingCols: Integer,
169
- * nonJSPrefacingLines: Integer,
170
- * string: string,
171
- * }[],
172
- * tag?: import('comment-parser').Spec & {
173
- * line?: Integer,
174
- * }|{
175
- * line: Integer,
176
- * }
177
- * }} cfg
178
- */
179
- const checkSource = ({
180
- cols = 0,
181
- defaultFileName,
182
- ext,
183
- filename,
184
- lines = 0,
185
- skipInit,
186
- source,
187
- sources = [],
188
- tag = {
189
- line: 0
190
- },
191
- targetTagName
192
- }) => {
193
- if (!skipInit) {
194
- sources.push({
195
- nonJSPrefacingCols: cols,
196
- nonJSPrefacingLines: lines,
197
- string: source
198
- });
199
- }
200
-
201
- /**
202
- * @param {{
203
- * nonJSPrefacingCols: Integer,
204
- * nonJSPrefacingLines: Integer,
205
- * string: string
206
- * }} cfg
207
- */
208
- const addSourceInfo = function ({
209
- nonJSPrefacingCols,
210
- nonJSPrefacingLines,
211
- string
212
- }) {
213
- const src = paddedIndent ? string.replaceAll(new RegExp(`(^|\n) {${paddedIndent}}(?!$)`, 'gv'), '\n') : string;
214
-
215
- // Programmatic ESLint API: https://eslint.org/docs/developer-guide/nodejs-api
216
- const file = filename || defaultFileName;
217
- if (!('line' in tag)) {
218
- tag.line = tag.source[0].number;
219
- }
220
-
221
- // NOTE: `tag.line` can be 0 if of form `/** @tag ... */`
222
- const codeStartLine =
223
- /**
224
- * @type {import('comment-parser').Spec & {
225
- * line: Integer,
226
- * }}
227
- */
228
- tag.line + nonJSPrefacingLines;
229
- const codeStartCol = likelyNestedJSDocIndentSpace;
230
- textsAndFileNames.push({
231
- filename: file,
232
- text: src
233
- });
234
- otherInfo.push({
235
- codeStartCol,
236
- codeStartLine,
237
- commentLineCols,
238
- ext,
239
- nonJSPrefacingCols,
240
- targetTagName
241
- });
242
- };
243
- for (const targetSource of sources) {
244
- addSourceInfo(targetSource);
245
- }
246
- };
247
-
248
- /**
249
- *
250
- * @param {string|null} filename
251
- * @param {string} [ext] Since `eslint-plugin-markdown` v2, and
252
- * ESLint 7, this is the default which other JS-fenced rules will used.
253
- * Formerly "md" was the default.
254
- * @returns {{
255
- * defaultFileName: string|undefined,
256
- * filename: string|null,
257
- * ext: string
258
- * }}
259
- */
260
- const getFilenameInfo = (filename, ext = 'md/*.js') => {
261
- let defaultFileName;
262
- if (!filename) {
263
- if (typeof jsFileName === 'string' && jsFileName.includes('.')) {
264
- defaultFileName = jsFileName.replace(/\.[^.]*$/v, `.${ext}`);
265
- } else {
266
- defaultFileName = `dummy.${ext}`;
267
- }
268
- }
269
- return {
270
- defaultFileName,
271
- ext,
272
- filename
273
- };
274
- };
275
- if (checkDefaults) {
276
- const filenameInfo = getFilenameInfo(matchingFileNameDefaults, 'jsdoc-defaults');
277
- (0, _jsdocUtils.forEachPreferredTag)(jsdoc, 'default', (tag, targetTagName) => {
278
- if (!tag.description.trim()) {
279
- return;
280
- }
281
- checkSource({
282
- source: `(${(0, _jsdocUtils.getTagDescription)(tag)})`,
283
- targetTagName,
284
- ...filenameInfo
285
- });
286
- });
287
- }
288
- if (checkParams) {
289
- const filenameInfo = getFilenameInfo(matchingFileNameParams, 'jsdoc-params');
290
- (0, _jsdocUtils.forEachPreferredTag)(jsdoc, 'param', (tag, targetTagName) => {
291
- if (!tag.default || !tag.default.trim()) {
292
- return;
293
- }
294
- checkSource({
295
- source: `(${tag.default})`,
296
- targetTagName,
297
- ...filenameInfo
298
- });
299
- });
300
- }
301
- if (checkProperties) {
302
- const filenameInfo = getFilenameInfo(matchingFileNameProperties, 'jsdoc-properties');
303
- (0, _jsdocUtils.forEachPreferredTag)(jsdoc, 'property', (tag, targetTagName) => {
304
- if (!tag.default || !tag.default.trim()) {
305
- return;
306
- }
307
- checkSource({
308
- source: `(${tag.default})`,
309
- targetTagName,
310
- ...filenameInfo
311
- });
312
- });
313
- }
314
- if (!checkExamples) {
315
- return textsAndFileNames;
316
- }
317
- const tagName = /** @type {string} */(0, _jsdocUtils.getPreferredTagName)(jsdoc, {
318
- tagName: 'example'
319
- });
320
- if (!(0, _jsdocUtils.hasTag)(jsdoc, tagName)) {
321
- return textsAndFileNames;
322
- }
323
- const matchingFilenameInfo = getFilenameInfo(matchingFileName);
324
- (0, _jsdocUtils.forEachPreferredTag)(jsdoc, 'example', (tag, targetTagName) => {
325
- let source = /** @type {string} */(0, _jsdocUtils.getTagDescription)(tag);
326
- const match = source.match(hasCaptionRegex);
327
- if (captionRequired && (!match || !match[1].trim())) {
328
- extraMessages.push({
329
- column: commentLineCols[1] + 1,
330
- line: 1 + commentLineCols[0] + (tag.line ?? tag.source[0].number),
331
- message: `@${targetTagName} error - Caption is expected for examples.`,
332
- ruleId: 'jsdoc/example-missing-caption',
333
- severity: 2
334
- });
335
- return;
336
- }
337
- source = source.replace(hasCaptionRegex, '');
338
- const [lines, cols] = match ? getLinesCols(match[0]) : [0, 0];
339
- if (exampleCodeRegex && !exampleCodeRegExp.test(source) || rejectExampleCodeRegex && rejectExampleCodeRegExp.test(source)) {
340
- return;
341
- }
342
-
343
- // If `allowedLanguagesToProcess` is falsy, all languages should be processed.
344
- if (allowedLanguagesToProcess) {
345
- const matches = /^\s*```(?<language>\S+)([\s\S]*)```\s*$/v.exec(source);
346
- if (matches?.groups && !allowedLanguagesToProcess.includes(matches.groups.language.toLowerCase())) {
347
- return;
348
- }
349
- }
350
- const sources = [];
351
- let skipInit = false;
352
- if (exampleCodeRegex) {
353
- let nonJSPrefacingCols = 0;
354
- let nonJSPrefacingLines = 0;
355
- let startingIndex = 0;
356
- let lastStringCount = 0;
357
- let exampleCode;
358
- exampleCodeRegExp.lastIndex = 0;
359
- while ((exampleCode = exampleCodeRegExp.exec(source)) !== null) {
360
- const {
361
- '0': n0,
362
- '1': n1,
363
- index
364
- } = exampleCode;
365
-
366
- // Count anything preceding user regex match (can affect line numbering)
367
- const preMatch = source.slice(startingIndex, index);
368
- const [preMatchLines, colDelta] = getLinesCols(preMatch);
369
- let nonJSPreface;
370
- let nonJSPrefaceLineCount;
371
- if (n1) {
372
- const idx = n0.indexOf(n1);
373
- nonJSPreface = n0.slice(0, idx);
374
- nonJSPrefaceLineCount = countChars(nonJSPreface, '\n');
375
- } else {
376
- nonJSPreface = '';
377
- nonJSPrefaceLineCount = 0;
378
- }
379
- nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount;
380
-
381
- // Ignore `preMatch` delta if newlines here
382
- if (nonJSPrefaceLineCount) {
383
- const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf('\n') + 1).length;
384
- nonJSPrefacingCols += charsInLastLine;
385
- } else {
386
- nonJSPrefacingCols += colDelta + nonJSPreface.length;
387
- }
388
- const string = n1 || n0;
389
- sources.push({
390
- nonJSPrefacingCols,
391
- nonJSPrefacingLines,
392
- string
393
- });
394
- startingIndex = exampleCodeRegExp.lastIndex;
395
- lastStringCount = countChars(string, '\n');
396
- if (!exampleCodeRegExp.global) {
397
- break;
398
- }
399
- }
400
- skipInit = true;
401
- }
402
- checkSource({
403
- cols,
404
- lines,
405
- skipInit,
406
- source,
407
- sources,
408
- tag,
409
- targetTagName,
410
- ...matchingFilenameInfo
411
- });
412
- });
413
- return textsAndFileNames;
414
- };
415
-
416
- // See https://eslint.org/docs/latest/extend/plugins#processors-in-plugins
417
- // See https://eslint.org/docs/latest/extend/custom-processors
418
- // From https://github.com/eslint/eslint/issues/14745#issuecomment-869457265
419
- /*
420
- {
421
- "files": ["*.js", "*.ts"],
422
- "processor": "jsdoc/example" // a pretended value here
423
- },
424
- {
425
- "files": [
426
- "*.js/*_jsdoc-example.js",
427
- "*.ts/*_jsdoc-example.js",
428
- "*.js/*_jsdoc-example.ts"
429
- ],
430
- "rules": {
431
- // specific rules for examples in jsdoc only here
432
- // And other rules for `.js` and `.ts` will also be enabled for them
433
- }
434
- }
435
- */
436
- return {
437
- meta: {
438
- name: 'eslint-plugin-jsdoc/processor',
439
- version
440
- },
441
- processors: {
442
- examples: {
443
- meta: {
444
- name: 'eslint-plugin-jsdoc/preprocessor',
445
- version
446
- },
447
- /**
448
- * @param {import('eslint').Linter.LintMessage[][]} messages
449
- * @param {string} filename
450
- */
451
- postprocess([jsMessages, ...messages
452
- // eslint-disable-next-line no-unused-vars -- Placeholder
453
- ], filename) {
454
- for (const [idx, message] of messages.entries()) {
455
- const {
456
- codeStartCol,
457
- codeStartLine,
458
- commentLineCols,
459
- nonJSPrefacingCols,
460
- targetTagName
461
- } = otherInfo[idx];
462
- for (const msg of message) {
463
- const {
464
- column,
465
- endColumn,
466
- endLine,
467
- fatal,
468
- line,
469
- message: messageText,
470
- ruleId,
471
- severity
472
-
473
- // Todo: Make fixable
474
- // fix
475
- // fix: {range: [number, number], text: string}
476
- // suggestions: {desc: , messageId:, fix: }[],
477
- } = msg;
478
- const [codeCtxLine, codeCtxColumn] = commentLineCols;
479
- const startLine = codeCtxLine + codeStartLine + line;
480
-
481
- // Seems to need one more now
482
- const startCol = 1 + codeCtxColumn + codeStartCol + (
483
- // This might not work for line 0, but line 0 is unlikely for examples
484
- line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength) + column;
485
- msg.message = '@' + targetTagName + ' ' + (severity === 2 ? 'error' : 'warning') + (ruleId ? ' (' + ruleId + ')' : '') + ': ' + (fatal ? 'Fatal: ' : '') + messageText;
486
- msg.line = startLine;
487
- msg.column = startCol;
488
- msg.endLine = endLine ? startLine + endLine : startLine;
489
- // added `- column` to offset what `endColumn` already seemed to include
490
- msg.endColumn = endColumn ? startCol - column + endColumn : startCol;
491
- }
492
- }
493
- const ret = [...jsMessages].concat(...messages, ...extraMessages);
494
- extraMessages = [];
495
- return ret;
496
- },
497
- /**
498
- * @param {string} text
499
- * @param {string} filename
500
- * @returns {(string | Linter.ProcessorFile)[]}
501
- */
502
- preprocess(text, filename) {
503
- try {
504
- let ast;
505
-
506
- // May be running a second time so catch and ignore
507
- try {
508
- ast = parser ?
509
- // @ts-expect-error Should be present
510
- parser.parseForESLint(text, {
511
- comment: true,
512
- ecmaVersion: 'latest',
513
- sourceType
514
- }).ast : espree.parse(text, {
515
- comment: true,
516
- ecmaVersion: 'latest',
517
- sourceType
518
- });
519
- } catch {
520
- return [text];
521
- }
522
-
523
- /** @type {[number, number][]} */
524
- const commentLineCols = [];
525
- const jsdocComments = /** @type {import('estree').Comment[]} */(
526
- /**
527
- * @type {import('estree').Program & {
528
- * comments?: import('estree').Comment[]
529
- * }}
530
- */
531
- ast.comments).filter(comment => {
532
- return /^\*\s/v.test(comment.value);
533
- }).map(comment => {
534
- const [start
535
- /* c8 ignore next -- Unsupporting processors only? */] = comment.range ?? [];
536
- const textToStart = text.slice(0, start);
537
- const [lines, cols] = getLinesCols(textToStart);
538
-
539
- // const lines = [...textToStart.matchAll(/\n/gv)].length
540
- // const lastLinePos = textToStart.lastIndexOf('\n');
541
- // const cols = lastLinePos === -1
542
- // ? 0
543
- // : textToStart.slice(lastLinePos).length;
544
- commentLineCols.push([lines, cols]);
545
- return (0, _jsdoccomment.parseComment)(comment);
546
- });
547
- return [text, ...jsdocComments.flatMap((jsdoc, idx) => {
548
- return getTextsAndFileNames(jsdoc, filename, commentLineCols[idx]);
549
- }).filter(
550
- /**
551
- * @returns {file is Linter.ProcessorFile}
552
- */
553
- file => {
554
- return file !== null && file !== undefined;
555
- })];
556
- /* c8 ignore next 6 */
557
- } catch (error) {
558
- // eslint-disable-next-line no-console -- Debugging
559
- console.log('err', filename, error);
560
- }
561
- return [];
562
- },
563
- // Todo: Reenable
564
- supportsAutofix: false
565
- }
566
- }
567
- };
79
+ const { allowedLanguagesToProcess = [
80
+ "js",
81
+ "ts",
82
+ "javascript",
83
+ "typescript"
84
+ ], captionRequired = false, checkDefaults = false, checkExamples = true, checkParams = false, checkProperties = false, exampleCodeRegex = null, matchingFileName = null, matchingFileNameDefaults = null, matchingFileNameParams = null, matchingFileNameProperties = null, paddedIndent = 0, parser = void 0, rejectExampleCodeRegex = null, sourceType = "module" } = options;
85
+ /** @type {RegExp} */
86
+ let exampleCodeRegExp;
87
+ /** @type {RegExp} */
88
+ let rejectExampleCodeRegExp;
89
+ if (exampleCodeRegex) exampleCodeRegExp = typeof exampleCodeRegex === "string" ? require_jsdocUtils.getRegexFromString(exampleCodeRegex) : exampleCodeRegex;
90
+ if (rejectExampleCodeRegex) rejectExampleCodeRegExp = typeof rejectExampleCodeRegex === "string" ? require_jsdocUtils.getRegexFromString(rejectExampleCodeRegex) : rejectExampleCodeRegex;
91
+ /**
92
+ * @type {{
93
+ * targetTagName: string,
94
+ * ext: string,
95
+ * codeStartLine: number,
96
+ * codeStartCol: number,
97
+ * nonJSPrefacingCols: number,
98
+ * commentLineCols: [number, number]
99
+ * }[]}
100
+ */
101
+ const otherInfo = [];
102
+ /** @type {import('eslint').Linter.LintMessage[]} */
103
+ let extraMessages = [];
104
+ /**
105
+ * @param {JsdocBlockWithInline} jsdoc
106
+ * @param {string} jsFileName
107
+ * @param {[number, number]} commentLineCols
108
+ */
109
+ const getTextsAndFileNames = (jsdoc, jsFileName, commentLineCols) => {
110
+ /**
111
+ * @type {{
112
+ * text: string,
113
+ * filename: string|null|undefined
114
+ * }[]}
115
+ */
116
+ const textsAndFileNames = [];
117
+ /**
118
+ * @param {{
119
+ * filename: string|null,
120
+ * defaultFileName: string|undefined,
121
+ * source: string,
122
+ * targetTagName: string,
123
+ * rules?: import('eslint').Linter.RulesRecord|undefined,
124
+ * lines?: Integer,
125
+ * cols?: Integer,
126
+ * skipInit?: boolean,
127
+ * ext: string,
128
+ * sources?: {
129
+ * nonJSPrefacingCols: Integer,
130
+ * nonJSPrefacingLines: Integer,
131
+ * string: string,
132
+ * }[],
133
+ * tag?: import('comment-parser').Spec & {
134
+ * line?: Integer,
135
+ * }|{
136
+ * line: Integer,
137
+ * }
138
+ * }} cfg
139
+ */
140
+ const checkSource = ({ cols = 0, defaultFileName, ext, filename, lines = 0, skipInit, source, sources = [], tag = { line: 0 }, targetTagName }) => {
141
+ if (!skipInit) sources.push({
142
+ nonJSPrefacingCols: cols,
143
+ nonJSPrefacingLines: lines,
144
+ string: source
145
+ });
146
+ /**
147
+ * @param {{
148
+ * nonJSPrefacingCols: Integer,
149
+ * nonJSPrefacingLines: Integer,
150
+ * string: string
151
+ * }} cfg
152
+ */
153
+ const addSourceInfo = function({ nonJSPrefacingCols, nonJSPrefacingLines, string }) {
154
+ const src = paddedIndent ? string.replaceAll(new RegExp(`(^|\n) {${paddedIndent}}(?!$)`, "gv"), "\n") : string;
155
+ const file = filename || defaultFileName;
156
+ if (!("line" in tag)) tag.line = tag.source[0].number;
157
+ const codeStartLine = tag.line + nonJSPrefacingLines;
158
+ const codeStartCol = likelyNestedJSDocIndentSpace;
159
+ textsAndFileNames.push({
160
+ filename: file,
161
+ text: src
162
+ });
163
+ otherInfo.push({
164
+ codeStartCol,
165
+ codeStartLine,
166
+ commentLineCols,
167
+ ext,
168
+ nonJSPrefacingCols,
169
+ targetTagName
170
+ });
171
+ };
172
+ for (const targetSource of sources) addSourceInfo(targetSource);
173
+ };
174
+ /**
175
+ *
176
+ * @param {string|null} filename
177
+ * @param {string} [ext] Since `eslint-plugin-markdown` v2, and
178
+ * ESLint 7, this is the default which other JS-fenced rules will used.
179
+ * Formerly "md" was the default.
180
+ * @returns {{
181
+ * defaultFileName: string|undefined,
182
+ * filename: string|null,
183
+ * ext: string
184
+ * }}
185
+ */
186
+ const getFilenameInfo = (filename, ext = "md/*.js") => {
187
+ let defaultFileName;
188
+ if (!filename) if (typeof jsFileName === "string" && jsFileName.includes(".")) defaultFileName = jsFileName.replace(/\.[^.]*$/v, `.${ext}`);
189
+ else defaultFileName = `dummy.${ext}`;
190
+ return {
191
+ defaultFileName,
192
+ ext,
193
+ filename
194
+ };
195
+ };
196
+ if (checkDefaults) {
197
+ const filenameInfo = getFilenameInfo(matchingFileNameDefaults, "jsdoc-defaults");
198
+ require_jsdocUtils.forEachPreferredTag(jsdoc, "default", (tag, targetTagName) => {
199
+ if (!tag.description.trim()) return;
200
+ checkSource({
201
+ source: `(${require_jsdocUtils.getTagDescription(tag)})`,
202
+ targetTagName,
203
+ ...filenameInfo
204
+ });
205
+ });
206
+ }
207
+ if (checkParams) {
208
+ const filenameInfo = getFilenameInfo(matchingFileNameParams, "jsdoc-params");
209
+ require_jsdocUtils.forEachPreferredTag(jsdoc, "param", (tag, targetTagName) => {
210
+ if (!tag.default || !tag.default.trim()) return;
211
+ checkSource({
212
+ source: `(${tag.default})`,
213
+ targetTagName,
214
+ ...filenameInfo
215
+ });
216
+ });
217
+ }
218
+ if (checkProperties) {
219
+ const filenameInfo = getFilenameInfo(matchingFileNameProperties, "jsdoc-properties");
220
+ require_jsdocUtils.forEachPreferredTag(jsdoc, "property", (tag, targetTagName) => {
221
+ if (!tag.default || !tag.default.trim()) return;
222
+ checkSource({
223
+ source: `(${tag.default})`,
224
+ targetTagName,
225
+ ...filenameInfo
226
+ });
227
+ });
228
+ }
229
+ if (!checkExamples) return textsAndFileNames;
230
+ const tagName = require_jsdocUtils.getPreferredTagName(jsdoc, { tagName: "example" });
231
+ if (!require_jsdocUtils.hasTag(jsdoc, tagName)) return textsAndFileNames;
232
+ const matchingFilenameInfo = getFilenameInfo(matchingFileName);
233
+ require_jsdocUtils.forEachPreferredTag(jsdoc, "example", (tag, targetTagName) => {
234
+ let source = require_jsdocUtils.getTagDescription(tag);
235
+ const match = source.match(hasCaptionRegex);
236
+ if (captionRequired && (!match || !match[1].trim())) {
237
+ extraMessages.push({
238
+ column: commentLineCols[1] + 1,
239
+ line: 1 + commentLineCols[0] + (tag.line ?? tag.source[0].number),
240
+ message: `@${targetTagName} error - Caption is expected for examples.`,
241
+ ruleId: "jsdoc/example-missing-caption",
242
+ severity: 2
243
+ });
244
+ return;
245
+ }
246
+ source = source.replace(hasCaptionRegex, "");
247
+ const [lines, cols] = match ? getLinesCols(match[0]) : [0, 0];
248
+ if (exampleCodeRegex && !exampleCodeRegExp.test(source) || rejectExampleCodeRegex && rejectExampleCodeRegExp.test(source)) return;
249
+ if (allowedLanguagesToProcess) {
250
+ const matches = /^\s*```(?<language>\S+)([\s\S]*)```\s*$/v.exec(source);
251
+ if (matches?.groups && !allowedLanguagesToProcess.includes(matches.groups.language.toLowerCase())) return;
252
+ }
253
+ const sources = [];
254
+ let skipInit = false;
255
+ if (exampleCodeRegex) {
256
+ let nonJSPrefacingCols = 0;
257
+ let nonJSPrefacingLines = 0;
258
+ let startingIndex = 0;
259
+ let lastStringCount = 0;
260
+ let exampleCode;
261
+ exampleCodeRegExp.lastIndex = 0;
262
+ while ((exampleCode = exampleCodeRegExp.exec(source)) !== null) {
263
+ const { "0": n0, "1": n1, index } = exampleCode;
264
+ const preMatch = source.slice(startingIndex, index);
265
+ const [preMatchLines, colDelta] = getLinesCols(preMatch);
266
+ let nonJSPreface;
267
+ let nonJSPrefaceLineCount;
268
+ if (n1) {
269
+ const idx = n0.indexOf(n1);
270
+ nonJSPreface = n0.slice(0, idx);
271
+ nonJSPrefaceLineCount = countChars(nonJSPreface, "\n");
272
+ } else {
273
+ nonJSPreface = "";
274
+ nonJSPrefaceLineCount = 0;
275
+ }
276
+ nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount;
277
+ if (nonJSPrefaceLineCount) {
278
+ const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf("\n") + 1).length;
279
+ nonJSPrefacingCols += charsInLastLine;
280
+ } else nonJSPrefacingCols += colDelta + nonJSPreface.length;
281
+ const string = n1 || n0;
282
+ sources.push({
283
+ nonJSPrefacingCols,
284
+ nonJSPrefacingLines,
285
+ string
286
+ });
287
+ startingIndex = exampleCodeRegExp.lastIndex;
288
+ lastStringCount = countChars(string, "\n");
289
+ if (!exampleCodeRegExp.global) break;
290
+ }
291
+ skipInit = true;
292
+ }
293
+ checkSource({
294
+ cols,
295
+ lines,
296
+ skipInit,
297
+ source,
298
+ sources,
299
+ tag,
300
+ targetTagName,
301
+ ...matchingFilenameInfo
302
+ });
303
+ });
304
+ return textsAndFileNames;
305
+ };
306
+ return {
307
+ meta: {
308
+ name: "eslint-plugin-jsdoc/processor",
309
+ version
310
+ },
311
+ processors: { examples: {
312
+ meta: {
313
+ name: "eslint-plugin-jsdoc/preprocessor",
314
+ version
315
+ },
316
+ postprocess([jsMessages, ...messages], filename) {
317
+ for (const [idx, message] of messages.entries()) {
318
+ const { codeStartCol, codeStartLine, commentLineCols, nonJSPrefacingCols, targetTagName } = otherInfo[idx];
319
+ for (const msg of message) {
320
+ const { column, endColumn, endLine, fatal, line, message: messageText, ruleId, severity } = msg;
321
+ const [codeCtxLine, codeCtxColumn] = commentLineCols;
322
+ const startLine = codeCtxLine + codeStartLine + line;
323
+ const startCol = 1 + codeCtxColumn + codeStartCol + (line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength) + column;
324
+ msg.message = "@" + targetTagName + " " + (severity === 2 ? "error" : "warning") + (ruleId ? " (" + ruleId + ")" : "") + ": " + (fatal ? "Fatal: " : "") + messageText;
325
+ msg.line = startLine;
326
+ msg.column = startCol;
327
+ msg.endLine = endLine ? startLine + endLine : startLine;
328
+ msg.endColumn = endColumn ? startCol - column + endColumn : startCol;
329
+ }
330
+ }
331
+ const ret = [...jsMessages].concat(...messages, ...extraMessages);
332
+ extraMessages = [];
333
+ return ret;
334
+ },
335
+ preprocess(text, filename) {
336
+ try {
337
+ let ast;
338
+ try {
339
+ ast = parser ? parser.parseForESLint(text, {
340
+ comment: true,
341
+ ecmaVersion: "latest",
342
+ sourceType
343
+ }).ast : espree.parse(text, {
344
+ comment: true,
345
+ ecmaVersion: "latest",
346
+ sourceType
347
+ });
348
+ } catch {
349
+ return [text];
350
+ }
351
+ /** @type {[number, number][]} */
352
+ const commentLineCols = [];
353
+ const jsdocComments = ast.comments.filter((comment) => {
354
+ return /^\*\s/v.test(comment.value);
355
+ }).map((comment) => {
356
+ const [start] = comment.range ?? [];
357
+ const textToStart = text.slice(0, start);
358
+ const [lines, cols] = getLinesCols(textToStart);
359
+ commentLineCols.push([lines, cols]);
360
+ return (0, __es_joy_jsdoccomment.parseComment)(comment);
361
+ });
362
+ return [text, ...jsdocComments.flatMap((jsdoc, idx) => {
363
+ return getTextsAndFileNames(jsdoc, filename, commentLineCols[idx]);
364
+ }).filter(
365
+ /**
366
+ * @returns {file is Linter.ProcessorFile}
367
+ */
368
+ (file) => {
369
+ return file !== null && file !== void 0;
370
+ }
371
+ )];
372
+ } catch (error) {
373
+ console.log("err", filename, error);
374
+ }
375
+ return [];
376
+ },
377
+ supportsAutofix: false
378
+ } }
379
+ };
568
380
  };
381
+
382
+ //#endregion
569
383
  exports.getJsdocProcessorPlugin = getJsdocProcessorPlugin;
570
384
  //# sourceMappingURL=getJsdocProcessorPlugin.cjs.map