Skip to content

Commit 925f6e3

Browse files
committed
feat(check-tag-names): add Typedoc include, includeCode, and TSDoc inheritDoc/inheritdoc and label to allowable inline tags; add TSDoc and typedoc tags
1 parent c078633 commit 925f6e3

6 files changed

Lines changed: 195 additions & 34 deletions

File tree

.README/rules/check-tag-names.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,19 @@ Also checks for unknown inline tags, with the following being permitted by defau
196196
(see the `inlineTags` option):
197197

198198
```
199+
// JSDoc
199200
link
200201
linkcode
201202
linkplain
202203
tutorial
204+
205+
// TSDoc
206+
inheritDoc
207+
label
208+
209+
// typedoc
210+
include
211+
includeCode
203212
```
204213

205214
## Fixer

docs/rules/check-tag-names.md

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,19 @@ Also checks for unknown inline tags, with the following being permitted by defau
208208
(see the `inlineTags` option):
209209

210210
```
211+
// JSDoc
211212
link
212213
linkcode
213214
linkplain
214215
tutorial
216+
217+
// TSDoc
218+
inheritDoc
219+
label
220+
221+
// typedoc
222+
include
223+
includeCode
215224
```
216225

217226
<a name="user-content-check-tag-names-fixer"></a>
@@ -251,7 +260,7 @@ Set to `false` to disable auto-removal of types that are redundant with the [`ty
251260

252261
List of tags to allow inline.
253262

254-
Defaults to array of `'link', 'linkcode', 'linkplain', 'tutorial'`
263+
Defaults to array of `'link', 'linkcode', 'linkplain', 'tutorial', 'inheritDoc', 'label', 'include', and 'includeCode'`
255264

256265
<a name="user-content-check-tag-names-options-jsxtags"></a>
257266
<a name="check-tag-names-options-jsxtags"></a>
@@ -727,27 +736,57 @@ function quux (foo) {}
727736
* @variation
728737
* @version
729738
* @yields
739+
* @alpha
740+
* @beta
741+
* @decorator
742+
* @eventProperty
743+
* @experimental
744+
* @packageDocumentation
745+
* @privateRemarks
746+
* @remarks
747+
* @sealed
748+
* @category
749+
* @categoryDescription
750+
* @disableGroups
751+
* @document
752+
* @expand
753+
* @expandType
754+
* @group
755+
* @groupDescription
756+
* @hidden
757+
* @hideCategories
758+
* @hideGroups
759+
* @inline
760+
* @inlineType
761+
* @mergeModuleWith
762+
* @preventExpand
763+
* @preventInline
764+
* @primaryExport
765+
* @showCategories
766+
* @showGroups
767+
* @sortStrategy
768+
* @useDeclaredType
730769
* @import
731770
* @internal
771+
* @jsx
732772
* @overload
733773
* @satisfies
734774
* @template
735775
*/
736776
function quux (foo) {}
737777
// Settings: {"jsdoc":{"mode":"jsdoc"}}
738-
// Message: Invalid JSDoc tag name "import".
778+
// Message: Invalid JSDoc tag name "alpha".
739779

740780
/**
741781
* @externs
742782
*/
743783
function quux (foo) {}
744784
// Message: Invalid JSDoc tag name "externs".
745785

746-
/** @jsx h */
747786
/** @jsxFrag Fragment */
748787
/** @jsxImportSource preact */
749788
/** @jsxRuntime automatic */
750-
// Message: Invalid JSDoc tag name "jsx".
789+
// Message: Invalid JSDoc tag name "jsxFrag".
751790

752791
/**
753792
* @constructor
@@ -1049,8 +1088,39 @@ function quux (foo) {}
10491088
* @variation
10501089
* @version
10511090
* @yields
1091+
* @alpha
1092+
* @beta
1093+
* @decorator
1094+
* @eventProperty
1095+
* @experimental
1096+
* @packageDocumentation
1097+
* @privateRemarks
1098+
* @remarks
1099+
* @sealed
1100+
* @category
1101+
* @categoryDescription
1102+
* @disableGroups
1103+
* @document
1104+
* @expand
1105+
* @expandType
1106+
* @group
1107+
* @groupDescription
1108+
* @hidden
1109+
* @hideCategories
1110+
* @hideGroups
1111+
* @inline
1112+
* @inlineType
1113+
* @mergeModuleWith
1114+
* @preventExpand
1115+
* @preventInline
1116+
* @primaryExport
1117+
* @showCategories
1118+
* @showGroups
1119+
* @sortStrategy
1120+
* @useDeclaredType
10521121
* @import
10531122
* @internal
1123+
* @jsx
10541124
* @overload
10551125
* @satisfies
10561126
* @template

src/rules.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export interface Rules {
267267
/**
268268
* List of tags to allow inline.
269269
*
270-
* Defaults to array of `'link', 'linkcode', 'linkplain', 'tutorial'`
270+
* Defaults to array of `'link', 'linkcode', 'linkplain', 'tutorial', 'inheritDoc', 'label', 'include', and 'includeCode'`
271271
*/
272272
inlineTags?: string[];
273273
/**

src/rules/checkTagNames.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ export default iterateJsdoc(({
8282
definedTags = [],
8383
enableFixer = true,
8484
inlineTags = [
85+
// jsdoc
8586
'link', 'linkcode', 'linkplain', 'tutorial',
87+
// https://tsdoc.org/pages/spec/tag_kinds/#inline-tags
88+
'inheritDoc',
89+
'label',
90+
// https://typedoc.org/documents/Tags.html#inline-tags
91+
'include', 'includeCode',
8692
],
8793
jsxTags,
8894
typed,
@@ -323,7 +329,7 @@ The format is as follows:
323329
inlineTags: {
324330
description: `List of tags to allow inline.
325331
326-
Defaults to array of \`'link', 'linkcode', 'linkplain', 'tutorial'\``,
332+
Defaults to array of \`'link', 'linkcode', 'linkplain', 'tutorial', 'inheritDoc', 'label', 'include', and 'includeCode'\``,
327333
items: {
328334
type: 'string',
329335
},

src/tagNames.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,68 @@ const jsdocTags = {
130130
],
131131
};
132132

133+
/**
134+
* @see {@link https://tsdoc.org/}
135+
* @type {AliasedTags}
136+
*/
137+
const tsdocTags = {
138+
alpha: [],
139+
beta: [],
140+
decorator: [],
141+
eventProperty: [],
142+
experimental: [],
143+
packageDocumentation: [],
144+
privateRemarks: [],
145+
remarks: [],
146+
sealed: [],
147+
};
148+
149+
/**
150+
* @see {@link https://typedoc.org/documents/Tags.html}
151+
* @type {AliasedTags}
152+
*/
153+
const typedocTags = {
154+
category: [],
155+
// https://typedoc.org/documents/Tags._category.html#category-descriptions
156+
categoryDescription: [],
157+
// https://typedoc.org/documents/Tags._group.html#disablegroups
158+
disableGroups: [],
159+
document: [],
160+
expand: [],
161+
// https://typedoc.org/documents/Tags._expand.html#expandtype
162+
expandType: [],
163+
group: [],
164+
// https://typedoc.org/documents/Tags._group.html#groupdescription
165+
groupDescription: [],
166+
hidden: [],
167+
// https://typedoc.org/documents/Tags._category.html#navigation-customization
168+
hideCategories: [],
169+
// https://typedoc.org/documents/Tags._group.html#navigation-customization
170+
hideGroups: [],
171+
inline: [],
172+
// https://typedoc.org/documents/Tags._inline.html#inlinetype
173+
inlineType: [],
174+
mergeModuleWith: [],
175+
// https://typedoc.org/documents/Tags._expand.html#preventexpand
176+
preventExpand: [],
177+
// https://typedoc.org/documents/Tags._inline.html#preventinline
178+
preventInline: [],
179+
primaryExport: [],
180+
// https://typedoc.org/documents/Tags._category.html#navigation-customization
181+
showCategories: [],
182+
// https://typedoc.org/documents/Tags._group.html#navigation-customization
183+
showGroups: [],
184+
sortStrategy: [],
185+
useDeclaredType: [],
186+
};
187+
133188
/**
134189
* @type {AliasedTags}
135190
*/
136191
const typeScriptTags = {
137192
...jsdocTags,
193+
...tsdocTags,
194+
...typedocTags,
138195

139196
// https://github.com/microsoft/TypeScript/issues/22160
140197
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#the-jsdoc-import-tag
@@ -143,6 +200,9 @@ const typeScriptTags = {
143200
// https://www.typescriptlang.org/tsconfig/#stripInternal
144201
internal: [],
145202

203+
// https://typedoc.org/documents/Tags.TypeScript_Tags.html
204+
jsx: [],
205+
146206
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#overload-support-in-jsdoc
147207
overload: [],
148208

test/rules/assertions/checkTagNames.js

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -824,27 +824,48 @@ export default /** @type {import('../index.js').TestCases} */ ({
824824
{
825825
code: `${ALL_TYPESCRIPT_TAGS_COMMENT}\nfunction quux (foo) {}`,
826826
errors: [
827-
{
828-
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 4,
829-
message: 'Invalid JSDoc tag name "import".',
830-
},
831-
{
832-
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 3,
833-
message: 'Invalid JSDoc tag name "internal".',
834-
},
835-
{
836-
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 2,
837-
message: 'Invalid JSDoc tag name "overload".',
838-
},
839-
{
840-
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - 1,
841-
message: 'Invalid JSDoc tag name "satisfies".',
842-
},
843-
{
844-
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT),
845-
message: 'Invalid JSDoc tag name "template".',
846-
},
847-
],
827+
// TSDoc
828+
'alpha',
829+
'beta',
830+
'decorator',
831+
'eventProperty',
832+
'experimental',
833+
'packageDocumentation',
834+
'privateRemarks',
835+
'remarks',
836+
'sealed',
837+
838+
// TypeDoc
839+
'category',
840+
'categoryDescription',
841+
'disableGroups',
842+
'document',
843+
'expand',
844+
'expandType',
845+
'group',
846+
'groupDescription',
847+
'hidden',
848+
'hideCategories',
849+
'hideGroups',
850+
'inline',
851+
'inlineType',
852+
'mergeModuleWith',
853+
'preventExpand',
854+
'preventInline',
855+
'primaryExport',
856+
'showCategories',
857+
'showGroups',
858+
'sortStrategy',
859+
'useDeclaredType',
860+
861+
// JSDoc/TypeScript
862+
'import', 'internal', 'jsx', 'overload', 'satisfies', 'template',
863+
].map((tagName, idx, arr) => {
864+
return {
865+
line: lineCount(ALL_TYPESCRIPT_TAGS_COMMENT) - arr.length + idx + 1,
866+
message: `Invalid JSDoc tag name "${tagName}".`,
867+
};
868+
}),
848869
settings: {
849870
jsdoc: {
850871
mode: 'jsdoc',
@@ -862,26 +883,21 @@ export default /** @type {import('../index.js').TestCases} */ ({
862883
},
863884
{
864885
code: `
865-
/** @jsx h */
866886
/** @jsxFrag Fragment */
867887
/** @jsxImportSource preact */
868888
/** @jsxRuntime automatic */
869889
`,
870890
errors: [
871891
{
872892
line: 2,
873-
message: 'Invalid JSDoc tag name "jsx".',
874-
},
875-
{
876-
line: 3,
877893
message: 'Invalid JSDoc tag name "jsxFrag".',
878894
},
879895
{
880-
line: 4,
896+
line: 3,
881897
message: 'Invalid JSDoc tag name "jsxImportSource".',
882898
},
883899
{
884-
line: 5,
900+
line: 4,
885901
message: 'Invalid JSDoc tag name "jsxRuntime".',
886902
},
887903
],

0 commit comments

Comments
 (0)