eslint-plugin-jsdoc 44.2.3 → 44.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/alignTransform.js +86 -4
  2. package/dist/alignTransform.js.map +1 -1
  3. package/dist/exportParser.js +134 -4
  4. package/dist/exportParser.js.map +1 -1
  5. package/dist/iterateJsdoc.js +936 -345
  6. package/dist/iterateJsdoc.js.map +1 -1
  7. package/dist/jsdocUtils.js +173 -105
  8. package/dist/jsdocUtils.js.map +1 -1
  9. package/dist/rules/checkAlignment.js +6 -0
  10. package/dist/rules/checkAlignment.js.map +1 -1
  11. package/dist/rules/checkExamples.js +70 -6
  12. package/dist/rules/checkExamples.js.map +1 -1
  13. package/dist/rules/checkIndentation.js +11 -1
  14. package/dist/rules/checkIndentation.js.map +1 -1
  15. package/dist/rules/checkLineAlignment.js +68 -4
  16. package/dist/rules/checkLineAlignment.js.map +1 -1
  17. package/dist/rules/checkParamNames.js +12 -7
  18. package/dist/rules/checkParamNames.js.map +1 -1
  19. package/dist/rules/checkPropertyNames.js +13 -7
  20. package/dist/rules/checkPropertyNames.js.map +1 -1
  21. package/dist/rules/checkTagNames.js +45 -5
  22. package/dist/rules/checkTagNames.js.map +1 -1
  23. package/dist/rules/checkTypes.js +97 -36
  24. package/dist/rules/checkTypes.js.map +1 -1
  25. package/dist/rules/checkValues.js +6 -6
  26. package/dist/rules/checkValues.js.map +1 -1
  27. package/dist/rules/emptyTags.js +8 -1
  28. package/dist/rules/emptyTags.js.map +1 -1
  29. package/dist/rules/informativeDocs.js +26 -7
  30. package/dist/rules/informativeDocs.js.map +1 -1
  31. package/dist/rules/matchDescription.js +18 -1
  32. package/dist/rules/matchDescription.js.map +1 -1
  33. package/dist/rules/matchName.js +2 -2
  34. package/dist/rules/matchName.js.map +1 -1
  35. package/dist/rules/multilineBlocks.js +12 -1
  36. package/dist/rules/multilineBlocks.js.map +1 -1
  37. package/dist/rules/noBadBlocks.js +3 -5
  38. package/dist/rules/noBadBlocks.js.map +1 -1
  39. package/dist/rules/noBlankBlockDescriptions.js +2 -0
  40. package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
  41. package/dist/rules/noMissingSyntax.js +58 -15
  42. package/dist/rules/noMissingSyntax.js.map +1 -1
  43. package/dist/rules/noMultiAsterisks.js +1 -6
  44. package/dist/rules/noMultiAsterisks.js.map +1 -1
  45. package/dist/rules/noRestrictedSyntax.js +17 -4
  46. package/dist/rules/noRestrictedSyntax.js.map +1 -1
  47. package/dist/rules/noTypes.js +3 -0
  48. package/dist/rules/noTypes.js.map +1 -1
  49. package/dist/rules/noUndefinedTypes.js +61 -20
  50. package/dist/rules/noUndefinedTypes.js.map +1 -1
  51. package/dist/rules/requireAsteriskPrefix.js +20 -0
  52. package/dist/rules/requireAsteriskPrefix.js.map +1 -1
  53. package/dist/rules/requireDescription.js +6 -2
  54. package/dist/rules/requireDescription.js.map +1 -1
  55. package/dist/rules/requireDescriptionCompleteSentence.js +72 -9
  56. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  57. package/dist/rules/requireFileOverview.js +9 -4
  58. package/dist/rules/requireFileOverview.js.map +1 -1
  59. package/dist/rules/requireHyphenBeforeParamDescription.js +23 -6
  60. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  61. package/dist/rules/requireJsdoc.js +144 -28
  62. package/dist/rules/requireJsdoc.js.map +1 -1
  63. package/dist/rules/requireParam.js +46 -2
  64. package/dist/rules/requireParam.js.map +1 -1
  65. package/dist/rules/requireProperty.js +1 -1
  66. package/dist/rules/requireProperty.js.map +1 -1
  67. package/dist/rules/requireReturns.js +2 -2
  68. package/dist/rules/requireReturns.js.map +1 -1
  69. package/dist/rules/requireReturnsCheck.js +9 -2
  70. package/dist/rules/requireReturnsCheck.js.map +1 -1
  71. package/dist/rules/requireThrows.js +2 -2
  72. package/dist/rules/requireThrows.js.map +1 -1
  73. package/dist/rules/requireYields.js +9 -2
  74. package/dist/rules/requireYields.js.map +1 -1
  75. package/dist/rules/requireYieldsCheck.js +19 -5
  76. package/dist/rules/requireYieldsCheck.js.map +1 -1
  77. package/dist/rules/sortTags.js +67 -9
  78. package/dist/rules/sortTags.js.map +1 -1
  79. package/dist/rules/tagLines.js +22 -3
  80. package/dist/rules/tagLines.js.map +1 -1
  81. package/dist/rules/textEscaping.js +16 -2
  82. package/dist/rules/textEscaping.js.map +1 -1
  83. package/dist/rules/validTypes.js +25 -8
  84. package/dist/rules/validTypes.js.map +1 -1
  85. package/dist/utils/hasReturnValue.js +77 -43
  86. package/dist/utils/hasReturnValue.js.map +1 -1
  87. package/docs/rules/check-tag-names.md +15 -0
  88. package/docs/rules/no-missing-syntax.md +6 -0
  89. package/docs/rules/require-description-complete-sentence.md +525 -289
  90. package/docs/rules/require-description.md +289 -525
  91. package/docs/rules/require-file-overview.md +7 -0
  92. package/docs/rules/require-jsdoc.md +1 -1
  93. package/docs/rules/require-param-description.md +116 -1694
  94. package/docs/rules/require-param-name.md +58 -133
  95. package/docs/rules/require-param-type.md +119 -55
  96. package/docs/rules/require-param.md +1700 -111
  97. package/docs/rules/require-property-description.md +39 -79
  98. package/docs/rules/require-property-name.md +21 -30
  99. package/docs/rules/require-property-type.md +21 -21
  100. package/docs/rules/require-property.md +82 -33
  101. package/docs/rules/require-returns-check.md +636 -747
  102. package/docs/rules/require-returns-description.md +61 -933
  103. package/docs/rules/require-returns-type.md +42 -79
  104. package/docs/rules/require-returns.md +1081 -61
  105. package/docs/rules/require-yields-check.md +238 -517
  106. package/docs/rules/require-yields.md +517 -238
  107. package/docs/rules/valid-types.md +1 -1
  108. package/docs/settings.md +1 -1
  109. package/package.json +5 -4
  110. package/tsconfig.json +2 -3
@@ -1,361 +1,325 @@
1
- <a name="user-content-require-yields-check"></a>
2
- <a name="require-yields-check"></a>
3
- # <code>require-yields-check</code>
1
+ <a name="user-content-require-yields"></a>
2
+ <a name="require-yields"></a>
3
+ # <code>require-yields</code>
4
4
 
5
- * [Options](#user-content-require-yields-check-options)
6
- * [Context and settings](#user-content-require-yields-check-context-and-settings)
7
- * [Failing examples](#user-content-require-yields-check-failing-examples)
8
- * [Passing examples](#user-content-require-yields-check-passing-examples)
5
+ * [Options](#user-content-require-yields-options)
6
+ * [Context and settings](#user-content-require-yields-context-and-settings)
7
+ * [Failing examples](#user-content-require-yields-failing-examples)
8
+ * [Passing examples](#user-content-require-yields-passing-examples)
9
9
 
10
10
 
11
- Ensures that if a `@yields` is present that a `yield` (or `yield` with a
12
- value) is present in the function body (or that if a `@next` is present that
13
- there is a `yield` with a return value present).
14
-
15
- Please also note that JavaScript does allow generators not to have `yield`
16
- (e.g., with just a return or even no explicit return), but if you want to
17
- enforce that all generators (except wholly empty ones) have a `yield` in the
18
- function body, you can use the ESLint
19
- [`require-yield`](https://eslint.org/docs/rules/require-yield) rule. In
20
- conjunction with this, you can also use the `checkGeneratorsOnly` option
21
- as an optimization so that this rule won't need to do its own checking within
22
- function bodies.
11
+ Requires that yields are documented.
23
12
 
24
13
  Will also report if multiple `@yields` tags are present.
25
14
 
26
- <a name="user-content-require-yields-check-options"></a>
27
- <a name="require-yields-check-options"></a>
15
+ See the `next`, `forceRequireNext`, and `nextWithGeneratorTag` options for an
16
+ option to expect a non-standard `@next` tag.
17
+
18
+ <a name="user-content-require-yields-options"></a>
19
+ <a name="require-yields-options"></a>
28
20
  ## Options
29
21
 
30
- - `checkGeneratorsOnly` - Avoids checking the function body and merely insists
31
- that all generators have `@yields`. This can be an optimization with the
32
- ESLint `require-yield` rule, as that rule already ensures a `yield` is
33
- present in generators, albeit assuming the generator is not empty).
34
- Defaults to `false`.
35
- - `next` - If `true`, this option will insist that any use of a (non-standard)
36
- `@next` tag (in addition to any `@yields` tag) will be matched by a `yield`
37
- which uses a return value in the body of the generator (e.g.,
38
- `const rv = yield;` or `const rv = yield value;`). This (non-standard)
39
- tag is intended to be used to indicate a type and/or description of
40
- the value expected to be supplied by the user when supplied to the iterator
41
- by its `next` method, as with `it.next(value)` (with the iterator being
42
- the `Generator` iterator that is returned by the call to the generator
43
- function). This option will report an error if the generator function body
44
- merely has plain `yield;` or `yield value;` statements without returning
45
- the values. Defaults to `false`.
46
-
47
- <a name="user-content-require-yields-check-context-and-settings"></a>
48
- <a name="require-yields-check-context-and-settings"></a>
22
+ - `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the
23
+ document block avoids the need for a `@yields`. Defaults to an array
24
+ with `inheritdoc`. If you set this array, it will overwrite the default,
25
+ so be sure to add back `inheritdoc` if you wish its presence to cause
26
+ exemption of the rule.
27
+ - `forceRequireYields` - Set to `true` to always insist on
28
+ `@yields` documentation for generators even if there are only
29
+ expressionless `yield` statements in the function. May be desired to flag
30
+ that a project is aware of an `undefined`/`void` yield. Defaults to
31
+ `false`.
32
+ - `contexts` - Set this to an array of strings representing the AST context
33
+ (or an object with `context` and `comment` properties) where you wish
34
+ the rule to be applied.
35
+ Overrides the default contexts (see below). Set to `"any"` if you want
36
+ the rule to apply to any jsdoc block throughout your files (as is necessary
37
+ for finding function blocks not attached to a function declaration or
38
+ expression, i.e., `@callback` or `@function` (or its aliases `@func` or
39
+ `@method`) (including those associated with an `@interface`). This
40
+ rule will only apply on non-default contexts when there is such a tag
41
+ present and the `forceRequireYields` option is set or if the
42
+ `withGeneratorTag` option is set with a present `@generator` tag
43
+ (since we are not checking against the actual `yield` values in these
44
+ cases).
45
+ - `withGeneratorTag` - If a `@generator` tag is present on a block, require
46
+ `@yields`/`@yield`. Defaults to `true`. See `contexts` to `any` if you want
47
+ to catch `@generator` with `@callback` or such not attached to a function.
48
+ - `next` - If `true`, this option will insist that any use of a `yield` return
49
+ value (e.g., `const rv = yield;` or `const rv = yield value;`) has a
50
+ (non-standard) `@next` tag (in addition to any `@yields` tag) so as to be
51
+ able to document the type expected to be supplied into the iterator
52
+ (the `Generator` iterator that is returned by the call to the generator
53
+ function) to the iterator (e.g., `it.next(value)`). The tag will not be
54
+ expected if the generator function body merely has plain `yield;` or
55
+ `yield value;` statements without returning the values. Defaults to
56
+ `false`.
57
+ - `forceRequireNext` - Set to `true` to always insist on
58
+ `@next` documentation even if there are no `yield` statements in the
59
+ function or none return values. May be desired to flag that a project is
60
+ aware of the expected yield return being `undefined`. Defaults to `false`.
61
+ - `nextWithGeneratorTag` - If a `@generator` tag is present on a block, require
62
+ (non-standard ) `@next` (see `next` option). This will require using `void`
63
+ or `undefined` in cases where generators do not use the `next()`-supplied
64
+ incoming `yield`-returned value. Defaults to `false`. See `contexts` to
65
+ `any` if you want to catch `@generator` with `@callback` or such not
66
+ attached to a function.
67
+
68
+ <a name="user-content-require-yields-context-and-settings"></a>
69
+ <a name="require-yields-context-and-settings"></a>
49
70
  ## Context and settings
50
71
 
51
72
  |||
52
73
  |---|---|
53
- |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
74
+ |Context|Generator functions (`FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled)|
54
75
  |Tags|`yields`|
55
76
  |Aliases|`yield`|
56
77
  |Recommended|true|
57
- |Options|`checkGeneratorsOnly`|
78
+ | Options | `contexts`, `exemptedBy`, `withGeneratorTag`, `nextWithGeneratorTag`, `forceRequireYields`, `next` |
79
+ | Settings | `ignoreReplacesDocs`, `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` |
58
80
 
59
- <a name="user-content-require-yields-check-failing-examples"></a>
60
- <a name="require-yields-check-failing-examples"></a>
81
+ <a name="user-content-require-yields-failing-examples"></a>
82
+ <a name="require-yields-failing-examples"></a>
61
83
  ## Failing examples
62
84
 
63
85
  The following patterns are considered problems:
64
86
 
65
87
  ````js
66
88
  /**
67
- * @yields
89
+ *
68
90
  */
69
91
  function * quux (foo) {
70
92
 
93
+ yield foo;
71
94
  }
72
- // Message: JSDoc @yields declaration present but yield expression not available in function.
95
+ // Message: Missing JSDoc @yields declaration.
73
96
 
74
97
  /**
75
98
  * @yields
76
99
  */
77
- function quux (foo) {
100
+ function * quux (foo) {
78
101
 
102
+ const retVal = yield foo;
79
103
  }
80
- // "jsdoc/require-yields-check": ["error"|"warn", {"checkGeneratorsOnly":true}]
81
- // Message: JSDoc @yields declaration present but yield expression not available in function.
104
+ // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
105
+ // Message: Missing JSDoc @next declaration.
82
106
 
83
107
  /**
84
- * @next
108
+ * @yields
85
109
  */
86
- function quux (foo) {
110
+ function * quux (foo) {
87
111
 
112
+ const retVal = yield;
88
113
  }
89
- // "jsdoc/require-yields-check": ["error"|"warn", {"checkGeneratorsOnly":true,"next":true}]
90
- // Message: JSDoc @next declaration present but yield expression with return value not available in function.
114
+ // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
115
+ // Message: Missing JSDoc @next declaration.
91
116
 
92
117
  /**
93
- * @next {SomeType}
118
+ * @yields {void}
94
119
  */
95
- function * quux (foo) {
96
-
120
+ function * quux () {
97
121
  }
98
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
99
- // Message: JSDoc @next declaration present but yield expression with return value not available in function.
122
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireNext":true}]
123
+ // Message: Missing JSDoc @next declaration.
100
124
 
101
125
  /**
102
- * @next {SomeType}
126
+ * @yields {void}
103
127
  */
104
- function * quux (foo) {
128
+ function * quux () {
105
129
  yield;
106
130
  }
107
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
108
- // Message: JSDoc @next declaration present but yield expression with return value not available in function.
131
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireNext":true}]
132
+ // Message: Missing JSDoc @next declaration.
109
133
 
110
134
  /**
111
- * @next {SomeType}
135
+ *
112
136
  */
113
137
  function * quux (foo) {
114
- yield 5;
138
+
139
+ const a = yield foo;
115
140
  }
116
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
117
- // Message: JSDoc @next declaration present but yield expression with return value not available in function.
141
+ // Message: Missing JSDoc @yields declaration.
118
142
 
119
143
  /**
120
- * @yield
144
+ *
121
145
  */
122
146
  function * quux (foo) {
123
-
147
+ yield foo;
124
148
  }
125
149
  // Settings: {"jsdoc":{"tagNamePreference":{"yields":"yield"}}}
126
- // Message: JSDoc @yield declaration present but yield expression not available in function.
150
+ // Message: Missing JSDoc @yield declaration.
127
151
 
128
152
  /**
129
- * @yield-returns {Something}
153
+ * @yields
130
154
  */
131
155
  function * quux (foo) {
132
- yield;
156
+ const val = yield foo;
133
157
  }
134
158
  // Settings: {"jsdoc":{"tagNamePreference":{"next":"yield-returns"}}}
135
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
136
- // Message: JSDoc @yield-returns declaration present but yield expression with return value not available in function.
137
-
138
- /**
139
- * @yields {undefined} Foo.
140
- * @yields {String} Foo.
141
- */
142
- function * quux () {
143
-
144
- yield foo;
145
- }
146
- // Message: Found more than one @yields declaration.
147
-
148
- class Foo {
149
- /**
150
- * @yields {string}
151
- */
152
- * bar () {
153
- }
154
- }
155
- // Message: JSDoc @yields declaration present but yield expression not available in function.
159
+ // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
160
+ // Message: Missing JSDoc @yield-returns declaration.
156
161
 
157
162
  /**
158
163
  * @yields
159
- */
160
- function * quux () {
161
-
162
- }
163
- // Settings: {"jsdoc":{"tagNamePreference":{"yields":false}}}
164
- // Message: Unexpected tag `@yields`
165
-
166
- /**
167
164
  * @next
168
165
  */
169
166
  function * quux () {
170
-
167
+ const ret = yield 5;
171
168
  }
172
169
  // Settings: {"jsdoc":{"tagNamePreference":{"next":false}}}
173
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
170
+ // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
174
171
  // Message: Unexpected tag `@next`
175
172
 
176
173
  /**
177
- * @yields {string}
178
- */
179
- function * f () {
180
- function * g() {
181
- yield 'foo'
182
- }
183
- }
184
- // Message: JSDoc @yields declaration present but yield expression not available in function.
185
-
186
- /**
187
- * @yields {Promise<void>}
188
- */
189
- async function * quux() {}
190
- // Message: JSDoc @yields declaration present but yield expression not available in function.
191
-
192
- /**
193
- * @yields {Promise<void>}
194
- */
195
- const quux = async function * () {}
196
- // Message: JSDoc @yields declaration present but yield expression not available in function.
197
-
198
- /**
199
- * @yields {never} Foo.
174
+ *
200
175
  */
201
- function * quux () {
176
+ function * quux() {
202
177
  yield 5;
203
178
  }
204
- // Message: JSDoc @yields declaration set with "never" but yield expression is present in function.
179
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
180
+ // Message: Missing JSDoc @yields declaration.
205
181
 
206
182
  /**
207
- * @next {never}
208
- */
209
- function * quux (foo) {
210
- const a = yield;
211
- }
212
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
213
- // Message: JSDoc @next declaration set with "never" but yield expression with return value is present in function.
214
- ````
215
-
216
-
217
-
218
- <a name="user-content-require-yields-check-passing-examples"></a>
219
- <a name="require-yields-check-passing-examples"></a>
220
- ## Passing examples
221
-
222
- The following patterns are not considered problems:
223
-
224
- ````js
225
- /**
226
- * @yields Foo.
183
+ *
227
184
  */
228
- function * quux () {
229
-
230
- yield foo;
185
+ function * quux() {
186
+ yield;
231
187
  }
188
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
189
+ // Message: Missing JSDoc @yields declaration.
232
190
 
233
191
  /**
234
- * @yields {string} Foo.
192
+ *
235
193
  */
236
- function * quux () {
237
-
238
- yield foo;
194
+ const quux = async function * () {
195
+ yield;
239
196
  }
197
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
198
+ // Message: Missing JSDoc @yields declaration.
240
199
 
241
200
  /**
242
- * @yields {string} Foo.
201
+ *
243
202
  */
244
- function * quux () {
245
-
246
- yield foo;
203
+ async function * quux () {
204
+ yield;
247
205
  }
206
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
207
+ // Message: Missing JSDoc @yields declaration.
248
208
 
249
209
  /**
250
210
  *
251
211
  */
252
212
  function * quux () {
213
+ yield;
253
214
  }
215
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
216
+ // Message: Missing JSDoc @yields declaration.
254
217
 
255
218
  /**
256
- * @yields {undefined} Foo.
219
+ * @function
220
+ * @generator
257
221
  */
258
- function * quux () {}
222
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
223
+ // Message: Missing JSDoc @yields declaration.
259
224
 
260
225
  /**
261
- * @yields { void } Foo.
226
+ * @callback
227
+ * @generator
262
228
  */
263
- function quux () {}
229
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
230
+ // Message: Missing JSDoc @yields declaration.
264
231
 
265
232
  /**
266
- * @yields Foo.
267
- * @abstract
233
+ * @yields {undefined}
234
+ * @yields {void}
268
235
  */
269
- function * quux () {
270
- throw new Error('must be implemented by subclass!');
271
- }
236
+ function * quux (foo) {
272
237
 
273
- /**
274
- * @yields Foo.
275
- * @virtual
276
- */
277
- function * quux () {
278
- throw new Error('must be implemented by subclass!');
238
+ return foo;
279
239
  }
240
+ // Message: Found more than one @yields declaration.
280
241
 
281
242
  /**
282
- * @yields Foo.
283
- * @constructor
243
+ * @yields
284
244
  */
285
245
  function * quux () {
286
- }
287
246
 
288
- /**
289
- * @interface
290
- */
291
- class Foo {
292
- /**
293
- * @yields {string}
294
- */
295
- * bar () {
296
- }
297
247
  }
248
+ // Settings: {"jsdoc":{"tagNamePreference":{"yields":false}}}
249
+ // Message: Unexpected tag `@yields`
298
250
 
299
251
  /**
300
- * @record
252
+ * @param foo
301
253
  */
302
- class Foo {
303
- /**
304
- * @yields {string}
305
- */
306
- * bar () {
307
- }
254
+ function * quux (foo) {
255
+ yield 'bar';
308
256
  }
309
- // Settings: {"jsdoc":{"mode":"closure"}}
257
+ // "jsdoc/require-yields": ["error"|"warn", {"exemptedBy":["notPresent"]}]
258
+ // Message: Missing JSDoc @yields declaration.
310
259
 
311
260
  /**
312
- * @yields {undefined} Foo.
261
+ * @param {array} a
313
262
  */
314
- function * quux () {
263
+ async function * foo(a) {
264
+ return;
315
265
  }
266
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
267
+ // Message: Missing JSDoc @yields declaration.
316
268
 
317
269
  /**
318
- * @yields {void} Foo.
270
+ * @param {array} a
319
271
  */
320
- function * quux () {
272
+ async function * foo(a) {
273
+ yield Promise.all(a);
321
274
  }
275
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
276
+ // Message: Missing JSDoc @yields declaration.
322
277
 
323
- /**
324
- * @yields {never} Foo.
325
- */
326
- function * quux () {
278
+ class quux {
279
+ /**
280
+ *
281
+ */
282
+ * quux () {
283
+ yield;
284
+ }
327
285
  }
286
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
287
+ // Message: Missing JSDoc @yields declaration.
328
288
 
329
289
  /**
330
- * @yields {void} Foo.
290
+ * @param {array} a
331
291
  */
332
- function * quux () {
333
- yield undefined;
292
+ async function * foo(a) {
293
+ yield Promise.all(a);
334
294
  }
295
+ // Message: Missing JSDoc @yields declaration.
335
296
 
336
297
  /**
337
- * @yields {void} Foo.
298
+ * @generator
338
299
  */
339
- function * quux () {
340
- yield;
341
- }
300
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"withGeneratorTag":true}]
301
+ // Message: Missing JSDoc @yields declaration.
342
302
 
343
303
  /**
344
- *
304
+ * @generator
305
+ * @yields
345
306
  */
346
- function * quux () {
347
- yield undefined;
348
- }
307
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"nextWithGeneratorTag":true}]
308
+ // Message: Missing JSDoc @next declaration.
349
309
 
350
310
  /**
351
311
  *
352
312
  */
353
313
  function * quux () {
354
- yield;
314
+ if (true) {
315
+ yield;
316
+ }
317
+ yield true;
355
318
  }
319
+ // Message: Missing JSDoc @yields declaration.
356
320
 
357
321
  /**
358
- * @yields {true}
322
+ *
359
323
  */
360
324
  function * quux () {
361
325
  try {
@@ -364,9 +328,10 @@ function * quux () {
364
328
  }
365
329
  yield;
366
330
  }
331
+ // Message: Missing JSDoc @yields declaration.
367
332
 
368
333
  /**
369
- * @yields {true}
334
+ *
370
335
  */
371
336
  function * quux () {
372
337
  try {
@@ -375,9 +340,10 @@ function * quux () {
375
340
  }
376
341
  yield;
377
342
  }
343
+ // Message: Missing JSDoc @yields declaration.
378
344
 
379
345
  /**
380
- * @yields {true}
346
+ *
381
347
  */
382
348
  function * quux () {
383
349
  try {
@@ -386,9 +352,10 @@ function * quux () {
386
352
  }
387
353
  yield true;
388
354
  }
355
+ // Message: Missing JSDoc @yields declaration.
389
356
 
390
357
  /**
391
- * @yields {true}
358
+ *
392
359
  */
393
360
  function * quux () {
394
361
  try {
@@ -398,9 +365,10 @@ function * quux () {
398
365
  }
399
366
  yield;
400
367
  }
368
+ // Message: Missing JSDoc @yields declaration.
401
369
 
402
370
  /**
403
- * @yields {true}
371
+ *
404
372
  */
405
373
  function * quux () {
406
374
  switch (true) {
@@ -409,9 +377,10 @@ function * quux () {
409
377
  }
410
378
  yield;
411
379
  }
380
+ // Message: Missing JSDoc @yields declaration.
412
381
 
413
382
  /**
414
- * @yields {true}
383
+ *
415
384
  */
416
385
  function * quux () {
417
386
  switch (true) {
@@ -420,9 +389,10 @@ function * quux () {
420
389
  }
421
390
  yield true;
422
391
  }
392
+ // Message: Missing JSDoc @yields declaration.
423
393
 
424
394
  /**
425
- * @yields {true}
395
+ *
426
396
  */
427
397
  function * quux () {
428
398
  for (const i of abc) {
@@ -430,36 +400,40 @@ function * quux () {
430
400
  }
431
401
  yield;
432
402
  }
403
+ // Message: Missing JSDoc @yields declaration.
433
404
 
434
405
  /**
435
- * @yields {true}
406
+ *
436
407
  */
437
408
  function * quux () {
438
409
  for (const a in b) {
439
410
  yield true;
440
411
  }
441
412
  }
413
+ // Message: Missing JSDoc @yields declaration.
442
414
 
443
415
  /**
444
- * @yields {true}
416
+ *
445
417
  */
446
418
  function * quux () {
447
419
  for (let i=0; i<n; i+=1) {
448
420
  yield true;
449
421
  }
450
422
  }
423
+ // Message: Missing JSDoc @yields declaration.
451
424
 
452
425
  /**
453
- * @yields {true}
426
+ *
454
427
  */
455
428
  function * quux () {
456
429
  while(true) {
457
430
  yield true
458
431
  }
459
432
  }
433
+ // Message: Missing JSDoc @yields declaration.
460
434
 
461
435
  /**
462
- * @yields {true}
436
+ *
463
437
  */
464
438
  function * quux () {
465
439
  do {
@@ -467,9 +441,10 @@ function * quux () {
467
441
  }
468
442
  while(true)
469
443
  }
444
+ // Message: Missing JSDoc @yields declaration.
470
445
 
471
446
  /**
472
- * @yields {true}
447
+ *
473
448
  */
474
449
  function * quux () {
475
450
  if (true) {
@@ -477,18 +452,20 @@ function * quux () {
477
452
  }
478
453
  yield true;
479
454
  }
455
+ // Message: Missing JSDoc @yields declaration.
480
456
 
481
457
  /**
482
- * @yields {true}
458
+ *
483
459
  */
484
460
  function * quux () {
485
461
  if (true) {
486
462
  yield true;
487
463
  }
488
464
  }
465
+ // Message: Missing JSDoc @yields declaration.
489
466
 
490
467
  /**
491
- * @yields {true}
468
+ *
492
469
  */
493
470
  function * quux () {
494
471
  var a = {};
@@ -496,9 +473,10 @@ function * quux () {
496
473
  yield true;
497
474
  }
498
475
  }
476
+ // Message: Missing JSDoc @yields declaration.
499
477
 
500
478
  /**
501
- * @yields {true}
479
+ *
502
480
  */
503
481
  function * quux () {
504
482
  if (true) {
@@ -508,37 +486,338 @@ function * quux () {
508
486
  }
509
487
  yield;
510
488
  }
489
+ // Message: Missing JSDoc @yields declaration.
490
+ ````
491
+
492
+
493
+
494
+ <a name="user-content-require-yields-passing-examples"></a>
495
+ <a name="require-yields-passing-examples"></a>
496
+ ## Passing examples
497
+
498
+ The following patterns are not considered problems:
499
+
500
+ ````js
501
+ /**
502
+ * @yields Foo.
503
+ */
504
+ function * quux () {
505
+
506
+ yield foo;
507
+ }
511
508
 
512
509
  /**
513
- * @next {void}
510
+ * @yields Foo.
511
+ */
512
+ function * quux () {
513
+
514
+ yield foo;
515
+ }
516
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"]}]
517
+
518
+ /**
519
+ *
520
+ */
521
+ function * quux () {
522
+ }
523
+
524
+ /**
525
+ *
526
+ */
527
+ function * quux () {
528
+ yield;
529
+ }
530
+
531
+ /**
532
+ *
533
+ */
534
+ function quux (bar) {
535
+ bar.doSomething(function * (baz) {
536
+ yield baz.corge();
537
+ })
538
+ }
539
+
540
+ /**
541
+ * @yields {Array}
542
+ */
543
+ function * quux (bar) {
544
+ yield bar.doSomething(function * (baz) {
545
+ yield baz.corge();
546
+ })
547
+ }
548
+
549
+ /**
550
+ * @inheritdoc
514
551
  */
515
552
  function * quux (foo) {
553
+ }
554
+
555
+ /**
556
+ * @override
557
+ */
558
+ function * quux (foo) {
559
+ }
560
+
561
+ /**
562
+ * @constructor
563
+ */
564
+ function * quux (foo) {
565
+ }
566
+
567
+ /**
568
+ * @implements
569
+ */
570
+ function * quux (foo) {
571
+ yield;
572
+ }
573
+
574
+ /**
575
+ * @override
576
+ */
577
+ function * quux (foo) {
578
+
579
+ yield foo;
580
+ }
581
+
582
+ /**
583
+ * @class
584
+ */
585
+ function * quux (foo) {
586
+ yield foo;
587
+ }
588
+
589
+ /**
590
+ * @constructor
591
+ */
592
+ function * quux (foo) {
593
+ }
594
+
595
+ /**
596
+ * @yields {object}
597
+ */
598
+ function * quux () {
599
+
600
+ yield {a: foo};
601
+ }
602
+
603
+ /**
604
+ * @yields {void}
605
+ */
606
+ function * quux () {
607
+ }
608
+
609
+ /**
610
+ * @yields {undefined}
611
+ */
612
+ function * quux () {
613
+ }
614
+
615
+ /**
616
+ *
617
+ */
618
+ function * quux () {
619
+ }
620
+
621
+ /**
622
+ * @yields {void}
623
+ */
624
+ function quux () {
625
+ }
626
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
627
+
628
+ /**
629
+ * @yields {void}
630
+ * @next {void}
631
+ */
632
+ function * quux () {
633
+ }
634
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireNext":true}]
635
+
636
+ /**
637
+ * @yields {void}
638
+ */
639
+ function * quux () {
640
+ yield undefined;
641
+ }
642
+
643
+ /**
644
+ * @yields {void}
645
+ */
646
+ function * quux () {
647
+ yield undefined;
648
+ }
649
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
650
+
651
+ /**
652
+ * @yields {void}
653
+ */
654
+ function * quux () {
655
+ yield;
656
+ }
657
+
658
+ /**
659
+ * @yields {void}
660
+ */
661
+ function * quux () {
662
+ }
663
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
664
+
665
+ /**
666
+ * @yields {void}
667
+ */
668
+ function * quux () {
669
+ yield;
670
+ }
671
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
516
672
 
673
+ /** @type {SpecialIterator} */
674
+ function * quux () {
675
+ yield 5;
517
676
  }
518
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
519
677
 
520
678
  /**
521
- * @next {SomeType}
679
+ * @yields {Something}
680
+ */
681
+ async function * quux () {
682
+ }
683
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
684
+
685
+ /**
686
+ *
687
+ */
688
+ async function * quux () {}
689
+
690
+ /**
691
+ *
692
+ */
693
+ const quux = async function * () {}
694
+
695
+ /**
696
+ * @type {MyCallback}
697
+ */
698
+ function * quux () {
699
+ yield;
700
+ }
701
+ // "jsdoc/require-yields": ["error"|"warn", {"exemptedBy":["type"]}]
702
+
703
+ /**
704
+ * @param {array} a
705
+ */
706
+ async function * foo (a) {
707
+ yield;
708
+ }
709
+
710
+ /**
711
+ *
712
+ */
713
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"]}]
714
+
715
+ /**
716
+ * @function
717
+ */
718
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"]}]
719
+
720
+ /**
721
+ * @function
722
+ */
723
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
724
+
725
+ /**
726
+ * @callback
727
+ */
728
+ // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
729
+
730
+ /**
731
+ * @generator
732
+ */
733
+ // "jsdoc/require-yields": ["error"|"warn", {"withGeneratorTag":true}]
734
+
735
+ /**
736
+ * @generator
737
+ */
738
+ // "jsdoc/require-yields": ["error"|"warn", {"nextWithGeneratorTag":true}]
739
+
740
+ /**
741
+ * @generator
742
+ * @yields
743
+ */
744
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"withGeneratorTag":true}]
745
+
746
+ /**
747
+ * @generator
748
+ * @yields
749
+ * @next
750
+ */
751
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"nextWithGeneratorTag":true}]
752
+
753
+ /**
754
+ * @generator
755
+ */
756
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"withGeneratorTag":false}]
757
+
758
+ /**
759
+ * @generator
760
+ * @yields
761
+ */
762
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"nextWithGeneratorTag":false}]
763
+
764
+ /**
765
+ * @yields
522
766
  */
523
767
  function * quux (foo) {
524
- const a = yield;
768
+
769
+ const a = yield foo;
525
770
  }
526
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
527
771
 
528
772
  /**
529
- * @next {SomeType}
773
+ * @yields
774
+ * @next
530
775
  */
531
776
  function * quux (foo) {
532
- const a = yield 5;
777
+ let a = yield;
533
778
  }
534
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
779
+ // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
535
780
 
536
781
  /**
537
- * @next {never}
782
+ * @yields
783
+ * @next
538
784
  */
539
785
  function * quux (foo) {
786
+ const a = yield foo;
787
+ }
788
+ // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
540
789
 
790
+ /**
791
+ *
792
+ */
793
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"nextWithGeneratorTag":true}]
794
+
795
+ /**
796
+ *
797
+ */
798
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"next":true}]
799
+
800
+ /**
801
+ *
802
+ */
803
+ function quux () {}
804
+ // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"next":true}]
805
+
806
+ /**
807
+ * @yields {void}
808
+ */
809
+ function * quux () {
810
+ yield;
811
+ }
812
+ // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
813
+
814
+ /**
815
+ *
816
+ */
817
+ function * quux (foo) {
818
+ const a = function * bar () {
819
+ yield foo;
820
+ }
541
821
  }
542
- // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
543
822
  ````
544
823