eslint-plugin-jsdoc 44.2.3 → 44.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/WarnSettings.js +0 -1
  2. package/dist/WarnSettings.js.map +1 -1
  3. package/dist/alignTransform.js +87 -5
  4. package/dist/alignTransform.js.map +1 -1
  5. package/dist/bin/generateRule.js +4 -3
  6. package/dist/bin/generateRule.js.map +1 -1
  7. package/dist/exportParser.js +272 -71
  8. package/dist/exportParser.js.map +1 -1
  9. package/dist/generateRule.js +4 -3
  10. package/dist/generateRule.js.map +1 -1
  11. package/dist/iterateJsdoc.js +921 -357
  12. package/dist/iterateJsdoc.js.map +1 -1
  13. package/dist/jsdocUtils.js +270 -168
  14. package/dist/jsdocUtils.js.map +1 -1
  15. package/dist/rules/checkAlignment.js +6 -0
  16. package/dist/rules/checkAlignment.js.map +1 -1
  17. package/dist/rules/checkExamples.js +73 -9
  18. package/dist/rules/checkExamples.js.map +1 -1
  19. package/dist/rules/checkIndentation.js +12 -2
  20. package/dist/rules/checkIndentation.js.map +1 -1
  21. package/dist/rules/checkLineAlignment.js +71 -7
  22. package/dist/rules/checkLineAlignment.js.map +1 -1
  23. package/dist/rules/checkParamNames.js +29 -11
  24. package/dist/rules/checkParamNames.js.map +1 -1
  25. package/dist/rules/checkPropertyNames.js +13 -7
  26. package/dist/rules/checkPropertyNames.js.map +1 -1
  27. package/dist/rules/checkTagNames.js +45 -9
  28. package/dist/rules/checkTagNames.js.map +1 -1
  29. package/dist/rules/checkTypes.js +98 -41
  30. package/dist/rules/checkTypes.js.map +1 -1
  31. package/dist/rules/checkValues.js +7 -7
  32. package/dist/rules/checkValues.js.map +1 -1
  33. package/dist/rules/emptyTags.js +8 -1
  34. package/dist/rules/emptyTags.js.map +1 -1
  35. package/dist/rules/informativeDocs.js +27 -8
  36. package/dist/rules/informativeDocs.js.map +1 -1
  37. package/dist/rules/matchDescription.js +18 -1
  38. package/dist/rules/matchDescription.js.map +1 -1
  39. package/dist/rules/matchName.js +2 -2
  40. package/dist/rules/matchName.js.map +1 -1
  41. package/dist/rules/multilineBlocks.js +12 -1
  42. package/dist/rules/multilineBlocks.js.map +1 -1
  43. package/dist/rules/noBadBlocks.js +4 -6
  44. package/dist/rules/noBadBlocks.js.map +1 -1
  45. package/dist/rules/noBlankBlockDescriptions.js +2 -0
  46. package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
  47. package/dist/rules/noMissingSyntax.js +53 -16
  48. package/dist/rules/noMissingSyntax.js.map +1 -1
  49. package/dist/rules/noMultiAsterisks.js +1 -6
  50. package/dist/rules/noMultiAsterisks.js.map +1 -1
  51. package/dist/rules/noRestrictedSyntax.js +12 -5
  52. package/dist/rules/noRestrictedSyntax.js.map +1 -1
  53. package/dist/rules/noTypes.js +3 -0
  54. package/dist/rules/noTypes.js.map +1 -1
  55. package/dist/rules/noUndefinedTypes.js +65 -27
  56. package/dist/rules/noUndefinedTypes.js.map +1 -1
  57. package/dist/rules/requireAsteriskPrefix.js +20 -0
  58. package/dist/rules/requireAsteriskPrefix.js.map +1 -1
  59. package/dist/rules/requireDescription.js +6 -2
  60. package/dist/rules/requireDescription.js.map +1 -1
  61. package/dist/rules/requireDescriptionCompleteSentence.js +75 -12
  62. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  63. package/dist/rules/requireFileOverview.js +9 -4
  64. package/dist/rules/requireFileOverview.js.map +1 -1
  65. package/dist/rules/requireHyphenBeforeParamDescription.js +21 -7
  66. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  67. package/dist/rules/requireJsdoc.js +150 -29
  68. package/dist/rules/requireJsdoc.js.map +1 -1
  69. package/dist/rules/requireParam.js +116 -10
  70. package/dist/rules/requireParam.js.map +1 -1
  71. package/dist/rules/requireProperty.js +1 -1
  72. package/dist/rules/requireProperty.js.map +1 -1
  73. package/dist/rules/requireReturns.js +2 -3
  74. package/dist/rules/requireReturns.js.map +1 -1
  75. package/dist/rules/requireReturnsCheck.js +9 -2
  76. package/dist/rules/requireReturnsCheck.js.map +1 -1
  77. package/dist/rules/requireThrows.js +2 -3
  78. package/dist/rules/requireThrows.js.map +1 -1
  79. package/dist/rules/requireYields.js +9 -3
  80. package/dist/rules/requireYields.js.map +1 -1
  81. package/dist/rules/requireYieldsCheck.js +19 -5
  82. package/dist/rules/requireYieldsCheck.js.map +1 -1
  83. package/dist/rules/sortTags.js +67 -9
  84. package/dist/rules/sortTags.js.map +1 -1
  85. package/dist/rules/tagLines.js +22 -3
  86. package/dist/rules/tagLines.js.map +1 -1
  87. package/dist/rules/textEscaping.js +18 -4
  88. package/dist/rules/textEscaping.js.map +1 -1
  89. package/dist/rules/validTypes.js +26 -9
  90. package/dist/rules/validTypes.js.map +1 -1
  91. package/dist/tagNames.js +0 -2
  92. package/dist/tagNames.js.map +1 -1
  93. package/dist/utils/hasReturnValue.js +77 -48
  94. package/dist/utils/hasReturnValue.js.map +1 -1
  95. package/docs/rules/check-line-alignment.md +7 -0
  96. package/docs/rules/check-tag-names.md +15 -0
  97. package/docs/rules/no-missing-syntax.md +6 -0
  98. package/docs/rules/no-undefined-types.md +6 -0
  99. package/docs/rules/require-description-complete-sentence.md +525 -289
  100. package/docs/rules/require-description.md +289 -525
  101. package/docs/rules/require-file-overview.md +7 -0
  102. package/docs/rules/require-jsdoc.md +1 -1
  103. package/docs/rules/require-param-description.md +116 -1694
  104. package/docs/rules/require-param-name.md +58 -133
  105. package/docs/rules/require-param-type.md +119 -55
  106. package/docs/rules/require-param.md +1704 -111
  107. package/docs/rules/require-property-description.md +39 -79
  108. package/docs/rules/require-property-name.md +21 -30
  109. package/docs/rules/require-property-type.md +21 -21
  110. package/docs/rules/require-property.md +82 -33
  111. package/docs/rules/require-returns-check.md +636 -747
  112. package/docs/rules/require-returns-description.md +61 -933
  113. package/docs/rules/require-returns-type.md +42 -79
  114. package/docs/rules/require-returns.md +1081 -61
  115. package/docs/rules/require-yields-check.md +238 -517
  116. package/docs/rules/require-yields.md +517 -238
  117. package/docs/rules/valid-types.md +1 -1
  118. package/docs/settings.md +3 -1
  119. package/package.json +10 -9
  120. package/tsconfig.json +2 -3
@@ -1,326 +1,362 @@
1
- <a name="user-content-require-yields"></a>
2
- <a name="require-yields"></a>
3
- # <code>require-yields</code>
1
+ <a name="user-content-require-yields-check"></a>
2
+ <a name="require-yields-check"></a>
3
+ # <code>require-yields-check</code>
4
4
 
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)
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)
9
9
 
10
10
 
11
- Requires that yields are documented.
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).
12
14
 
13
- Will also report if multiple `@yields` tags are present.
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.
14
23
 
15
- See the `next`, `forceRequireNext`, and `nextWithGeneratorTag` options for an
16
- option to expect a non-standard `@next` tag.
24
+ Will also report if multiple `@yields` tags are present.
17
25
 
18
- <a name="user-content-require-yields-options"></a>
19
- <a name="require-yields-options"></a>
26
+ <a name="user-content-require-yields-check-options"></a>
27
+ <a name="require-yields-check-options"></a>
20
28
  ## Options
21
29
 
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>
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>
70
49
  ## Context and settings
71
50
 
72
51
  |||
73
52
  |---|---|
74
- |Context|Generator functions (`FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled)|
53
+ |Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
75
54
  |Tags|`yields`|
76
55
  |Aliases|`yield`|
77
56
  |Recommended|true|
78
- | Options | `contexts`, `exemptedBy`, `withGeneratorTag`, `nextWithGeneratorTag`, `forceRequireYields`, `next` |
79
- | Settings | `ignoreReplacesDocs`, `overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs` |
57
+ |Options|`checkGeneratorsOnly`|
80
58
 
81
- <a name="user-content-require-yields-failing-examples"></a>
82
- <a name="require-yields-failing-examples"></a>
59
+ <a name="user-content-require-yields-check-failing-examples"></a>
60
+ <a name="require-yields-check-failing-examples"></a>
83
61
  ## Failing examples
84
62
 
85
63
  The following patterns are considered problems:
86
64
 
87
65
  ````js
88
66
  /**
89
- *
67
+ * @yields
90
68
  */
91
69
  function * quux (foo) {
92
70
 
93
- yield foo;
94
71
  }
95
- // Message: Missing JSDoc @yields declaration.
72
+ // Message: JSDoc @yields declaration present but yield expression not available in function.
96
73
 
97
74
  /**
98
75
  * @yields
99
76
  */
100
- function * quux (foo) {
77
+ function quux (foo) {
101
78
 
102
- const retVal = yield foo;
103
79
  }
104
- // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
105
- // Message: Missing JSDoc @next declaration.
80
+ // "jsdoc/require-yields-check": ["error"|"warn", {"checkGeneratorsOnly":true}]
81
+ // Message: JSDoc @yields declaration present but yield expression not available in function.
106
82
 
107
83
  /**
108
- * @yields
84
+ * @next
109
85
  */
110
- function * quux (foo) {
86
+ function quux (foo) {
111
87
 
112
- const retVal = yield;
113
88
  }
114
- // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
115
- // Message: Missing JSDoc @next declaration.
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.
116
91
 
117
92
  /**
118
- * @yields {void}
93
+ * @next {SomeType}
119
94
  */
120
- function * quux () {
95
+ function * quux (foo) {
96
+
121
97
  }
122
- // "jsdoc/require-yields": ["error"|"warn", {"forceRequireNext":true}]
123
- // Message: Missing JSDoc @next declaration.
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.
124
100
 
125
101
  /**
126
- * @yields {void}
102
+ * @next {SomeType}
127
103
  */
128
- function * quux () {
104
+ function * quux (foo) {
129
105
  yield;
130
106
  }
131
- // "jsdoc/require-yields": ["error"|"warn", {"forceRequireNext":true}]
132
- // Message: Missing JSDoc @next declaration.
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.
133
109
 
134
110
  /**
135
- *
111
+ * @next {SomeType}
136
112
  */
137
113
  function * quux (foo) {
138
-
139
- const a = yield foo;
114
+ yield 5;
140
115
  }
141
- // Message: Missing JSDoc @yields declaration.
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.
142
118
 
143
119
  /**
144
- *
120
+ * @yield
145
121
  */
146
122
  function * quux (foo) {
147
- yield foo;
123
+
148
124
  }
149
125
  // Settings: {"jsdoc":{"tagNamePreference":{"yields":"yield"}}}
150
- // Message: Missing JSDoc @yield declaration.
126
+ // Message: JSDoc @yield declaration present but yield expression not available in function.
151
127
 
152
128
  /**
153
- * @yields
129
+ * @yield-returns {Something}
154
130
  */
155
131
  function * quux (foo) {
156
- const val = yield foo;
132
+ yield;
157
133
  }
158
134
  // Settings: {"jsdoc":{"tagNamePreference":{"next":"yield-returns"}}}
159
- // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
160
- // Message: Missing JSDoc @yield-returns declaration.
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.
161
156
 
162
157
  /**
163
158
  * @yields
159
+ */
160
+ function * quux () {
161
+
162
+ }
163
+ // Settings: {"jsdoc":{"tagNamePreference":{"yields":false}}}
164
+ // Message: Unexpected tag `@yields`
165
+
166
+ /**
164
167
  * @next
165
168
  */
166
169
  function * quux () {
167
- const ret = yield 5;
170
+
168
171
  }
169
172
  // Settings: {"jsdoc":{"tagNamePreference":{"next":false}}}
170
- // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
173
+ // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
171
174
  // Message: Unexpected tag `@next`
172
175
 
173
176
  /**
174
- *
177
+ * @yields {string}
175
178
  */
176
- function * quux() {
177
- yield 5;
179
+ function * f () {
180
+ function * g() {
181
+ yield 'foo'
182
+ }
178
183
  }
179
- // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
180
- // Message: Missing JSDoc @yields declaration.
184
+ // Message: JSDoc @yields declaration present but yield expression not available in function.
181
185
 
182
186
  /**
183
- *
187
+ * @yields {Promise<void>}
184
188
  */
185
- function * quux() {
186
- yield;
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.
200
+ */
201
+ function * quux () {
202
+ yield 5;
187
203
  }
188
- // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
189
- // Message: Missing JSDoc @yields declaration.
204
+ // Message: JSDoc @yields declaration set with "never" but yield expression is present in function.
190
205
 
191
206
  /**
192
- *
207
+ * @next {never}
193
208
  */
194
- const quux = async function * () {
195
- yield;
209
+ function * quux (foo) {
210
+ const a = yield;
196
211
  }
197
- // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
198
- // Message: Missing JSDoc @yields declaration.
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
+ ````
199
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
200
225
  /**
201
- *
226
+ * @yields Foo.
202
227
  */
203
- async function * quux () {
204
- yield;
228
+ function * quux () {
229
+
230
+ yield foo;
205
231
  }
206
- // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
207
- // Message: Missing JSDoc @yields declaration.
208
232
 
209
233
  /**
210
- *
234
+ * @yields {string} Foo.
211
235
  */
212
236
  function * quux () {
213
- yield;
237
+
238
+ yield foo;
214
239
  }
215
- // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
216
- // Message: Missing JSDoc @yields declaration.
217
240
 
218
241
  /**
219
- * @function
220
- * @generator
242
+ * @yields {string} Foo.
221
243
  */
222
- // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
223
- // Message: Missing JSDoc @yields declaration.
244
+ function * quux () {
245
+
246
+ yield foo;
247
+ }
224
248
 
225
249
  /**
226
- * @callback
227
- * @generator
250
+ *
228
251
  */
229
- // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
230
- // Message: Missing JSDoc @yields declaration.
252
+ function * quux () {
253
+ }
231
254
 
232
255
  /**
233
- * @yields {undefined}
234
- * @yields {void}
256
+ * @yields {undefined} Foo.
235
257
  */
236
- function * quux (foo) {
258
+ function * quux () {}
237
259
 
238
- return foo;
239
- }
240
- // Message: Found more than one @yields declaration.
260
+ /**
261
+ * @yields { void } Foo.
262
+ */
263
+ function quux () {}
241
264
 
242
265
  /**
243
- * @yields
266
+ * @yields Foo.
267
+ * @abstract
244
268
  */
245
269
  function * quux () {
246
-
270
+ throw new Error('must be implemented by subclass!');
247
271
  }
248
- // Settings: {"jsdoc":{"tagNamePreference":{"yields":false}}}
249
- // Message: Unexpected tag `@yields`
250
272
 
251
273
  /**
252
- * @param foo
274
+ * @yields Foo.
275
+ * @virtual
253
276
  */
254
- function * quux (foo) {
255
- yield 'bar';
277
+ function * quux () {
278
+ throw new Error('must be implemented by subclass!');
256
279
  }
257
- // "jsdoc/require-yields": ["error"|"warn", {"exemptedBy":["notPresent"]}]
258
- // Message: Missing JSDoc @yields declaration.
259
280
 
260
281
  /**
261
- * @param {array} a
282
+ * @yields Foo.
283
+ * @constructor
262
284
  */
263
- async function * foo(a) {
264
- return;
285
+ function * quux () {
265
286
  }
266
- // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
267
- // Message: Missing JSDoc @yields declaration.
268
287
 
269
288
  /**
270
- * @param {array} a
289
+ * @interface
271
290
  */
272
- async function * foo(a) {
273
- yield Promise.all(a);
291
+ class Foo {
292
+ /**
293
+ * @yields {string}
294
+ */
295
+ * bar () {
296
+ }
274
297
  }
275
- // "jsdoc/require-yields": ["error"|"warn", {"forceRequireYields":true}]
276
- // Message: Missing JSDoc @yields declaration.
277
298
 
278
- class quux {
299
+ /**
300
+ * @record
301
+ */
302
+ class Foo {
279
303
  /**
280
- *
304
+ * @yields {string}
281
305
  */
282
- * quux () {
283
- yield;
306
+ * bar () {
284
307
  }
285
308
  }
286
- // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"forceRequireYields":true}]
287
- // Message: Missing JSDoc @yields declaration.
309
+ // Settings: {"jsdoc":{"mode":"closure"}}
288
310
 
289
311
  /**
290
- * @param {array} a
312
+ * @yields {undefined} Foo.
291
313
  */
292
- async function * foo(a) {
293
- yield Promise.all(a);
314
+ function * quux () {
294
315
  }
295
- // Message: Missing JSDoc @yields declaration.
296
316
 
297
317
  /**
298
- * @generator
318
+ * @yields {void} Foo.
299
319
  */
300
- // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"withGeneratorTag":true}]
301
- // Message: Missing JSDoc @yields declaration.
320
+ function * quux () {
321
+ }
302
322
 
303
323
  /**
304
- * @generator
305
- * @yields
324
+ * @yields {never} Foo.
325
+ */
326
+ function * quux () {
327
+ }
328
+
329
+ /**
330
+ * @yields {void} Foo.
306
331
  */
307
- // "jsdoc/require-yields": ["error"|"warn", {"contexts":["any"],"nextWithGeneratorTag":true}]
308
- // Message: Missing JSDoc @next declaration.
332
+ function * quux () {
333
+ yield undefined;
334
+ }
335
+
336
+ /**
337
+ * @yields {void} Foo.
338
+ */
339
+ function * quux () {
340
+ yield;
341
+ }
309
342
 
310
343
  /**
311
344
  *
312
345
  */
313
346
  function * quux () {
314
- if (true) {
315
- yield;
316
- }
317
- yield true;
347
+ yield undefined;
318
348
  }
319
- // Message: Missing JSDoc @yields declaration.
320
349
 
321
350
  /**
322
351
  *
323
352
  */
353
+ function * quux () {
354
+ yield;
355
+ }
356
+
357
+ /**
358
+ * @yields {true}
359
+ */
324
360
  function * quux () {
325
361
  try {
326
362
  yield true;
@@ -328,10 +364,9 @@ function * quux () {
328
364
  }
329
365
  yield;
330
366
  }
331
- // Message: Missing JSDoc @yields declaration.
332
367
 
333
368
  /**
334
- *
369
+ * @yields {true}
335
370
  */
336
371
  function * quux () {
337
372
  try {
@@ -340,10 +375,9 @@ function * quux () {
340
375
  }
341
376
  yield;
342
377
  }
343
- // Message: Missing JSDoc @yields declaration.
344
378
 
345
379
  /**
346
- *
380
+ * @yields {true}
347
381
  */
348
382
  function * quux () {
349
383
  try {
@@ -352,10 +386,9 @@ function * quux () {
352
386
  }
353
387
  yield true;
354
388
  }
355
- // Message: Missing JSDoc @yields declaration.
356
389
 
357
390
  /**
358
- *
391
+ * @yields {true}
359
392
  */
360
393
  function * quux () {
361
394
  try {
@@ -365,10 +398,9 @@ function * quux () {
365
398
  }
366
399
  yield;
367
400
  }
368
- // Message: Missing JSDoc @yields declaration.
369
401
 
370
402
  /**
371
- *
403
+ * @yields {true}
372
404
  */
373
405
  function * quux () {
374
406
  switch (true) {
@@ -377,10 +409,9 @@ function * quux () {
377
409
  }
378
410
  yield;
379
411
  }
380
- // Message: Missing JSDoc @yields declaration.
381
412
 
382
413
  /**
383
- *
414
+ * @yields {true}
384
415
  */
385
416
  function * quux () {
386
417
  switch (true) {
@@ -389,10 +420,9 @@ function * quux () {
389
420
  }
390
421
  yield true;
391
422
  }
392
- // Message: Missing JSDoc @yields declaration.
393
423
 
394
424
  /**
395
- *
425
+ * @yields {true}
396
426
  */
397
427
  function * quux () {
398
428
  for (const i of abc) {
@@ -400,40 +430,36 @@ function * quux () {
400
430
  }
401
431
  yield;
402
432
  }
403
- // Message: Missing JSDoc @yields declaration.
404
433
 
405
434
  /**
406
- *
435
+ * @yields {true}
407
436
  */
408
437
  function * quux () {
409
438
  for (const a in b) {
410
439
  yield true;
411
440
  }
412
441
  }
413
- // Message: Missing JSDoc @yields declaration.
414
442
 
415
443
  /**
416
- *
444
+ * @yields {true}
417
445
  */
418
446
  function * quux () {
419
447
  for (let i=0; i<n; i+=1) {
420
448
  yield true;
421
449
  }
422
450
  }
423
- // Message: Missing JSDoc @yields declaration.
424
451
 
425
452
  /**
426
- *
453
+ * @yields {true}
427
454
  */
428
455
  function * quux () {
429
456
  while(true) {
430
457
  yield true
431
458
  }
432
459
  }
433
- // Message: Missing JSDoc @yields declaration.
434
460
 
435
461
  /**
436
- *
462
+ * @yields {true}
437
463
  */
438
464
  function * quux () {
439
465
  do {
@@ -441,10 +467,9 @@ function * quux () {
441
467
  }
442
468
  while(true)
443
469
  }
444
- // Message: Missing JSDoc @yields declaration.
445
470
 
446
471
  /**
447
- *
472
+ * @yields {true}
448
473
  */
449
474
  function * quux () {
450
475
  if (true) {
@@ -452,20 +477,18 @@ function * quux () {
452
477
  }
453
478
  yield true;
454
479
  }
455
- // Message: Missing JSDoc @yields declaration.
456
480
 
457
481
  /**
458
- *
482
+ * @yields {true}
459
483
  */
460
484
  function * quux () {
461
485
  if (true) {
462
486
  yield true;
463
487
  }
464
488
  }
465
- // Message: Missing JSDoc @yields declaration.
466
489
 
467
490
  /**
468
- *
491
+ * @yields {true}
469
492
  */
470
493
  function * quux () {
471
494
  var a = {};
@@ -473,10 +496,9 @@ function * quux () {
473
496
  yield true;
474
497
  }
475
498
  }
476
- // Message: Missing JSDoc @yields declaration.
477
499
 
478
500
  /**
479
- *
501
+ * @yields {true}
480
502
  */
481
503
  function * quux () {
482
504
  if (true) {
@@ -486,338 +508,37 @@ function * quux () {
486
508
  }
487
509
  yield;
488
510
  }
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
- }
508
-
509
- /**
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
511
 
531
512
  /**
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
551
- */
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
513
  * @next {void}
631
514
  */
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}]
672
-
673
- /** @type {SpecialIterator} */
674
- function * quux () {
675
- yield 5;
676
- }
677
-
678
- /**
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
766
- */
767
515
  function * quux (foo) {
768
516
 
769
- const a = yield foo;
770
517
  }
518
+ // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
771
519
 
772
520
  /**
773
- * @yields
774
- * @next
521
+ * @next {SomeType}
775
522
  */
776
523
  function * quux (foo) {
777
- let a = yield;
524
+ const a = yield;
778
525
  }
779
- // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
526
+ // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
780
527
 
781
528
  /**
782
- * @yields
783
- * @next
529
+ * @next {SomeType}
784
530
  */
785
531
  function * quux (foo) {
786
- const a = yield foo;
787
- }
788
- // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
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;
532
+ const a = yield 5;
811
533
  }
812
- // "jsdoc/require-yields": ["error"|"warn", {"next":true}]
534
+ // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
813
535
 
814
536
  /**
815
- *
537
+ * @next {never}
816
538
  */
817
539
  function * quux (foo) {
818
- const a = function * bar () {
819
- yield foo;
820
- }
540
+
821
541
  }
542
+ // "jsdoc/require-yields-check": ["error"|"warn", {"next":true}]
822
543
  ````
823
544