eslint-plugin-jsdoc 63.3.2 → 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 (270) hide show
  1. package/dist/index.d.ts +7 -4
  2. package/package.json +27 -52
  3. package/src/index.js +7 -8
  4. package/dist/WarnSettings.cjs +0 -38
  5. package/dist/WarnSettings.cjs.map +0 -1
  6. package/dist/alignTransform.cjs +0 -402
  7. package/dist/alignTransform.cjs.map +0 -1
  8. package/dist/buildForbidRuleDefinition.cjs +0 -101
  9. package/dist/buildForbidRuleDefinition.cjs.map +0 -1
  10. package/dist/buildRejectOrPreferRuleDefinition.cjs +0 -352
  11. package/dist/buildRejectOrPreferRuleDefinition.cjs.map +0 -1
  12. package/dist/cjs/WarnSettings.d.ts +0 -16
  13. package/dist/cjs/alignTransform.d.ts +0 -33
  14. package/dist/cjs/buildForbidRuleDefinition.d.ts +0 -14
  15. package/dist/cjs/buildRejectOrPreferRuleDefinition.d.ts +0 -8
  16. package/dist/cjs/defaultTagOrder.d.ts +0 -4
  17. package/dist/cjs/exportParser.d.ts +0 -40
  18. package/dist/cjs/getDefaultTagStructureForMode.d.ts +0 -10
  19. package/dist/cjs/getJsdocProcessorPlugin.d.cts +0 -5
  20. package/dist/cjs/getJsdocProcessorPlugin.d.ts +0 -66
  21. package/dist/cjs/index-cjs.d.ts +0 -23
  22. package/dist/cjs/index.cjs.d.cts +0 -2
  23. package/dist/cjs/iterateJsdoc.d.cts +0 -7
  24. package/dist/cjs/iterateJsdoc.d.ts +0 -495
  25. package/dist/cjs/jsdocUtils.d.ts +0 -500
  26. package/dist/cjs/rules/checkAccess.d.ts +0 -2
  27. package/dist/cjs/rules/checkAlignment.d.ts +0 -2
  28. package/dist/cjs/rules/checkExamples.d.ts +0 -3
  29. package/dist/cjs/rules/checkIndentation.d.ts +0 -2
  30. package/dist/cjs/rules/checkLineAlignment.d.ts +0 -9
  31. package/dist/cjs/rules/checkParamNames.d.ts +0 -2
  32. package/dist/cjs/rules/checkPropertyNames.d.ts +0 -2
  33. package/dist/cjs/rules/checkSyntax.d.ts +0 -2
  34. package/dist/cjs/rules/checkTagNames.d.ts +0 -2
  35. package/dist/cjs/rules/checkTemplateNames.d.ts +0 -2
  36. package/dist/cjs/rules/checkTypes.d.ts +0 -7
  37. package/dist/cjs/rules/checkValues.d.ts +0 -2
  38. package/dist/cjs/rules/convertToJsdocComments.d.ts +0 -266
  39. package/dist/cjs/rules/emptyTags.d.ts +0 -2
  40. package/dist/cjs/rules/escapeInlineTags.d.ts +0 -2
  41. package/dist/cjs/rules/implementsOnClasses.d.ts +0 -2
  42. package/dist/cjs/rules/importsAsDependencies.d.ts +0 -2
  43. package/dist/cjs/rules/informativeDocs.d.ts +0 -2
  44. package/dist/cjs/rules/linesBeforeBlock.d.ts +0 -2
  45. package/dist/cjs/rules/matchDescription.d.ts +0 -2
  46. package/dist/cjs/rules/matchName.d.ts +0 -2
  47. package/dist/cjs/rules/multilineBlocks.d.ts +0 -2
  48. package/dist/cjs/rules/noBadBlocks.d.ts +0 -2
  49. package/dist/cjs/rules/noBlankBlockDescriptions.d.ts +0 -2
  50. package/dist/cjs/rules/noBlankBlocks.d.ts +0 -2
  51. package/dist/cjs/rules/noDefaults.d.ts +0 -2
  52. package/dist/cjs/rules/noMissingSyntax.d.ts +0 -9
  53. package/dist/cjs/rules/noMultiAsterisks.d.ts +0 -2
  54. package/dist/cjs/rules/noRestrictedSyntax.d.ts +0 -2
  55. package/dist/cjs/rules/noTypes.d.ts +0 -2
  56. package/dist/cjs/rules/noUndefinedTypes.d.ts +0 -2
  57. package/dist/cjs/rules/normalizeSeeLinks.d.ts +0 -2
  58. package/dist/cjs/rules/preferImportTag.d.ts +0 -2
  59. package/dist/cjs/rules/requireAsteriskPrefix.d.ts +0 -2
  60. package/dist/cjs/rules/requireDescription.d.ts +0 -2
  61. package/dist/cjs/rules/requireDescriptionCompleteSentence.d.ts +0 -2
  62. package/dist/cjs/rules/requireExample.d.ts +0 -2
  63. package/dist/cjs/rules/requireFileOverview.d.ts +0 -2
  64. package/dist/cjs/rules/requireHyphenBeforeParamDescription.d.ts +0 -2
  65. package/dist/cjs/rules/requireJsdoc.d.ts +0 -24
  66. package/dist/cjs/rules/requireParam.d.ts +0 -3
  67. package/dist/cjs/rules/requireParamDescription.d.ts +0 -2
  68. package/dist/cjs/rules/requireParamName.d.ts +0 -2
  69. package/dist/cjs/rules/requireParamType.d.ts +0 -2
  70. package/dist/cjs/rules/requireProperty.d.ts +0 -2
  71. package/dist/cjs/rules/requirePropertyDescription.d.ts +0 -2
  72. package/dist/cjs/rules/requirePropertyName.d.ts +0 -2
  73. package/dist/cjs/rules/requirePropertyType.d.ts +0 -2
  74. package/dist/cjs/rules/requireRejects.d.ts +0 -2
  75. package/dist/cjs/rules/requireReturns.d.ts +0 -2
  76. package/dist/cjs/rules/requireReturnsCheck.d.ts +0 -2
  77. package/dist/cjs/rules/requireReturnsDescription.d.ts +0 -2
  78. package/dist/cjs/rules/requireReturnsType.d.ts +0 -2
  79. package/dist/cjs/rules/requireTags.d.ts +0 -2
  80. package/dist/cjs/rules/requireTemplate.d.ts +0 -2
  81. package/dist/cjs/rules/requireThrows.d.ts +0 -2
  82. package/dist/cjs/rules/requireYields.d.ts +0 -2
  83. package/dist/cjs/rules/requireYieldsCheck.d.ts +0 -2
  84. package/dist/cjs/rules/sortTags.d.ts +0 -2
  85. package/dist/cjs/rules/tagLines.d.ts +0 -2
  86. package/dist/cjs/rules/textEscaping.d.ts +0 -2
  87. package/dist/cjs/rules/tsMethodSignatureStyle.d.ts +0 -2
  88. package/dist/cjs/rules/tsNoEmptyObjectType.d.ts +0 -2
  89. package/dist/cjs/rules/tsNoUnnecessaryTemplateExpression.d.ts +0 -2
  90. package/dist/cjs/rules/tsPreferFunctionType.d.ts +0 -2
  91. package/dist/cjs/rules/typeFormatting.d.ts +0 -2
  92. package/dist/cjs/rules/validTypes.d.ts +0 -2
  93. package/dist/cjs/tagNames.d.ts +0 -15
  94. package/dist/cjs/utils/hasReturnValue.d.ts +0 -19
  95. package/dist/defaultTagOrder.cjs +0 -46
  96. package/dist/defaultTagOrder.cjs.map +0 -1
  97. package/dist/exportParser.cjs +0 -732
  98. package/dist/exportParser.cjs.map +0 -1
  99. package/dist/generateDocs.cjs +0 -342
  100. package/dist/generateDocs.cjs.map +0 -1
  101. package/dist/generateOptions.cjs +0 -62
  102. package/dist/generateOptions.cjs.map +0 -1
  103. package/dist/generateRule.cjs +0 -248
  104. package/dist/generateRule.cjs.map +0 -1
  105. package/dist/generateRuleTypes.cjs +0 -24
  106. package/dist/generateRuleTypes.cjs.map +0 -1
  107. package/dist/getDefaultTagStructureForMode.cjs +0 -289
  108. package/dist/getDefaultTagStructureForMode.cjs.map +0 -1
  109. package/dist/getJsdocProcessorPlugin.cjs +0 -587
  110. package/dist/getJsdocProcessorPlugin.cjs.map +0 -1
  111. package/dist/getJsdocProcessorPlugin.cts +0 -5
  112. package/dist/index-cjs.cjs +0 -598
  113. package/dist/index-cjs.cjs.map +0 -1
  114. package/dist/index-cjs.d.ts +0 -24
  115. package/dist/index-esm.cjs +0 -162
  116. package/dist/index-esm.cjs.map +0 -1
  117. package/dist/index-esm.d.ts +0 -72
  118. package/dist/index.cjs +0 -746
  119. package/dist/index.cjs.cts +0 -3
  120. package/dist/index.cjs.map +0 -1
  121. package/dist/iterateJsdoc.cjs +0 -2150
  122. package/dist/iterateJsdoc.cjs.map +0 -1
  123. package/dist/iterateJsdoc.cts +0 -7
  124. package/dist/jsdocUtils.cjs +0 -1786
  125. package/dist/jsdocUtils.cjs.map +0 -1
  126. package/dist/rules/checkAccess.cjs +0 -40
  127. package/dist/rules/checkAccess.cjs.map +0 -1
  128. package/dist/rules/checkAlignment.cjs +0 -78
  129. package/dist/rules/checkAlignment.cjs.map +0 -1
  130. package/dist/rules/checkExamples.cjs +0 -521
  131. package/dist/rules/checkExamples.cjs.map +0 -1
  132. package/dist/rules/checkIndentation.cjs +0 -170
  133. package/dist/rules/checkIndentation.cjs.map +0 -1
  134. package/dist/rules/checkLineAlignment.cjs +0 -398
  135. package/dist/rules/checkLineAlignment.cjs.map +0 -1
  136. package/dist/rules/checkParamNames.cjs +0 -407
  137. package/dist/rules/checkParamNames.cjs.map +0 -1
  138. package/dist/rules/checkPropertyNames.cjs +0 -135
  139. package/dist/rules/checkPropertyNames.cjs.map +0 -1
  140. package/dist/rules/checkSyntax.cjs +0 -38
  141. package/dist/rules/checkSyntax.cjs.map +0 -1
  142. package/dist/rules/checkTagNames.cjs +0 -312
  143. package/dist/rules/checkTagNames.cjs.map +0 -1
  144. package/dist/rules/checkTemplateNames.cjs +0 -192
  145. package/dist/rules/checkTemplateNames.cjs.map +0 -1
  146. package/dist/rules/checkTypes.cjs +0 -111
  147. package/dist/rules/checkTypes.cjs.map +0 -1
  148. package/dist/rules/checkValues.cjs +0 -166
  149. package/dist/rules/checkValues.cjs.map +0 -1
  150. package/dist/rules/convertToJsdocComments.cjs +0 -356
  151. package/dist/rules/convertToJsdocComments.cjs.map +0 -1
  152. package/dist/rules/emptyTags.cjs +0 -98
  153. package/dist/rules/emptyTags.cjs.map +0 -1
  154. package/dist/rules/escapeInlineTags.cjs +0 -234
  155. package/dist/rules/escapeInlineTags.cjs.map +0 -1
  156. package/dist/rules/implementsOnClasses.cjs +0 -74
  157. package/dist/rules/implementsOnClasses.cjs.map +0 -1
  158. package/dist/rules/importsAsDependencies.cjs +0 -104
  159. package/dist/rules/importsAsDependencies.cjs.map +0 -1
  160. package/dist/rules/informativeDocs.cjs +0 -187
  161. package/dist/rules/informativeDocs.cjs.map +0 -1
  162. package/dist/rules/linesBeforeBlock.cjs +0 -120
  163. package/dist/rules/linesBeforeBlock.cjs.map +0 -1
  164. package/dist/rules/matchDescription.cjs +0 -356
  165. package/dist/rules/matchDescription.cjs.map +0 -1
  166. package/dist/rules/matchName.cjs +0 -160
  167. package/dist/rules/matchName.cjs.map +0 -1
  168. package/dist/rules/multilineBlocks.cjs +0 -431
  169. package/dist/rules/multilineBlocks.cjs.map +0 -1
  170. package/dist/rules/noBadBlocks.cjs +0 -100
  171. package/dist/rules/noBadBlocks.cjs.map +0 -1
  172. package/dist/rules/noBlankBlockDescriptions.cjs +0 -63
  173. package/dist/rules/noBlankBlockDescriptions.cjs.map +0 -1
  174. package/dist/rules/noBlankBlocks.cjs +0 -54
  175. package/dist/rules/noBlankBlocks.cjs.map +0 -1
  176. package/dist/rules/noDefaults.cjs +0 -102
  177. package/dist/rules/noDefaults.cjs.map +0 -1
  178. package/dist/rules/noMissingSyntax.cjs +0 -196
  179. package/dist/rules/noMissingSyntax.cjs.map +0 -1
  180. package/dist/rules/noMultiAsterisks.cjs +0 -126
  181. package/dist/rules/noMultiAsterisks.cjs.map +0 -1
  182. package/dist/rules/noRestrictedSyntax.cjs +0 -68
  183. package/dist/rules/noRestrictedSyntax.cjs.map +0 -1
  184. package/dist/rules/noTypes.cjs +0 -101
  185. package/dist/rules/noTypes.cjs.map +0 -1
  186. package/dist/rules/noUndefinedTypes.cjs +0 -616
  187. package/dist/rules/noUndefinedTypes.cjs.map +0 -1
  188. package/dist/rules/normalizeSeeLinks.cjs +0 -271
  189. package/dist/rules/normalizeSeeLinks.cjs.map +0 -1
  190. package/dist/rules/preferImportTag.cjs +0 -362
  191. package/dist/rules/preferImportTag.cjs.map +0 -1
  192. package/dist/rules/requireAsteriskPrefix.cjs +0 -190
  193. package/dist/rules/requireAsteriskPrefix.cjs.map +0 -1
  194. package/dist/rules/requireDescription.cjs +0 -164
  195. package/dist/rules/requireDescription.cjs.map +0 -1
  196. package/dist/rules/requireDescriptionCompleteSentence.cjs +0 -321
  197. package/dist/rules/requireDescriptionCompleteSentence.cjs.map +0 -1
  198. package/dist/rules/requireExample.cjs +0 -136
  199. package/dist/rules/requireExample.cjs.map +0 -1
  200. package/dist/rules/requireFileOverview.cjs +0 -194
  201. package/dist/rules/requireFileOverview.cjs.map +0 -1
  202. package/dist/rules/requireHyphenBeforeParamDescription.cjs +0 -166
  203. package/dist/rules/requireHyphenBeforeParamDescription.cjs.map +0 -1
  204. package/dist/rules/requireJsdoc.cjs +0 -721
  205. package/dist/rules/requireJsdoc.cjs.map +0 -1
  206. package/dist/rules/requireParam.cjs +0 -772
  207. package/dist/rules/requireParam.cjs.map +0 -1
  208. package/dist/rules/requireParamDescription.cjs +0 -105
  209. package/dist/rules/requireParamDescription.cjs.map +0 -1
  210. package/dist/rules/requireParamName.cjs +0 -68
  211. package/dist/rules/requireParamName.cjs.map +0 -1
  212. package/dist/rules/requireParamType.cjs +0 -104
  213. package/dist/rules/requireParamType.cjs.map +0 -1
  214. package/dist/rules/requireProperty.cjs +0 -63
  215. package/dist/rules/requireProperty.cjs.map +0 -1
  216. package/dist/rules/requirePropertyDescription.cjs +0 -29
  217. package/dist/rules/requirePropertyDescription.cjs.map +0 -1
  218. package/dist/rules/requirePropertyName.cjs +0 -29
  219. package/dist/rules/requirePropertyName.cjs.map +0 -1
  220. package/dist/rules/requirePropertyType.cjs +0 -29
  221. package/dist/rules/requirePropertyType.cjs.map +0 -1
  222. package/dist/rules/requireRejects.cjs +0 -226
  223. package/dist/rules/requireRejects.cjs.map +0 -1
  224. package/dist/rules/requireReturns.cjs +0 -262
  225. package/dist/rules/requireReturns.cjs.map +0 -1
  226. package/dist/rules/requireReturnsCheck.cjs +0 -225
  227. package/dist/rules/requireReturnsCheck.cjs.map +0 -1
  228. package/dist/rules/requireReturnsDescription.cjs +0 -72
  229. package/dist/rules/requireReturnsDescription.cjs.map +0 -1
  230. package/dist/rules/requireReturnsType.cjs +0 -68
  231. package/dist/rules/requireReturnsType.cjs.map +0 -1
  232. package/dist/rules/requireTags.cjs +0 -74
  233. package/dist/rules/requireTags.cjs.map +0 -1
  234. package/dist/rules/requireTemplate.cjs +0 -220
  235. package/dist/rules/requireTemplate.cjs.map +0 -1
  236. package/dist/rules/requireThrows.cjs +0 -118
  237. package/dist/rules/requireThrows.cjs.map +0 -1
  238. package/dist/rules/requireYields.cjs +0 -224
  239. package/dist/rules/requireYields.cjs.map +0 -1
  240. package/dist/rules/requireYieldsCheck.cjs +0 -179
  241. package/dist/rules/requireYieldsCheck.cjs.map +0 -1
  242. package/dist/rules/sortTags.cjs +0 -656
  243. package/dist/rules/sortTags.cjs.map +0 -1
  244. package/dist/rules/tagLines.cjs +0 -374
  245. package/dist/rules/tagLines.cjs.map +0 -1
  246. package/dist/rules/textEscaping.cjs +0 -141
  247. package/dist/rules/textEscaping.cjs.map +0 -1
  248. package/dist/rules/tsMethodSignatureStyle.cjs +0 -240
  249. package/dist/rules/tsMethodSignatureStyle.cjs.map +0 -1
  250. package/dist/rules/tsNoEmptyObjectType.cjs +0 -62
  251. package/dist/rules/tsNoEmptyObjectType.cjs.map +0 -1
  252. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs +0 -104
  253. package/dist/rules/tsNoUnnecessaryTemplateExpression.cjs.map +0 -1
  254. package/dist/rules/tsPreferFunctionType.cjs +0 -110
  255. package/dist/rules/tsPreferFunctionType.cjs.map +0 -1
  256. package/dist/rules/typeFormatting.cjs +0 -607
  257. package/dist/rules/typeFormatting.cjs.map +0 -1
  258. package/dist/rules/validTypes.cjs +0 -324
  259. package/dist/rules/validTypes.cjs.map +0 -1
  260. package/dist/tagNames.cjs +0 -244
  261. package/dist/tagNames.cjs.map +0 -1
  262. package/dist/to-valid-identifier.cjs +0 -263
  263. package/dist/utils/hasReturnValue.cjs +0 -495
  264. package/dist/utils/hasReturnValue.cjs.map +0 -1
  265. package/rollup.config.js +0 -16
  266. package/src/getJsdocProcessorPlugin.cts +0 -5
  267. package/src/index-cjs.js +0 -758
  268. package/src/index-esm.js +0 -196
  269. package/src/index.cjs.cts +0 -3
  270. 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