Getting Started
eslint-plugin-tsdoc-require-2 is easiest to adopt in layers:
- Require docs to exist with
tsdoc-require-2/require. - Require specific tags with one or more
require-*rules. - Restrict allowed tag vocabulary with
tsdoc-require-2/restrict-tags.
Starting from a preset gives you a stable baseline before you tune rule options.
1) Installâ
npm install --save-dev eslint-plugin-tsdoc-require-2
2) Choose one preset baselineâ
Pick one preset as your starting point:
| Preset | Best for |
|---|---|
recommended | Minimal rollout: require TSDoc comments only. |
detailed | Require comments + @remarks for richer docs. |
packages | Package/library docs including @packageDocumentation. |
jsdoc | Function-tag baseline (@param, @returns, @throws) with JSDoc-friendly behavior. |
tsdoc | Strong TSDoc baseline with tag requirements + compatibility-tag restrictions. |
typedoc | TypeDoc-oriented declaration-kind tag enforcement. |
typedoc-strict | Stricter TypeDoc baseline with module remarks and restricted tags. |
all | Every rule. Useful for audits, usually too strict for day-one adoption. |
3) Enable a preset in Flat Configâ
import tsdocRequire from "eslint-plugin-tsdoc-require-2";
export default [tsdocRequire.configs.recommended];
4) Add targeted overrides (recommended)â
After selecting a preset, add a second config block to tune scope/options.
import tsdocRequire from "eslint-plugin-tsdoc-require-2";
export default [
tsdocRequire.configs.tsdoc,
{
rules: {
"tsdoc-require-2/require": [
"error",
{
exportMode: "all",
},
],
"tsdoc-require-2/restrict-tags": [
"error",
{
exportMode: "all",
mode: "deny",
tags: ["@typedef", "@callback"],
},
],
},
},
];
How to use the rules togetherâ
Treat the rules as a pipeline:
- Presence layer:
requireensures there is a TSDoc block. - Content layer:
require-*tag rules enforce required fields (for example@param). - Vocabulary layer:
restrict-tagsblocks unsupported tags.
Important composition tipâ
Keep exportMode and enforceFor aligned across rules. If one rule checks only exported declarations but another checks all declarations, your policy can feel inconsistent.
Important allow-mode tipâ
When using restrict-tags with mode: "allow", include every tag required by enabled require-* rules, or the rules will conflict.
Suggested rollout strategyâ
- Start with
recommended. - Add only the tag rules your team can consistently maintain (
@param,@returns,@throws,@remarksare common first picks). - Add
restrict-tagsonly after your required-tag policy is stable. - Expand from
exportMode: "exported"to"all"when internal documentation quality is a goal.
Next stepsâ
- Compare presets in Presets Overview.
- Review Rules Overview.
- Learn the foundational rule in
tsdoc-require-2/require.