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

require-returns-check: warns for @returns union with undefined #925

Closed
kevinoid opened this issue Oct 23, 2022 · 1 comment
Closed

require-returns-check: warns for @returns union with undefined #925

kevinoid opened this issue Oct 23, 2022 · 1 comment

Comments

@kevinoid
Copy link

Expected behavior

jsdoc/require-returns-check should not produce a warning or error for functions with @returns types which include undefined.

Actual behavior

The following warning is produced:

1:1  warning  JSDoc @returns declaration present but return expression not available in function  jsdoc/require-returns-check

ESLint Config

{
  "extends": [
    "plugin:jsdoc/recommended"
  ]
}

ESLint sample

/** Maybe return a boolean.
 *
 * @returns {boolean|undefined} true, or undefined.
 */
function maybeTrue() {
  if (Math.random() > 0.5) {
    return true;
  }
}

Environment

  • Node version: v18.10.0
  • ESLint version v8.26.0
  • eslint-plugin-jsdoc version: 39.3.22

Related Issues

#924

Additional Notes

I noticed the same issue occurs with @returns {boolean=}, but I'm not sure whether = is allowed in @returns types. It's only documented to signify optional parameters, not optional return values, as far as I can see.

@gajus
Copy link
Owner

gajus commented Oct 24, 2022

🎉 This issue has been resolved in version 39.3.24 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

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

---

### Release Notes

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

### [`v39.3.24`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.24)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.23...v39.3.24)

##### Bug Fixes

-   **`require-returns-check`, `require-yields-check`:** check for undefined/void within union; fixes [#&#8203;925](gajus/eslint-plugin-jsdoc#925) ([cfbdf8b](gajus/eslint-plugin-jsdoc@cfbdf8b))

### [`v39.3.23`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.23)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.22...v39.3.23)

##### Bug Fixes

-   **`require-returns-check`:** allow implicit-return finally if other try-catch branches returning; fixes [#&#8203;926](gajus/eslint-plugin-jsdoc#926) ([12da503](gajus/eslint-plugin-jsdoc@12da503))

### [`v39.3.22`](https://github.com/gajus/eslint-plugin-jsdoc/releases/tag/v39.3.22)

[Compare Source](gajus/eslint-plugin-jsdoc@v39.3.21...v39.3.22)

##### Bug Fixes

-   **`valid-types`:** report problems with name parsing ([e247d67](gajus/eslint-plugin-jsdoc@e247d67))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - 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).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMy4xLjAiLCJ1cGRhdGVkSW5WZXIiOiIzMy4xLjAifQ==-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1603
Reviewed-by: Epsilon_02 <epsilon_02@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