eslint-plugin-jsdoc 46.4.6 → 46.5.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 (187) hide show
  1. package/README.md +31 -0
  2. package/dist/index.js +21 -10
  3. package/dist/index.js.map +1 -1
  4. package/package.json +14 -12
  5. package/dist/WarnSettings.d.ts +0 -17
  6. package/dist/WarnSettings.d.ts.map +0 -1
  7. package/dist/alignTransform.d.ts +0 -32
  8. package/dist/alignTransform.d.ts.map +0 -1
  9. package/dist/defaultTagOrder.d.ts +0 -5
  10. package/dist/defaultTagOrder.d.ts.map +0 -1
  11. package/dist/exportParser.d.ts +0 -41
  12. package/dist/exportParser.d.ts.map +0 -1
  13. package/dist/getDefaultTagStructureForMode.d.ts +0 -11
  14. package/dist/getDefaultTagStructureForMode.d.ts.map +0 -1
  15. package/dist/index.d.ts +0 -10
  16. package/dist/index.d.ts.map +0 -1
  17. package/dist/iterateJsdoc.d.ts +0 -460
  18. package/dist/iterateJsdoc.d.ts.map +0 -1
  19. package/dist/jsdocUtils.d.ts +0 -421
  20. package/dist/jsdocUtils.d.ts.map +0 -1
  21. package/dist/rules/checkAccess.d.ts +0 -3
  22. package/dist/rules/checkAccess.d.ts.map +0 -1
  23. package/dist/rules/checkAlignment.d.ts +0 -3
  24. package/dist/rules/checkAlignment.d.ts.map +0 -1
  25. package/dist/rules/checkExamples.d.ts +0 -4
  26. package/dist/rules/checkExamples.d.ts.map +0 -1
  27. package/dist/rules/checkIndentation.d.ts +0 -3
  28. package/dist/rules/checkIndentation.d.ts.map +0 -1
  29. package/dist/rules/checkLineAlignment.d.ts +0 -10
  30. package/dist/rules/checkLineAlignment.d.ts.map +0 -1
  31. package/dist/rules/checkParamNames.d.ts +0 -3
  32. package/dist/rules/checkParamNames.d.ts.map +0 -1
  33. package/dist/rules/checkPropertyNames.d.ts +0 -3
  34. package/dist/rules/checkPropertyNames.d.ts.map +0 -1
  35. package/dist/rules/checkSyntax.d.ts +0 -3
  36. package/dist/rules/checkSyntax.d.ts.map +0 -1
  37. package/dist/rules/checkTagNames.d.ts +0 -3
  38. package/dist/rules/checkTagNames.d.ts.map +0 -1
  39. package/dist/rules/checkTypes.d.ts +0 -3
  40. package/dist/rules/checkTypes.d.ts.map +0 -1
  41. package/dist/rules/checkValues.d.ts +0 -3
  42. package/dist/rules/checkValues.d.ts.map +0 -1
  43. package/dist/rules/emptyTags.d.ts +0 -3
  44. package/dist/rules/emptyTags.d.ts.map +0 -1
  45. package/dist/rules/implementsOnClasses.d.ts +0 -3
  46. package/dist/rules/implementsOnClasses.d.ts.map +0 -1
  47. package/dist/rules/importsAsDependencies.d.ts +0 -3
  48. package/dist/rules/importsAsDependencies.d.ts.map +0 -1
  49. package/dist/rules/informativeDocs.d.ts +0 -3
  50. package/dist/rules/informativeDocs.d.ts.map +0 -1
  51. package/dist/rules/matchDescription.d.ts +0 -3
  52. package/dist/rules/matchDescription.d.ts.map +0 -1
  53. package/dist/rules/matchName.d.ts +0 -3
  54. package/dist/rules/matchName.d.ts.map +0 -1
  55. package/dist/rules/multilineBlocks.d.ts +0 -3
  56. package/dist/rules/multilineBlocks.d.ts.map +0 -1
  57. package/dist/rules/noBadBlocks.d.ts +0 -3
  58. package/dist/rules/noBadBlocks.d.ts.map +0 -1
  59. package/dist/rules/noBlankBlockDescriptions.d.ts +0 -3
  60. package/dist/rules/noBlankBlockDescriptions.d.ts.map +0 -1
  61. package/dist/rules/noBlankBlocks.d.ts +0 -3
  62. package/dist/rules/noBlankBlocks.d.ts.map +0 -1
  63. package/dist/rules/noDefaults.d.ts +0 -3
  64. package/dist/rules/noDefaults.d.ts.map +0 -1
  65. package/dist/rules/noMissingSyntax.d.ts +0 -10
  66. package/dist/rules/noMissingSyntax.d.ts.map +0 -1
  67. package/dist/rules/noMultiAsterisks.d.ts +0 -3
  68. package/dist/rules/noMultiAsterisks.d.ts.map +0 -1
  69. package/dist/rules/noRestrictedSyntax.d.ts +0 -3
  70. package/dist/rules/noRestrictedSyntax.d.ts.map +0 -1
  71. package/dist/rules/noTypes.d.ts +0 -3
  72. package/dist/rules/noTypes.d.ts.map +0 -1
  73. package/dist/rules/noUndefinedTypes.d.ts +0 -3
  74. package/dist/rules/noUndefinedTypes.d.ts.map +0 -1
  75. package/dist/rules/requireAsteriskPrefix.d.ts +0 -3
  76. package/dist/rules/requireAsteriskPrefix.d.ts.map +0 -1
  77. package/dist/rules/requireDescription.d.ts +0 -3
  78. package/dist/rules/requireDescription.d.ts.map +0 -1
  79. package/dist/rules/requireDescriptionCompleteSentence.d.ts +0 -3
  80. package/dist/rules/requireDescriptionCompleteSentence.d.ts.map +0 -1
  81. package/dist/rules/requireExample.d.ts +0 -3
  82. package/dist/rules/requireExample.d.ts.map +0 -1
  83. package/dist/rules/requireFileOverview.d.ts +0 -3
  84. package/dist/rules/requireFileOverview.d.ts.map +0 -1
  85. package/dist/rules/requireHyphenBeforeParamDescription.d.ts +0 -3
  86. package/dist/rules/requireHyphenBeforeParamDescription.d.ts.map +0 -1
  87. package/dist/rules/requireJsdoc.d.ts +0 -9
  88. package/dist/rules/requireJsdoc.d.ts.map +0 -1
  89. package/dist/rules/requireParam.d.ts +0 -4
  90. package/dist/rules/requireParam.d.ts.map +0 -1
  91. package/dist/rules/requireParamDescription.d.ts +0 -3
  92. package/dist/rules/requireParamDescription.d.ts.map +0 -1
  93. package/dist/rules/requireParamName.d.ts +0 -3
  94. package/dist/rules/requireParamName.d.ts.map +0 -1
  95. package/dist/rules/requireParamType.d.ts +0 -3
  96. package/dist/rules/requireParamType.d.ts.map +0 -1
  97. package/dist/rules/requireProperty.d.ts +0 -3
  98. package/dist/rules/requireProperty.d.ts.map +0 -1
  99. package/dist/rules/requirePropertyDescription.d.ts +0 -3
  100. package/dist/rules/requirePropertyDescription.d.ts.map +0 -1
  101. package/dist/rules/requirePropertyName.d.ts +0 -3
  102. package/dist/rules/requirePropertyName.d.ts.map +0 -1
  103. package/dist/rules/requirePropertyType.d.ts +0 -3
  104. package/dist/rules/requirePropertyType.d.ts.map +0 -1
  105. package/dist/rules/requireReturns.d.ts +0 -3
  106. package/dist/rules/requireReturns.d.ts.map +0 -1
  107. package/dist/rules/requireReturnsCheck.d.ts +0 -3
  108. package/dist/rules/requireReturnsCheck.d.ts.map +0 -1
  109. package/dist/rules/requireReturnsDescription.d.ts +0 -3
  110. package/dist/rules/requireReturnsDescription.d.ts.map +0 -1
  111. package/dist/rules/requireReturnsType.d.ts +0 -3
  112. package/dist/rules/requireReturnsType.d.ts.map +0 -1
  113. package/dist/rules/requireThrows.d.ts +0 -3
  114. package/dist/rules/requireThrows.d.ts.map +0 -1
  115. package/dist/rules/requireYields.d.ts +0 -3
  116. package/dist/rules/requireYields.d.ts.map +0 -1
  117. package/dist/rules/requireYieldsCheck.d.ts +0 -3
  118. package/dist/rules/requireYieldsCheck.d.ts.map +0 -1
  119. package/dist/rules/sortTags.d.ts +0 -3
  120. package/dist/rules/sortTags.d.ts.map +0 -1
  121. package/dist/rules/tagLines.d.ts +0 -3
  122. package/dist/rules/tagLines.d.ts.map +0 -1
  123. package/dist/rules/textEscaping.d.ts +0 -3
  124. package/dist/rules/textEscaping.d.ts.map +0 -1
  125. package/dist/rules/validTypes.d.ts +0 -3
  126. package/dist/rules/validTypes.d.ts.map +0 -1
  127. package/dist/tagNames.d.ts +0 -16
  128. package/dist/tagNames.d.ts.map +0 -1
  129. package/dist/utils/hasReturnValue.d.ts +0 -20
  130. package/dist/utils/hasReturnValue.d.ts.map +0 -1
  131. package/docs/advanced.md +0 -102
  132. package/docs/rules/check-access.md +0 -193
  133. package/docs/rules/check-alignment.md +0 -169
  134. package/docs/rules/check-examples.md +0 -784
  135. package/docs/rules/check-indentation.md +0 -296
  136. package/docs/rules/check-line-alignment.md +0 -1002
  137. package/docs/rules/check-param-names.md +0 -1035
  138. package/docs/rules/check-property-names.md +0 -244
  139. package/docs/rules/check-syntax.md +0 -80
  140. package/docs/rules/check-tag-names.md +0 -1132
  141. package/docs/rules/check-types.md +0 -1198
  142. package/docs/rules/check-values.md +0 -409
  143. package/docs/rules/empty-tags.md +0 -220
  144. package/docs/rules/implements-on-classes.md +0 -219
  145. package/docs/rules/imports-as-dependencies.md +0 -99
  146. package/docs/rules/informative-docs.md +0 -400
  147. package/docs/rules/match-description.md +0 -1008
  148. package/docs/rules/match-name.md +0 -249
  149. package/docs/rules/multiline-blocks.md +0 -398
  150. package/docs/rules/no-bad-blocks.md +0 -174
  151. package/docs/rules/no-blank-block-descriptions.md +0 -91
  152. package/docs/rules/no-blank-blocks.md +0 -98
  153. package/docs/rules/no-defaults.md +0 -207
  154. package/docs/rules/no-missing-syntax.md +0 -275
  155. package/docs/rules/no-multi-asterisks.md +0 -278
  156. package/docs/rules/no-restricted-syntax.md +0 -383
  157. package/docs/rules/no-types.md +0 -168
  158. package/docs/rules/no-undefined-types.md +0 -789
  159. package/docs/rules/require-asterisk-prefix.md +0 -297
  160. package/docs/rules/require-description-complete-sentence.md +0 -820
  161. package/docs/rules/require-description.md +0 -585
  162. package/docs/rules/require-example.md +0 -390
  163. package/docs/rules/require-file-overview.md +0 -324
  164. package/docs/rules/require-hyphen-before-param-description.md +0 -281
  165. package/docs/rules/require-jsdoc.md +0 -1857
  166. package/docs/rules/require-param-description.md +0 -238
  167. package/docs/rules/require-param-name.md +0 -163
  168. package/docs/rules/require-param-type.md +0 -227
  169. package/docs/rules/require-param.md +0 -1820
  170. package/docs/rules/require-property-description.md +0 -88
  171. package/docs/rules/require-property-name.md +0 -79
  172. package/docs/rules/require-property-type.md +0 -79
  173. package/docs/rules/require-property.md +0 -128
  174. package/docs/rules/require-returns-check.md +0 -1053
  175. package/docs/rules/require-returns-description.md +0 -181
  176. package/docs/rules/require-returns-type.md +0 -144
  177. package/docs/rules/require-returns.md +0 -1191
  178. package/docs/rules/require-throws.md +0 -326
  179. package/docs/rules/require-yields-check.md +0 -544
  180. package/docs/rules/require-yields.md +0 -823
  181. package/docs/rules/sort-tags.md +0 -635
  182. package/docs/rules/tag-lines.md +0 -551
  183. package/docs/rules/text-escaping.md +0 -177
  184. package/docs/rules/valid-types.md +0 -881
  185. package/docs/settings.md +0 -362
  186. package/tsconfig-prod.json +0 -20
  187. package/tsconfig.json +0 -21
@@ -1,1820 +0,0 @@
1
- <a name="user-content-require-param"></a>
2
- <a name="require-param"></a>
3
- # <code>require-param</code>
4
-
5
- * [Fixer](#user-content-require-param-fixer)
6
- * [Destructured object and array naming](#user-content-require-param-fixer-destructured-object-and-array-naming)
7
- * [Missing root fixing](#user-content-require-param-fixer-missing-root-fixing)
8
- * [Rest Element (`RestElement`) insertions](#user-content-require-param-fixer-rest-element-restelement-insertions)
9
- * [Object Rest Property insertions](#user-content-require-param-fixer-object-rest-property-insertions)
10
- * [Options](#user-content-require-param-options)
11
- * [`enableFixer`](#user-content-require-param-options-enablefixer)
12
- * [`enableRootFixer`](#user-content-require-param-options-enablerootfixer)
13
- * [`enableRestElementFixer`](#user-content-require-param-options-enablerestelementfixer)
14
- * [`checkRestProperty`](#user-content-require-param-options-checkrestproperty)
15
- * [`autoIncrementBase`](#user-content-require-param-options-autoincrementbase)
16
- * [`unnamedRootBase`](#user-content-require-param-options-unnamedrootbase)
17
- * [`exemptedBy`](#user-content-require-param-options-exemptedby)
18
- * [`checkTypesPattern`](#user-content-require-param-options-checktypespattern)
19
- * [`contexts`](#user-content-require-param-options-contexts)
20
- * [`checkConstructors`](#user-content-require-param-options-checkconstructors)
21
- * [`checkGetters`](#user-content-require-param-options-checkgetters)
22
- * [`checkSetters`](#user-content-require-param-options-checksetters)
23
- * [`checkDestructured`](#user-content-require-param-options-checkdestructured)
24
- * [`checkDestructuredRoots`](#user-content-require-param-options-checkdestructuredroots)
25
- * [`useDefaultObjectProperties`](#user-content-require-param-options-usedefaultobjectproperties)
26
- * [Context and settings](#user-content-require-param-context-and-settings)
27
- * [Failing examples](#user-content-require-param-failing-examples)
28
- * [Passing examples](#user-content-require-param-passing-examples)
29
-
30
-
31
- Requires that all function parameters are documented.
32
-
33
- <a name="user-content-require-param-fixer"></a>
34
- <a name="require-param-fixer"></a>
35
- ## Fixer
36
-
37
- Adds `@param <name>` for each tag present in the function signature but
38
- missing in the jsdoc. Can be disabled by setting the `enableFixer`
39
- option to `false`.
40
-
41
- <a name="user-content-require-param-fixer-destructured-object-and-array-naming"></a>
42
- <a name="require-param-fixer-destructured-object-and-array-naming"></a>
43
- ### Destructured object and array naming
44
-
45
- When the fixer is applied to destructured objects, only the input name is
46
- used.
47
-
48
- So for:
49
-
50
- ```js
51
- /**
52
- * @param cfg
53
- */
54
- function quux ({foo: bar, baz: bax = 5}) {
55
- }
56
- ```
57
-
58
- ...the fixed jsdoc will be:
59
-
60
- ```js
61
- /**
62
- * @param cfg
63
- * @param cfg.foo
64
- * @param cfg.baz
65
- */
66
- ```
67
-
68
- This is because the input to the function is the relevant item for
69
- understanding the function's input, not how the variable is renamed
70
- for internal use (the signature itself documents that).
71
-
72
- For destructured arrays, the input name is merely the array index.
73
-
74
- So for:
75
-
76
- ```js
77
- /**
78
- * @param cfg
79
- */
80
- function quux ([foo, bar]) {
81
- }
82
- ```
83
-
84
- ..the fixed jsdoc will be:
85
-
86
- ```js
87
- /**
88
- * @param cfg
89
- * @param cfg."0"
90
- * @param cfg."1"
91
- */
92
- ```
93
-
94
- <a name="user-content-require-param-fixer-missing-root-fixing"></a>
95
- <a name="require-param-fixer-missing-root-fixing"></a>
96
- ### Missing root fixing
97
-
98
- Note that unless `enableRootFixer` (or `enableFixer`) is set to `false`,
99
- missing roots will be added and auto-incremented. The default behavior
100
- is for "root" to be auto-inserted for missing roots, followed by a
101
- 0-based auto-incrementing number.
102
-
103
- So for:
104
-
105
- ```js
106
- function quux ({foo}, {bar}, {baz}) {
107
- }
108
- ```
109
-
110
- ...the default jsdoc that would be added if the fixer is enabled would be:
111
-
112
- ```js
113
- /**
114
- * @param root0
115
- * @param root0.foo
116
- * @param root1
117
- * @param root1.bar
118
- * @param root2
119
- * @param root2.baz
120
- */
121
- ```
122
-
123
- The name of "root" can be configured with `unnamedRootBase` (which also allows
124
- cycling through a list of multiple root names before there is need for any
125
- numeric component).
126
-
127
- And one can have the count begin at another number (e.g., `1`) by changing
128
- `autoIncrementBase` from the default of `0`.
129
-
130
- <a name="user-content-require-param-fixer-rest-element-restelement-insertions"></a>
131
- <a name="require-param-fixer-rest-element-restelement-insertions"></a>
132
- ### Rest Element (<code>RestElement</code>) insertions
133
-
134
- The fixer will automatically report/insert
135
- [jsdoc repeatable parameters](https://jsdoc.app/tags-param.html#multiple-types-and-repeatable-parameters)
136
- if missing.
137
-
138
- ```js
139
- /**
140
- * @param {GenericArray} cfg
141
- * @param {number} cfg."0"
142
- */
143
- function baar ([a, ...extra]) {
144
- //
145
- }
146
- ```
147
-
148
- ..becomes:
149
-
150
- ```js
151
- /**
152
- * @param {GenericArray} cfg
153
- * @param {number} cfg."0"
154
- * @param {...any} cfg."1"
155
- */
156
- function baar ([a, ...extra]) {
157
- //
158
- }
159
- ```
160
-
161
- Note that the type `any` is included since we don't know of any specific
162
- type to use.
163
-
164
- To disable such rest element insertions, set `enableRestElementFixer` to
165
- `false`.
166
-
167
- Note too that the following will be reported even though there is an item
168
- corresponding to `extra`:
169
-
170
- ```js
171
- /**
172
- * @param {GenericArray} cfg
173
- * @param {number} cfg."0"
174
- * @param {any} cfg."1"
175
- */
176
- function baar ([a, ...extra]) {
177
- //
178
- }
179
- ```
180
-
181
- ...because it does not use the `...` syntax in the type.
182
-
183
- <a name="user-content-require-param-fixer-object-rest-property-insertions"></a>
184
- <a name="require-param-fixer-object-rest-property-insertions"></a>
185
- ### Object Rest Property insertions
186
-
187
- If the `checkRestProperty` option is set to `true` (`false` by default),
188
- missing rest properties will be reported with documentation auto-inserted:
189
-
190
- ```js
191
- /**
192
- * @param cfg
193
- * @param cfg.num
194
- */
195
- function quux ({num, ...extra}) {
196
- }
197
- ```
198
-
199
- ...becomes:
200
-
201
- ```js
202
- /**
203
- * @param cfg
204
- * @param cfg.num
205
- * @param cfg.extra
206
- */
207
- function quux ({num, ...extra}) {
208
- }
209
- ```
210
-
211
- You may wish to manually note in your jsdoc for `extra` that this is a
212
- rest property, however, as jsdoc
213
- [does not appear](https://github.com/jsdoc/jsdoc/issues/1773)
214
- to currently support syntax or output to distinguish rest properties from
215
- other properties, so in looking at the docs alone without looking at the
216
- function signature, it may appear that there is an actual property named
217
- `extra`.
218
-
219
- <a name="user-content-require-param-options"></a>
220
- <a name="require-param-options"></a>
221
- ## Options
222
-
223
- An options object accepts the following optional properties:
224
-
225
- <a name="user-content-require-param-options-enablefixer"></a>
226
- <a name="require-param-options-enablefixer"></a>
227
- ### <code>enableFixer</code>
228
-
229
- Whether to enable the fixer. Defaults to `true`.
230
-
231
- <a name="user-content-require-param-options-enablerootfixer"></a>
232
- <a name="require-param-options-enablerootfixer"></a>
233
- ### <code>enableRootFixer</code>
234
-
235
- Whether to enable the auto-adding of incrementing roots (see the "Fixer"
236
- section). Defaults to `true`. Has no effect if `enableFixer` is set to
237
- `false`.
238
-
239
- <a name="user-content-require-param-options-enablerestelementfixer"></a>
240
- <a name="require-param-options-enablerestelementfixer"></a>
241
- ### <code>enableRestElementFixer</code>
242
-
243
- Whether to enable the rest element fixer (see
244
- "Rest Element (`RestElement`) insertions"). Defaults to `true`.
245
-
246
- <a name="user-content-require-param-options-checkrestproperty"></a>
247
- <a name="require-param-options-checkrestproperty"></a>
248
- ### <code>checkRestProperty</code>
249
-
250
- If set to `true`, will report (and add fixer insertions) for missing rest
251
- properties. Defaults to `false`.
252
-
253
- If set to `true`, note that you can still document the subproperties of the
254
- rest property using other jsdoc features, e.g., `@typedef`:
255
-
256
- ```js
257
- /**
258
- * @typedef ExtraOptions
259
- * @property innerProp1
260
- * @property innerProp2
261
- */
262
-
263
- /**
264
- * @param cfg
265
- * @param cfg.num
266
- * @param {ExtraOptions} extra
267
- */
268
- function quux ({num, ...extra}) {
269
- }
270
- ```
271
-
272
- Setting this option to `false` (the default) may be useful in cases where
273
- you already have separate `@param` definitions for each of the properties
274
- within the rest property.
275
-
276
- For example, with the option disabled, this will not give an error despite
277
- `extra` not having any definition:
278
-
279
- ```js
280
- /**
281
- * @param cfg
282
- * @param cfg.num
283
- */
284
- function quux ({num, ...extra}) {
285
- }
286
- ```
287
-
288
- Nor will this:
289
-
290
- ```js
291
- /**
292
- * @param cfg
293
- * @param cfg.num
294
- * @param cfg.innerProp1
295
- * @param cfg.innerProp2
296
- */
297
- function quux ({num, ...extra}) {
298
- }
299
- ```
300
-
301
- <a name="user-content-require-param-options-autoincrementbase"></a>
302
- <a name="require-param-options-autoincrementbase"></a>
303
- ### <code>autoIncrementBase</code>
304
-
305
- Numeric to indicate the number at which to begin auto-incrementing roots.
306
- Defaults to `0`.
307
-
308
- <a name="user-content-require-param-options-unnamedrootbase"></a>
309
- <a name="require-param-options-unnamedrootbase"></a>
310
- ### <code>unnamedRootBase</code>
311
-
312
- An array of root names to use in the fixer when roots are missing. Defaults
313
- to `['root']`. Note that only when all items in the array besides the last
314
- are exhausted will auto-incrementing occur. So, with
315
- `unnamedRootBase: ['arg', 'config']`, the following:
316
-
317
- ```js
318
- function quux ({foo}, [bar], {baz}) {
319
- }
320
- ```
321
-
322
- ...will get the following jsdoc block added:
323
-
324
- ```js
325
- /**
326
- * @param arg
327
- * @param arg.foo
328
- * @param config0
329
- * @param config0."0" (`bar`)
330
- * @param config1
331
- * @param config1.baz
332
- */
333
- ```
334
-
335
- <a name="user-content-require-param-options-exemptedby"></a>
336
- <a name="require-param-options-exemptedby"></a>
337
- ### <code>exemptedBy</code>
338
-
339
- Array of tags (e.g., `['type']`) whose presence on the document block
340
- avoids the need for a `@param`. Defaults to an array with
341
- `inheritdoc`. If you set this array, it will overwrite the default,
342
- so be sure to add back `inheritdoc` if you wish its presence to cause
343
- exemption of the rule.
344
-
345
- <a name="user-content-require-param-options-checktypespattern"></a>
346
- <a name="require-param-options-checktypespattern"></a>
347
- ### <code>checkTypesPattern</code>
348
-
349
- When one specifies a type, unless it is of a generic type, like `object`
350
- or `array`, it may be considered unnecessary to have that object's
351
- destructured components required, especially where generated docs will
352
- link back to the specified type. For example:
353
-
354
- ```js
355
- /**
356
- * @param {SVGRect} bbox - a SVGRect
357
- */
358
- export const bboxToObj = function ({x, y, width, height}) {
359
- return {x, y, width, height};
360
- };
361
- ```
362
-
363
- By default `checkTypesPattern` is set to
364
- `/^(?:[oO]bject|[aA]rray|PlainObject|Generic(?:Object|Array))$/u`,
365
- meaning that destructuring will be required only if the type of the `@param`
366
- (the text between curly brackets) is a match for "Object" or "Array" (with or
367
- without initial caps), "PlainObject", or "GenericObject", "GenericArray" (or
368
- if no type is present). So in the above example, the lack of a match will
369
- mean that no complaint will be given about the undocumented destructured
370
- parameters.
371
-
372
- Note that the `/` delimiters are optional, but necessary to add flags.
373
-
374
- Defaults to using (only) the `u` flag, so to add your own flags, encapsulate
375
- your expression as a string, but like a literal, e.g., `/^object$/ui`.
376
-
377
- You could set this regular expression to a more expansive list, or you
378
- could restrict it such that even types matching those strings would not
379
- need destructuring.
380
-
381
- <a name="user-content-require-param-options-contexts"></a>
382
- <a name="require-param-options-contexts"></a>
383
- ### <code>contexts</code>
384
-
385
- Set this to an array of strings representing the AST context (or an object with
386
- `context` and `comment` properties) where you wish the rule to be applied.
387
- Overrides the default contexts (see below). May be useful for adding such as
388
- `TSMethodSignature` in TypeScript or restricting the contexts
389
- which are checked.
390
-
391
- See the ["AST and Selectors"](#user-content-eslint-plugin-jsdoc-advanced-ast-and-selectors)
392
- section of our README for more on the expected format.
393
-
394
- <a name="user-content-require-param-options-checkconstructors"></a>
395
- <a name="require-param-options-checkconstructors"></a>
396
- ### <code>checkConstructors</code>
397
-
398
- A value indicating whether `constructor`s should be checked. Defaults to
399
- `true`.
400
-
401
- <a name="user-content-require-param-options-checkgetters"></a>
402
- <a name="require-param-options-checkgetters"></a>
403
- ### <code>checkGetters</code>
404
-
405
- A value indicating whether getters should be checked. Defaults to `false`.
406
-
407
- <a name="user-content-require-param-options-checksetters"></a>
408
- <a name="require-param-options-checksetters"></a>
409
- ### <code>checkSetters</code>
410
-
411
- A value indicating whether setters should be checked. Defaults to `false`.
412
-
413
- <a name="user-content-require-param-options-checkdestructured"></a>
414
- <a name="require-param-options-checkdestructured"></a>
415
- ### <code>checkDestructured</code>
416
-
417
- Whether to require destructured properties. Defaults to `true`.
418
-
419
- <a name="user-content-require-param-options-checkdestructuredroots"></a>
420
- <a name="require-param-options-checkdestructuredroots"></a>
421
- ### <code>checkDestructuredRoots</code>
422
-
423
- Whether to check the existence of a corresponding `@param` for root objects
424
- of destructured properties (e.g., that for `function ({a, b}) {}`, that there
425
- is something like `@param myRootObj` defined that can correspond to
426
- the `{a, b}` object parameter).
427
-
428
- If `checkDestructuredRoots` is `false`, `checkDestructured` will also be
429
- implied to be `false` (i.e., the inside of the roots will not be checked
430
- either, e.g., it will also not complain if `a` or `b` do not have their own
431
- documentation). Defaults to `true`.
432
-
433
- <a name="user-content-require-param-options-usedefaultobjectproperties"></a>
434
- <a name="require-param-options-usedefaultobjectproperties"></a>
435
- ### <code>useDefaultObjectProperties</code>
436
-
437
- Set to `true` if you wish to expect documentation of properties on objects
438
- supplied as default values. Defaults to `false`.
439
-
440
- <a name="user-content-require-param-context-and-settings"></a>
441
- <a name="require-param-context-and-settings"></a>
442
- ## Context and settings
443
-
444
- | | |
445
- | -------- | ----------------------------------------------------------------------------- |
446
- | Context | `ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled |
447
- | Tags | `param` |
448
- | Aliases | `arg`, `argument` |
449
- |Recommended | true|
450
- | Options |`autoIncrementBase`, `checkConstructors`, `checkDestructured`, `checkDestructuredRoots`, `checkGetters`, `checkRestProperty`, `checkSetters`, `checkTypesPattern`, `contexts`, `enableFixer`, `enableRestElementFixer`, `enableRootFixer`, `exemptedBy`, `unnamedRootBase`, `useDefaultObjectProperties`|
451
- | Settings | `ignoreReplacesDocs`, `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
452
-
453
- <a name="user-content-require-param-failing-examples"></a>
454
- <a name="require-param-failing-examples"></a>
455
- ## Failing examples
456
-
457
- The following patterns are considered problems:
458
-
459
- ````js
460
- /**
461
- *
462
- */
463
- function quux (foo) {
464
-
465
- }
466
- // Message: Missing JSDoc @param "foo" declaration.
467
-
468
- /**
469
- *
470
- */
471
- function quux (foo) {
472
-
473
- }
474
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["FunctionDeclaration"]}]
475
- // Message: Missing JSDoc @param "foo" declaration.
476
-
477
- /**
478
- *
479
- */
480
- function quux ({foo}) {
481
-
482
- }
483
- // Message: Missing JSDoc @param "root0" declaration.
484
-
485
- /**
486
- * @param foo
487
- */
488
- function quux (foo, bar, {baz}) {
489
-
490
- }
491
- // "jsdoc/require-param": ["error"|"warn", {"checkDestructured":false}]
492
- // Message: Missing JSDoc @param "bar" declaration.
493
-
494
- /**
495
- * @param foo
496
- */
497
- function quux (foo, bar, {baz}) {
498
-
499
- }
500
- // "jsdoc/require-param": ["error"|"warn", {"checkDestructuredRoots":false}]
501
- // Message: Missing JSDoc @param "bar" declaration.
502
-
503
- /**
504
- *
505
- */
506
- function quux ({foo}) {
507
-
508
- }
509
- // "jsdoc/require-param": ["error"|"warn", {"enableFixer":false}]
510
- // Message: Missing JSDoc @param "root0" declaration.
511
-
512
- /**
513
- *
514
- */
515
- function quux ({foo: bar = 5} = {}) {
516
-
517
- }
518
- // Message: Missing JSDoc @param "root0" declaration.
519
-
520
- /**
521
- * @param
522
- */
523
- function quux ({foo}) {
524
-
525
- }
526
- // Message: Missing JSDoc @param "root0" declaration.
527
-
528
- /**
529
- * @param
530
- */
531
- function quux ({foo}) {
532
-
533
- }
534
- // "jsdoc/require-param": ["error"|"warn", {"autoIncrementBase":1}]
535
- // Message: Missing JSDoc @param "root1" declaration.
536
-
537
- /**
538
- * @param options
539
- */
540
- function quux ({foo}) {
541
-
542
- }
543
- // Message: Missing JSDoc @param "options.foo" declaration.
544
-
545
- /**
546
- * @param
547
- */
548
- function quux ({ foo, bar: { baz }}) {
549
-
550
- }
551
- // Message: Missing JSDoc @param "root0" declaration.
552
-
553
- /**
554
- *
555
- */
556
- function quux ({foo}, {bar}) {
557
-
558
- }
559
- // "jsdoc/require-param": ["error"|"warn", {"unnamedRootBase":["arg"]}]
560
- // Message: Missing JSDoc @param "arg0" declaration.
561
-
562
- /**
563
- *
564
- */
565
- function quux ({foo}, {bar}) {
566
-
567
- }
568
- // "jsdoc/require-param": ["error"|"warn", {"unnamedRootBase":["arg","config"]}]
569
- // Message: Missing JSDoc @param "arg" declaration.
570
-
571
- /**
572
- *
573
- */
574
- function quux ({foo}, {bar}) {
575
-
576
- }
577
- // "jsdoc/require-param": ["error"|"warn", {"enableRootFixer":false,"unnamedRootBase":["arg","config"]}]
578
- // Message: Missing JSDoc @param "arg" declaration.
579
-
580
- /**
581
- *
582
- */
583
- function quux (foo, bar) {
584
-
585
- }
586
- // Message: Missing JSDoc @param "foo" declaration.
587
-
588
- /**
589
- * @param foo
590
- */
591
- function quux (foo, bar) {
592
-
593
- }
594
- // Message: Missing JSDoc @param "bar" declaration.
595
-
596
- /**
597
- * @param bar
598
- */
599
- function quux (foo, bar, baz) {
600
-
601
- }
602
- // Message: Missing JSDoc @param "foo" declaration.
603
-
604
- /**
605
- * @param foo
606
- * @param bar
607
- */
608
- function quux (foo, bar, baz) {
609
-
610
- }
611
- // Message: Missing JSDoc @param "baz" declaration.
612
-
613
- /**
614
- * @param baz
615
- */
616
- function quux (foo, bar, baz) {
617
-
618
- }
619
- // Message: Missing JSDoc @param "foo" declaration.
620
-
621
- /**
622
- * @param
623
- */
624
- function quux (foo) {
625
-
626
- }
627
- // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
628
- // Message: Missing JSDoc @arg "foo" declaration.
629
-
630
- /**
631
- * @param foo
632
- */
633
- function quux (foo, bar) {
634
-
635
- }
636
- // Message: Missing JSDoc @param "bar" declaration.
637
-
638
- /**
639
- * @override
640
- */
641
- function quux (foo) {
642
-
643
- }
644
- // Settings: {"jsdoc":{"overrideReplacesDocs":false}}
645
- // Message: Missing JSDoc @param "foo" declaration.
646
-
647
- /**
648
- * @ignore
649
- */
650
- function quux (foo) {
651
-
652
- }
653
- // Settings: {"jsdoc":{"ignoreReplacesDocs":false}}
654
- // Message: Missing JSDoc @param "foo" declaration.
655
-
656
- /**
657
- * @implements
658
- */
659
- function quux (foo) {
660
-
661
- }
662
- // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
663
- // Message: Missing JSDoc @param "foo" declaration.
664
-
665
- /**
666
- * @augments
667
- */
668
- function quux (foo) {
669
-
670
- }
671
- // Message: Missing JSDoc @param "foo" declaration.
672
-
673
- /**
674
- * @extends
675
- */
676
- function quux (foo) {
677
-
678
- }
679
- // Message: Missing JSDoc @param "foo" declaration.
680
-
681
- /**
682
- * @override
683
- */
684
- class A {
685
- /**
686
- *
687
- */
688
- quux (foo) {
689
-
690
- }
691
- }
692
- // Settings: {"jsdoc":{"overrideReplacesDocs":false}}
693
- // Message: Missing JSDoc @param "foo" declaration.
694
-
695
- /**
696
- * @ignore
697
- */
698
- class A {
699
- /**
700
- *
701
- */
702
- quux (foo) {
703
-
704
- }
705
- }
706
- // Settings: {"jsdoc":{"ignoreReplacesDocs":false}}
707
- // Message: Missing JSDoc @param "foo" declaration.
708
-
709
- /**
710
- * @implements
711
- */
712
- class A {
713
- /**
714
- *
715
- */
716
- quux (foo) {
717
-
718
- }
719
- }
720
- // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
721
- // Message: Missing JSDoc @param "foo" declaration.
722
-
723
- /**
724
- * @augments
725
- */
726
- class A {
727
- /**
728
- *
729
- */
730
- quux (foo) {
731
-
732
- }
733
- }
734
- // Message: Missing JSDoc @param "foo" declaration.
735
-
736
- /**
737
- * @extends
738
- */
739
- class A {
740
- /**
741
- *
742
- */
743
- quux (foo) {
744
-
745
- }
746
- }
747
- // Message: Missing JSDoc @param "foo" declaration.
748
-
749
- export class SomeClass {
750
- /**
751
- * @param property
752
- */
753
- constructor(private property: string, private foo: number) {}
754
- }
755
- // Message: Missing JSDoc @param "foo" declaration.
756
-
757
- /**
758
- * @param
759
- */
760
- function quux (foo) {
761
-
762
- }
763
- // Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
764
- // Message: Unexpected tag `@param`
765
-
766
- /**
767
- *
768
- */
769
- function quux ({bar, baz}, foo) {
770
- }
771
- // Message: Missing JSDoc @param "root0" declaration.
772
-
773
- /**
774
- *
775
- */
776
- function quux (foo, {bar, baz}) {
777
- }
778
- // Message: Missing JSDoc @param "foo" declaration.
779
-
780
- /**
781
- *
782
- */
783
- function quux ([bar, baz], foo) {
784
- }
785
- // Message: Missing JSDoc @param "root0" declaration.
786
-
787
- /**
788
- *
789
- */
790
- function quux (foo) {
791
- }
792
- // "jsdoc/require-param": ["error"|"warn", {"exemptedBy":["notPresent"]}]
793
- // Message: Missing JSDoc @param "foo" declaration.
794
-
795
- /**
796
- * @inheritdoc
797
- */
798
- function quux (foo) {
799
-
800
- }
801
- // "jsdoc/require-param": ["error"|"warn", {"exemptedBy":[]}]
802
- // Message: Missing JSDoc @param "foo" declaration.
803
-
804
- /**
805
- * @inheritdoc
806
- */
807
- function quux (foo) {
808
-
809
- }
810
- // Settings: {"jsdoc":{"mode":"closure"}}
811
- // Message: Missing JSDoc @param "foo" declaration.
812
-
813
- /**
814
- * Assign the project to a list of employees.
815
- * @param {object[]} employees - The employees who are responsible for the project.
816
- * @param {string} employees[].name - The name of an employee.
817
- * @param {string} employees[].department - The employee's department.
818
- */
819
- function assign (employees, name) {
820
-
821
- };
822
- // Message: Missing JSDoc @param "name" declaration.
823
-
824
- interface ITest {
825
- /**
826
- * Test description.
827
- */
828
- TestMethod(id: number): void;
829
- }
830
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSMethodSignature"]}]
831
- // Message: Missing JSDoc @param "id" declaration.
832
-
833
- /**
834
- * A test class.
835
- */
836
- abstract class TestClass
837
- {
838
- /**
839
- * A test method.
840
- */
841
- abstract TestFunction(id);
842
- }
843
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSEmptyBodyFunctionExpression"]}]
844
- // Message: Missing JSDoc @param "id" declaration.
845
-
846
- /**
847
- * A test class.
848
- */
849
- declare class TestClass
850
- {
851
- /**
852
- *
853
- */
854
- TestMethod(id);
855
- }
856
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSEmptyBodyFunctionExpression"]}]
857
- // Message: Missing JSDoc @param "id" declaration.
858
-
859
- /**
860
- * A test function.
861
- */
862
- declare let TestFunction: (id) => void;
863
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
864
- // Message: Missing JSDoc @param "id" declaration.
865
-
866
- /**
867
- * A test function.
868
- */
869
- let TestFunction: (id) => void;
870
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
871
- // Message: Missing JSDoc @param "id" declaration.
872
-
873
- /**
874
- * A test function.
875
- */
876
- function test(
877
- processor: (id: number) => string
878
- ) {
879
- return processor(10);
880
- }
881
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
882
- // Message: Missing JSDoc @param "id" declaration.
883
-
884
- /**
885
- * A test function.
886
- */
887
- let test = (processor: (id: number) => string) =>
888
- {
889
- return processor(10);
890
- }
891
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
892
- // Message: Missing JSDoc @param "id" declaration.
893
-
894
- class TestClass {
895
- /**
896
- * A class property.
897
- */
898
- public Test: (id: number) => string;
899
- }
900
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
901
- // Message: Missing JSDoc @param "id" declaration.
902
-
903
- class TestClass {
904
- /**
905
- * A class method.
906
- */
907
- public TestMethod(): (id: number) => string
908
- {
909
- }
910
- }
911
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
912
- // Message: Missing JSDoc @param "id" declaration.
913
-
914
- interface TestInterface {
915
- /**
916
- * An interface property.
917
- */
918
- Test: (id: number) => string;
919
- }
920
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
921
- // Message: Missing JSDoc @param "id" declaration.
922
-
923
- interface TestInterface {
924
- /**
925
- * An interface method.
926
- */
927
- TestMethod(): (id: number) => string;
928
- }
929
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
930
- // Message: Missing JSDoc @param "id" declaration.
931
-
932
- /**
933
- * A function with return type
934
- */
935
- function test(): (id: number) => string;
936
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
937
- // Message: Missing JSDoc @param "id" declaration.
938
-
939
- /**
940
- * A function with return type
941
- */
942
- let test = (): (id: number) => string =>
943
- {
944
- return (id) => `${id}`;
945
- }
946
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
947
- // Message: Missing JSDoc @param "id" declaration.
948
-
949
- /**
950
- * @param baz
951
- * @param options
952
- */
953
- function quux (baz, {foo: bar}) {
954
-
955
- }
956
- // Message: Missing JSDoc @param "options.foo" declaration.
957
-
958
- class Client {
959
- /**
960
- * Set collection data.
961
- * @param {Object} data The collection data object.
962
- * @param {number} data.last_modified
963
- * @param {Object} options The options object.
964
- * @param {Object} [options.headers] The headers object option.
965
- * @param {Number} [options.retry=0] Number of retries to make
966
- * when faced with transient errors.
967
- * @param {Boolean} [options.safe] The safe option.
968
- * @param {Boolean} [options.patch] The patch option.
969
- * @param {Number} [options.last_modified] The last_modified option.
970
- * @return {Promise<Object, Error>}
971
- */
972
- async setData(
973
- data: { last_modified?: number },
974
- options: {
975
- headers?: Record<string, string>;
976
- safe?: boolean;
977
- retry?: number;
978
- patch?: boolean;
979
- last_modified?: number;
980
- permissions?: [];
981
- } = {}
982
- ) {}
983
- }
984
- // Message: Missing JSDoc @param "options.permissions" declaration.
985
-
986
- /**
987
- *
988
- */
989
- function quux (foo) {
990
-
991
- }
992
- // "jsdoc/require-param": ["error"|"warn", {"enableFixer":false}]
993
- // Message: Missing JSDoc @param "foo" declaration.
994
-
995
- class Client {
996
- /**
997
- * Set collection data.
998
- * @return {Promise<Object, Error>}
999
- */
1000
- async setData(
1001
- data: { last_modified?: number }
1002
- ) {}
1003
- }
1004
- // Message: Missing JSDoc @param "data" declaration.
1005
-
1006
- /**
1007
- * @param cfg
1008
- * @param cfg.num
1009
- */
1010
- function quux ({num, ...extra}) {
1011
- }
1012
- // "jsdoc/require-param": ["error"|"warn", {"checkRestProperty":true}]
1013
- // Message: Missing JSDoc @param "cfg.extra" declaration.
1014
-
1015
- /**
1016
- * @param cfg
1017
- * @param cfg.opts
1018
- * @param cfg.opts.num
1019
- */
1020
- function quux ({opts: {num, ...extra}}) {
1021
- }
1022
- // "jsdoc/require-param": ["error"|"warn", {"checkRestProperty":true}]
1023
- // Message: Missing JSDoc @param "cfg.opts.extra" declaration.
1024
-
1025
- /**
1026
- * @param {GenericArray} cfg
1027
- * @param {number} cfg."0"
1028
- */
1029
- function baar ([a, ...extra]) {
1030
- //
1031
- }
1032
- // Message: Missing JSDoc @param "cfg."1"" declaration.
1033
-
1034
- /**
1035
- * @param a
1036
- */
1037
- function baar (a, ...extra) {
1038
- //
1039
- }
1040
- // Message: Missing JSDoc @param "extra" declaration.
1041
-
1042
- /**
1043
- * Converts an SVGRect into an object.
1044
- * @param {SVGRect} bbox - a SVGRect
1045
- */
1046
- const bboxToObj = function ({x, y, width, height}) {
1047
- return {x, y, width, height};
1048
- };
1049
- // "jsdoc/require-param": ["error"|"warn", {"checkTypesPattern":"SVGRect"}]
1050
- // Message: Missing JSDoc @param "bbox.x" declaration.
1051
-
1052
- /**
1053
- * Converts an SVGRect into an object.
1054
- * @param {object} bbox - a SVGRect
1055
- */
1056
- const bboxToObj = function ({x, y, width, height}) {
1057
- return {x, y, width, height};
1058
- };
1059
- // Message: Missing JSDoc @param "bbox.x" declaration.
1060
-
1061
- module.exports = class GraphQL {
1062
- /**
1063
- * @param fetchOptions
1064
- * @param cacheKey
1065
- */
1066
- fetch = ({ url, ...options }, cacheKey) => {
1067
- }
1068
- };
1069
- // "jsdoc/require-param": ["error"|"warn", {"checkRestProperty":true}]
1070
- // Message: Missing JSDoc @param "fetchOptions.url" declaration.
1071
-
1072
- (function() {
1073
- /**
1074
- * A function.
1075
- */
1076
- function f(param) {
1077
- return !param;
1078
- }
1079
- })();
1080
- // Message: Missing JSDoc @param "param" declaration.
1081
-
1082
- /**
1083
- * Description.
1084
- * @param {Object} options
1085
- * @param {Object} options.foo
1086
- */
1087
- function quux ({ foo: { bar } }) {}
1088
- // Message: Missing JSDoc @param "options.foo.bar" declaration.
1089
-
1090
- /**
1091
- * Description.
1092
- * @param {FooBar} options
1093
- * @param {FooBar} options.foo
1094
- */
1095
- function quux ({ foo: { bar } }) {}
1096
- // "jsdoc/require-param": ["error"|"warn", {"checkTypesPattern":"FooBar"}]
1097
- // Message: Missing JSDoc @param "options.foo.bar" declaration.
1098
-
1099
- /**
1100
- * Description.
1101
- * @param {Object} options
1102
- * @param {FooBar} foo
1103
- */
1104
- function quux ({ foo: { bar } }) {}
1105
- // Message: Missing JSDoc @param "options.foo" declaration.
1106
-
1107
- /**
1108
- * Description.
1109
- * @param {Object} options
1110
- * @param options.foo
1111
- */
1112
- function quux ({ foo: { bar } }) {}
1113
- // Message: Missing JSDoc @param "options.foo.bar" declaration.
1114
-
1115
- /**
1116
- * Description.
1117
- * @param {object} options Options.
1118
- * @param {object} options.foo A description.
1119
- * @param {object} options.foo.bar
1120
- */
1121
- function foo({ foo: { bar: { baz } }}) {}
1122
- // Message: Missing JSDoc @param "options.foo.bar.baz" declaration.
1123
-
1124
- /**
1125
- * Returns a number.
1126
- * @param {Object} props Props.
1127
- * @param {Object} props.prop Prop.
1128
- * @return {number} A number.
1129
- */
1130
- export function testFn1 ({ prop = { a: 1, b: 2 } }) {
1131
- }
1132
- // "jsdoc/require-param": ["error"|"warn", {"useDefaultObjectProperties":true}]
1133
- // Message: Missing JSDoc @param "props.prop.a" declaration.
1134
-
1135
- /** Foo. */
1136
- function foo(a, b, c) {}
1137
- // Message: Missing JSDoc @param "a" declaration.
1138
-
1139
- /**
1140
- * @param foo Some number.
1141
- * @param bar Some number.
1142
- */
1143
- export function myPublicFunction(foo: number, bar: number, baz: number) {}
1144
- // "jsdoc/require-param": ["error"|"warn", {"contexts":[{"comment":"JsdocBlock:has(JsdocTag[tag=\"param\"])","context":"FunctionDeclaration"}]}]
1145
- // Message: Missing JSDoc @param "baz" declaration.
1146
- ````
1147
-
1148
-
1149
-
1150
- <a name="user-content-require-param-passing-examples"></a>
1151
- <a name="require-param-passing-examples"></a>
1152
- ## Passing examples
1153
-
1154
- The following patterns are not considered problems:
1155
-
1156
- ````js
1157
- /**
1158
- * @param foo
1159
- */
1160
- function quux (foo) {
1161
-
1162
- }
1163
-
1164
- /**
1165
- * @param root0
1166
- * @param root0.foo
1167
- */
1168
- function quux ({foo}) {
1169
-
1170
- }
1171
-
1172
- /**
1173
- * @param root0
1174
- * @param root0.foo
1175
- * @param root1
1176
- * @param root1.bar
1177
- */
1178
- function quux ({foo}, {bar}) {
1179
-
1180
- }
1181
-
1182
- /**
1183
- * @param arg0
1184
- * @param arg0.foo
1185
- * @param arg1
1186
- * @param arg1.bar
1187
- */
1188
- function quux ({foo}, {bar}) {
1189
-
1190
- }
1191
- // "jsdoc/require-param": ["error"|"warn", {"unnamedRootBase":["arg"]}]
1192
-
1193
- /**
1194
- * @param arg
1195
- * @param arg.foo
1196
- * @param config0
1197
- * @param config0.bar
1198
- * @param config1
1199
- * @param config1.baz
1200
- */
1201
- function quux ({foo}, {bar}, {baz}) {
1202
-
1203
- }
1204
- // "jsdoc/require-param": ["error"|"warn", {"unnamedRootBase":["arg","config"]}]
1205
-
1206
- /**
1207
- * @inheritdoc
1208
- */
1209
- function quux (foo) {
1210
-
1211
- }
1212
-
1213
- /**
1214
- * @inheritDoc
1215
- */
1216
- function quux (foo) {
1217
-
1218
- }
1219
-
1220
- /**
1221
- * @arg foo
1222
- */
1223
- function quux (foo) {
1224
-
1225
- }
1226
- // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
1227
-
1228
- /**
1229
- * @override
1230
- * @param foo
1231
- */
1232
- function quux (foo) {
1233
-
1234
- }
1235
-
1236
- /**
1237
- * @override
1238
- */
1239
- function quux (foo) {
1240
-
1241
- }
1242
-
1243
- /**
1244
- * @override
1245
- */
1246
- class A {
1247
- /**
1248
- *
1249
- */
1250
- quux (foo) {
1251
-
1252
- }
1253
- }
1254
-
1255
- /**
1256
- * @override
1257
- */
1258
- function quux (foo) {
1259
-
1260
- }
1261
- // Settings: {"jsdoc":{"overrideReplacesDocs":true}}
1262
-
1263
- /**
1264
- * @ignore
1265
- */
1266
- function quux (foo) {
1267
-
1268
- }
1269
- // Settings: {"jsdoc":{"ignoreReplacesDocs":true}}
1270
-
1271
- /**
1272
- * @implements
1273
- */
1274
- class A {
1275
- /**
1276
- *
1277
- */
1278
- quux (foo) {
1279
-
1280
- }
1281
- }
1282
-
1283
- /**
1284
- * @implements
1285
- */
1286
- function quux (foo) {
1287
-
1288
- }
1289
-
1290
- /**
1291
- * @implements
1292
- */
1293
- function quux (foo) {
1294
-
1295
- }
1296
- // Settings: {"jsdoc":{"implementsReplacesDocs":true}}
1297
-
1298
- /**
1299
- * @implements
1300
- * @param foo
1301
- */
1302
- function quux (foo) {
1303
-
1304
- }
1305
-
1306
- /**
1307
- * @augments
1308
- */
1309
- function quux (foo) {
1310
-
1311
- }
1312
- // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
1313
-
1314
- /**
1315
- * @augments
1316
- * @param foo
1317
- */
1318
- function quux (foo) {
1319
-
1320
- }
1321
-
1322
- /**
1323
- * @extends
1324
- */
1325
- function quux (foo) {
1326
-
1327
- }
1328
- // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
1329
-
1330
- /**
1331
- * @extends
1332
- * @param foo
1333
- */
1334
- function quux (foo) {
1335
-
1336
- }
1337
-
1338
- /**
1339
- * @augments
1340
- */
1341
- function quux (foo) {
1342
-
1343
- }
1344
- // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
1345
-
1346
- /**
1347
- * @extends
1348
- */
1349
- function quux (foo) {
1350
-
1351
- }
1352
- // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
1353
-
1354
- /**
1355
- * @override
1356
- */
1357
- class A {
1358
- /**
1359
- * @param foo
1360
- */
1361
- quux (foo) {
1362
-
1363
- }
1364
- }
1365
-
1366
- /**
1367
- * @override
1368
- */
1369
- class A {
1370
- /**
1371
- *
1372
- */
1373
- quux (foo) {
1374
-
1375
- }
1376
- }
1377
- // Settings: {"jsdoc":{"overrideReplacesDocs":true}}
1378
-
1379
- /**
1380
- * @ignore
1381
- */
1382
- class A {
1383
- /**
1384
- *
1385
- */
1386
- quux (foo) {
1387
-
1388
- }
1389
- }
1390
- // Settings: {"jsdoc":{"ignoreReplacesDocs":true}}
1391
-
1392
- /**
1393
- * @implements
1394
- */
1395
- class A {
1396
- /**
1397
- *
1398
- */
1399
- quux (foo) {
1400
-
1401
- }
1402
- }
1403
- // Settings: {"jsdoc":{"implementsReplacesDocs":true}}
1404
-
1405
- /**
1406
- * @implements
1407
- */
1408
- class A {
1409
- /**
1410
- * @param foo
1411
- */
1412
- quux (foo) {
1413
-
1414
- }
1415
- }
1416
-
1417
- /**
1418
- * @augments
1419
- */
1420
- class A {
1421
- /**
1422
- *
1423
- */
1424
- quux (foo) {
1425
-
1426
- }
1427
- }
1428
- // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
1429
-
1430
- /**
1431
- * @augments
1432
- */
1433
- class A {
1434
- /**
1435
- * @param foo
1436
- */
1437
- quux (foo) {
1438
-
1439
- }
1440
- }
1441
-
1442
- /**
1443
- * @extends
1444
- */
1445
- class A {
1446
- /**
1447
- *
1448
- */
1449
- quux (foo) {
1450
-
1451
- }
1452
- }
1453
- // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
1454
-
1455
- /**
1456
- * @extends
1457
- */
1458
- class A {
1459
- /**
1460
- * @param foo
1461
- */
1462
- quux (foo) {
1463
-
1464
- }
1465
- }
1466
-
1467
- /**
1468
- * @augments
1469
- */
1470
- class A {
1471
- /**
1472
- *
1473
- */
1474
- quux (foo) {
1475
-
1476
- }
1477
- }
1478
- // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
1479
-
1480
- /**
1481
- * @extends
1482
- */
1483
- class A {
1484
- /**
1485
- *
1486
- */
1487
- quux (foo) {
1488
-
1489
- }
1490
- }
1491
- // Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
1492
-
1493
- /**
1494
- * @internal
1495
- */
1496
- function quux (foo) {
1497
-
1498
- }
1499
- // Settings: {"jsdoc":{"ignoreInternal":true}}
1500
-
1501
- /**
1502
- * @private
1503
- */
1504
- function quux (foo) {
1505
-
1506
- }
1507
- // Settings: {"jsdoc":{"ignorePrivate":true}}
1508
-
1509
- /**
1510
- * @access private
1511
- */
1512
- function quux (foo) {
1513
-
1514
- }
1515
- // Settings: {"jsdoc":{"ignorePrivate":true}}
1516
-
1517
- // issue 182: optional chaining
1518
- /** @const {boolean} test */
1519
- const test = something?.find(_ => _)
1520
-
1521
- /** @type {RequestHandler} */
1522
- function foo(req, res, next) {}
1523
-
1524
- /**
1525
- * @type {MyCallback}
1526
- */
1527
- function quux () {
1528
-
1529
- }
1530
- // "jsdoc/require-param": ["error"|"warn", {"exemptedBy":["type"]}]
1531
-
1532
- /**
1533
- * @override
1534
- */
1535
- var A = class {
1536
- /**
1537
- *
1538
- */
1539
- quux (foo) {
1540
-
1541
- }
1542
- }
1543
-
1544
- export class SomeClass {
1545
- /**
1546
- * @param property
1547
- */
1548
- constructor(private property: string) {}
1549
- }
1550
-
1551
- /**
1552
- * Assign the project to an employee.
1553
- *
1554
- * @param {object} employee - The employee who is responsible for the project.
1555
- * @param {string} employee.name - The name of the employee.
1556
- * @param {string} employee.department - The employee's department.
1557
- */
1558
- function assign({name, department}) {
1559
- // ...
1560
- }
1561
-
1562
- export abstract class StephanPlugin<O, D> {
1563
-
1564
- /**
1565
- * Called right after Stephan loads the plugin file.
1566
- *
1567
- * @example
1568
- *```typescript
1569
- * type Options = {
1570
- * verbose?: boolean;
1571
- * token?: string;
1572
- * }
1573
- * ```
1574
- *
1575
- * Note that your Options type should only have optional properties...
1576
- *
1577
- * @param args Arguments compiled and provided by StephanClient.
1578
- * @param args.options The options as provided by the user, or an empty object if not provided.
1579
- * @param args.client The options as provided by the user, or an empty object if not provided.
1580
- * @param defaultOptions The default options as provided by the plugin, or an empty object.
1581
- */
1582
- public constructor({options, client}: {
1583
- options: O;
1584
- client: unknown;
1585
- }, defaultOptions: D) {
1586
-
1587
- }
1588
- }
1589
-
1590
- /**
1591
- *
1592
- */
1593
- function quux (foo) {
1594
-
1595
- }
1596
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["ArrowFunctionExpression"]}]
1597
-
1598
- /**
1599
- * A function with return type
1600
- *
1601
- * @param id
1602
- */
1603
- let test = (): (id: number) => string =>
1604
- {
1605
- return (id) => `${id}`;
1606
- }
1607
- // "jsdoc/require-param": ["error"|"warn", {"contexts":["TSFunctionType"]}]
1608
-
1609
- /** @abstract */
1610
- class base {
1611
- /** @param {boolean} arg0 */
1612
- constructor(arg0) {}
1613
- }
1614
-
1615
- class foo extends base {
1616
- /** @inheritDoc */
1617
- constructor(arg0) {
1618
- super(arg0);
1619
- this.arg0 = arg0;
1620
- }
1621
- }
1622
- // Settings: {"jsdoc":{"mode":"closure"}}
1623
-
1624
- export abstract class StephanPlugin<O, D> {
1625
-
1626
- /**
1627
- * Called right after Stephan loads the plugin file.
1628
- *
1629
- * @example
1630
- *```typescript
1631
- * type Options = {
1632
- * verbose?: boolean;
1633
- * token?: string;
1634
- * }
1635
- * ```
1636
- *
1637
- * Note that your Options type should only have optional properties...
1638
- *
1639
- * @param args Arguments compiled and provided by StephanClient.
1640
- * @param args.options The options as provided by the user, or an empty object if not provided.
1641
- * @param args.client The options as provided by the user, or an empty object if not provided.
1642
- * @param args.client.name The name of the client.
1643
- * @param defaultOptions The default options as provided by the plugin, or an empty object.
1644
- */
1645
- public constructor({ options, client: { name } }: {
1646
- options: O;
1647
- client: { name: string };
1648
- }, defaultOptions: D) {
1649
-
1650
- }
1651
- }
1652
-
1653
- /**
1654
- * @param {string} cb
1655
- */
1656
- function createGetter (cb) {
1657
- return function (...args) {
1658
- cb();
1659
- };
1660
- }
1661
-
1662
- /**
1663
- * @param cfg
1664
- * @param cfg.num
1665
- */
1666
- function quux ({num, ...extra}) {
1667
- }
1668
-
1669
- /**
1670
- * @param {GenericArray} cfg
1671
- * @param {number} cfg."0"
1672
- */
1673
- function baar ([a, ...extra]) {
1674
- //
1675
- }
1676
- // "jsdoc/require-param": ["error"|"warn", {"enableRestElementFixer":false}]
1677
-
1678
- /**
1679
- * @param a
1680
- */
1681
- function baar (a, ...extra) {
1682
- //
1683
- }
1684
- // "jsdoc/require-param": ["error"|"warn", {"enableRestElementFixer":false}]
1685
-
1686
- /**
1687
- * Converts an SVGRect into an object.
1688
- * @param {SVGRect} bbox - a SVGRect
1689
- */
1690
- const bboxToObj = function ({x, y, width, height}) {
1691
- return {x, y, width, height};
1692
- };
1693
-
1694
- /**
1695
- * Converts an SVGRect into an object.
1696
- * @param {object} bbox - a SVGRect
1697
- */
1698
- const bboxToObj = function ({x, y, width, height}) {
1699
- return {x, y, width, height};
1700
- };
1701
- // "jsdoc/require-param": ["error"|"warn", {"checkTypesPattern":"SVGRect"}]
1702
-
1703
- class CSS {
1704
- /**
1705
- * Set one or more CSS properties for the set of matched elements.
1706
- *
1707
- * @param {Object} propertyObject - An object of property-value pairs to set.
1708
- */
1709
- setCssObject(propertyObject: {[key: string]: string | number}): void {
1710
- }
1711
- }
1712
-
1713
- /**
1714
- * @param foo
1715
- * @param bar
1716
- * @param cfg
1717
- */
1718
- function quux (foo, bar, {baz}) {
1719
-
1720
- }
1721
- // "jsdoc/require-param": ["error"|"warn", {"checkDestructured":false}]
1722
-
1723
- /**
1724
- * @param foo
1725
- * @param bar
1726
- */
1727
- function quux (foo, bar, {baz}) {
1728
-
1729
- }
1730
- // "jsdoc/require-param": ["error"|"warn", {"checkDestructuredRoots":false}]
1731
-
1732
- /**
1733
- * @param root
1734
- * @param root.foo
1735
- */
1736
- function quux ({"foo": bar}) {
1737
-
1738
- }
1739
-
1740
- /**
1741
- * @param root
1742
- * @param root."foo"
1743
- */
1744
- function quux ({foo: bar}) {
1745
-
1746
- }
1747
-
1748
- /**
1749
- * Description.
1750
- * @param {string} b Description `/**`.
1751
- */
1752
- module.exports = function a(b) {
1753
- console.info(b);
1754
- };
1755
-
1756
- /**
1757
- * Description.
1758
- * @param {Object} options Options.
1759
- * @param {FooBar} options.foo foo description.
1760
- */
1761
- function quux ({ foo: { bar } }) {}
1762
-
1763
- /**
1764
- * Description.
1765
- * @param {FooBar} options
1766
- * @param {Object} options.foo
1767
- */
1768
- function quux ({ foo: { bar } }) {}
1769
- // "jsdoc/require-param": ["error"|"warn", {"checkTypesPattern":"FooBar"}]
1770
-
1771
- /**
1772
- * @param obj
1773
- * @param obj.data
1774
- * @param obj.data."0"
1775
- * @param obj.data."1"
1776
- * @param obj.data."2"
1777
- * @param obj.defaulting
1778
- * @param obj.defaulting."0"
1779
- * @param obj.defaulting."1"
1780
- */
1781
- function Item({
1782
- data: [foo, bar, ...baz],
1783
- defaulting: [quux, xyz] = []
1784
- }) {
1785
- }
1786
-
1787
- /**
1788
- * Returns a number.
1789
- * @param {Object} props Props.
1790
- * @param {Object} props.prop Prop.
1791
- * @return {number} A number.
1792
- */
1793
- export function testFn1 ({ prop = { a: 1, b: 2 } }) {
1794
- }
1795
- // "jsdoc/require-param": ["error"|"warn", {"useDefaultObjectProperties":false}]
1796
-
1797
- /**
1798
- * @param this The this object
1799
- * @param bar number to return
1800
- * @returns number returned back to caller
1801
- */
1802
- function foo(this: T, bar: number): number {
1803
- console.log(this.name);
1804
- return bar;
1805
- }
1806
-
1807
- /**
1808
- * @param bar number to return
1809
- * @returns number returned back to caller
1810
- */
1811
- function foo(this: T, bar: number): number {
1812
- console.log(this.name);
1813
- return bar;
1814
- }
1815
-
1816
- /** {@link someOtherval} */
1817
- function a (b) {}
1818
- // "jsdoc/require-param": ["error"|"warn", {"contexts":[{"comment":"*:not(JsdocBlock:has(JsdocInlineTag[tag=link]))","context":"FunctionDeclaration"}]}]
1819
- ````
1820
-