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,64 +1,51 @@
1
- <a name="user-content-require-returns-check"></a>
2
- <a name="require-returns-check"></a>
3
- # <code>require-returns-check</code>
1
+ <a name="user-content-require-returns-description"></a>
2
+ <a name="require-returns-description"></a>
3
+ # <code>require-returns-description</code>
4
4
 
5
- * [Options](#user-content-require-returns-check-options)
6
- * [Context and settings](#user-content-require-returns-check-context-and-settings)
7
- * [Failing examples](#user-content-require-returns-check-failing-examples)
8
- * [Passing examples](#user-content-require-returns-check-passing-examples)
5
+ * [Options](#user-content-require-returns-description-options)
6
+ * [`contexts`](#user-content-require-returns-description-options-contexts)
7
+ * [Context and settings](#user-content-require-returns-description-context-and-settings)
8
+ * [Failing examples](#user-content-require-returns-description-failing-examples)
9
+ * [Passing examples](#user-content-require-returns-description-passing-examples)
9
10
 
10
11
 
11
- Requires a return statement (or non-`undefined` Promise resolve value)
12
- be present in a
13
- function body if a `@returns` tag (without a `void` or `undefined` type)
14
- is specified in the function's JSDoc comment block.
12
+ Requires that the `@returns` tag has a `description` value. The error
13
+ will not be reported if the return value is `void` or `undefined`
14
+ or if it is `Promise<void>` or `Promise<undefined>`.
15
15
 
16
- Will also report `@returns {void}` and `@returns {undefined}` if `exemptAsync`
17
- is set to `false` and a non-`undefined` value is returned or a resolved value
18
- is found. Also reports if `@returns {never}` is discovered with a return value.
16
+ <a name="user-content-require-returns-description-options"></a>
17
+ <a name="require-returns-description-options"></a>
18
+ ## Options
19
19
 
20
- Will also report if multiple `@returns` tags are present.
20
+ <a name="user-content-require-returns-description-options-contexts"></a>
21
+ <a name="require-returns-description-options-contexts"></a>
22
+ ### <code>contexts</code>
21
23
 
22
- <a name="user-content-require-returns-check-options"></a>
23
- <a name="require-returns-check-options"></a>
24
- ## Options
24
+ Set this to an array of strings representing the AST context (or an object with
25
+ `context` and `comment` properties) where you wish the rule to be applied.
26
+ Overrides the default contexts (see below). Set to `"any"` if you want
27
+ the rule to apply to any jsdoc block throughout your files (as is necessary
28
+ for finding function blocks not attached to a function declaration or
29
+ expression, i.e., `@callback` or `@function` (or its aliases `@func` or
30
+ `@method`) (including those associated with an `@interface`).
25
31
 
26
- - `exemptGenerators`- Because a generator might be labeled as having a
27
- `IterableIterator` `@returns` value (along with an iterator type
28
- corresponding to the type of any `yield` statements), projects might wish to
29
- leverage `@returns` in generators even without a` return` statement. This
30
- option is therefore `true` by default in `typescript` mode (in "jsdoc" mode,
31
- one might be more likely to take advantage of `@yields`). Set it to `false`
32
- if you wish for a missing `return` to be flagged regardless.
33
- - `exemptAsync` - By default, functions which return a `Promise` that are not
34
- detected as resolving with a non-`undefined` value and `async` functions
35
- (even ones that do not explicitly return a value, as these are returning a
36
- `Promise` implicitly) will be exempted from reporting by this rule.
37
- If you wish to insist that only `Promise`'s which resolve to
38
- non-`undefined` values or `async` functions with explicit `return`'s will
39
- be exempted from reporting (i.e., that `async` functions can be reported
40
- if they lack an explicit (non-`undefined`) `return` when a `@returns` is
41
- present), you can set `exemptAsync` to `false` on the options object.
42
- - `reportMissingReturnForUndefinedTypes` - If `true` and no return or
43
- resolve value is found, this setting will even insist that reporting occur
44
- with `void` or `undefined` (including as an indicated `Promise` type).
45
- Unlike `require-returns`, with this option in the rule, one can
46
- *discourage* the labeling of `undefined` types. Defaults to `false`.
32
+ See the ["AST and Selectors"](#user-content-eslint-plugin-jsdoc-advanced-ast-and-selectors)
33
+ section of our README for more on the expected format.
47
34
 
48
- <a name="user-content-require-returns-check-context-and-settings"></a>
49
- <a name="require-returns-check-context-and-settings"></a>
35
+ <a name="user-content-require-returns-description-context-and-settings"></a>
36
+ <a name="require-returns-description-context-and-settings"></a>
50
37
  ## Context and settings
51
38
 
52
39
  |||
53
40
  |---|---|
54
- |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
41
+ |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
55
42
  |Tags|`returns`|
56
43
  |Aliases|`return`|
57
- |Options|`exemptAsync`, `reportMissingReturnForUndefinedTypes`|
58
44
  |Recommended|true|
45
+ |Options|`contexts`|
59
46
 
60
- <a name="user-content-require-returns-check-failing-examples"></a>
61
- <a name="require-returns-check-failing-examples"></a>
47
+ <a name="user-content-require-returns-description-failing-examples"></a>
48
+ <a name="require-returns-description-failing-examples"></a>
62
49
  ## Failing examples
63
50
 
64
51
  The following patterns are considered problems:
@@ -70,984 +57,125 @@ The following patterns are considered problems:
70
57
  function quux (foo) {
71
58
 
72
59
  }
73
- // Message: JSDoc @returns declaration present but return expression not available in function.
60
+ // Message: Missing JSDoc @returns description.
74
61
 
75
62
  /**
76
- * @return
63
+ * @returns {string}
77
64
  */
78
65
  function quux (foo) {
79
66
 
80
67
  }
81
- // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
82
- // Message: JSDoc @return declaration present but return expression not available in function.
83
-
84
- /**
85
- * @returns
86
- */
87
- const quux = () => {}
88
- // Message: JSDoc @returns declaration present but return expression not available in function.
89
-
90
- /**
91
- * @returns {undefined} Foo.
92
- * @returns {String} Foo.
93
- */
94
- function quux () {
95
-
96
- return foo;
97
- }
98
- // Message: Found more than one @returns declaration.
99
-
100
- const language = {
101
- /**
102
- * @param {string} name
103
- * @returns {string}
104
- */
105
- get name() {
106
- this._name = name;
107
- }
108
- }
109
- // Message: JSDoc @returns declaration present but return expression not available in function.
110
-
111
- class Foo {
112
- /**
113
- * @returns {string}
114
- */
115
- bar () {
116
- }
117
- }
118
- // Message: JSDoc @returns declaration present but return expression not available in function.
119
-
120
- /**
121
- * @returns
122
- */
123
- function quux () {
124
-
125
- }
126
- // Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
127
- // Message: Unexpected tag `@returns`
68
+ // Message: Missing JSDoc @returns description.
128
69
 
129
70
  /**
130
71
  * @returns {string}
131
72
  */
132
- function f () {
133
- function g() {
134
- return 'foo'
135
- }
136
-
137
- () => {
138
- return 5
139
- }
140
- }
141
- // Message: JSDoc @returns declaration present but return expression not available in function.
142
-
143
- /**
144
- * @returns {Promise<void>}
145
- */
146
- async function quux() {}
147
- // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
148
- // Message: JSDoc @returns declaration present but return expression not available in function.
149
-
150
- /**
151
- * @returns {IterableIterator<any>}
152
- */
153
- function * quux() {}
154
- // Settings: {"jsdoc":{"mode":"jsdoc"}}
155
- // Message: JSDoc @returns declaration present but return expression not available in function.
156
-
157
- /**
158
- * @returns {IterableIterator<any>}
159
- */
160
- function * quux() {}
161
- // Settings: {"jsdoc":{"mode":"typescript"}}
162
- // "jsdoc/require-returns-check": ["error"|"warn", {"exemptGenerators":false}]
163
- // Message: JSDoc @returns declaration present but return expression not available in function.
164
-
165
- /**
166
- * @returns {Promise<void>}
167
- */
168
- function quux() {
169
- return new Promise((resolve, reject) => {})
170
- }
171
- // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
172
- // Message: JSDoc @returns declaration present but return expression not available in function.
73
+ function quux (foo) {
173
74
 
174
- /**
175
- * @returns {Promise<void>}
176
- */
177
- function quux() {
178
- return new Promise((resolve, reject) => {
179
- setTimeout(() => {
180
- resolve();
181
- });
182
- })
183
75
  }
184
- // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
185
- // Message: JSDoc @returns declaration present but return expression not available in function.
76
+ // "jsdoc/require-returns-description": ["error"|"warn", {"contexts":["any"]}]
77
+ // Message: Missing JSDoc @returns description.
186
78
 
187
79
  /**
188
- * Description.
80
+ * @function
189
81
  * @returns {string}
190
82
  */
191
- async function foo() {
192
- return new Promise(resolve => resolve());
193
- }
194
- // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
195
- // Message: JSDoc @returns declaration present but return expression not available in function.
83
+ // "jsdoc/require-returns-description": ["error"|"warn", {"contexts":["any"]}]
84
+ // Message: Missing JSDoc @returns description.
196
85
 
197
86
  /**
198
- * Description.
199
- * @returns {void}
200
- */
201
- async function foo() {
202
- return new Promise(resolve => resolve());
203
- }
204
- // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false,"reportMissingReturnForUndefinedTypes":true}]
205
- // Message: JSDoc @returns declaration present but return expression not available in function.
206
-
207
- /**
208
- * @returns { void } Foo.
209
- */
210
- function quux () {}
211
- // "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
212
- // Message: JSDoc @returns declaration present but return expression not available in function.
213
-
214
- /**
215
- * @returns {never} Foo.
87
+ * @callback
88
+ * @returns {string}
216
89
  */
217
- function quux () {
218
- return undefined;
219
- }
220
- // Message: JSDoc @returns declaration set with "never" but return expression is present in function.
90
+ // "jsdoc/require-returns-description": ["error"|"warn", {"contexts":["any"]}]
91
+ // Message: Missing JSDoc @returns description.
221
92
 
222
93
  /**
223
- * @returns {never}
94
+ * @return
224
95
  */
225
96
  function quux (foo) {
226
- return foo;
227
- }
228
- // Message: JSDoc @returns declaration set with "never" but return expression is present in function.
229
-
230
- /**
231
- * Reads a test fixture.
232
- *
233
- * @param path The path to resolve relative to the fixture base. It will be normalized for the
234
- * operating system.
235
- *
236
- * @returns The file contents as buffer.
237
- */
238
- export function readFixture(path: string): void;
239
- // Message: JSDoc @returns declaration present but return expression not available in function.
240
97
 
241
- /**
242
- * Reads a test fixture.
243
- *
244
- * @param path The path to resolve relative to the fixture base. It will be normalized for the
245
- * operating system.
246
- *
247
- * @returns The file contents as buffer.
248
- */
249
- export function readFixture(path: string);
250
- // Message: JSDoc @returns declaration present but return expression not available in function.
251
-
252
- /**
253
- * @returns {SomeType}
254
- */
255
- function quux (path) {
256
- if (true) {
257
- return;
258
- }
259
- return 15;
260
- };
261
- // Message: JSDoc @returns declaration present but return expression not available in function.
262
-
263
- /**
264
- * Reads a test fixture.
265
- *
266
- * @param path The path to resolve relative to the fixture base. It will be normalized for the
267
- * operating system.
268
- *
269
- * @returns The file contents as buffer.
270
- */
271
- export function readFixture(path: string): void {
272
- return;
273
- };
274
- // Message: JSDoc @returns declaration present but return expression not available in function.
275
-
276
- /**
277
- * @returns {true}
278
- */
279
- function quux () {
280
- if (true) {
281
- return true;
282
- }
283
- }
284
- // Message: JSDoc @returns declaration present but return expression not available in function.
285
-
286
- /**
287
- * @returns {true}
288
- */
289
- function quux () {
290
- if (true) {
291
- } else {
292
- return;
293
- }
294
- }
295
- // Message: JSDoc @returns declaration present but return expression not available in function.
296
-
297
- /**
298
- * @returns {true}
299
- */
300
- function quux (someVar) {
301
- switch (someVar) {
302
- case 1:
303
- return true;
304
- case 2:
305
- return;
306
- }
307
98
  }
308
- // Message: JSDoc @returns declaration present but return expression not available in function.
309
-
310
- /**
311
- * @returns {boolean}
312
- */
313
- const quux = (someVar) => {
314
- if (someVar) {
315
- return true;
316
- }
317
- };
318
- // Message: JSDoc @returns declaration present but return expression not available in function.
319
-
320
- /**
321
- * @returns {true}
322
- */
323
- function quux () {
324
- try {
325
- return true;
326
- } catch (error) {
327
- }
328
- }
329
- // Message: JSDoc @returns declaration present but return expression not available in function.
330
-
331
- /**
332
- * @returns {true}
333
- */
334
- function quux () {
335
- try {
336
- return true;
337
- } catch (error) {
338
- return true;
339
- } finally {
340
- return;
341
- }
342
- }
343
- // Message: JSDoc @returns declaration present but return expression not available in function.
99
+ // Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
100
+ // Message: Missing JSDoc @return description.
344
101
 
345
102
  /**
346
- * @returns {true}
103
+ * @returns
347
104
  */
348
105
  function quux () {
349
- if (true) {
350
- throw new Error('abc');
351
- }
352
106
 
353
- throw new Error('def');
354
107
  }
355
- // Message: JSDoc @returns declaration present but return expression not available in function.
356
-
357
- /**
358
- * @returns {SomeType} Baz.
359
- */
360
- function foo() {
361
- switch (true) {
362
- default:
363
- switch (false) {
364
- default: return;
365
- }
366
- return "baz";
367
- }
368
- };
369
- // Message: JSDoc @returns declaration present but return expression not available in function.
370
-
371
- /**
372
- * @returns {SomeType} Baz.
373
- */
374
- function foo() {
375
- switch (true) {
376
- default:
377
- switch (false) {
378
- default: return;
379
- }
380
- return "baz";
381
- }
382
- };
383
- // Message: JSDoc @returns declaration present but return expression not available in function.
384
-
385
- /**
386
- * @returns {number}
387
- */
388
- function foo() {
389
- let n = 1;
390
- while (n > 0.5) {
391
- n = Math.random();
392
- if (n < 0.2) {
393
- return n;
394
- }
395
- }
396
- }
397
- // Message: JSDoc @returns declaration present but return expression not available in function.
108
+ // Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
109
+ // Message: Unexpected tag `@returns`
398
110
  ````
399
111
 
400
112
 
401
113
 
402
- <a name="user-content-require-returns-check-passing-examples"></a>
403
- <a name="require-returns-check-passing-examples"></a>
114
+ <a name="user-content-require-returns-description-passing-examples"></a>
115
+ <a name="require-returns-description-passing-examples"></a>
404
116
  ## Passing examples
405
117
 
406
118
  The following patterns are not considered problems:
407
119
 
408
120
  ````js
409
- /**
410
- * @returns Foo.
411
- */
412
- function quux () {
413
-
414
- return foo;
415
- }
416
-
417
- /**
418
- * @returns {string} Foo.
419
- */
420
- function quux () {
421
-
422
- return foo;
423
- }
424
-
425
- /**
426
- * @returns {string} Foo.
427
- */
428
- function quux () {
429
-
430
- return foo;
431
- }
432
-
433
121
  /**
434
122
  *
435
123
  */
436
124
  function quux () {
437
- }
438
-
439
- /**
440
- * @returns {SomeType} Foo.
441
- */
442
- const quux = () => foo;
443
-
444
- /**
445
- * @returns {undefined} Foo.
446
- */
447
- function quux () {}
448
125
 
449
- /**
450
- * @returns { void } Foo.
451
- */
452
- function quux () {}
453
-
454
- /**
455
- * @returns {Promise<void>}
456
- */
457
- async function quux() {}
458
-
459
- /**
460
- * @returns {Promise<void>}
461
- */
462
- const quux = async function () {}
463
-
464
- /**
465
- * @returns {Promise<void>}
466
- */
467
- const quux = async () => {}
468
-
469
- /**
470
- * @returns Foo.
471
- * @abstract
472
- */
473
- function quux () {
474
- throw new Error('must be implemented by subclass!');
475
- }
476
-
477
- /**
478
- * @returns Foo.
479
- * @virtual
480
- */
481
- function quux () {
482
- throw new Error('must be implemented by subclass!');
483
126
  }
484
127
 
485
128
  /**
486
129
  * @returns Foo.
487
- * @constructor
488
130
  */
489
131
  function quux () {
490
- }
491
-
492
- /**
493
- * @interface
494
- */
495
- class Foo {
496
- /**
497
- * @returns {string}
498
- */
499
- bar () {
500
- }
501
- }
502
-
503
- /**
504
- * @record
505
- */
506
- class Foo {
507
- /**
508
- * @returns {string}
509
- */
510
- bar () {
511
- }
512
- }
513
- // Settings: {"jsdoc":{"mode":"closure"}}
514
-
515
- /**
516
- * @returns {undefined} Foo.
517
- */
518
- function quux () {
519
- }
520
-
521
- /**
522
- * @returns {void} Foo.
523
- */
524
- function quux () {
525
- }
526
132
 
527
- /**
528
- * @returns {void} Foo.
529
- */
530
- function quux () {
531
- return undefined;
532
133
  }
533
134
 
534
135
  /**
535
- * @returns {never} Foo.
536
- */
537
- function quux () {
538
- }
539
-
540
- /**
541
- * @returns {void} Foo.
542
- */
543
- function quux () {
544
- return;
545
- }
546
-
547
- /**
548
- *
549
- */
550
- function quux () {
551
- return undefined;
552
- }
553
-
554
- /**
555
- *
556
- */
557
- function quux () {
558
- return;
559
- }
560
-
561
- /**
562
- * @returns {true}
563
- */
564
- function quux () {
565
- try {
566
- return true;
567
- } catch (err) {
568
- }
569
- return true;
570
- }
571
-
572
- /**
573
- * @returns {true}
574
- */
575
- function quux () {
576
- try {
577
- } finally {
578
- return true;
579
- }
580
- return true;
581
- }
582
-
583
- /**
584
- * @returns {true}
585
- */
586
- function quux () {
587
- try {
588
- return true;
589
- } catch (err) {
590
- }
591
- return true;
592
- }
593
-
594
- /**
595
- * @returns {true}
596
- */
597
- function quux () {
598
- try {
599
- something();
600
- } catch (err) {
601
- return true;
602
- }
603
- return true;
604
- }
605
-
606
- /**
607
- * @returns {true}
608
- */
609
- function quux () {
610
- switch (true) {
611
- case 'abc':
612
- return true;
613
- }
614
- return true;
615
- }
616
-
617
- /**
618
- * @returns {true}
619
- */
620
- function quux () {
621
- switch (true) {
622
- case 'abc':
623
- return true;
624
- }
625
- return true;
626
- }
627
-
628
- /**
629
- * @returns {true}
630
- */
631
- function quux () {
632
- for (const i of abc) {
633
- return true;
634
- }
635
- return true;
636
- }
637
-
638
- /**
639
- * @returns {true}
640
- */
641
- function quux () {
642
- for (const a in b) {
643
- return true;
644
- }
645
- }
646
-
647
- /**
648
- * @returns {true}
649
- */
650
- function quux () {
651
- for (const a of b) {
652
- return true;
653
- }
654
- }
655
-
656
- /**
657
- * @returns {true}
658
- */
659
- function quux () {
660
- loop: for (const a of b) {
661
- return true;
662
- }
663
- }
664
-
665
- /**
666
- * @returns {true}
667
- */
668
- function quux () {
669
- for (let i=0; i<n; i+=1) {
670
- return true;
671
- }
672
- }
673
-
674
- /**
675
- * @returns {true}
676
- */
677
- function quux () {
678
- while(true) {
679
- return true
680
- }
681
- }
682
-
683
- /**
684
- * @returns {true}
685
- */
686
- function quux () {
687
- do {
688
- return true
689
- }
690
- while(true)
691
- }
692
-
693
- /**
694
- * @returns {true}
136
+ * @returns Foo.
695
137
  */
696
138
  function quux () {
697
- if (true) {
698
- return true;
699
- }
700
- return true;
701
- }
702
139
 
703
- /**
704
- * @returns {true}
705
- */
706
- function quux () {
707
- var a = {};
708
- with (a) {
709
- return true;
710
- }
711
140
  }
141
+ // "jsdoc/require-returns-description": ["error"|"warn", {"contexts":["any"]}]
712
142
 
713
143
  /**
714
- * @returns {true}
144
+ * @returns {undefined}
715
145
  */
716
146
  function quux () {
717
- if (true) {
718
- return true;
719
- } else {
720
- return true;
721
- }
722
- return true;
723
- }
724
-
725
- /**
726
- * @returns {Promise<number>}
727
- */
728
- async function quux() {
729
- return 5;
730
- }
731
-
732
- /**
733
- * @returns {Promise<number>}
734
- */
735
- async function quux() {
736
- return 5;
737
- }
738
- // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
739
147
 
740
- /**
741
- * @returns {Promise<void>}
742
- */
743
- function quux() {
744
- return new Promise((resolve, reject) => {
745
- setTimeout(() => {
746
- resolve(true);
747
- });
748
- })
749
148
  }
750
- // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
751
149
 
752
150
  /**
753
- * Description.
754
151
  * @returns {void}
755
152
  */
756
- async function foo() {
757
- return new Promise(resolve => resolve());
758
- }
759
- // "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
760
-
761
- /**
762
- * @returns { void } Foo.
763
- */
764
153
  function quux () {
765
- return undefined;
766
- }
767
- // "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
768
154
 
769
- /**
770
- * @returns { string } Foo.
771
- */
772
- function quux () {
773
- return 'abc';
774
155
  }
775
- // "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
776
156
 
777
157
  /**
778
- * @returns {IterableIterator<any>}
779
- */
780
- function * quux() {}
781
- // Settings: {"jsdoc":{"mode":"typescript"}}
782
-
783
- /**
784
- * @returns {IterableIterator<any>}
785
- */
786
- function * quux() {}
787
- // Settings: {"jsdoc":{"mode":"jsdoc"}}
788
- // "jsdoc/require-returns-check": ["error"|"warn", {"exemptGenerators":true}]
789
-
790
- /**
791
- * @param {unknown} val
792
- * @returns { asserts val is number }
793
- */
794
- function assertNumber(val) {
795
- assert(typeof val === 'number');
796
- }
797
-
798
- /**
799
- * Reads a test fixture.
800
- *
801
- * @param path The path to resolve relative to the fixture base. It will be normalized for the
802
- * operating system.
803
- *
804
- * @returns The file contents as buffer.
805
- */
806
- export function readFixture(path: string): Promise<Buffer>;
807
-
808
- /**
809
- * Reads a test fixture.
810
- *
811
- * @param path The path to resolve relative to the fixture base. It will be normalized for the
812
- * operating system.
813
- *
814
- * @returns {SomeType} The file contents as buffer.
815
- */
816
- export function readFixture(path: string): Promise<Buffer>;
817
-
818
- /**
819
- * Reads a test fixture.
820
- *
821
- * @param path The path to resolve relative to the fixture base. It will be normalized for the
822
- * operating system.
823
- *
824
- * @returns The file contents as buffer.
825
- */
826
- export function readFixture(path: string): Promise<Buffer> {
827
- return new Promise(() => {});
828
- }
829
-
830
- /**
831
- * Reads a test fixture.
832
- *
833
- * @param path The path to resolve relative to the fixture base. It will be normalized for the
834
- * operating system.
835
- *
836
- * @returns {void} The file contents as buffer.
837
- */
838
- export function readFixture(path: string);
839
-
840
- /**
841
- * @returns {SomeType}
842
- */
843
- function quux (path) {
844
- if (true) {
845
- return 5;
846
- }
847
- return 15;
848
- };
849
-
850
- /**
851
- * @returns {SomeType} Foo.
852
- */
853
- const quux = () => new Promise((resolve) => {
854
- resolve(3);
855
- });
856
-
857
- /**
858
- * @returns {SomeType} Foo.
859
- */
860
- const quux = function () {
861
- return new Promise((resolve) => {
862
- resolve(3);
863
- });
864
- };
865
-
866
- /**
867
- * @returns {true}
158
+ * @returns {Promise<void>}
868
159
  */
869
160
  function quux () {
870
- if (true) {
871
- return true;
872
- }
873
-
874
- throw new Error('Fail');
875
- }
876
-
877
- /**
878
- * @returns Baz.
879
- */
880
- function foo() {
881
- switch (true) {
882
- default:
883
- switch (false) {
884
- default: break;
885
- }
886
- return "baz";
887
- }
888
- };
889
-
890
- /**
891
- * Return a V1 style query identifier.
892
- *
893
- * @param {string} id - The query identifier.
894
- * @returns {string} V1 style query identifier.
895
- */
896
- function v1QueryId(id) {
897
- switch (id) {
898
- case 'addq':
899
- case 'aliq':
900
- case 'locq':
901
- return id.substring(3);
902
- case 'lost':
903
- return id.substring(4);
904
- default:
905
- return id;
906
- }
907
- }
908
161
 
909
- /**
910
- * Parses the required header fields for the given SIP message.
911
- *
912
- * @param {string} logPrefix - The log prefix.
913
- * @param {string} sipMessage - The SIP message.
914
- * @param {string[]} headers - The header fields to be parsed.
915
- * @returns {object} Object with parsed header fields.
916
- */
917
- function parseSipHeaders(logPrefix, sipMessage, headers) {
918
- try {
919
- return esappSip.parseHeaders(sipMessage, headers);
920
- } catch (err) {
921
- logger.error(logPrefix, 'Failed to parse');
922
- return {};
923
- }
924
162
  }
925
163
 
926
164
  /**
927
- * @returns {true}
165
+ * @returns {Promise<undefined>}
928
166
  */
929
167
  function quux () {
930
- try {
931
- } catch (error) {
932
- } finally {
933
- return true;
934
- }
935
- }
936
-
937
- /** Returns true.
938
- *
939
- * @returns {boolean} true
940
- */
941
- function getTrue() {
942
- try {
943
- return true;
944
- } finally {
945
- console.log('returning...');
946
- }
947
- }
948
-
949
- /**
950
- * Maybe return a boolean.
951
- * @returns {boolean|void} true, or undefined.
952
- */
953
- function maybeTrue() {
954
- if (Math.random() > 0.5) {
955
- return true;
956
- }
957
- }
958
-
959
- /**
960
- * @param {AST} astNode
961
- * @returns {AST}
962
- */
963
- const getTSFunctionComment = function (astNode) {
964
- switch (greatGrandparent.type) {
965
- case 'VariableDeclarator':
966
- if (greatGreatGrandparent.type === 'VariableDeclaration') {
967
- return greatGreatGrandparent;
968
- }
969
-
970
- default:
971
- return astNode;
972
- }
973
- };
974
-
975
- const f =
976
- /**
977
- * Description.
978
- *
979
- * @returns Result.
980
- */
981
- () => {
982
- return function () {};
983
- };
984
-
985
- /**
986
- * Description.
987
- *
988
- * @returns Result.
989
- */
990
- export function f(): string {
991
- return "";
992
168
 
993
- interface I {}
994
169
  }
995
170
 
996
171
  /**
997
- * @param {boolean} bar A fun variable.
998
- * @returns {*} Anything at all!
999
- */
1000
- function foo( bar ) {
1001
- if ( bar ) {
1002
- return functionWithUnknownReturnType();
1003
- }
1004
- }
1005
-
1006
- /**
1007
- * @returns Baz.
1008
- */
1009
- function foo() {
1010
- switch (true) {
1011
- default:
1012
- switch (false) {
1013
- default: return;
1014
- }
1015
- return "baz";
1016
- }
1017
- };
1018
-
1019
- /**
1020
- * @returns Baz.
1021
- */
1022
- function foo() {
1023
- switch (true) {
1024
- default:
1025
- switch (false) {
1026
- default: return;
1027
- }
1028
- return "baz";
1029
- }
1030
- };
1031
-
1032
- /**
172
+ * @function
1033
173
  * @returns
1034
174
  */
1035
- const quux = (someVar) => {
1036
- if (someVar) {
1037
- return true;
1038
- }
1039
- };
1040
175
 
1041
176
  /**
1042
- * @returns {number}
177
+ * @callback
178
+ * @returns
1043
179
  */
1044
- function foo() {
1045
- while (true) {
1046
- const n = Math.random();
1047
- if (n < 0.5) {
1048
- return n;
1049
- }
1050
- }
1051
- }
1052
180
  ````
1053
181