eslint-plugin-jsdoc 43.1.0 → 43.2.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 (109) hide show
  1. package/README.md +58 -24372
  2. package/dist/WarnSettings.js.map +1 -1
  3. package/dist/alignTransform.js.map +1 -1
  4. package/dist/bin/generateRule.js.map +1 -1
  5. package/dist/exportParser.js.map +1 -1
  6. package/dist/generateRule.js.map +1 -1
  7. package/dist/iterateJsdoc.js +4 -4
  8. package/dist/iterateJsdoc.js.map +1 -1
  9. package/dist/jsdocUtils.js.map +1 -1
  10. package/dist/rules/checkAccess.js.map +1 -1
  11. package/dist/rules/checkExamples.js.map +1 -1
  12. package/dist/rules/checkLineAlignment.js.map +1 -1
  13. package/dist/rules/checkParamNames.js.map +1 -1
  14. package/dist/rules/checkPropertyNames.js.map +1 -1
  15. package/dist/rules/checkTagNames.js.map +1 -1
  16. package/dist/rules/checkTypes.js.map +1 -1
  17. package/dist/rules/checkValues.js.map +1 -1
  18. package/dist/rules/emptyTags.js.map +1 -1
  19. package/dist/rules/implementsOnClasses.js.map +1 -1
  20. package/dist/rules/informativeDocs.js.map +1 -1
  21. package/dist/rules/matchDescription.js.map +1 -1
  22. package/dist/rules/matchName.js.map +1 -1
  23. package/dist/rules/multilineBlocks.js.map +1 -1
  24. package/dist/rules/noBadBlocks.js.map +1 -1
  25. package/dist/rules/noBlankBlockDescriptions.js.map +1 -1
  26. package/dist/rules/noBlankBlocks.js.map +1 -1
  27. package/dist/rules/noDefaults.js.map +1 -1
  28. package/dist/rules/noMultiAsterisks.js.map +1 -1
  29. package/dist/rules/noTypes.js.map +1 -1
  30. package/dist/rules/noUndefinedTypes.js.map +1 -1
  31. package/dist/rules/requireDescription.js.map +1 -1
  32. package/dist/rules/requireDescriptionCompleteSentence.js.map +1 -1
  33. package/dist/rules/requireExample.js.map +1 -1
  34. package/dist/rules/requireFileOverview.js.map +1 -1
  35. package/dist/rules/requireHyphenBeforeParamDescription.js.map +1 -1
  36. package/dist/rules/requireJsdoc.js.map +1 -1
  37. package/dist/rules/requireParam.js.map +1 -1
  38. package/dist/rules/requireParamDescription.js.map +1 -1
  39. package/dist/rules/requireParamName.js.map +1 -1
  40. package/dist/rules/requireParamType.js.map +1 -1
  41. package/dist/rules/requirePropertyDescription.js.map +1 -1
  42. package/dist/rules/requirePropertyName.js.map +1 -1
  43. package/dist/rules/requirePropertyType.js.map +1 -1
  44. package/dist/rules/requireReturns.js.map +1 -1
  45. package/dist/rules/requireReturnsCheck.js.map +1 -1
  46. package/dist/rules/requireReturnsDescription.js.map +1 -1
  47. package/dist/rules/requireThrows.js.map +1 -1
  48. package/dist/rules/requireYields.js.map +1 -1
  49. package/dist/rules/requireYieldsCheck.js.map +1 -1
  50. package/dist/rules/sortTags.js.map +1 -1
  51. package/dist/rules/tagLines.js.map +1 -1
  52. package/dist/rules/textEscaping.js.map +1 -1
  53. package/dist/rules/validTypes.js.map +1 -1
  54. package/dist/utils/hasReturnValue.js.map +1 -1
  55. package/docs/advanced.md +102 -0
  56. package/docs/rules/check-access.md +193 -0
  57. package/docs/rules/check-alignment.md +169 -0
  58. package/docs/rules/check-examples.md +784 -0
  59. package/docs/rules/check-indentation.md +296 -0
  60. package/docs/rules/check-line-alignment.md +995 -0
  61. package/docs/rules/check-param-names.md +1035 -0
  62. package/docs/rules/check-property-names.md +244 -0
  63. package/docs/rules/check-syntax.md +80 -0
  64. package/docs/rules/check-tag-names.md +1116 -0
  65. package/docs/rules/check-types.md +1197 -0
  66. package/docs/rules/check-values.md +409 -0
  67. package/docs/rules/empty-tags.md +220 -0
  68. package/docs/rules/implements-on-classes.md +219 -0
  69. package/docs/rules/informative-docs.md +400 -0
  70. package/docs/rules/match-description.md +979 -0
  71. package/docs/rules/match-name.md +243 -0
  72. package/docs/rules/multiline-blocks.md +398 -0
  73. package/docs/rules/no-bad-blocks.md +174 -0
  74. package/docs/rules/no-blank-block-descriptions.md +91 -0
  75. package/docs/rules/no-blank-blocks.md +98 -0
  76. package/docs/rules/no-defaults.md +207 -0
  77. package/docs/rules/no-missing-syntax.md +269 -0
  78. package/docs/rules/no-multi-asterisks.md +278 -0
  79. package/docs/rules/no-restricted-syntax.md +377 -0
  80. package/docs/rules/no-types.md +168 -0
  81. package/docs/rules/no-undefined-types.md +730 -0
  82. package/docs/rules/require-asterisk-prefix.md +297 -0
  83. package/docs/rules/require-description-complete-sentence.md +584 -0
  84. package/docs/rules/require-description.md +820 -0
  85. package/docs/rules/require-example.md +390 -0
  86. package/docs/rules/require-file-overview.md +317 -0
  87. package/docs/rules/require-hyphen-before-param-description.md +258 -0
  88. package/docs/rules/require-jsdoc.md +1837 -0
  89. package/docs/rules/require-param-description.md +1816 -0
  90. package/docs/rules/require-param-name.md +238 -0
  91. package/docs/rules/require-param-type.md +163 -0
  92. package/docs/rules/require-param.md +227 -0
  93. package/docs/rules/require-property-description.md +128 -0
  94. package/docs/rules/require-property-name.md +88 -0
  95. package/docs/rules/require-property-type.md +79 -0
  96. package/docs/rules/require-property.md +79 -0
  97. package/docs/rules/require-returns-check.md +1164 -0
  98. package/docs/rules/require-returns-description.md +1053 -0
  99. package/docs/rules/require-returns-type.md +181 -0
  100. package/docs/rules/require-returns.md +144 -0
  101. package/docs/rules/require-throws.md +326 -0
  102. package/docs/rules/require-yields-check.md +823 -0
  103. package/docs/rules/require-yields.md +544 -0
  104. package/docs/rules/sort-tags.md +635 -0
  105. package/docs/rules/tag-lines.md +551 -0
  106. package/docs/rules/text-escaping.md +177 -0
  107. package/docs/rules/valid-types.md +833 -0
  108. package/docs/settings.md +355 -0
  109. package/package.json +15 -15
@@ -0,0 +1,833 @@
1
+ <a name="user-content-valid-types"></a>
2
+ <a name="valid-types"></a>
3
+ # <code>valid-types</code>
4
+
5
+ * [Options](#user-content-valid-types-options)
6
+ * [Context and settings](#user-content-valid-types-context-and-settings)
7
+ * [Failing examples](#user-content-valid-types-failing-examples)
8
+ * [Passing examples](#user-content-valid-types-passing-examples)
9
+
10
+
11
+ Requires all types/namepaths to be valid JSDoc, Closure compiler, or
12
+ TypeScript types (configured by `settings.jsdoc.mode`).
13
+
14
+ Note that what determines a valid type is handled by
15
+ our type parsing engine, [jsdoc-type-pratt-parser](https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser),
16
+ using [`settings.jsdoc.mode`](#user-content-eslint-plugin-jsdoc-settings-mode) to
17
+ determine whether to use jsdoc-type-pratt-parser's "permissive" parsing or
18
+ the stricter "jsdoc", "typescript", "closure" modes.
19
+
20
+ The following tags have their "type" portions (the segment within brackets)
21
+ checked (though those portions may sometimes be confined to namepaths,
22
+ e.g., `@modifies`):
23
+
24
+ 1. Tags with required types: `@type`, `@implements`
25
+ 1. Tags with required types in Closure or TypeScript: `@this`,
26
+ `@define` (Closure only)
27
+ 1. Tags with optional types: `@enum`, `@member` (`@var`), `@typedef`,
28
+ `@augments` (or `@extends`), `@class` (or `@constructor`), `@constant`
29
+ (or `@const`), `@module` (module paths are not planned for TypeScript),
30
+ `@namespace`, `@throws`, `@exception`, `@yields` (or `@yield`),
31
+ `@modifies` (undocumented jsdoc); `@param` (`@arg`, `@argument`),
32
+ `@property` (`@prop`), and `@returns` (`@return`) also fall into this
33
+ category, but while this rule will check their type validity, we leave
34
+ the requiring of the type portion to the rules `require-param-type`,
35
+ `require-property-type`, and `require-returns-type`, respectively.
36
+ 1. Tags with types that are available optionally in Closure: `@export`,
37
+ `@package`, `@private`, `@protected`, `@public`, `@static`;
38
+ `@template` (TypeScript also)
39
+ 1. Tags with optional types that may take free text instead: `@throws`
40
+
41
+ The following tags have their name/namepath portion (the non-whitespace
42
+ text after the tag name) checked:
43
+
44
+ 1. Name(path)-defining tags requiring namepath: `@event`, `@callback`,
45
+ `@exports` (JSDoc only),
46
+ `@external`, `@host`, `@name`, `@typedef` (JSDoc only), and `@template`
47
+ (TypeScript/Closure only); `@param` (`@arg`, `@argument`) and `@property`
48
+ (`@prop`) also fall into this category, but while this rule will check
49
+ their namepath validity, we leave the requiring of the name portion
50
+ to the rules `require-param-name` and `require-property-name`,
51
+ respectively.
52
+ 1. Name(path)-defining tags (which may have value without namepath or their
53
+ namepath can be expressed elsewhere on the block):
54
+ `@class`, `@constructor`, `@constant`, `@const`, `@function`, `@func`,
55
+ `@method`, `@interface` (non-Closure only), `@member`, `@var`,
56
+ `@mixin`, `@namespace`, `@module` (module paths are not planned for
57
+ TypeScript)
58
+ 1. Name(path)-pointing tags requiring namepath: `@alias`, `@augments`,
59
+ `@extends` (JSDoc only), `@lends`, `@memberof`, `@memberof!`, `@mixes`, `@requires`, `@this`
60
+ (jsdoc only)
61
+ 1. Name(path)-pointing tags (which may have value without namepath or their
62
+ namepath can be expressed elsewhere on the block): `@listens`, `@fires`,
63
+ `@emits`.
64
+ 1. Name(path)-pointing tags which may have free text or a namepath: `@see`
65
+ 1. Name(path)-pointing tags (multiple names in one): `@borrows`
66
+
67
+ ...with the following applying to the above sets:
68
+
69
+ - Expect tags in set 1-4 to have a valid namepath if present
70
+ - Prevent sets 2 and 4 from being empty by setting `allowEmptyNamepaths` to
71
+ `false` as these tags might have some indicative value without a path
72
+ or may allow a name expressed elsewhere on the block (but sets 1 and 3 will
73
+ always fail if empty)
74
+ - For the special case of set 6, i.e.,
75
+ `@borrows <that namepath> as <this namepath>`,
76
+ check that both namepaths are present and valid and ensure there is an `as `
77
+ between them. In the case of `<this namepath>`, it can be preceded by
78
+ one of the name path operators, `#`, `.`, or `~`.
79
+ - For the special case of `@memberof` and `@memberof!` (part of set 3), as
80
+ per the [specification](https://jsdoc.app/tags-memberof.html), they also
81
+ allow `#`, `.`, or `~` at the end (which is not allowed at the end of
82
+ normal paths).
83
+
84
+ If you define your own tags, `settings.jsdoc.structuredTags` will allow
85
+ these custom tags to be checked, with the name portion of tags checked for
86
+ valid namepaths (based on the tag's `name` value), their type portions checked
87
+ for valid types (based on the tag's `type` value), and either portion checked
88
+ for presence (based on `false` `name` or `type` values or their `required`
89
+ value). See the setting for more details.
90
+
91
+ <a name="user-content-valid-types-options"></a>
92
+ <a name="valid-types-options"></a>
93
+ ## Options
94
+
95
+ - `allowEmptyNamepaths` (default: true) - Set to `false` to bulk disallow
96
+ empty name paths with namepath groups 2 and 4 (these might often be
97
+ expected to have an accompanying name path, though they have some
98
+ indicative value without one; these may also allow names to be defined
99
+ in another manner elsewhere in the block); you can use
100
+ `settings.jsdoc.structuredTags` with the `required` key set to "name" if you
101
+ wish to require name paths on a tag-by-tag basis.
102
+
103
+ <a name="user-content-valid-types-context-and-settings"></a>
104
+ <a name="valid-types-context-and-settings"></a>
105
+ ## Context and settings
106
+
107
+ |||
108
+ |---|---|
109
+ |Context|everywhere|
110
+ |Tags|For name only unless otherwise stated: `alias`, `augments`, `borrows`, `callback`, `class` (for name and type), `constant` (for name and type), `enum` (for type), `event`, `external`, `fires`, `function`, `implements` (for type), `interface`, `lends`, `listens`, `member` (for name and type), `memberof`, `memberof!`, `mixes`, `mixin`, `modifies`, `module` (for name and type), `name`, `namespace` (for name and type), `param` (for name and type), `property` (for name and type), `returns` (for type), `see` (optionally for name), `this`, `throws` (for type), `type` (for type), `typedef` (for name and type), `yields` (for type)|
111
+ |Aliases|`extends`, `constructor`, `const`, `host`, `emits`, `func`, `method`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
112
+ |Closure-only|For type only: `package`, `private`, `protected`, `public`, `static`|
113
+ |Recommended|true|
114
+ |Options|`allowEmptyNamepaths`|
115
+ |Settings|`mode`, `structuredTags`|
116
+
117
+ <a name="user-content-valid-types-failing-examples"></a>
118
+ <a name="valid-types-failing-examples"></a>
119
+ ## Failing examples
120
+
121
+ The following patterns are considered problems:
122
+
123
+ ````js
124
+ /**
125
+ * @param {Array<string} foo
126
+ */
127
+ function quux() {
128
+
129
+ }
130
+ // Message: Syntax error in type: Array<string
131
+
132
+ /**
133
+ * @memberof module:namespace.SomeClass<~
134
+ */
135
+ function quux() {
136
+
137
+ }
138
+ // Message: Syntax error in namepath: module:namespace.SomeClass<~
139
+
140
+ /**
141
+ * @param someParam<~
142
+ */
143
+ function quux() {
144
+
145
+ }
146
+ // Message: Syntax error in namepath: someParam<~
147
+
148
+ /**
149
+ * @memberof module:namespace.SomeClass~<
150
+ */
151
+ function quux() {
152
+
153
+ }
154
+ // Message: Syntax error in namepath: module:namespace.SomeClass~<
155
+
156
+ /**
157
+ * @borrows foo% as bar
158
+ */
159
+ function quux() {
160
+
161
+ }
162
+ // Message: Syntax error in namepath: foo%
163
+
164
+ /**
165
+ * @borrows #foo as bar
166
+ */
167
+ function quux() {
168
+
169
+ }
170
+ // Message: Syntax error in namepath: #foo
171
+
172
+ /**
173
+ * @borrows foo as bar%
174
+ */
175
+ function quux() {
176
+
177
+ }
178
+ // Message: Syntax error in namepath: bar%
179
+
180
+ /**
181
+ * @borrows foo
182
+ */
183
+ function quux() {
184
+
185
+ }
186
+ // Message: @borrows must have an "as" expression. Found ""
187
+
188
+ /**
189
+ * @see foo%
190
+ */
191
+ function quux() {
192
+
193
+ }
194
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"name":"namepath-referencing","required":["name"]}}}}
195
+ // Message: Syntax error in namepath: foo%
196
+
197
+ /**
198
+ * @mixes module:namespace.SomeClass~
199
+ */
200
+ function quux() {
201
+
202
+ }
203
+ // Message: Syntax error in namepath: module:namespace.SomeClass~
204
+
205
+ /**
206
+ * @callback
207
+ */
208
+ function quux() {
209
+
210
+ }
211
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
212
+ // Message: Tag @callback must have a name/namepath.
213
+
214
+ /**
215
+ * @constant {str%ng}
216
+ */
217
+ const FOO = 'foo';
218
+ // Message: Syntax error in type: str%ng
219
+
220
+ /**
221
+ * @typedef {str%ng} UserString
222
+ */
223
+ // Message: Syntax error in type: str%ng
224
+
225
+ /**
226
+ * @typedef {string} UserStr%ng
227
+ */
228
+ // Message: Syntax error in namepath: UserStr%ng
229
+
230
+ /**
231
+ * @this
232
+ */
233
+ class Bar {};
234
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
235
+ // Message: Tag @this must have either a type or namepath in "jsdoc" mode.
236
+
237
+ /**
238
+ * @aCustomTag
239
+ */
240
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"required":["typeOrNameRequired"]}}}}
241
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
242
+ // Message: Tag @aCustomTag must have either a type or namepath.
243
+
244
+ /**
245
+ * @type
246
+ */
247
+ let foo;
248
+ // Message: Tag @type must have a type.
249
+
250
+ /**
251
+ * @modifies {bar | foo<}
252
+ */
253
+ function quux (foo, bar, baz) {}
254
+ // Message: Syntax error in type: bar | foo<
255
+
256
+ /**
257
+ * @private {BadTypeChecked<}
258
+ */
259
+ function quux () {}
260
+ // Settings: {"jsdoc":{"mode":"closure"}}
261
+ // Message: Syntax error in type: BadTypeChecked<
262
+
263
+ /**
264
+ * @this {BadTypeChecked<}
265
+ */
266
+ function quux () {}
267
+ // Settings: {"jsdoc":{"mode":"closure"}}
268
+ // Message: Syntax error in type: BadTypeChecked<
269
+
270
+ /**
271
+ * @define
272
+ */
273
+ function quux () {}
274
+ // Settings: {"jsdoc":{"mode":"closure"}}
275
+ // Message: Tag @define must have a type in "closure" mode.
276
+
277
+ /**
278
+ * @this
279
+ */
280
+ let foo;
281
+ // Settings: {"jsdoc":{"mode":"closure"}}
282
+ // Message: Tag @this must have a type in "closure" mode.
283
+
284
+ /**
285
+ * Foo function.
286
+ *
287
+ * @param {[number, string]} bar - The bar array.
288
+ */
289
+ function foo(bar) {}
290
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
291
+ // Message: Syntax error in type: [number, string]
292
+
293
+ /**
294
+ * @interface name<
295
+ */
296
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
297
+ // Message: Syntax error in namepath: name<
298
+
299
+ /**
300
+ * @module name<
301
+ */
302
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
303
+ // Message: Syntax error in namepath: name<
304
+
305
+ /**
306
+ * @module module:name<
307
+ */
308
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
309
+ // Message: Syntax error in namepath: module:name<
310
+
311
+ /**
312
+ * @interface name
313
+ */
314
+ // Settings: {"jsdoc":{"mode":"closure"}}
315
+ // Message: @interface should not have a name in "closure" mode.
316
+
317
+ /**
318
+ * @aCustomTag name
319
+ */
320
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"name":false}}}}
321
+ // Message: @aCustomTag should not have a name.
322
+
323
+ /**
324
+ * @typedef {SomeType}
325
+ */
326
+ function quux () {}
327
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
328
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
329
+ // Message: Tag @typedef must have a name/namepath in "jsdoc" mode.
330
+
331
+ /**
332
+ * @private {SomeType}
333
+ */
334
+ function quux () {}
335
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
336
+ // Message: @private should not have a bracketed type in "jsdoc" mode.
337
+
338
+ /**
339
+ * @aCustomTag {SomeType}
340
+ */
341
+ function quux () {}
342
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":false}}}}
343
+ // Message: @aCustomTag should not have a bracketed type.
344
+
345
+ /**
346
+ * @see foo%
347
+ */
348
+ function quux() {
349
+
350
+ }
351
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["name"]}}}}
352
+ // Message: Cannot add "name" to `require` with the tag's `name` set to `false`
353
+
354
+ /**
355
+ * @see foo%
356
+ */
357
+ function quux() {
358
+
359
+ }
360
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"required":["type"],"type":false}}}}
361
+ // Message: Cannot add "type" to `require` with the tag's `type` set to `false`
362
+
363
+ /**
364
+ * @see foo%
365
+ */
366
+ function quux() {
367
+
368
+ }
369
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["typeOrNameRequired"]}}}}
370
+ // Message: Cannot add "typeOrNameRequired" to `require` with the tag's `name` set to `false`
371
+
372
+ /**
373
+ * @see foo%
374
+ */
375
+ function quux() {
376
+
377
+ }
378
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"required":["typeOrNameRequired"],"type":false}}}}
379
+ // Message: Cannot add "typeOrNameRequired" to `require` with the tag's `type` set to `false`
380
+
381
+ /**
382
+ * @template T<~, R
383
+ * @param {function(!T): !R} parser
384
+ * @return {function(!Array<!T>): !Array<!R>}
385
+ */
386
+ parseArray = function(parser) {
387
+ return function(array) {
388
+ return array.map(parser);
389
+ };
390
+ };
391
+ // Settings: {"jsdoc":{"mode":"closure"}}
392
+ // Message: Syntax error in namepath: T<~
393
+
394
+ /**
395
+ * @template T, R<~
396
+ * @param {function(!T): !R} parser
397
+ * @return {function(!Array<!T>): !Array<!R>}
398
+ */
399
+ parseArray = function(parser) {
400
+ return function(array) {
401
+ return array.map(parser);
402
+ };
403
+ };
404
+ // Settings: {"jsdoc":{"mode":"closure"}}
405
+ // Message: Syntax error in namepath: R<~
406
+
407
+ /**
408
+ * @template T, R<~
409
+ * @param {function(!T): !R} parser
410
+ * @return {function(!Array<!T>): !Array<!R>}
411
+ */
412
+ parseArray = function(parser) {
413
+ return function(array) {
414
+ return array.map(parser);
415
+ };
416
+ };
417
+ // Settings: {"jsdoc":{"mode":"closure"}}
418
+ // Message: Syntax error in namepath: R<~
419
+
420
+ /**
421
+ * @suppress
422
+ */
423
+ function quux () {}
424
+ // Settings: {"jsdoc":{"mode":"closure"}}
425
+ // Message: Tag @suppress must have a type in "closure" mode.
426
+
427
+ /**
428
+ * @suppress {visibility} sth
429
+ */
430
+ function quux () {}
431
+ // Settings: {"jsdoc":{"mode":"closure"}}
432
+ // Message: @suppress should not have a name in "closure" mode.
433
+
434
+ /**
435
+ * @suppress {visibility|blah}
436
+ */
437
+ function quux () {}
438
+ // Settings: {"jsdoc":{"mode":"closure"}}
439
+ // Message: Syntax error in supresss type: blah
440
+
441
+ /**
442
+ * @param {Object[]} employees
443
+ * @param {string} employees[.name - The name of an employee.
444
+ */
445
+ function quux () {}
446
+ // Message: Invalid name: unpaired brackets
447
+
448
+ /**
449
+ * @param {Object[]} employees
450
+ * @param {string} [] - The name of an employee.
451
+ */
452
+ function quux () {}
453
+ // Message: Invalid name: empty name
454
+
455
+ /**
456
+ * @param {Object[]} employees
457
+ * @param {string} [] - The name of an employee.
458
+ */
459
+ function quux () {}
460
+ // Message: Invalid name: empty name
461
+
462
+ /**
463
+ * @param {string} [name=] - The name of an employee.
464
+ */
465
+ function quux () {}
466
+ // Message: Invalid name: empty default value
467
+
468
+ /**
469
+ * @param {string} [name==] - The name of an employee.
470
+ */
471
+ function quux () {}
472
+ // Message: Invalid name: invalid default value syntax
473
+ ````
474
+
475
+
476
+
477
+ <a name="user-content-valid-types-passing-examples"></a>
478
+ <a name="valid-types-passing-examples"></a>
479
+ ## Passing examples
480
+
481
+ The following patterns are not considered problems:
482
+
483
+ ````js
484
+ /**
485
+ * @param {Array<string>} foo
486
+ */
487
+ function quux() {
488
+
489
+ }
490
+
491
+ /**
492
+ * @param {string} foo
493
+ */
494
+ function quux() {
495
+
496
+ }
497
+
498
+ /**
499
+ * @param foo
500
+ */
501
+ function quux() {
502
+
503
+ }
504
+
505
+ /**
506
+ * @borrows foo as bar
507
+ */
508
+ function quux() {
509
+
510
+ }
511
+
512
+ /**
513
+ * @borrows foo as #bar
514
+ */
515
+ function quux() {
516
+
517
+ }
518
+
519
+ /**
520
+ * @see foo%
521
+ */
522
+ function quux() {
523
+
524
+ }
525
+
526
+ /**
527
+ * @alias module:namespace.SomeClass#event:ext_anevent
528
+ */
529
+ function quux() {
530
+
531
+ }
532
+
533
+ /**
534
+ * @callback foo
535
+ */
536
+ function quux() {
537
+
538
+ }
539
+
540
+ /**
541
+ * @callback
542
+ */
543
+ function quux() {
544
+
545
+ }
546
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":true}]
547
+
548
+ /**
549
+ * @class
550
+ */
551
+ function quux() {
552
+
553
+ }
554
+
555
+ /**
556
+ * @see {@link foo}
557
+ */
558
+ function quux() {
559
+
560
+ }
561
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"name":"namepath-referencing","required":["name"]}}}}
562
+
563
+ /**
564
+ *
565
+ * @fires module:namespace.SomeClass#event:ext_anevent
566
+ */
567
+ function quux() {
568
+
569
+ }
570
+
571
+ /**
572
+ * @memberof module:namespace.SomeClass~
573
+ */
574
+ function quux() {
575
+
576
+ }
577
+
578
+ /**
579
+ * @memberof! module:namespace.SomeClass.
580
+ */
581
+ function quux() {
582
+
583
+ }
584
+
585
+ /**
586
+ *
587
+ */
588
+ function quux() {
589
+
590
+ }
591
+
592
+ /**
593
+ * @aCustomTag
594
+ */
595
+ function quux() {
596
+
597
+ }
598
+
599
+ /**
600
+ * @constant {string}
601
+ */
602
+ const FOO = 'foo';
603
+
604
+ /**
605
+ * @constant {string} FOO
606
+ */
607
+ const FOO = 'foo';
608
+
609
+ /**
610
+ * @extends Foo
611
+ */
612
+ class Bar {};
613
+
614
+ /**
615
+ * @extends Foo<String>
616
+ */
617
+ class Bar {};
618
+
619
+ /**
620
+ * @extends {Foo<String>}
621
+ */
622
+ class Bar {};
623
+ // Settings: {"jsdoc":{"mode":"closure"}}
624
+
625
+ /**
626
+ * @typedef {number | string} UserDefinedType
627
+ */
628
+
629
+ /**
630
+ * @typedef {number | string}
631
+ */
632
+ let UserDefinedGCCType;
633
+ // Settings: {"jsdoc":{"mode":"closure"}}
634
+
635
+ /**
636
+ * @modifies {foo | bar}
637
+ */
638
+ function quux (foo, bar, baz) {}
639
+
640
+ /**
641
+ * @this {Navigator}
642
+ */
643
+ function quux () {}
644
+ // Settings: {"jsdoc":{"mode":"closure"}}
645
+
646
+ /**
647
+ * @export {SomeType}
648
+ */
649
+ function quux () {}
650
+ // Settings: {"jsdoc":{"mode":"closure"}}
651
+
652
+ /**
653
+ * @define {boolean}
654
+ */
655
+ function quux () {}
656
+ // Settings: {"jsdoc":{"mode":"closure"}}
657
+
658
+ /**
659
+ * @define
660
+ */
661
+ function quux () {}
662
+
663
+ /**
664
+ * Foo function.
665
+ *
666
+ * @interface foo
667
+ */
668
+ function foo(bar) {}
669
+ // Settings: {"jsdoc":{"mode":"typescript"}}
670
+
671
+ /**
672
+ * Foo function.
673
+ *
674
+ * @param {[number, string]} bar - The bar array.
675
+ */
676
+ function foo(bar) {}
677
+ // Settings: {"jsdoc":{"mode":"typescript"}}
678
+
679
+ /**
680
+ * Foo function.
681
+ *
682
+ * @param {[number, string]} bar - The bar array.
683
+ */
684
+ function foo(bar) {}
685
+
686
+ /**
687
+ * Foo function.
688
+ *
689
+ * @param {[number, string]} bar - The bar array.
690
+ */
691
+ function foo(bar) {}
692
+ // Settings: {"jsdoc":{"mode":"permissive"}}
693
+
694
+ /**
695
+ * @typedef {SomeType}
696
+ */
697
+ function quux () {}
698
+ // Settings: {"jsdoc":{"mode":"closure"}}
699
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
700
+
701
+ /**
702
+ * @private {SomeType}
703
+ */
704
+ function quux () {}
705
+ // Settings: {"jsdoc":{"mode":"closure"}}
706
+
707
+ /**
708
+ * @param
709
+ */
710
+ function quux() {
711
+
712
+ }
713
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
714
+
715
+ /**
716
+ * @see
717
+ */
718
+ function quux() {
719
+
720
+ }
721
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"name":"namepath-referencing"}}}}
722
+
723
+ /**
724
+ * @template T, R
725
+ * @param {function(!T): !R} parser
726
+ * @return {function(!Array<!T>): !Array<!R>}
727
+ */
728
+ parseArray = function(parser) {
729
+ return function(array) {
730
+ return array.map(parser);
731
+ };
732
+ };
733
+ // Settings: {"jsdoc":{"mode":"closure"}}
734
+
735
+ /**
736
+ * @template T, R<~
737
+ * @param {function(!T): !R} parser
738
+ * @return {function(!Array<!T>): !Array<!R>}
739
+ */
740
+ parseArray = function(parser) {
741
+ return function(array) {
742
+ return array.map(parser);
743
+ };
744
+ };
745
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
746
+
747
+ /**
748
+ * @template {string} K - K must be a string or string literal
749
+ * @template {{ serious: string }} Seriousalizable - must have a serious property
750
+ * @param {K} key
751
+ * @param {Seriousalizable} object
752
+ */
753
+ function seriousalize(key, object) {
754
+ // ????
755
+ }
756
+ // Settings: {"jsdoc":{"mode":"typescript"}}
757
+
758
+ /**
759
+ * @module foo/bar
760
+ */
761
+
762
+ /**
763
+ * @module module:foo/bar
764
+ */
765
+
766
+ /**
767
+ * @template invalid namepath,T Description
768
+ */
769
+ function f() {}
770
+ // Settings: {"jsdoc":{"mode":"closure"}}
771
+
772
+ /**
773
+ * Description of complicated type.
774
+ *
775
+ * @template T Description of the T type parameter.
776
+ * @template U - Like other tags, this can have an optional hyphen before the description.
777
+ * @template V,W More parameters
778
+ * @template W,X - Also with a hyphen
779
+ */
780
+ type ComplicatedType<T, U, V, W, X> = never
781
+
782
+ /** Multi-line typedef for an options object type.
783
+ *
784
+ * @typedef {{
785
+ * prop: number
786
+ * }} MyOptions
787
+ */
788
+
789
+ /**
790
+ * @extends {SomeType}
791
+ */
792
+ class quux {}
793
+ // Settings: {"jsdoc":{"mode":"typescript"}}
794
+
795
+ /**
796
+ * @suppress {visibility|underscore}
797
+ */
798
+ function quux() {
799
+ }
800
+ // Settings: {"jsdoc":{"mode":"closure"}}
801
+
802
+ /**
803
+ * @param {string} id
804
+ * @param {Object} options
805
+ * @param {boolean} options.isSet
806
+ * @param {string} options.module
807
+ */
808
+ function quux ( id, options ) {
809
+ }
810
+
811
+
812
+ /**
813
+ * Assign the project to a list of employees.
814
+ * @param {Object[]} employees - The employees who are responsible for the project.
815
+ * @param {string} employees[].name - The name of an employee.
816
+ * @param {string} employees[].department - The employee's department.
817
+ */
818
+ function assign(employees) {
819
+ // ...
820
+ }
821
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":true}]
822
+
823
+ /**
824
+ * @param {typeof obj["level1"]["level2"]} foo
825
+ * @param {Parameters<testFunc>[0]} ghi
826
+ * @param {{[key: string]: string}} hjk
827
+ */
828
+ function quux() {
829
+
830
+ }
831
+ // Settings: {"jsdoc":{"mode":"typescript"}}
832
+ ````
833
+