eslint-plugin-jsdoc 44.2.3 → 44.2.5

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 (120) hide show
  1. package/dist/WarnSettings.js +0 -1
  2. package/dist/WarnSettings.js.map +1 -1
  3. package/dist/alignTransform.js +87 -5
  4. package/dist/alignTransform.js.map +1 -1
  5. package/dist/bin/generateRule.js +4 -3
  6. package/dist/bin/generateRule.js.map +1 -1
  7. package/dist/exportParser.js +272 -71
  8. package/dist/exportParser.js.map +1 -1
  9. package/dist/generateRule.js +4 -3
  10. package/dist/generateRule.js.map +1 -1
  11. package/dist/iterateJsdoc.js +921 -357
  12. package/dist/iterateJsdoc.js.map +1 -1
  13. package/dist/jsdocUtils.js +270 -168
  14. package/dist/jsdocUtils.js.map +1 -1
  15. package/dist/rules/checkAlignment.js +6 -0
  16. package/dist/rules/checkAlignment.js.map +1 -1
  17. package/dist/rules/checkExamples.js +73 -9
  18. package/dist/rules/checkExamples.js.map +1 -1
  19. package/dist/rules/checkIndentation.js +12 -2
  20. package/dist/rules/checkIndentation.js.map +1 -1
  21. package/dist/rules/checkLineAlignment.js +71 -7
  22. package/dist/rules/checkLineAlignment.js.map +1 -1
  23. package/dist/rules/checkParamNames.js +29 -11
  24. package/dist/rules/checkParamNames.js.map +1 -1
  25. package/dist/rules/checkPropertyNames.js +13 -7
  26. package/dist/rules/checkPropertyNames.js.map +1 -1
  27. package/dist/rules/checkTagNames.js +45 -9
  28. package/dist/rules/checkTagNames.js.map +1 -1
  29. package/dist/rules/checkTypes.js +98 -41
  30. package/dist/rules/checkTypes.js.map +1 -1
  31. package/dist/rules/checkValues.js +7 -7
  32. package/dist/rules/checkValues.js.map +1 -1
  33. package/dist/rules/emptyTags.js +8 -1
  34. package/dist/rules/emptyTags.js.map +1 -1
  35. package/dist/rules/informativeDocs.js +27 -8
  36. package/dist/rules/informativeDocs.js.map +1 -1
  37. package/dist/rules/matchDescription.js +18 -1
  38. package/dist/rules/matchDescription.js.map +1 -1
  39. package/dist/rules/matchName.js +2 -2
  40. package/dist/rules/matchName.js.map +1 -1
  41. package/dist/rules/multilineBlocks.js +12 -1
  42. package/dist/rules/multilineBlocks.js.map +1 -1
  43. package/dist/rules/noBadBlocks.js +4 -6
  44. package/dist/rules/noBadBlocks.js.map +1 -1
  45. package/dist/rules/noBlankBlockDescriptions.js +2 -0
  46. package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
  47. package/dist/rules/noMissingSyntax.js +53 -16
  48. package/dist/rules/noMissingSyntax.js.map +1 -1
  49. package/dist/rules/noMultiAsterisks.js +1 -6
  50. package/dist/rules/noMultiAsterisks.js.map +1 -1
  51. package/dist/rules/noRestrictedSyntax.js +12 -5
  52. package/dist/rules/noRestrictedSyntax.js.map +1 -1
  53. package/dist/rules/noTypes.js +3 -0
  54. package/dist/rules/noTypes.js.map +1 -1
  55. package/dist/rules/noUndefinedTypes.js +65 -27
  56. package/dist/rules/noUndefinedTypes.js.map +1 -1
  57. package/dist/rules/requireAsteriskPrefix.js +20 -0
  58. package/dist/rules/requireAsteriskPrefix.js.map +1 -1
  59. package/dist/rules/requireDescription.js +6 -2
  60. package/dist/rules/requireDescription.js.map +1 -1
  61. package/dist/rules/requireDescriptionCompleteSentence.js +75 -12
  62. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  63. package/dist/rules/requireFileOverview.js +9 -4
  64. package/dist/rules/requireFileOverview.js.map +1 -1
  65. package/dist/rules/requireHyphenBeforeParamDescription.js +21 -7
  66. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  67. package/dist/rules/requireJsdoc.js +150 -29
  68. package/dist/rules/requireJsdoc.js.map +1 -1
  69. package/dist/rules/requireParam.js +116 -10
  70. package/dist/rules/requireParam.js.map +1 -1
  71. package/dist/rules/requireProperty.js +1 -1
  72. package/dist/rules/requireProperty.js.map +1 -1
  73. package/dist/rules/requireReturns.js +2 -3
  74. package/dist/rules/requireReturns.js.map +1 -1
  75. package/dist/rules/requireReturnsCheck.js +9 -2
  76. package/dist/rules/requireReturnsCheck.js.map +1 -1
  77. package/dist/rules/requireThrows.js +2 -3
  78. package/dist/rules/requireThrows.js.map +1 -1
  79. package/dist/rules/requireYields.js +9 -3
  80. package/dist/rules/requireYields.js.map +1 -1
  81. package/dist/rules/requireYieldsCheck.js +19 -5
  82. package/dist/rules/requireYieldsCheck.js.map +1 -1
  83. package/dist/rules/sortTags.js +67 -9
  84. package/dist/rules/sortTags.js.map +1 -1
  85. package/dist/rules/tagLines.js +22 -3
  86. package/dist/rules/tagLines.js.map +1 -1
  87. package/dist/rules/textEscaping.js +18 -4
  88. package/dist/rules/textEscaping.js.map +1 -1
  89. package/dist/rules/validTypes.js +26 -9
  90. package/dist/rules/validTypes.js.map +1 -1
  91. package/dist/tagNames.js +0 -2
  92. package/dist/tagNames.js.map +1 -1
  93. package/dist/utils/hasReturnValue.js +77 -48
  94. package/dist/utils/hasReturnValue.js.map +1 -1
  95. package/docs/rules/check-line-alignment.md +7 -0
  96. package/docs/rules/check-tag-names.md +15 -0
  97. package/docs/rules/no-missing-syntax.md +6 -0
  98. package/docs/rules/no-undefined-types.md +6 -0
  99. package/docs/rules/require-description-complete-sentence.md +525 -289
  100. package/docs/rules/require-description.md +289 -525
  101. package/docs/rules/require-file-overview.md +7 -0
  102. package/docs/rules/require-jsdoc.md +1 -1
  103. package/docs/rules/require-param-description.md +116 -1694
  104. package/docs/rules/require-param-name.md +58 -133
  105. package/docs/rules/require-param-type.md +119 -55
  106. package/docs/rules/require-param.md +1704 -111
  107. package/docs/rules/require-property-description.md +39 -79
  108. package/docs/rules/require-property-name.md +21 -30
  109. package/docs/rules/require-property-type.md +21 -21
  110. package/docs/rules/require-property.md +82 -33
  111. package/docs/rules/require-returns-check.md +636 -747
  112. package/docs/rules/require-returns-description.md +61 -933
  113. package/docs/rules/require-returns-type.md +42 -79
  114. package/docs/rules/require-returns.md +1081 -61
  115. package/docs/rules/require-yields-check.md +238 -517
  116. package/docs/rules/require-yields.md +517 -238
  117. package/docs/rules/valid-types.md +1 -1
  118. package/docs/settings.md +3 -1
  119. package/package.json +10 -9
  120. package/tsconfig.json +2 -3
@@ -1,227 +1,1820 @@
1
- <a name="user-content-require-param-type"></a>
2
- <a name="require-param-type"></a>
3
- # <code>require-param-type</code>
1
+ <a name="user-content-require-param"></a>
2
+ <a name="require-param"></a>
3
+ # <code>require-param</code>
4
4
 
5
- * [Options](#user-content-require-param-type-options)
6
- * [`setDefaultDestructuredRootType`](#user-content-require-param-type-options-setdefaultdestructuredroottype)
7
- * [`defaultDestructuredRootType`](#user-content-require-param-type-options-defaultdestructuredroottype)
8
- * [`contexts`](#user-content-require-param-type-options-contexts)
9
- * [Context and settings](#user-content-require-param-type-context-and-settings)
10
- * [Failing examples](#user-content-require-param-type-failing-examples)
11
- * [Passing examples](#user-content-require-param-type-passing-examples)
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)
12
29
 
13
30
 
14
- Requires that each `@param` tag has a `type` value (within curly brackets).
31
+ Requires that all function parameters are documented.
15
32
 
16
- Will exempt destructured roots and their children if
17
- `settings.exemptDestructuredRootsFromChecks` is set to `true` (e.g.,
18
- `@param props` will be exempted from requiring a type given
19
- `function someFunc ({child1, child2})`).
33
+ <a name="user-content-require-param-fixer"></a>
34
+ <a name="require-param-fixer"></a>
35
+ ## Fixer
20
36
 
21
- <a name="user-content-require-param-type-options"></a>
22
- <a name="require-param-type-options"></a>
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>
23
221
  ## Options
24
222
 
25
- <a name="user-content-require-param-type-options-setdefaultdestructuredroottype"></a>
26
- <a name="require-param-type-options-setdefaultdestructuredroottype"></a>
27
- ### <code>setDefaultDestructuredRootType</code>
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>
28
228
 
29
- Whether to set a default destructured root type. For example, you may wish
30
- to avoid manually having to set the type for a `@param`
31
- corresponding to a destructured root object as it is always going to be an
32
- object. Uses `defaultDestructuredRootType` for the type string. Defaults to
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
33
237
  `false`.
34
238
 
35
- <a name="user-content-require-param-type-options-defaultdestructuredroottype"></a>
36
- <a name="require-param-type-options-defaultdestructuredroottype"></a>
37
- ### <code>defaultDestructuredRootType</code>
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
+ ```
38
362
 
39
- The type string to set by default for destructured roots. Defaults to "object".
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.
40
371
 
41
- <a name="user-content-require-param-type-options-contexts"></a>
42
- <a name="require-param-type-options-contexts"></a>
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>
43
383
  ### <code>contexts</code>
44
384
 
45
385
  Set this to an array of strings representing the AST context (or an object with
46
386
  `context` and `comment` properties) where you wish the rule to be applied.
47
- Overrides the default contexts (see below). Set to `"any"` if you want
48
- the rule to apply to any jsdoc block throughout your files (as is necessary
49
- for finding function blocks not attached to a function declaration or
50
- expression, i.e., `@callback` or `@function` (or its aliases `@func` or
51
- `@method`) (including those associated with an `@interface`).
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.
52
390
 
53
391
  See the ["AST and Selectors"](#user-content-eslint-plugin-jsdoc-advanced-ast-and-selectors)
54
392
  section of our README for more on the expected format.
55
393
 
56
- <a name="user-content-require-param-type-context-and-settings"></a>
57
- <a name="require-param-type-context-and-settings"></a>
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>
58
442
  ## Context and settings
59
443
 
60
- |||
61
- |---|---|
62
- |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
63
- |Tags|`param`|
64
- |Aliases|`arg`, `argument`|
65
- |Recommended|true|
66
- |Options|`setDefaultDestructuredRootType`, `defaultDestructuredRootType`, `contexts`|
67
- |Settings|`exemptDestructuredRootsFromChecks`|
68
-
69
- <a name="user-content-require-param-type-failing-examples"></a>
70
- <a name="require-param-type-failing-examples"></a>
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`, `checkDestructured`, `checkDestructuredRoots`, `contexts`, `enableFixer`, `enableRootFixer`, `enableRestElementFixer`, `checkRestProperty`, `exemptedBy`, `checkConstructors`, `checkGetters`, `checkSetters`, `checkTypesPattern`, `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>
71
455
  ## Failing examples
72
456
 
73
457
  The following patterns are considered problems:
74
458
 
75
459
  ````js
76
460
  /**
77
- * @param foo
461
+ *
78
462
  */
79
463
  function quux (foo) {
80
464
 
81
465
  }
82
- // Message: Missing JSDoc @param "foo" type.
466
+ // Message: Missing JSDoc @param "foo" declaration.
83
467
 
84
468
  /**
85
- * @param {a xxx
469
+ *
86
470
  */
87
- function quux () {
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
+
88
482
  }
89
- // Message: Missing JSDoc @param "" type.
483
+ // Message: Missing JSDoc @param "root0" declaration.
90
484
 
91
485
  /**
92
486
  * @param foo
93
487
  */
94
- function quux (foo) {
488
+ function quux (foo, bar, {baz}) {
95
489
 
96
490
  }
97
- // "jsdoc/require-param-type": ["error"|"warn", {"contexts":["any"]}]
98
- // Message: Missing JSDoc @param "foo" type.
491
+ // "jsdoc/require-param": ["error"|"warn", {"checkDestructured":false}]
492
+ // Message: Missing JSDoc @param "bar" declaration.
99
493
 
100
494
  /**
101
- * @function
102
495
  * @param foo
103
496
  */
104
- // "jsdoc/require-param-type": ["error"|"warn", {"contexts":["any"]}]
105
- // Message: Missing JSDoc @param "foo" type.
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.
106
587
 
107
588
  /**
108
- * @callback
109
589
  * @param foo
110
590
  */
111
- // "jsdoc/require-param-type": ["error"|"warn", {"contexts":["any"]}]
112
- // Message: Missing JSDoc @param "foo" type.
591
+ function quux (foo, bar) {
592
+
593
+ }
594
+ // Message: Missing JSDoc @param "bar" declaration.
113
595
 
114
596
  /**
115
- * @arg foo
597
+ * @param bar
116
598
  */
117
- function quux (foo) {
599
+ function quux (foo, bar, baz) {
118
600
 
119
601
  }
120
- // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
121
- // Message: Missing JSDoc @arg "foo" type.
602
+ // Message: Missing JSDoc @param "foo" declaration.
122
603
 
123
604
  /**
124
605
  * @param foo
606
+ * @param bar
125
607
  */
126
- function quux (foo) {
608
+ function quux (foo, bar, baz) {
127
609
 
128
610
  }
129
- // Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
130
- // Message: Unexpected tag `@param`
611
+ // Message: Missing JSDoc @param "baz" declaration.
131
612
 
132
613
  /**
133
- * @param {number} foo
134
- * @param root
135
- * @param {boolean} baz
614
+ * @param baz
136
615
  */
137
- function quux (foo, {bar}, baz) {
616
+ function quux (foo, bar, baz) {
138
617
 
139
618
  }
140
- // "jsdoc/require-param-type": ["error"|"warn", {"setDefaultDestructuredRootType":true}]
141
- // Message: Missing root type for @param.
619
+ // Message: Missing JSDoc @param "foo" declaration.
142
620
 
143
621
  /**
144
- * @param {number} foo
145
- * @param root
146
- * @param {boolean} baz
622
+ * @param
147
623
  */
148
- function quux (foo, {bar}, baz) {
624
+ function quux (foo) {
149
625
 
150
626
  }
151
- // "jsdoc/require-param-type": ["error"|"warn", {"defaultDestructuredRootType":"Object","setDefaultDestructuredRootType":true}]
152
- // Message: Missing root type for @param.
627
+ // Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
628
+ // Message: Missing JSDoc @arg "foo" declaration.
153
629
 
154
630
  /**
155
- * @param {number} foo
156
- * @param root
157
- * @param {boolean} baz
631
+ * @param foo
158
632
  */
159
- function quux (foo, {bar}, baz) {
633
+ function quux (foo, bar) {
160
634
 
161
635
  }
162
- // "jsdoc/require-param-type": ["error"|"warn", {"setDefaultDestructuredRootType":false}]
163
- // Message: Missing JSDoc @param "root" type.
164
- ````
636
+ // Message: Missing JSDoc @param "bar" declaration.
165
637
 
638
+ /**
639
+ * @override
640
+ */
641
+ function quux (foo) {
166
642
 
643
+ }
644
+ // Settings: {"jsdoc":{"overrideReplacesDocs":false}}
645
+ // Message: Missing JSDoc @param "foo" declaration.
167
646
 
168
- <a name="user-content-require-param-type-passing-examples"></a>
169
- <a name="require-param-type-passing-examples"></a>
170
- ## Passing examples
647
+ /**
648
+ * @ignore
649
+ */
650
+ function quux (foo) {
171
651
 
172
- The following patterns are not considered problems:
652
+ }
653
+ // Settings: {"jsdoc":{"ignoreReplacesDocs":false}}
654
+ // Message: Missing JSDoc @param "foo" declaration.
173
655
 
174
- ````js
175
656
  /**
176
- *
657
+ * @implements
177
658
  */
178
659
  function quux (foo) {
179
660
 
180
661
  }
662
+ // Settings: {"jsdoc":{"implementsReplacesDocs":false}}
663
+ // Message: Missing JSDoc @param "foo" declaration.
181
664
 
182
665
  /**
183
- * @param {number} foo
666
+ * @augments
184
667
  */
185
668
  function quux (foo) {
186
669
 
187
670
  }
671
+ // Message: Missing JSDoc @param "foo" declaration.
188
672
 
189
673
  /**
190
- * @param {number} foo
674
+ * @extends
191
675
  */
192
676
  function quux (foo) {
193
677
 
194
678
  }
195
- // "jsdoc/require-param-type": ["error"|"warn", {"contexts":["any"]}]
679
+ // Message: Missing JSDoc @param "foo" declaration.
196
680
 
197
681
  /**
198
- * @function
199
- * @param foo
682
+ * @override
200
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.
201
694
 
202
695
  /**
203
- * @callback
204
- * @param foo
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
205
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.
206
722
 
207
723
  /**
208
- * @param {number} foo
209
- * @param root
210
- * @param {boolean} baz
724
+ * @augments
211
725
  */
212
- function quux (foo, {bar}, baz) {
726
+ class A {
727
+ /**
728
+ *
729
+ */
730
+ quux (foo) {
213
731
 
732
+ }
214
733
  }
215
- // Settings: {"jsdoc":{"exemptDestructuredRootsFromChecks":true}}
734
+ // Message: Missing JSDoc @param "foo" declaration.
216
735
 
217
736
  /**
218
- * @param {number} foo
219
- * @param root
220
- * @param root.bar
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
+ *
221
768
  */
222
- function quux (foo, {bar: {baz}}) {
769
+ function quux ({bar, baz}, foo) {
770
+ }
771
+ // Message: Missing JSDoc @param "root0" declaration.
223
772
 
773
+ /**
774
+ *
775
+ */
776
+ function quux (foo, {bar, baz}) {
224
777
  }
225
- // Settings: {"jsdoc":{"exemptDestructuredRootsFromChecks":true}}
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
+ public 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
+ public 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"}]}]
226
1819
  ````
227
1820