require-returns-tag
Require @returns tags for documented declarations with non-void return types.
Targeted pattern scopeโ
This rule checks documented function declarations, declared functions, and methods that have explicit non-void return types.
What this rule reportsโ
This rule reports documented declarations with non-void return types when their TypeDoc block does not include @returns (or @return).
Why this rule existsโ
Return value documentation is part of API usability. Missing @returns tags make generated docs incomplete and increase onboarding friction for API consumers.
โ Incorrectโ
/**
* Build a cache key for a user id.
*/
export function toCacheKey(userId: string): string {
return `user:${userId}`;
}
โ Correctโ
/**
* Build a cache key for a user id.
* @returns Stable cache key for storage lookups.
*/
export function toCacheKey(userId: string): string {
return `user:${userId}`;
}
Behavior and migration notesโ
Autofix inserts a TODO @returns line into the existing doc block so teams can capture missing return semantics incrementally.
ESLint flat config exampleโ
import typedocPlugin from "eslint-plugin-typedoc";
export default [
{
plugins: { typedoc: typedocPlugin },
rules: {
"typedoc/require-returns-tag": "error",
},
},
];
When not to use itโ
Disable this rule for internal codebases where return semantics are intentionally inferred from types alone and generated docs are not consumed.
Package documentationโ
TypeDoc package documentation:
Further readingโ
Rule catalog ID: R005
Adoption resourcesโ
- Enable this rule after
require-param-tagswhen your team is ready for stricter API completeness.