@@ -13737,11 +13737,26 @@ in jsdoc comment.
1373713737
1373813738Will also report if multiple ` @returns ` tags are present.
1373913739
13740+ <a name =" eslint-plugin-jsdoc-rules-require-returns-check-options-27 " ></a >
13741+ #### Options
13742+
13743+ - ` exemptAsync ` - By default, functions which return a ` Promise ` that are not
13744+ detected as resolving with a non-` undefined ` value and ` async ` functions
13745+ (even ones that do not explicitly return a value, as these are returning a
13746+ ` Promise ` implicitly) will be exempted from reporting by this rule.
13747+ If you wish to insist that only ` Promise ` 's which resolve to
13748+ non-` undefined ` values or ` async ` functions with explicit ` return ` 's will
13749+ be exempted from reporting (i.e., that ` async ` functions can be reported
13750+ if they lack an explicit (non-` undefined ` ) ` return ` when a ` @returns ` is
13751+ present), you can set ` exemptAsync ` to ` false ` on the options object.
13752+ Defaults to ` true ` .
13753+
1374013754|||
1374113755| ---| ---|
1374213756| Context| ` ArrowFunctionExpression ` , ` FunctionDeclaration ` , ` FunctionExpression ` |
1374313757| Tags| ` returns ` |
1374413758| Aliases| ` return ` |
13759+ | Options| ` exemptAsync ` |
1374513760| Recommended| true|
1374613761
1374713762The following patterns are considered problems:
@@ -13822,6 +13837,35 @@ function f () {
1382213837 }
1382313838}
1382413839// Message: JSDoc @returns declaration present but return expression not available in function.
13840+
13841+ /**
13842+ * @returns {Promise<void>}
13843+ */
13844+ async function quux () {}
13845+ // Options: [{"exemptAsync":false}]
13846+ // Message: JSDoc @returns declaration present but return expression not available in function.
13847+
13848+ /**
13849+ * @returns {Promise<void>}
13850+ */
13851+ function quux () {
13852+ return new Promise ((resolve , reject ) => {})
13853+ }
13854+ // Options: [{"exemptAsync":false}]
13855+ // Message: JSDoc @returns declaration present but return expression not available in function.
13856+
13857+ /**
13858+ * @returns {Promise<void>}
13859+ */
13860+ function quux () {
13861+ return new Promise ((resolve , reject ) => {
13862+ setTimeout (() => {
13863+ resolve ();
13864+ });
13865+ })
13866+ }
13867+ // Options: [{"exemptAsync":false}]
13868+ // Message: JSDoc @returns declaration present but return expression not available in function.
1382513869````
1382613870
1382713871The following patterns are not considered problems:
@@ -14127,6 +14171,26 @@ function quux () {
1412714171 }
1412814172 return ;
1412914173}
14174+
14175+ /**
14176+ * @returns {Promise<void>}
14177+ */
14178+ async function quux () {
14179+ return 5 ;
14180+ }
14181+ // Options: [{"exemptAsync":false}]
14182+
14183+ /**
14184+ * @returns {Promise<void>}
14185+ */
14186+ function quux () {
14187+ return new Promise ((resolve , reject ) => {
14188+ setTimeout (() => {
14189+ resolve (true );
14190+ });
14191+ })
14192+ }
14193+ // Options: [{"exemptAsync":false}]
1413014194````
1413114195
1413214196
@@ -14137,10 +14201,10 @@ Requires that the `@returns` tag has a `description` value. The error
1413714201will not be reported if the return value is ` void ` or ` undefined `
1413814202or if it is ` Promise<void> ` or ` Promise<undefined> ` .
1413914203
14140- <a name =" eslint-plugin-jsdoc-rules-require-returns-description-options-27 " ></a >
14204+ <a name =" eslint-plugin-jsdoc-rules-require-returns-description-options-28 " ></a >
1414114205#### Options
1414214206
14143- <a name =" eslint-plugin-jsdoc-rules-require-returns-description-options-27 -contexts-10 " ></a >
14207+ <a name =" eslint-plugin-jsdoc-rules-require-returns-description-options-28 -contexts-10 " ></a >
1414414208##### <code >contexts</code >
1414514209
1414614210Set this to an array of strings representing the AST context
@@ -14293,10 +14357,10 @@ function quux () {
1429314357
1429414358Requires that ` @returns ` tag has ` type ` value.
1429514359
14296- <a name =" eslint-plugin-jsdoc-rules-require-returns-type-options-28 " ></a >
14360+ <a name =" eslint-plugin-jsdoc-rules-require-returns-type-options-29 " ></a >
1429714361#### Options
1429814362
14299- <a name =" eslint-plugin-jsdoc-rules-require-returns-type-options-28 -contexts-11 " ></a >
14363+ <a name =" eslint-plugin-jsdoc-rules-require-returns-type-options-29 -contexts-11 " ></a >
1430014364##### <code >contexts</code >
1430114365
1430214366Set this to an array of strings representing the AST context
@@ -14416,7 +14480,7 @@ Requires that returns are documented.
1441614480
1441714481Will also report if multiple ` @returns ` tags are present.
1441814482
14419- <a name =" eslint-plugin-jsdoc-rules-require-returns-options-29 " ></a >
14483+ <a name =" eslint-plugin-jsdoc-rules-require-returns-options-30 " ></a >
1442014484#### Options
1442114485
1442214486- ` checkConstructors ` - A value indicating whether ` constructor ` s should
@@ -15436,7 +15500,7 @@ async function foo() {
1543615500
1543715501Requires that throw statements are documented.
1543815502
15439- <a name =" eslint-plugin-jsdoc-rules-require-throws-options-30 " ></a >
15503+ <a name =" eslint-plugin-jsdoc-rules-require-throws-options-31 " ></a >
1544015504#### Options
1544115505
1544215506- ` exemptedBy ` - Array of tags (e.g., ` ['type'] ` ) whose presence on the
@@ -15711,7 +15775,7 @@ Will also report if multiple `@yields` tags are present.
1571115775See the ` next ` , ` forceRequireNext ` , and ` nextWithGeneratorTag ` options for an
1571215776option to expect a non-standard ` @next ` tag.
1571315777
15714- <a name =" eslint-plugin-jsdoc-rules-require-yields-options-31 " ></a >
15778+ <a name =" eslint-plugin-jsdoc-rules-require-yields-options-32 " ></a >
1571515779#### Options
1571615780
1571715781- ` exemptedBy ` - Array of tags (e.g., ` ['type'] ` ) whose presence on the
@@ -16511,7 +16575,7 @@ function bodies.
1651116575
1651216576Will also report if multiple ` @yields ` tags are present.
1651316577
16514- <a name =" eslint-plugin-jsdoc-rules-require-yields-check-options-32 " ></a >
16578+ <a name =" eslint-plugin-jsdoc-rules-require-yields-check-options-33 " ></a >
1651516579#### Options
1651616580
1651716581- ` checkGeneratorsOnly ` - Avoids checking the function body and merely insists
@@ -17064,7 +17128,7 @@ for valid types (based on the tag's `type` value), and either portion checked
1706417128for presence (based on ` false ` ` name ` or ` type ` values or their ` required `
1706517129value). See the setting for more details.
1706617130
17067- <a name =" eslint-plugin-jsdoc-rules-valid-types-options-33 " ></a >
17131+ <a name =" eslint-plugin-jsdoc-rules-valid-types-options-34 " ></a >
1706817132#### Options
1706917133
1707017134- ` allowEmptyNamepaths ` (default: true) - Set to ` false ` to bulk disallow
0 commit comments