tsdoc-require-2/require-function
Require the @function tag in TSDoc blocks for supported TypeScript declarations.
Rule detailsâ
This rule reports declarations that already have TSDoc but do not contain @function.
It does not create a TSDoc block. Pair it with tsdoc-require-2/require when you also want to require comments.
Why use itâ
@function can help teams and doc generators that expect explicit declaration-kind tags.
Optionsâ
This rule accepts the same options as tsdoc-require-2/require:
enforceFor: limit which declaration kinds are checked.exportMode: choose whether to check exported declarations, non-exported top-level declarations, or both.includeNonExported: legacy alias forexportMode: "all".
Flat config example (function-only scope):
import tsdocRequire from "eslint-plugin-tsdoc-require-2";
export default [
{
plugins: {
"tsdoc-require-2": tsdocRequire,
},
rules: {
"tsdoc-require-2/require-function": ["error", { enforceFor: ["function"] }],
},
},
];
â Incorrectâ
/**
* Creates a stable slug for a title.
*/
export function toSlug(value: string): string {
return value.trim().toLowerCase();
}
â Correctâ
/**
* Creates a stable slug for a title.
*
* @function
*/
export function toSlug(value: string): string {
return value.trim().toLowerCase();
}
When not to use itâ
Disable this rule if your documentation convention does not require @function on the declarations targeted by your configuration.