eslint-plugin-jsdoc 46.4.5 → 46.5.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 (66) hide show
  1. package/README.md +31 -0
  2. package/dist/alignTransform.js +5 -5
  3. package/dist/alignTransform.js.map +1 -1
  4. package/dist/index.js +21 -10
  5. package/dist/index.js.map +1 -1
  6. package/dist/iterateJsdoc.js +1 -1
  7. package/dist/iterateJsdoc.js.map +1 -1
  8. package/dist/rules/checkExamples.js +12 -6
  9. package/dist/rules/checkExamples.js.map +1 -1
  10. package/package.json +19 -15
  11. package/docs/advanced.md +0 -102
  12. package/docs/rules/check-access.md +0 -193
  13. package/docs/rules/check-alignment.md +0 -169
  14. package/docs/rules/check-examples.md +0 -784
  15. package/docs/rules/check-indentation.md +0 -296
  16. package/docs/rules/check-line-alignment.md +0 -1002
  17. package/docs/rules/check-param-names.md +0 -1035
  18. package/docs/rules/check-property-names.md +0 -244
  19. package/docs/rules/check-syntax.md +0 -80
  20. package/docs/rules/check-tag-names.md +0 -1132
  21. package/docs/rules/check-types.md +0 -1198
  22. package/docs/rules/check-values.md +0 -409
  23. package/docs/rules/empty-tags.md +0 -220
  24. package/docs/rules/implements-on-classes.md +0 -219
  25. package/docs/rules/imports-as-dependencies.md +0 -99
  26. package/docs/rules/informative-docs.md +0 -400
  27. package/docs/rules/match-description.md +0 -1008
  28. package/docs/rules/match-name.md +0 -249
  29. package/docs/rules/multiline-blocks.md +0 -398
  30. package/docs/rules/no-bad-blocks.md +0 -174
  31. package/docs/rules/no-blank-block-descriptions.md +0 -91
  32. package/docs/rules/no-blank-blocks.md +0 -98
  33. package/docs/rules/no-defaults.md +0 -207
  34. package/docs/rules/no-missing-syntax.md +0 -275
  35. package/docs/rules/no-multi-asterisks.md +0 -278
  36. package/docs/rules/no-restricted-syntax.md +0 -383
  37. package/docs/rules/no-types.md +0 -168
  38. package/docs/rules/no-undefined-types.md +0 -789
  39. package/docs/rules/require-asterisk-prefix.md +0 -297
  40. package/docs/rules/require-description-complete-sentence.md +0 -820
  41. package/docs/rules/require-description.md +0 -585
  42. package/docs/rules/require-example.md +0 -390
  43. package/docs/rules/require-file-overview.md +0 -324
  44. package/docs/rules/require-hyphen-before-param-description.md +0 -281
  45. package/docs/rules/require-jsdoc.md +0 -1857
  46. package/docs/rules/require-param-description.md +0 -238
  47. package/docs/rules/require-param-name.md +0 -163
  48. package/docs/rules/require-param-type.md +0 -227
  49. package/docs/rules/require-param.md +0 -1820
  50. package/docs/rules/require-property-description.md +0 -88
  51. package/docs/rules/require-property-name.md +0 -79
  52. package/docs/rules/require-property-type.md +0 -79
  53. package/docs/rules/require-property.md +0 -128
  54. package/docs/rules/require-returns-check.md +0 -1053
  55. package/docs/rules/require-returns-description.md +0 -181
  56. package/docs/rules/require-returns-type.md +0 -144
  57. package/docs/rules/require-returns.md +0 -1191
  58. package/docs/rules/require-throws.md +0 -326
  59. package/docs/rules/require-yields-check.md +0 -544
  60. package/docs/rules/require-yields.md +0 -823
  61. package/docs/rules/sort-tags.md +0 -635
  62. package/docs/rules/tag-lines.md +0 -551
  63. package/docs/rules/text-escaping.md +0 -177
  64. package/docs/rules/valid-types.md +0 -881
  65. package/docs/settings.md +0 -362
  66. package/tsconfig.json +0 -22
@@ -1,789 +0,0 @@
1
- <a name="user-content-no-undefined-types"></a>
2
- <a name="no-undefined-types"></a>
3
- # <code>no-undefined-types</code>
4
-
5
- * [Options](#user-content-no-undefined-types-options)
6
- * [Context and settings](#user-content-no-undefined-types-context-and-settings)
7
- * [Failing examples](#user-content-no-undefined-types-failing-examples)
8
- * [Passing examples](#user-content-no-undefined-types-passing-examples)
9
-
10
-
11
- Checks that types in jsdoc comments are defined. This can be used to check
12
- unimported types.
13
-
14
- When enabling this rule, types in jsdoc comments will resolve as used
15
- variables, i.e. will not be marked as unused by `no-unused-vars`.
16
-
17
- In addition to considering globals found in code (or in ESLint-indicated
18
- `globals`) as defined, the following tags will also be checked for
19
- name(path) definitions to also serve as a potential "type" for checking
20
- the tag types in the table below:
21
-
22
- `@callback`, `@class` (or `@constructor`), `@constant` (or `@const`),
23
- `@event`, `@external` (or `@host`), `@function` (or `@func` or `@method`),
24
- `@interface`, `@member` (or `@var`), `@mixin`, `@name`, `@namespace`,
25
- `@template` (for "closure" or "typescript" `settings.jsdoc.mode` only),
26
- `@typedef`.
27
-
28
- The following tags will also be checked but only when the mode is `closure`:
29
-
30
- `@package`, `@private`, `@protected`, `@public`, `@static`
31
-
32
- The following types are always considered defined.
33
-
34
- - `null`, `undefined`, `void`, `string`, `boolean`, `object`,
35
- `function`, `symbol`
36
- - `number`, `bigint`, `NaN`, `Infinity`
37
- - `any`, `*`, `never`, `unknown`, `const`
38
- - `this`, `true`, `false`
39
- - `Array`, `Object`, `RegExp`, `Date`, `Function`
40
-
41
- Note that preferred types indicated within `settings.jsdoc.preferredTypes` will
42
- also be assumed to be defined.
43
-
44
- Also note that if there is an error [parsing](https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser)
45
- types for a tag, the function will silently ignore that tag, leaving it to
46
- the `valid-types` rule to report parsing errors.
47
-
48
- If you define your own tags, you can use `settings.jsdoc.structuredTags`
49
- to indicate that a tag's `name` is "namepath-defining" (and should prevent
50
- reporting on use of that namepath elsewhere) and/or that a tag's `type` is
51
- `false` (and should not be checked for types). If the `type` is an array, that
52
- array's items will be considered as defined for the purposes of that tag.
53
-
54
- <a name="user-content-no-undefined-types-options"></a>
55
- <a name="no-undefined-types-options"></a>
56
- ## Options
57
-
58
- An option object may have the following keys:
59
-
60
- - `definedTypes` - This array can be populated to indicate other types which
61
- are automatically considered as defined (in addition to globals, etc.).
62
- Defaults to an empty array.
63
- - `markVariablesAsUsed` - Whether to mark variables as used for the purposes
64
- of the `no-unused-vars` rule when they are not found to be undefined.
65
- Defaults to `true`. May be set to `false` to enforce a practice of not
66
- importing types unless used in code.
67
- - `disableReporting` - Whether to disable reporting of errors. Defaults to
68
- `false`. This may be set to `true` in order to take advantage of only
69
- marking defined variables as used.
70
-
71
- <a name="user-content-no-undefined-types-context-and-settings"></a>
72
- <a name="no-undefined-types-context-and-settings"></a>
73
- ## Context and settings
74
-
75
- |||
76
- |---|---|
77
- |Context|everywhere|
78
- |Tags|`augments`, `class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
79
- |Aliases|`constructor`, `const`, `extends`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
80
- |Closure-only|`package`, `private`, `protected`, `public`, `static`|
81
- |Recommended|true|
82
- |Options|`definedTypes`, `disableReporting`, `markVariablesAsUsed`|
83
- |Settings|`preferredTypes`, `mode`, `structuredTags`|
84
-
85
-
86
- <a name="user-content-no-undefined-types-failing-examples"></a>
87
- <a name="no-undefined-types-failing-examples"></a>
88
- ## Failing examples
89
-
90
- The following patterns are considered problems:
91
-
92
- ````js
93
- /**
94
- * @param {HerType} baz - Foo.
95
- */
96
- function quux(foo, bar, baz) {
97
-
98
- }
99
- // Settings: {"jsdoc":{"preferredTypes":{"HerType":1000}}}
100
- // Message: Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.
101
-
102
- /**
103
- * @param {HerType} baz - Foo.
104
- */
105
- function quux(foo, bar, baz) {
106
-
107
- }
108
- // Settings: {"jsdoc":{"preferredTypes":{"HerType":false}}}
109
- // Message: The type 'HerType' is undefined.
110
-
111
- /**
112
- * @param {strnig} foo - Bar.
113
- */
114
- function quux(foo) {
115
-
116
- }
117
- // Message: The type 'strnig' is undefined.
118
-
119
- /**
120
- * @param {MyType} foo - Bar.
121
- * @param {HisType} bar - Foo.
122
- */
123
- function quux(foo, bar) {
124
-
125
- }
126
- // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
127
- // Message: The type 'HisType' is undefined.
128
-
129
- /**
130
- * @param {MyType} foo - Bar.
131
- * @param {HisType} bar - Foo.
132
- * @param {HerType} baz - Foo.
133
- */
134
- function quux(foo, bar, baz) {
135
-
136
- }
137
- // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"}}}}
138
- // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
139
- // Message: The type 'HisType' is undefined.
140
-
141
- /**
142
- * @param {MyType} foo - Bar.
143
- * @param {HisType} bar - Foo.
144
- * @param {HerType} baz - Foo.
145
- */
146
- function quux(foo, bar, baz) {
147
-
148
- }
149
- // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":false},"histype":"HisType"}}}
150
- // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
151
- // Message: The type 'HerType' is undefined.
152
-
153
- /**
154
- * @template TEMPLATE_TYPE
155
- * @param {WRONG_TEMPLATE_TYPE} bar
156
- */
157
- function foo (bar) {
158
- };
159
- // Settings: {"jsdoc":{"mode":"closure"}}
160
- // Message: The type 'WRONG_TEMPLATE_TYPE' is undefined.
161
-
162
- class Foo {
163
- /**
164
- * @return {TEMPLATE_TYPE}
165
- */
166
- bar () {
167
- }
168
- }
169
- // Message: The type 'TEMPLATE_TYPE' is undefined.
170
-
171
- class Foo {
172
- /**
173
- * @return {TEMPLATE_TYPE}
174
- */
175
- invalidTemplateReference () {
176
- }
177
- }
178
-
179
- /**
180
- * @template TEMPLATE_TYPE
181
- */
182
- class Bar {
183
- /**
184
- * @return {TEMPLATE_TYPE}
185
- */
186
- validTemplateReference () {
187
- }
188
- }
189
- // Settings: {"jsdoc":{"mode":"typescript"}}
190
- // Message: The type 'TEMPLATE_TYPE' is undefined.
191
-
192
- /**
193
- * @type {strnig}
194
- */
195
- var quux = {
196
-
197
- };
198
- // Message: The type 'strnig' is undefined.
199
-
200
- /**
201
- * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
202
- */
203
- class Foo {
204
- /**
205
- * @param {TEMPLATE_TYPE_A} baz
206
- * @return {TEMPLATE_TYPE_B}
207
- */
208
- bar (baz) {
209
- }
210
- }
211
- // Settings: {"jsdoc":{"mode":"jsdoc"}}
212
- // Message: The type 'TEMPLATE_TYPE_A' is undefined.
213
-
214
- /**
215
- * @param {...VAR_TYPE} varargs
216
- */
217
- function quux (varargs) {
218
- }
219
- // Message: The type 'VAR_TYPE' is undefined.
220
-
221
- /**
222
- * @this {Navigator}
223
- */
224
- function quux () {}
225
- // Settings: {"jsdoc":{"mode":"closure"}}
226
- // Message: The type 'Navigator' is undefined.
227
-
228
- /**
229
- * @export {SomeType}
230
- */
231
- function quux () {}
232
- // Settings: {"jsdoc":{"mode":"closure"}}
233
- // Message: The type 'SomeType' is undefined.
234
-
235
- /**
236
- * @aCustomTag {SomeType}
237
- */
238
- function quux () {}
239
- // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":true}}}}
240
- // Message: The type 'SomeType' is undefined.
241
-
242
- /**
243
- * @aCustomTag {SomeType}
244
- */
245
- function quux () {}
246
- // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["aType","anotherType"]}}}}
247
- // Message: The type 'SomeType' is undefined.
248
-
249
- /**
250
- * @namepathReferencing SomeType
251
- */
252
- /**
253
- * @type {SomeType}
254
- */
255
- // Settings: {"jsdoc":{"structuredTags":{"namepathReferencing":{"name":"namepath-referencing"}}}}
256
- // Message: The type 'SomeType' is undefined.
257
-
258
- /**
259
- * @template abc TEMPLATE_TYPE
260
- * @param {TEMPLATE_TYPE} bar
261
- */
262
- function foo (bar) {
263
- };
264
- // Settings: {"jsdoc":{"mode":"closure"}}
265
- // Message: The type 'TEMPLATE_TYPE' is undefined.
266
-
267
- /**
268
- * @suppress {visibility}
269
- */
270
- function foo () {
271
- }
272
- // Settings: {"jsdoc":{"mode":"jsdoc"}}
273
- // Message: The type 'visibility' is undefined.
274
-
275
- /**
276
- * @typedef Todo
277
- * @property description
278
- * @property otherStuff
279
- */
280
- /**
281
- * @type {Omit<Todo, "description">}
282
- */
283
- const a = new Todo();
284
- // Settings: {"jsdoc":{"mode":"jsdoc"}}
285
- // Message: The type 'Omit' is undefined.
286
-
287
- /**
288
- * Message with {@link NotKnown}
289
- */
290
- // Message: The type 'NotKnown' is undefined.
291
-
292
- /**
293
- * Message with
294
- * a link that is {@link NotKnown}
295
- */
296
- // Message: The type 'NotKnown' is undefined.
297
-
298
- /**
299
- * @abc
300
- * @someTag Message with
301
- * a link that is {@link NotKnown}
302
- */
303
- // Message: The type 'NotKnown' is undefined.
304
-
305
- /**
306
- * This is a {@namepathOrURLReferencer SomeType}.
307
- */
308
- // Settings: {"jsdoc":{"structuredTags":{"namepathOrURLReferencer":{"name":"namepath-or-url-referencing"}}}}
309
- // Message: The type 'SomeType' is undefined.
310
- ````
311
-
312
-
313
-
314
- <a name="user-content-no-undefined-types-passing-examples"></a>
315
- <a name="no-undefined-types-passing-examples"></a>
316
- ## Passing examples
317
-
318
- The following patterns are not considered problems:
319
-
320
- ````js
321
- /**
322
- * @param {string} foo - Bar.
323
- */
324
- function quux(foo) {
325
-
326
- }
327
-
328
- /**
329
- * @param {Promise} foo - Bar.
330
- */
331
- function quux(foo) {
332
-
333
- }
334
-
335
- class MyClass {}
336
-
337
- /**
338
- * @param {MyClass} foo - Bar.
339
- */
340
- function quux(foo) {
341
- console.log(foo);
342
- }
343
-
344
- quux(0);
345
-
346
- const MyType = require('my-library').MyType;
347
-
348
- /**
349
- * @param {MyType} foo - Bar.
350
- */
351
- function quux(foo) {
352
-
353
- }
354
-
355
- const MyType = require('my-library').MyType;
356
-
357
- /**
358
- * @param {MyType} foo - Bar.
359
- */
360
- function quux(foo) {
361
-
362
- }
363
-
364
- const MyType = require('my-library').MyType;
365
-
366
- /**
367
- * @param {MyType} foo - Bar.
368
- */
369
- function quux(foo) {
370
-
371
- }
372
-
373
- import {MyType} from 'my-library';
374
-
375
- /**
376
- * @param {MyType} foo - Bar.
377
- * @param {object<string, number>} foo
378
- * @param {Array<string>} baz
379
- */
380
- function quux(foo, bar, baz) {
381
-
382
- }
383
-
384
- /*globals MyType*/
385
-
386
- /**
387
- * @param {MyType} foo - Bar.
388
- * @param {HisType} bar - Foo.
389
- */
390
- function quux(foo, bar) {
391
-
392
- }
393
-
394
- /**
395
- * @typedef {object} hello
396
- * @property {string} a - a.
397
- */
398
-
399
- /**
400
- * @param {hello} foo
401
- */
402
- function quux(foo) {
403
-
404
- }
405
-
406
- /**
407
- * @param {Array<syntaxError} foo
408
- */
409
- function quux(foo) {
410
-
411
- }
412
-
413
- /**
414
- * Callback test.
415
- *
416
- * @callback addStuffCallback
417
- * @param {String} sum - An test integer.
418
- */
419
- /**
420
- * Test Eslint.
421
- *
422
- * @param {addStuffCallback} callback - A callback to run.
423
- */
424
- function testFunction(callback) {
425
- callback();
426
- }
427
-
428
- /**
429
- *
430
- *
431
- */
432
- function foo () {
433
-
434
- }
435
-
436
- /**
437
- * @param {MyType} foo - Bar.
438
- * @param {HisType} bar - Foo.
439
- */
440
- function quux(foo, bar) {
441
-
442
- }
443
- // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType","HisType"]}]
444
-
445
- /**
446
- * @param {MyType} foo - Bar.
447
- * @param {HisType} bar - Foo.
448
- * @param {HerType} baz - Foo.
449
- */
450
- function quux(foo, bar, baz) {
451
-
452
- }
453
- // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"},"histype":"HisType"}}}
454
- // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
455
-
456
- /**
457
- * @param {MyType} foo - Bar.
458
- * @param {HisType} bar - Foo.
459
- * @param {HerType} baz - Foo.
460
- */
461
- function quux(foo, bar, baz) {
462
-
463
- }
464
- // Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType<>"},"histype":"HisType.<>"}}}
465
- // "jsdoc/no-undefined-types": ["error"|"warn", {"definedTypes":["MyType"]}]
466
-
467
- /**
468
- * @template TEMPLATE_TYPE
469
- * @param {TEMPLATE_TYPE} bar
470
- * @return {TEMPLATE_TYPE}
471
- */
472
- function foo (bar) {
473
- };
474
- // Settings: {"jsdoc":{"mode":"closure"}}
475
-
476
- /**
477
- * @template TEMPLATE_TYPE
478
- */
479
- class Foo {
480
- /**
481
- * @return {TEMPLATE_TYPE}
482
- */
483
- bar () {
484
- }
485
- }
486
- // Settings: {"jsdoc":{"mode":"closure"}}
487
-
488
- /**
489
- * @template TEMPLATE_TYPE
490
- */
491
- class Foo {
492
- /**
493
- * @return {TEMPLATE_TYPE}
494
- */
495
- bar () {}
496
-
497
- /**
498
- * @return {TEMPLATE_TYPE}
499
- */
500
- baz () {}
501
- }
502
- // Settings: {"jsdoc":{"mode":"closure"}}
503
-
504
- /**
505
- * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
506
- */
507
- class Foo {
508
- /**
509
- * @param {TEMPLATE_TYPE_A} baz
510
- * @return {TEMPLATE_TYPE_B}
511
- */
512
- bar (baz) {
513
- }
514
- }
515
- // Settings: {"jsdoc":{"mode":"closure"}}
516
-
517
- /**
518
- * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B - Some description
519
- */
520
- class Foo {
521
- /**
522
- * @param {TEMPLATE_TYPE_A} baz
523
- * @return {TEMPLATE_TYPE_B}
524
- */
525
- bar (baz) {
526
- }
527
- }
528
- // Settings: {"jsdoc":{"mode":"closure"}}
529
-
530
- /****/
531
-
532
- /* */
533
-
534
- /*** */
535
-
536
- /**
537
- *
538
- */
539
- function quux () {
540
-
541
- }
542
-
543
- /**
544
- * @typedef {object} BaseObject
545
- */
546
- /**
547
- * Run callback when hooked method is called.
548
- *
549
- * @template {BaseObject} T
550
- * @param {T} obj - object whose method should be hooked.
551
- * @param {string} method - method which should be hooked.
552
- * @param {(sender: T) => void} callback - callback which should
553
- * be called when the hooked method was invoked.
554
- */
555
- function registerEvent(obj, method, callback) {
556
-
557
- }
558
- // Settings: {"jsdoc":{"mode":"typescript"}}
559
-
560
- /**
561
- * @param {...} varargs
562
- */
563
- function quux (varargs) {
564
- }
565
-
566
- /**
567
- * @param {...number} varargs
568
- */
569
- function quux (varargs) {
570
- }
571
-
572
- class Navigator {}
573
- /**
574
- * @this {Navigator}
575
- */
576
- function quux () {}
577
- // Settings: {"jsdoc":{"mode":"closure"}}
578
-
579
- class SomeType {}
580
- /**
581
- * @export {SomeType}
582
- */
583
- function quux () {}
584
- // Settings: {"jsdoc":{"mode":"closure"}}
585
-
586
- /**
587
- * @template T
588
- * @param {T} arg
589
- */
590
- function example(arg) {
591
-
592
- /** @param {T} */
593
- function inner(x) {
594
- }
595
- }
596
- // Settings: {"jsdoc":{"mode":"closure"}}
597
-
598
- const init = () => {
599
- /**
600
- * Makes request
601
- * @returns {Promise}
602
- */
603
- function request() {
604
- return Promise.resolve('success');
605
- }
606
- };
607
-
608
- /** Gets a Promise resolved with a given value.
609
- *
610
- * @template ValueType
611
- * @param {ValueType} value Value to resolve.
612
- * @returns {Promise<ValueType>} Promise resolved with value.
613
- */
614
- exports.resolve1 = function resolve1(value) {
615
- return Promise.resolve(value);
616
- };
617
- // Settings: {"jsdoc":{"mode":"typescript"}}
618
-
619
- /**
620
- * A function returning the same type as its argument.
621
- *
622
- * @template ValueType
623
- * @typedef {ValueType} ValueFunc
624
- */
625
- // Settings: {"jsdoc":{"mode":"typescript"}}
626
-
627
- /**
628
- * @aCustomTag {SomeType}
629
- */
630
- function quux () {}
631
- // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":false}}}}
632
-
633
- /**
634
- * @aCustomTag {SomeType}
635
- */
636
- function quux () {}
637
- // Settings: {"jsdoc":{"structuredTags":{"aCustomTag":{"type":["aType","SomeType"]}}}}
638
-
639
- /**
640
- * @namepathDefiner SomeType
641
- */
642
- /**
643
- * @type {SomeType}
644
- */
645
- // Settings: {"jsdoc":{"structuredTags":{"namepathDefiner":{"name":"namepath-defining"}}}}
646
-
647
- class Test {
648
- /**
649
- * Method.
650
- *
651
- * @returns {this} Return description.
652
- */
653
- method (): this {
654
- return this;
655
- }
656
- }
657
-
658
- /**
659
- * Bad types ignored here and handled instead by `valid-types`.
660
- * @param {string(} foo - Bar.
661
- */
662
- function quux(foo) {
663
-
664
- }
665
-
666
- /**
667
- * @template T
668
- * @param {T} arg
669
- * @returns {[T]}
670
- */
671
- function genericFunctionExample(arg) {
672
- const result = /** @type {[T]} */ (new Array());
673
- result[0] = arg;
674
- return result;
675
- }
676
- // Settings: {"jsdoc":{"mode":"closure"}}
677
-
678
- /** @typedef QDigestNode */
679
- class A {
680
- /**
681
- * @template {object} T
682
- * @param {(node: QDigestNode) => T} callback
683
- * @returns {T[]}
684
- */
685
- map(callback) {
686
- /** @type {T[]} */
687
- let vals;
688
- return vals;
689
- }
690
- }
691
- // Settings: {"jsdoc":{"mode":"typescript"}}
692
-
693
- /**
694
- * @template T
695
- * @param {T} arg
696
- */
697
- function example(arg) {
698
-
699
- /** @param {T} */
700
- function inner(x) {
701
- }
702
- }
703
- // Settings: {"jsdoc":{"mode":"typescript"}}
704
-
705
- /**
706
- * @suppress {visibility}
707
- */
708
- function foo () {
709
- }
710
- // Settings: {"jsdoc":{"mode":"closure"}}
711
-
712
- /**
713
- * @template T
714
- */
715
- export class Foo {
716
- // cast to T
717
- getType() {
718
- const x = "hello";
719
- const y = /** @type {T} */ (x);
720
- return y;
721
- }
722
- }
723
- // Settings: {"jsdoc":{"mode":"typescript"}}
724
-
725
- /**
726
- * @type {const}
727
- */
728
- const a = 'string';
729
-
730
- /**
731
- * @typedef Todo
732
- * @property description
733
- * @property otherStuff
734
- */
735
- /**
736
- * @type {Omit<Todo, "description">}
737
- */
738
- const a = new Todo();
739
- // Settings: {"jsdoc":{"mode":"typescript"}}
740
-
741
- /**
742
- * @template A, [B=SomeDefault]
743
- */
744
- class Foo {
745
- /**
746
- * @param {A} baz
747
- * @return {B}
748
- */
749
- bar (baz) {
750
- }
751
- }
752
- // Settings: {"jsdoc":{"mode":"typescript"}}
753
-
754
- import {MyType} from 'my-library';
755
-
756
- /**
757
- * @param {MyType} foo - Bar.
758
- * @param {AnUndefinedType} bar
759
- */
760
- function quux(foo, bar) {
761
-
762
- }
763
- // "jsdoc/no-undefined-types": ["error"|"warn", {"disableReporting":true}]
764
-
765
- class MyClass {}
766
- class AnotherClass {}
767
-
768
- /**
769
- * A description mentioning {@link MyClass} and {@link AnotherClass | another class} and a URL via [this link]{@link https://www.example.com}.
770
- */
771
- function quux(foo) {
772
- console.log(foo);
773
- }
774
-
775
- quux(0);
776
-
777
- class MyClass {}
778
- class AnotherClass {}
779
-
780
- /**
781
- * @see A tag mentioning {@link MyClass} and {@link AnotherClass | another class} and a URL via [this link]{@link https://www.example.com}.
782
- */
783
- function quux(foo) {
784
- console.log(foo);
785
- }
786
-
787
- quux(0);
788
- ````
789
-