require-returns-description
Require @returns tags to include a human-readable description.
Targeted pattern scopeโ
This rule checks TypeDoc comments on function-like declarations and methods that include a @returns (or @return) tag.
What this rule reportsโ
This rule reports return tags that have no prose description (for example only a type annotation).
Why this rule existsโ
Type annotations alone do not explain semantics. This rule ensures return docs communicate meaning, not just shape.
โ Incorrectโ
/**
* Add values.
* @param left Left value.
* @param right Right value.
* @returns {number}
*/
export function add(left: number, right: number): number {
return left + right;
}
โ Correctโ
/**
* Add values.
* @param left Left value.
* @param right Right value.
* @returns {number} Sum result.
*/
export function add(left: number, right: number): number {
return left + right;
}
Behavior and migration notesโ
No autofix is provided, because semantic return descriptions cannot be generated safely.
ESLint flat config exampleโ
import typedocPlugin from "eslint-plugin-typedoc";
export default [
{
plugins: { typedoc: typedocPlugin },
rules: {
"typedoc/require-returns-description": "error",
},
},
];
When not to use itโ
Disable when return semantics are documented externally and TypeDoc comments are intentionally concise.
Package documentationโ
TypeDoc package documentation:
Further readingโ
Rule catalog ID: R020
Adoption resourcesโ
- Pair with
require-returns-tagfor complete return-tag presence and quality checks.