config-oxlint-tsdoc #
Oxlint JS plugin providing TSDoc validation rules adapted from eslint-plugin-jsdoc's recommended-typescript config.
Uses an in-house TSDoc comment scanner;
no external dependency on @microsoft/tsdoc.
A bounded process-local cache shares one parsed model for each exact comment body across participating rules.
Motivation #
eslint-plugin-jsdoc only runs inside ESLint, which is slow and cannot participate in oxlint's single-pass architecture. This plugin reimplements the recommended-typescript ruleset as an oxlint JS plugin, adapting all rules to conform to TSDoc (not JSDoc) conventions used in the monorepo.
Usage #
Reference the package in oxlint.config.ts:
// oxlint.config.ts
import { defineConfig, } from 'oxlint';
export default defineConfig({
jsPlugins: ['@monochromatic-dev/oxlint-plugin-tsdoc',],
},);
Each rule advertises recommended: true.
Configure severity in the consuming oxlint config.
The shared @monochromatic-dev/config-oxlint package enables the TSDoc rules it uses
and keeps the yield rules off because @yields is not part of TSDoc.
The package default export resolves to the prebuilt,
self-contained
dist/final/node/index.mjs (run mise run //package/oxlint-plugin/tsdoc:build first).
TypeScript source is available at the /ts subpath (/ts/* for individual files) for
development.
Rules #
Presence #
- require-tsdoc: requires TSDoc comments on documentable declarations at module, function, and block scope (functions, classes, interfaces, type aliases, enums, variables, properties, enum members, getters, setters); skips for-loop binding declarations
- require-example:
requires exported functions to include an
@exampletag unless@inheritDocor@internalmakes the example requirement inappropriate
Structural formatting #
- check-alignment: enforces consistent asterisk alignment in multiline TSDoc blocks
- multiline-blocks: requires multiline format for all TSDoc comments and auto-fixes single-line blocks to star-less body lines
- no-multi-asterisks:
disallows
** textlines (doubled canonical prefixes) while permitting literal-leading Markdown such as**Note** - tag-lines: requires blank comment lines before block tags
- empty-tags:
enforces that modifier tags (
@public,@readonly,@override, etc.) have no content - escape-inline-tags:
detects unescaped
*/inside comment content
Tag validation #
- check-tag-names: validates that tags are recognized TSDoc standard tags; reports JSDoc-only tags with migration suggestions; skips fenced code blocks and backtick-wrapped inline code
- check-access: detects conflicting access modifier tags
- valid-types:
reports best-effort structural problems from the in-house scanner
(
@paramtag missing its hyphen separator, unclosed{@link, empty{@link}) - no-types:
disallows JSDoc-style
{Type}annotations in TSDoc
Parameter documentation #
- check-param-names:
validates
@paramnames against the function signature; allows property names from destructured parameters - require-param:
requires
@paramtags for all function parameters - require-param-name:
requires every
@paramtag to specify a parameter name - require-param-description:
requires descriptions on
@paramtags
Mutation contracts #
- check-mutates:
validates each project-specific
@mutates parameterName - descriptionblock; reports missing targets, unknown callable parameters, duplicate targets, and missing descriptions; accepts named parameters and destructured binding names
@mutates means that a callable may cause caller-observable state changes through state reachable from the named
parameter.
It is a repeatable custom block tag,
not a standard TSDoc tag.
This plugin recognizes and validates the tag directly.
External tools using @microsoft/tsdoc must register it before parsing comments:
import {
TSDocConfiguration,
TSDocTagDefinition,
TSDocTagSyntaxKind,
} from '@microsoft/tsdoc';
const configuration = new TSDocConfiguration();
const mutatesTag = new TSDocTagDefinition({
tagName: '@mutates',
syntaxKind: TSDocTagSyntaxKind.BlockTag,
allowMultiple: true,
});
configuration.addTagDefinition(mutatesTag);
configuration.setSupportForTag(mutatesTag, true);
Registration makes the reference parser accept repeatable blocks.
Consumers must preserve the block text and interpret the first token as the parameter target followed by a hyphen and
author-written rationale.
The API shape is verified against @microsoft/tsdoc 0.16.0's
TSDocConfiguration and TSDocTagDefinition declarations.
Return documentation #
- require-returns:
requires
@returnstag for functions with non-void return types; skips constructors and setters - require-returns-check:
reports
@returnson void functions - require-returns-description:
requires descriptions on
@returnstags
Yield documentation #
These rules are available in the plugin for compatibility testing,
but the shared config keeps them off because @yields is not part of TSDoc.
- require-yields:
requires
@yieldstag for generator functions - require-yields-check:
reports
@yieldson non-generator functions
Ignored files #
Files matching these extensions are skipped by all rules:
.test.ts,
.spec.ts,
.bench.ts,
.js,
.d.ts,
.mjs,
.cjs,
.d.mts,
.d.cts
Source files #
index.ts: plugin entry point; assembles all rules into the oxlint plugin objectast-access.ts: untyped AST guards, record helpers, and parameter binding unwrap logiccomment-text.ts: leaf text-scanning primitives (line normalization, tag/code scanning)tsdoc-comments.ts: comment lookup, TSDoc block parsing, and parse-result assemblytsdoc-blocks.ts: in-house scanner producing parsed@param,@mutates, and@returnsmodelstsdoc-params.ts,tsdoc-destructured.ts, andtsdoc-params-returns.ts: function signature, destructured parameter, return, and generator helperstsdoc-structural-messages.ts: best-effort structural diagnostics forvalid-typestsdoc-doc-model.ts: parsed doc-model and message typestsdoc-utils.ts: compatibility barrel for rules that need shared TSDoc helpersrule/tsdoc-visitors.ts: shared visitor factories, ignored-file handling, and report-location helpersrule/require-tsdoc.tsandrule/require-example.ts: presence rules for declarations and exported function examplesrule/params.ts,rule/mutates.ts,rule/returns.ts, andrule/yields.ts: callable documentation rulesrule/structural.tsandrule/tag-validation.ts: aggregate entry points for structural and tag-validation rulesrule/asterisk-validation.ts,rule/structural-tags.ts,rule/empty-tags.ts,rule/tag-escaping.ts,rule/tag-names.ts,rule/tag-types.ts,rule/type-annotations.ts, andrule/jsdoc-map.ts: focused helpers behind the aggregate structural and tag-validation rules
Tests #
Fixture-based integration tests cover all plugin rules, and focused unit tests cover the scanner and text helpers:
mise run buildAndTest -- package/oxlint-plugin/tsdoc/src/oxlint-tsdoc.unit.test.ts
mise run //package/oxlint-plugin/tsdoc:test:unit
Test fixtures live in package/test-fixture/oxlint-tsdoc/src/ with valid/ and invalid/ directories.