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,743 +0,0 @@
1
- import exportParser from '../exportParser.js';
2
- import {
3
- getSettings,
4
- } from '../iterateJsdoc.js';
5
- import {
6
- enforcedContexts,
7
- exemptSpeciaMethods,
8
- getContextObject,
9
- getFunctionParameterNames,
10
- getIndent,
11
- hasReturnValue,
12
- isConstructor,
13
- } from '../jsdocUtils.js';
14
- import {
15
- getDecorator,
16
- getJSDocComment,
17
- getReducedASTNode,
18
- } from '@es-joy/jsdoccomment';
19
-
20
- /**
21
- * @typedef {{
22
- * ancestorsOnly: boolean,
23
- * esm: boolean,
24
- * initModuleExports: boolean,
25
- * initWindow: boolean
26
- * }} RequireJsdocOpts
27
- */
28
-
29
- /**
30
- * @typedef {import('eslint').Rule.Node|
31
- * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
32
- */
33
-
34
- /** @type {import('json-schema').JSONSchema4} */
35
- const OPTIONS_SCHEMA = {
36
- additionalProperties: false,
37
- properties: {
38
- checkConstructors: {
39
- default: true,
40
- type: 'boolean',
41
- },
42
- checkGetters: {
43
- anyOf: [
44
- {
45
- type: 'boolean',
46
- },
47
- {
48
- enum: [
49
- 'no-setter',
50
- ],
51
- type: 'string',
52
- },
53
- ],
54
- default: true,
55
- },
56
- checkSetters: {
57
- anyOf: [
58
- {
59
- type: 'boolean',
60
- },
61
- {
62
- enum: [
63
- 'no-getter',
64
- ],
65
- type: 'string',
66
- },
67
- ],
68
- default: true,
69
- },
70
- contexts: {
71
- items: {
72
- anyOf: [
73
- {
74
- type: 'string',
75
- },
76
- {
77
- additionalProperties: false,
78
- properties: {
79
- context: {
80
- type: 'string',
81
- },
82
- inlineCommentBlock: {
83
- type: 'boolean',
84
- },
85
- minLineCount: {
86
- type: 'integer',
87
- },
88
- },
89
- type: 'object',
90
- },
91
- ],
92
- },
93
- type: 'array',
94
- },
95
- enableFixer: {
96
- default: true,
97
- type: 'boolean',
98
- },
99
- exemptEmptyConstructors: {
100
- default: false,
101
- type: 'boolean',
102
- },
103
- exemptEmptyFunctions: {
104
- default: false,
105
- type: 'boolean',
106
- },
107
- fixerMessage: {
108
- default: '',
109
- type: 'string',
110
- },
111
- minLineCount: {
112
- type: 'integer',
113
- },
114
- publicOnly: {
115
- oneOf: [
116
- {
117
- default: false,
118
- type: 'boolean',
119
- },
120
- {
121
- additionalProperties: false,
122
- default: {},
123
- properties: {
124
- ancestorsOnly: {
125
- type: 'boolean',
126
- },
127
- cjs: {
128
- type: 'boolean',
129
- },
130
- esm: {
131
- type: 'boolean',
132
- },
133
- window: {
134
- type: 'boolean',
135
- },
136
- },
137
- type: 'object',
138
- },
139
- ],
140
- },
141
- require: {
142
- additionalProperties: false,
143
- default: {},
144
- properties: {
145
- ArrowFunctionExpression: {
146
- default: false,
147
- type: 'boolean',
148
- },
149
- ClassDeclaration: {
150
- default: false,
151
- type: 'boolean',
152
- },
153
- ClassExpression: {
154
- default: false,
155
- type: 'boolean',
156
- },
157
- FunctionDeclaration: {
158
- default: true,
159
- type: 'boolean',
160
- },
161
- FunctionExpression: {
162
- default: false,
163
- type: 'boolean',
164
- },
165
- MethodDefinition: {
166
- default: false,
167
- type: 'boolean',
168
- },
169
- },
170
- type: 'object',
171
- },
172
- },
173
- type: 'object',
174
- };
175
-
176
- /**
177
- * @param {string} interfaceName
178
- * @param {string} methodName
179
- * @param {import("eslint").Scope.Scope | null} scope
180
- * @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
181
- */
182
- const getMethodOnInterface = (interfaceName, methodName, scope) => {
183
- let scp = scope;
184
- while (scp) {
185
- for (const {
186
- identifiers,
187
- name,
188
- } of scp.variables) {
189
- if (interfaceName !== name) {
190
- continue;
191
- }
192
-
193
- for (const identifier of identifiers) {
194
- const interfaceDeclaration = /** @type {import('@typescript-eslint/types').TSESTree.Identifier & {parent: import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration}} */ (
195
- identifier
196
- ).parent;
197
- /* c8 ignore next 3 -- TS */
198
- if (interfaceDeclaration.type !== 'TSInterfaceDeclaration') {
199
- continue;
200
- }
201
-
202
- for (const bodyItem of interfaceDeclaration.body.body) {
203
- const methodSig = /** @type {import('@typescript-eslint/types').TSESTree.TSMethodSignature} */ (
204
- bodyItem
205
- );
206
- if (methodName === /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
207
- methodSig.key
208
- ).name) {
209
- return methodSig;
210
- }
211
- }
212
- }
213
- }
214
-
215
- scp = scp.upper;
216
- }
217
-
218
- return null;
219
- };
220
-
221
- /**
222
- * @param {import('eslint').Rule.Node} node
223
- * @param {import('eslint').SourceCode} sourceCode
224
- * @param {import('eslint').Rule.RuleContext} context
225
- * @param {import('../iterateJsdoc.js').Settings} settings
226
- */
227
- const isExemptedImplementer = (node, sourceCode, context, settings) => {
228
- if (node.type === 'FunctionExpression' &&
229
- node.parent.type === 'MethodDefinition' &&
230
- node.parent.parent.type === 'ClassBody' &&
231
- node.parent.parent.parent.type === 'ClassDeclaration' &&
232
- 'implements' in node.parent.parent.parent
233
- ) {
234
- const implments = /** @type {import('@typescript-eslint/types').TSESTree.TSClassImplements[]} */ (
235
- node.parent.parent.parent.implements
236
- );
237
-
238
- const {
239
- name: methodName,
240
- } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
241
- node.parent.key
242
- );
243
-
244
- for (const impl of implments) {
245
- const {
246
- name: interfaceName,
247
- } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */ (
248
- impl.expression
249
- );
250
-
251
- const interfaceMethodNode = getMethodOnInterface(interfaceName, methodName, node && (
252
- (sourceCode.getScope &&
253
- /* c8 ignore next 2 */
254
- sourceCode.getScope(node)) ||
255
- context.getScope()
256
- ));
257
- if (interfaceMethodNode) {
258
- // @ts-expect-error Ok
259
- const comment = getJSDocComment(sourceCode, interfaceMethodNode, settings);
260
- if (comment) {
261
- return true;
262
- }
263
- }
264
- }
265
- }
266
-
267
- return false;
268
- };
269
-
270
- /**
271
- * @param {import('eslint').Rule.RuleContext} context
272
- * @param {import('json-schema').JSONSchema4Object} baseObject
273
- * @param {string} option
274
- * @param {string} key
275
- * @returns {boolean|undefined}
276
- */
277
- const getOption = (context, baseObject, option, key) => {
278
- if (context.options[0] && option in context.options[0] &&
279
- // Todo: boolean shouldn't be returning property, but
280
- // tests currently require
281
- (typeof context.options[0][option] === 'boolean' ||
282
- key in context.options[0][option])
283
- ) {
284
- return context.options[0][option][key];
285
- }
286
-
287
- return /** @type {{[key: string]: {default?: boolean|undefined}}} */ (
288
- baseObject.properties
289
- )[key].default;
290
- };
291
-
292
- /**
293
- * @param {import('eslint').Rule.RuleContext} context
294
- * @param {import('../iterateJsdoc.js').Settings} settings
295
- * @returns {{
296
- * contexts: (string|{
297
- * context: string,
298
- * inlineCommentBlock: boolean,
299
- * minLineCount: import('../iterateJsdoc.js').Integer
300
- * })[],
301
- * enableFixer: boolean,
302
- * exemptEmptyConstructors: boolean,
303
- * exemptEmptyFunctions: boolean,
304
- * fixerMessage: string,
305
- * minLineCount: undefined|import('../iterateJsdoc.js').Integer,
306
- * publicOnly: boolean|{[key: string]: boolean|undefined}
307
- * require: {[key: string]: boolean|undefined}
308
- * }}
309
- */
310
- const getOptions = (context, settings) => {
311
- const {
312
- contexts = settings.contexts || [],
313
- enableFixer = true,
314
- exemptEmptyConstructors = true,
315
- exemptEmptyFunctions = false,
316
- fixerMessage = '',
317
- minLineCount = undefined,
318
- publicOnly,
319
- } = context.options[0] || {};
320
-
321
- return {
322
- contexts,
323
- enableFixer,
324
- exemptEmptyConstructors,
325
- exemptEmptyFunctions,
326
- fixerMessage,
327
- minLineCount,
328
- publicOnly: ((baseObj) => {
329
- if (!publicOnly) {
330
- return false;
331
- }
332
-
333
- /** @type {{[key: string]: boolean|undefined}} */
334
- const properties = {};
335
- for (const prop of Object.keys(
336
- /** @type {import('json-schema').JSONSchema4Object} */ (
337
- /** @type {import('json-schema').JSONSchema4Object} */ (
338
- baseObj
339
- ).properties),
340
- )) {
341
- const opt = getOption(
342
- context,
343
- /** @type {import('json-schema').JSONSchema4Object} */ (baseObj),
344
- 'publicOnly',
345
- prop,
346
- );
347
-
348
- properties[prop] = opt;
349
- }
350
-
351
- return properties;
352
- })(
353
- /** @type {import('json-schema').JSONSchema4Object} */
354
- (
355
- /** @type {import('json-schema').JSONSchema4Object} */
356
- (
357
- /** @type {import('json-schema').JSONSchema4Object} */
358
- (
359
- OPTIONS_SCHEMA.properties
360
- ).publicOnly
361
- ).oneOf
362
- )[1],
363
- ),
364
- require: ((baseObj) => {
365
- /** @type {{[key: string]: boolean|undefined}} */
366
- const properties = {};
367
- for (const prop of Object.keys(
368
- /** @type {import('json-schema').JSONSchema4Object} */ (
369
- /** @type {import('json-schema').JSONSchema4Object} */ (
370
- baseObj
371
- ).properties),
372
- )) {
373
- const opt = getOption(
374
- context,
375
- /** @type {import('json-schema').JSONSchema4Object} */
376
- (baseObj),
377
- 'require',
378
- prop,
379
- );
380
- properties[prop] = opt;
381
- }
382
-
383
- return properties;
384
- })(
385
- /** @type {import('json-schema').JSONSchema4Object} */
386
- (OPTIONS_SCHEMA.properties).require,
387
- ),
388
- };
389
- };
390
-
391
- /** @type {import('eslint').Rule.RuleModule} */
392
- export default {
393
- create (context) {
394
- /* c8 ignore next -- Fallback to deprecated method */
395
- const {
396
- sourceCode = context.getSourceCode(),
397
- } = context;
398
- const settings = getSettings(context);
399
- if (!settings) {
400
- return {};
401
- }
402
-
403
- const opts = getOptions(context, settings);
404
-
405
- const {
406
- contexts,
407
- enableFixer,
408
- exemptEmptyConstructors,
409
- exemptEmptyFunctions,
410
- fixerMessage,
411
- minLineCount,
412
- require: requireOption,
413
- } = opts;
414
-
415
- const publicOnly =
416
-
417
- /**
418
- * @type {{
419
- * [key: string]: boolean | undefined;
420
- * }}
421
- */ (
422
- opts.publicOnly
423
- );
424
-
425
- /**
426
- * @type {import('../iterateJsdoc.js').CheckJsdoc}
427
- */
428
- const checkJsDoc = (info, _handler, node) => {
429
- if (
430
- // Optimize
431
- minLineCount !== undefined || contexts.some((ctxt) => {
432
- if (typeof ctxt === 'string') {
433
- return false;
434
- }
435
-
436
- const {
437
- minLineCount: count,
438
- } = ctxt;
439
- return count !== undefined;
440
- })
441
- ) {
442
- /**
443
- * @param {undefined|import('../iterateJsdoc.js').Integer} count
444
- */
445
- const underMinLine = (count) => {
446
- return count !== undefined && count >
447
- (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
448
- };
449
-
450
- if (underMinLine(minLineCount)) {
451
- return;
452
- }
453
-
454
- const {
455
- minLineCount: contextMinLineCount,
456
- } =
457
- /**
458
- * @type {{
459
- * context: string;
460
- * inlineCommentBlock: boolean;
461
- * minLineCount: number;
462
- * }}
463
- */ (contexts.find((ctxt) => {
464
- if (typeof ctxt === 'string') {
465
- return false;
466
- }
467
-
468
- const {
469
- context: ctx,
470
- } = ctxt;
471
- return ctx === (info.selector || node.type);
472
- })) || {};
473
- if (underMinLine(contextMinLineCount)) {
474
- return;
475
- }
476
- }
477
-
478
- const jsDocNode = getJSDocComment(sourceCode, node, settings);
479
-
480
- if (jsDocNode) {
481
- return;
482
- }
483
-
484
- // For those who have options configured against ANY constructors (or
485
- // setters or getters) being reported
486
- if (exemptSpeciaMethods(
487
- {
488
- description: '',
489
- inlineTags: [],
490
- problems: [],
491
- source: [],
492
- tags: [],
493
- },
494
- node,
495
- context,
496
- [
497
- OPTIONS_SCHEMA,
498
- ],
499
- )) {
500
- return;
501
- }
502
-
503
- if (
504
- // Avoid reporting param-less, return-less functions (when
505
- // `exemptEmptyFunctions` option is set)
506
- exemptEmptyFunctions && info.isFunctionContext ||
507
-
508
- // Avoid reporting param-less, return-less constructor methods (when
509
- // `exemptEmptyConstructors` option is set)
510
- exemptEmptyConstructors && isConstructor(node)
511
- ) {
512
- const functionParameterNames = getFunctionParameterNames(node);
513
- if (!functionParameterNames.length && !hasReturnValue(node)) {
514
- return;
515
- }
516
- }
517
-
518
- if (isExemptedImplementer(node, sourceCode, context, settings)) {
519
- return;
520
- }
521
-
522
- const fix = /** @type {import('eslint').Rule.ReportFixer} */ (fixer) => {
523
- // Default to one line break if the `minLines`/`maxLines` settings allow
524
- const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
525
- /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
526
- let baseNode = getReducedASTNode(node, sourceCode);
527
-
528
- const decorator = getDecorator(
529
- /** @type {import('eslint').Rule.Node} */
530
- (baseNode),
531
- );
532
- if (decorator) {
533
- baseNode = decorator;
534
- }
535
-
536
- const indent = getIndent({
537
- text: sourceCode.getText(
538
- /** @type {import('eslint').Rule.Node} */ (baseNode),
539
- /** @type {import('eslint').AST.SourceLocation} */
540
- (
541
- /** @type {import('eslint').Rule.Node} */ (baseNode).loc
542
- ).start.column,
543
- ),
544
- });
545
-
546
- const {
547
- inlineCommentBlock,
548
- } =
549
- /**
550
- * @type {{
551
- * context: string,
552
- * inlineCommentBlock: boolean,
553
- * minLineCount: import('../iterateJsdoc.js').Integer
554
- * }}
555
- */ (contexts.find((contxt) => {
556
- if (typeof contxt === 'string') {
557
- return false;
558
- }
559
-
560
- const {
561
- context: ctxt,
562
- } = contxt;
563
- return ctxt === node.type;
564
- })) || {};
565
- const insertion = (inlineCommentBlock ?
566
- `/** ${fixerMessage}` :
567
- `/**\n${indent}*${fixerMessage}\n${indent}`) +
568
- `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`;
569
-
570
- return fixer.insertTextBefore(
571
- /** @type {import('eslint').Rule.Node} */
572
- (baseNode),
573
- insertion,
574
- );
575
- };
576
-
577
- const report = () => {
578
- const {
579
- start,
580
- } = /** @type {import('eslint').AST.SourceLocation} */ (node.loc);
581
- const loc = {
582
- end: {
583
- column: 0,
584
- line: start.line + 1,
585
- },
586
- start,
587
- };
588
- context.report({
589
- fix: enableFixer ? fix : null,
590
- loc,
591
- messageId: 'missingJsDoc',
592
- node,
593
- });
594
- };
595
-
596
- if (publicOnly) {
597
- /** @type {RequireJsdocOpts} */
598
- const opt = {
599
- ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
600
- esm: Boolean(publicOnly?.esm ?? true),
601
- initModuleExports: Boolean(publicOnly?.cjs ?? true),
602
- initWindow: Boolean(publicOnly?.window ?? false),
603
- };
604
- const exported = exportParser.isUncommentedExport(node, sourceCode, opt, settings);
605
-
606
- if (exported) {
607
- report();
608
- }
609
- } else {
610
- report();
611
- }
612
- };
613
-
614
- /**
615
- * @param {string} prop
616
- * @returns {boolean}
617
- */
618
- const hasOption = (prop) => {
619
- return requireOption[prop] || contexts.some((ctxt) => {
620
- return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop;
621
- });
622
- };
623
-
624
- return {
625
- ...getContextObject(
626
- enforcedContexts(context, [], settings),
627
- checkJsDoc,
628
- ),
629
- ArrowFunctionExpression (node) {
630
- if (!hasOption('ArrowFunctionExpression')) {
631
- return;
632
- }
633
-
634
- if (
635
- [
636
- 'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
637
- ].includes(node.parent.type) ||
638
- [
639
- 'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
640
- ].includes(node.parent.type) &&
641
- node ===
642
- /**
643
- * @type {import('@typescript-eslint/types').TSESTree.Property|
644
- * import('@typescript-eslint/types').TSESTree.PropertyDefinition
645
- * }
646
- */
647
- (node.parent).value
648
- ) {
649
- checkJsDoc({
650
- isFunctionContext: true,
651
- }, null, node);
652
- }
653
- },
654
-
655
- ClassDeclaration (node) {
656
- if (!hasOption('ClassDeclaration')) {
657
- return;
658
- }
659
-
660
- checkJsDoc({
661
- isFunctionContext: false,
662
- }, null, node);
663
- },
664
-
665
- ClassExpression (node) {
666
- if (!hasOption('ClassExpression')) {
667
- return;
668
- }
669
-
670
- checkJsDoc({
671
- isFunctionContext: false,
672
- }, null, node);
673
- },
674
-
675
- FunctionDeclaration (node) {
676
- if (!hasOption('FunctionDeclaration')) {
677
- return;
678
- }
679
-
680
- checkJsDoc({
681
- isFunctionContext: true,
682
- }, null, node);
683
- },
684
-
685
- FunctionExpression (node) {
686
- if (!hasOption('FunctionExpression')) {
687
- return;
688
- }
689
-
690
- if (
691
- [
692
- 'AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator',
693
- ].includes(node.parent.type) ||
694
- [
695
- 'ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition',
696
- ].includes(node.parent.type) &&
697
- node ===
698
- /**
699
- * @type {import('@typescript-eslint/types').TSESTree.Property|
700
- * import('@typescript-eslint/types').TSESTree.PropertyDefinition
701
- * }
702
- */
703
- (node.parent).value
704
- ) {
705
- checkJsDoc({
706
- isFunctionContext: true,
707
- }, null, node);
708
- }
709
- },
710
-
711
- MethodDefinition (node) {
712
- if (!hasOption('MethodDefinition')) {
713
- return;
714
- }
715
-
716
- checkJsDoc({
717
- isFunctionContext: true,
718
- selector: 'MethodDefinition',
719
- }, null, /** @type {import('eslint').Rule.Node} */ (node.value));
720
- },
721
- };
722
- },
723
- meta: {
724
- docs: {
725
- category: 'Stylistic Issues',
726
- description: 'Require JSDoc comments',
727
- recommended: true,
728
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header',
729
- },
730
-
731
- fixable: 'code',
732
-
733
- messages: {
734
- missingJsDoc: 'Missing JSDoc comment.',
735
- },
736
-
737
- schema: [
738
- OPTIONS_SCHEMA,
739
- ],
740
-
741
- type: 'suggestion',
742
- },
743
- };