Require JSDoc Body
Require a body paragraph in JSDoc blocks that explains why the declaration exists.
Summary
The require-jsdoc-body rule reports any JSDoc block that is missing a body paragraph after the summary line. The body paragraph must explain why the declaration exists and meet minimum and maximum line count and line width constraints.
Why Use This Rule?
- Forces authors to explain the purpose behind each declaration, not just restate its name.
- Catches JSDoc blocks that have a summary line but no context for future readers.
- Enforces consistent body length and width so inline documentation stays readable.
Examples
Configuration
Options
warning
ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.
| Option | Type | Default | Description |
|---|---|---|---|
ignoreFiles | string[] | [] | File patterns to skip. |
maxLines | number | 3 | Maximum number of lines allowed in the body. |
maxWidth | number | 80 | Maximum character width allowed per body line. |
minLines | number | 2 | Minimum number of lines required in the body. |
skipDirectories | string[] | [] | Directory names to skip. |
Autofix
Autofix is not available for this rule. Flagged code must be updated manually.
Troubleshooting
- Warning fires even though a body is present — Check that the body paragraph is separated from the summary line by a blank
*line. Text immediately after the summary is treated as part of the summary, not as body text. - Body too short or too long — Adjust
minLinesandmaxLinesto match your project's documentation standards. - Line too wide — The
maxWidthoption defaults to80characters per body line. Wrap long sentences to stay within the limit. - Want to skip specific files — Use the
ignoreFilesoption to exclude files that do not need body paragraphs.