55* [ Options] ( #user-content-require-returns-check-options )
66 * [ ` exemptAsync ` ] ( #user-content-require-returns-check-options-exemptasync )
77 * [ ` exemptGenerators ` ] ( #user-content-require-returns-check-options-exemptgenerators )
8+ * [ ` noNativeTypes ` ] ( #user-content-require-returns-check-options-nonativetypes )
89 * [ ` reportMissingReturnForUndefinedTypes ` ] ( #user-content-require-returns-check-options-reportmissingreturnforundefinedtypes )
910* [ Context and settings] ( #user-content-require-returns-check-context-and-settings )
1011* [ Failing examples] ( #user-content-require-returns-check-failing-examples )
@@ -20,6 +21,8 @@ Will also report `@returns {void}` and `@returns {undefined}` if `exemptAsync`
2021is set to ` false ` and a non-` undefined ` value is returned or a resolved value
2122is found. Also reports if ` @returns {never} ` is discovered with a return value.
2223
24+ Will report if native types are specified for ` @returns ` on an async function.
25+
2326Will also report if multiple ` @returns ` tags are present.
2427
2528<a name =" user-content-require-returns-check-options " ></a >
@@ -54,6 +57,13 @@ option is therefore `true` by default in `typescript` mode (in "jsdoc" mode,
5457one might be more likely to take advantage of ` @yields ` ). Set it to ` false `
5558if you wish for a missing ` return ` to be flagged regardless.
5659
60+ <a name =" user-content-require-returns-check-options-nonativetypes " ></a >
61+ <a name =" require-returns-check-options-nonativetypes " ></a >
62+ ### <code >noNativeTypes</code >
63+
64+ Whether to check that async functions do not
65+ indicate they return non-native types. Defaults to ` true ` .
66+
5767<a name =" user-content-require-returns-check-options-reportmissingreturnforundefinedtypes " ></a >
5868<a name =" require-returns-check-options-reportmissingreturnforundefinedtypes " ></a >
5969### <code >reportMissingReturnForUndefinedTypes</code >
@@ -74,7 +84,7 @@ Unlike `require-returns`, with this option in the rule, one can
7484| Context| ` ArrowFunctionExpression ` , ` FunctionDeclaration ` , ` FunctionExpression ` |
7585| Tags| ` returns ` |
7686| Aliases| ` return ` |
77- | Options| ` exemptAsync ` , ` exemptGenerators ` , ` reportMissingReturnForUndefinedTypes ` |
87+ | Options| ` exemptAsync ` , ` exemptGenerators ` , ` noNativeTypes ` , ` reportMissingReturnForUndefinedTypes ` |
7888| Recommended| true|
7989
8090<a name =" user-content-require-returns-check-failing-examples " ></a >
@@ -206,7 +216,7 @@ function quux() {
206216
207217/**
208218 * Description.
209- * @returns {string }
219+ * @returns {SomeType }
210220 */
211221async function foo() {
212222 return new Promise (resolve => resolve ());
@@ -401,6 +411,15 @@ function foo() {
401411 }
402412}
403413// Message: JSDoc @returns declaration present but return expression not available in function.
414+
415+ /**
416+ * @returns {number}
417+ */
418+ async function quux (foo ) {
419+
420+ }
421+ // "jsdoc/require-returns-check": ["error"|"warn", {"exemptAsync":false}]
422+ // Message: Function is async or otherwise returns a Promise but the return type is a native type.
404423````
405424
406425
0 commit comments