eslint-plugin-jsdoc 52.0.1 → 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 +365 -532
  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 -90
  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 +48 -38
  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 -652
  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,506 +1,349 @@
1
- "use strict";
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"));
2
5
 
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;
6
+ //#region src/rules/checkExamples.js
7
+ const { CLIEngine } = eslint.default;
16
8
  const zeroBasedLineIndexAdjust = -1;
17
9
  const likelyNestedJSDocIndentSpace = 1;
18
10
  const preTagSpaceLength = 1;
19
-
20
- // If a space is present, we should ignore it
21
11
  const firstLinePrefixLength = preTagSpaceLength;
22
12
  const hasCaptionRegex = /^\s*<caption>([\s\S]*?)<\/caption>/v;
23
-
24
13
  /**
25
- * @param {string} str
26
- * @returns {string}
27
- */
28
- const escapeStringRegexp = str => {
29
- return str.replaceAll(/[.*+?^$\{\}\(\)\|\[\]\\]/gv, '\\$&');
14
+ * @param {string} str
15
+ * @returns {string}
16
+ */
17
+ const escapeStringRegexp = (str) => {
18
+ return str.replaceAll(/[.*+?^$\{\}\(\)\|\[\]\\]/gv, "\\$&");
30
19
  };
31
-
32
20
  /**
33
- * @param {string} str
34
- * @param {string} ch
35
- * @returns {import('../iterateJsdoc.js').Integer}
36
- */
21
+ * @param {string} str
22
+ * @param {string} ch
23
+ * @returns {import('../iterateJsdoc.js').Integer}
24
+ */
37
25
  const countChars = (str, ch) => {
38
- return (str.match(new RegExp(escapeStringRegexp(ch), 'gv')) || []).length;
26
+ return (str.match(new RegExp(escapeStringRegexp(ch), "gv")) || []).length;
39
27
  };
40
-
41
28
  /** @type {import('eslint').Linter.RulesRecord} */
42
29
  const defaultMdRules = {
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
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
66
42
  };
67
-
68
43
  /** @type {import('eslint').Linter.RulesRecord} */
69
44
  const defaultExpressionRules = {
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'
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"
78
53
  };
79
-
80
54
  /**
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];
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];
91
65
  };
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
- });
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
+ });
429
286
  }, {
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
- }
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
+ }
504
345
  });
505
- module.exports = exports.default;
346
+
347
+ //#endregion
348
+ exports.default = checkExamples_default;
506
349
  //# sourceMappingURL=checkExamples.cjs.map