@@ -12,6 +12,7 @@ JSDoc linting rules for ESLint.
12
12
* [ Installation] ( #eslint-plugin-jsdoc-installation )
13
13
* [ Configuration] ( #eslint-plugin-jsdoc-configuration )
14
14
* [ Settings] ( #eslint-plugin-jsdoc-settings )
15
+ * [ Mode] ( #eslint-plugin-jsdoc-settings-mode )
15
16
* [ Allow ` @private ` to disable rules for that comment block] ( #eslint-plugin-jsdoc-settings-allow-private-to-disable-rules-for-that-comment-block )
16
17
* [ Alias Preference] ( #eslint-plugin-jsdoc-settings-alias-preference )
17
18
* [ ` @override ` /` @augments ` /` @extends ` /` @implements ` Without Accompanying ` @param ` /` @description ` /` @example ` /` @returns ` ] ( #eslint-plugin-jsdoc-settings-override-augments-extends-implements-without-accompanying-param-description-example-returns )
@@ -122,6 +123,13 @@ You can then selectively add to or override the recommended rules.
122
123
<a name =" eslint-plugin-jsdoc-settings " ></a >
123
124
## Settings
124
125
126
+ <a name =" eslint-plugin-jsdoc-settings-mode " ></a >
127
+ ### Mode
128
+
129
+ While TypeScript and the Google Closure Compiler (GCC) support some jsdoc tags,
130
+ there are some differences. The ` settings.jsdoc.mode ` lets you choose the precise
131
+ mode (` "typescript" ` , ` "gcc" ` , or ` "jsdoc" ` (the default)).
132
+
125
133
<a name =" eslint-plugin-jsdoc-settings-allow-private-to-disable-rules-for-that-comment-block " ></a >
126
134
### Allow <code >@private </code > to disable rules for that comment block
127
135
@@ -6324,6 +6332,21 @@ Requires a return statement in function body if a `@returns` tag is specified in
6324
6332
6325
6333
Will also report if multiple `@returns` tags are present.
6326
6334
6335
+ <a name="eslint-plugin-jsdoc-rules-require-returns-check-options-12"></a>
6336
+ #### Options
6337
+
6338
+ <a name="eslint-plugin-jsdoc-rules-require-returns-check-options-12-yieldasreturn"></a>
6339
+ ##### <code>yieldAsReturn</code>
6340
+
6341
+ If the setting `settings.jsdoc.mode` is set to `typescript` or `gcc`, this option
6342
+ will allow `yield` statements to be treated as `@returns` for the purposes of this
6343
+ rule. (If the mode is instead ` jsdoc` , then this option will have no effect , since
6344
+ the jsdoc approach is to instead use the ` @yields` tag .)
6345
+
6346
+ The allowable values are `"always"` which will treat any `yield` as a `return`,
6347
+ or `argument`, which will only treat a `yield` as a `return` when `yield` is
6348
+ followed by an argument.
6349
+
6327
6350
|||
6328
6351
|---|---|
6329
6352
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
@@ -6394,6 +6417,59 @@ function quux () {
6394
6417
}
6395
6418
// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
6396
6419
// Message: Unexpected tag `@returns`
6420
+
6421
+ /**
6422
+ *
6423
+ * @returns {boolean}
6424
+ */
6425
+ function * quux () {
6426
+ }
6427
+ // Settings: {"jsdoc":{"mode":"typescript"}}
6428
+ // Options: [{"yieldAsReturn":"always"}]
6429
+ // Message: JSDoc @returns declaration present but return expression not available in function.
6430
+
6431
+ /**
6432
+ *
6433
+ * @returns {boolean}
6434
+ */
6435
+ function * quux () {
6436
+ }
6437
+ // Settings: {"jsdoc":{"mode":"typescript"}}
6438
+ // Options: [{"yieldAsReturn":"argument"}]
6439
+ // Message: JSDoc @returns declaration present but return expression not available in function.
6440
+
6441
+ /**
6442
+ *
6443
+ * @returns {boolean}
6444
+ */
6445
+ function * quux () {
6446
+ yield ;
6447
+ }
6448
+ // Settings: {"jsdoc":{"mode":"typescript"}}
6449
+ // Options: [{"yieldAsReturn":"argument"}]
6450
+ // Message: JSDoc @returns declaration present but return expression not available in function.
6451
+
6452
+ /**
6453
+ *
6454
+ * @returns {boolean}
6455
+ */
6456
+ function * quux () {
6457
+ var a = 5 , b = yield ;
6458
+ }
6459
+ // Settings: {"jsdoc":{"mode":"typescript"}}
6460
+ // Options: [{"yieldAsReturn":"argument"}]
6461
+ // Message: JSDoc @returns declaration present but return expression not available in function.
6462
+
6463
+ /**
6464
+ *
6465
+ * @returns {boolean}
6466
+ */
6467
+ function * quux () {
6468
+ yield true ;
6469
+ }
6470
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
6471
+ // Options: [{"yieldAsReturn":"always"}]
6472
+ // Message: JSDoc @returns declaration present but return expression not available in function.
6397
6473
` ` ` `
6398
6474
6399
6475
The following patterns are not considered problems:
@@ -6650,6 +6726,46 @@ function quux () {
6650
6726
}
6651
6727
return ;
6652
6728
}
6729
+
6730
+ /**
6731
+ *
6732
+ * @returns {boolean}
6733
+ */
6734
+ function * quux () {
6735
+ yield true ;
6736
+ }
6737
+ // Settings: {"jsdoc":{"mode":"typescript"}}
6738
+ // Options: [{"yieldAsReturn":"always"}]
6739
+
6740
+ /**
6741
+ *
6742
+ * @returns {boolean}
6743
+ */
6744
+ function * quux () {
6745
+ return true ;
6746
+ }
6747
+ // Settings: {"jsdoc":{"mode":"typescript"}}
6748
+ // Options: [{"yieldAsReturn":"always"}]
6749
+
6750
+ /**
6751
+ *
6752
+ * @returns {boolean}
6753
+ */
6754
+ function * quux () {
6755
+ yield true ;
6756
+ }
6757
+ // Settings: {"jsdoc":{"mode":"typescript"}}
6758
+ // Options: [{"yieldAsReturn":"argument"}]
6759
+
6760
+ /**
6761
+ *
6762
+ * @returns {boolean}
6763
+ */
6764
+ function * quux () {
6765
+ var a = 5 , b = yield true ;
6766
+ }
6767
+ // Settings: {"jsdoc":{"mode":"typescript"}}
6768
+ // Options: [{"yieldAsReturn":"argument"}]
6653
6769
````
6654
6770
6655
6771
@@ -6795,7 +6911,7 @@ Requires returns are documented.
6795
6911
6796
6912
Will also report if multiple ` @returns ` tags are present.
6797
6913
6798
- <a name =" eslint-plugin-jsdoc-rules-require-returns-options-12 " ></a >
6914
+ <a name =" eslint-plugin-jsdoc-rules-require-returns-options-13 " ></a >
6799
6915
#### Options
6800
6916
6801
6917
- ` exemptedBy ` - Array of tags (e.g., ` ['type'] ` ) whose presence on the document
@@ -7251,7 +7367,7 @@ Also impacts behaviors on namepath (or event)-defining and pointing tags:
7251
7367
allow ` # ` , ` . ` , or ` ~ ` at the end (which is not allowed at the end of
7252
7368
normal paths).
7253
7369
7254
- <a name =" eslint-plugin-jsdoc-rules-valid-types-options-13 " ></a >
7370
+ <a name =" eslint-plugin-jsdoc-rules-valid-types-options-14 " ></a >
7255
7371
#### Options
7256
7372
7257
7373
- ` allowEmptyNamepaths ` (default: true) - Set to ` false ` to disallow
0 commit comments