eslint-plugin-jsdoc 48.0.0 → 48.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/WarnSettings.js +34 -0
- package/src/alignTransform.js +356 -0
- package/src/defaultTagOrder.js +168 -0
- package/src/exportParser.js +957 -0
- package/src/getDefaultTagStructureForMode.js +969 -0
- package/src/index.js +266 -0
- package/src/iterateJsdoc.js +2555 -0
- package/src/jsdocUtils.js +1693 -0
- package/src/rules/checkAccess.js +45 -0
- package/src/rules/checkAlignment.js +63 -0
- package/src/rules/checkExamples.js +594 -0
- package/src/rules/checkIndentation.js +75 -0
- package/src/rules/checkLineAlignment.js +364 -0
- package/src/rules/checkParamNames.js +404 -0
- package/src/rules/checkPropertyNames.js +152 -0
- package/src/rules/checkSyntax.js +30 -0
- package/src/rules/checkTagNames.js +314 -0
- package/src/rules/checkTypes.js +535 -0
- package/src/rules/checkValues.js +220 -0
- package/src/rules/emptyTags.js +88 -0
- package/src/rules/implementsOnClasses.js +64 -0
- package/src/rules/importsAsDependencies.js +131 -0
- package/src/rules/informativeDocs.js +182 -0
- package/src/rules/matchDescription.js +286 -0
- package/src/rules/matchName.js +147 -0
- package/src/rules/multilineBlocks.js +333 -0
- package/src/rules/noBadBlocks.js +109 -0
- package/src/rules/noBlankBlockDescriptions.js +69 -0
- package/src/rules/noBlankBlocks.js +53 -0
- package/src/rules/noDefaults.js +85 -0
- package/src/rules/noMissingSyntax.js +195 -0
- package/src/rules/noMultiAsterisks.js +134 -0
- package/src/rules/noRestrictedSyntax.js +91 -0
- package/src/rules/noTypes.js +73 -0
- package/src/rules/noUndefinedTypes.js +328 -0
- package/src/rules/requireAsteriskPrefix.js +189 -0
- package/src/rules/requireDescription.js +161 -0
- package/src/rules/requireDescriptionCompleteSentence.js +333 -0
- package/src/rules/requireExample.js +118 -0
- package/src/rules/requireFileOverview.js +154 -0
- package/src/rules/requireHyphenBeforeParamDescription.js +178 -0
- package/src/rules/requireJsdoc.js +629 -0
- package/src/rules/requireParam.js +592 -0
- package/src/rules/requireParamDescription.js +89 -0
- package/src/rules/requireParamName.js +55 -0
- package/src/rules/requireParamType.js +89 -0
- package/src/rules/requireProperty.js +48 -0
- package/src/rules/requirePropertyDescription.js +25 -0
- package/src/rules/requirePropertyName.js +25 -0
- package/src/rules/requirePropertyType.js +25 -0
- package/src/rules/requireReturns.js +238 -0
- package/src/rules/requireReturnsCheck.js +141 -0
- package/src/rules/requireReturnsDescription.js +59 -0
- package/src/rules/requireReturnsType.js +51 -0
- package/src/rules/requireThrows.js +111 -0
- package/src/rules/requireYields.js +216 -0
- package/src/rules/requireYieldsCheck.js +208 -0
- package/src/rules/sortTags.js +557 -0
- package/src/rules/tagLines.js +359 -0
- package/src/rules/textEscaping.js +146 -0
- package/src/rules/validTypes.js +368 -0
- package/src/tagNames.js +234 -0
- package/src/utils/hasReturnValue.js +549 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import iterateJsdoc from '../iterateJsdoc.js';
|
|
2
|
+
import {
|
|
3
|
+
parse,
|
|
4
|
+
traverse,
|
|
5
|
+
tryParse,
|
|
6
|
+
} from '@es-joy/jsdoccomment';
|
|
7
|
+
|
|
8
|
+
const inlineTags = new Set([
|
|
9
|
+
'link', 'linkcode', 'linkplain',
|
|
10
|
+
'tutorial',
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
const asExpression = /as\s+/u;
|
|
14
|
+
|
|
15
|
+
const suppressTypes = new Set([
|
|
16
|
+
// https://github.com/google/closure-compiler/wiki/@suppress-annotations
|
|
17
|
+
// https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/ParserConfig.properties#L154
|
|
18
|
+
'accessControls',
|
|
19
|
+
'checkDebuggerStatement',
|
|
20
|
+
'checkPrototypalTypes',
|
|
21
|
+
'checkRegExp',
|
|
22
|
+
'checkTypes',
|
|
23
|
+
'checkVars',
|
|
24
|
+
'closureDepMethodUsageChecks',
|
|
25
|
+
'const',
|
|
26
|
+
'constantProperty',
|
|
27
|
+
'deprecated',
|
|
28
|
+
'duplicate',
|
|
29
|
+
'es5Strict',
|
|
30
|
+
'externsValidation',
|
|
31
|
+
'extraProvide',
|
|
32
|
+
'extraRequire',
|
|
33
|
+
'globalThis',
|
|
34
|
+
'invalidCasts',
|
|
35
|
+
'lateProvide',
|
|
36
|
+
'legacyGoogScopeRequire',
|
|
37
|
+
'lintChecks',
|
|
38
|
+
'messageConventions',
|
|
39
|
+
'misplacedTypeAnnotation',
|
|
40
|
+
'missingOverride',
|
|
41
|
+
'missingPolyfill',
|
|
42
|
+
'missingProperties',
|
|
43
|
+
'missingProvide',
|
|
44
|
+
'missingRequire',
|
|
45
|
+
'missingSourcesWarnings',
|
|
46
|
+
'moduleLoad',
|
|
47
|
+
'nonStandardJsDocs',
|
|
48
|
+
'partialAlias',
|
|
49
|
+
'polymer',
|
|
50
|
+
'reportUnknownTypes',
|
|
51
|
+
'strictMissingProperties',
|
|
52
|
+
'strictModuleDepCheck',
|
|
53
|
+
'strictPrimitiveOperators',
|
|
54
|
+
'suspiciousCode',
|
|
55
|
+
|
|
56
|
+
// Not documented in enum
|
|
57
|
+
'switch',
|
|
58
|
+
'transitionalSuspiciousCodeWarnings',
|
|
59
|
+
'undefinedNames',
|
|
60
|
+
'undefinedVars',
|
|
61
|
+
'underscore',
|
|
62
|
+
'unknownDefines',
|
|
63
|
+
'untranspilableFeatures',
|
|
64
|
+
'unusedLocalVariables',
|
|
65
|
+
'unusedPrivateMembers',
|
|
66
|
+
'useOfGoogProvide',
|
|
67
|
+
'uselessCode',
|
|
68
|
+
'visibility',
|
|
69
|
+
'with',
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param {string} path
|
|
74
|
+
* @returns {boolean}
|
|
75
|
+
*/
|
|
76
|
+
const tryParsePathIgnoreError = (path) => {
|
|
77
|
+
try {
|
|
78
|
+
tryParse(path);
|
|
79
|
+
|
|
80
|
+
return true;
|
|
81
|
+
} catch {
|
|
82
|
+
// Keep the original error for including the whole type
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return false;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// eslint-disable-next-line complexity
|
|
89
|
+
export default iterateJsdoc(({
|
|
90
|
+
jsdoc,
|
|
91
|
+
report,
|
|
92
|
+
utils,
|
|
93
|
+
context,
|
|
94
|
+
settings,
|
|
95
|
+
}) => {
|
|
96
|
+
const {
|
|
97
|
+
allowEmptyNamepaths = false,
|
|
98
|
+
} = context.options[0] || {};
|
|
99
|
+
const {
|
|
100
|
+
mode,
|
|
101
|
+
} = settings;
|
|
102
|
+
|
|
103
|
+
for (const tag of jsdoc.tags) {
|
|
104
|
+
/**
|
|
105
|
+
* @param {string} namepath
|
|
106
|
+
* @param {string} [tagName]
|
|
107
|
+
* @returns {boolean}
|
|
108
|
+
*/
|
|
109
|
+
const validNamepathParsing = function (namepath, tagName) {
|
|
110
|
+
if (tryParsePathIgnoreError(namepath)) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let handled = false;
|
|
115
|
+
|
|
116
|
+
if (tagName) {
|
|
117
|
+
switch (tagName) {
|
|
118
|
+
case 'requires':
|
|
119
|
+
case 'module': {
|
|
120
|
+
if (!namepath.startsWith('module:')) {
|
|
121
|
+
handled = tryParsePathIgnoreError(`module:${namepath}`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
case 'memberof': case 'memberof!': {
|
|
128
|
+
const endChar = namepath.slice(-1);
|
|
129
|
+
if ([
|
|
130
|
+
'#', '.', '~',
|
|
131
|
+
].includes(endChar)) {
|
|
132
|
+
handled = tryParsePathIgnoreError(namepath.slice(0, -1));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
case 'borrows': {
|
|
139
|
+
const startChar = namepath.charAt(0);
|
|
140
|
+
if ([
|
|
141
|
+
'#', '.', '~',
|
|
142
|
+
].includes(startChar)) {
|
|
143
|
+
handled = tryParsePathIgnoreError(namepath.slice(1));
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (!handled) {
|
|
150
|
+
report(`Syntax error in namepath: ${namepath}`, null, tag);
|
|
151
|
+
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return true;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* @param {string} type
|
|
160
|
+
* @returns {boolean}
|
|
161
|
+
*/
|
|
162
|
+
const validTypeParsing = function (type) {
|
|
163
|
+
let parsedTypes;
|
|
164
|
+
try {
|
|
165
|
+
if (mode === 'permissive') {
|
|
166
|
+
parsedTypes = tryParse(type);
|
|
167
|
+
} else {
|
|
168
|
+
parsedTypes = parse(type, mode);
|
|
169
|
+
}
|
|
170
|
+
} catch {
|
|
171
|
+
report(`Syntax error in type: ${type}`, null, tag);
|
|
172
|
+
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (mode === 'closure' || mode === 'typescript') {
|
|
177
|
+
traverse(parsedTypes, (node) => {
|
|
178
|
+
const {
|
|
179
|
+
type: typ,
|
|
180
|
+
} = node;
|
|
181
|
+
|
|
182
|
+
if (
|
|
183
|
+
(typ === 'JsdocTypeObjectField' || typ === 'JsdocTypeKeyValue') &&
|
|
184
|
+
node.right?.type === 'JsdocTypeNullable' &&
|
|
185
|
+
node.right?.meta?.position === 'suffix'
|
|
186
|
+
) {
|
|
187
|
+
report(`Syntax error in type: ${node.right.type}`, null, tag);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return true;
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
if (tag.problems.length) {
|
|
196
|
+
const msg = tag.problems.reduce((str, {
|
|
197
|
+
message,
|
|
198
|
+
}) => {
|
|
199
|
+
return str + '; ' + message;
|
|
200
|
+
}, '').slice(2);
|
|
201
|
+
report(`Invalid name: ${msg}`, null, tag);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (tag.tag === 'borrows') {
|
|
206
|
+
const thisNamepath = /** @type {string} */ (
|
|
207
|
+
utils.getTagDescription(tag)
|
|
208
|
+
).replace(asExpression, '')
|
|
209
|
+
.trim();
|
|
210
|
+
|
|
211
|
+
if (!asExpression.test(/** @type {string} */ (
|
|
212
|
+
utils.getTagDescription(tag)
|
|
213
|
+
)) || !thisNamepath) {
|
|
214
|
+
report(`@borrows must have an "as" expression. Found "${utils.getTagDescription(tag)}"`, null, tag);
|
|
215
|
+
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (validNamepathParsing(thisNamepath, 'borrows')) {
|
|
220
|
+
const thatNamepath = tag.name;
|
|
221
|
+
|
|
222
|
+
validNamepathParsing(thatNamepath);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (tag.tag === 'suppress' && mode === 'closure') {
|
|
229
|
+
let parsedTypes;
|
|
230
|
+
|
|
231
|
+
try {
|
|
232
|
+
parsedTypes = tryParse(tag.type);
|
|
233
|
+
} catch {
|
|
234
|
+
// Ignore
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (parsedTypes) {
|
|
238
|
+
traverse(parsedTypes, (node) => {
|
|
239
|
+
let type;
|
|
240
|
+
if ('value' in node && typeof node.value === 'string') {
|
|
241
|
+
type = node.value;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (type !== undefined && !suppressTypes.has(type)) {
|
|
245
|
+
report(`Syntax error in suppress type: ${type}`, null, tag);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const otherModeMaps = /** @type {import('../jsdocUtils.js').ParserMode[]} */ ([
|
|
252
|
+
'jsdoc', 'typescript', 'closure', 'permissive',
|
|
253
|
+
]).filter(
|
|
254
|
+
(mde) => {
|
|
255
|
+
return mde !== mode;
|
|
256
|
+
},
|
|
257
|
+
).map((mde) => {
|
|
258
|
+
return utils.getTagStructureForMode(mde);
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
const tagMightHaveNamePosition = utils.tagMightHaveNamePosition(tag.tag, otherModeMaps);
|
|
262
|
+
if (tagMightHaveNamePosition !== true && tag.name) {
|
|
263
|
+
const modeInfo = tagMightHaveNamePosition === false ? '' : ` in "${mode}" mode`;
|
|
264
|
+
report(`@${tag.tag} should not have a name${modeInfo}.`, null, tag);
|
|
265
|
+
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const mightHaveTypePosition = utils.tagMightHaveTypePosition(tag.tag, otherModeMaps);
|
|
270
|
+
if (mightHaveTypePosition !== true && tag.type) {
|
|
271
|
+
const modeInfo = mightHaveTypePosition === false ? '' : ` in "${mode}" mode`;
|
|
272
|
+
report(`@${tag.tag} should not have a bracketed type${modeInfo}.`, null, tag);
|
|
273
|
+
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// REQUIRED NAME
|
|
278
|
+
const tagMustHaveNamePosition = utils.tagMustHaveNamePosition(tag.tag, otherModeMaps);
|
|
279
|
+
|
|
280
|
+
// Don't handle `@param` here though it does require name as handled by
|
|
281
|
+
// `require-param-name` (`@property` would similarly seem to require one,
|
|
282
|
+
// but is handled by `require-property-name`)
|
|
283
|
+
if (tagMustHaveNamePosition !== false && !tag.name && !allowEmptyNamepaths && ![
|
|
284
|
+
'param', 'arg', 'argument',
|
|
285
|
+
'property', 'prop',
|
|
286
|
+
].includes(tag.tag) &&
|
|
287
|
+
(tag.tag !== 'see' || !utils.getTagDescription(tag).includes('{@link'))
|
|
288
|
+
) {
|
|
289
|
+
const modeInfo = tagMustHaveNamePosition === true ? '' : ` in "${mode}" mode`;
|
|
290
|
+
report(`Tag @${tag.tag} must have a name/namepath${modeInfo}.`, null, tag);
|
|
291
|
+
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// REQUIRED TYPE
|
|
296
|
+
const mustHaveTypePosition = utils.tagMustHaveTypePosition(tag.tag, otherModeMaps);
|
|
297
|
+
if (mustHaveTypePosition !== false && !tag.type) {
|
|
298
|
+
const modeInfo = mustHaveTypePosition === true ? '' : ` in "${mode}" mode`;
|
|
299
|
+
report(`Tag @${tag.tag} must have a type${modeInfo}.`, null, tag);
|
|
300
|
+
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// REQUIRED TYPE OR NAME/NAMEPATH
|
|
305
|
+
const tagMissingRequiredTypeOrNamepath = utils.tagMissingRequiredTypeOrNamepath(tag, otherModeMaps);
|
|
306
|
+
if (tagMissingRequiredTypeOrNamepath !== false && !allowEmptyNamepaths) {
|
|
307
|
+
const modeInfo = tagMissingRequiredTypeOrNamepath === true ? '' : ` in "${mode}" mode`;
|
|
308
|
+
report(`Tag @${tag.tag} must have either a type or namepath${modeInfo}.`, null, tag);
|
|
309
|
+
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// VALID TYPE
|
|
314
|
+
const hasTypePosition = mightHaveTypePosition === true && Boolean(tag.type);
|
|
315
|
+
if (hasTypePosition) {
|
|
316
|
+
validTypeParsing(tag.type);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// VALID NAME/NAMEPATH
|
|
320
|
+
const hasNameOrNamepathPosition = (
|
|
321
|
+
tagMustHaveNamePosition !== false ||
|
|
322
|
+
utils.tagMightHaveNamepath(tag.tag)
|
|
323
|
+
) && Boolean(tag.name);
|
|
324
|
+
|
|
325
|
+
if (hasNameOrNamepathPosition) {
|
|
326
|
+
if (mode !== 'jsdoc' && tag.tag === 'template') {
|
|
327
|
+
for (const namepath of utils.parseClosureTemplateTag(tag)) {
|
|
328
|
+
validNamepathParsing(namepath);
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
validNamepathParsing(tag.name, tag.tag);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
for (const inlineTag of tag.inlineTags) {
|
|
336
|
+
if (inlineTags.has(inlineTag.tag) && !inlineTag.text && !inlineTag.namepathOrURL) {
|
|
337
|
+
report(`Inline tag "${inlineTag.tag}" missing content`, null, tag);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
for (const inlineTag of jsdoc.inlineTags) {
|
|
343
|
+
if (inlineTags.has(inlineTag.tag) && !inlineTag.text && !inlineTag.namepathOrURL) {
|
|
344
|
+
report(`Inline tag "${inlineTag.tag}" missing content`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}, {
|
|
348
|
+
iterateAllJsdocs: true,
|
|
349
|
+
meta: {
|
|
350
|
+
docs: {
|
|
351
|
+
description: 'Requires all types to be valid JSDoc or Closure compiler types without syntax errors.',
|
|
352
|
+
url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/valid-types.md#repos-sticky-header',
|
|
353
|
+
},
|
|
354
|
+
schema: [
|
|
355
|
+
{
|
|
356
|
+
additionalProperties: false,
|
|
357
|
+
properties: {
|
|
358
|
+
allowEmptyNamepaths: {
|
|
359
|
+
default: false,
|
|
360
|
+
type: 'boolean',
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
type: 'object',
|
|
364
|
+
},
|
|
365
|
+
],
|
|
366
|
+
type: 'suggestion',
|
|
367
|
+
},
|
|
368
|
+
});
|
package/src/tagNames.js
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* [key: string]: string[]
|
|
4
|
+
* }} AliasedTags
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @type {AliasedTags}
|
|
9
|
+
*/
|
|
10
|
+
const jsdocTagsUndocumented = {
|
|
11
|
+
// Undocumented but present; see
|
|
12
|
+
// https://github.com/jsdoc/jsdoc/issues/1283#issuecomment-516816802
|
|
13
|
+
// https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js#L594
|
|
14
|
+
modifies: [],
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {AliasedTags}
|
|
19
|
+
*/
|
|
20
|
+
const jsdocTags = {
|
|
21
|
+
...jsdocTagsUndocumented,
|
|
22
|
+
abstract: [
|
|
23
|
+
'virtual',
|
|
24
|
+
],
|
|
25
|
+
access: [],
|
|
26
|
+
alias: [],
|
|
27
|
+
async: [],
|
|
28
|
+
augments: [
|
|
29
|
+
'extends',
|
|
30
|
+
],
|
|
31
|
+
author: [],
|
|
32
|
+
borrows: [],
|
|
33
|
+
callback: [],
|
|
34
|
+
class: [
|
|
35
|
+
'constructor',
|
|
36
|
+
],
|
|
37
|
+
classdesc: [],
|
|
38
|
+
constant: [
|
|
39
|
+
'const',
|
|
40
|
+
],
|
|
41
|
+
constructs: [],
|
|
42
|
+
copyright: [],
|
|
43
|
+
default: [
|
|
44
|
+
'defaultvalue',
|
|
45
|
+
],
|
|
46
|
+
deprecated: [],
|
|
47
|
+
description: [
|
|
48
|
+
'desc',
|
|
49
|
+
],
|
|
50
|
+
enum: [],
|
|
51
|
+
event: [],
|
|
52
|
+
example: [],
|
|
53
|
+
exports: [],
|
|
54
|
+
external: [
|
|
55
|
+
'host',
|
|
56
|
+
],
|
|
57
|
+
file: [
|
|
58
|
+
'fileoverview',
|
|
59
|
+
'overview',
|
|
60
|
+
],
|
|
61
|
+
fires: [
|
|
62
|
+
'emits',
|
|
63
|
+
],
|
|
64
|
+
function: [
|
|
65
|
+
'func',
|
|
66
|
+
'method',
|
|
67
|
+
],
|
|
68
|
+
generator: [],
|
|
69
|
+
global: [],
|
|
70
|
+
hideconstructor: [],
|
|
71
|
+
ignore: [],
|
|
72
|
+
implements: [],
|
|
73
|
+
inheritdoc: [],
|
|
74
|
+
|
|
75
|
+
// Allowing casing distinct from jsdoc `definitions.js` (required in Closure)
|
|
76
|
+
inheritDoc: [],
|
|
77
|
+
|
|
78
|
+
inner: [],
|
|
79
|
+
instance: [],
|
|
80
|
+
interface: [],
|
|
81
|
+
kind: [],
|
|
82
|
+
lends: [],
|
|
83
|
+
license: [],
|
|
84
|
+
listens: [],
|
|
85
|
+
member: [
|
|
86
|
+
'var',
|
|
87
|
+
],
|
|
88
|
+
memberof: [],
|
|
89
|
+
'memberof!': [],
|
|
90
|
+
mixes: [],
|
|
91
|
+
mixin: [],
|
|
92
|
+
|
|
93
|
+
module: [],
|
|
94
|
+
name: [],
|
|
95
|
+
namespace: [],
|
|
96
|
+
override: [],
|
|
97
|
+
package: [],
|
|
98
|
+
param: [
|
|
99
|
+
'arg',
|
|
100
|
+
'argument',
|
|
101
|
+
],
|
|
102
|
+
private: [],
|
|
103
|
+
property: [
|
|
104
|
+
'prop',
|
|
105
|
+
],
|
|
106
|
+
protected: [],
|
|
107
|
+
public: [],
|
|
108
|
+
readonly: [],
|
|
109
|
+
requires: [],
|
|
110
|
+
returns: [
|
|
111
|
+
'return',
|
|
112
|
+
],
|
|
113
|
+
see: [],
|
|
114
|
+
since: [],
|
|
115
|
+
static: [],
|
|
116
|
+
summary: [],
|
|
117
|
+
|
|
118
|
+
this: [],
|
|
119
|
+
throws: [
|
|
120
|
+
'exception',
|
|
121
|
+
],
|
|
122
|
+
todo: [],
|
|
123
|
+
tutorial: [],
|
|
124
|
+
type: [],
|
|
125
|
+
typedef: [],
|
|
126
|
+
variation: [],
|
|
127
|
+
version: [],
|
|
128
|
+
yields: [
|
|
129
|
+
'yield',
|
|
130
|
+
],
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* @type {AliasedTags}
|
|
135
|
+
*/
|
|
136
|
+
const typeScriptTags = {
|
|
137
|
+
...jsdocTags,
|
|
138
|
+
|
|
139
|
+
// https://www.typescriptlang.org/tsconfig/#stripInternal
|
|
140
|
+
internal: [],
|
|
141
|
+
|
|
142
|
+
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#overload-support-in-jsdoc
|
|
143
|
+
overload: [],
|
|
144
|
+
|
|
145
|
+
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#satisfies-support-in-jsdoc
|
|
146
|
+
satisfies: [],
|
|
147
|
+
|
|
148
|
+
// `@template` is also in TypeScript per:
|
|
149
|
+
// https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc
|
|
150
|
+
template: [],
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* @type {AliasedTags}
|
|
155
|
+
*/
|
|
156
|
+
const undocumentedClosureTags = {
|
|
157
|
+
// These are in Closure source but not in jsdoc source nor in the Closure
|
|
158
|
+
// docs: https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/Annotation.java
|
|
159
|
+
closurePrimitive: [],
|
|
160
|
+
customElement: [],
|
|
161
|
+
expose: [],
|
|
162
|
+
hidden: [],
|
|
163
|
+
idGenerator: [],
|
|
164
|
+
meaning: [],
|
|
165
|
+
mixinClass: [],
|
|
166
|
+
mixinFunction: [],
|
|
167
|
+
ngInject: [],
|
|
168
|
+
owner: [],
|
|
169
|
+
typeSummary: [],
|
|
170
|
+
wizaction: [],
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const {
|
|
174
|
+
/* eslint-disable no-unused-vars */
|
|
175
|
+
inheritdoc,
|
|
176
|
+
internal,
|
|
177
|
+
overload,
|
|
178
|
+
satisfies,
|
|
179
|
+
|
|
180
|
+
// Will be inverted to prefer `return`
|
|
181
|
+
returns,
|
|
182
|
+
/* eslint-enable no-unused-vars */
|
|
183
|
+
...typeScriptTagsInClosure
|
|
184
|
+
} = typeScriptTags;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @type {AliasedTags}
|
|
188
|
+
*/
|
|
189
|
+
const closureTags = {
|
|
190
|
+
...typeScriptTagsInClosure,
|
|
191
|
+
...undocumentedClosureTags,
|
|
192
|
+
|
|
193
|
+
// From https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler
|
|
194
|
+
// These are all recognized in https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js
|
|
195
|
+
// except for the experimental `noinline` and the casing differences noted below
|
|
196
|
+
|
|
197
|
+
// Defined as a synonym of `const` in jsdoc `definitions.js`
|
|
198
|
+
define: [],
|
|
199
|
+
|
|
200
|
+
dict: [],
|
|
201
|
+
export: [],
|
|
202
|
+
externs: [],
|
|
203
|
+
final: [],
|
|
204
|
+
|
|
205
|
+
// With casing distinct from jsdoc `definitions.js`
|
|
206
|
+
implicitCast: [],
|
|
207
|
+
|
|
208
|
+
noalias: [],
|
|
209
|
+
nocollapse: [],
|
|
210
|
+
nocompile: [],
|
|
211
|
+
noinline: [],
|
|
212
|
+
nosideeffects: [],
|
|
213
|
+
polymer: [],
|
|
214
|
+
polymerBehavior: [],
|
|
215
|
+
preserve: [],
|
|
216
|
+
|
|
217
|
+
// Defined as a synonym of `interface` in jsdoc `definitions.js`
|
|
218
|
+
record: [],
|
|
219
|
+
|
|
220
|
+
return: [
|
|
221
|
+
'returns',
|
|
222
|
+
],
|
|
223
|
+
|
|
224
|
+
struct: [],
|
|
225
|
+
suppress: [],
|
|
226
|
+
|
|
227
|
+
unrestricted: [],
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export {
|
|
231
|
+
closureTags,
|
|
232
|
+
jsdocTags,
|
|
233
|
+
typeScriptTags,
|
|
234
|
+
};
|