eslint-plugin-jsdoc 44.2.2 → 44.2.4

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