eslint-plugin-jsdoc 46.4.5 → 46.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -0
- package/dist/alignTransform.js +5 -5
- package/dist/alignTransform.js.map +1 -1
- package/dist/index.js +21 -10
- package/dist/index.js.map +1 -1
- package/dist/iterateJsdoc.js +1 -1
- package/dist/iterateJsdoc.js.map +1 -1
- package/dist/rules/checkExamples.js +12 -6
- package/dist/rules/checkExamples.js.map +1 -1
- package/package.json +19 -15
- package/docs/advanced.md +0 -102
- package/docs/rules/check-access.md +0 -193
- package/docs/rules/check-alignment.md +0 -169
- package/docs/rules/check-examples.md +0 -784
- package/docs/rules/check-indentation.md +0 -296
- package/docs/rules/check-line-alignment.md +0 -1002
- package/docs/rules/check-param-names.md +0 -1035
- package/docs/rules/check-property-names.md +0 -244
- package/docs/rules/check-syntax.md +0 -80
- package/docs/rules/check-tag-names.md +0 -1132
- package/docs/rules/check-types.md +0 -1198
- package/docs/rules/check-values.md +0 -409
- package/docs/rules/empty-tags.md +0 -220
- package/docs/rules/implements-on-classes.md +0 -219
- package/docs/rules/imports-as-dependencies.md +0 -99
- package/docs/rules/informative-docs.md +0 -400
- package/docs/rules/match-description.md +0 -1008
- package/docs/rules/match-name.md +0 -249
- package/docs/rules/multiline-blocks.md +0 -398
- package/docs/rules/no-bad-blocks.md +0 -174
- package/docs/rules/no-blank-block-descriptions.md +0 -91
- package/docs/rules/no-blank-blocks.md +0 -98
- package/docs/rules/no-defaults.md +0 -207
- package/docs/rules/no-missing-syntax.md +0 -275
- package/docs/rules/no-multi-asterisks.md +0 -278
- package/docs/rules/no-restricted-syntax.md +0 -383
- package/docs/rules/no-types.md +0 -168
- package/docs/rules/no-undefined-types.md +0 -789
- package/docs/rules/require-asterisk-prefix.md +0 -297
- package/docs/rules/require-description-complete-sentence.md +0 -820
- package/docs/rules/require-description.md +0 -585
- package/docs/rules/require-example.md +0 -390
- package/docs/rules/require-file-overview.md +0 -324
- package/docs/rules/require-hyphen-before-param-description.md +0 -281
- package/docs/rules/require-jsdoc.md +0 -1857
- package/docs/rules/require-param-description.md +0 -238
- package/docs/rules/require-param-name.md +0 -163
- package/docs/rules/require-param-type.md +0 -227
- package/docs/rules/require-param.md +0 -1820
- package/docs/rules/require-property-description.md +0 -88
- package/docs/rules/require-property-name.md +0 -79
- package/docs/rules/require-property-type.md +0 -79
- package/docs/rules/require-property.md +0 -128
- package/docs/rules/require-returns-check.md +0 -1053
- package/docs/rules/require-returns-description.md +0 -181
- package/docs/rules/require-returns-type.md +0 -144
- package/docs/rules/require-returns.md +0 -1191
- package/docs/rules/require-throws.md +0 -326
- package/docs/rules/require-yields-check.md +0 -544
- package/docs/rules/require-yields.md +0 -823
- package/docs/rules/sort-tags.md +0 -635
- package/docs/rules/tag-lines.md +0 -551
- package/docs/rules/text-escaping.md +0 -177
- package/docs/rules/valid-types.md +0 -881
- package/docs/settings.md +0 -362
- package/tsconfig.json +0 -22
|
@@ -1,1053 +0,0 @@
|
|
|
1
|
-
<a name="user-content-require-returns-check"></a>
|
|
2
|
-
<a name="require-returns-check"></a>
|
|
3
|
-
# <code>require-returns-check</code>
|
|
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)
|
|
9
|
-
|
|
10
|
-
|
|
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.
|
|
19
|
-
|
|
20
|
-
Will also report if multiple `@returns` tags are present.
|
|
21
|
-
|
|
22
|
-
<a name="user-content-require-returns-check-options"></a>
|
|
23
|
-
<a name="require-returns-check-options"></a>
|
|
24
|
-
## Options
|
|
25
|
-
|
|
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>
|
|
50
|
-
## Context and settings
|
|
51
|
-
|
|
52
|
-
|||
|
|
53
|
-
|---|---|
|
|
54
|
-
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
|
|
55
|
-
|Tags|`returns`|
|
|
56
|
-
|Aliases|`return`|
|
|
57
|
-
|Options|`exemptAsync`, `exemptGenerators`, `reportMissingReturnForUndefinedTypes`|
|
|
58
|
-
|Recommended|true|
|
|
59
|
-
|
|
60
|
-
<a name="user-content-require-returns-check-failing-examples"></a>
|
|
61
|
-
<a name="require-returns-check-failing-examples"></a>
|
|
62
|
-
## Failing examples
|
|
63
|
-
|
|
64
|
-
The following patterns are considered problems:
|
|
65
|
-
|
|
66
|
-
````js
|
|
67
|
-
/**
|
|
68
|
-
* @returns
|
|
69
|
-
*/
|
|
70
|
-
function quux (foo) {
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
// Message: JSDoc @returns declaration present but return expression not available in function.
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* @return
|
|
77
|
-
*/
|
|
78
|
-
function quux (foo) {
|
|
79
|
-
|
|
80
|
-
}
|
|
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`
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @returns {string}
|
|
131
|
-
*/
|
|
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.
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* @returns {Promise<void>}
|
|
176
|
-
*/
|
|
177
|
-
function quux() {
|
|
178
|
-
return new Promise((resolve, reject) => {
|
|
179
|
-
setTimeout(() => {
|
|
180
|
-
resolve();
|
|
181
|
-
});
|
|
182
|
-
})
|
|
183
|
-
}
|
|
184
|
-
// "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
|
|
185
|
-
// Message: JSDoc @returns declaration present but return expression not available in function.
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Description.
|
|
189
|
-
* @returns {string}
|
|
190
|
-
*/
|
|
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.
|
|
196
|
-
|
|
197
|
-
/**
|
|
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.
|
|
216
|
-
*/
|
|
217
|
-
function quux () {
|
|
218
|
-
return undefined;
|
|
219
|
-
}
|
|
220
|
-
// Message: JSDoc @returns declaration set with "never" but return expression is present in function.
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* @returns {never}
|
|
224
|
-
*/
|
|
225
|
-
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
|
-
|
|
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
|
-
}
|
|
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.
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* @returns {true}
|
|
347
|
-
*/
|
|
348
|
-
function quux () {
|
|
349
|
-
if (true) {
|
|
350
|
-
throw new Error('abc');
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
throw new Error('def');
|
|
354
|
-
}
|
|
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.
|
|
398
|
-
````
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
<a name="user-content-require-returns-check-passing-examples"></a>
|
|
403
|
-
<a name="require-returns-check-passing-examples"></a>
|
|
404
|
-
## Passing examples
|
|
405
|
-
|
|
406
|
-
The following patterns are not considered problems:
|
|
407
|
-
|
|
408
|
-
````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
|
-
/**
|
|
434
|
-
*
|
|
435
|
-
*/
|
|
436
|
-
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
|
-
|
|
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
|
-
}
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* @returns Foo.
|
|
487
|
-
* @constructor
|
|
488
|
-
*/
|
|
489
|
-
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
|
-
|
|
527
|
-
/**
|
|
528
|
-
* @returns {void} Foo.
|
|
529
|
-
*/
|
|
530
|
-
function quux () {
|
|
531
|
-
return undefined;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
/**
|
|
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}
|
|
695
|
-
*/
|
|
696
|
-
function quux () {
|
|
697
|
-
if (true) {
|
|
698
|
-
return true;
|
|
699
|
-
}
|
|
700
|
-
return true;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
* @returns {true}
|
|
705
|
-
*/
|
|
706
|
-
function quux () {
|
|
707
|
-
var a = {};
|
|
708
|
-
with (a) {
|
|
709
|
-
return true;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
/**
|
|
714
|
-
* @returns {true}
|
|
715
|
-
*/
|
|
716
|
-
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
|
-
|
|
740
|
-
/**
|
|
741
|
-
* @returns {Promise<void>}
|
|
742
|
-
*/
|
|
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}]
|
|
751
|
-
|
|
752
|
-
/**
|
|
753
|
-
* Description.
|
|
754
|
-
* @returns {void}
|
|
755
|
-
*/
|
|
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
|
-
function quux () {
|
|
765
|
-
return undefined;
|
|
766
|
-
}
|
|
767
|
-
// "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
* @returns { string } Foo.
|
|
771
|
-
*/
|
|
772
|
-
function quux () {
|
|
773
|
-
return 'abc';
|
|
774
|
-
}
|
|
775
|
-
// "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
|
|
776
|
-
|
|
777
|
-
/**
|
|
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}
|
|
868
|
-
*/
|
|
869
|
-
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
|
-
|
|
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
|
-
}
|
|
925
|
-
|
|
926
|
-
/**
|
|
927
|
-
* @returns {true}
|
|
928
|
-
*/
|
|
929
|
-
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
|
-
|
|
993
|
-
interface I {}
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
/**
|
|
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
|
-
/**
|
|
1033
|
-
* @returns
|
|
1034
|
-
*/
|
|
1035
|
-
const quux = (someVar) => {
|
|
1036
|
-
if (someVar) {
|
|
1037
|
-
return true;
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
|
-
|
|
1041
|
-
/**
|
|
1042
|
-
* @returns {number}
|
|
1043
|
-
*/
|
|
1044
|
-
function foo() {
|
|
1045
|
-
while (true) {
|
|
1046
|
-
const n = Math.random();
|
|
1047
|
-
if (n < 0.5) {
|
|
1048
|
-
return n;
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
````
|
|
1053
|
-
|