Skip to content

Commit 99476af

Browse files
committedMay 18, 2020
fix(require-returns): async with return should be documented; fixes #518
1 parent 176be5d commit 99476af

File tree

3 files changed

+28
-21
lines changed

3 files changed

+28
-21
lines changed
 

‎README.md

+8-7
Original file line numberDiff line numberDiff line change
@@ -12209,6 +12209,14 @@ class quux {
1220912209
}
1221012210
// Options: [{"contexts":["any"],"forceRequireReturn":true}]
1221112211
// Message: Missing JSDoc @returns declaration.
12212+
12213+
/**
12214+
* @param {array} a
12215+
*/
12216+
async function foo(a) {
12217+
return Promise.all(a);
12218+
}
12219+
// Message: Missing JSDoc @returns declaration.
1221212220
````
1221312221
1221412222
The following patterns are not considered problems:
@@ -12487,13 +12495,6 @@ function quux () {
1248712495
}
1248812496
// Options: [{"exemptedBy":["type"]}]
1248912497
12490-
/**
12491-
* @param {array} a
12492-
*/
12493-
async function foo(a) {
12494-
return Promise.all(a);
12495-
}
12496-
1249712498
/**
1249812499
* @param {array} a
1249912500
*/

‎src/rules/requireReturns.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export default iterateJsdoc(({
8888
return true;
8989
}
9090

91-
return !isAsync && iteratingFunction && utils.hasReturnValue();
91+
return iteratingFunction && utils.hasReturnValue();
9292
};
9393

9494
if (shouldReport()) {

‎test/rules/assertions/requireReturns.js

+19-13
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,25 @@ export default {
529529
forceRequireReturn: true,
530530
}],
531531
},
532+
{
533+
code: `
534+
/**
535+
* @param {array} a
536+
*/
537+
async function foo(a) {
538+
return Promise.all(a);
539+
}
540+
`,
541+
errors: [
542+
{
543+
line: 2,
544+
message: 'Missing JSDoc @returns declaration.',
545+
},
546+
],
547+
parserOptions: {
548+
ecmaVersion: 8,
549+
},
550+
},
532551
],
533552
valid: [
534553
{
@@ -963,19 +982,6 @@ export default {
963982
},
964983
],
965984
},
966-
{
967-
code: `
968-
/**
969-
* @param {array} a
970-
*/
971-
async function foo(a) {
972-
return Promise.all(a);
973-
}
974-
`,
975-
parserOptions: {
976-
ecmaVersion: 8,
977-
},
978-
},
979985
{
980986
code: `
981987
/**

0 commit comments

Comments
 (0)
Please sign in to comment.