Skip to content

Commit 41d1cf3

Browse files
committed
fix(require-returns): regression with forcing all async returns to be ignored; fixes #1019
1 parent b23a587 commit 41d1cf3

File tree

3 files changed

+56
-21
lines changed

3 files changed

+56
-21
lines changed

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20446,6 +20446,22 @@ export function readFixture(path: string): void;
2044620446
export function readFixture(path: string);
2044720447
// "jsdoc/require-returns": ["error"|"warn", {"forceRequireReturn":true}]
2044820448
// Message: Missing JSDoc @returns declaration.
20449+
20450+
/**
20451+
* @param {array} a
20452+
*/
20453+
async function foo(a) {
20454+
return Promise.all(a);
20455+
}
20456+
// Message: Missing JSDoc @returns declaration.
20457+
20458+
/**
20459+
* Description.
20460+
*/
20461+
export default async function demo() {
20462+
return true;
20463+
}
20464+
// Message: Missing JSDoc @returns declaration.
2044920465
````
2045020466

2045120467
The following patterns are not considered problems:
@@ -20930,13 +20946,6 @@ async function foo() {
2093020946
return new Promise(resolve => resolve());
2093120947
}
2093220948

20933-
/**
20934-
* @param {array} a
20935-
*/
20936-
async function foo(a) {
20937-
return Promise.all(a);
20938-
}
20939-
2094020949
/**
2094120950
* @param ms time in millis
2094220951
*/

src/rules/requireReturns.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default iterateJsdoc(({
9090
return true;
9191
}
9292

93-
return !isAsync && iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(
93+
return iteratingFunction && utils.hasValueOrExecutorHasNonEmptyResolveValue(
9494
forceReturnsWithAsync,
9595
);
9696
};

test/rules/assertions/requireReturns.js

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,45 @@ export default {
17261726
],
17271727
parser: require.resolve('@typescript-eslint/parser'),
17281728
},
1729+
{
1730+
code: `
1731+
/**
1732+
* @param {array} a
1733+
*/
1734+
async function foo(a) {
1735+
return Promise.all(a);
1736+
}
1737+
`,
1738+
errors: [
1739+
{
1740+
line: 2,
1741+
message: 'Missing JSDoc @returns declaration.',
1742+
},
1743+
],
1744+
parserOptions: {
1745+
ecmaVersion: 8,
1746+
},
1747+
},
1748+
{
1749+
code: `
1750+
/**
1751+
* Description.
1752+
*/
1753+
export default async function demo() {
1754+
return true;
1755+
}
1756+
`,
1757+
errors: [
1758+
{
1759+
line: 2,
1760+
message: 'Missing JSDoc @returns declaration.',
1761+
},
1762+
],
1763+
parserOptions: {
1764+
ecmaVersion: 8,
1765+
sourceType: 'module',
1766+
},
1767+
},
17291768
],
17301769
valid: [
17311770
{
@@ -2562,19 +2601,6 @@ export default {
25622601
],
25632602
parser: require.resolve('@typescript-eslint/parser'),
25642603
},
2565-
{
2566-
code: `
2567-
/**
2568-
* @param {array} a
2569-
*/
2570-
async function foo(a) {
2571-
return Promise.all(a);
2572-
}
2573-
`,
2574-
parserOptions: {
2575-
ecmaVersion: 8,
2576-
},
2577-
},
25782604
{
25792605
code: `
25802606
/**

0 commit comments

Comments
 (0)