eslint-plugin-jsdoc 43.1.1 → 44.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 (109) hide show
  1. package/README.md +58 -24393
  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 +2 -2
  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 +1117 -0
  65. package/docs/rules/check-types.md +1198 -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 +731 -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 +834 -0
  108. package/docs/settings.md +355 -0
  109. package/package.json +15 -15
@@ -0,0 +1,834 @@
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
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
235
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
236
+ // Message: Tag @this must have either a type or namepath in "jsdoc" mode.
237
+
238
+ /**
239
+ * @aCustomTag
240
+ */
241
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"required":["typeOrNameRequired"]}}}}
242
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
243
+ // Message: Tag @aCustomTag must have either a type or namepath.
244
+
245
+ /**
246
+ * @type
247
+ */
248
+ let foo;
249
+ // Message: Tag @type must have a type.
250
+
251
+ /**
252
+ * @modifies {bar | foo<}
253
+ */
254
+ function quux (foo, bar, baz) {}
255
+ // Message: Syntax error in type: bar | foo<
256
+
257
+ /**
258
+ * @private {BadTypeChecked<}
259
+ */
260
+ function quux () {}
261
+ // Settings: {"jsdoc":{"mode":"closure"}}
262
+ // Message: Syntax error in type: BadTypeChecked<
263
+
264
+ /**
265
+ * @this {BadTypeChecked<}
266
+ */
267
+ function quux () {}
268
+ // Settings: {"jsdoc":{"mode":"closure"}}
269
+ // Message: Syntax error in type: BadTypeChecked<
270
+
271
+ /**
272
+ * @define
273
+ */
274
+ function quux () {}
275
+ // Settings: {"jsdoc":{"mode":"closure"}}
276
+ // Message: Tag @define must have a type in "closure" mode.
277
+
278
+ /**
279
+ * @this
280
+ */
281
+ let foo;
282
+ // Settings: {"jsdoc":{"mode":"closure"}}
283
+ // Message: Tag @this must have a type in "closure" mode.
284
+
285
+ /**
286
+ * Foo function.
287
+ *
288
+ * @param {[number, string]} bar - The bar array.
289
+ */
290
+ function foo(bar) {}
291
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
292
+ // Message: Syntax error in type: [number, string]
293
+
294
+ /**
295
+ * @interface name<
296
+ */
297
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
298
+ // Message: Syntax error in namepath: name<
299
+
300
+ /**
301
+ * @module name<
302
+ */
303
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
304
+ // Message: Syntax error in namepath: name<
305
+
306
+ /**
307
+ * @module module:name<
308
+ */
309
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
310
+ // Message: Syntax error in namepath: module:name<
311
+
312
+ /**
313
+ * @interface name
314
+ */
315
+ // Settings: {"jsdoc":{"mode":"closure"}}
316
+ // Message: @interface should not have a name in "closure" mode.
317
+
318
+ /**
319
+ * @aCustomTag name
320
+ */
321
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"name":false}}}}
322
+ // Message: @aCustomTag should not have a name.
323
+
324
+ /**
325
+ * @typedef {SomeType}
326
+ */
327
+ function quux () {}
328
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
329
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
330
+ // Message: Tag @typedef must have a name/namepath in "jsdoc" mode.
331
+
332
+ /**
333
+ * @private {SomeType}
334
+ */
335
+ function quux () {}
336
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
337
+ // Message: @private should not have a bracketed type in "jsdoc" mode.
338
+
339
+ /**
340
+ * @aCustomTag {SomeType}
341
+ */
342
+ function quux () {}
343
+ // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":false}}}}
344
+ // Message: @aCustomTag should not have a bracketed type.
345
+
346
+ /**
347
+ * @see foo%
348
+ */
349
+ function quux() {
350
+
351
+ }
352
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["name"]}}}}
353
+ // Message: Cannot add "name" to `require` with the tag's `name` set to `false`
354
+
355
+ /**
356
+ * @see foo%
357
+ */
358
+ function quux() {
359
+
360
+ }
361
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"required":["type"],"type":false}}}}
362
+ // Message: Cannot add "type" to `require` with the tag's `type` set to `false`
363
+
364
+ /**
365
+ * @see foo%
366
+ */
367
+ function quux() {
368
+
369
+ }
370
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"name":false,"required":["typeOrNameRequired"]}}}}
371
+ // Message: Cannot add "typeOrNameRequired" to `require` with the tag's `name` set to `false`
372
+
373
+ /**
374
+ * @see foo%
375
+ */
376
+ function quux() {
377
+
378
+ }
379
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"required":["typeOrNameRequired"],"type":false}}}}
380
+ // Message: Cannot add "typeOrNameRequired" to `require` with the tag's `type` set to `false`
381
+
382
+ /**
383
+ * @template T<~, R
384
+ * @param {function(!T): !R} parser
385
+ * @return {function(!Array<!T>): !Array<!R>}
386
+ */
387
+ parseArray = function(parser) {
388
+ return function(array) {
389
+ return array.map(parser);
390
+ };
391
+ };
392
+ // Settings: {"jsdoc":{"mode":"closure"}}
393
+ // Message: Syntax error in namepath: T<~
394
+
395
+ /**
396
+ * @template T, R<~
397
+ * @param {function(!T): !R} parser
398
+ * @return {function(!Array<!T>): !Array<!R>}
399
+ */
400
+ parseArray = function(parser) {
401
+ return function(array) {
402
+ return array.map(parser);
403
+ };
404
+ };
405
+ // Settings: {"jsdoc":{"mode":"closure"}}
406
+ // Message: Syntax error in namepath: R<~
407
+
408
+ /**
409
+ * @template T, R<~
410
+ * @param {function(!T): !R} parser
411
+ * @return {function(!Array<!T>): !Array<!R>}
412
+ */
413
+ parseArray = function(parser) {
414
+ return function(array) {
415
+ return array.map(parser);
416
+ };
417
+ };
418
+ // Settings: {"jsdoc":{"mode":"closure"}}
419
+ // Message: Syntax error in namepath: R<~
420
+
421
+ /**
422
+ * @suppress
423
+ */
424
+ function quux () {}
425
+ // Settings: {"jsdoc":{"mode":"closure"}}
426
+ // Message: Tag @suppress must have a type in "closure" mode.
427
+
428
+ /**
429
+ * @suppress {visibility} sth
430
+ */
431
+ function quux () {}
432
+ // Settings: {"jsdoc":{"mode":"closure"}}
433
+ // Message: @suppress should not have a name in "closure" mode.
434
+
435
+ /**
436
+ * @suppress {visibility|blah}
437
+ */
438
+ function quux () {}
439
+ // Settings: {"jsdoc":{"mode":"closure"}}
440
+ // Message: Syntax error in supresss type: blah
441
+
442
+ /**
443
+ * @param {Object[]} employees
444
+ * @param {string} employees[.name - The name of an employee.
445
+ */
446
+ function quux () {}
447
+ // Message: Invalid name: unpaired brackets
448
+
449
+ /**
450
+ * @param {Object[]} employees
451
+ * @param {string} [] - The name of an employee.
452
+ */
453
+ function quux () {}
454
+ // Message: Invalid name: empty name
455
+
456
+ /**
457
+ * @param {Object[]} employees
458
+ * @param {string} [] - The name of an employee.
459
+ */
460
+ function quux () {}
461
+ // Message: Invalid name: empty name
462
+
463
+ /**
464
+ * @param {string} [name=] - The name of an employee.
465
+ */
466
+ function quux () {}
467
+ // Message: Invalid name: empty default value
468
+
469
+ /**
470
+ * @param {string} [name==] - The name of an employee.
471
+ */
472
+ function quux () {}
473
+ // Message: Invalid name: invalid default value syntax
474
+ ````
475
+
476
+
477
+
478
+ <a name="user-content-valid-types-passing-examples"></a>
479
+ <a name="valid-types-passing-examples"></a>
480
+ ## Passing examples
481
+
482
+ The following patterns are not considered problems:
483
+
484
+ ````js
485
+ /**
486
+ * @param {Array<string>} foo
487
+ */
488
+ function quux() {
489
+
490
+ }
491
+
492
+ /**
493
+ * @param {string} foo
494
+ */
495
+ function quux() {
496
+
497
+ }
498
+
499
+ /**
500
+ * @param foo
501
+ */
502
+ function quux() {
503
+
504
+ }
505
+
506
+ /**
507
+ * @borrows foo as bar
508
+ */
509
+ function quux() {
510
+
511
+ }
512
+
513
+ /**
514
+ * @borrows foo as #bar
515
+ */
516
+ function quux() {
517
+
518
+ }
519
+
520
+ /**
521
+ * @see foo%
522
+ */
523
+ function quux() {
524
+
525
+ }
526
+
527
+ /**
528
+ * @alias module:namespace.SomeClass#event:ext_anevent
529
+ */
530
+ function quux() {
531
+
532
+ }
533
+
534
+ /**
535
+ * @callback foo
536
+ */
537
+ function quux() {
538
+
539
+ }
540
+
541
+ /**
542
+ * @callback
543
+ */
544
+ function quux() {
545
+
546
+ }
547
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":true}]
548
+
549
+ /**
550
+ * @class
551
+ */
552
+ function quux() {
553
+
554
+ }
555
+
556
+ /**
557
+ * @see {@link foo}
558
+ */
559
+ function quux() {
560
+
561
+ }
562
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"name":"namepath-referencing","required":["name"]}}}}
563
+
564
+ /**
565
+ *
566
+ * @fires module:namespace.SomeClass#event:ext_anevent
567
+ */
568
+ function quux() {
569
+
570
+ }
571
+
572
+ /**
573
+ * @memberof module:namespace.SomeClass~
574
+ */
575
+ function quux() {
576
+
577
+ }
578
+
579
+ /**
580
+ * @memberof! module:namespace.SomeClass.
581
+ */
582
+ function quux() {
583
+
584
+ }
585
+
586
+ /**
587
+ *
588
+ */
589
+ function quux() {
590
+
591
+ }
592
+
593
+ /**
594
+ * @aCustomTag
595
+ */
596
+ function quux() {
597
+
598
+ }
599
+
600
+ /**
601
+ * @constant {string}
602
+ */
603
+ const FOO = 'foo';
604
+
605
+ /**
606
+ * @constant {string} FOO
607
+ */
608
+ const FOO = 'foo';
609
+
610
+ /**
611
+ * @extends Foo
612
+ */
613
+ class Bar {};
614
+
615
+ /**
616
+ * @extends Foo<String>
617
+ */
618
+ class Bar {};
619
+
620
+ /**
621
+ * @extends {Foo<String>}
622
+ */
623
+ class Bar {};
624
+ // Settings: {"jsdoc":{"mode":"closure"}}
625
+
626
+ /**
627
+ * @typedef {number | string} UserDefinedType
628
+ */
629
+
630
+ /**
631
+ * @typedef {number | string}
632
+ */
633
+ let UserDefinedGCCType;
634
+ // Settings: {"jsdoc":{"mode":"closure"}}
635
+
636
+ /**
637
+ * @modifies {foo | bar}
638
+ */
639
+ function quux (foo, bar, baz) {}
640
+
641
+ /**
642
+ * @this {Navigator}
643
+ */
644
+ function quux () {}
645
+ // Settings: {"jsdoc":{"mode":"closure"}}
646
+
647
+ /**
648
+ * @export {SomeType}
649
+ */
650
+ function quux () {}
651
+ // Settings: {"jsdoc":{"mode":"closure"}}
652
+
653
+ /**
654
+ * @define {boolean}
655
+ */
656
+ function quux () {}
657
+ // Settings: {"jsdoc":{"mode":"closure"}}
658
+
659
+ /**
660
+ * @define
661
+ */
662
+ function quux () {}
663
+
664
+ /**
665
+ * Foo function.
666
+ *
667
+ * @interface foo
668
+ */
669
+ function foo(bar) {}
670
+ // Settings: {"jsdoc":{"mode":"typescript"}}
671
+
672
+ /**
673
+ * Foo function.
674
+ *
675
+ * @param {[number, string]} bar - The bar array.
676
+ */
677
+ function foo(bar) {}
678
+ // Settings: {"jsdoc":{"mode":"typescript"}}
679
+
680
+ /**
681
+ * Foo function.
682
+ *
683
+ * @param {[number, string]} bar - The bar array.
684
+ */
685
+ function foo(bar) {}
686
+
687
+ /**
688
+ * Foo function.
689
+ *
690
+ * @param {[number, string]} bar - The bar array.
691
+ */
692
+ function foo(bar) {}
693
+ // Settings: {"jsdoc":{"mode":"permissive"}}
694
+
695
+ /**
696
+ * @typedef {SomeType}
697
+ */
698
+ function quux () {}
699
+ // Settings: {"jsdoc":{"mode":"closure"}}
700
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
701
+
702
+ /**
703
+ * @private {SomeType}
704
+ */
705
+ function quux () {}
706
+ // Settings: {"jsdoc":{"mode":"closure"}}
707
+
708
+ /**
709
+ * @param
710
+ */
711
+ function quux() {
712
+
713
+ }
714
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":false}]
715
+
716
+ /**
717
+ * @see
718
+ */
719
+ function quux() {
720
+
721
+ }
722
+ // Settings: {"jsdoc":{"structuredTags":{"see":{"name":"namepath-referencing"}}}}
723
+
724
+ /**
725
+ * @template T, R
726
+ * @param {function(!T): !R} parser
727
+ * @return {function(!Array<!T>): !Array<!R>}
728
+ */
729
+ parseArray = function(parser) {
730
+ return function(array) {
731
+ return array.map(parser);
732
+ };
733
+ };
734
+ // Settings: {"jsdoc":{"mode":"closure"}}
735
+
736
+ /**
737
+ * @template T, R<~
738
+ * @param {function(!T): !R} parser
739
+ * @return {function(!Array<!T>): !Array<!R>}
740
+ */
741
+ parseArray = function(parser) {
742
+ return function(array) {
743
+ return array.map(parser);
744
+ };
745
+ };
746
+ // Settings: {"jsdoc":{"mode":"jsdoc"}}
747
+
748
+ /**
749
+ * @template {string} K - K must be a string or string literal
750
+ * @template {{ serious: string }} Seriousalizable - must have a serious property
751
+ * @param {K} key
752
+ * @param {Seriousalizable} object
753
+ */
754
+ function seriousalize(key, object) {
755
+ // ????
756
+ }
757
+ // Settings: {"jsdoc":{"mode":"typescript"}}
758
+
759
+ /**
760
+ * @module foo/bar
761
+ */
762
+
763
+ /**
764
+ * @module module:foo/bar
765
+ */
766
+
767
+ /**
768
+ * @template invalid namepath,T Description
769
+ */
770
+ function f() {}
771
+ // Settings: {"jsdoc":{"mode":"closure"}}
772
+
773
+ /**
774
+ * Description of complicated type.
775
+ *
776
+ * @template T Description of the T type parameter.
777
+ * @template U - Like other tags, this can have an optional hyphen before the description.
778
+ * @template V,W More parameters
779
+ * @template W,X - Also with a hyphen
780
+ */
781
+ type ComplicatedType<T, U, V, W, X> = never
782
+
783
+ /** Multi-line typedef for an options object type.
784
+ *
785
+ * @typedef {{
786
+ * prop: number
787
+ * }} MyOptions
788
+ */
789
+
790
+ /**
791
+ * @extends {SomeType}
792
+ */
793
+ class quux {}
794
+ // Settings: {"jsdoc":{"mode":"typescript"}}
795
+
796
+ /**
797
+ * @suppress {visibility|underscore}
798
+ */
799
+ function quux() {
800
+ }
801
+ // Settings: {"jsdoc":{"mode":"closure"}}
802
+
803
+ /**
804
+ * @param {string} id
805
+ * @param {Object} options
806
+ * @param {boolean} options.isSet
807
+ * @param {string} options.module
808
+ */
809
+ function quux ( id, options ) {
810
+ }
811
+
812
+
813
+ /**
814
+ * Assign the project to a list of employees.
815
+ * @param {Object[]} employees - The employees who are responsible for the project.
816
+ * @param {string} employees[].name - The name of an employee.
817
+ * @param {string} employees[].department - The employee's department.
818
+ */
819
+ function assign(employees) {
820
+ // ...
821
+ }
822
+ // "jsdoc/valid-types": ["error"|"warn", {"allowEmptyNamepaths":true}]
823
+
824
+ /**
825
+ * @param {typeof obj["level1"]["level2"]} foo
826
+ * @param {Parameters<testFunc>[0]} ghi
827
+ * @param {{[key: string]: string}} hjk
828
+ */
829
+ function quux() {
830
+
831
+ }
832
+ // Settings: {"jsdoc":{"mode":"typescript"}}
833
+ ````
834
+