Skip to content

Commit 71ba9f2

Browse files
committed
test: add back async function quux test with forceRequireReturn (keeping the one with forceReturnsWithAsync as well)
test: add passing test for `forceReturnsWithAsync` on non-async function without requires docs: grammar nit
1 parent 3c15d65 commit 71ba9f2

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

.README/rules/require-returns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Requires returns are documented.
44

5-
By default `async` functions that do not explicitly return a value pass this rule. You can force all `async` functions to require return statements by setting `forceReturnsWithAsync` as true on the options object. This maybe useful as an `async` function will always return a Promise, even if the Promise returns void.
5+
By default `async` functions that do not explicitly return a value pass this rule. You can force all `async` functions to require return statements by setting `forceReturnsWithAsync` as true on the options object. This may be useful as an `async` function will always return a Promise, even if the Promise returns void.
66

77
```js
88
'jsdoc/require-jsdoc': ['error', {forceReturnsWithAsync: true}]

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4564,7 +4564,7 @@ function quux () {
45644564

45654565
Requires returns are documented.
45664566

4567-
By default `async` functions that do not explicitly return a value pass this rule. You can force all `async` functions to require return statements by setting `forceReturnsWithAsync` as true on the options object. This maybe useful as an `async` function will always return a Promise, even if the Promise returns void.
4567+
By default `async` functions that do not explicitly return a value pass this rule. You can force all `async` functions to require return statements by setting `forceReturnsWithAsync` as true on the options object. This may be useful as an `async` function will always return a Promise, even if the Promise returns void.
45684568

45694569
```js
45704570
'jsdoc/require-jsdoc': ['error', {forceReturnsWithAsync: true}]
@@ -4642,6 +4642,13 @@ const quux = async () => {}
46424642
// Settings: {"jsdoc":{"forceRequireReturn":true}}
46434643
// Message: Missing JSDoc @returns declaration.
46444644

4645+
/**
4646+
*
4647+
*/
4648+
async function quux () {}
4649+
// Settings: {"jsdoc":{"forceRequireReturn":true}}
4650+
// Message: Missing JSDoc @returns declaration.
4651+
46454652
/**
46464653
*
46474654
*/
@@ -4915,6 +4922,13 @@ class foo {
49154922
}
49164923

49174924
export default foo;
4925+
4926+
/**
4927+
*
4928+
*/
4929+
function quux () {
4930+
}
4931+
// Options: [{"forceReturnsWithAsync":true}]
49184932
````
49194933

49204934

test/rules/assertions/requireReturns.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,28 @@ export default {
152152
}
153153
}
154154
},
155+
{
156+
code: `
157+
/**
158+
*
159+
*/
160+
async function quux () {}
161+
`,
162+
errors: [
163+
{
164+
line: 2,
165+
message: 'Missing JSDoc @returns declaration.'
166+
}
167+
],
168+
parserOptions: {
169+
ecmaVersion: 8
170+
},
171+
settings: {
172+
jsdoc: {
173+
forceRequireReturn: true
174+
}
175+
}
176+
},
155177
{
156178
code: `
157179
/**
@@ -605,6 +627,18 @@ export default {
605627
parserOptions: {
606628
sourceType: 'module'
607629
}
630+
},
631+
{
632+
code: `
633+
/**
634+
*
635+
*/
636+
function quux () {
637+
}
638+
`,
639+
options: [{
640+
forceReturnsWithAsync: true
641+
}]
608642
}
609643
]
610644
};

0 commit comments

Comments
 (0)