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,349 +1,506 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_iterateJsdoc = require('../iterateJsdoc.cjs');
3
- const eslint = require_rolldown_runtime.__toESM(require("eslint"));
4
- const semver = require_rolldown_runtime.__toESM(require("semver"));
1
+ "use strict";
5
2
 
6
- //#region src/rules/checkExamples.js
7
- const { CLIEngine } = eslint.default;
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.cjs"));
8
+ var _eslint = _interopRequireWildcard(require("eslint"));
9
+ var _semver = _interopRequireDefault(require("semver"));
10
+ 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); }
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ const {
13
+ // @ts-expect-error Older ESLint
14
+ CLIEngine
15
+ } = _eslint.default;
8
16
  const zeroBasedLineIndexAdjust = -1;
9
17
  const likelyNestedJSDocIndentSpace = 1;
10
18
  const preTagSpaceLength = 1;
19
+
20
+ // If a space is present, we should ignore it
11
21
  const firstLinePrefixLength = preTagSpaceLength;
12
22
  const hasCaptionRegex = /^\s*<caption>([\s\S]*?)<\/caption>/v;
23
+
13
24
  /**
14
- * @param {string} str
15
- * @returns {string}
16
- */
17
- const escapeStringRegexp = (str) => {
18
- return str.replaceAll(/[.*+?^$\{\}\(\)\|\[\]\\]/gv, "\\$&");
25
+ * @param {string} str
26
+ * @returns {string}
27
+ */
28
+ const escapeStringRegexp = str => {
29
+ return str.replaceAll(/[.*+?^$\{\}\(\)\|\[\]\\]/gv, '\\$&');
19
30
  };
31
+
20
32
  /**
21
- * @param {string} str
22
- * @param {string} ch
23
- * @returns {import('../iterateJsdoc.js').Integer}
24
- */
33
+ * @param {string} str
34
+ * @param {string} ch
35
+ * @returns {import('../iterateJsdoc.js').Integer}
36
+ */
25
37
  const countChars = (str, ch) => {
26
- return (str.match(new RegExp(escapeStringRegexp(ch), "gv")) || []).length;
38
+ return (str.match(new RegExp(escapeStringRegexp(ch), 'gv')) || []).length;
27
39
  };
40
+
28
41
  /** @type {import('eslint').Linter.RulesRecord} */
29
42
  const defaultMdRules = {
30
- "eol-last": 0,
31
- "import/no-unresolved": 0,
32
- "import/unambiguous": 0,
33
- "jsdoc/require-file-overview": 0,
34
- "jsdoc/require-jsdoc": 0,
35
- "no-console": 0,
36
- "no-multiple-empty-lines": 0,
37
- "no-undef": 0,
38
- "no-unused-vars": 0,
39
- "node/no-missing-import": 0,
40
- "node/no-missing-require": 0,
41
- "padded-blocks": 0
43
+ // "always" newline rule at end unlikely in sample code
44
+ 'eol-last': 0,
45
+ // Wouldn't generally expect example paths to resolve relative to JS file
46
+ 'import/no-unresolved': 0,
47
+ // Snippets likely too short to always include import/export info
48
+ 'import/unambiguous': 0,
49
+ 'jsdoc/require-file-overview': 0,
50
+ // The end of a multiline comment would end the comment the example is in.
51
+ 'jsdoc/require-jsdoc': 0,
52
+ // Unlikely to have inadvertent debugging within examples
53
+ 'no-console': 0,
54
+ // Often wish to start `@example` code after newline; also may use
55
+ // empty lines for spacing
56
+ 'no-multiple-empty-lines': 0,
57
+ // Many variables in examples will be `undefined`
58
+ 'no-undef': 0,
59
+ // Common to define variables for clarity without always using them
60
+ 'no-unused-vars': 0,
61
+ // See import/no-unresolved
62
+ 'node/no-missing-import': 0,
63
+ 'node/no-missing-require': 0,
64
+ // Can generally look nicer to pad a little even if code imposes more stringency
65
+ 'padded-blocks': 0
42
66
  };
67
+
43
68
  /** @type {import('eslint').Linter.RulesRecord} */
44
69
  const defaultExpressionRules = {
45
- ...defaultMdRules,
46
- "chai-friendly/no-unused-expressions": "off",
47
- "no-empty-function": "off",
48
- "no-new": "off",
49
- "no-unused-expressions": "off",
50
- quotes: ["error", "double"],
51
- semi: ["error", "never"],
52
- strict: "off"
70
+ ...defaultMdRules,
71
+ 'chai-friendly/no-unused-expressions': 'off',
72
+ 'no-empty-function': 'off',
73
+ 'no-new': 'off',
74
+ 'no-unused-expressions': 'off',
75
+ quotes: ['error', 'double'],
76
+ semi: ['error', 'never'],
77
+ strict: 'off'
53
78
  };
79
+
54
80
  /**
55
- * @param {string} text
56
- * @returns {[
57
- * import('../iterateJsdoc.js').Integer,
58
- * import('../iterateJsdoc.js').Integer
59
- * ]}
60
- */
61
- const getLinesCols = (text) => {
62
- const matchLines = countChars(text, "\n");
63
- const colDelta = matchLines ? text.slice(text.lastIndexOf("\n") + 1).length : text.length;
64
- return [matchLines, colDelta];
81
+ * @param {string} text
82
+ * @returns {[
83
+ * import('../iterateJsdoc.js').Integer,
84
+ * import('../iterateJsdoc.js').Integer
85
+ * ]}
86
+ */
87
+ const getLinesCols = text => {
88
+ const matchLines = countChars(text, '\n');
89
+ const colDelta = matchLines ? text.slice(text.lastIndexOf('\n') + 1).length : text.length;
90
+ return [matchLines, colDelta];
65
91
  };
66
- var checkExamples_default = require_iterateJsdoc.default(({ context, globalState, report, utils }) => {
67
- if (semver.default.gte(eslint.ESLint.version, "8.0.0")) {
68
- report("This rule does not work for ESLint 8+; you should disable this rule and usethe processor mentioned in the docs.", null, {
69
- column: 1,
70
- line: 1
71
- });
72
- return;
73
- }
74
- if (!globalState.has("checkExamples-matchingFileName")) globalState.set("checkExamples-matchingFileName", /* @__PURE__ */ new Map());
75
- const matchingFileNameMap = globalState.get("checkExamples-matchingFileName");
76
- const options = context.options[0] || {};
77
- let { exampleCodeRegex = null, rejectExampleCodeRegex = null } = options;
78
- const { allowInlineConfig = true, baseConfig = {}, captionRequired = false, checkDefaults = false, checkEslintrc = true, checkParams = false, checkProperties = false, configFile, matchingFileName = null, matchingFileNameDefaults = null, matchingFileNameParams = null, matchingFileNameProperties = null, noDefaultExampleRules = false, paddedIndent = 0, reportUnusedDisableDirectives = true } = options;
79
- /**
80
- * @type {never[]}
81
- */
82
- const rulePaths = [];
83
- const mdRules = noDefaultExampleRules ? void 0 : defaultMdRules;
84
- const expressionRules = noDefaultExampleRules ? void 0 : defaultExpressionRules;
85
- if (exampleCodeRegex) exampleCodeRegex = utils.getRegexFromString(exampleCodeRegex);
86
- if (rejectExampleCodeRegex) rejectExampleCodeRegex = utils.getRegexFromString(rejectExampleCodeRegex);
87
- /**
88
- * @param {{
89
- * filename: string,
90
- * defaultFileName: string|undefined,
91
- * source: string,
92
- * targetTagName: string,
93
- * rules?: import('eslint').Linter.RulesRecord|undefined,
94
- * lines?: import('../iterateJsdoc.js').Integer,
95
- * cols?: import('../iterateJsdoc.js').Integer,
96
- * skipInit?: boolean,
97
- * sources?: {
98
- * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer,
99
- * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer,
100
- * string: string,
101
- * }[],
102
- * tag?: import('comment-parser').Spec & {
103
- * line?: import('../iterateJsdoc.js').Integer,
104
- * }|{
105
- * line: import('../iterateJsdoc.js').Integer,
106
- * }
107
- * }} cfg
108
- */
109
- const checkSource = ({ cols = 0, defaultFileName, filename, lines = 0, rules = expressionRules, skipInit, source, sources = [], tag = { line: 0 }, targetTagName }) => {
110
- if (!skipInit) sources.push({
111
- nonJSPrefacingCols: cols,
112
- nonJSPrefacingLines: lines,
113
- string: source
114
- });
115
- /**
116
- * @param {{
117
- * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer,
118
- * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer,
119
- * string: string
120
- * }} cfg
121
- */
122
- const checkRules = function({ nonJSPrefacingCols, nonJSPrefacingLines, string }) {
123
- const cliConfig = {
124
- allowInlineConfig,
125
- baseConfig,
126
- configFile,
127
- reportUnusedDisableDirectives,
128
- rulePaths,
129
- rules,
130
- useEslintrc: checkEslintrc
131
- };
132
- const cliConfigStr = JSON.stringify(cliConfig);
133
- const src = paddedIndent ? string.replaceAll(new RegExp(`(^|\n) {${paddedIndent}}(?!$)`, "gv"), "\n") : string;
134
- const fileNameMapKey = filename ? "a" + cliConfigStr + filename : "b" + cliConfigStr + defaultFileName;
135
- const file = filename || defaultFileName;
136
- let cliFile;
137
- if (matchingFileNameMap.has(fileNameMapKey)) cliFile = matchingFileNameMap.get(fileNameMapKey);
138
- else {
139
- const cli = new CLIEngine(cliConfig);
140
- let config;
141
- if (filename || checkEslintrc) config = cli.getConfigForFile(file);
142
- cliFile = new CLIEngine({
143
- allowInlineConfig,
144
- baseConfig: {
145
- ...baseConfig,
146
- ...config
147
- },
148
- configFile,
149
- reportUnusedDisableDirectives,
150
- rulePaths,
151
- rules,
152
- useEslintrc: false
153
- });
154
- matchingFileNameMap.set(fileNameMapKey, cliFile);
155
- }
156
- const { results: [{ messages }] } = cliFile.executeOnText(src);
157
- if (!("line" in tag)) tag.line = tag.source[0].number;
158
- const codeStartLine = tag.line + nonJSPrefacingLines;
159
- const codeStartCol = likelyNestedJSDocIndentSpace;
160
- for (const { column, line, message, ruleId, severity } of messages) {
161
- const startLine = codeStartLine + line + zeroBasedLineIndexAdjust;
162
- const startCol = codeStartCol + (line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength) + column;
163
- report("@" + targetTagName + " " + (severity === 2 ? "error" : "warning") + (ruleId ? " (" + ruleId + ")" : "") + ": " + message, null, {
164
- column: startCol,
165
- line: startLine
166
- });
167
- }
168
- };
169
- for (const targetSource of sources) checkRules(targetSource);
170
- };
171
- /**
172
- *
173
- * @param {string} filename
174
- * @param {string} [ext] Since `eslint-plugin-markdown` v2, and
175
- * ESLint 7, this is the default which other JS-fenced rules will used.
176
- * Formerly "md" was the default.
177
- * @returns {{defaultFileName: string|undefined, filename: string}}
178
- */
179
- const getFilenameInfo = (filename, ext = "md/*.js") => {
180
- let defaultFileName;
181
- if (!filename) {
182
- const jsFileName = context.getFilename();
183
- if (typeof jsFileName === "string" && jsFileName.includes(".")) defaultFileName = jsFileName.replace(/\.[^.]*$/v, `.${ext}`);
184
- else defaultFileName = `dummy.${ext}`;
185
- }
186
- return {
187
- defaultFileName,
188
- filename
189
- };
190
- };
191
- if (checkDefaults) {
192
- const filenameInfo = getFilenameInfo(matchingFileNameDefaults, "jsdoc-defaults");
193
- utils.forEachPreferredTag("default", (tag, targetTagName) => {
194
- if (!tag.description.trim()) return;
195
- checkSource({
196
- source: `(${utils.getTagDescription(tag)})`,
197
- targetTagName,
198
- ...filenameInfo
199
- });
200
- });
201
- }
202
- if (checkParams) {
203
- const filenameInfo = getFilenameInfo(matchingFileNameParams, "jsdoc-params");
204
- utils.forEachPreferredTag("param", (tag, targetTagName) => {
205
- if (!tag.default || !tag.default.trim()) return;
206
- checkSource({
207
- source: `(${tag.default})`,
208
- targetTagName,
209
- ...filenameInfo
210
- });
211
- });
212
- }
213
- if (checkProperties) {
214
- const filenameInfo = getFilenameInfo(matchingFileNameProperties, "jsdoc-properties");
215
- utils.forEachPreferredTag("property", (tag, targetTagName) => {
216
- if (!tag.default || !tag.default.trim()) return;
217
- checkSource({
218
- source: `(${tag.default})`,
219
- targetTagName,
220
- ...filenameInfo
221
- });
222
- });
223
- }
224
- const tagName = utils.getPreferredTagName({ tagName: "example" });
225
- if (!utils.hasTag(tagName)) return;
226
- const matchingFilenameInfo = getFilenameInfo(matchingFileName);
227
- utils.forEachPreferredTag("example", (tag, targetTagName) => {
228
- let source = utils.getTagDescription(tag);
229
- const match = source.match(hasCaptionRegex);
230
- if (captionRequired && (!match || !match[1].trim())) report("Caption is expected for examples.", null, tag);
231
- source = source.replace(hasCaptionRegex, "");
232
- const [lines, cols] = match ? getLinesCols(match[0]) : [0, 0];
233
- if (exampleCodeRegex && !exampleCodeRegex.test(source) || rejectExampleCodeRegex && rejectExampleCodeRegex.test(source)) return;
234
- const sources = [];
235
- let skipInit = false;
236
- if (exampleCodeRegex) {
237
- let nonJSPrefacingCols = 0;
238
- let nonJSPrefacingLines = 0;
239
- let startingIndex = 0;
240
- let lastStringCount = 0;
241
- let exampleCode;
242
- exampleCodeRegex.lastIndex = 0;
243
- while ((exampleCode = exampleCodeRegex.exec(source)) !== null) {
244
- const { "0": n0, "1": n1, index } = exampleCode;
245
- const preMatch = source.slice(startingIndex, index);
246
- const [preMatchLines, colDelta] = getLinesCols(preMatch);
247
- let nonJSPreface;
248
- let nonJSPrefaceLineCount;
249
- if (n1) {
250
- const idx = n0.indexOf(n1);
251
- nonJSPreface = n0.slice(0, idx);
252
- nonJSPrefaceLineCount = countChars(nonJSPreface, "\n");
253
- } else {
254
- nonJSPreface = "";
255
- nonJSPrefaceLineCount = 0;
256
- }
257
- nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount;
258
- if (nonJSPrefaceLineCount) {
259
- const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf("\n") + 1).length;
260
- nonJSPrefacingCols += charsInLastLine;
261
- } else nonJSPrefacingCols += colDelta + nonJSPreface.length;
262
- const string = n1 || n0;
263
- sources.push({
264
- nonJSPrefacingCols,
265
- nonJSPrefacingLines,
266
- string
267
- });
268
- startingIndex = exampleCodeRegex.lastIndex;
269
- lastStringCount = countChars(string, "\n");
270
- if (!exampleCodeRegex.global) break;
271
- }
272
- skipInit = true;
273
- }
274
- checkSource({
275
- cols,
276
- lines,
277
- rules: mdRules,
278
- skipInit,
279
- source,
280
- sources,
281
- tag,
282
- targetTagName,
283
- ...matchingFilenameInfo
284
- });
285
- });
92
+ var _default = exports.default = (0, _iterateJsdoc.default)(({
93
+ context,
94
+ globalState,
95
+ report,
96
+ utils
97
+ }) => {
98
+ if (_semver.default.gte(_eslint.ESLint.version, '8.0.0')) {
99
+ report('This rule does not work for ESLint 8+; you should disable this rule and use' + 'the processor mentioned in the docs.', null, {
100
+ column: 1,
101
+ line: 1
102
+ });
103
+ return;
104
+ }
105
+ if (!globalState.has('checkExamples-matchingFileName')) {
106
+ globalState.set('checkExamples-matchingFileName', new Map());
107
+ }
108
+ const matchingFileNameMap = /** @type {Map<string, string>} */
109
+ globalState.get('checkExamples-matchingFileName');
110
+ const options = context.options[0] || {};
111
+ let {
112
+ exampleCodeRegex = null,
113
+ rejectExampleCodeRegex = null
114
+ } = options;
115
+ const {
116
+ allowInlineConfig = true,
117
+ baseConfig = {},
118
+ captionRequired = false,
119
+ checkDefaults = false,
120
+ checkEslintrc = true,
121
+ checkParams = false,
122
+ checkProperties = false,
123
+ configFile,
124
+ matchingFileName = null,
125
+ matchingFileNameDefaults = null,
126
+ matchingFileNameParams = null,
127
+ matchingFileNameProperties = null,
128
+ noDefaultExampleRules = false,
129
+ paddedIndent = 0,
130
+ reportUnusedDisableDirectives = true
131
+ } = options;
132
+
133
+ // Make this configurable?
134
+ /**
135
+ * @type {never[]}
136
+ */
137
+ const rulePaths = [];
138
+ const mdRules = noDefaultExampleRules ? undefined : defaultMdRules;
139
+ const expressionRules = noDefaultExampleRules ? undefined : defaultExpressionRules;
140
+ if (exampleCodeRegex) {
141
+ exampleCodeRegex = utils.getRegexFromString(exampleCodeRegex);
142
+ }
143
+ if (rejectExampleCodeRegex) {
144
+ rejectExampleCodeRegex = utils.getRegexFromString(rejectExampleCodeRegex);
145
+ }
146
+
147
+ /**
148
+ * @param {{
149
+ * filename: string,
150
+ * defaultFileName: string|undefined,
151
+ * source: string,
152
+ * targetTagName: string,
153
+ * rules?: import('eslint').Linter.RulesRecord|undefined,
154
+ * lines?: import('../iterateJsdoc.js').Integer,
155
+ * cols?: import('../iterateJsdoc.js').Integer,
156
+ * skipInit?: boolean,
157
+ * sources?: {
158
+ * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer,
159
+ * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer,
160
+ * string: string,
161
+ * }[],
162
+ * tag?: import('comment-parser').Spec & {
163
+ * line?: import('../iterateJsdoc.js').Integer,
164
+ * }|{
165
+ * line: import('../iterateJsdoc.js').Integer,
166
+ * }
167
+ * }} cfg
168
+ */
169
+ const checkSource = ({
170
+ cols = 0,
171
+ defaultFileName,
172
+ filename,
173
+ lines = 0,
174
+ rules = expressionRules,
175
+ skipInit,
176
+ source,
177
+ sources = [],
178
+ tag = {
179
+ line: 0
180
+ },
181
+ targetTagName
182
+ }) => {
183
+ if (!skipInit) {
184
+ sources.push({
185
+ nonJSPrefacingCols: cols,
186
+ nonJSPrefacingLines: lines,
187
+ string: source
188
+ });
189
+ }
190
+
191
+ /**
192
+ * @param {{
193
+ * nonJSPrefacingCols: import('../iterateJsdoc.js').Integer,
194
+ * nonJSPrefacingLines: import('../iterateJsdoc.js').Integer,
195
+ * string: string
196
+ * }} cfg
197
+ */
198
+ const checkRules = function ({
199
+ nonJSPrefacingCols,
200
+ nonJSPrefacingLines,
201
+ string
202
+ }) {
203
+ const cliConfig = {
204
+ allowInlineConfig,
205
+ baseConfig,
206
+ configFile,
207
+ reportUnusedDisableDirectives,
208
+ rulePaths,
209
+ rules,
210
+ useEslintrc: checkEslintrc
211
+ };
212
+ const cliConfigStr = JSON.stringify(cliConfig);
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 fileNameMapKey = filename ? 'a' + cliConfigStr + filename : 'b' + cliConfigStr + defaultFileName;
217
+ const file = filename || defaultFileName;
218
+ let cliFile;
219
+ if (matchingFileNameMap.has(fileNameMapKey)) {
220
+ cliFile = matchingFileNameMap.get(fileNameMapKey);
221
+ } else {
222
+ const cli = new CLIEngine(cliConfig);
223
+ let config;
224
+ if (filename || checkEslintrc) {
225
+ config = cli.getConfigForFile(file);
226
+ }
227
+
228
+ // We need a new instance to ensure that the rules that may only
229
+ // be available to `file` (if it has its own `.eslintrc`),
230
+ // will be defined.
231
+ cliFile = new CLIEngine({
232
+ allowInlineConfig,
233
+ baseConfig: {
234
+ ...baseConfig,
235
+ ...config
236
+ },
237
+ configFile,
238
+ reportUnusedDisableDirectives,
239
+ rulePaths,
240
+ rules,
241
+ useEslintrc: false
242
+ });
243
+ matchingFileNameMap.set(fileNameMapKey, cliFile);
244
+ }
245
+ const {
246
+ results: [{
247
+ messages
248
+ }]
249
+ } = cliFile.executeOnText(src);
250
+ if (!('line' in tag)) {
251
+ tag.line = tag.source[0].number;
252
+ }
253
+
254
+ // NOTE: `tag.line` can be 0 if of form `/** @tag ... */`
255
+ const codeStartLine =
256
+ /**
257
+ * @type {import('comment-parser').Spec & {
258
+ * line: import('../iterateJsdoc.js').Integer,
259
+ * }}
260
+ */
261
+ tag.line + nonJSPrefacingLines;
262
+ const codeStartCol = likelyNestedJSDocIndentSpace;
263
+ for (const {
264
+ column,
265
+ line,
266
+ message,
267
+ ruleId,
268
+ severity
269
+ } of messages) {
270
+ const startLine = codeStartLine + line + zeroBasedLineIndexAdjust;
271
+ const startCol = codeStartCol + (
272
+ // This might not work for line 0, but line 0 is unlikely for examples
273
+ line <= 1 ? nonJSPrefacingCols + firstLinePrefixLength : preTagSpaceLength) + column;
274
+ report('@' + targetTagName + ' ' + (severity === 2 ? 'error' : 'warning') + (ruleId ? ' (' + ruleId + ')' : '') + ': ' + message, null, {
275
+ column: startCol,
276
+ line: startLine
277
+ });
278
+ }
279
+ };
280
+ for (const targetSource of sources) {
281
+ checkRules(targetSource);
282
+ }
283
+ };
284
+
285
+ /**
286
+ *
287
+ * @param {string} filename
288
+ * @param {string} [ext] Since `eslint-plugin-markdown` v2, and
289
+ * ESLint 7, this is the default which other JS-fenced rules will used.
290
+ * Formerly "md" was the default.
291
+ * @returns {{defaultFileName: string|undefined, filename: string}}
292
+ */
293
+ const getFilenameInfo = (filename, ext = 'md/*.js') => {
294
+ let defaultFileName;
295
+ if (!filename) {
296
+ const jsFileName = context.getFilename();
297
+ if (typeof jsFileName === 'string' && jsFileName.includes('.')) {
298
+ defaultFileName = jsFileName.replace(/\.[^.]*$/v, `.${ext}`);
299
+ } else {
300
+ defaultFileName = `dummy.${ext}`;
301
+ }
302
+ }
303
+ return {
304
+ defaultFileName,
305
+ filename
306
+ };
307
+ };
308
+ if (checkDefaults) {
309
+ const filenameInfo = getFilenameInfo(matchingFileNameDefaults, 'jsdoc-defaults');
310
+ utils.forEachPreferredTag('default', (tag, targetTagName) => {
311
+ if (!tag.description.trim()) {
312
+ return;
313
+ }
314
+ checkSource({
315
+ source: `(${utils.getTagDescription(tag)})`,
316
+ targetTagName,
317
+ ...filenameInfo
318
+ });
319
+ });
320
+ }
321
+ if (checkParams) {
322
+ const filenameInfo = getFilenameInfo(matchingFileNameParams, 'jsdoc-params');
323
+ utils.forEachPreferredTag('param', (tag, targetTagName) => {
324
+ if (!tag.default || !tag.default.trim()) {
325
+ return;
326
+ }
327
+ checkSource({
328
+ source: `(${tag.default})`,
329
+ targetTagName,
330
+ ...filenameInfo
331
+ });
332
+ });
333
+ }
334
+ if (checkProperties) {
335
+ const filenameInfo = getFilenameInfo(matchingFileNameProperties, 'jsdoc-properties');
336
+ utils.forEachPreferredTag('property', (tag, targetTagName) => {
337
+ if (!tag.default || !tag.default.trim()) {
338
+ return;
339
+ }
340
+ checkSource({
341
+ source: `(${tag.default})`,
342
+ targetTagName,
343
+ ...filenameInfo
344
+ });
345
+ });
346
+ }
347
+ const tagName = /** @type {string} */utils.getPreferredTagName({
348
+ tagName: 'example'
349
+ });
350
+ if (!utils.hasTag(tagName)) {
351
+ return;
352
+ }
353
+ const matchingFilenameInfo = getFilenameInfo(matchingFileName);
354
+ utils.forEachPreferredTag('example', (tag, targetTagName) => {
355
+ let source = /** @type {string} */utils.getTagDescription(tag);
356
+ const match = source.match(hasCaptionRegex);
357
+ if (captionRequired && (!match || !match[1].trim())) {
358
+ report('Caption is expected for examples.', null, tag);
359
+ }
360
+ source = source.replace(hasCaptionRegex, '');
361
+ const [lines, cols] = match ? getLinesCols(match[0]) : [0, 0];
362
+ if (exampleCodeRegex && !exampleCodeRegex.test(source) || rejectExampleCodeRegex && rejectExampleCodeRegex.test(source)) {
363
+ return;
364
+ }
365
+ const sources = [];
366
+ let skipInit = false;
367
+ if (exampleCodeRegex) {
368
+ let nonJSPrefacingCols = 0;
369
+ let nonJSPrefacingLines = 0;
370
+ let startingIndex = 0;
371
+ let lastStringCount = 0;
372
+ let exampleCode;
373
+ exampleCodeRegex.lastIndex = 0;
374
+ while ((exampleCode = exampleCodeRegex.exec(source)) !== null) {
375
+ const {
376
+ '0': n0,
377
+ '1': n1,
378
+ index
379
+ } = exampleCode;
380
+
381
+ // Count anything preceding user regex match (can affect line numbering)
382
+ const preMatch = source.slice(startingIndex, index);
383
+ const [preMatchLines, colDelta] = getLinesCols(preMatch);
384
+ let nonJSPreface;
385
+ let nonJSPrefaceLineCount;
386
+ if (n1) {
387
+ const idx = n0.indexOf(n1);
388
+ nonJSPreface = n0.slice(0, idx);
389
+ nonJSPrefaceLineCount = countChars(nonJSPreface, '\n');
390
+ } else {
391
+ nonJSPreface = '';
392
+ nonJSPrefaceLineCount = 0;
393
+ }
394
+ nonJSPrefacingLines += lastStringCount + preMatchLines + nonJSPrefaceLineCount;
395
+
396
+ // Ignore `preMatch` delta if newlines here
397
+ if (nonJSPrefaceLineCount) {
398
+ const charsInLastLine = nonJSPreface.slice(nonJSPreface.lastIndexOf('\n') + 1).length;
399
+ nonJSPrefacingCols += charsInLastLine;
400
+ } else {
401
+ nonJSPrefacingCols += colDelta + nonJSPreface.length;
402
+ }
403
+ const string = n1 || n0;
404
+ sources.push({
405
+ nonJSPrefacingCols,
406
+ nonJSPrefacingLines,
407
+ string
408
+ });
409
+ startingIndex = exampleCodeRegex.lastIndex;
410
+ lastStringCount = countChars(string, '\n');
411
+ if (!exampleCodeRegex.global) {
412
+ break;
413
+ }
414
+ }
415
+ skipInit = true;
416
+ }
417
+ checkSource({
418
+ cols,
419
+ lines,
420
+ rules: mdRules,
421
+ skipInit,
422
+ source,
423
+ sources,
424
+ tag,
425
+ targetTagName,
426
+ ...matchingFilenameInfo
427
+ });
428
+ });
286
429
  }, {
287
- iterateAllJsdocs: true,
288
- meta: {
289
- docs: {
290
- description: "Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.",
291
- url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-examples.md#repos-sticky-header"
292
- },
293
- schema: [{
294
- additionalProperties: false,
295
- properties: {
296
- allowInlineConfig: {
297
- default: true,
298
- type: "boolean"
299
- },
300
- baseConfig: { type: "object" },
301
- captionRequired: {
302
- default: false,
303
- type: "boolean"
304
- },
305
- checkDefaults: {
306
- default: false,
307
- type: "boolean"
308
- },
309
- checkEslintrc: {
310
- default: true,
311
- type: "boolean"
312
- },
313
- checkParams: {
314
- default: false,
315
- type: "boolean"
316
- },
317
- checkProperties: {
318
- default: false,
319
- type: "boolean"
320
- },
321
- configFile: { type: "string" },
322
- exampleCodeRegex: { type: "string" },
323
- matchingFileName: { type: "string" },
324
- matchingFileNameDefaults: { type: "string" },
325
- matchingFileNameParams: { type: "string" },
326
- matchingFileNameProperties: { type: "string" },
327
- noDefaultExampleRules: {
328
- default: false,
329
- type: "boolean"
330
- },
331
- paddedIndent: {
332
- default: 0,
333
- type: "integer"
334
- },
335
- rejectExampleCodeRegex: { type: "string" },
336
- reportUnusedDisableDirectives: {
337
- default: true,
338
- type: "boolean"
339
- }
340
- },
341
- type: "object"
342
- }],
343
- type: "suggestion"
344
- }
430
+ iterateAllJsdocs: true,
431
+ meta: {
432
+ docs: {
433
+ description: 'Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.',
434
+ url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/check-examples.md#repos-sticky-header'
435
+ },
436
+ schema: [{
437
+ additionalProperties: false,
438
+ properties: {
439
+ allowInlineConfig: {
440
+ default: true,
441
+ type: 'boolean'
442
+ },
443
+ baseConfig: {
444
+ type: 'object'
445
+ },
446
+ captionRequired: {
447
+ default: false,
448
+ type: 'boolean'
449
+ },
450
+ checkDefaults: {
451
+ default: false,
452
+ type: 'boolean'
453
+ },
454
+ checkEslintrc: {
455
+ default: true,
456
+ type: 'boolean'
457
+ },
458
+ checkParams: {
459
+ default: false,
460
+ type: 'boolean'
461
+ },
462
+ checkProperties: {
463
+ default: false,
464
+ type: 'boolean'
465
+ },
466
+ configFile: {
467
+ type: 'string'
468
+ },
469
+ exampleCodeRegex: {
470
+ type: 'string'
471
+ },
472
+ matchingFileName: {
473
+ type: 'string'
474
+ },
475
+ matchingFileNameDefaults: {
476
+ type: 'string'
477
+ },
478
+ matchingFileNameParams: {
479
+ type: 'string'
480
+ },
481
+ matchingFileNameProperties: {
482
+ type: 'string'
483
+ },
484
+ noDefaultExampleRules: {
485
+ default: false,
486
+ type: 'boolean'
487
+ },
488
+ paddedIndent: {
489
+ default: 0,
490
+ type: 'integer'
491
+ },
492
+ rejectExampleCodeRegex: {
493
+ type: 'string'
494
+ },
495
+ reportUnusedDisableDirectives: {
496
+ default: true,
497
+ type: 'boolean'
498
+ }
499
+ },
500
+ type: 'object'
501
+ }],
502
+ type: 'suggestion'
503
+ }
345
504
  });
346
-
347
- //#endregion
348
- exports.default = checkExamples_default;
505
+ module.exports = exports.default;
349
506
  //# sourceMappingURL=checkExamples.cjs.map