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