eslint-plugin-jsdoc 52.0.2 → 52.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (357) hide show
  1. package/dist/WarnSettings.cjs +18 -35
  2. package/dist/WarnSettings.cjs.map +1 -1
  3. package/dist/WarnSettings.js +20 -0
  4. package/dist/WarnSettings.js.map +1 -0
  5. package/dist/_virtual/rolldown_runtime.cjs +32 -0
  6. package/dist/_virtual/rolldown_runtime.js +11 -0
  7. package/dist/alignTransform.cjs +224 -305
  8. package/dist/alignTransform.cjs.map +1 -1
  9. package/dist/alignTransform.js +241 -0
  10. package/dist/alignTransform.js.map +1 -0
  11. package/dist/defaultTagOrder.cjs +132 -43
  12. package/dist/defaultTagOrder.cjs.map +1 -1
  13. package/dist/defaultTagOrder.js +134 -0
  14. package/dist/defaultTagOrder.js.map +1 -0
  15. package/dist/exportParser.cjs +478 -696
  16. package/dist/exportParser.cjs.map +1 -1
  17. package/dist/exportParser.js +518 -0
  18. package/dist/exportParser.js.map +1 -0
  19. package/dist/getDefaultTagStructureForMode.cjs +184 -288
  20. package/dist/getDefaultTagStructureForMode.cjs.map +1 -1
  21. package/dist/getDefaultTagStructureForMode.js +188 -0
  22. package/dist/getDefaultTagStructureForMode.js.map +1 -0
  23. package/dist/getJsdocProcessorPlugin.cjs +364 -550
  24. package/dist/getJsdocProcessorPlugin.cjs.map +1 -1
  25. package/dist/getJsdocProcessorPlugin.d.cts +70 -0
  26. package/dist/getJsdocProcessorPlugin.d.cts.map +1 -0
  27. package/dist/getJsdocProcessorPlugin.d.ts +68 -65
  28. package/dist/getJsdocProcessorPlugin.d.ts.map +1 -1
  29. package/dist/getJsdocProcessorPlugin.js +383 -0
  30. package/dist/getJsdocProcessorPlugin.js.map +1 -0
  31. package/dist/index.cjs +398 -383
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +22 -0
  34. package/dist/index.d.cts.map +1 -0
  35. package/dist/index.d.ts +11 -6
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +425 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/iterateJsdoc.cjs +1528 -1988
  40. package/dist/iterateJsdoc.cjs.map +1 -1
  41. package/dist/iterateJsdoc.d.cts +471 -0
  42. package/dist/iterateJsdoc.d.cts.map +1 -0
  43. package/dist/iterateJsdoc.d.ts +358 -349
  44. package/dist/iterateJsdoc.d.ts.map +1 -1
  45. package/dist/iterateJsdoc.js +1617 -0
  46. package/dist/iterateJsdoc.js.map +1 -0
  47. package/dist/jsdocUtils.cjs +1009 -1376
  48. package/dist/jsdocUtils.cjs.map +1 -1
  49. package/dist/jsdocUtils.js +1123 -0
  50. package/dist/jsdocUtils.js.map +1 -0
  51. package/dist/rules/checkAccess.cjs +29 -36
  52. package/dist/rules/checkAccess.cjs.map +1 -1
  53. package/dist/rules/checkAccess.js +33 -0
  54. package/dist/rules/checkAccess.js.map +1 -0
  55. package/dist/rules/checkAlignment.cjs +41 -54
  56. package/dist/rules/checkAlignment.cjs.map +1 -1
  57. package/dist/rules/checkAlignment.js +47 -0
  58. package/dist/rules/checkAlignment.js.map +1 -0
  59. package/dist/rules/checkExamples.cjs +327 -484
  60. package/dist/rules/checkExamples.cjs.map +1 -1
  61. package/dist/rules/checkExamples.js +348 -0
  62. package/dist/rules/checkExamples.js.map +1 -0
  63. package/dist/rules/checkIndentation.cjs +50 -65
  64. package/dist/rules/checkIndentation.cjs.map +1 -1
  65. package/dist/rules/checkIndentation.js +59 -0
  66. package/dist/rules/checkIndentation.js.map +1 -0
  67. package/dist/rules/checkLineAlignment.cjs +220 -311
  68. package/dist/rules/checkLineAlignment.cjs.map +1 -1
  69. package/dist/rules/checkLineAlignment.js +229 -0
  70. package/dist/rules/checkLineAlignment.js.map +1 -0
  71. package/dist/rules/checkParamNames.cjs +227 -335
  72. package/dist/rules/checkParamNames.cjs.map +1 -1
  73. package/dist/rules/checkParamNames.js +237 -0
  74. package/dist/rules/checkParamNames.js.map +1 -0
  75. package/dist/rules/checkPropertyNames.cjs +78 -106
  76. package/dist/rules/checkPropertyNames.cjs.map +1 -1
  77. package/dist/rules/checkPropertyNames.js +88 -0
  78. package/dist/rules/checkPropertyNames.js.map +1 -0
  79. package/dist/rules/checkSyntax.cjs +21 -34
  80. package/dist/rules/checkSyntax.cjs.map +1 -1
  81. package/dist/rules/checkSyntax.js +25 -0
  82. package/dist/rules/checkSyntax.js.map +1 -0
  83. package/dist/rules/checkTagNames.cjs +188 -210
  84. package/dist/rules/checkTagNames.cjs.map +1 -1
  85. package/dist/rules/checkTagNames.js +191 -0
  86. package/dist/rules/checkTagNames.js.map +1 -0
  87. package/dist/rules/checkTemplateNames.cjs +121 -178
  88. package/dist/rules/checkTemplateNames.cjs.map +1 -1
  89. package/dist/rules/checkTemplateNames.js +124 -0
  90. package/dist/rules/checkTemplateNames.js.map +1 -0
  91. package/dist/rules/checkTypes.cjs +291 -385
  92. package/dist/rules/checkTypes.cjs.map +1 -1
  93. package/dist/rules/checkTypes.js +299 -0
  94. package/dist/rules/checkTypes.js.map +1 -0
  95. package/dist/rules/checkValues.cjs +100 -146
  96. package/dist/rules/checkValues.cjs.map +1 -1
  97. package/dist/rules/checkValues.js +103 -0
  98. package/dist/rules/checkValues.js.map +1 -0
  99. package/dist/rules/convertToJsdocComments.cjs +228 -306
  100. package/dist/rules/convertToJsdocComments.cjs.map +1 -1
  101. package/dist/rules/convertToJsdocComments.js +231 -0
  102. package/dist/rules/convertToJsdocComments.js.map +1 -0
  103. package/dist/rules/emptyTags.cjs +62 -72
  104. package/dist/rules/emptyTags.cjs.map +1 -1
  105. package/dist/rules/emptyTags.js +67 -0
  106. package/dist/rules/emptyTags.js.map +1 -0
  107. package/dist/rules/implementsOnClasses.cjs +36 -56
  108. package/dist/rules/implementsOnClasses.cjs.map +1 -1
  109. package/dist/rules/implementsOnClasses.js +40 -0
  110. package/dist/rules/implementsOnClasses.js.map +1 -0
  111. package/dist/rules/importsAsDependencies.cjs +62 -99
  112. package/dist/rules/importsAsDependencies.cjs.map +1 -1
  113. package/dist/rules/importsAsDependencies.js +68 -0
  114. package/dist/rules/importsAsDependencies.js.map +1 -0
  115. package/dist/rules/informativeDocs.cjs +105 -142
  116. package/dist/rules/informativeDocs.cjs.map +1 -1
  117. package/dist/rules/informativeDocs.js +110 -0
  118. package/dist/rules/informativeDocs.js.map +1 -0
  119. package/dist/rules/linesBeforeBlock.cjs +70 -105
  120. package/dist/rules/linesBeforeBlock.cjs.map +1 -1
  121. package/dist/rules/linesBeforeBlock.js +75 -0
  122. package/dist/rules/linesBeforeBlock.js.map +1 -0
  123. package/dist/rules/matchDescription.cjs +160 -222
  124. package/dist/rules/matchDescription.cjs.map +1 -1
  125. package/dist/rules/matchDescription.js +167 -0
  126. package/dist/rules/matchDescription.js.map +1 -0
  127. package/dist/rules/matchName.cjs +73 -128
  128. package/dist/rules/matchName.cjs.map +1 -1
  129. package/dist/rules/matchName.js +77 -0
  130. package/dist/rules/matchName.js.map +1 -0
  131. package/dist/rules/multilineBlocks.cjs +235 -352
  132. package/dist/rules/multilineBlocks.cjs.map +1 -1
  133. package/dist/rules/multilineBlocks.js +245 -0
  134. package/dist/rules/multilineBlocks.js.map +1 -0
  135. package/dist/rules/noBadBlocks.cjs +63 -86
  136. package/dist/rules/noBadBlocks.cjs.map +1 -1
  137. package/dist/rules/noBadBlocks.js +68 -0
  138. package/dist/rules/noBadBlocks.js.map +1 -0
  139. package/dist/rules/noBlankBlockDescriptions.cjs +35 -57
  140. package/dist/rules/noBlankBlockDescriptions.cjs.map +1 -1
  141. package/dist/rules/noBlankBlockDescriptions.js +41 -0
  142. package/dist/rules/noBlankBlockDescriptions.js.map +1 -0
  143. package/dist/rules/noBlankBlocks.cjs +26 -48
  144. package/dist/rules/noBlankBlocks.cjs.map +1 -1
  145. package/dist/rules/noBlankBlocks.js +30 -0
  146. package/dist/rules/noBlankBlocks.js.map +1 -0
  147. package/dist/rules/noDefaults.cjs +52 -79
  148. package/dist/rules/noDefaults.cjs.map +1 -1
  149. package/dist/rules/noDefaults.js +56 -0
  150. package/dist/rules/noDefaults.js.map +1 -0
  151. package/dist/rules/noMissingSyntax.cjs +115 -165
  152. package/dist/rules/noMissingSyntax.cjs.map +1 -1
  153. package/dist/rules/noMissingSyntax.js +126 -0
  154. package/dist/rules/noMissingSyntax.js.map +1 -0
  155. package/dist/rules/noMultiAsterisks.cjs +48 -89
  156. package/dist/rules/noMultiAsterisks.cjs.map +1 -1
  157. package/dist/rules/noMultiAsterisks.js +58 -0
  158. package/dist/rules/noMultiAsterisks.js.map +1 -0
  159. package/dist/rules/noRestrictedSyntax.cjs +45 -79
  160. package/dist/rules/noRestrictedSyntax.cjs.map +1 -1
  161. package/dist/rules/noRestrictedSyntax.js +49 -0
  162. package/dist/rules/noRestrictedSyntax.js.map +1 -0
  163. package/dist/rules/noTypes.cjs +59 -80
  164. package/dist/rules/noTypes.cjs.map +1 -1
  165. package/dist/rules/noTypes.js +65 -0
  166. package/dist/rules/noTypes.js.map +1 -0
  167. package/dist/rules/noUndefinedTypes.cjs +297 -388
  168. package/dist/rules/noUndefinedTypes.cjs.map +1 -1
  169. package/dist/rules/noUndefinedTypes.js +303 -0
  170. package/dist/rules/noUndefinedTypes.js.map +1 -0
  171. package/dist/rules/requireAsteriskPrefix.cjs +108 -159
  172. package/dist/rules/requireAsteriskPrefix.cjs.map +1 -1
  173. package/dist/rules/requireAsteriskPrefix.js +112 -0
  174. package/dist/rules/requireAsteriskPrefix.js.map +1 -0
  175. package/dist/rules/requireDescription.cjs +89 -129
  176. package/dist/rules/requireDescription.cjs.map +1 -1
  177. package/dist/rules/requireDescription.js +95 -0
  178. package/dist/rules/requireDescription.js.map +1 -0
  179. package/dist/rules/requireDescriptionCompleteSentence.cjs +201 -262
  180. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +1 -1
  181. package/dist/rules/requireDescriptionCompleteSentence.js +220 -0
  182. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -0
  183. package/dist/rules/requireExample.cjs +73 -104
  184. package/dist/rules/requireExample.cjs.map +1 -1
  185. package/dist/rules/requireExample.js +77 -0
  186. package/dist/rules/requireExample.js.map +1 -0
  187. package/dist/rules/requireFileOverview.cjs +75 -129
  188. package/dist/rules/requireFileOverview.cjs.map +1 -1
  189. package/dist/rules/requireFileOverview.js +81 -0
  190. package/dist/rules/requireFileOverview.js.map +1 -0
  191. package/dist/rules/requireHyphenBeforeParamDescription.cjs +85 -133
  192. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +1 -1
  193. package/dist/rules/requireHyphenBeforeParamDescription.js +89 -0
  194. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -0
  195. package/dist/rules/requireJsdoc.cjs +384 -557
  196. package/dist/rules/requireJsdoc.cjs.map +1 -1
  197. package/dist/rules/requireJsdoc.js +404 -0
  198. package/dist/rules/requireJsdoc.js.map +1 -0
  199. package/dist/rules/requireParam.cjs +336 -526
  200. package/dist/rules/requireParam.cjs.map +1 -1
  201. package/dist/rules/requireParam.js +344 -0
  202. package/dist/rules/requireParam.js.map +1 -0
  203. package/dist/rules/requireParamDescription.cjs +55 -80
  204. package/dist/rules/requireParamDescription.cjs.map +1 -1
  205. package/dist/rules/requireParamDescription.js +59 -0
  206. package/dist/rules/requireParamDescription.js.map +1 -0
  207. package/dist/rules/requireParamName.cjs +32 -50
  208. package/dist/rules/requireParamName.cjs.map +1 -1
  209. package/dist/rules/requireParamName.js +36 -0
  210. package/dist/rules/requireParamName.js.map +1 -0
  211. package/dist/rules/requireParamType.cjs +55 -80
  212. package/dist/rules/requireParamType.cjs.map +1 -1
  213. package/dist/rules/requireParamType.js +59 -0
  214. package/dist/rules/requireParamType.js.map +1 -0
  215. package/dist/rules/requireProperty.cjs +31 -42
  216. package/dist/rules/requireProperty.cjs.map +1 -1
  217. package/dist/rules/requireProperty.js +35 -0
  218. package/dist/rules/requireProperty.js.map +1 -0
  219. package/dist/rules/requirePropertyDescription.cjs +17 -25
  220. package/dist/rules/requirePropertyDescription.cjs.map +1 -1
  221. package/dist/rules/requirePropertyDescription.js +21 -0
  222. package/dist/rules/requirePropertyDescription.js.map +1 -0
  223. package/dist/rules/requirePropertyName.cjs +17 -25
  224. package/dist/rules/requirePropertyName.cjs.map +1 -1
  225. package/dist/rules/requirePropertyName.js +21 -0
  226. package/dist/rules/requirePropertyName.js.map +1 -0
  227. package/dist/rules/requirePropertyType.cjs +17 -25
  228. package/dist/rules/requirePropertyType.cjs.map +1 -1
  229. package/dist/rules/requirePropertyType.js +21 -0
  230. package/dist/rules/requirePropertyType.js.map +1 -0
  231. package/dist/rules/requireReturns.cjs +125 -203
  232. package/dist/rules/requireReturns.cjs.map +1 -1
  233. package/dist/rules/requireReturns.js +131 -0
  234. package/dist/rules/requireReturns.js.map +1 -0
  235. package/dist/rules/requireReturnsCheck.cjs +60 -103
  236. package/dist/rules/requireReturnsCheck.cjs.map +1 -1
  237. package/dist/rules/requireReturnsCheck.js +66 -0
  238. package/dist/rules/requireReturnsCheck.js.map +1 -0
  239. package/dist/rules/requireReturnsDescription.cjs +39 -54
  240. package/dist/rules/requireReturnsDescription.cjs.map +1 -1
  241. package/dist/rules/requireReturnsDescription.js +43 -0
  242. package/dist/rules/requireReturnsDescription.js.map +1 -0
  243. package/dist/rules/requireReturnsType.cjs +32 -50
  244. package/dist/rules/requireReturnsType.cjs.map +1 -1
  245. package/dist/rules/requireReturnsType.js +36 -0
  246. package/dist/rules/requireReturnsType.js.map +1 -0
  247. package/dist/rules/requireTemplate.cjs +119 -178
  248. package/dist/rules/requireTemplate.cjs.map +1 -1
  249. package/dist/rules/requireTemplate.js +122 -0
  250. package/dist/rules/requireTemplate.js.map +1 -0
  251. package/dist/rules/requireThrows.cjs +61 -95
  252. package/dist/rules/requireThrows.cjs.map +1 -1
  253. package/dist/rules/requireThrows.js +67 -0
  254. package/dist/rules/requireThrows.js.map +1 -0
  255. package/dist/rules/requireYields.cjs +106 -166
  256. package/dist/rules/requireYields.cjs.map +1 -1
  257. package/dist/rules/requireYields.js +115 -0
  258. package/dist/rules/requireYields.js.map +1 -0
  259. package/dist/rules/requireYieldsCheck.cjs +96 -152
  260. package/dist/rules/requireYieldsCheck.cjs.map +1 -1
  261. package/dist/rules/requireYieldsCheck.js +105 -0
  262. package/dist/rules/requireYieldsCheck.js.map +1 -0
  263. package/dist/rules/sortTags.cjs +258 -444
  264. package/dist/rules/sortTags.cjs.map +1 -1
  265. package/dist/rules/sortTags.js +262 -0
  266. package/dist/rules/sortTags.js.map +1 -0
  267. package/dist/rules/tagLines.cjs +179 -266
  268. package/dist/rules/tagLines.cjs.map +1 -1
  269. package/dist/rules/tagLines.js +183 -0
  270. package/dist/rules/tagLines.js.map +1 -0
  271. package/dist/rules/textEscaping.cjs +92 -127
  272. package/dist/rules/textEscaping.cjs.map +1 -1
  273. package/dist/rules/textEscaping.js +102 -0
  274. package/dist/rules/textEscaping.js.map +1 -0
  275. package/dist/rules/validTypes.cjs +252 -265
  276. package/dist/rules/validTypes.cjs.map +1 -1
  277. package/dist/rules/validTypes.js +259 -0
  278. package/dist/rules/validTypes.js.map +1 -0
  279. package/dist/tagNames.cjs +134 -170
  280. package/dist/tagNames.cjs.map +1 -1
  281. package/dist/tagNames.js +144 -0
  282. package/dist/tagNames.js.map +1 -0
  283. package/dist/utils/hasReturnValue.cjs +246 -474
  284. package/dist/utils/hasReturnValue.cjs.map +1 -1
  285. package/dist/utils/hasReturnValue.js +265 -0
  286. package/dist/utils/hasReturnValue.js.map +1 -0
  287. package/package.json +40 -24
  288. package/dist/generateRule.cjs +0 -242
  289. package/dist/generateRule.cjs.map +0 -1
  290. package/src/WarnSettings.js +0 -34
  291. package/src/alignTransform.js +0 -358
  292. package/src/defaultTagOrder.js +0 -169
  293. package/src/exportParser.js +0 -978
  294. package/src/getDefaultTagStructureForMode.js +0 -969
  295. package/src/getJsdocProcessorPlugin.js +0 -672
  296. package/src/index.js +0 -530
  297. package/src/iterateJsdoc.js +0 -2518
  298. package/src/jsdocUtils.js +0 -1896
  299. package/src/rules/checkAccess.js +0 -45
  300. package/src/rules/checkAlignment.js +0 -63
  301. package/src/rules/checkExamples.js +0 -589
  302. package/src/rules/checkIndentation.js +0 -75
  303. package/src/rules/checkLineAlignment.js +0 -372
  304. package/src/rules/checkParamNames.js +0 -474
  305. package/src/rules/checkPropertyNames.js +0 -152
  306. package/src/rules/checkSyntax.js +0 -30
  307. package/src/rules/checkTagNames.js +0 -314
  308. package/src/rules/checkTemplateNames.js +0 -204
  309. package/src/rules/checkTypes.js +0 -535
  310. package/src/rules/checkValues.js +0 -248
  311. package/src/rules/convertToJsdocComments.js +0 -398
  312. package/src/rules/emptyTags.js +0 -98
  313. package/src/rules/implementsOnClasses.js +0 -64
  314. package/src/rules/importsAsDependencies.js +0 -133
  315. package/src/rules/informativeDocs.js +0 -189
  316. package/src/rules/linesBeforeBlock.js +0 -134
  317. package/src/rules/matchDescription.js +0 -286
  318. package/src/rules/matchName.js +0 -151
  319. package/src/rules/multilineBlocks.js +0 -493
  320. package/src/rules/noBadBlocks.js +0 -119
  321. package/src/rules/noBlankBlockDescriptions.js +0 -69
  322. package/src/rules/noBlankBlocks.js +0 -53
  323. package/src/rules/noDefaults.js +0 -85
  324. package/src/rules/noMissingSyntax.js +0 -195
  325. package/src/rules/noMultiAsterisks.js +0 -134
  326. package/src/rules/noRestrictedSyntax.js +0 -91
  327. package/src/rules/noTypes.js +0 -93
  328. package/src/rules/noUndefinedTypes.js +0 -543
  329. package/src/rules/requireAsteriskPrefix.js +0 -190
  330. package/src/rules/requireDescription.js +0 -161
  331. package/src/rules/requireDescriptionCompleteSentence.js +0 -335
  332. package/src/rules/requireExample.js +0 -118
  333. package/src/rules/requireFileOverview.js +0 -154
  334. package/src/rules/requireHyphenBeforeParamDescription.js +0 -176
  335. package/src/rules/requireJsdoc.js +0 -743
  336. package/src/rules/requireParam.js +0 -602
  337. package/src/rules/requireParamDescription.js +0 -89
  338. package/src/rules/requireParamName.js +0 -55
  339. package/src/rules/requireParamType.js +0 -89
  340. package/src/rules/requireProperty.js +0 -48
  341. package/src/rules/requirePropertyDescription.js +0 -25
  342. package/src/rules/requirePropertyName.js +0 -25
  343. package/src/rules/requirePropertyType.js +0 -25
  344. package/src/rules/requireReturns.js +0 -238
  345. package/src/rules/requireReturnsCheck.js +0 -145
  346. package/src/rules/requireReturnsDescription.js +0 -59
  347. package/src/rules/requireReturnsType.js +0 -51
  348. package/src/rules/requireTemplate.js +0 -201
  349. package/src/rules/requireThrows.js +0 -111
  350. package/src/rules/requireYields.js +0 -216
  351. package/src/rules/requireYieldsCheck.js +0 -208
  352. package/src/rules/sortTags.js +0 -558
  353. package/src/rules/tagLines.js +0 -359
  354. package/src/rules/textEscaping.js +0 -154
  355. package/src/rules/validTypes.js +0 -401
  356. package/src/tagNames.js +0 -238
  357. package/src/utils/hasReturnValue.js +0 -572
@@ -1,578 +1,405 @@
1
- "use strict";
1
+ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
+ const require_hasReturnValue = require('../utils/hasReturnValue.cjs');
3
+ const require_jsdocUtils = require('../jsdocUtils.cjs');
4
+ const require_iterateJsdoc = require('../iterateJsdoc.cjs');
5
+ const require_exportParser = require('../exportParser.cjs');
6
+ const __es_joy_jsdoccomment = require_rolldown_runtime.__toESM(require("@es-joy/jsdoccomment"));
2
7
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _exportParser = _interopRequireDefault(require("../exportParser.cjs"));
8
- var _iterateJsdoc = require("../iterateJsdoc.cjs");
9
- var _jsdocUtils = require("../jsdocUtils.cjs");
10
- var _jsdoccomment = require("@es-joy/jsdoccomment");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ //#region src/rules/requireJsdoc.js
12
9
  /**
13
- * @typedef {{
14
- * ancestorsOnly: boolean,
15
- * esm: boolean,
16
- * initModuleExports: boolean,
17
- * initWindow: boolean
18
- * }} RequireJsdocOpts
19
- */
20
-
10
+ * @typedef {{
11
+ * ancestorsOnly: boolean,
12
+ * esm: boolean,
13
+ * initModuleExports: boolean,
14
+ * initWindow: boolean
15
+ * }} RequireJsdocOpts
16
+ */
21
17
  /**
22
- * @typedef {import('eslint').Rule.Node|
23
- * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
24
- */
25
-
18
+ * @typedef {import('eslint').Rule.Node|
19
+ * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
20
+ */
26
21
  /** @type {import('json-schema').JSONSchema4} */
27
22
  const OPTIONS_SCHEMA = {
28
- additionalProperties: false,
29
- properties: {
30
- checkConstructors: {
31
- default: true,
32
- type: 'boolean'
33
- },
34
- checkGetters: {
35
- anyOf: [{
36
- type: 'boolean'
37
- }, {
38
- enum: ['no-setter'],
39
- type: 'string'
40
- }],
41
- default: true
42
- },
43
- checkSetters: {
44
- anyOf: [{
45
- type: 'boolean'
46
- }, {
47
- enum: ['no-getter'],
48
- type: 'string'
49
- }],
50
- default: true
51
- },
52
- contexts: {
53
- items: {
54
- anyOf: [{
55
- type: 'string'
56
- }, {
57
- additionalProperties: false,
58
- properties: {
59
- context: {
60
- type: 'string'
61
- },
62
- inlineCommentBlock: {
63
- type: 'boolean'
64
- },
65
- minLineCount: {
66
- type: 'integer'
67
- }
68
- },
69
- type: 'object'
70
- }]
71
- },
72
- type: 'array'
73
- },
74
- enableFixer: {
75
- default: true,
76
- type: 'boolean'
77
- },
78
- exemptEmptyConstructors: {
79
- default: false,
80
- type: 'boolean'
81
- },
82
- exemptEmptyFunctions: {
83
- default: false,
84
- type: 'boolean'
85
- },
86
- fixerMessage: {
87
- default: '',
88
- type: 'string'
89
- },
90
- minLineCount: {
91
- type: 'integer'
92
- },
93
- publicOnly: {
94
- oneOf: [{
95
- default: false,
96
- type: 'boolean'
97
- }, {
98
- additionalProperties: false,
99
- default: {},
100
- properties: {
101
- ancestorsOnly: {
102
- type: 'boolean'
103
- },
104
- cjs: {
105
- type: 'boolean'
106
- },
107
- esm: {
108
- type: 'boolean'
109
- },
110
- window: {
111
- type: 'boolean'
112
- }
113
- },
114
- type: 'object'
115
- }]
116
- },
117
- require: {
118
- additionalProperties: false,
119
- default: {},
120
- properties: {
121
- ArrowFunctionExpression: {
122
- default: false,
123
- type: 'boolean'
124
- },
125
- ClassDeclaration: {
126
- default: false,
127
- type: 'boolean'
128
- },
129
- ClassExpression: {
130
- default: false,
131
- type: 'boolean'
132
- },
133
- FunctionDeclaration: {
134
- default: true,
135
- type: 'boolean'
136
- },
137
- FunctionExpression: {
138
- default: false,
139
- type: 'boolean'
140
- },
141
- MethodDefinition: {
142
- default: false,
143
- type: 'boolean'
144
- }
145
- },
146
- type: 'object'
147
- }
148
- },
149
- type: 'object'
23
+ additionalProperties: false,
24
+ properties: {
25
+ checkConstructors: {
26
+ default: true,
27
+ type: "boolean"
28
+ },
29
+ checkGetters: {
30
+ anyOf: [{ type: "boolean" }, {
31
+ enum: ["no-setter"],
32
+ type: "string"
33
+ }],
34
+ default: true
35
+ },
36
+ checkSetters: {
37
+ anyOf: [{ type: "boolean" }, {
38
+ enum: ["no-getter"],
39
+ type: "string"
40
+ }],
41
+ default: true
42
+ },
43
+ contexts: {
44
+ items: { anyOf: [{ type: "string" }, {
45
+ additionalProperties: false,
46
+ properties: {
47
+ context: { type: "string" },
48
+ inlineCommentBlock: { type: "boolean" },
49
+ minLineCount: { type: "integer" }
50
+ },
51
+ type: "object"
52
+ }] },
53
+ type: "array"
54
+ },
55
+ enableFixer: {
56
+ default: true,
57
+ type: "boolean"
58
+ },
59
+ exemptEmptyConstructors: {
60
+ default: false,
61
+ type: "boolean"
62
+ },
63
+ exemptEmptyFunctions: {
64
+ default: false,
65
+ type: "boolean"
66
+ },
67
+ fixerMessage: {
68
+ default: "",
69
+ type: "string"
70
+ },
71
+ minLineCount: { type: "integer" },
72
+ publicOnly: { oneOf: [{
73
+ default: false,
74
+ type: "boolean"
75
+ }, {
76
+ additionalProperties: false,
77
+ default: {},
78
+ properties: {
79
+ ancestorsOnly: { type: "boolean" },
80
+ cjs: { type: "boolean" },
81
+ esm: { type: "boolean" },
82
+ window: { type: "boolean" }
83
+ },
84
+ type: "object"
85
+ }] },
86
+ require: {
87
+ additionalProperties: false,
88
+ default: {},
89
+ properties: {
90
+ ArrowFunctionExpression: {
91
+ default: false,
92
+ type: "boolean"
93
+ },
94
+ ClassDeclaration: {
95
+ default: false,
96
+ type: "boolean"
97
+ },
98
+ ClassExpression: {
99
+ default: false,
100
+ type: "boolean"
101
+ },
102
+ FunctionDeclaration: {
103
+ default: true,
104
+ type: "boolean"
105
+ },
106
+ FunctionExpression: {
107
+ default: false,
108
+ type: "boolean"
109
+ },
110
+ MethodDefinition: {
111
+ default: false,
112
+ type: "boolean"
113
+ }
114
+ },
115
+ type: "object"
116
+ }
117
+ },
118
+ type: "object"
150
119
  };
151
-
152
120
  /**
153
- * @param {string} interfaceName
154
- * @param {string} methodName
155
- * @param {import("eslint").Scope.Scope | null} scope
156
- * @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
157
- */
121
+ * @param {string} interfaceName
122
+ * @param {string} methodName
123
+ * @param {import("eslint").Scope.Scope | null} scope
124
+ * @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
125
+ */
158
126
  const getMethodOnInterface = (interfaceName, methodName, scope) => {
159
- let scp = scope;
160
- while (scp) {
161
- for (const {
162
- identifiers,
163
- name
164
- } of scp.variables) {
165
- if (interfaceName !== name) {
166
- continue;
167
- }
168
- for (const identifier of identifiers) {
169
- const interfaceDeclaration = /** @type {import('@typescript-eslint/types').TSESTree.Identifier & {parent: import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration}} */identifier.parent;
170
- /* c8 ignore next 3 -- TS */
171
- if (interfaceDeclaration.type !== 'TSInterfaceDeclaration') {
172
- continue;
173
- }
174
- for (const bodyItem of interfaceDeclaration.body.body) {
175
- const methodSig = /** @type {import('@typescript-eslint/types').TSESTree.TSMethodSignature} */
176
- bodyItem;
177
- if (methodName === /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */methodSig.key.name) {
178
- return methodSig;
179
- }
180
- }
181
- }
182
- }
183
- scp = scp.upper;
184
- }
185
- return null;
127
+ let scp = scope;
128
+ while (scp) {
129
+ for (const { identifiers, name } of scp.variables) {
130
+ if (interfaceName !== name) continue;
131
+ for (const identifier of identifiers) {
132
+ const interfaceDeclaration = identifier.parent;
133
+ /* c8 ignore next 3 -- TS */
134
+ if (interfaceDeclaration.type !== "TSInterfaceDeclaration") continue;
135
+ for (const bodyItem of interfaceDeclaration.body.body) {
136
+ const methodSig = bodyItem;
137
+ if (methodName === methodSig.key.name) return methodSig;
138
+ }
139
+ }
140
+ }
141
+ scp = scp.upper;
142
+ }
143
+ return null;
186
144
  };
187
-
188
145
  /**
189
- * @param {import('eslint').Rule.Node} node
190
- * @param {import('eslint').SourceCode} sourceCode
191
- * @param {import('eslint').Rule.RuleContext} context
192
- * @param {import('../iterateJsdoc.js').Settings} settings
193
- */
146
+ * @param {import('eslint').Rule.Node} node
147
+ * @param {import('eslint').SourceCode} sourceCode
148
+ * @param {import('eslint').Rule.RuleContext} context
149
+ * @param {import('../iterateJsdoc.js').Settings} settings
150
+ */
194
151
  const isExemptedImplementer = (node, sourceCode, context, settings) => {
195
- if (node.type === 'FunctionExpression' && node.parent.type === 'MethodDefinition' && node.parent.parent.type === 'ClassBody' && node.parent.parent.parent.type === 'ClassDeclaration' && 'implements' in node.parent.parent.parent) {
196
- const implments = /** @type {import('@typescript-eslint/types').TSESTree.TSClassImplements[]} */
197
- node.parent.parent.parent.implements;
198
- const {
199
- name: methodName
200
- } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
201
- node.parent.key;
202
- for (const impl of implments) {
203
- const {
204
- name: interfaceName
205
- } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
206
- impl.expression;
207
- const interfaceMethodNode = getMethodOnInterface(interfaceName, methodName, node && (sourceCode.getScope && /* c8 ignore next 2 */
208
- sourceCode.getScope(node) || context.getScope()));
209
- if (interfaceMethodNode) {
210
- // @ts-expect-error Ok
211
- const comment = (0, _jsdoccomment.getJSDocComment)(sourceCode, interfaceMethodNode, settings);
212
- if (comment) {
213
- return true;
214
- }
215
- }
216
- }
217
- }
218
- return false;
152
+ if (node.type === "FunctionExpression" && node.parent.type === "MethodDefinition" && node.parent.parent.type === "ClassBody" && node.parent.parent.parent.type === "ClassDeclaration" && "implements" in node.parent.parent.parent) {
153
+ const implments = node.parent.parent.parent.implements;
154
+ const { name: methodName } = node.parent.key;
155
+ for (const impl of implments) {
156
+ const { name: interfaceName } = impl.expression;
157
+ const interfaceMethodNode = getMethodOnInterface(interfaceName, methodName, node && (sourceCode.getScope && sourceCode.getScope(node) || context.getScope()));
158
+ if (interfaceMethodNode) {
159
+ const comment = (0, __es_joy_jsdoccomment.getJSDocComment)(sourceCode, interfaceMethodNode, settings);
160
+ if (comment) return true;
161
+ }
162
+ }
163
+ }
164
+ return false;
219
165
  };
220
-
221
166
  /**
222
- * @param {import('eslint').Rule.RuleContext} context
223
- * @param {import('json-schema').JSONSchema4Object} baseObject
224
- * @param {string} option
225
- * @param {string} key
226
- * @returns {boolean|undefined}
227
- */
167
+ * @param {import('eslint').Rule.RuleContext} context
168
+ * @param {import('json-schema').JSONSchema4Object} baseObject
169
+ * @param {string} option
170
+ * @param {string} key
171
+ * @returns {boolean|undefined}
172
+ */
228
173
  const getOption = (context, baseObject, option, key) => {
229
- if (context.options[0] && option in context.options[0] && (
230
- // Todo: boolean shouldn't be returning property, but
231
- // tests currently require
232
- typeof context.options[0][option] === 'boolean' || key in context.options[0][option])) {
233
- return context.options[0][option][key];
234
- }
235
- return /** @type {{[key: string]: {default?: boolean|undefined}}} */baseObject.properties[key].default;
174
+ if (context.options[0] && option in context.options[0] && (typeof context.options[0][option] === "boolean" || key in context.options[0][option])) return context.options[0][option][key];
175
+ return baseObject.properties[key].default;
236
176
  };
237
-
238
177
  /**
239
- * @param {import('eslint').Rule.RuleContext} context
240
- * @param {import('../iterateJsdoc.js').Settings} settings
241
- * @returns {{
242
- * contexts: (string|{
243
- * context: string,
244
- * inlineCommentBlock: boolean,
245
- * minLineCount: import('../iterateJsdoc.js').Integer
246
- * })[],
247
- * enableFixer: boolean,
248
- * exemptEmptyConstructors: boolean,
249
- * exemptEmptyFunctions: boolean,
250
- * fixerMessage: string,
251
- * minLineCount: undefined|import('../iterateJsdoc.js').Integer,
252
- * publicOnly: boolean|{[key: string]: boolean|undefined}
253
- * require: {[key: string]: boolean|undefined}
254
- * }}
255
- */
178
+ * @param {import('eslint').Rule.RuleContext} context
179
+ * @param {import('../iterateJsdoc.js').Settings} settings
180
+ * @returns {{
181
+ * contexts: (string|{
182
+ * context: string,
183
+ * inlineCommentBlock: boolean,
184
+ * minLineCount: import('../iterateJsdoc.js').Integer
185
+ * })[],
186
+ * enableFixer: boolean,
187
+ * exemptEmptyConstructors: boolean,
188
+ * exemptEmptyFunctions: boolean,
189
+ * fixerMessage: string,
190
+ * minLineCount: undefined|import('../iterateJsdoc.js').Integer,
191
+ * publicOnly: boolean|{[key: string]: boolean|undefined}
192
+ * require: {[key: string]: boolean|undefined}
193
+ * }}
194
+ */
256
195
  const getOptions = (context, settings) => {
257
- const {
258
- contexts = settings.contexts || [],
259
- enableFixer = true,
260
- exemptEmptyConstructors = true,
261
- exemptEmptyFunctions = false,
262
- fixerMessage = '',
263
- minLineCount = undefined,
264
- publicOnly
265
- } = context.options[0] || {};
266
- return {
267
- contexts,
268
- enableFixer,
269
- exemptEmptyConstructors,
270
- exemptEmptyFunctions,
271
- fixerMessage,
272
- minLineCount,
273
- publicOnly: (baseObj => {
274
- if (!publicOnly) {
275
- return false;
276
- }
277
-
278
- /** @type {{[key: string]: boolean|undefined}} */
279
- const properties = {};
280
- for (const prop of Object.keys(/** @type {import('json-schema').JSONSchema4Object} */
281
- /** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) {
282
- const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */baseObj, 'publicOnly', prop);
283
- properties[prop] = opt;
284
- }
285
- return properties;
286
- })(/** @type {import('json-schema').JSONSchema4Object} */
287
- (/** @type {import('json-schema').JSONSchema4Object} */
288
- (/** @type {import('json-schema').JSONSchema4Object} */
289
- OPTIONS_SCHEMA.properties.publicOnly).oneOf)[1]),
290
- require: (baseObj => {
291
- /** @type {{[key: string]: boolean|undefined}} */
292
- const properties = {};
293
- for (const prop of Object.keys(/** @type {import('json-schema').JSONSchema4Object} */
294
- /** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) {
295
- const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */
296
- baseObj, 'require', prop);
297
- properties[prop] = opt;
298
- }
299
- return properties;
300
- })(/** @type {import('json-schema').JSONSchema4Object} */
301
- OPTIONS_SCHEMA.properties.require)
302
- };
196
+ const { contexts = settings.contexts || [], enableFixer = true, exemptEmptyConstructors = true, exemptEmptyFunctions = false, fixerMessage = "", minLineCount = void 0, publicOnly } = context.options[0] || {};
197
+ return {
198
+ contexts,
199
+ enableFixer,
200
+ exemptEmptyConstructors,
201
+ exemptEmptyFunctions,
202
+ fixerMessage,
203
+ minLineCount,
204
+ publicOnly: ((baseObj) => {
205
+ if (!publicOnly) return false;
206
+ /** @type {{[key: string]: boolean|undefined}} */
207
+ const properties = {};
208
+ for (const prop of Object.keys(
209
+ /** @type {import('json-schema').JSONSchema4Object} */
210
+ baseObj.properties
211
+ )) {
212
+ const opt = getOption(context, baseObj, "publicOnly", prop);
213
+ properties[prop] = opt;
214
+ }
215
+ return properties;
216
+ })(
217
+ /** @type {import('json-schema').JSONSchema4Object} */
218
+ OPTIONS_SCHEMA.properties.publicOnly.oneOf[1]
219
+ ),
220
+ require: ((baseObj) => {
221
+ /** @type {{[key: string]: boolean|undefined}} */
222
+ const properties = {};
223
+ for (const prop of Object.keys(
224
+ /** @type {import('json-schema').JSONSchema4Object} */
225
+ baseObj.properties
226
+ )) {
227
+ const opt = getOption(context, baseObj, "require", prop);
228
+ properties[prop] = opt;
229
+ }
230
+ return properties;
231
+ })(
232
+ /** @type {import('json-schema').JSONSchema4Object} */
233
+ OPTIONS_SCHEMA.properties.require
234
+ )
235
+ };
303
236
  };
304
-
305
237
  /** @type {import('eslint').Rule.RuleModule} */
306
- var _default = exports.default = {
307
- create(context) {
308
- /* c8 ignore next -- Fallback to deprecated method */
309
- const {
310
- sourceCode = context.getSourceCode()
311
- } = context;
312
- const settings = (0, _iterateJsdoc.getSettings)(context);
313
- if (!settings) {
314
- return {};
315
- }
316
- const opts = getOptions(context, settings);
317
- const {
318
- contexts,
319
- enableFixer,
320
- exemptEmptyConstructors,
321
- exemptEmptyFunctions,
322
- fixerMessage,
323
- minLineCount,
324
- require: requireOption
325
- } = opts;
326
- const publicOnly =
327
- /**
328
- * @type {{
329
- * [key: string]: boolean | undefined;
330
- * }}
331
- */
332
- opts.publicOnly;
333
-
334
- /**
335
- * @type {import('../iterateJsdoc.js').CheckJsdoc}
336
- */
337
- const checkJsDoc = (info, _handler, node) => {
338
- if (
339
- // Optimize
340
- minLineCount !== undefined || contexts.some(ctxt => {
341
- if (typeof ctxt === 'string') {
342
- return false;
343
- }
344
- const {
345
- minLineCount: count
346
- } = ctxt;
347
- return count !== undefined;
348
- })) {
349
- /**
350
- * @param {undefined|import('../iterateJsdoc.js').Integer} count
351
- */
352
- const underMinLine = count => {
353
- return count !== undefined && count > (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
354
- };
355
- if (underMinLine(minLineCount)) {
356
- return;
357
- }
358
- const {
359
- minLineCount: contextMinLineCount
360
- } =
361
- /**
362
- * @type {{
363
- * context: string;
364
- * inlineCommentBlock: boolean;
365
- * minLineCount: number;
366
- * }}
367
- */
368
- contexts.find(ctxt => {
369
- if (typeof ctxt === 'string') {
370
- return false;
371
- }
372
- const {
373
- context: ctx
374
- } = ctxt;
375
- return ctx === (info.selector || node.type);
376
- }) || {};
377
- if (underMinLine(contextMinLineCount)) {
378
- return;
379
- }
380
- }
381
- const jsDocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings);
382
- if (jsDocNode) {
383
- return;
384
- }
385
-
386
- // For those who have options configured against ANY constructors (or
387
- // setters or getters) being reported
388
- if ((0, _jsdocUtils.exemptSpeciaMethods)({
389
- description: '',
390
- inlineTags: [],
391
- problems: [],
392
- source: [],
393
- tags: []
394
- }, node, context, [OPTIONS_SCHEMA])) {
395
- return;
396
- }
397
- if (
398
- // Avoid reporting param-less, return-less functions (when
399
- // `exemptEmptyFunctions` option is set)
400
- exemptEmptyFunctions && info.isFunctionContext ||
401
- // Avoid reporting param-less, return-less constructor methods (when
402
- // `exemptEmptyConstructors` option is set)
403
- exemptEmptyConstructors && (0, _jsdocUtils.isConstructor)(node)) {
404
- const functionParameterNames = (0, _jsdocUtils.getFunctionParameterNames)(node);
405
- if (!functionParameterNames.length && !(0, _jsdocUtils.hasReturnValue)(node)) {
406
- return;
407
- }
408
- }
409
- if (isExemptedImplementer(node, sourceCode, context, settings)) {
410
- return;
411
- }
412
- const fix = /** @type {import('eslint').Rule.ReportFixer} */fixer => {
413
- // Default to one line break if the `minLines`/`maxLines` settings allow
414
- const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
415
- /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
416
- let baseNode = (0, _jsdoccomment.getReducedASTNode)(node, sourceCode);
417
- const decorator = (0, _jsdoccomment.getDecorator)(/** @type {import('eslint').Rule.Node} */
418
- baseNode);
419
- if (decorator) {
420
- baseNode = decorator;
421
- }
422
- const indent = (0, _jsdocUtils.getIndent)({
423
- text: sourceCode.getText(/** @type {import('eslint').Rule.Node} */baseNode, /** @type {import('eslint').AST.SourceLocation} */
424
- (/** @type {import('eslint').Rule.Node} */baseNode.loc).start.column)
425
- });
426
- const {
427
- inlineCommentBlock
428
- } =
429
- /**
430
- * @type {{
431
- * context: string,
432
- * inlineCommentBlock: boolean,
433
- * minLineCount: import('../iterateJsdoc.js').Integer
434
- * }}
435
- */
436
- contexts.find(contxt => {
437
- if (typeof contxt === 'string') {
438
- return false;
439
- }
440
- const {
441
- context: ctxt
442
- } = contxt;
443
- return ctxt === node.type;
444
- }) || {};
445
- const insertion = (inlineCommentBlock ? `/** ${fixerMessage}` : `/**\n${indent}*${fixerMessage}\n${indent}`) + `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`;
446
- return fixer.insertTextBefore(/** @type {import('eslint').Rule.Node} */
447
- baseNode, insertion);
448
- };
449
- const report = () => {
450
- const {
451
- start
452
- } = /** @type {import('eslint').AST.SourceLocation} */node.loc;
453
- const loc = {
454
- end: {
455
- column: 0,
456
- line: start.line + 1
457
- },
458
- start
459
- };
460
- context.report({
461
- fix: enableFixer ? fix : null,
462
- loc,
463
- messageId: 'missingJsDoc',
464
- node
465
- });
466
- };
467
- if (publicOnly) {
468
- /** @type {RequireJsdocOpts} */
469
- const opt = {
470
- ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
471
- esm: Boolean(publicOnly?.esm ?? true),
472
- initModuleExports: Boolean(publicOnly?.cjs ?? true),
473
- initWindow: Boolean(publicOnly?.window ?? false)
474
- };
475
- const exported = _exportParser.default.isUncommentedExport(node, sourceCode, opt, settings);
476
- if (exported) {
477
- report();
478
- }
479
- } else {
480
- report();
481
- }
482
- };
483
-
484
- /**
485
- * @param {string} prop
486
- * @returns {boolean}
487
- */
488
- const hasOption = prop => {
489
- return requireOption[prop] || contexts.some(ctxt => {
490
- return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop;
491
- });
492
- };
493
- return {
494
- ...(0, _jsdocUtils.getContextObject)((0, _jsdocUtils.enforcedContexts)(context, [], settings), checkJsDoc),
495
- ArrowFunctionExpression(node) {
496
- if (!hasOption('ArrowFunctionExpression')) {
497
- return;
498
- }
499
- if (['AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator'].includes(node.parent.type) || ['ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition'].includes(node.parent.type) && node ===
500
- /**
501
- * @type {import('@typescript-eslint/types').TSESTree.Property|
502
- * import('@typescript-eslint/types').TSESTree.PropertyDefinition
503
- * }
504
- */
505
- node.parent.value) {
506
- checkJsDoc({
507
- isFunctionContext: true
508
- }, null, node);
509
- }
510
- },
511
- ClassDeclaration(node) {
512
- if (!hasOption('ClassDeclaration')) {
513
- return;
514
- }
515
- checkJsDoc({
516
- isFunctionContext: false
517
- }, null, node);
518
- },
519
- ClassExpression(node) {
520
- if (!hasOption('ClassExpression')) {
521
- return;
522
- }
523
- checkJsDoc({
524
- isFunctionContext: false
525
- }, null, node);
526
- },
527
- FunctionDeclaration(node) {
528
- if (!hasOption('FunctionDeclaration')) {
529
- return;
530
- }
531
- checkJsDoc({
532
- isFunctionContext: true
533
- }, null, node);
534
- },
535
- FunctionExpression(node) {
536
- if (!hasOption('FunctionExpression')) {
537
- return;
538
- }
539
- if (['AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator'].includes(node.parent.type) || ['ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition'].includes(node.parent.type) && node ===
540
- /**
541
- * @type {import('@typescript-eslint/types').TSESTree.Property|
542
- * import('@typescript-eslint/types').TSESTree.PropertyDefinition
543
- * }
544
- */
545
- node.parent.value) {
546
- checkJsDoc({
547
- isFunctionContext: true
548
- }, null, node);
549
- }
550
- },
551
- MethodDefinition(node) {
552
- if (!hasOption('MethodDefinition')) {
553
- return;
554
- }
555
- checkJsDoc({
556
- isFunctionContext: true,
557
- selector: 'MethodDefinition'
558
- }, null, /** @type {import('eslint').Rule.Node} */node.value);
559
- }
560
- };
561
- },
562
- meta: {
563
- docs: {
564
- category: 'Stylistic Issues',
565
- description: 'Require JSDoc comments',
566
- recommended: true,
567
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header'
568
- },
569
- fixable: 'code',
570
- messages: {
571
- missingJsDoc: 'Missing JSDoc comment.'
572
- },
573
- schema: [OPTIONS_SCHEMA],
574
- type: 'suggestion'
575
- }
238
+ var requireJsdoc_default = {
239
+ create(context) {
240
+ /* c8 ignore next -- Fallback to deprecated method */
241
+ const { sourceCode = context.getSourceCode() } = context;
242
+ const settings = require_iterateJsdoc.getSettings(context);
243
+ if (!settings) return {};
244
+ const opts = getOptions(context, settings);
245
+ const { contexts, enableFixer, exemptEmptyConstructors, exemptEmptyFunctions, fixerMessage, minLineCount, require: requireOption } = opts;
246
+ const publicOnly = opts.publicOnly;
247
+ /**
248
+ * @type {import('../iterateJsdoc.js').CheckJsdoc}
249
+ */
250
+ const checkJsDoc = (info, _handler, node) => {
251
+ if (minLineCount !== void 0 || contexts.some((ctxt) => {
252
+ if (typeof ctxt === "string") return false;
253
+ const { minLineCount: count } = ctxt;
254
+ return count !== void 0;
255
+ })) {
256
+ /**
257
+ * @param {undefined|import('../iterateJsdoc.js').Integer} count
258
+ */
259
+ const underMinLine = (count) => {
260
+ return count !== void 0 && count > (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
261
+ };
262
+ if (underMinLine(minLineCount)) return;
263
+ const { minLineCount: contextMinLineCount } = contexts.find((ctxt) => {
264
+ if (typeof ctxt === "string") return false;
265
+ const { context: ctx } = ctxt;
266
+ return ctx === (info.selector || node.type);
267
+ }) || {};
268
+ if (underMinLine(contextMinLineCount)) return;
269
+ }
270
+ const jsDocNode = (0, __es_joy_jsdoccomment.getJSDocComment)(sourceCode, node, settings);
271
+ if (jsDocNode) return;
272
+ if (require_jsdocUtils.exemptSpeciaMethods({
273
+ description: "",
274
+ inlineTags: [],
275
+ problems: [],
276
+ source: [],
277
+ tags: []
278
+ }, node, context, [OPTIONS_SCHEMA])) return;
279
+ if (exemptEmptyFunctions && info.isFunctionContext || exemptEmptyConstructors && require_jsdocUtils.isConstructor(node)) {
280
+ const functionParameterNames = require_jsdocUtils.getFunctionParameterNames(node);
281
+ if (!functionParameterNames.length && !require_hasReturnValue.hasReturnValue(node)) return;
282
+ }
283
+ if (isExemptedImplementer(node, sourceCode, context, settings)) return;
284
+ const fix = (fixer) => {
285
+ const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
286
+ /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
287
+ let baseNode = (0, __es_joy_jsdoccomment.getReducedASTNode)(node, sourceCode);
288
+ const decorator = (0, __es_joy_jsdoccomment.getDecorator)(baseNode);
289
+ if (decorator) baseNode = decorator;
290
+ const indent = require_jsdocUtils.getIndent({ text: sourceCode.getText(
291
+ baseNode,
292
+ /** @type {import('eslint').AST.SourceLocation} */
293
+ baseNode.loc.start.column
294
+ ) });
295
+ const { inlineCommentBlock } = contexts.find((contxt) => {
296
+ if (typeof contxt === "string") return false;
297
+ const { context: ctxt } = contxt;
298
+ return ctxt === node.type;
299
+ }) || {};
300
+ const insertion = (inlineCommentBlock ? `/** ${fixerMessage}` : `/**\n${indent}*${fixerMessage}\n${indent}`) + `*/${"\n".repeat(lines)}${indent.slice(0, -1)}`;
301
+ return fixer.insertTextBefore(baseNode, insertion);
302
+ };
303
+ const report = () => {
304
+ const { start } = node.loc;
305
+ const loc = {
306
+ end: {
307
+ column: 0,
308
+ line: start.line + 1
309
+ },
310
+ start
311
+ };
312
+ context.report({
313
+ fix: enableFixer ? fix : null,
314
+ loc,
315
+ messageId: "missingJsDoc",
316
+ node
317
+ });
318
+ };
319
+ if (publicOnly) {
320
+ /** @type {RequireJsdocOpts} */
321
+ const opt = {
322
+ ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
323
+ esm: Boolean(publicOnly?.esm ?? true),
324
+ initModuleExports: Boolean(publicOnly?.cjs ?? true),
325
+ initWindow: Boolean(publicOnly?.window ?? false)
326
+ };
327
+ const exported = require_exportParser.default.isUncommentedExport(node, sourceCode, opt, settings);
328
+ if (exported) report();
329
+ } else report();
330
+ };
331
+ /**
332
+ * @param {string} prop
333
+ * @returns {boolean}
334
+ */
335
+ const hasOption = (prop) => {
336
+ return requireOption[prop] || contexts.some((ctxt) => {
337
+ return typeof ctxt === "object" ? ctxt.context === prop : ctxt === prop;
338
+ });
339
+ };
340
+ return {
341
+ ...require_jsdocUtils.getContextObject(require_jsdocUtils.enforcedContexts(context, [], settings), checkJsDoc),
342
+ ArrowFunctionExpression(node) {
343
+ if (!hasOption("ArrowFunctionExpression")) return;
344
+ if ([
345
+ "AssignmentExpression",
346
+ "ExportDefaultDeclaration",
347
+ "VariableDeclarator"
348
+ ].includes(node.parent.type) || [
349
+ "ClassProperty",
350
+ "ObjectProperty",
351
+ "Property",
352
+ "PropertyDefinition"
353
+ ].includes(node.parent.type) && node === node.parent.value) checkJsDoc({ isFunctionContext: true }, null, node);
354
+ },
355
+ ClassDeclaration(node) {
356
+ if (!hasOption("ClassDeclaration")) return;
357
+ checkJsDoc({ isFunctionContext: false }, null, node);
358
+ },
359
+ ClassExpression(node) {
360
+ if (!hasOption("ClassExpression")) return;
361
+ checkJsDoc({ isFunctionContext: false }, null, node);
362
+ },
363
+ FunctionDeclaration(node) {
364
+ if (!hasOption("FunctionDeclaration")) return;
365
+ checkJsDoc({ isFunctionContext: true }, null, node);
366
+ },
367
+ FunctionExpression(node) {
368
+ if (!hasOption("FunctionExpression")) return;
369
+ if ([
370
+ "AssignmentExpression",
371
+ "ExportDefaultDeclaration",
372
+ "VariableDeclarator"
373
+ ].includes(node.parent.type) || [
374
+ "ClassProperty",
375
+ "ObjectProperty",
376
+ "Property",
377
+ "PropertyDefinition"
378
+ ].includes(node.parent.type) && node === node.parent.value) checkJsDoc({ isFunctionContext: true }, null, node);
379
+ },
380
+ MethodDefinition(node) {
381
+ if (!hasOption("MethodDefinition")) return;
382
+ checkJsDoc({
383
+ isFunctionContext: true,
384
+ selector: "MethodDefinition"
385
+ }, null, node.value);
386
+ }
387
+ };
388
+ },
389
+ meta: {
390
+ docs: {
391
+ category: "Stylistic Issues",
392
+ description: "Require JSDoc comments",
393
+ recommended: true,
394
+ url: "https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header"
395
+ },
396
+ fixable: "code",
397
+ messages: { missingJsDoc: "Missing JSDoc comment." },
398
+ schema: [OPTIONS_SCHEMA],
399
+ type: "suggestion"
400
+ }
576
401
  };
577
- module.exports = exports.default;
402
+
403
+ //#endregion
404
+ exports.default = requireJsdoc_default;
578
405
  //# sourceMappingURL=requireJsdoc.cjs.map