Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsdoc/require-returns emits a warning for function returning Promise<void> #845

Closed
Properko opened this issue Feb 28, 2022 · 1 comment
Closed

Comments

@Properko
Copy link

Properko commented Feb 28, 2022

Expected behavior

jsdoc/require-returns should not emit a warning because the return type is Promise<void>.

Actual behavior

1:1 warning Missing JSDoc @returns declaration jsdoc/require-returns.
Happens even if the function is declared async explicitly. Without the <void>, the return type is inferred to be Promise<unknown> in which case the warning makes sense. Is this type knowledge lost to jsdoc in this case?

ESLint Config

{
  "root": true,
  "extends": [
    "plugin:@typescript-eslint/recommended",
    "plugin:jsdoc/recommended"
  ],
  "env": {
    "es6": true,
    "node": true
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module"
  },
  "rules": {
    "jsdoc/no-types": "warn",
    "jsdoc/require-param-type": 0,
    "jsdoc/require-returns-type": 0
  },
  "plugins": ["@typescript-eslint", "jsdoc"]
}

ESLint sample

/**
 * @param ms time in millis
 */
export const sleep = (ms: number) =>
  new Promise<void>((res) => setTimeout(res, ms));

The warning can be fixed by adding @returns nothing to the jsdoc above.

Environment

  • Node version: 14.18.1
  • ESLint version: 8.10.0
  • eslint-plugin-jsdoc version: 37.9.4
@gajus
Copy link
Owner

gajus commented Feb 28, 2022

🎉 This issue has been resolved in version 37.9.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@gajus gajus added the released label Feb 28, 2022
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this issue Mar 8, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) | devDependencies | patch | [`37.9.4` -> `37.9.5`](https://renovatebot.com/diffs/npm/eslint-plugin-jsdoc/37.9.4/37.9.5) |

---

### Release Notes

<details>
<summary>gajus/eslint-plugin-jsdoc</summary>

### [`v37.9.5`](https://github.com/gajus/eslint-plugin-jsdoc/releases/v37.9.5)

[Compare Source](gajus/eslint-plugin-jsdoc@v37.9.4...v37.9.5)

##### Bug Fixes

-   stop reporting `async` function (unless with `forceReturnsWithAsync`) or Promise return with void type parameter; fixes [#&#8203;845](gajus/eslint-plugin-jsdoc#845) ([509baf9](gajus/eslint-plugin-jsdoc@509baf9))

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox.

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1191
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants