-
-
Couldn't load subscription status.
- Fork 4.8k
Closed
Labels
archived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyESLint is working incorrectlyevaluatingThe team will evaluate this issue to decide whether it meets the criteria for inclusionThe team will evaluate this issue to decide whether it meets the criteria for inclusionruleRelates to ESLint's core rulesRelates to ESLint's core rules
Description
Tell us about your environment
- ESLint Version: 5.0.0-alpha.3
- Node Version: 8.11.2
- npm Version: 5.6.0
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration:
Configuration
module.exports = {
"rules": {
},
"env": {
"es6": true
},
"parserOptions": {
"ecmaVersion": 9,
},
"rules": {
"valid-jsdoc": ["error", {
"prefer": {
"return": "returns",
},
"requireReturn": false,
"requireReturnDescription": false,
}]
}
};What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.
/**
* A comment.
*/
async function foo() {
if (!this.bar) {
return;
}
await this.bar();
}./node_modules/.bin/eslint eslint5.0test.jsWhat did you expect to happen?
No failures
What actually happened? Please include the actual, raw output from ESLint.
eslint4.0test.js
1:1 error Missing JSDoc @returns for function valid-jsdoc
✖ 1 problem (1 error, 0 warnings)This is a possible regression from #10161
Metadata
Metadata
Assignees
Labels
archived due to ageThis issue has been archived; please open a new issue for any further discussionThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlyESLint is working incorrectlyevaluatingThe team will evaluate this issue to decide whether it meets the criteria for inclusionThe team will evaluate this issue to decide whether it meets the criteria for inclusionruleRelates to ESLint's core rulesRelates to ESLint's core rules
Activity
Standard8 commentedon Jun 12, 2018
Now I'm having another look at #10161, I'm seeing that since that has been implemented, async functions must always have a @returns statement in the jsdoc, regardless of the
requireReturnvalue.For a function that is
asyncthe fact it returns a promise is implicit in its definition. Therefore, documentation wise, it could be treated the same as a function that returns nothing.Unfortunately, I'm not quite seeing how making this optional could fit into the current configuration.
So ideas here would be appreciated, /cc @not-an-aardvark @rachx
rachx commentedon Jun 14, 2018
In the original issue, some users suggested that with
requireReturn: false, it should also allow them to add jsdoc descriptions asasyncfunctions returns a promise.To make it optional for
asyncfunction just like constructors and support both preferences, how about check if it is not an async function before reporting missing jsdocs?eslint/lib/rules/valid-jsdoc.js
Lines 407 to 420 in e0a0418
Standard8 commentedon Jun 14, 2018
@rachx now I re-read the docs again(!), I think having returns optional in the
requireReturn:falsecase makes sense.Updating that section seems to make sense as well. Do you want to do a PR for that, or I could do one tomorrow?
rachx commentedon Jun 15, 2018
@Standard8 You can make the PR 👍
Fix: Change valid-jsdoc to allow returns to be optional for async fun…
Fix: valid-jsdoc should allow optional returns for async (fixes eslin…
Update eslint to the latest version 🚀 (#8)
2 remaining items