eslint-plugin-jsdoc 55.4.0 → 56.0.0

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