Skip to main content

require-exported-doc-comment

Require exported declarations to include a leading TypeDoc comment block.

Targeted pattern scopeโ€‹

This rule targets exported declarations that TypeDoc commonly documents, including:

  • exported functions and classes
  • exported interfaces, type aliases, enums, and namespaces
  • exported variable declarations

What this rule reportsโ€‹

This rule reports exported declarations that do not have an adjacent leading TypeDoc block comment.

Why this rule existsโ€‹

Public exports define your documented API surface. Missing comments on exports produce gaps in generated docs and make API intent harder to understand.

โŒ Incorrectโ€‹

export function createClient(): void {}

โœ… Correctโ€‹

/**
* Create the primary API client.
*/
export function createClient(): void {}

Behavior and migration notesโ€‹

This rule does not apply changes during --fix.

It provides an editor suggestion that inserts a minimal documentation stub (for example: buildClient API documentation.) so authors can replace it with real API intent.

By default, this rule ignores non-production paths:

  • test/**, tests/**
  • benchmark/**, benchmarks/**
  • fixture/**, fixtures/**
  • temp/**, coverage/**, dist/**, build/**, generated/**

Use ignorePatterns to override those defaults, and ignoreDeclarationFiles: true when declaration outputs should be skipped.

Rule options:

type RuleOptions = [
{
ignoreDeclarationFiles?: boolean;
ignorePatterns?: string[];
}?
];

ESLint flat config exampleโ€‹

import typedocPlugin from "eslint-plugin-typedoc";

export default [
{
plugins: { typedoc: typedocPlugin },
rules: {
"typedoc/require-exported-doc-comment": "error",
},
},
];

When not to use itโ€‹

Disable this rule when a package intentionally has no generated API documentation and treats exports as internal-only implementation details.

Package documentationโ€‹

TypeDoc package documentation:

Further readingโ€‹

Rule catalog ID: R003

Adoption resourcesโ€‹

  • Start with typedoc.configs.recommended and apply suggestions during docs review, not blanket --fix runs.