eslint-plugin-jsdoc 63.3.3 → 64.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/package.json +23 -48
  2. package/src/index.js +3 -6
  3. package/dist/WarnSettings.cjs +0 -38
  4. package/dist/WarnSettings.cjs.map +0 -1
  5. package/dist/alignTransform.cjs +0 -402
  6. package/dist/alignTransform.cjs.map +0 -1
  7. package/dist/buildForbidRuleDefinition.cjs +0 -101
  8. package/dist/buildForbidRuleDefinition.cjs.map +0 -1
  9. package/dist/buildRejectOrPreferRuleDefinition.cjs +0 -352
  10. package/dist/buildRejectOrPreferRuleDefinition.cjs.map +0 -1
  11. package/dist/cjs/WarnSettings.d.ts +0 -16
  12. package/dist/cjs/alignTransform.d.ts +0 -33
  13. package/dist/cjs/buildForbidRuleDefinition.d.ts +0 -14
  14. package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +0 -8
  15. package/dist/cjs/defaultTagOrder.d.ts +0 -4
  16. package/dist/cjs/exportParser.d.ts +0 -40
  17. package/dist/cjs/getDefaultTagStructureForMode.d.ts +0 -10
  18. package/dist/cjs/getJsdocProcessorPlugin.d.cts +0 -5
  19. package/dist/cjs/getJsdocProcessorPlugin.d.ts +0 -66
  20. package/dist/cjs/index-cjs.d.ts +0 -26
  21. package/dist/cjs/index.cjs.d.cts +0 -2
  22. package/dist/cjs/iterateJsdoc.d.cts +0 -7
  23. package/dist/cjs/iterateJsdoc.d.ts +0 -495
  24. package/dist/cjs/jsdocUtils.d.ts +0 -500
  25. package/dist/cjs/rules/checkAccess.d.ts +0 -2
  26. package/dist/cjs/rules/checkAlignment.d.ts +0 -2
  27. package/dist/cjs/rules/checkExamples.d.ts +0 -3
  28. package/dist/cjs/rules/checkIndentation.d.ts +0 -2
  29. package/dist/cjs/rules/checkLineAlignment.d.ts +0 -9
  30. package/dist/cjs/rules/checkParamNames.d.ts +0 -2
  31. package/dist/cjs/rules/checkPropertyNames.d.ts +0 -2
  32. package/dist/cjs/rules/checkSyntax.d.ts +0 -2
  33. package/dist/cjs/rules/checkTagNames.d.ts +0 -2
  34. package/dist/cjs/rules/checkTemplateNames.d.ts +0 -2
  35. package/dist/cjs/rules/checkTypes.d.ts +0 -7
  36. package/dist/cjs/rules/checkValues.d.ts +0 -2
  37. package/dist/cjs/rules/convertToJsdocComments.d.ts +0 -266
  38. package/dist/cjs/rules/emptyTags.d.ts +0 -2
  39. package/dist/cjs/rules/escapeInlineTags.d.ts +0 -2
  40. package/dist/cjs/rules/implementsOnClasses.d.ts +0 -2
  41. package/dist/cjs/rules/importsAsDependencies.d.ts +0 -2
  42. package/dist/cjs/rules/informativeDocs.d.ts +0 -2
  43. package/dist/cjs/rules/linesBeforeBlock.d.ts +0 -2
  44. package/dist/cjs/rules/matchDescription.d.ts +0 -2
  45. package/dist/cjs/rules/matchName.d.ts +0 -2
  46. package/dist/cjs/rules/multilineBlocks.d.ts +0 -2
  47. package/dist/cjs/rules/noBadBlocks.d.ts +0 -2
  48. package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +0 -2
  49. package/dist/cjs/rules/noBlankBlocks.d.ts +0 -2
  50. package/dist/cjs/rules/noDefaults.d.ts +0 -2
  51. package/dist/cjs/rules/noMissingSyntax.d.ts +0 -9
  52. package/dist/cjs/rules/noMultiAsterisks.d.ts +0 -2
  53. package/dist/cjs/rules/noRestrictedSyntax.d.ts +0 -2
  54. package/dist/cjs/rules/noTypes.d.ts +0 -2
  55. package/dist/cjs/rules/noUndefinedTypes.d.ts +0 -2
  56. package/dist/cjs/rules/normalizeSeeLinks.d.ts +0 -2
  57. package/dist/cjs/rules/preferImportTag.d.ts +0 -2
  58. package/dist/cjs/rules/requireAsteriskPrefix.d.ts +0 -2
  59. package/dist/cjs/rules/requireDescription.d.ts +0 -2
  60. package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +0 -2
  61. package/dist/cjs/rules/requireExample.d.ts +0 -2
  62. package/dist/cjs/rules/requireFileOverview.d.ts +0 -2
  63. package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +0 -2
  64. package/dist/cjs/rules/requireJsdoc.d.ts +0 -24
  65. package/dist/cjs/rules/requireParam.d.ts +0 -3
  66. package/dist/cjs/rules/requireParamDescription.d.ts +0 -2
  67. package/dist/cjs/rules/requireParamName.d.ts +0 -2
  68. package/dist/cjs/rules/requireParamType.d.ts +0 -2
  69. package/dist/cjs/rules/requireProperty.d.ts +0 -2
  70. package/dist/cjs/rules/requirePropertyDescription.d.ts +0 -2
  71. package/dist/cjs/rules/requirePropertyName.d.ts +0 -2
  72. package/dist/cjs/rules/requirePropertyType.d.ts +0 -2
  73. package/dist/cjs/rules/requireRejects.d.ts +0 -2
  74. package/dist/cjs/rules/requireReturns.d.ts +0 -2
  75. package/dist/cjs/rules/requireReturnsCheck.d.ts +0 -2
  76. package/dist/cjs/rules/requireReturnsDescription.d.ts +0 -2
  77. package/dist/cjs/rules/requireReturnsType.d.ts +0 -2
  78. package/dist/cjs/rules/requireTags.d.ts +0 -2
  79. package/dist/cjs/rules/requireTemplate.d.ts +0 -2
  80. package/dist/cjs/rules/requireThrows.d.ts +0 -2
  81. package/dist/cjs/rules/requireYields.d.ts +0 -2
  82. package/dist/cjs/rules/requireYieldsCheck.d.ts +0 -2
  83. package/dist/cjs/rules/sortTags.d.ts +0 -2
  84. package/dist/cjs/rules/tagLines.d.ts +0 -2
  85. package/dist/cjs/rules/textEscaping.d.ts +0 -2
  86. package/dist/cjs/rules/tsMethodSignatureStyle.d.ts +0 -2
  87. package/dist/cjs/rules/tsNoEmptyObjectType.d.ts +0 -2
  88. package/dist/cjs/rules/tsNoUnnecessaryTemplateExpression.d.ts +0 -2
  89. package/dist/cjs/rules/tsPreferFunctionType.d.ts +0 -2
  90. package/dist/cjs/rules/typeFormatting.d.ts +0 -2
  91. package/dist/cjs/rules/validTypes.d.ts +0 -2
  92. package/dist/cjs/tagNames.d.ts +0 -15
  93. package/dist/cjs/utils/hasReturnValue.d.ts +0 -19
  94. package/dist/defaultTagOrder.cjs +0 -46
  95. package/dist/defaultTagOrder.cjs.map +0 -1
  96. package/dist/exportParser.cjs +0 -732
  97. package/dist/exportParser.cjs.map +0 -1
  98. package/dist/generateDocs.cjs +0 -342
  99. package/dist/generateDocs.cjs.map +0 -1
  100. package/dist/generateOptions.cjs +0 -62
  101. package/dist/generateOptions.cjs.map +0 -1
  102. package/dist/generateRule.cjs +0 -248
  103. package/dist/generateRule.cjs.map +0 -1
  104. package/dist/generateRuleTypes.cjs +0 -24
  105. package/dist/generateRuleTypes.cjs.map +0 -1
  106. package/dist/getDefaultTagStructureForMode.cjs +0 -289
  107. package/dist/getDefaultTagStructureForMode.cjs.map +0 -1
  108. package/dist/getJsdocProcessorPlugin.cjs +0 -587
  109. package/dist/getJsdocProcessorPlugin.cjs.map +0 -1
  110. package/dist/getJsdocProcessorPlugin.cts +0 -5
  111. package/dist/index-cjs.cjs +0 -600
  112. package/dist/index-cjs.cjs.map +0 -1
  113. package/dist/index-cjs.d.ts +0 -27
  114. package/dist/index-esm.cjs +0 -162
  115. package/dist/index-esm.cjs.map +0 -1
  116. package/dist/index-esm.d.ts +0 -72
  117. package/dist/index.cjs +0 -748
  118. package/dist/index.cjs.cts +0 -3
  119. package/dist/index.cjs.map +0 -1
  120. package/dist/iterateJsdoc.cjs +0 -2150
  121. package/dist/iterateJsdoc.cjs.map +0 -1
  122. package/dist/iterateJsdoc.cts +0 -7
  123. package/dist/jsdocUtils.cjs +0 -1786
  124. package/dist/jsdocUtils.cjs.map +0 -1
  125. package/dist/rules/checkAccess.cjs +0 -40
  126. package/dist/rules/checkAccess.cjs.map +0 -1
  127. package/dist/rules/checkAlignment.cjs +0 -78
  128. package/dist/rules/checkAlignment.cjs.map +0 -1
  129. package/dist/rules/checkExamples.cjs +0 -521
  130. package/dist/rules/checkExamples.cjs.map +0 -1
  131. package/dist/rules/checkIndentation.cjs +0 -170
  132. package/dist/rules/checkIndentation.cjs.map +0 -1
  133. package/dist/rules/checkLineAlignment.cjs +0 -398
  134. package/dist/rules/checkLineAlignment.cjs.map +0 -1
  135. package/dist/rules/checkParamNames.cjs +0 -407
  136. package/dist/rules/checkParamNames.cjs.map +0 -1
  137. package/dist/rules/checkPropertyNames.cjs +0 -135
  138. package/dist/rules/checkPropertyNames.cjs.map +0 -1
  139. package/dist/rules/checkSyntax.cjs +0 -38
  140. package/dist/rules/checkSyntax.cjs.map +0 -1
  141. package/dist/rules/checkTagNames.cjs +0 -312
  142. package/dist/rules/checkTagNames.cjs.map +0 -1
  143. package/dist/rules/checkTemplateNames.cjs +0 -192
  144. package/dist/rules/checkTemplateNames.cjs.map +0 -1
  145. package/dist/rules/checkTypes.cjs +0 -111
  146. package/dist/rules/checkTypes.cjs.map +0 -1
  147. package/dist/rules/checkValues.cjs +0 -166
  148. package/dist/rules/checkValues.cjs.map +0 -1
  149. package/dist/rules/convertToJsdocComments.cjs +0 -356
  150. package/dist/rules/convertToJsdocComments.cjs.map +0 -1
  151. package/dist/rules/emptyTags.cjs +0 -98
  152. package/dist/rules/emptyTags.cjs.map +0 -1
  153. package/dist/rules/escapeInlineTags.cjs +0 -234
  154. package/dist/rules/escapeInlineTags.cjs.map +0 -1
  155. package/dist/rules/implementsOnClasses.cjs +0 -74
  156. package/dist/rules/implementsOnClasses.cjs.map +0 -1
  157. package/dist/rules/importsAsDependencies.cjs +0 -104
  158. package/dist/rules/importsAsDependencies.cjs.map +0 -1
  159. package/dist/rules/informativeDocs.cjs +0 -187
  160. package/dist/rules/informativeDocs.cjs.map +0 -1
  161. package/dist/rules/linesBeforeBlock.cjs +0 -120
  162. package/dist/rules/linesBeforeBlock.cjs.map +0 -1
  163. package/dist/rules/matchDescription.cjs +0 -356
  164. package/dist/rules/matchDescription.cjs.map +0 -1
  165. package/dist/rules/matchName.cjs +0 -160
  166. package/dist/rules/matchName.cjs.map +0 -1
  167. package/dist/rules/multilineBlocks.cjs +0 -431
  168. package/dist/rules/multilineBlocks.cjs.map +0 -1
  169. package/dist/rules/noBadBlocks.cjs +0 -100
  170. package/dist/rules/noBadBlocks.cjs.map +0 -1
  171. package/dist/rules/noBlankBlockDescriptions.cjs +0 -63
  172. package/dist/rules/noBlankBlockDescriptions.cjs.map +0 -1
  173. package/dist/rules/noBlankBlocks.cjs +0 -54
  174. package/dist/rules/noBlankBlocks.cjs.map +0 -1
  175. package/dist/rules/noDefaults.cjs +0 -102
  176. package/dist/rules/noDefaults.cjs.map +0 -1
  177. package/dist/rules/noMissingSyntax.cjs +0 -196
  178. package/dist/rules/noMissingSyntax.cjs.map +0 -1
  179. package/dist/rules/noMultiAsterisks.cjs +0 -126
  180. package/dist/rules/noMultiAsterisks.cjs.map +0 -1
  181. package/dist/rules/noRestrictedSyntax.cjs +0 -68
  182. package/dist/rules/noRestrictedSyntax.cjs.map +0 -1
  183. package/dist/rules/noTypes.cjs +0 -101
  184. package/dist/rules/noTypes.cjs.map +0 -1
  185. package/dist/rules/noUndefinedTypes.cjs +0 -616
  186. package/dist/rules/noUndefinedTypes.cjs.map +0 -1
  187. package/dist/rules/normalizeSeeLinks.cjs +0 -271
  188. package/dist/rules/normalizeSeeLinks.cjs.map +0 -1
  189. package/dist/rules/preferImportTag.cjs +0 -362
  190. package/dist/rules/preferImportTag.cjs.map +0 -1
  191. package/dist/rules/requireAsteriskPrefix.cjs +0 -190
  192. package/dist/rules/requireAsteriskPrefix.cjs.map +0 -1
  193. package/dist/rules/requireDescription.cjs +0 -164
  194. package/dist/rules/requireDescription.cjs.map +0 -1
  195. package/dist/rules/requireDescriptionCompleteSentence.cjs +0 -321
  196. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +0 -1
  197. package/dist/rules/requireExample.cjs +0 -136
  198. package/dist/rules/requireExample.cjs.map +0 -1
  199. package/dist/rules/requireFileOverview.cjs +0 -194
  200. package/dist/rules/requireFileOverview.cjs.map +0 -1
  201. package/dist/rules/requireHyphenBeforeParamDescription.cjs +0 -166
  202. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +0 -1
  203. package/dist/rules/requireJsdoc.cjs +0 -721
  204. package/dist/rules/requireJsdoc.cjs.map +0 -1
  205. package/dist/rules/requireParam.cjs +0 -772
  206. package/dist/rules/requireParam.cjs.map +0 -1
  207. package/dist/rules/requireParamDescription.cjs +0 -105
  208. package/dist/rules/requireParamDescription.cjs.map +0 -1
  209. package/dist/rules/requireParamName.cjs +0 -68
  210. package/dist/rules/requireParamName.cjs.map +0 -1
  211. package/dist/rules/requireParamType.cjs +0 -104
  212. package/dist/rules/requireParamType.cjs.map +0 -1
  213. package/dist/rules/requireProperty.cjs +0 -63
  214. package/dist/rules/requireProperty.cjs.map +0 -1
  215. package/dist/rules/requirePropertyDescription.cjs +0 -29
  216. package/dist/rules/requirePropertyDescription.cjs.map +0 -1
  217. package/dist/rules/requirePropertyName.cjs +0 -29
  218. package/dist/rules/requirePropertyName.cjs.map +0 -1
  219. package/dist/rules/requirePropertyType.cjs +0 -29
  220. package/dist/rules/requirePropertyType.cjs.map +0 -1
  221. package/dist/rules/requireRejects.cjs +0 -226
  222. package/dist/rules/requireRejects.cjs.map +0 -1
  223. package/dist/rules/requireReturns.cjs +0 -262
  224. package/dist/rules/requireReturns.cjs.map +0 -1
  225. package/dist/rules/requireReturnsCheck.cjs +0 -225
  226. package/dist/rules/requireReturnsCheck.cjs.map +0 -1
  227. package/dist/rules/requireReturnsDescription.cjs +0 -72
  228. package/dist/rules/requireReturnsDescription.cjs.map +0 -1
  229. package/dist/rules/requireReturnsType.cjs +0 -68
  230. package/dist/rules/requireReturnsType.cjs.map +0 -1
  231. package/dist/rules/requireTags.cjs +0 -74
  232. package/dist/rules/requireTags.cjs.map +0 -1
  233. package/dist/rules/requireTemplate.cjs +0 -220
  234. package/dist/rules/requireTemplate.cjs.map +0 -1
  235. package/dist/rules/requireThrows.cjs +0 -118
  236. package/dist/rules/requireThrows.cjs.map +0 -1
  237. package/dist/rules/requireYields.cjs +0 -224
  238. package/dist/rules/requireYields.cjs.map +0 -1
  239. package/dist/rules/requireYieldsCheck.cjs +0 -179
  240. package/dist/rules/requireYieldsCheck.cjs.map +0 -1
  241. package/dist/rules/sortTags.cjs +0 -656
  242. package/dist/rules/sortTags.cjs.map +0 -1
  243. package/dist/rules/tagLines.cjs +0 -374
  244. package/dist/rules/tagLines.cjs.map +0 -1
  245. package/dist/rules/textEscaping.cjs +0 -141
  246. package/dist/rules/textEscaping.cjs.map +0 -1
  247. package/dist/rules/tsMethodSignatureStyle.cjs +0 -240
  248. package/dist/rules/tsMethodSignatureStyle.cjs.map +0 -1
  249. package/dist/rules/tsNoEmptyObjectType.cjs +0 -62
  250. package/dist/rules/tsNoEmptyObjectType.cjs.map +0 -1
  251. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +0 -104
  252. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +0 -1
  253. package/dist/rules/tsPreferFunctionType.cjs +0 -110
  254. package/dist/rules/tsPreferFunctionType.cjs.map +0 -1
  255. package/dist/rules/typeFormatting.cjs +0 -607
  256. package/dist/rules/typeFormatting.cjs.map +0 -1
  257. package/dist/rules/validTypes.cjs +0 -324
  258. package/dist/rules/validTypes.cjs.map +0 -1
  259. package/dist/tagNames.cjs +0 -244
  260. package/dist/tagNames.cjs.map +0 -1
  261. package/dist/to-valid-identifier.cjs +0 -263
  262. package/dist/utils/hasReturnValue.cjs +0 -495
  263. package/dist/utils/hasReturnValue.cjs.map +0 -1
  264. package/rollup.config.js +0 -16
  265. package/src/getJsdocProcessorPlugin.cts +0 -5
  266. package/src/index-cjs.js +0 -760
  267. package/src/index-esm.js +0 -196
  268. package/src/index.cjs.cts +0 -3
  269. package/src/iterateJsdoc.cts +0 -7
@@ -1,721 +0,0 @@
1
- "use strict";
2
-
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 }; }
12
- /**
13
- * @typedef {{
14
- * ancestorsOnly: boolean,
15
- * esm: boolean,
16
- * initModuleExports: boolean,
17
- * initWindow: boolean
18
- * }} RequireJsdocOpts
19
- */
20
-
21
- /**
22
- * @typedef {import('eslint').Rule.Node|
23
- * import('@typescript-eslint/types').TSESTree.Node} ESLintOrTSNode
24
- */
25
-
26
- /** @type {import('json-schema').JSONSchema4} */
27
- const OPTIONS_SCHEMA = {
28
- additionalProperties: false,
29
- description: 'Has the following optional keys.\n',
30
- properties: {
31
- checkAllFunctionExpressions: {
32
- default: false,
33
- description: `Normally, when \`FunctionExpression\` is checked, additional checks are
34
- added to check the parent contexts where reporting is likely to be desired. If you really
35
- want to check *all* function expressions, then set this to \`true\`.`,
36
- type: 'boolean'
37
- },
38
- checkConstructors: {
39
- default: true,
40
- description: `A value indicating whether \`constructor\`s should be checked. Defaults to
41
- \`true\`. When \`true\`, \`exemptEmptyConstructors\` may still avoid reporting when
42
- no parameters or return values are found.`,
43
- type: 'boolean'
44
- },
45
- checkGetters: {
46
- anyOf: [{
47
- type: 'boolean'
48
- }, {
49
- enum: ['no-setter'],
50
- type: 'string'
51
- }],
52
- default: true,
53
- description: `A value indicating whether getters should be checked. Besides setting as a
54
- boolean, this option can be set to the string \`"no-setter"\` to indicate that
55
- getters should be checked but only when there is no setter. This may be useful
56
- if one only wishes documentation on one of the two accessors. Defaults to
57
- \`false\`.`
58
- },
59
- checkSetters: {
60
- anyOf: [{
61
- type: 'boolean'
62
- }, {
63
- enum: ['no-getter'],
64
- type: 'string'
65
- }],
66
- default: true,
67
- description: `A value indicating whether setters should be checked. Besides setting as a
68
- boolean, this option can be set to the string \`"no-getter"\` to indicate that
69
- setters should be checked but only when there is no getter. This may be useful
70
- if one only wishes documentation on one of the two accessors. Defaults to
71
- \`false\`.`
72
- },
73
- contexts: {
74
- description: `Set this to an array of strings or objects representing the additional AST
75
- contexts where you wish the rule to be applied (e.g., \`Property\` for
76
- properties). If specified as an object, it should have a \`context\` property
77
- and can have an \`inlineCommentBlock\` property which, if set to \`true\`, will
78
- add an inline \`/** */\` instead of the regular, multi-line, indented jsdoc
79
- block which will otherwise be added. Defaults to an empty array. Contexts
80
- may also have their own \`minLineCount\` property which is an integer
81
- indicating a minimum number of lines expected for a node in order
82
- for it to require documentation.
83
-
84
- Note that you may need to disable \`require\` items (e.g., \`MethodDefinition\`)
85
- if you are specifying a more precise form in \`contexts\` (e.g., \`MethodDefinition:not([accessibility="private"] > FunctionExpression\`).
86
-
87
- See the ["AST and Selectors"](../advanced.md#ast-and-selectors)
88
- section of our Advanced docs for more on the expected format.`,
89
- items: {
90
- anyOf: [{
91
- type: 'string'
92
- }, {
93
- additionalProperties: false,
94
- properties: {
95
- context: {
96
- type: 'string'
97
- },
98
- inlineCommentBlock: {
99
- type: 'boolean'
100
- },
101
- minLineCount: {
102
- type: 'integer'
103
- }
104
- },
105
- type: 'object'
106
- }]
107
- },
108
- type: 'array'
109
- },
110
- enableFixer: {
111
- default: true,
112
- description: `A boolean on whether to enable the fixer (which adds an empty JSDoc block).
113
- Defaults to \`true\`.`,
114
- type: 'boolean'
115
- },
116
- exemptEmptyConstructors: {
117
- default: false,
118
- description: `When \`true\`, the rule will not report missing JSDoc blocks above constructors
119
- with no parameters or return values (this is enabled by default as the class
120
- name or description should be seen as sufficient to convey intent).
121
-
122
- Defaults to \`true\`.`,
123
- type: 'boolean'
124
- },
125
- exemptEmptyFunctions: {
126
- default: false,
127
- description: `When \`true\`, the rule will not report missing JSDoc blocks above
128
- functions/methods with no parameters or return values (intended where
129
- function/method names are sufficient for themselves as documentation).
130
-
131
- Defaults to \`false\`.`,
132
- type: 'boolean'
133
- },
134
- exemptOverloadedImplementations: {
135
- default: false,
136
- description: `If set to \`true\` will avoid checking an overloaded function's implementation.
137
-
138
- Defaults to \`false\`.`,
139
- type: 'boolean'
140
- },
141
- fixerMessage: {
142
- default: '',
143
- description: `An optional message to add to the inserted JSDoc block. Defaults to the
144
- empty string.`,
145
- type: 'string'
146
- },
147
- minLineCount: {
148
- description: `An integer to indicate a minimum number of lines expected for a node in order
149
- for it to require documentation. Defaults to \`undefined\`. This option will
150
- apply to any context; see \`contexts\` for line counts specific to a context.`,
151
- type: 'integer'
152
- },
153
- publicOnly: {
154
- description: `This option will insist that missing JSDoc blocks are only reported for
155
- function bodies / class declarations that are exported from the module.
156
- May be a boolean or object. If set to \`true\`, the defaults below will be
157
- used. If unset, JSDoc block reporting will not be limited to exports.
158
-
159
- This object supports the following optional boolean keys (\`false\` unless
160
- otherwise noted):
161
-
162
- - \`ancestorsOnly\` - Optimization to only check node ancestors to check if node is exported
163
- - \`esm\` - ESM exports are checked for JSDoc comments (Defaults to \`true\`)
164
- - \`cjs\` - CommonJS exports are checked for JSDoc comments (Defaults to \`true\`)
165
- - \`window\` - Window global exports are checked for JSDoc comments`,
166
- oneOf: [{
167
- default: false,
168
- type: 'boolean'
169
- }, {
170
- additionalProperties: false,
171
- default: {},
172
- properties: {
173
- ancestorsOnly: {
174
- type: 'boolean'
175
- },
176
- cjs: {
177
- type: 'boolean'
178
- },
179
- esm: {
180
- type: 'boolean'
181
- },
182
- window: {
183
- type: 'boolean'
184
- }
185
- },
186
- type: 'object'
187
- }]
188
- },
189
- require: {
190
- additionalProperties: false,
191
- default: {},
192
- description: `An object with the following optional boolean keys which all default to
193
- \`false\` except for \`FunctionDeclaration\` which defaults to \`true\`.`,
194
- properties: {
195
- ArrowFunctionExpression: {
196
- default: false,
197
- description: 'Whether to check arrow functions like `() => {}`',
198
- type: 'boolean'
199
- },
200
- ClassDeclaration: {
201
- default: false,
202
- description: 'Whether to check declarations like `class A {}`',
203
- type: 'boolean'
204
- },
205
- ClassExpression: {
206
- default: false,
207
- description: 'Whether to check class expressions like `const myClass = class {}`',
208
- type: 'boolean'
209
- },
210
- FunctionDeclaration: {
211
- default: true,
212
- description: 'Whether to check function declarations like `function a {}`',
213
- type: 'boolean'
214
- },
215
- FunctionExpression: {
216
- default: false,
217
- description: 'Whether to check function expressions like `const a = function {}`',
218
- type: 'boolean'
219
- },
220
- MethodDefinition: {
221
- default: false,
222
- description: 'Whether to check method definitions like `class A { someMethodDefinition () {} }`',
223
- type: 'boolean'
224
- }
225
- },
226
- type: 'object'
227
- },
228
- skipInterveningOverloadedDeclarations: {
229
- default: true,
230
- description: `If \`true\`, will skip above uncommented overloaded functions to check
231
- for a comment block (e.g., at the top of a set of overloaded functions).
232
-
233
- If \`false\`, will force each overloaded function to be checked for a
234
- comment block.
235
-
236
- Defaults to \`true\`.`,
237
- type: 'boolean'
238
- }
239
- },
240
- type: 'object'
241
- };
242
-
243
- /**
244
- * @param {string} interfaceName
245
- * @param {string} methodName
246
- * @param {import("eslint").Scope.Scope | null} scope
247
- * @returns {import('@typescript-eslint/types').TSESTree.TSMethodSignature|null}
248
- */
249
- const getMethodOnInterface = (interfaceName, methodName, scope) => {
250
- let scp = scope;
251
- while (scp) {
252
- for (const {
253
- identifiers,
254
- name
255
- } of scp.variables) {
256
- if (interfaceName !== name) {
257
- continue;
258
- }
259
- for (const identifier of identifiers) {
260
- const interfaceDeclaration = /** @type {import('@typescript-eslint/types').TSESTree.Identifier & {parent: import('@typescript-eslint/types').TSESTree.TSInterfaceDeclaration}} */identifier.parent;
261
- /* c8 ignore next 3 -- TS */
262
- if (interfaceDeclaration.type !== 'TSInterfaceDeclaration') {
263
- continue;
264
- }
265
- for (const bodyItem of interfaceDeclaration.body.body) {
266
- const methodSig = /** @type {import('@typescript-eslint/types').TSESTree.TSMethodSignature} */
267
- bodyItem;
268
- if (methodName === /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */methodSig.key.name) {
269
- return methodSig;
270
- }
271
- }
272
- }
273
- }
274
- scp = scp.upper;
275
- }
276
- return null;
277
- };
278
-
279
- /**
280
- * @param {import('eslint').Rule.Node} node
281
- * @param {import('eslint').SourceCode} sourceCode
282
- * @param {import('eslint').Rule.RuleContext} context
283
- * @param {import('../iterateJsdoc.js').Settings} settings
284
- */
285
- const isExemptedImplementer = (node, sourceCode, context, settings) => {
286
- 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) {
287
- const implments = /** @type {import('@typescript-eslint/types').TSESTree.TSClassImplements[]} */
288
- node.parent.parent.parent.implements;
289
- const {
290
- name: methodName
291
- } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
292
- node.parent.key;
293
- for (const impl of implments) {
294
- const {
295
- name: interfaceName
296
- } = /** @type {import('@typescript-eslint/types').TSESTree.Identifier} */
297
- impl.expression;
298
- const interfaceMethodNode = getMethodOnInterface(interfaceName, methodName, node && (sourceCode.getScope && /* c8 ignore next 3 */
299
- sourceCode.getScope(node) ||
300
- // @ts-expect-error ESLint 8
301
- context.getScope()));
302
- if (interfaceMethodNode) {
303
- const comment = (0, _jsdoccomment.getJSDocComment)(sourceCode, interfaceMethodNode, settings);
304
- if (comment) {
305
- return true;
306
- }
307
- }
308
- }
309
- }
310
- return false;
311
- };
312
-
313
- /**
314
- * @param {import('eslint').Rule.RuleContext} context
315
- * @param {import('json-schema').JSONSchema4Object} baseObject
316
- * @param {string} option
317
- * @param {string} key
318
- * @returns {boolean|undefined}
319
- */
320
- const getOption = (context, baseObject, option, key) => {
321
- if (context.options[0] && option in context.options[0] && (
322
- // Todo: boolean shouldn't be returning property, but
323
- // tests currently require
324
- typeof context.options[0][option] === 'boolean' || key in context.options[0][option])) {
325
- return context.options[0][option][key];
326
- }
327
- return /** @type {{[key: string]: {default?: boolean|undefined}}} */baseObject.properties[key].default;
328
- };
329
-
330
- /**
331
- * @param {import('eslint').Rule.RuleContext} context
332
- * @param {import('../iterateJsdoc.js').Settings} settings
333
- * @returns {{
334
- * checkAllFunctionExpressions: boolean,
335
- * contexts: (string|{
336
- * context: string,
337
- * inlineCommentBlock: boolean,
338
- * minLineCount: import('../iterateJsdoc.js').Integer
339
- * })[],
340
- * enableFixer: boolean,
341
- * exemptEmptyConstructors: boolean,
342
- * exemptEmptyFunctions: boolean,
343
- * skipInterveningOverloadedDeclarations: boolean,
344
- * exemptOverloadedImplementations: boolean,
345
- * fixerMessage: string,
346
- * minLineCount: undefined|import('../iterateJsdoc.js').Integer,
347
- * publicOnly: boolean|{[key: string]: boolean|undefined}
348
- * require: {[key: string]: boolean|undefined}
349
- * }}
350
- */
351
- const getOptions = (context, settings) => {
352
- const {
353
- checkAllFunctionExpressions = false,
354
- contexts = settings.contexts || [],
355
- enableFixer = true,
356
- exemptEmptyConstructors = true,
357
- exemptEmptyFunctions = false,
358
- exemptOverloadedImplementations = false,
359
- fixerMessage = '',
360
- minLineCount = undefined,
361
- publicOnly,
362
- skipInterveningOverloadedDeclarations = true
363
- } = context.options[0] || {};
364
- return {
365
- checkAllFunctionExpressions,
366
- contexts,
367
- enableFixer,
368
- exemptEmptyConstructors,
369
- exemptEmptyFunctions,
370
- exemptOverloadedImplementations,
371
- fixerMessage,
372
- minLineCount,
373
- publicOnly: (baseObj => {
374
- if (!publicOnly) {
375
- return false;
376
- }
377
-
378
- /** @type {{[key: string]: boolean|undefined}} */
379
- const properties = {};
380
- for (const prop of Object.keys(/** @type {import('json-schema').JSONSchema4Object} */
381
- /** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) {
382
- const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */baseObj, 'publicOnly', prop);
383
- properties[prop] = opt;
384
- }
385
- return properties;
386
- })(/** @type {import('json-schema').JSONSchema4Object} */
387
- (/** @type {import('json-schema').JSONSchema4Object} */
388
- (/** @type {import('json-schema').JSONSchema4Object} */
389
- OPTIONS_SCHEMA.properties.publicOnly).oneOf)[1]),
390
- require: (baseObj => {
391
- /** @type {{[key: string]: boolean|undefined}} */
392
- const properties = {};
393
- for (const prop of Object.keys(/** @type {import('json-schema').JSONSchema4Object} */
394
- /** @type {import('json-schema').JSONSchema4Object} */baseObj.properties)) {
395
- const opt = getOption(context, /** @type {import('json-schema').JSONSchema4Object} */
396
- baseObj, 'require', prop);
397
- properties[prop] = opt;
398
- }
399
- return properties;
400
- })(/** @type {import('json-schema').JSONSchema4Object} */
401
- OPTIONS_SCHEMA.properties.require),
402
- skipInterveningOverloadedDeclarations
403
- };
404
- };
405
-
406
- /**
407
- * @param {ESLintOrTSNode} node
408
- */
409
- const isFunctionWithOverload = node => {
410
- if (node.type !== 'FunctionDeclaration') {
411
- return false;
412
- }
413
- let parent;
414
- let child;
415
- if (node.parent?.type === 'Program') {
416
- parent = node.parent;
417
- child = node;
418
- } else if (node.parent?.type === 'ExportNamedDeclaration' && node.parent?.parent.type === 'Program') {
419
- parent = node.parent?.parent;
420
- child = node.parent;
421
- }
422
- if (!child || !parent) {
423
- return false;
424
- }
425
- const functionName = node.id?.name;
426
- const idx = parent.body.indexOf(child);
427
- const prevSibling = parent.body[idx - 1];
428
- return (
429
- // @ts-expect-error Should be ok
430
- prevSibling?.type === 'TSDeclareFunction' &&
431
- // @ts-expect-error Should be ok
432
- functionName === prevSibling.id.name || prevSibling?.type === 'ExportNamedDeclaration' &&
433
- // @ts-expect-error Should be ok
434
- prevSibling.declaration?.type === 'TSDeclareFunction' &&
435
- // @ts-expect-error Should be ok
436
- prevSibling.declaration?.id?.name === functionName
437
- );
438
- };
439
-
440
- /** @type {import('eslint').Rule.RuleModule} */
441
- var _default = exports.default = {
442
- create(context) {
443
- /* c8 ignore next -- Fallback to deprecated method */
444
- const {
445
- // @ts-expect-error ESLint < 10
446
- sourceCode = context.getSourceCode()
447
- } = context;
448
- const settings = (0, _iterateJsdoc.getSettings)(context);
449
- if (!settings) {
450
- return {};
451
- }
452
- const opts = getOptions(context, settings);
453
- const {
454
- checkAllFunctionExpressions,
455
- contexts,
456
- enableFixer,
457
- exemptEmptyConstructors,
458
- exemptEmptyFunctions,
459
- exemptOverloadedImplementations,
460
- fixerMessage,
461
- minLineCount,
462
- require: requireOption,
463
- skipInterveningOverloadedDeclarations
464
- } = opts;
465
- const publicOnly =
466
- /**
467
- * @type {{
468
- * [key: string]: boolean | undefined;
469
- * }}
470
- */
471
- opts.publicOnly;
472
-
473
- /**
474
- * @type {import('../iterateJsdoc.js').CheckJsdoc}
475
- */
476
- const checkJsDoc = (info, _handler, node) => {
477
- if (
478
- // Optimize
479
- minLineCount !== undefined || contexts.some(ctxt => {
480
- if (typeof ctxt === 'string') {
481
- return false;
482
- }
483
- const {
484
- minLineCount: count
485
- } = ctxt;
486
- return count !== undefined;
487
- })) {
488
- /**
489
- * @param {undefined|import('../iterateJsdoc.js').Integer} count
490
- */
491
- const underMinLine = count => {
492
- return count !== undefined && count > (sourceCode.getText(node).match(/\n/gv)?.length ?? 0) + 1;
493
- };
494
- if (underMinLine(minLineCount)) {
495
- return;
496
- }
497
- const {
498
- minLineCount: contextMinLineCount
499
- } =
500
- /**
501
- * @type {{
502
- * context: string;
503
- * inlineCommentBlock: boolean;
504
- * minLineCount: number;
505
- * }}
506
- */
507
- contexts.find(ctxt => {
508
- if (typeof ctxt === 'string') {
509
- return false;
510
- }
511
- const {
512
- context: ctx
513
- } = ctxt;
514
- return ctx === (info.selector || node.type);
515
- }) || {};
516
- if (underMinLine(contextMinLineCount)) {
517
- return;
518
- }
519
- }
520
- if (exemptOverloadedImplementations && isFunctionWithOverload(node)) {
521
- return;
522
- }
523
- const jsDocNode = (0, _jsdoccomment.getJSDocComment)(sourceCode, node, settings, {
524
- checkOverloads: skipInterveningOverloadedDeclarations
525
- });
526
- if (jsDocNode) {
527
- return;
528
- }
529
-
530
- // For those who have options configured against ANY constructors (or
531
- // setters or getters) being reported
532
- if ((0, _jsdocUtils.exemptSpeciaMethods)({
533
- description: '',
534
- inlineTags: [],
535
- problems: [],
536
- source: [],
537
- tags: []
538
- }, node, context, [OPTIONS_SCHEMA])) {
539
- return;
540
- }
541
- if (
542
- // Avoid reporting param-less, return-less functions (when
543
- // `exemptEmptyFunctions` option is set)
544
- exemptEmptyFunctions && info.isFunctionContext ||
545
- // Avoid reporting param-less, return-less constructor methods (when
546
- // `exemptEmptyConstructors` option is set)
547
- exemptEmptyConstructors && (0, _jsdocUtils.isConstructor)(node)) {
548
- const functionParameterNames = (0, _jsdocUtils.getFunctionParameterNames)(node);
549
- if (!functionParameterNames.length && !(0, _jsdocUtils.hasReturnValue)(node)) {
550
- return;
551
- }
552
- }
553
- if (isExemptedImplementer(node, sourceCode, context, settings)) {
554
- return;
555
- }
556
- const fix = /** @type {import('eslint').Rule.ReportFixer} */fixer => {
557
- // Default to one line break if the `minLines`/`maxLines` settings allow
558
- const lines = settings.minLines === 0 && settings.maxLines >= 1 ? 1 : settings.minLines;
559
- /** @type {ESLintOrTSNode|import('@typescript-eslint/types').TSESTree.Decorator} */
560
- let baseNode = (0, _jsdoccomment.getReducedASTNode)(node, sourceCode);
561
- const decorator = (0, _jsdoccomment.getDecorator)(/** @type {import('eslint').Rule.Node} */
562
- baseNode);
563
- if (decorator) {
564
- baseNode = decorator;
565
- }
566
- const indent = (0, _jsdocUtils.getIndent)({
567
- text: sourceCode.getText(/** @type {import('eslint').Rule.Node} */baseNode, /** @type {import('eslint').AST.SourceLocation} */
568
- (/** @type {import('eslint').Rule.Node} */baseNode.loc).start.column)
569
- });
570
- const {
571
- inlineCommentBlock
572
- } =
573
- /**
574
- * @type {{
575
- * context: string,
576
- * inlineCommentBlock: boolean,
577
- * minLineCount: import('../iterateJsdoc.js').Integer
578
- * }}
579
- */
580
- contexts.find(contxt => {
581
- if (typeof contxt === 'string') {
582
- return false;
583
- }
584
- const {
585
- context: ctxt
586
- } = contxt;
587
- return ctxt === node.type;
588
- }) || {};
589
- const insertion = (inlineCommentBlock ? `/** ${fixerMessage}` : `/**\n${indent}*${fixerMessage}\n${indent}`) + `*/${'\n'.repeat(lines)}${indent.slice(0, -1)}`;
590
- return fixer.insertTextBefore(/** @type {import('eslint').Rule.Node} */
591
- baseNode, insertion);
592
- };
593
- const report = () => {
594
- const {
595
- start
596
- } = /** @type {import('eslint').AST.SourceLocation} */node.loc;
597
- const loc = {
598
- end: {
599
- column: 0,
600
- line: start.line + 1
601
- },
602
- start
603
- };
604
- context.report({
605
- fix: enableFixer ? fix : null,
606
- loc,
607
- messageId: 'missingJsDoc',
608
- node
609
- });
610
- };
611
- if (publicOnly) {
612
- /** @type {RequireJsdocOpts} */
613
- const opt = {
614
- ancestorsOnly: Boolean(publicOnly?.ancestorsOnly ?? false),
615
- esm: Boolean(publicOnly?.esm ?? true),
616
- initModuleExports: Boolean(publicOnly?.cjs ?? true),
617
- initWindow: Boolean(publicOnly?.window ?? false)
618
- };
619
- const exported = _exportParser.default.isUncommentedExport(node, sourceCode, opt, settings);
620
- if (exported) {
621
- report();
622
- }
623
- } else {
624
- report();
625
- }
626
- };
627
-
628
- /**
629
- * @param {string} prop
630
- * @returns {boolean}
631
- */
632
- const hasOption = prop => {
633
- return requireOption[prop] || contexts.some(ctxt => {
634
- return typeof ctxt === 'object' ? ctxt.context === prop : ctxt === prop;
635
- });
636
- };
637
- return {
638
- ...(0, _jsdocUtils.getContextObject)((0, _jsdocUtils.enforcedContexts)(context, [], settings), checkJsDoc),
639
- ArrowFunctionExpression(node) {
640
- if (!hasOption('ArrowFunctionExpression')) {
641
- return;
642
- }
643
- if (['AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator'].includes(node.parent.type) || ['ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition'].includes(node.parent.type) && node ===
644
- /**
645
- * @type {import('@typescript-eslint/types').TSESTree.Property|
646
- * import('@typescript-eslint/types').TSESTree.PropertyDefinition
647
- * }
648
- */
649
- node.parent.value) {
650
- checkJsDoc({
651
- isFunctionContext: true
652
- }, null, node);
653
- }
654
- },
655
- ClassDeclaration(node) {
656
- if (!hasOption('ClassDeclaration')) {
657
- return;
658
- }
659
- checkJsDoc({
660
- isFunctionContext: false
661
- }, null, node);
662
- },
663
- ClassExpression(node) {
664
- if (!hasOption('ClassExpression')) {
665
- return;
666
- }
667
- checkJsDoc({
668
- isFunctionContext: false
669
- }, null, node);
670
- },
671
- FunctionDeclaration(node) {
672
- if (!hasOption('FunctionDeclaration')) {
673
- return;
674
- }
675
- checkJsDoc({
676
- isFunctionContext: true
677
- }, null, node);
678
- },
679
- FunctionExpression(node) {
680
- if (!hasOption('FunctionExpression')) {
681
- return;
682
- }
683
- if (checkAllFunctionExpressions || ['AssignmentExpression', 'ExportDefaultDeclaration', 'VariableDeclarator'].includes(node.parent.type) || ['ClassProperty', 'ObjectProperty', 'Property', 'PropertyDefinition'].includes(node.parent.type) && node ===
684
- /**
685
- * @type {import('@typescript-eslint/types').TSESTree.Property|
686
- * import('@typescript-eslint/types').TSESTree.PropertyDefinition
687
- * }
688
- */
689
- node.parent.value) {
690
- checkJsDoc({
691
- isFunctionContext: true
692
- }, null, node);
693
- }
694
- },
695
- MethodDefinition(node) {
696
- if (!hasOption('MethodDefinition')) {
697
- return;
698
- }
699
- checkJsDoc({
700
- isFunctionContext: true,
701
- selector: 'MethodDefinition'
702
- }, null, /** @type {import('eslint').Rule.Node} */node.value);
703
- }
704
- };
705
- },
706
- meta: {
707
- docs: {
708
- description: 'Checks for presence of JSDoc comments, on functions and potentially other contexts (optionally limited to exports).',
709
- recommended: true,
710
- url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-jsdoc.md#repos-sticky-header'
711
- },
712
- fixable: 'code',
713
- messages: {
714
- missingJsDoc: 'Missing JSDoc comment.'
715
- },
716
- schema: [OPTIONS_SCHEMA],
717
- type: 'suggestion'
718
- }
719
- };
720
- module.exports = exports.default;
721
- //# sourceMappingURL=requireJsdoc.cjs.map