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 only on exported functions #1137

Closed
ehoogeveen-medweb opened this issue Aug 1, 2023 · 4 comments · Fixed by #1156
Closed

require-returns only on exported functions #1137

ehoogeveen-medweb opened this issue Aug 1, 2023 · 4 comments · Fixed by #1156

Comments

@ehoogeveen-medweb
Copy link

Motivation

We primarily use jsdoc comments to document our types for on-hover information in VSCode. Return types can often be inferred by typescript from the function body (even for javascript code), making @returns annotations redundant (aside from descriptions, which I also consider optional).

Exported functions are an exception: I believe the API surface should be fully documented, and inference across module boundaries is potentially slower as well.

Current behavior

I don't think there is currently a way to automatically require @returns annotations only on exported functions.

Desired behavior

I would like to see an option, e.g. onlyExported, that makes the rule only check exported symbols. I think this option should take precedence over forceRequireReturn or forceReturnsWithAsync.

Alternatives considered

I guess we could use @internal to avoid requiring @returns via the exemptedBy option, but we don't use that currently. I'd like to encourage use of jsdoc comments in our codebase with minimal barrier to entry.

@ehoogeveen-medweb
Copy link
Author

This request applies to require-returns-type as well for the same reason: If you are documenting a return value, the type should only be required for exported symbols.

brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Sep 12, 2023
brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Sep 12, 2023
@brettz9
Copy link
Collaborator

brettz9 commented Sep 12, 2023

I've submitted #1156 for this.

I'm not convinced we really need a require-returns-type equivalent as I think most projects enabling the rule would want a @returns without a type to be reported regardless of its context).

@ehoogeveen-medweb
Copy link
Author

Thanks! I'm sure we can live with adding types for require-returns-type if we feel the need to document a return value for an internal function.

brettz9 added a commit to brettz9/eslint-plugin-jsdoc that referenced this issue Sep 14, 2023
@github-actions
Copy link

🎉 This issue has been resolved in version 46.8.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

voxpelli added a commit to voxpelli/eslint-config that referenced this issue Nov 28, 2023
voxpelli added a commit to voxpelli/eslint-config that referenced this issue Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants