Skip to content

require-returns only on exported functions #1137

@ehoogeveen-medweb

Description

@ehoogeveen-medweb

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions