eslint-plugin-jsdoc 44.2.2 → 44.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alignTransform.js +86 -4
- package/dist/alignTransform.js.map +1 -1
- package/dist/exportParser.js +134 -4
- package/dist/exportParser.js.map +1 -1
- package/dist/getDefaultTagStructureForMode.js +71 -62
- package/dist/getDefaultTagStructureForMode.js.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/iterateJsdoc.js +1081 -111
- package/dist/iterateJsdoc.js.map +1 -1
- package/dist/jsdocUtils.js +381 -132
- package/dist/jsdocUtils.js.map +1 -1
- package/dist/rules/checkAlignment.js +6 -0
- package/dist/rules/checkAlignment.js.map +1 -1
- package/dist/rules/checkExamples.js +70 -6
- package/dist/rules/checkExamples.js.map +1 -1
- package/dist/rules/checkIndentation.js +11 -1
- package/dist/rules/checkIndentation.js.map +1 -1
- package/dist/rules/checkLineAlignment.js +69 -5
- package/dist/rules/checkLineAlignment.js.map +1 -1
- package/dist/rules/checkParamNames.js +12 -7
- package/dist/rules/checkParamNames.js.map +1 -1
- package/dist/rules/checkPropertyNames.js +13 -7
- package/dist/rules/checkPropertyNames.js.map +1 -1
- package/dist/rules/checkTagNames.js +45 -5
- package/dist/rules/checkTagNames.js.map +1 -1
- package/dist/rules/checkTypes.js +97 -36
- package/dist/rules/checkTypes.js.map +1 -1
- package/dist/rules/checkValues.js +6 -6
- package/dist/rules/checkValues.js.map +1 -1
- package/dist/rules/emptyTags.js +8 -1
- package/dist/rules/emptyTags.js.map +1 -1
- package/dist/rules/informativeDocs.js +26 -7
- package/dist/rules/informativeDocs.js.map +1 -1
- package/dist/rules/matchDescription.js +19 -2
- package/dist/rules/matchDescription.js.map +1 -1
- package/dist/rules/matchName.js +2 -2
- package/dist/rules/matchName.js.map +1 -1
- package/dist/rules/multilineBlocks.js +12 -1
- package/dist/rules/multilineBlocks.js.map +1 -1
- package/dist/rules/noBadBlocks.js +4 -6
- package/dist/rules/noBadBlocks.js.map +1 -1
- package/dist/rules/noBlankBlockDescriptions.js +2 -0
- package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
- package/dist/rules/noMissingSyntax.js +58 -15
- package/dist/rules/noMissingSyntax.js.map +1 -1
- package/dist/rules/noMultiAsterisks.js +1 -6
- package/dist/rules/noMultiAsterisks.js.map +1 -1
- package/dist/rules/noRestrictedSyntax.js +17 -4
- package/dist/rules/noRestrictedSyntax.js.map +1 -1
- package/dist/rules/noTypes.js +3 -0
- package/dist/rules/noTypes.js.map +1 -1
- package/dist/rules/noUndefinedTypes.js +61 -20
- package/dist/rules/noUndefinedTypes.js.map +1 -1
- package/dist/rules/requireAsteriskPrefix.js +20 -0
- package/dist/rules/requireAsteriskPrefix.js.map +1 -1
- package/dist/rules/requireDescription.js +6 -2
- package/dist/rules/requireDescription.js.map +1 -1
- package/dist/rules/requireDescriptionCompleteSentence.js +73 -10
- package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
- package/dist/rules/requireFileOverview.js +9 -4
- package/dist/rules/requireFileOverview.js.map +1 -1
- package/dist/rules/requireHyphenBeforeParamDescription.js +23 -6
- package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
- package/dist/rules/requireJsdoc.js +148 -30
- package/dist/rules/requireJsdoc.js.map +1 -1
- package/dist/rules/requireParam.js +46 -2
- package/dist/rules/requireParam.js.map +1 -1
- package/dist/rules/requireProperty.js +1 -1
- package/dist/rules/requireProperty.js.map +1 -1
- package/dist/rules/requireReturns.js +2 -2
- package/dist/rules/requireReturns.js.map +1 -1
- package/dist/rules/requireReturnsCheck.js +9 -2
- package/dist/rules/requireReturnsCheck.js.map +1 -1
- package/dist/rules/requireThrows.js +2 -2
- package/dist/rules/requireThrows.js.map +1 -1
- package/dist/rules/requireYields.js +9 -2
- package/dist/rules/requireYields.js.map +1 -1
- package/dist/rules/requireYieldsCheck.js +19 -5
- package/dist/rules/requireYieldsCheck.js.map +1 -1
- package/dist/rules/sortTags.js +67 -9
- package/dist/rules/sortTags.js.map +1 -1
- package/dist/rules/tagLines.js +22 -3
- package/dist/rules/tagLines.js.map +1 -1
- package/dist/rules/textEscaping.js +16 -2
- package/dist/rules/textEscaping.js.map +1 -1
- package/dist/rules/validTypes.js +25 -8
- package/dist/rules/validTypes.js.map +1 -1
- package/dist/tagNames.js +27 -0
- package/dist/tagNames.js.map +1 -1
- package/dist/utils/hasReturnValue.js +87 -42
- package/dist/utils/hasReturnValue.js.map +1 -1
- package/docs/rules/check-tag-names.md +15 -0
- package/docs/rules/no-missing-syntax.md +6 -0
- package/docs/rules/no-undefined-types.md +18 -0
- package/docs/rules/require-description-complete-sentence.md +525 -289
- package/docs/rules/require-description.md +289 -525
- package/docs/rules/require-file-overview.md +7 -0
- package/docs/rules/require-jsdoc.md +1 -1
- package/docs/rules/require-param-description.md +116 -1694
- package/docs/rules/require-param-name.md +58 -133
- package/docs/rules/require-param-type.md +119 -55
- package/docs/rules/require-param.md +1700 -111
- package/docs/rules/require-property-description.md +39 -79
- package/docs/rules/require-property-name.md +21 -30
- package/docs/rules/require-property-type.md +21 -21
- package/docs/rules/require-property.md +82 -33
- package/docs/rules/require-returns-check.md +636 -747
- package/docs/rules/require-returns-description.md +61 -933
- package/docs/rules/require-returns-type.md +42 -79
- package/docs/rules/require-returns.md +1081 -61
- package/docs/rules/require-yields-check.md +238 -517
- package/docs/rules/require-yields.md +517 -238
- package/docs/rules/valid-types.md +1 -1
- package/docs/settings.md +1 -1
- package/package.json +13 -5
- package/tsconfig.json +5 -2
|
@@ -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
|
|
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
|
-
- `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
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:
|
|
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:
|
|
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 =
|
|
132
|
-
//
|
|
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
|
-
//
|
|
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
|
-
|
|
106
|
+
this._name = name;
|
|
176
107
|
}
|
|
177
108
|
}
|
|
178
|
-
// Message:
|
|
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
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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:
|
|
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
|
-
* @
|
|
130
|
+
* @returns {string}
|
|
223
131
|
*/
|
|
224
|
-
function
|
|
225
|
-
|
|
132
|
+
function f () {
|
|
133
|
+
function g() {
|
|
134
|
+
return 'foo'
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
() => {
|
|
138
|
+
return 5
|
|
139
|
+
}
|
|
226
140
|
}
|
|
227
|
-
//
|
|
228
|
-
// Message: Missing JSDoc @returns declaration.
|
|
141
|
+
// Message: JSDoc @returns declaration present but return expression not available in function.
|
|
229
142
|
|
|
230
143
|
/**
|
|
231
|
-
* @
|
|
144
|
+
* @returns {Promise<void>}
|
|
232
145
|
*/
|
|
233
|
-
async function
|
|
234
|
-
|
|
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
|
-
* @
|
|
151
|
+
* @returns {IterableIterator<any>}
|
|
241
152
|
*/
|
|
242
|
-
|
|
243
|
-
|
|
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
|
|
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
|
-
|
|
295
|
-
|
|
296
|
-
|
|
165
|
+
/**
|
|
166
|
+
* @returns {Promise<void>}
|
|
167
|
+
*/
|
|
168
|
+
function quux() {
|
|
169
|
+
return new Promise((resolve, reject) => {})
|
|
297
170
|
}
|
|
298
|
-
//
|
|
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
|
|
304
|
-
|
|
305
|
-
return new Promise(function (resolve, reject) {
|
|
177
|
+
function quux() {
|
|
178
|
+
return new Promise((resolve, reject) => {
|
|
306
179
|
setTimeout(() => {
|
|
307
|
-
resolve(
|
|
180
|
+
resolve();
|
|
308
181
|
});
|
|
309
|
-
})
|
|
182
|
+
})
|
|
310
183
|
}
|
|
311
|
-
//
|
|
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
|
|
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
|
-
//
|
|
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
|
|
328
|
-
return new Promise(
|
|
329
|
-
while(true) {
|
|
330
|
-
resolve(true);
|
|
331
|
-
}
|
|
332
|
-
});
|
|
201
|
+
async function foo() {
|
|
202
|
+
return new Promise(resolve => resolve());
|
|
333
203
|
}
|
|
334
|
-
//
|
|
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
|
-
|
|
341
|
-
|
|
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
|
|
354
|
-
if (true) {
|
|
355
|
-
resolve(true);
|
|
356
|
-
}
|
|
357
|
-
return;
|
|
358
|
-
});
|
|
218
|
+
return undefined;
|
|
359
219
|
}
|
|
360
|
-
// Message:
|
|
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
|
|
367
|
-
if (true) {
|
|
368
|
-
resolve(true);
|
|
369
|
-
}
|
|
370
|
-
});
|
|
225
|
+
function quux (foo) {
|
|
226
|
+
return foo;
|
|
371
227
|
}
|
|
372
|
-
// Message:
|
|
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
|
|
378
|
-
|
|
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
|
|
391
|
-
|
|
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
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
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
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
case 'abc':
|
|
437
|
-
resolve(true);
|
|
438
|
-
}
|
|
439
|
-
});
|
|
280
|
+
if (true) {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
440
283
|
}
|
|
441
|
-
// Message:
|
|
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
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
resolve(true);
|
|
452
|
-
}
|
|
453
|
-
});
|
|
290
|
+
if (true) {
|
|
291
|
+
} else {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
454
294
|
}
|
|
455
|
-
// Message:
|
|
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
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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:
|
|
308
|
+
// Message: JSDoc @returns declaration present but return expression not available in function.
|
|
468
309
|
|
|
469
310
|
/**
|
|
470
|
-
*
|
|
311
|
+
* @returns {boolean}
|
|
471
312
|
*/
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
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
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
});
|
|
324
|
+
try {
|
|
325
|
+
return true;
|
|
326
|
+
} catch (error) {
|
|
327
|
+
}
|
|
490
328
|
}
|
|
491
|
-
// Message:
|
|
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
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
}
|
|
335
|
+
try {
|
|
336
|
+
return true;
|
|
337
|
+
} catch (error) {
|
|
338
|
+
return true;
|
|
339
|
+
} finally {
|
|
340
|
+
return;
|
|
341
|
+
}
|
|
504
342
|
}
|
|
505
|
-
// Message:
|
|
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
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
});
|
|
349
|
+
if (true) {
|
|
350
|
+
throw new Error('abc');
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
throw new Error('def');
|
|
517
354
|
}
|
|
518
|
-
// Message:
|
|
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
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
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
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
410
|
+
* @returns Foo.
|
|
580
411
|
*/
|
|
581
|
-
|
|
582
|
-
|
|
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
|
-
* @
|
|
418
|
+
* @returns {string} Foo.
|
|
589
419
|
*/
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
420
|
+
function quux () {
|
|
421
|
+
|
|
422
|
+
return foo;
|
|
423
|
+
}
|
|
593
424
|
|
|
594
425
|
/**
|
|
595
|
-
* @
|
|
426
|
+
* @returns {string} Foo.
|
|
596
427
|
*/
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
428
|
+
function quux () {
|
|
429
|
+
|
|
430
|
+
return foo;
|
|
431
|
+
}
|
|
601
432
|
|
|
602
433
|
/**
|
|
603
|
-
*
|
|
434
|
+
*
|
|
604
435
|
*/
|
|
605
|
-
|
|
606
|
-
|
|
436
|
+
function quux () {
|
|
437
|
+
}
|
|
607
438
|
|
|
608
439
|
/**
|
|
609
|
-
*
|
|
440
|
+
* @returns {SomeType} Foo.
|
|
610
441
|
*/
|
|
611
|
-
|
|
612
|
-
// "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
|
|
613
|
-
// Message: Missing JSDoc @returns declaration.
|
|
442
|
+
const quux = () => foo;
|
|
614
443
|
|
|
615
444
|
/**
|
|
616
|
-
*
|
|
445
|
+
* @returns {undefined} Foo.
|
|
617
446
|
*/
|
|
618
|
-
|
|
619
|
-
// "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
|
|
620
|
-
// Message: Missing JSDoc @returns declaration.
|
|
447
|
+
function quux () {}
|
|
621
448
|
|
|
622
449
|
/**
|
|
623
|
-
* @
|
|
450
|
+
* @returns { void } Foo.
|
|
624
451
|
*/
|
|
625
|
-
|
|
626
|
-
return Promise.all(a);
|
|
627
|
-
}
|
|
628
|
-
// Message: Missing JSDoc @returns declaration.
|
|
452
|
+
function quux () {}
|
|
629
453
|
|
|
630
454
|
/**
|
|
631
|
-
*
|
|
455
|
+
* @returns {Promise<void>}
|
|
632
456
|
*/
|
|
633
|
-
|
|
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
|
|
460
|
+
* @returns {Promise<void>}
|
|
650
461
|
*/
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
return foo;
|
|
654
|
-
}
|
|
462
|
+
const quux = async function () {}
|
|
655
463
|
|
|
656
464
|
/**
|
|
657
|
-
* @returns
|
|
465
|
+
* @returns {Promise<void>}
|
|
658
466
|
*/
|
|
659
|
-
|
|
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 (
|
|
675
|
-
|
|
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
|
|
486
|
+
* @returns Foo.
|
|
487
|
+
* @constructor
|
|
682
488
|
*/
|
|
683
|
-
function quux (
|
|
684
|
-
return bar.filter(baz => {
|
|
685
|
-
return baz.corge();
|
|
686
|
-
})
|
|
489
|
+
function quux () {
|
|
687
490
|
}
|
|
688
491
|
|
|
689
492
|
/**
|
|
690
|
-
* @
|
|
691
|
-
*/
|
|
692
|
-
const quux = (bar) => bar.filter(({ corge }) => corge())
|
|
693
|
-
|
|
694
|
-
/**
|
|
695
|
-
* @inheritdoc
|
|
493
|
+
* @interface
|
|
696
494
|
*/
|
|
697
|
-
|
|
495
|
+
class Foo {
|
|
496
|
+
/**
|
|
497
|
+
* @returns {string}
|
|
498
|
+
*/
|
|
499
|
+
bar () {
|
|
500
|
+
}
|
|
698
501
|
}
|
|
699
502
|
|
|
700
503
|
/**
|
|
701
|
-
* @
|
|
504
|
+
* @record
|
|
702
505
|
*/
|
|
703
|
-
|
|
506
|
+
class Foo {
|
|
507
|
+
/**
|
|
508
|
+
* @returns {string}
|
|
509
|
+
*/
|
|
510
|
+
bar () {
|
|
511
|
+
}
|
|
704
512
|
}
|
|
513
|
+
// Settings: {"jsdoc":{"mode":"closure"}}
|
|
705
514
|
|
|
706
515
|
/**
|
|
707
|
-
* @
|
|
516
|
+
* @returns {undefined} Foo.
|
|
708
517
|
*/
|
|
709
|
-
function quux (
|
|
710
|
-
return true;
|
|
518
|
+
function quux () {
|
|
711
519
|
}
|
|
712
520
|
|
|
713
521
|
/**
|
|
714
|
-
* @
|
|
522
|
+
* @returns {void} Foo.
|
|
715
523
|
*/
|
|
716
|
-
function quux (
|
|
717
|
-
return true;
|
|
524
|
+
function quux () {
|
|
718
525
|
}
|
|
719
526
|
|
|
720
527
|
/**
|
|
721
|
-
* @
|
|
528
|
+
* @returns {void} Foo.
|
|
722
529
|
*/
|
|
723
|
-
function quux (
|
|
724
|
-
|
|
725
|
-
return foo;
|
|
530
|
+
function quux () {
|
|
531
|
+
return undefined;
|
|
726
532
|
}
|
|
727
533
|
|
|
728
534
|
/**
|
|
729
|
-
* @
|
|
535
|
+
* @returns {never} Foo.
|
|
730
536
|
*/
|
|
731
|
-
function quux (
|
|
732
|
-
return true;
|
|
537
|
+
function quux () {
|
|
733
538
|
}
|
|
734
539
|
|
|
735
540
|
/**
|
|
736
|
-
* @
|
|
541
|
+
* @returns {void} Foo.
|
|
737
542
|
*/
|
|
738
|
-
function quux (
|
|
739
|
-
|
|
543
|
+
function quux () {
|
|
544
|
+
return;
|
|
740
545
|
}
|
|
741
546
|
|
|
742
547
|
/**
|
|
743
|
-
*
|
|
548
|
+
*
|
|
744
549
|
*/
|
|
745
550
|
function quux () {
|
|
746
|
-
|
|
747
|
-
return {a: foo};
|
|
551
|
+
return undefined;
|
|
748
552
|
}
|
|
749
553
|
|
|
750
554
|
/**
|
|
751
|
-
*
|
|
555
|
+
*
|
|
752
556
|
*/
|
|
753
|
-
|
|
557
|
+
function quux () {
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
754
560
|
|
|
755
561
|
/**
|
|
756
|
-
* @returns {
|
|
562
|
+
* @returns {true}
|
|
757
563
|
*/
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
564
|
+
function quux () {
|
|
565
|
+
try {
|
|
566
|
+
return true;
|
|
567
|
+
} catch (err) {
|
|
568
|
+
}
|
|
569
|
+
return true;
|
|
570
|
+
}
|
|
761
571
|
|
|
762
572
|
/**
|
|
763
|
-
* @returns {
|
|
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 {
|
|
584
|
+
* @returns {true}
|
|
770
585
|
*/
|
|
771
|
-
|
|
772
|
-
|
|
586
|
+
function quux () {
|
|
587
|
+
try {
|
|
588
|
+
return true;
|
|
589
|
+
} catch (err) {
|
|
590
|
+
}
|
|
591
|
+
return true;
|
|
773
592
|
}
|
|
774
593
|
|
|
775
594
|
/**
|
|
776
|
-
* @returns {
|
|
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 {
|
|
607
|
+
* @returns {true}
|
|
783
608
|
*/
|
|
784
|
-
|
|
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
|
-
|
|
798
|
-
|
|
631
|
+
function quux () {
|
|
632
|
+
for (const i of abc) {
|
|
633
|
+
return true;
|
|
634
|
+
}
|
|
635
|
+
return true;
|
|
799
636
|
}
|
|
800
637
|
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
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
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
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 {
|
|
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 {
|
|
666
|
+
* @returns {true}
|
|
828
667
|
*/
|
|
829
668
|
function quux () {
|
|
830
|
-
|
|
669
|
+
for (let i=0; i<n; i+=1) {
|
|
670
|
+
return true;
|
|
671
|
+
}
|
|
831
672
|
}
|
|
832
673
|
|
|
833
674
|
/**
|
|
834
|
-
* @returns {
|
|
675
|
+
* @returns {true}
|
|
835
676
|
*/
|
|
836
677
|
function quux () {
|
|
837
|
-
|
|
678
|
+
while(true) {
|
|
679
|
+
return true
|
|
680
|
+
}
|
|
838
681
|
}
|
|
839
|
-
// "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
|
|
840
682
|
|
|
841
683
|
/**
|
|
842
|
-
* @returns {
|
|
684
|
+
* @returns {true}
|
|
843
685
|
*/
|
|
844
686
|
function quux () {
|
|
845
|
-
|
|
687
|
+
do {
|
|
688
|
+
return true
|
|
689
|
+
}
|
|
690
|
+
while(true)
|
|
846
691
|
}
|
|
847
692
|
|
|
848
693
|
/**
|
|
849
|
-
* @returns {
|
|
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 {
|
|
704
|
+
* @returns {true}
|
|
857
705
|
*/
|
|
858
706
|
function quux () {
|
|
859
|
-
|
|
707
|
+
var a = {};
|
|
708
|
+
with (a) {
|
|
709
|
+
return true;
|
|
710
|
+
}
|
|
860
711
|
}
|
|
861
|
-
// "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
|
|
862
712
|
|
|
863
|
-
/**
|
|
864
|
-
|
|
865
|
-
|
|
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", {"
|
|
738
|
+
// "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
|
|
881
739
|
|
|
882
740
|
/**
|
|
883
|
-
*
|
|
741
|
+
* @returns {Promise<void>}
|
|
884
742
|
*/
|
|
885
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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", {"
|
|
775
|
+
// "jsdoc/require-returns-check": ["error"|"warn", {"reportMissingReturnForUndefinedTypes":true}]
|
|
914
776
|
|
|
915
777
|
/**
|
|
916
|
-
* @
|
|
778
|
+
* @returns {IterableIterator<any>}
|
|
917
779
|
*/
|
|
918
|
-
function quux
|
|
780
|
+
function * quux() {}
|
|
781
|
+
// Settings: {"jsdoc":{"mode":"typescript"}}
|
|
919
782
|
|
|
920
|
-
|
|
921
|
-
|
|
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 {
|
|
791
|
+
* @param {unknown} val
|
|
792
|
+
* @returns { asserts val is number }
|
|
925
793
|
*/
|
|
926
|
-
|
|
927
|
-
|
|
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
|
-
|
|
806
|
+
export function readFixture(path: string): Promise<Buffer>;
|
|
934
807
|
|
|
935
808
|
/**
|
|
936
|
-
*
|
|
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
|
-
|
|
816
|
+
export function readFixture(path: string): Promise<Buffer>;
|
|
939
817
|
|
|
940
818
|
/**
|
|
941
|
-
*
|
|
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
|
-
|
|
826
|
+
export function readFixture(path: string): Promise<Buffer> {
|
|
827
|
+
return new Promise(() => {});
|
|
828
|
+
}
|
|
944
829
|
|
|
945
830
|
/**
|
|
946
|
-
*
|
|
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
|
-
|
|
838
|
+
export function readFixture(path: string);
|
|
949
839
|
|
|
950
840
|
/**
|
|
951
|
-
* @
|
|
952
|
-
* @async
|
|
841
|
+
* @returns {SomeType}
|
|
953
842
|
*/
|
|
954
|
-
|
|
843
|
+
function quux (path) {
|
|
844
|
+
if (true) {
|
|
845
|
+
return 5;
|
|
846
|
+
}
|
|
847
|
+
return 15;
|
|
848
|
+
};
|
|
955
849
|
|
|
956
850
|
/**
|
|
957
|
-
* @
|
|
958
|
-
* @async
|
|
851
|
+
* @returns {SomeType} Foo.
|
|
959
852
|
*/
|
|
960
|
-
|
|
853
|
+
const quux = () => new Promise((resolve) => {
|
|
854
|
+
resolve(3);
|
|
855
|
+
});
|
|
961
856
|
|
|
962
857
|
/**
|
|
963
|
-
* @
|
|
858
|
+
* @returns {SomeType} Foo.
|
|
964
859
|
*/
|
|
965
|
-
|
|
860
|
+
const quux = function () {
|
|
861
|
+
return new Promise((resolve) => {
|
|
862
|
+
resolve(3);
|
|
863
|
+
});
|
|
864
|
+
};
|
|
966
865
|
|
|
967
866
|
/**
|
|
968
|
-
* @
|
|
867
|
+
* @returns {true}
|
|
969
868
|
*/
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
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
|
-
|
|
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
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
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
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
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
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
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 (
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
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
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
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
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
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
|
|
1117
|
-
|
|
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
|
-
|
|
1124
|
-
return
|
|
990
|
+
export function f(): string {
|
|
991
|
+
return "";
|
|
992
|
+
|
|
993
|
+
interface I {}
|
|
1125
994
|
}
|
|
1126
995
|
|
|
1127
996
|
/**
|
|
1128
|
-
* @param
|
|
997
|
+
* @param {boolean} bar A fun variable.
|
|
998
|
+
* @returns {*} Anything at all!
|
|
1129
999
|
*/
|
|
1130
|
-
|
|
1131
|
-
|
|
1000
|
+
function foo( bar ) {
|
|
1001
|
+
if ( bar ) {
|
|
1002
|
+
return functionWithUnknownReturnType();
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1132
1005
|
|
|
1133
1006
|
/**
|
|
1134
|
-
* @
|
|
1007
|
+
* @returns Baz.
|
|
1135
1008
|
*/
|
|
1136
|
-
|
|
1137
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
1033
|
+
* @returns
|
|
1156
1034
|
*/
|
|
1157
|
-
|
|
1035
|
+
const quux = (someVar) => {
|
|
1036
|
+
if (someVar) {
|
|
1037
|
+
return true;
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1158
1040
|
|
|
1159
1041
|
/**
|
|
1160
|
-
*
|
|
1042
|
+
* @returns {number}
|
|
1161
1043
|
*/
|
|
1162
|
-
|
|
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
|
|