UNPKG

208 kBMarkdownView Raw
1<a name="eslint-plugin-jsdoc"></a>
2# eslint-plugin-jsdoc
3
4[![GitSpo Mentions](https://gitspo.com/badges/mentions/gajus/eslint-plugin-jsdoc?style=flat-square)](https://gitspo.com/mentions/gajus/eslint-plugin-jsdoc)
5[![NPM version](http://img.shields.io/npm/v/eslint-plugin-jsdoc.svg?style=flat-square)](https://www.npmjs.org/package/eslint-plugin-jsdoc)
6[![Travis build status](http://img.shields.io/travis/gajus/eslint-plugin-jsdoc/master.svg?style=flat-square)](https://travis-ci.org/gajus/eslint-plugin-jsdoc)
7[![js-canonical-style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat-square)](https://github.com/gajus/canonical)
8
9JSDoc linting rules for ESLint.
10
11* [eslint-plugin-jsdoc](#eslint-plugin-jsdoc)
12 * [Installation](#eslint-plugin-jsdoc-installation)
13 * [Configuration](#eslint-plugin-jsdoc-configuration)
14 * [Options](#eslint-plugin-jsdoc-options)
15 * [Settings](#eslint-plugin-jsdoc-settings)
16 * [Allow `@private` to disable rules for that comment block](#eslint-plugin-jsdoc-settings-allow-private-to-disable-rules-for-that-comment-block)
17 * [Mode](#eslint-plugin-jsdoc-settings-mode)
18 * [Alias Preference](#eslint-plugin-jsdoc-settings-alias-preference)
19 * [`@override`/`@augments`/`@extends`/`@implements` Without Accompanying `@param`/`@description`/`@example`/`@returns`](#eslint-plugin-jsdoc-settings-override-augments-extends-implements-without-accompanying-param-description-example-returns)
20 * [Settings to Configure `check-types` and `no-undefined-types`](#eslint-plugin-jsdoc-settings-settings-to-configure-check-types-and-no-undefined-types)
21 * [Rules](#eslint-plugin-jsdoc-rules)
22 * [`check-access`](#eslint-plugin-jsdoc-rules-check-access)
23 * [`check-alignment`](#eslint-plugin-jsdoc-rules-check-alignment)
24 * [`check-examples`](#eslint-plugin-jsdoc-rules-check-examples)
25 * [`check-indentation`](#eslint-plugin-jsdoc-rules-check-indentation)
26 * [`check-param-names`](#eslint-plugin-jsdoc-rules-check-param-names)
27 * [`check-property-names`](#eslint-plugin-jsdoc-rules-check-property-names)
28 * [`check-syntax`](#eslint-plugin-jsdoc-rules-check-syntax)
29 * [`check-tag-names`](#eslint-plugin-jsdoc-rules-check-tag-names)
30 * [`check-types`](#eslint-plugin-jsdoc-rules-check-types)
31 * [`check-values`](#eslint-plugin-jsdoc-rules-check-values)
32 * [`empty-tags`](#eslint-plugin-jsdoc-rules-empty-tags)
33 * [`implements-on-classes`](#eslint-plugin-jsdoc-rules-implements-on-classes)
34 * [`match-description`](#eslint-plugin-jsdoc-rules-match-description)
35 * [`newline-after-description`](#eslint-plugin-jsdoc-rules-newline-after-description)
36 * [`no-types`](#eslint-plugin-jsdoc-rules-no-types)
37 * [`no-undefined-types`](#eslint-plugin-jsdoc-rules-no-undefined-types)
38 * [`require-description-complete-sentence`](#eslint-plugin-jsdoc-rules-require-description-complete-sentence)
39 * [`require-description`](#eslint-plugin-jsdoc-rules-require-description)
40 * [`require-example`](#eslint-plugin-jsdoc-rules-require-example)
41 * [`require-file-overview`](#eslint-plugin-jsdoc-rules-require-file-overview)
42 * [`require-hyphen-before-param-description`](#eslint-plugin-jsdoc-rules-require-hyphen-before-param-description)
43 * [`require-jsdoc`](#eslint-plugin-jsdoc-rules-require-jsdoc)
44 * [`require-param-description`](#eslint-plugin-jsdoc-rules-require-param-description)
45 * [`require-param-name`](#eslint-plugin-jsdoc-rules-require-param-name)
46 * [`require-param-type`](#eslint-plugin-jsdoc-rules-require-param-type)
47 * [`require-param`](#eslint-plugin-jsdoc-rules-require-param)
48 * [`require-property`](#eslint-plugin-jsdoc-rules-require-property)
49 * [`require-property-description`](#eslint-plugin-jsdoc-rules-require-property-description)
50 * [`require-property-name`](#eslint-plugin-jsdoc-rules-require-property-name)
51 * [`require-property-type`](#eslint-plugin-jsdoc-rules-require-property-type)
52 * [`require-returns-check`](#eslint-plugin-jsdoc-rules-require-returns-check)
53 * [`require-returns-description`](#eslint-plugin-jsdoc-rules-require-returns-description)
54 * [`require-returns-type`](#eslint-plugin-jsdoc-rules-require-returns-type)
55 * [`require-returns`](#eslint-plugin-jsdoc-rules-require-returns)
56 * [`valid-types`](#eslint-plugin-jsdoc-rules-valid-types)
57
58
59<a name="eslint-plugin-jsdoc-installation"></a>
60## Installation
61
62Install [ESLint](https://www.github.com/eslint/eslint) either locally or globally.
63
64```sh
65npm install --save-dev eslint
66```
67
68If you have installed `ESLint` globally, you have to install JSDoc plugin globally too. Otherwise, install it locally.
69
70```sh
71npm install --save-dev eslint-plugin-jsdoc
72```
73
74<a name="eslint-plugin-jsdoc-configuration"></a>
75## Configuration
76
77Add `plugins` section and specify `eslint-plugin-jsdoc` as a plugin.
78
79```json
80{
81 "plugins": [
82 "jsdoc"
83 ]
84}
85```
86
87Finally, enable all of the rules that you would like to use.
88
89```javascript
90{
91 "rules": {
92 "jsdoc/check-alignment": 1, // Recommended
93 "jsdoc/check-examples": 1,
94 "jsdoc/check-indentation": 1,
95 "jsdoc/check-param-names": 1, // Recommended
96 "jsdoc/check-syntax": 1,
97 "jsdoc/check-tag-names": 1, // Recommended
98 "jsdoc/check-types": 1, // Recommended
99 "jsdoc/implements-on-classes": 1, // Recommended
100 "jsdoc/match-description": 1,
101 "jsdoc/newline-after-description": 1, // Recommended
102 "jsdoc/no-types": 1,
103 "jsdoc/no-undefined-types": 1, // Recommended
104 "jsdoc/require-description": 1,
105 "jsdoc/require-description-complete-sentence": 1,
106 "jsdoc/require-example": 1,
107 "jsdoc/require-hyphen-before-param-description": 1,
108 "jsdoc/require-jsdoc": 1, // Recommended
109 "jsdoc/require-param": 1, // Recommended
110 "jsdoc/require-param-description": 1, // Recommended
111 "jsdoc/require-param-name": 1, // Recommended
112 "jsdoc/require-param-type": 1, // Recommended
113 "jsdoc/require-returns": 1, // Recommended
114 "jsdoc/require-returns-check": 1, // Recommended
115 "jsdoc/require-returns-description": 1, // Recommended
116 "jsdoc/require-returns-type": 1, // Recommended
117 "jsdoc/valid-types": 1 // Recommended
118 }
119}
120```
121
122Or you can simply use the following which enables the rules commented
123above as "recommended":
124
125```json
126{
127 "extends": ["plugin:jsdoc/recommended"]
128}
129```
130
131You can then selectively add to or override the recommended rules.
132
133<a name="eslint-plugin-jsdoc-options"></a>
134## Options
135
136Rules may, as per the [ESLint user guide](https://eslint.org/docs/user-guide/configuring), have their own individual options. In `eslint-plugin-jsdoc`, a few options,
137such as, `exemptedBy` and `contexts`, may be used across different rules.
138
139`eslint-plugin-jsdoc` options, if present, are in the form of an object
140supplied as the second argument in an array after the error level.
141
142```js
143// `.eslintrc.js`
144{
145 rules: {
146 'jsdoc/require-example': [
147 // The Error level should be `error`, `warn`, or `off` (or 2, 1, or 0)
148 'error',
149 // The options vary by rule, but are added to an options object:
150 {
151 avoidExampleOnConstructors: true,
152 exemptedBy: ['type']
153 }
154 ]
155 }
156}
157```
158
159<a name="eslint-plugin-jsdoc-settings"></a>
160## Settings
161
162<a name="eslint-plugin-jsdoc-settings-allow-private-to-disable-rules-for-that-comment-block"></a>
163### Allow <code>@private</code> to disable rules for that comment block
164
165- `settings.jsdoc.ignorePrivate` - Disables all rules for the comment block
166 on which a `@private` tag (or `@access private`) occurs. Defaults to
167 `false`. Note: This has no effect with the rule `check-access` (whose
168 purpose is to check access modifiers).
169
170<a name="eslint-plugin-jsdoc-settings-mode"></a>
171### Mode
172
173- `settings.jsdoc.mode` - Set to `jsdoc` (the default), `typescript`, or `closure`.
174 Currently is used for the following:
175 - Determine valid tags for `check-tag-names`
176 - Only check `@template` in `no-undefined-types` for types in "closure" and
177 "typescript" modes
178 - For type-checking rules, determine which tags will be checked for types
179 (Closure allows types on some tags which the others do not,
180 so these tags will additionally be checked in "closure" mode)
181 - Check preferred tag names
182
183<a name="eslint-plugin-jsdoc-settings-alias-preference"></a>
184### Alias Preference
185
186Use `settings.jsdoc.tagNamePreference` to configure a preferred alias name for a JSDoc tag. The format of the configuration is: `<primary tag name>: <preferred alias name>`, e.g.
187
188```json
189{
190 "rules": {},
191 "settings": {
192 "jsdoc": {
193 "tagNamePreference": {
194 "param": "arg",
195 "returns": "return"
196 }
197 }
198 }
199}
200```
201
202One may also use an object with a `message` and `replacement`.
203
204The following will report the message `@extends is to be used over @augments as it is more evocative of classes than @augments` upon encountering `@augments`.
205
206```json
207{
208 "rules": {},
209 "settings": {
210 "jsdoc": {
211 "tagNamePreference": {
212 "augments": {
213 "message": "@extends is to be used over @augments as it is more evocative of classes than @augments",
214 "replacement": "extends"
215 }
216 }
217 }
218 }
219}
220```
221
222If one wishes to reject a normally valid tag, e.g., `@todo`, one may set the tag to `false`:
223
224```json
225{
226 "rules": {},
227 "settings": {
228 "jsdoc": {
229 "tagNamePreference": {
230 "todo": false
231 }
232 }
233 }
234}
235```
236
237A project wishing to ensure no blocks are left excluded from entering the
238documentation, might wish to prevent the `@ignore` tag in the above manner.
239
240Or one may set the targeted tag to an object with a custom `message`, but without a `replacement` property:
241
242```json
243{
244 "rules": {},
245 "settings": {
246 "jsdoc": {
247 "tagNamePreference": {
248 "todo": {
249 "message": "We expect immediate perfection, so don't leave to-dos in your code."
250 }
251 }
252 }
253 }
254}
255```
256
257Note that the preferred tags indicated in the `settings.jsdoc.tagNamePreference`
258map will be assumed to be defined by `check-tag-names`.
259
260<a name="eslint-plugin-jsdoc-settings-alias-preference-default-preferred-aliases"></a>
261#### Default Preferred Aliases
262
263The defaults in `eslint-plugin-jsdoc` (for tags which offer
264aliases) are as follows:
265
266- `@abstract` (over `@virtual`)
267- `@augments` (over `@extends`)
268- `@class` (over `@constructor`)
269- `@constant` (over `@const`)
270- `@default` (over `@defaultvalue`)
271- `@description` (over `@desc`)
272- `@external` (over `@host`)
273- `@file` (over `@fileoverview`, `@overview`)
274- `@fires` (over `@emits`)
275- `@function` (over `@func`, `@method`)
276- `@member` (over `@var`)
277- `@param` (over `@arg`, `@argument`)
278- `@property` (over `@prop`)
279- `@returns` (over `@return`)
280- `@throws` (over `@exception`)
281- `@yields` (over `@yield`)
282
283This setting is utilized by the the rule for tag name checking
284(`check-tag-names`) as well as in the `@param` and `@require` rules:
285
286- `check-param-names`
287- `check-tag-names`
288- `require-hyphen-before-param-description`
289- `require-description`
290- `require-param`
291- `require-param-description`
292- `require-param-name`
293- `require-param-type`
294- `require-returns`
295- `require-returns-check`
296- `require-returns-description`
297- `require-returns-type`
298
299<a name="eslint-plugin-jsdoc-settings-override-augments-extends-implements-without-accompanying-param-description-example-returns"></a>
300### <code>@override</code>/<code>@augments</code>/<code>@extends</code>/<code>@implements</code> Without Accompanying <code>@param</code>/<code>@description</code>/<code>@example</code>/<code>@returns</code>
301
302The following settings allows the element(s) they reference to be omitted
303on the JSDoc comment block of the function or that of its parent class
304for any of the "require" rules (i.e., `require-param`, `require-description`,
305`require-example`, or `require-returns`).
306
307* `settings.jsdoc.overrideReplacesDocs` (`@override`) - Defaults to `true`
308* `settings.jsdoc.augmentsExtendsReplacesDocs` (`@augments` or its alias `@extends`) - Defaults to `false`.
309* `settings.jsdoc.implementsReplacesDocs` (`@implements`) - Defaults to `false`
310
311The format of the configuration is as follows:
312
313```json
314{
315 "rules": {},
316 "settings": {
317 "jsdoc": {
318 "overrideReplacesDocs": true,
319 "augmentsExtendsReplacesDocs": true,
320 "implementsReplacesDocs": true
321 }
322 }
323}
324```
325
326<a name="eslint-plugin-jsdoc-settings-settings-to-configure-check-types-and-no-undefined-types"></a>
327### Settings to Configure <code>check-types</code> and <code>no-undefined-types</code>
328
329- `settings.jsdoc.preferredTypes` An option map to indicate preferred
330 or forbidden types (if default types are indicated here, these will
331 have precedence over the default recommendations for `check-types`).
332 The keys of this map are the types to be replaced (or forbidden).
333 These keys may include:
334 1. The "ANY" type, `*`
335 1. The pseudo-type `[]` which we use to denote the parent (array)
336 types used in the syntax `string[]`, `number[]`, etc.
337 1. The pseudo-type `.<>` (or `.`) to represent the format `Array.<value>`
338 or `Object.<key, value>`
339 1. The pseudo-type `<>` to represent the format `Array<value>` or
340 `Object<key, value>`
341 1. A plain string type, e.g., `MyType`
342 1. A plain string type followed by one of the above pseudo-types (except
343 for `[]` which is always assumed to be an `Array`), e.g., `Array.`, or
344 `SpecialObject<>`.
345
346 If a bare pseudo-type is used, it will match all parent types of that form.
347 If a pseudo-type prefixed with a type name is used, it will only match
348 parent types of that form and type name.
349
350 The values can be:
351 - `false` to forbid the type
352 - a string to indicate the type that should be preferred in its place
353 (and which `fix` mode can replace); this can be one of the formats
354 of the keys described above.
355 - Note that the format will not be changed unless you use a pseudo-type
356 in the replacement. (For example, `'Array.<>': 'MyArray'` will change
357 `Array.<string>` to `MyArray.<string>`, preserving the dot. To get rid
358 of the dot, you must use the pseudo-type with `<>`, i.e.,
359 `'Array.<>': 'MyArray<>'`, which will change `Array.<string>` to
360 `MyArray<string>`).
361 - If you use a _bare_ pseudo-type in the replacement (e.g.,
362 `'MyArray.<>': '<>'`), the type will be converted to the format
363 of the pseudo-type without changing the type name. For example,
364 `MyArray.<string>` will become `MyArray<string>` but `Array.<string>`
365 will not be modified.
366 - an object with:
367 - the key `message` to provide a specific error message
368 when encountering the discouraged type.
369 - The message string will have the substrings with special meaning,
370 `{{tagName}}` and `{{tagValue}}`, replaced with their
371 corresponding value.
372 - an optional key `replacement` with either of the following values:
373 - a string type to be preferred in its place (and which `fix` mode
374 can replace)
375 - `false` (for forbidding the type)
376
377Note that the preferred types indicated as targets in `settings.jsdoc.preferredTypes`
378map will be assumed to be defined by `no-undefined-types`.
379
380See the option of `check-types`, `unifyParentAndChildTypeChecks`, for
381how the keys of `preferredTypes` may have `<>` or `.<>` (or just `.`)
382appended and its bearing on whether types are checked as parents/children
383only (e.g., to match `Array` if the type is `Array` vs. `Array.<string>`).
384
385<a name="eslint-plugin-jsdoc-rules"></a>
386## Rules
387
388<a name="eslint-plugin-jsdoc-rules-check-access"></a>
389### <code>check-access</code>
390
391Checks that `@access` tags use one of the following values:
392
393- "package", "private", "protected", "public"
394
395Also reports:
396
397- Mixing of `@access` with `@public`, `@private`, `@protected`, or `@package`
398 on the same doc block.
399- Use of multiple instances of `@access` (or the `@public`, etc. style tags)
400 on the same doc block.
401
402|||
403|---|---|
404|Context|everywhere|
405|Tags|`@access`|
406|Settings||
407|Options||
408
409The following patterns are considered problems:
410
411````js
412/**
413 * @access foo
414 */
415function quux (foo) {
416
417}
418// Message: Missing valid JSDoc @access level.
419
420/**
421 * @access foo
422 */
423function quux (foo) {
424
425}
426// Settings: {"jsdoc":{"ignorePrivate":true}}
427// Message: Missing valid JSDoc @access level.
428
429/**
430 * @accessLevel foo
431 */
432function quux (foo) {
433
434}
435// Settings: {"jsdoc":{"tagNamePreference":{"access":"accessLevel"}}}
436// Message: Missing valid JSDoc @accessLevel level.
437
438/**
439 * @access
440 */
441function quux (foo) {
442
443}
444// Settings: {"jsdoc":{"tagNamePreference":{"access":false}}}
445// Message: Unexpected tag `@access`
446
447class MyClass {
448 /**
449 * @access
450 */
451 myClassField = 1
452}
453// Message: Missing valid JSDoc @access level.
454
455/**
456 * @access public
457 * @public
458 */
459function quux (foo) {
460
461}
462// Message: The @access tag may not be used with specific access-control tags (@package, @private, @protected, or @public).
463
464/**
465 * @access public
466 * @access private
467 */
468function quux (foo) {
469
470}
471// Message: At most one access-control tag may be present on a jsdoc block.
472
473/**
474 * @access public
475 * @access private
476 */
477function quux (foo) {
478
479}
480// Settings: {"jsdoc":{"ignorePrivate":true}}
481// Message: At most one access-control tag may be present on a jsdoc block.
482
483/**
484 * @public
485 * @private
486 */
487function quux (foo) {
488
489}
490// Message: At most one access-control tag may be present on a jsdoc block.
491
492/**
493 * @public
494 * @private
495 */
496function quux (foo) {
497
498}
499// Settings: {"jsdoc":{"ignorePrivate":true}}
500// Message: At most one access-control tag may be present on a jsdoc block.
501
502/**
503 * @public
504 * @public
505 */
506function quux (foo) {
507
508}
509// Message: At most one access-control tag may be present on a jsdoc block.
510````
511
512The following patterns are not considered problems:
513
514````js
515/**
516 *
517 */
518function quux (foo) {
519
520}
521
522/**
523 * @access public
524 */
525function quux (foo) {
526
527}
528
529/**
530 * @accessLevel package
531 */
532function quux (foo) {
533
534}
535// Settings: {"jsdoc":{"tagNamePreference":{"access":"accessLevel"}}}
536
537class MyClass {
538 /**
539 * @access private
540 */
541 myClassField = 1
542}
543
544/**
545 * @public
546 */
547function quux (foo) {
548
549}
550
551/**
552 * @private
553 */
554function quux (foo) {
555
556}
557// Settings: {"jsdoc":{"ignorePrivate":true}}
558````
559
560
561<a name="eslint-plugin-jsdoc-rules-check-alignment"></a>
562### <code>check-alignment</code>
563
564Reports invalid alignment of JSDoc block asterisks.
565
566|||
567|---|---|
568|Context|everywhere|
569|Tags|N/A|
570
571The following patterns are considered problems:
572
573````js
574/**
575 * @param {Number} foo
576 */
577function quux (foo) {
578 // with spaces
579}
580// Message: Expected JSDoc block to be aligned.
581
582/**
583 * @param {Number} foo
584 */
585function quux (foo) {
586 // with tabs
587}
588// Message: Expected JSDoc block to be aligned.
589
590/**
591 * @param {Number} foo
592 */
593function quux (foo) {
594 // with spaces
595}
596// Message: Expected JSDoc block to be aligned.
597
598/**
599* @param {Number} foo
600*/
601function quux (foo) {
602 // with spaces
603}
604// Message: Expected JSDoc block to be aligned.
605
606/**
607 * @param {Number} foo
608 */
609function quux (foo) {
610
611}
612// Message: Expected JSDoc block to be aligned.
613
614 /**
615 * @param {Number} foo
616 */
617function quux (foo) {
618
619}
620// Message: Expected JSDoc block to be aligned.
621
622 /**
623 * @param {Number} foo
624 */
625function quux (foo) {
626
627}
628// Message: Expected JSDoc block to be aligned.
629
630/**
631 * @param {Number} foo
632 */
633 function quux (foo) {
634
635 }
636// Message: Expected JSDoc block to be aligned.
637
638/**
639 * A jsdoc not attached to any node.
640 */
641// Message: Expected JSDoc block to be aligned.
642
643class Foo {
644 /**
645 * Some method
646 * @param a
647 */
648 quux(a) {}
649}
650// Message: Expected JSDoc block to be aligned.
651````
652
653The following patterns are not considered problems:
654
655````js
656/**
657 * Desc
658 *
659 * @param {Number} foo
660 */
661function quux (foo) {
662
663}
664
665/**
666 * Desc
667 *
668 * @param {{
669 foo: Bar,
670 bar: Baz
671 * }} foo
672 *
673 */
674function quux (foo) {
675
676}
677
678/* <- JSDoc must start with 2 stars.
679 * So this is unchecked.
680 */
681function quux (foo) {}
682
683/**
684 * @param {Number} foo
685 * @private
686 */
687function quux (foo) {
688 // with spaces
689}
690// Settings: {"jsdoc":{"ignorePrivate":true}}
691
692/**
693 * @param {Number} foo
694 * @access private
695 */
696function quux (foo) {
697 // with spaces
698}
699// Settings: {"jsdoc":{"ignorePrivate":true}}
700````
701
702
703<a name="eslint-plugin-jsdoc-rules-check-examples"></a>
704### <code>check-examples</code>
705
706Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.
707
708<a name="eslint-plugin-jsdoc-rules-check-examples-options-1"></a>
709#### Options
710
711The options below all default to no-op/`false` except as noted.
712
713<a name="eslint-plugin-jsdoc-rules-check-examples-options-1-captionrequired"></a>
714##### <code>captionRequired</code>
715
716JSDoc specs use of an optional `<caption>` element at the beginning of
717`@example`.
718
719The option `captionRequired` insists on a `<caption>` being present at
720the beginning of any `@example`.
721
722<a name="eslint-plugin-jsdoc-rules-check-examples-options-1-examplecoderegex-and-rejectexamplecoderegex"></a>
723##### <code>exampleCodeRegex</code> and <code>rejectExampleCodeRegex</code>
724
725JSDoc does not specify a formal means for delimiting code blocks within
726`@example` (it uses generic syntax highlighting techniques for its own
727syntax highlighting). The following options determine whether a given
728`@example` tag will have the `check-examples` checks applied to it:
729
730* `exampleCodeRegex` - Regex which whitelists lintable
731 examples. If a parenthetical group is used, the first one will be used,
732 so you may wish to use `(?:...)` groups where you do not wish the
733 first such group treated as one to include. If no parenthetical group
734 exists or matches, the whole matching expression will be used.
735 An example might be ````"^```(?:js|javascript)([\\s\\S]*)```\s*$"````
736 to only match explicitly fenced JavaScript blocks. Defaults to only
737 using the `u` flag, so to add your own flags, encapsulate your
738 expression as a string, but like a literal, e.g., ````/```js.*```/gi````.
739 Note that specifying a global regular expression (i.e., with `g`) will
740 allow independent linting of matched blocks within a single `@example`.
741* `rejectExampleCodeRegex` - Regex blacklist which rejects
742 non-lintable examples (has priority over `exampleCodeRegex`). An example
743 might be ```"^`"``` to avoid linting fenced blocks which may indicate
744 a non-JavaScript language. See `exampleCodeRegex` on how to add flags
745 if the default `u` is not sufficient.
746
747If neither is in use, all examples will be matched. Note also that even if
748`captionRequired` is not set, any initial `<caption>` will be stripped out
749before doing the regex matching.
750
751<a name="eslint-plugin-jsdoc-rules-check-examples-options-1-paddedindent"></a>
752##### <code>paddedIndent</code>
753
754This integer property allows one to add a fixed amount of whitespace at the
755beginning of the second or later lines of the example to be stripped so as
756to avoid linting issues with the decorative whitespace. For example, if set
757to a value of `4`, the initial whitespace below will not trigger `indent`
758rule errors as the extra 4 spaces on each subsequent line will be stripped
759out before evaluation.
760
761```js
762/**
763 * @example
764 * anArray.filter((a) => {
765 * return a.b;
766 * });
767 */
768```
769
770<a name="eslint-plugin-jsdoc-rules-check-examples-options-1-reportunuseddisabledirectives"></a>
771##### <code>reportUnusedDisableDirectives</code>
772
773If not set to `false`, `reportUnusedDisableDirectives` will report disabled
774directives which are not used (and thus not needed). Defaults to `true`.
775Corresponds to ESLint's [`--report-unused-disable-directives`](https://eslint.org/docs/user-guide/command-line-interface#--report-unused-disable-directives).
776
777Inline ESLint config within `@example` JavaScript is allowed, though the
778disabling of ESLint directives which are not needed by the resolved rules
779will be reported as with the ESLint `--report-unused-disable-directives`
780command.
781
782<a name="eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-eslintrcforexamples-and-baseconfig"></a>
783#### Options for Determining ESLint Rule Applicability (<code>allowInlineConfig</code>, <code>noDefaultExampleRules</code>, <code>matchingFileName</code>, <code>configFile</code>, <code>eslintrcForExamples</code>, and <code>baseConfig</code>)
784
785The following options determine which individual ESLint rules will be
786applied to the JavaScript found within the `@example` tags (as determined
787to be applicable by the above regex options). They are ordered by
788decreasing precedence:
789
790* `allowInlineConfig` - If not set to `false`, will allow
791 inline config within the `@example` to override other config. Defaults
792 to `true`.
793* `noDefaultExampleRules` - Setting to `true` will disable the
794 default rules which are expected to be troublesome for most documentation
795 use. See the section below for the specific default rules.
796* `matchingFileName` - Option for a file name (even non-existent) to trigger
797 specific rules defined in one's config; usable with ESLint `.eslintrc.*`
798 `overrides` -> `files` globs, to apply a desired subset of rules with
799 `@example` (besides allowing for rules specific to examples, this option
800 can be useful for enabling reuse of the same rules within `@example` as
801 with JavaScript Markdown lintable by
802 [other plugins](https://github.com/eslint/eslint-plugin-markdown), e.g.,
803 if one sets `matchingFileName` to `dummy.md` so that `@example` rules will
804 follow one's Markdown rules). Note that this option may come at somewhat
805 of a performance penalty as the file's existence is checked by eslint.
806* `configFile` - A config file. Corresponds to ESLint's [`-c`](https://eslint.org/docs/user-guide/command-line-interface#-c---config).
807* `eslintrcForExamples` - Defaults to `true` in adding rules
808 based on an `.eslintrc.*` file. Setting to `false` corresponds to
809 ESLint's [`--no-eslintrc`](https://eslint.org/docs/user-guide/command-line-interface#--no-eslintrc).
810* `baseConfig` - Set to an object of rules with the same schema
811 as `.eslintrc.*` for defaults.
812
813<a name="eslint-plugin-jsdoc-rules-check-examples-options-for-determining-eslint-rule-applicability-allowinlineconfig-nodefaultexamplerules-matchingfilename-configfile-eslintrcforexamples-and-baseconfig-rules-disabled-by-default-unless-nodefaultexamplerules-is-set-to-true"></a>
814##### Rules Disabled by Default Unless <code>noDefaultExampleRules</code> is Set to <code>true</code>
815
816* `eol-last` - Insisting that a newline "always" be at the end is less likely
817 to be desired in sample code as with the code file convention.
818* `no-console` - This rule is unlikely to have inadvertent temporary debugging
819 within examples.
820* `no-multiple-empty-lines` - This rule may be problematic for projects which
821 use an initial newline just to start an example. Also, projects may wish to
822 use extra lines within examples just for easier illustration
823 purposes.
824* `no-undef` - Many variables in examples will be `undefined`.
825* `no-unused-vars` - It is common to define variables for clarity without always
826 using them within examples.
827* `padded-blocks` - It can generally look nicer to pad a little even if one's
828 code follows more stringency as far as block padding.
829* `import/no-unresolved` - One wouldn't generally expect example paths to
830 resolve relative to the current JavaScript file as one would with real code.
831* `import/unambiguous` - Snippets in examples are likely too short to always
832 include full import/export info.
833* `node/no-missing-import` - See `import/no-unresolved`.
834* `node/no-missing-require` - See `import/no-unresolved`.
835
836|||
837|---|---|
838|Context|everywhere|
839|Tags|`example`|
840|Options| *See above* |
841
842The following patterns are considered problems:
843
844````js
845/**
846 * @example alert('hello')
847 */
848function quux () {
849
850}
851// Options: [{"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"eslintrcForExamples":false}]
852// Message: @example error (no-alert): Unexpected alert.
853
854/**
855 * @example alert('hello')
856 */
857class quux {
858
859}
860// Options: [{"baseConfig":{"rules":{"no-alert":2,"semi":["error","always"]}},"eslintrcForExamples":false}]
861// Message: @example error (no-alert): Unexpected alert.
862
863/**
864 * @example ```js
865 alert('hello');
866 ```
867 */
868function quux () {
869
870}
871// Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
872// Message: @example error (semi): Extra semicolon.
873
874/**
875 * @example
876 *
877 * ```js alert('hello'); ```
878 */
879function quux () {
880
881}
882// Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
883// Message: @example error (semi): Extra semicolon.
884
885/**
886 * @example
887 * ```js alert('hello'); ```
888 */
889var quux = {
890
891};
892// Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```js ([\\s\\S]*)```"}]
893// Message: @example error (semi): Extra semicolon.
894
895/**
896 * @example ```
897 * js alert('hello'); ```
898 */
899function quux () {
900
901}
902// Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```\njs ([\\s\\S]*)```"}]
903// Message: @example error (semi): Extra semicolon.
904
905/**
906 * @example <b>Not JavaScript</b>
907 */
908function quux () {
909
910}
911/**
912 * @example quux2();
913 */
914function quux2 () {
915
916}
917// Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"rejectExampleCodeRegex":"^\\s*<.*>\\s*$"}]
918// Message: @example error (semi): Extra semicolon.
919
920/**
921 * @example
922 * quux(); // does something useful
923 */
924function quux () {
925
926}
927// Options: [{"baseConfig":{"rules":{"no-undef":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":true}]
928// Message: @example error (no-undef): 'quux' is not defined.
929
930/**
931 * @example <caption>Valid usage</caption>
932 * quux(); // does something useful
933 *
934 * @example
935 * quux('random unwanted arg'); // results in an error
936 */
937function quux () {
938
939}
940// Options: [{"captionRequired":true,"eslintrcForExamples":false}]
941// Message: Caption is expected for examples.
942
943/**
944 * @example quux();
945 */
946function quux () {
947
948}
949// Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":false}]
950// Message: @example error (indent): Expected indentation of 0 spaces but found 1.
951
952/**
953 * @example test() // eslint-disable-line semi
954 */
955function quux () {}
956// Options: [{"eslintrcForExamples":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":true}]
957// Message: @example error: Unused eslint-disable directive (no problems were reported from 'semi').
958
959/**
960 * @example
961 test() // eslint-disable-line semi
962 */
963function quux () {}
964// Options: [{"allowInlineConfig":false,"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples":false,"noDefaultExampleRules":true}]
965// Message: @example error (semi): Missing semicolon.
966
967/**
968 * @example const i = 5;
969 * quux2()
970 */
971function quux2 () {
972
973}
974// Options: [{"matchingFileName":"test/jsdocUtils.js"}]
975// Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
976
977/**
978 * @example const i = 5;
979 * quux2()
980 */
981function quux2 () {
982
983}
984// Options: [{"paddedIndent":2}]
985// Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
986
987/**
988 * @example
989 * const i = 5;
990 * quux2()
991 */
992function quux2 () {
993
994}
995// Message: @example warning (id-length): Identifier name 'i' is too short (< 2).
996
997/**
998 * @example const i = 5;
999 * quux2()
1000 */
1001function quux2 () {
1002
1003}
1004// Options: [{"matchingFileName":"test/rules/data/dummy.js"}]
1005// Message: @example error (semi): Missing semicolon.
1006
1007/**
1008 * @example // begin
1009 alert('hello')
1010 // end
1011 */
1012function quux () {
1013
1014}
1015// Options: [{"baseConfig":{"rules":{"semi":["warn","always"]}},"eslintrcForExamples":false,"exampleCodeRegex":"// begin[\\s\\S]*// end","noDefaultExampleRules":true}]
1016// Message: @example warning (semi): Missing semicolon.
1017
1018/**
1019 *
1020 */
1021function f () {
1022
1023}
1024// Settings: {"jsdoc":{"allowInlineConfig":true,"baseConfig":{},"captionRequired":false,"configFile":"configFile.js","eslintrcForExamples":true,"exampleCodeRegex":".*?","matchingFileName":"test.md","noDefaultExampleRules":false,"rejectExampleCodeRegex":"\\W*","reportUnusedDisableDirectives":true}}
1025// Message: `settings.jsdoc.captionRequired` has been removed, use options in the rule `check-examples` instead.
1026
1027/**
1028 * @typedef {string} Foo
1029 * @example <caption></caption>
1030 * 'foo'
1031 */
1032// Options: [{"captionRequired":true,"eslintrcForExamples":false}]
1033// Message: Caption is expected for examples.
1034
1035/**
1036 * @example
1037 * const list: number[] = [1, 2, 3]
1038 * quux(list);
1039 */
1040function quux () {
1041
1042}
1043// Options: [{"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"eslintrcForExamples":false}]
1044// Message: @example error (semi): Missing semicolon.
1045
1046/**
1047 * @example <caption>Say `Hello!` to the user.</caption>
1048 * First, import the function:
1049 *
1050 * ```js
1051 * import popup from './popup'
1052 * const aConstInSameScope = 5;
1053 * ```
1054 *
1055 * Then use it like this:
1056 *
1057 * ```js
1058 * const aConstInSameScope = 7;
1059 * popup('Hello!')
1060 * ```
1061 *
1062 * Here is the result on macOS:
1063 *
1064 * ![Screenshot](path/to/screenshot.jpg)
1065 */
1066// Options: [{"baseConfig":{"parserOptions":{"ecmaVersion":2015,"sourceType":"module"},"rules":{"semi":["error","always"]}},"eslintrcForExamples":false,"exampleCodeRegex":"/^```(?:js|javascript)\\n([\\s\\S]*?)```$/gm"}]
1067// Message: @example error (semi): Missing semicolon.
1068
1069/**
1070 * @example // begin
1071 alert('hello')
1072 // end
1073 * And here is another example:
1074 // begin
1075 alert('there')
1076 // end
1077 */
1078function quux () {
1079
1080}
1081// Options: [{"baseConfig":{"rules":{"semi":["warn","always"]}},"eslintrcForExamples":false,"exampleCodeRegex":"/\\/\\/ begin[\\s\\S]*?// end/g","noDefaultExampleRules":true}]
1082// Message: @example warning (semi): Missing semicolon.
1083
1084/**
1085 * @example
1086 * quux();
1087 */
1088function quux () {
1089
1090}
1091// Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":false}]
1092// Message: @example error (indent): Expected indentation of 0 spaces but found 2.
1093````
1094
1095The following patterns are not considered problems:
1096
1097````js
1098/**
1099 * @example ```js
1100 alert('hello');
1101 ```
1102 */
1103function quux () {
1104
1105}
1106// Options: [{"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
1107
1108/**
1109 * @example ```js
1110 alert('hello');
1111 ```
1112 */
1113function quux () {
1114
1115}
1116// Options: [{"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples":false,"exampleCodeRegex":"/```js([\\s\\S]*)```/"}]
1117
1118/**
1119 * @example
1120 * // arbitrary example content
1121 */
1122function quux () {
1123
1124}
1125// Options: [{"eslintrcForExamples":false}]
1126
1127/**
1128 * @example
1129 * quux(); // does something useful
1130 */
1131function quux () {
1132
1133}
1134// Options: [{"baseConfig":{"rules":{"no-undef":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":false}]
1135
1136/**
1137 * @example quux();
1138 */
1139function quux () {
1140
1141}
1142// Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":false}]
1143
1144/**
1145 * @example <caption>Valid usage</caption>
1146 * quux(); // does something useful
1147 *
1148 * @example <caption>Invalid usage</caption>
1149 * quux('random unwanted arg'); // results in an error
1150 */
1151function quux () {
1152
1153}
1154// Options: [{"captionRequired":true,"eslintrcForExamples":false}]
1155
1156/**
1157 * @example test() // eslint-disable-line semi
1158 */
1159function quux () {}
1160// Options: [{"eslintrcForExamples":false,"noDefaultExampleRules":true,"reportUnusedDisableDirectives":false}]
1161
1162/**
1163 * @example
1164 test() // eslint-disable-line semi
1165 */
1166function quux () {}
1167// Options: [{"allowInlineConfig":true,"baseConfig":{"rules":{"semi":["error","always"]}},"eslintrcForExamples":false,"noDefaultExampleRules":true}]
1168
1169/**
1170 * @example ```js
1171 alert('hello')
1172 ```
1173 */
1174var quux = {
1175
1176};
1177// Options: [{"baseConfig":{"rules":{"semi":["error","never"]}},"eslintrcForExamples":false,"exampleCodeRegex":"```js([\\s\\S]*)```"}]
1178
1179/**
1180 * @example
1181 * foo(function (err) {
1182 * throw err;
1183 * });
1184 */
1185function quux () {}
1186// Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":false}]
1187
1188/**
1189 * @example
1190 * const list: number[] = [1, 2, 3];
1191 * quux(list);
1192 */
1193function quux () {
1194
1195}
1196// Options: [{"baseConfig":{"parser":"@typescript-eslint/parser","parserOptions":{"ecmaVersion":6},"rules":{"semi":["error","always"]}},"eslintrcForExamples":false}]
1197
1198/**
1199 * @example const ident = 5;
1200 * quux2();
1201 * bar();
1202 */
1203function quux2 () {
1204
1205}
1206// Options: [{"paddedIndent":2}]
1207
1208/**
1209 * @example
1210 * function quux() {
1211 * bar();
1212 * }
1213 */
1214function quux () {
1215
1216}
1217// Options: [{"baseConfig":{"rules":{"indent":["error"]}},"eslintrcForExamples":false,"noDefaultExampleRules":false}]
1218````
1219
1220
1221<a name="eslint-plugin-jsdoc-rules-check-indentation"></a>
1222### <code>check-indentation</code>
1223
1224Reports invalid padding inside JSDoc blocks.
1225
1226Ignores parts enclosed in Markdown "code block"'s. For example,
1227the following description is not reported:
1228
1229```js
1230/**
1231 * Some description:
1232 * ```html
1233 * <section>
1234 * <title>test</title>
1235 * </section>
1236 * ```
1237 */
1238```
1239
1240<a name="eslint-plugin-jsdoc-rules-check-indentation-options-2"></a>
1241#### Options
1242
1243This rule has an object option.
1244
1245<a name="eslint-plugin-jsdoc-rules-check-indentation-options-2-excludetags"></a>
1246##### <code>excludeTags</code>
1247
1248Array of tags (e.g., `['example', 'description']`) whose content will be
1249"hidden" from the `check-indentation` rule. Defaults to `['example']`.
1250
1251By default, the whole JSDoc block will be checked for invalid padding.
1252That would include `@example` blocks too, which can get in the way
1253of adding full, readable examples of code without ending up with multiple
1254linting issues.
1255
1256When disabled (by passing `excludeTags: []` option), the following code *will*
1257report a padding issue:
1258
1259```js
1260/**
1261 * @example
1262 * anArray.filter((a) => {
1263 * return a.b;
1264 * });
1265 */
1266```
1267
1268|||
1269|---|---|
1270|Context|everywhere|
1271|Tags|N/A|
1272|Options| `excludeTags` |
1273
1274The following patterns are considered problems:
1275
1276````js
1277/** foo */
1278function quux () {
1279
1280}
1281// Message: There must be no indentation.
1282
1283/**
1284 * foo
1285 *
1286 * @param bar
1287 * baz
1288 */
1289function quux () {
1290
1291}
1292// Message: There must be no indentation.
1293
1294/**
1295 * Foo
1296 * bar
1297 */
1298class Moo {}
1299// Message: There must be no indentation.
1300
1301/**
1302 * foo
1303 *
1304 * @example
1305 * anArray.filter((a) => {
1306 * return a.b;
1307 * });
1308 */
1309function quux () {
1310
1311}
1312// Options: [{"excludeTags":[]}]
1313// Message: There must be no indentation.
1314
1315/**
1316 * foo
1317 *
1318 * @example
1319 * aaaa
1320 * @returns
1321 * eeee
1322 */
1323function quux () {
1324
1325}
1326// Message: There must be no indentation.
1327
1328/**
1329 * foo
1330 * ```html
1331 * <section>
1332 * <title>test</title>
1333 * </section>
1334 * ```
1335 * @returns
1336 * eeee
1337 */
1338function quux () {
1339
1340}
1341// Message: There must be no indentation.
1342
1343/**
1344 * foo
1345 * ``` aaaa```
1346 * @returns
1347 * eeee
1348 */
1349function quux () {
1350
1351}
1352// Message: There must be no indentation.
1353
1354/**
1355* @example <caption>
1356* Here is a long
1357* indented summary of this
1358* example
1359* </caption>
1360* ```js
1361* function hi () {
1362* alert('Hello');
1363* }
1364* ```
1365*/
1366// Options: [{"excludeTags":[]}]
1367// Message: There must be no indentation.
1368
1369/**
1370* @example <caption>
1371* Here is a long
1372* summary of this
1373* example
1374* </caption>
1375* // Code is not wrapped into fenced code block
1376* function hi () {
1377* alert('Hello');
1378* }
1379*/
1380// Options: [{"excludeTags":[]}]
1381// Message: There must be no indentation.
1382````
1383
1384The following patterns are not considered problems:
1385
1386````js
1387/**
1388 * foo
1389 *
1390 * @param bar
1391 * baz
1392 */
1393function quux () {
1394
1395}
1396
1397/*** foo */
1398function quux () {
1399
1400}
1401
1402/**
1403 * foo
1404 *
1405 * @example
1406 * anArray.filter((a) => {
1407 * return a.b;
1408 * });
1409 */
1410function quux () {
1411
1412}
1413
1414/**
1415 * foo
1416 *
1417 * @example
1418 * anArray.filter((a) => {
1419 * return a.b;
1420 * });
1421 * @returns
1422 * eeee
1423 */
1424function quux () {
1425
1426}
1427// Options: [{"excludeTags":["example","returns"]}]
1428
1429/**
1430 * foo
1431 * ```html
1432 * <section>
1433 * <title>test</title>
1434 * </section>
1435 * ```
1436 * @returns eeee
1437 */
1438function quux () {
1439
1440}
1441
1442/**
1443 * foo
1444 * ``` aaaa```
1445 * @returns eeee
1446 */
1447function quux () {
1448
1449}
1450
1451/**
1452* @example <caption>
1453* Here is a long
1454* summary of this
1455* example
1456* </caption>
1457* ```js
1458* function hi () {
1459* alert('Hello');
1460* }
1461* ```
1462*/
1463// Options: [{"excludeTags":[]}]
1464````
1465
1466
1467<a name="eslint-plugin-jsdoc-rules-check-param-names"></a>
1468### <code>check-param-names</code>
1469
1470Ensures that parameter names in JSDoc match those in the function declaration.
1471
1472<a name="eslint-plugin-jsdoc-rules-check-param-names-options-3"></a>
1473#### Options
1474
1475<a name="eslint-plugin-jsdoc-rules-check-param-names-options-3-allowextratrailingparamdocs"></a>
1476##### <code>allowExtraTrailingParamDocs</code>
1477
1478If set to `true`, this option will allow extra `@param` definitions (e.g.,
1479representing future expected or virtual params) to be present without needing
1480their presence within the function signature. Other inconsistencies between
1481`@param`'s and present function parameters will still be reported.
1482
1483|||
1484|---|---|
1485|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
1486|Options|`allowExtraTrailingParamDocs`|
1487|Tags|`param`|
1488
1489The following patterns are considered problems:
1490
1491````js
1492/**
1493 * @param Foo
1494 */
1495function quux (foo = 'FOO') {
1496
1497}
1498// Message: Expected @param names to be "foo". Got "Foo".
1499
1500/**
1501 * @arg Foo
1502 */
1503function quux (foo = 'FOO') {
1504
1505}
1506// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
1507// Message: Expected @arg names to be "foo". Got "Foo".
1508
1509/**
1510 * @param Foo
1511 */
1512function quux (foo) {
1513
1514}
1515// Message: Expected @param names to be "foo". Got "Foo".
1516
1517/**
1518 * @param Foo.Bar
1519 */
1520function quux (foo) {
1521
1522}
1523// Message: @param path declaration ("Foo.Bar") appears before any real parameter.
1524
1525/**
1526 * @param foo
1527 * @param Foo.Bar
1528 */
1529function quux (foo) {
1530
1531}
1532// Message: @param path declaration ("Foo.Bar") root node name ("Foo") does not match previous real parameter name ("foo").
1533
1534/**
1535 * @param foo
1536 * @param foo.bar
1537 * @param bar
1538 */
1539function quux (bar, foo) {
1540
1541}
1542// Message: Expected @param names to be "bar, foo". Got "foo, bar".
1543
1544/**
1545 * @param foo
1546 * @param bar
1547 */
1548function quux (foo) {
1549
1550}
1551// Message: @param "bar" does not match an existing function parameter.
1552
1553/**
1554 * @param foo
1555 * @param foo
1556 */
1557function quux (foo) {
1558
1559}
1560// Message: Duplicate @param "foo"
1561
1562/**
1563 * @param foo
1564 * @param foo
1565 */
1566function quux (foo, bar) {
1567
1568}
1569// Message: Duplicate @param "foo"
1570
1571/**
1572 * @param foo
1573 * @param foo
1574 */
1575function quux (foo, foo) {
1576
1577}
1578// Message: Duplicate @param "foo"
1579
1580export class SomeClass {
1581 /**
1582 * @param prop
1583 */
1584 constructor(private property: string) {}
1585}
1586// Message: Expected @param names to be "property". Got "prop".
1587
1588/**
1589 * @param foo
1590 */
1591function quux (foo) {
1592
1593}
1594// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
1595// Message: Unexpected tag `@param`
1596
1597/**
1598 * @param {Error} error Exit code
1599 * @param {number} [code = 1] Exit code
1600 */
1601function quux (error, cde = 1) {
1602};
1603// Message: Expected @param names to be "error, cde". Got "error, code".
1604````
1605
1606The following patterns are not considered problems:
1607
1608````js
1609/**
1610 *
1611 */
1612function quux (foo) {
1613
1614}
1615
1616/**
1617 * @param foo
1618 */
1619function quux (foo) {
1620
1621}
1622
1623/**
1624 * @param foo
1625 * @param bar
1626 */
1627function quux (foo, bar) {
1628
1629}
1630
1631/**
1632 * @param foo
1633 * @param bar
1634 */
1635function quux (foo, bar, baz) {
1636
1637}
1638
1639/**
1640 * @param foo
1641 * @param foo.foo
1642 * @param bar
1643 */
1644function quux (foo, bar) {
1645
1646}
1647
1648/**
1649 * @param args
1650 */
1651function quux (...args) {
1652
1653}
1654
1655/**
1656 * @param foo
1657 */
1658function quux ({a, b}) {
1659
1660}
1661
1662/**
1663 * @param foo
1664 */
1665function quux ({a, b} = {}) {
1666
1667}
1668
1669/**
1670 * @param foo
1671 */
1672function quux ([a, b] = []) {
1673
1674}
1675
1676/**
1677 * Assign the project to a list of employees.
1678 * @param {object[]} employees - The employees who are responsible for the project.
1679 * @param {string} employees[].name - The name of an employee.
1680 * @param {string} employees[].department - The employee's department.
1681 */
1682function assign (employees) {
1683
1684};
1685
1686export class SomeClass {
1687 /**
1688 * @param property
1689 */
1690 constructor(private property: string) {}
1691}
1692
1693/**
1694 * @param {Error} error Exit code
1695 * @param {number} [code = 1] Exit code
1696 */
1697function quux (error, code = 1) {
1698};
1699
1700/**
1701 * @param foo
1702 * @param bar
1703 */
1704function quux (foo) {
1705
1706}
1707// Options: [{"allowExtraTrailingParamDocs":true}]
1708````
1709
1710
1711<a name="eslint-plugin-jsdoc-rules-check-param-names-deconstructing-function-parameter"></a>
1712#### Deconstructing Function Parameter
1713
1714`eslint-plugin-jsdoc` does not validate names of parameters in function deconstruction, e.g.
1715
1716```js
1717/**
1718 * @param foo
1719 */
1720function quux ({
1721 a,
1722 b
1723}) {
1724
1725}
1726```
1727
1728`{a, b}` is an [`ObjectPattern`](https://github.com/estree/estree/blob/master/es2015.md#objectpattern) AST type and does not have a name. Therefore, the associated parameter in JSDoc block can have any name.
1729
1730Likewise for the pattern `[a, b]` which is an [`ArrayPattern`](https://github.com/estree/estree/blob/master/es2015.md#arraypattern).
1731
1732<a name="eslint-plugin-jsdoc-rules-check-property-names"></a>
1733### <code>check-property-names</code>
1734
1735Ensures that property names in JSDoc are not duplicated on the same block
1736and that nested properties have defined roots.
1737
1738<a name="eslint-plugin-jsdoc-rules-check-property-names-options-4"></a>
1739#### Options
1740
1741|||
1742|---|---|
1743|Context|Everywhere|
1744|Tags|`property`|
1745
1746The following patterns are considered problems:
1747
1748````js
1749/**
1750 * @typedef (SomeType) SomeTypedef
1751 * @property Foo.Bar
1752 */
1753// Message: @property path declaration ("Foo.Bar") appears before any real property.
1754
1755/**
1756 * @typedef (SomeType) SomeTypedef
1757 * @property foo
1758 * @property Foo.Bar
1759 */
1760// Message: @property path declaration ("Foo.Bar") root node name ("Foo") does not match previous real property name ("foo").
1761
1762/**
1763 * @typedef (SomeType) SomeTypedef
1764 * @property foo
1765 * @property foo
1766 */
1767// Message: Duplicate @property "foo"
1768
1769/**
1770 * @typedef (SomeType) SomeTypedef
1771 * @prop foo
1772 * @prop foo
1773 */
1774// Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
1775// Message: Duplicate @prop "foo"
1776
1777/**
1778 * @typedef (SomeType) SomeTypedef
1779 * @property foo
1780 */
1781// Settings: {"jsdoc":{"tagNamePreference":{"property":false}}}
1782// Message: Unexpected tag `@property`
1783````
1784
1785The following patterns are not considered problems:
1786
1787````js
1788/**
1789 *
1790 */
1791
1792/**
1793 * @typedef (SomeType) SomeTypedef
1794 * @property foo
1795 */
1796
1797/**
1798 * @typedef (SomeType) SomeTypedef
1799 * @prop foo
1800 */
1801
1802/**
1803 * @typedef (SomeType) SomeTypedef
1804 * @property foo
1805 * @property bar
1806 */
1807
1808/**
1809 * @typedef (SomeType) SomeTypedef
1810 * @property foo
1811 * @property foo.foo
1812 * @property bar
1813 */
1814
1815/**
1816 * Assign the project to a list of employees.
1817 * @typedef (SomeType) SomeTypedef
1818 * @property {object[]} employees - The employees who are responsible for the project.
1819 * @property {string} employees[].name - The name of an employee.
1820 * @property {string} employees[].department - The employee's department.
1821 */
1822
1823/**
1824 * @typedef (SomeType) SomeTypedef
1825 * @property {Error} error Exit code
1826 * @property {number} [code = 1] Exit code
1827 */
1828
1829/**
1830 * @namespace (SomeType) SomeNamespace
1831 * @property {Error} error Exit code
1832 * @property {number} [code = 1] Exit code
1833 */
1834
1835/**
1836 * @class
1837 * @property {Error} error Exit code
1838 * @property {number} [code = 1] Exit code
1839 */
1840function quux (code = 1) {
1841 this.error = new Error('oops');
1842 this.code = code;
1843}
1844````
1845
1846
1847<a name="eslint-plugin-jsdoc-rules-check-syntax"></a>
1848### <code>check-syntax</code>
1849
1850Reports against Google Closure Compiler syntax.
1851
1852|||
1853|---|---|
1854|Context|everywhere|
1855|Tags|N/A|
1856
1857The following patterns are considered problems:
1858
1859````js
1860/**
1861 * @param {string=} foo
1862 */
1863function quux (foo) {
1864
1865}
1866// Message: Syntax should not be Google Closure Compiler style.
1867````
1868
1869The following patterns are not considered problems:
1870
1871````js
1872/**
1873 * @param {string} [foo]
1874 */
1875function quux (foo) {
1876
1877}
1878
1879/**
1880 *
1881 */
1882function quux (foo) {
1883
1884}
1885````
1886
1887
1888<a name="eslint-plugin-jsdoc-rules-check-tag-names"></a>
1889### <code>check-tag-names</code>
1890
1891Reports invalid block tag names.
1892
1893Valid [JSDoc 3 Block Tags](https://jsdoc.app/#block-tags) are:
1894
1895```
1896abstract
1897access
1898alias
1899async
1900augments
1901author
1902borrows
1903callback
1904class
1905classdesc
1906constant
1907constructs
1908copyright
1909default
1910deprecated
1911description
1912enum
1913event
1914example
1915exports
1916external
1917file
1918fires
1919function
1920generator
1921global
1922hideconstructor
1923ignore
1924implements
1925inheritdoc
1926inner
1927instance
1928interface
1929kind
1930lends
1931license
1932listens
1933member
1934memberof
1935memberof!
1936mixes
1937mixin
1938module
1939name
1940namespace
1941override
1942package
1943param
1944private
1945property
1946protected
1947public
1948readonly
1949requires
1950returns
1951see
1952since
1953static
1954summary
1955this
1956throws
1957todo
1958tutorial
1959type
1960typedef
1961variation
1962version
1963yields
1964```
1965
1966`modifies` is also supported (see [source](https://github.com/jsdoc/jsdoc/blob/master/packages/jsdoc/lib/jsdoc/tag/dictionary/definitions.js#L594)) but is undocumented.
1967
1968The following synonyms are also recognized:
1969
1970```
1971arg
1972argument
1973const
1974constructor
1975defaultvalue
1976desc
1977emits
1978exception
1979extends
1980fileoverview
1981func
1982host
1983method
1984overview
1985prop
1986return
1987var
1988virtual
1989yield
1990```
1991
1992For [TypeScript](https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html#supported-jsdoc)
1993(or Closure), when `settings.jsdoc.mode` is set to `typescript` or `closure`,
1994one may also use the following:
1995
1996```
1997template
1998```
1999
2000And for [Closure](https://github.com/google/closure-compiler/wiki/Annotating-JavaScript-for-the-Closure-Compiler),
2001when `settings.jsdoc.mode` is set to `closure`, one may use the following (in
2002addition to the jsdoc and TypeScript tags):
2003
2004```
2005define (synonym of `const` per jsdoc source)
2006dict
2007export
2008externs
2009final
2010implicitCast (casing distinct from that recognized by jsdoc internally)
2011inheritDoc (casing distinct from that recognized by jsdoc internally)
2012noalias
2013nocollapse
2014nocompile
2015noinline
2016nosideeffects
2017polymer
2018polymerBehavior
2019preserve
2020record (synonym of `interface` per jsdoc source)
2021struct
2022suppress
2023unrestricted
2024```
2025
2026...and these undocumented tags which are only in [source](https://github.com/google/closure-compiler/blob/master/src/com/google/javascript/jscomp/parsing/Annotation.java):
2027
2028```
2029closurePrimitive
2030customElement
2031expose
2032hidden
2033idGenerator
2034meaning
2035mixinClass
2036mixinFunction
2037ngInject
2038owner
2039typeSummary
2040wizaction
2041```
2042
2043Note that the tags indicated as replacements in `settings.jsdoc.tagNamePreference` will automatically be considered as valid.
2044
2045<a name="eslint-plugin-jsdoc-rules-check-tag-names-options-5"></a>
2046#### Options
2047
2048<a name="eslint-plugin-jsdoc-rules-check-tag-names-options-5-definedtags"></a>
2049##### <code>definedTags</code>
2050
2051Use an array of `definedTags` strings to configure additional, allowed tags.
2052The format is as follows:
2053
2054```json
2055{
2056 "definedTags": ["note", "record"]
2057}
2058```
2059
2060|||
2061|---|---|
2062|Context|everywhere|
2063|Tags|N/A|
2064|Options|`definedTags`|
2065|Settings|`tagNamePreference`, `mode`|
2066
2067The following patterns are considered problems:
2068
2069````js
2070/** @typoo {string} */
2071let a;
2072// Message: Invalid JSDoc tag name "typoo".
2073
2074/**
2075 * @Param
2076 */
2077function quux () {
2078
2079}
2080// Message: Invalid JSDoc tag name "Param".
2081
2082/**
2083 * @foo
2084 */
2085function quux () {
2086
2087}
2088// Message: Invalid JSDoc tag name "foo".
2089
2090/**
2091 * @arg foo
2092 */
2093function quux (foo) {
2094
2095}
2096// Message: Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "param".
2097
2098/**
2099 * @param foo
2100 */
2101function quux (foo) {
2102
2103}
2104// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
2105// Message: Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "arg".
2106
2107/**
2108 * @arg foo
2109 */
2110function quux (foo) {
2111
2112}
2113// Settings: {"jsdoc":{"tagNamePreference":{"arg":"somethingDifferent"}}}
2114// Message: Invalid JSDoc tag (preference). Replace "arg" JSDoc tag with "somethingDifferent".
2115
2116/**
2117 * @param foo
2118 */
2119function quux (foo) {
2120
2121}
2122// Settings: {"jsdoc":{"tagNamePreference":{"param":"parameter"}}}
2123// Message: Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "parameter".
2124
2125/**
2126 * @bar foo
2127 */
2128function quux (foo) {
2129
2130}
2131// Message: Invalid JSDoc tag name "bar".
2132
2133/**
2134 * @baz @bar foo
2135 */
2136function quux (foo) {
2137
2138}
2139// Options: [{"definedTags":["bar"]}]
2140// Message: Invalid JSDoc tag name "baz".
2141
2142/**
2143 * @bar
2144 * @baz
2145 */
2146function quux (foo) {
2147
2148}
2149// Options: [{"definedTags":["bar"]}]
2150// Message: Invalid JSDoc tag name "baz".
2151
2152/**
2153 * @todo
2154 */
2155function quux () {
2156
2157}
2158// Settings: {"jsdoc":{"tagNamePreference":{"todo":false}}}
2159// Message: Blacklisted tag found (`@todo`)
2160
2161/**
2162 * @todo
2163 */
2164function quux () {
2165
2166}
2167// Settings: {"jsdoc":{"tagNamePreference":{"todo":{"message":"Please resolve to-dos or add to the tracker"}}}}
2168// Message: Please resolve to-dos or add to the tracker
2169
2170/**
2171 * @todo
2172 */
2173function quux () {
2174
2175}
2176// Settings: {"jsdoc":{"tagNamePreference":{"todo":{"message":"Please use x-todo instead of todo","replacement":"x-todo"}}}}
2177// Message: Please use x-todo instead of todo
2178
2179/**
2180 * @todo
2181 */
2182function quux () {
2183
2184}
2185// Settings: {"jsdoc":{"tagNamePreference":{"todo":{"message":"Please use x-todo instead of todo","replacement":"x-todo"}}}}
2186// Message: Please use x-todo instead of todo
2187
2188/**
2189 * @todo
2190 */
2191function quux () {
2192
2193}
2194// Settings: {"jsdoc":{"tagNamePreference":{"todo":55}}}
2195// Message: Invalid `settings.jsdoc.tagNamePreference`. Values must be falsy, a string, or an object.
2196
2197/**
2198 * @property {object} a
2199 * @prop {boolean} b
2200 */
2201function quux () {
2202
2203}
2204// Message: Invalid JSDoc tag (preference). Replace "prop" JSDoc tag with "property".
2205
2206/**
2207 * @abc foo
2208 * @abcd bar
2209 */
2210function quux () {
2211
2212}
2213// Settings: {"jsdoc":{"tagNamePreference":{"abc":"abcd"}}}
2214// Options: [{"definedTags":["abcd"]}]
2215// Message: Invalid JSDoc tag (preference). Replace "abc" JSDoc tag with "abcd".
2216
2217/**
2218 * @abc
2219 * @abcd
2220 */
2221function quux () {
2222
2223}
2224// Settings: {"jsdoc":{"tagNamePreference":{"abc":"abcd"}}}
2225// Message: Invalid JSDoc tag (preference). Replace "abc" JSDoc tag with "abcd".
2226
2227/**
2228 * @modifies
2229 * @abstract
2230 * @access
2231 * @alias
2232 * @async
2233 * @augments
2234 * @author
2235 * @borrows
2236 * @callback
2237 * @class
2238 * @classdesc
2239 * @constant
2240 * @constructs
2241 * @copyright
2242 * @default
2243 * @deprecated
2244 * @description
2245 * @enum
2246 * @event
2247 * @example
2248 * @exports
2249 * @external
2250 * @file
2251 * @fires
2252 * @function
2253 * @generator
2254 * @global
2255 * @hideconstructor
2256 * @ignore
2257 * @implements
2258 * @inheritdoc
2259 * @inner
2260 * @instance
2261 * @interface
2262 * @kind
2263 * @lends
2264 * @license
2265 * @listens
2266 * @member
2267 * @memberof
2268 * @memberof!
2269 * @mixes
2270 * @mixin
2271 * @module
2272 * @name
2273 * @namespace
2274 * @override
2275 * @package
2276 * @param
2277 * @private
2278 * @property
2279 * @protected
2280 * @public
2281 * @readonly
2282 * @requires
2283 * @returns
2284 * @see
2285 * @since
2286 * @static
2287 * @summary
2288 * @this
2289 * @throws
2290 * @todo
2291 * @tutorial
2292 * @type
2293 * @typedef
2294 * @variation
2295 * @version
2296 * @yields
2297 */
2298function quux (foo) {}
2299// Settings: {"jsdoc":{"mode":"badMode"}}
2300// Message: Unrecognized value `badMode` for `settings.jsdoc.mode`.
2301
2302/**
2303 * @modifies
2304 * @abstract
2305 * @access
2306 * @alias
2307 * @async
2308 * @augments
2309 * @author
2310 * @borrows
2311 * @callback
2312 * @class
2313 * @classdesc
2314 * @constant
2315 * @constructs
2316 * @copyright
2317 * @default
2318 * @deprecated
2319 * @description
2320 * @enum
2321 * @event
2322 * @example
2323 * @exports
2324 * @external
2325 * @file
2326 * @fires
2327 * @function
2328 * @generator
2329 * @global
2330 * @hideconstructor
2331 * @ignore
2332 * @implements
2333 * @inheritdoc
2334 * @inner
2335 * @instance
2336 * @interface
2337 * @kind
2338 * @lends
2339 * @license
2340 * @listens
2341 * @member
2342 * @memberof
2343 * @memberof!
2344 * @mixes
2345 * @mixin
2346 * @module
2347 * @name
2348 * @namespace
2349 * @override
2350 * @package
2351 * @param
2352 * @private
2353 * @property
2354 * @protected
2355 * @public
2356 * @readonly
2357 * @requires
2358 * @returns
2359 * @see
2360 * @since
2361 * @static
2362 * @summary
2363 * @this
2364 * @throws
2365 * @todo
2366 * @tutorial
2367 * @type
2368 * @typedef
2369 * @variation
2370 * @version
2371 * @yields
2372 * @template
2373 */
2374function quux (foo) {}
2375// Message: Invalid JSDoc tag name "template".
2376
2377/**
2378 * @externs
2379 */
2380function quux (foo) {}
2381// Message: Invalid JSDoc tag name "externs".
2382````
2383
2384The following patterns are not considered problems:
2385
2386````js
2387/**
2388 * @param foo
2389 */
2390function quux (foo) {
2391
2392}
2393
2394/**
2395 * @memberof! foo
2396 */
2397function quux (foo) {
2398
2399}
2400
2401/**
2402 * @arg foo
2403 */
2404function quux (foo) {
2405
2406}
2407// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
2408
2409/**
2410 * @bar foo
2411 */
2412function quux (foo) {
2413
2414}
2415// Options: [{"definedTags":["bar"]}]
2416
2417/**
2418 * @baz @bar foo
2419 */
2420function quux (foo) {
2421
2422}
2423// Options: [{"definedTags":["baz","bar"]}]
2424
2425/**
2426 * @baz @bar foo
2427 */
2428function quux (foo) {
2429
2430}
2431// Settings: {"jsdoc":{"tagNamePreference":{"param":"baz","returns":{"message":"Prefer `bar`","replacement":"bar"},"todo":false}}}
2432
2433/**
2434 * @modifies
2435 * @abstract
2436 * @access
2437 * @alias
2438 * @async
2439 * @augments
2440 * @author
2441 * @borrows
2442 * @callback
2443 * @class
2444 * @classdesc
2445 * @constant
2446 * @constructs
2447 * @copyright
2448 * @default
2449 * @deprecated
2450 * @description
2451 * @enum
2452 * @event
2453 * @example
2454 * @exports
2455 * @external
2456 * @file
2457 * @fires
2458 * @function
2459 * @generator
2460 * @global
2461 * @hideconstructor
2462 * @ignore
2463 * @implements
2464 * @inheritdoc
2465 * @inner
2466 * @instance
2467 * @interface
2468 * @kind
2469 * @lends
2470 * @license
2471 * @listens
2472 * @member
2473 * @memberof
2474 * @memberof!
2475 * @mixes
2476 * @mixin
2477 * @module
2478 * @name
2479 * @namespace
2480 * @override
2481 * @package
2482 * @param
2483 * @private
2484 * @property
2485 * @protected
2486 * @public
2487 * @readonly
2488 * @requires
2489 * @returns
2490 * @see
2491 * @since
2492 * @static
2493 * @summary
2494 * @this
2495 * @throws
2496 * @todo
2497 * @tutorial
2498 * @type
2499 * @typedef
2500 * @variation
2501 * @version
2502 * @yields
2503 */
2504function quux (foo) {}
2505
2506/**
2507 * @modifies
2508 * @abstract
2509 * @access
2510 * @alias
2511 * @async
2512 * @augments
2513 * @author
2514 * @borrows
2515 * @callback
2516 * @class
2517 * @classdesc
2518 * @constant
2519 * @constructs
2520 * @copyright
2521 * @default
2522 * @deprecated
2523 * @description
2524 * @enum
2525 * @event
2526 * @example
2527 * @exports
2528 * @external
2529 * @file
2530 * @fires
2531 * @function
2532 * @generator
2533 * @global
2534 * @hideconstructor
2535 * @ignore
2536 * @implements
2537 * @inheritdoc
2538 * @inner
2539 * @instance
2540 * @interface
2541 * @kind
2542 * @lends
2543 * @license
2544 * @listens
2545 * @member
2546 * @memberof
2547 * @memberof!
2548 * @mixes
2549 * @mixin
2550 * @module
2551 * @name
2552 * @namespace
2553 * @override
2554 * @package
2555 * @param
2556 * @private
2557 * @property
2558 * @protected
2559 * @public
2560 * @readonly
2561 * @requires
2562 * @returns
2563 * @see
2564 * @since
2565 * @static
2566 * @summary
2567 * @this
2568 * @throws
2569 * @todo
2570 * @tutorial
2571 * @type
2572 * @typedef
2573 * @variation
2574 * @version
2575 * @yields
2576 * @template
2577 */
2578function quux (foo) {}
2579// Settings: {"jsdoc":{"mode":"typescript"}}
2580
2581/**
2582 * @externs
2583 */
2584function quux (foo) {}
2585// Settings: {"jsdoc":{"mode":"closure"}}
2586
2587/**
2588 *
2589 */
2590function quux (foo) {
2591
2592}
2593
2594/**
2595 * @todo
2596 */
2597function quux () {
2598
2599}
2600
2601/**
2602 * @extends Foo
2603 */
2604function quux () {
2605
2606}
2607// Settings: {"jsdoc":{"tagNamePreference":{"augments":{"message":"@extends is to be used over @augments.","replacement":"extends"}}}}
2608
2609/**
2610 * Registers the `target` class as a transient dependency; each time the dependency is resolved a new instance will be created.
2611 *
2612 * @param target - The class / constructor function to register as transient.
2613 *
2614 * @example ```ts
2615@transient()
2616class Foo { }
2617```
2618 * @param Time for a new tag
2619 */
2620export function transient<T>(target?: T): T {
2621 // ...
2622}
2623````
2624
2625
2626<a name="eslint-plugin-jsdoc-rules-check-types"></a>
2627### <code>check-types</code>
2628
2629Reports invalid types.
2630
2631By default, ensures that the casing of native types is the same as in this list:
2632
2633```
2634undefined
2635null
2636boolean
2637number
2638bigint
2639string
2640symbol
2641object
2642Array
2643Function
2644Date
2645RegExp
2646```
2647
2648<a name="eslint-plugin-jsdoc-rules-check-types-options-6"></a>
2649#### Options
2650
2651`check-types` allows one option:
2652
2653- An option object:
2654 - with the key `noDefaults` to insist that only the supplied option type
2655 map is to be used, and that the default preferences (such as "string"
2656 over "String") will not be enforced. The option's default is `false`.
2657 - with the key `exemptTagContexts` which will avoid reporting when a
2658 bad type is found on a specified tag. Set to an array of objects with
2659 a key `tag` set to the tag to exempt, and a `types` key which can
2660 either be `true` to indicate that any types on that tag will be allowed,
2661 or to an array of strings which will only allow specific bad types.
2662 If an array of strings is given, these must match the type exactly,
2663 e.g., if you only allow `"object"`, it will not allow
2664 `"object<string, string>"`. Note that this is different from the
2665 behavior of `settings.jsdoc.preferredTypes`. This option is useful
2666 for normally restricting generic types like `object` with
2667 `preferredTypes`, but allowing `typedef` to indicate that its base
2668 type is `object`.
2669 - with the key `unifyParentAndChildTypeChecks` which will treat
2670 `settings.jsdoc.preferredTypes` keys such as `SomeType` as matching
2671 not only child types such as an unadorned `SomeType` but also
2672 `SomeType<aChildType>`, `SomeType.<aChildType>`, or if `SomeType` is
2673 `Array` (or `[]`), it will match `aChildType[]`. If this is `false` or
2674 unset, the former format will only apply to types which are not parent
2675 types/unions whereas the latter formats will only apply for parent
2676 types/unions. The special types `[]`, `.<>` (or `.`), and `<>`
2677 act only as parent types (and will not match a bare child type such as
2678 `Array` even when unified, though, as mentioned, `Array` will match
2679 say `string[]` or `Array.<string>` when unified). The special type
2680 `*` is only a child type. Note that there is no detection of parent
2681 and child type together, e.g., you cannot specify preferences for
2682 `string[]` specifically as distinct from say `number[]`, but you can
2683 target both with `[]` or the child types `number` or `string`.
2684
2685See also the documentation on `settings.jsdoc.preferredTypes` which impacts
2686the behavior of `check-types`.
2687
2688<a name="eslint-plugin-jsdoc-rules-check-types-why-not-capital-case-everything"></a>
2689#### Why not capital case everything?
2690
2691Why are `boolean`, `number` and `string` exempt from starting with a capital letter? Let's take `string` as an example. In Javascript, everything is an object. The string Object has prototypes for string functions such as `.toUpperCase()`.
2692
2693Fortunately we don't have to write `new String()` everywhere in our code. Javascript will automatically wrap string primitives into string Objects when we're applying a string function to a string primitive. This way the memory footprint is a tiny little bit smaller, and the [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has less work to do.
2694
2695So in a sense, there two types of strings in Javascript; `{string}` literals, also called primitives and `{String}` Objects. We use the primitives because it's easier to write and uses less memory. `{String}` and `{string}` are technically both valid, but they are not the same.
2696
2697```js
2698new String('lard') // String {0: "l", 1: "a", 2: "r", 3: "d", length: 4}
2699'lard' // "lard"
2700new String('lard') === 'lard' // false
2701```
2702
2703To make things more confusing, there are also object literals and object Objects. But object literals are still static Objects and object Objects are instantiated Objects. So an object primitive is still an object Object.
2704
2705However, `Object.create(null)` objects are not `instanceof Object`, however, so
2706in the case of this Object we lower-case to indicate possible support for
2707these objects.
2708
2709Basically, for primitives, we want to define the type as a primitive, because that's what we use in 99.9% of cases. For everything else, we use the type rather than the primitive. Otherwise it would all just be `{object}`.
2710
2711In short: It's not about consistency, rather about the 99.9% use case. (And some
2712functions might not even support the objects if they are checking for identity.)
2713
2714type name | `typeof` | check-types | testcase
2715--|--|--|--
2716**Array** | object | **Array** | `([]) instanceof Array` -> `true`
2717**Function** | function | **function** | `(function f () {}) instanceof Function` -> `true`
2718**Date** | object | **Date** | `(new Date()) instanceof Date` -> `true`
2719**RegExp** | object | **RegExp** | `(new RegExp(/.+/)) instanceof RegExp` -> `true`
2720Object | **object** | **object** | `({}) instanceof Object` -> `true` but `Object.create(null) instanceof Object` -> `false`
2721Boolean | **boolean** | **boolean** | `(true) instanceof Boolean` -> **`false`**
2722Number | **number** | **number** | `(41) instanceof Number` -> **`false`**
2723String | **string** | **string** | `("test") instanceof String` -> **`false`**
2724
2725|||
2726|---|---|
2727|Context|everywhere|
2728|Tags|`augments`, `class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
2729|Aliases|`constructor`, `const`, `extends`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
2730|Closure-only|`package`, `private`, `protected`, `public`, `static`|
2731|Options|`noDefaults`, `exemptTagContexts`, `unifyParentAndChildTypeChecks`|
2732|Settings|`preferredTypes`, `mode`|
2733
2734The following patterns are considered problems:
2735
2736````js
2737/**
2738 * @param {abc} foo
2739 */
2740function quux (foo) {
2741
2742}
2743// Settings: {"jsdoc":{"preferredTypes":{"abc":100}}}
2744// Message: Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.
2745
2746/**
2747 * @param {Number} foo
2748 */
2749function quux (foo) {
2750
2751}
2752// Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".
2753
2754/**
2755 * @arg {Number} foo
2756 */
2757function quux (foo) {
2758
2759}
2760// Message: Invalid JSDoc @arg "foo" type "Number"; prefer: "number".
2761
2762/**
2763 * @returns {Number} foo
2764 * @throws {Number} foo
2765 */
2766function quux () {
2767
2768}
2769// Message: Invalid JSDoc @returns type "Number"; prefer: "number".
2770
2771/**
2772 * @param {(Number|string|Boolean)=} foo
2773 */
2774function quux (foo, bar, baz) {
2775
2776}
2777// Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".
2778
2779/**
2780 * @param {Array.<Number|String>} foo
2781 */
2782function quux (foo, bar, baz) {
2783
2784}
2785// Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".
2786
2787/**
2788 * @param {(Number|String)[]} foo
2789 */
2790function quux (foo, bar, baz) {
2791
2792}
2793// Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".
2794
2795/**
2796 * @param {abc} foo
2797 */
2798function qux(foo) {
2799}
2800// Settings: {"jsdoc":{"preferredTypes":{"abc":"Abc","string":"Str"}}}
2801// Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
2802
2803/**
2804 * @param {abc} foo
2805 */
2806function qux(foo) {
2807}
2808// Settings: {"jsdoc":{"preferredTypes":{"abc":{"replacement":"Abc"},"string":"Str"}}}
2809// Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
2810
2811/**
2812 * @param {abc} foo
2813 */
2814function qux(foo) {
2815}
2816// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\"; prefer: \"Abc\".","replacement":"Abc"},"string":"Str"}}}
2817// Message: Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".
2818
2819/**
2820 * @param {abc} foo
2821 * @param {cde} bar
2822 * @param {object} baz
2823 */
2824function qux(foo, bar, baz) {
2825}
2826// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\"; prefer: \"Abc\".","replacement":"Abc"},"cde":{"message":"More messed up JSDoc @{{tagName}}{{tagValue}} type \"cde\"; prefer: \"Cde\".","replacement":"Cde"},"object":"Object"}}}
2827// Message: Messed up JSDoc @param "foo" type "abc"; prefer: "Abc".
2828
2829/**
2830 * @param {abc} foo
2831 */
2832function qux(foo) {
2833}
2834// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\".","replacement":false},"string":"Str"}}}
2835// Message: Messed up JSDoc @param "foo" type "abc".
2836
2837/**
2838 * @param {abc} foo
2839 */
2840function qux(foo) {
2841}
2842// Settings: {"jsdoc":{"preferredTypes":{"abc":{"message":"Messed up JSDoc @{{tagName}}{{tagValue}} type \"abc\"."},"string":"Str"}}}
2843// Message: Messed up JSDoc @param "foo" type "abc".
2844
2845/**
2846 * @param {abc} foo
2847 * @param {Number} bar
2848 */
2849function qux(foo, bar) {
2850}
2851// Settings: {"jsdoc":{"preferredTypes":{"abc":"Abc","string":"Str"}}}
2852// Options: [{"noDefaults":true}]
2853// Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
2854
2855/**
2856 * @param {abc} foo
2857 * @param {Number} bar
2858 */
2859function qux(foo, bar) {
2860}
2861// Settings: {"jsdoc":{"preferredTypes":{"abc":"Abc","string":"Str"}}}
2862// Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
2863
2864/**
2865 * @param {abc} foo
2866 */
2867function qux(foo) {
2868}
2869// Settings: {"jsdoc":{"preferredTypes":{"abc":false,"string":"Str"}}}
2870// Message: Invalid JSDoc @param "foo" type "abc".
2871
2872/**
2873 * @param {abc} foo
2874 */
2875function qux(foo) {
2876}
2877// Settings: {"jsdoc":{"preferredTypes":{"abc":false}}}
2878// Message: Invalid JSDoc @param "foo" type "abc".
2879
2880/**
2881 * @param {*} baz
2882 */
2883function qux(baz) {
2884}
2885// Settings: {"jsdoc":{"preferredTypes":{"*":false,"abc":"Abc","string":"Str"}}}
2886// Message: Invalid JSDoc @param "baz" type "*".
2887
2888/**
2889 * @param {*} baz
2890 */
2891function qux(baz) {
2892}
2893// Settings: {"jsdoc":{"preferredTypes":{"*":"aaa","abc":"Abc","string":"Str"}}}
2894// Message: Invalid JSDoc @param "baz" type "*"; prefer: "aaa".
2895
2896/**
2897 * @param {abc} foo
2898 * @param {Number} bar
2899 */
2900function qux(foo, bar) {
2901}
2902// Settings: {"jsdoc":{"preferredTypes":{"abc":"Abc","string":"Str"}}}
2903// Message: Invalid JSDoc @param "foo" type "abc"; prefer: "Abc".
2904
2905/**
2906 * @param {Array} foo
2907 */
2908function quux (foo) {
2909
2910}
2911// Settings: {"jsdoc":{"preferredTypes":{"Array":"GenericArray"}}}
2912// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".
2913
2914/**
2915 * @param {Array} foo
2916 */
2917function quux (foo) {
2918
2919}
2920// Settings: {"jsdoc":{"preferredTypes":{"Array":"GenericArray","Array.<>":"GenericArray"}}}
2921// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".
2922
2923/**
2924 * @param {Array.<string>} foo
2925 */
2926function quux (foo) {
2927
2928}
2929// Settings: {"jsdoc":{"preferredTypes":{"Array.<>":"GenericArray"}}}
2930// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".
2931
2932/**
2933 * @param {Array<string>} foo
2934 */
2935function quux (foo) {
2936
2937}
2938// Settings: {"jsdoc":{"preferredTypes":{"Array<>":"GenericArray"}}}
2939// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "GenericArray".
2940
2941/**
2942 * @param {string[]} foo
2943 */
2944function quux (foo) {
2945
2946}
2947// Settings: {"jsdoc":{"preferredTypes":{"[]":"SpecialTypeArray"}}}
2948// Message: Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".
2949
2950/**
2951 * @param {string[]} foo
2952 */
2953function quux (foo) {
2954
2955}
2956// Settings: {"jsdoc":{"preferredTypes":{"[]":"SpecialTypeArray"}}}
2957// Options: [{"unifyParentAndChildTypeChecks":true}]
2958// Message: Invalid JSDoc @param "foo" type "[]"; prefer: "SpecialTypeArray".
2959
2960/**
2961 * @param {string[]} foo
2962 */
2963function quux (foo) {
2964
2965}
2966// Settings: {"jsdoc":{"preferredTypes":{"Array":"SpecialTypeArray"}}}
2967// Options: [{"unifyParentAndChildTypeChecks":true}]
2968// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "SpecialTypeArray".
2969
2970/**
2971 * @param {object} foo
2972 */
2973function quux (foo) {
2974
2975}
2976// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
2977// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
2978
2979/**
2980 * @param {object} foo
2981 */
2982function quux (foo) {
2983
2984}
2985// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject","object.<>":"GenericObject"}}}
2986// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
2987
2988/**
2989 * @param {object} foo
2990 */
2991function quux (foo) {
2992
2993}
2994// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject","object<>":"GenericObject"}}}
2995// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
2996
2997/**
2998 * @param {object.<string>} foo
2999 */
3000function quux (foo) {
3001
3002}
3003// Settings: {"jsdoc":{"preferredTypes":{"object.<>":"GenericObject"}}}
3004// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
3005
3006/**
3007 * @param {object<string>} foo
3008 */
3009function quux (foo) {
3010
3011}
3012// Settings: {"jsdoc":{"preferredTypes":{"object<>":"GenericObject"}}}
3013// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
3014
3015/**
3016 * @param {object.<string, number>} foo
3017 */
3018function quux (foo) {
3019
3020}
3021// Settings: {"jsdoc":{"preferredTypes":{"object.<>":"GenericObject"}}}
3022// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
3023
3024/**
3025 * @param {object<string, number>} foo
3026 */
3027function quux (foo) {
3028
3029}
3030// Settings: {"jsdoc":{"preferredTypes":{"object<>":"GenericObject"}}}
3031// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
3032
3033/**
3034 * @param {object.<string>} foo
3035 */
3036function quux (foo) {
3037
3038}
3039// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
3040// Options: [{"unifyParentAndChildTypeChecks":true}]
3041// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
3042
3043/**
3044 * @param {object<string>} foo
3045 */
3046function quux (foo) {
3047
3048}
3049// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
3050// Options: [{"unifyParentAndChildTypeChecks":true}]
3051// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
3052
3053/**
3054 * @param {object} foo
3055 */
3056function quux (foo) {
3057
3058}
3059// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
3060// Options: [{"unifyParentAndChildTypeChecks":true}]
3061// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
3062
3063/**
3064 * @param {object} foo
3065 */
3066function quux (foo) {
3067
3068}
3069// Settings: {"jsdoc":{"preferredTypes":{"object":false}}}
3070// Options: [{"unifyParentAndChildTypeChecks":true}]
3071// Message: Invalid JSDoc @param "foo" type "object".
3072
3073/**
3074 * @param {object} foo
3075 */
3076function quux (foo) {
3077
3078}
3079// Settings: {"jsdoc":{"preferredTypes":{"object":false}}}
3080// Message: Invalid JSDoc @param "foo" type "object".
3081
3082/**
3083 * @param {object.<string, number>} foo
3084 */
3085function quux (foo) {
3086
3087}
3088// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
3089// Options: [{"unifyParentAndChildTypeChecks":true}]
3090// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
3091
3092/**
3093 * @param {object<string, number>} foo
3094 */
3095function quux (foo) {
3096
3097}
3098// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
3099// Options: [{"unifyParentAndChildTypeChecks":true}]
3100// Message: Invalid JSDoc @param "foo" type "object"; prefer: "GenericObject".
3101
3102/**
3103 *
3104 * @param {string[][]} foo
3105 */
3106function quux (foo) {
3107
3108}
3109// Settings: {"jsdoc":{"preferredTypes":{"[]":"Array."}}}
3110// Message: Invalid JSDoc @param "foo" type "[]"; prefer: "Array.".
3111
3112/**
3113 *
3114 * @param {string[][]} foo
3115 */
3116function quux (foo) {
3117
3118}
3119// Settings: {"jsdoc":{"preferredTypes":{"[]":"Array.<>"}}}
3120// Message: Invalid JSDoc @param "foo" type "[]"; prefer: "Array.<>".
3121
3122/**
3123 *
3124 * @param {string[][]} foo
3125 */
3126function quux (foo) {
3127
3128}
3129// Settings: {"jsdoc":{"preferredTypes":{"[]":"Array<>"}}}
3130// Message: Invalid JSDoc @param "foo" type "[]"; prefer: "Array<>".
3131
3132/**
3133 *
3134 * @param {object.<string, object.<string, string>>} foo
3135 */
3136function quux (foo) {
3137
3138}
3139// Settings: {"jsdoc":{"preferredTypes":{"object.":"Object"}}}
3140// Message: Invalid JSDoc @param "foo" type "object"; prefer: "Object".
3141
3142/**
3143 *
3144 * @param {object.<string, object.<string, string>>} foo
3145 */
3146function quux (foo) {
3147
3148}
3149// Settings: {"jsdoc":{"preferredTypes":{"object.":"Object<>"}}}
3150// Message: Invalid JSDoc @param "foo" type "object"; prefer: "Object<>".
3151
3152/**
3153 *
3154 * @param {object<string, object<string, string>>} foo
3155 */
3156function quux (foo) {
3157
3158}
3159// Settings: {"jsdoc":{"preferredTypes":{"object<>":"Object."}}}
3160// Message: Invalid JSDoc @param "foo" type "object"; prefer: "Object.".
3161
3162/**
3163 *
3164 * @param {Array.<Array.<string>>} foo
3165 */
3166function quux (foo) {
3167
3168}
3169// Settings: {"jsdoc":{"preferredTypes":{"Array.":"[]"}}}
3170// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "[]".
3171
3172/**
3173 *
3174 * @param {Array.<Array.<string>>} foo
3175 */
3176function quux (foo) {
3177
3178}
3179// Settings: {"jsdoc":{"preferredTypes":{"Array.":"Array<>"}}}
3180// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "Array<>".
3181
3182/**
3183 *
3184 * @param {Array.<Array.<string>>} foo
3185 */
3186function quux (foo) {
3187
3188}
3189// Settings: {"jsdoc":{"preferredTypes":{"Array.":"<>"}}}
3190// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "<>".
3191
3192/**
3193 *
3194 * @param {Array.<MyArray.<string>>} foo
3195 */
3196function quux (foo) {
3197
3198}
3199// Settings: {"jsdoc":{"preferredTypes":{"Array.":"<>"}}}
3200// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "<>".
3201
3202/**
3203 *
3204 * @param {Array.<MyArray.<string>>} foo
3205 */
3206function quux (foo) {
3207
3208}
3209// Settings: {"jsdoc":{"preferredTypes":{"MyArray.":"<>"}}}
3210// Message: Invalid JSDoc @param "foo" type "MyArray"; prefer: "<>".
3211
3212/**
3213 *
3214 * @param {Array<Array<string>>} foo
3215 */
3216function quux (foo) {
3217
3218}
3219// Settings: {"jsdoc":{"preferredTypes":{"<>":"Array."}}}
3220// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".
3221
3222/**
3223 *
3224 * @param {Array<Array<string>>} foo
3225 */
3226function quux (foo) {
3227
3228}
3229// Settings: {"jsdoc":{"preferredTypes":{"Array":"Array."}}}
3230// Options: [{"unifyParentAndChildTypeChecks":true}]
3231// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "Array.".
3232
3233/**
3234 *
3235 * @param {Array<Array<string>>} foo
3236 */
3237function quux (foo) {
3238
3239}
3240// Settings: {"jsdoc":{"preferredTypes":{"<>":"[]"}}}
3241// Message: Invalid JSDoc @param "foo" type "Array"; prefer: "[]".
3242
3243/** @typedef {String} foo */
3244// Message: Invalid JSDoc @typedef "foo" type "String"; prefer: "string".
3245
3246/**
3247 * @this {array}
3248 */
3249function quux () {}
3250// Settings: {"jsdoc":{"mode":"closure"}}
3251// Message: Invalid JSDoc @this type "array"; prefer: "Array".
3252
3253/**
3254 * @export {array}
3255 */
3256function quux () {}
3257// Settings: {"jsdoc":{"mode":"closure"}}
3258// Message: Invalid JSDoc @export type "array"; prefer: "Array".
3259
3260/**
3261 * @typedef {object} foo
3262 * @property {object} bar
3263 */
3264// Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
3265// Options: [{"exemptTagContexts":[{"tag":"typedef","types":true}]}]
3266// Message: Invalid JSDoc @property "bar" type "object"; prefer: "Object".
3267
3268/** @typedef {object} foo */
3269// Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
3270// Options: [{"exemptTagContexts":[{"tag":"typedef","types":["array"]}]}]
3271// Message: Invalid JSDoc @typedef "foo" type "object"; prefer: "Object".
3272
3273/**
3274 * @typedef {object} foo
3275 * @property {object} bar
3276 */
3277// Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
3278// Options: [{"exemptTagContexts":[{"tag":"typedef","types":["object"]}]}]
3279// Message: Invalid JSDoc @property "bar" type "object"; prefer: "Object".
3280
3281/** @typedef {object<string, string>} foo */
3282// Settings: {"jsdoc":{"preferredTypes":{"object<>":"Object<>"}}}
3283// Options: [{"exemptTagContexts":[{"tag":"typedef","types":["object"]}]}]
3284// Message: Invalid JSDoc @typedef "foo" type "object"; prefer: "Object<>".
3285````
3286
3287The following patterns are not considered problems:
3288
3289````js
3290/**
3291 * @param {number} foo
3292 * @param {Bar} bar
3293 * @param {*} baz
3294 */
3295function quux (foo, bar, baz) {
3296
3297}
3298
3299/**
3300 * @arg {number} foo
3301 * @arg {Bar} bar
3302 * @arg {*} baz
3303 */
3304function quux (foo, bar, baz) {
3305
3306}
3307
3308/**
3309 * @param {(number|string|boolean)=} foo
3310 */
3311function quux (foo, bar, baz) {
3312
3313}
3314
3315/**
3316 * @param {typeof bar} foo
3317 */
3318function qux(foo) {
3319}
3320
3321/**
3322 * @param {import('./foo').bar.baz} foo
3323 */
3324function qux(foo) {
3325}
3326
3327/**
3328 * @param {(x: number, y: string) => string} foo
3329 */
3330function qux(foo) {
3331}
3332
3333/**
3334 * @param {() => string} foo
3335 */
3336function qux(foo) {
3337}
3338
3339/**
3340 * @returns {Number} foo
3341 * @throws {Number} foo
3342 */
3343function quux () {
3344
3345}
3346// Options: [{"noDefaults":true}]
3347
3348/**
3349 * @param {Object} foo
3350 */
3351function quux (foo) {
3352
3353}
3354// Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
3355
3356/**
3357 * @param {Array} foo
3358 */
3359function quux (foo) {
3360
3361}
3362
3363/**
3364 * @param {Array.<string>} foo
3365 */
3366function quux (foo) {
3367
3368}
3369// Settings: {"jsdoc":{"preferredTypes":{"Array":"GenericArray"}}}
3370
3371/**
3372 * @param {Array<string>} foo
3373 */
3374function quux (foo) {
3375
3376}
3377// Settings: {"jsdoc":{"preferredTypes":{"Array":"GenericArray"}}}
3378
3379/**
3380 * @param {string[]} foo
3381 */
3382function quux (foo) {
3383
3384}
3385// Settings: {"jsdoc":{"preferredTypes":{"Array":"SpecialTypeArray","Array.<>":"SpecialTypeArray","Array<>":"SpecialTypeArray"}}}
3386
3387/**
3388 * @param {string[]} foo
3389 */
3390function quux (foo) {
3391
3392}
3393// Settings: {"jsdoc":{"preferredTypes":{"Array.<>":"SpecialTypeArray","Array<>":"SpecialTypeArray"}}}
3394// Options: [{"unifyParentAndChildTypeChecks":true}]
3395
3396/**
3397 * @param {Array} foo
3398 */
3399function quux (foo) {
3400
3401}
3402// Settings: {"jsdoc":{"preferredTypes":{"[]":"SpecialTypeArray"}}}
3403
3404/**
3405 * @param {Array} foo
3406 */
3407function quux (foo) {
3408
3409}
3410// Settings: {"jsdoc":{"preferredTypes":{"[]":"SpecialTypeArray"}}}
3411// Options: [{"unifyParentAndChildTypeChecks":true}]
3412
3413/**
3414 * @param {Array} foo
3415 */
3416function quux (foo) {
3417
3418}
3419// Settings: {"jsdoc":{"preferredTypes":{"Array.<>":"GenericArray"}}}
3420
3421/**
3422 * @param {Array} foo
3423 */
3424function quux (foo) {
3425
3426}
3427// Settings: {"jsdoc":{"preferredTypes":{"Array<>":"GenericArray"}}}
3428
3429/**
3430 * @param {object} foo
3431 */
3432function quux (foo) {
3433
3434}
3435
3436/**
3437 * @param {object.<string>} foo
3438 */
3439function quux (foo) {
3440
3441}
3442// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
3443
3444/**
3445 * @param {object<string>} foo
3446 */
3447function quux (foo) {
3448
3449}
3450// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
3451
3452/**
3453 * @param {object.<string, number>} foo
3454 */
3455function quux (foo) {
3456
3457}
3458// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
3459
3460/**
3461 * @param {object<string, number>} foo
3462 */
3463function quux (foo) {
3464
3465}
3466// Settings: {"jsdoc":{"preferredTypes":{"object":"GenericObject"}}}
3467
3468/**
3469 * @param {object} foo
3470 */
3471function quux (foo) {
3472
3473}
3474// Settings: {"jsdoc":{"preferredTypes":{"object.<>":"GenericObject"}}}
3475
3476/**
3477 * @param {object} foo
3478 */
3479function quux (foo) {
3480
3481}
3482// Settings: {"jsdoc":{"preferredTypes":{"object<>":"GenericObject"}}}
3483
3484/**
3485 * @param {Number<} Ignore the error as not a validating rule
3486 */
3487function quux (foo) {
3488
3489}
3490
3491/** @param {function(...)} callback The function to invoke. */
3492var subscribe = function(callback) {};
3493
3494/**
3495 * @this {Array}
3496 */
3497function quux () {}
3498// Settings: {"jsdoc":{"mode":"closure"}}
3499
3500/**
3501 * @export {Array}
3502 */
3503function quux () {}
3504// Settings: {"jsdoc":{"mode":"closure"}}
3505
3506/** @type {new() => EntityBase} */
3507
3508/** @typedef {object} foo */
3509// Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
3510// Options: [{"exemptTagContexts":[{"tag":"typedef","types":true}]}]
3511
3512/** @typedef {object<string, string>} foo */
3513// Settings: {"jsdoc":{"preferredTypes":{"object":"Object"}}}
3514
3515/** @typedef {object<string, string>} foo */
3516// Settings: {"jsdoc":{"preferredTypes":{"object<>":"Object<>"}}}
3517// Options: [{"exemptTagContexts":[{"tag":"typedef","types":["object<string, string>"]}]}]
3518````
3519
3520
3521<a name="eslint-plugin-jsdoc-rules-check-values"></a>
3522### <code>check-values</code>
3523
3524This rule checks the values for a handful of tags:
3525
35261. `@version` - Checks that there is a present and valid
3527 [semver](https://semver.org/) version value.
35282. `@since` - As with `@version`
35293. `@license` - Checks that there is a present and valid SPDX identifier
3530 or is present within an `allowedLicenses` option.
35314. `@author` - Checks there is a value present, and if the option
3532 `allowedAuthors` is present, ensure that the author value is one
3533 of these array items.
3534
3535<a name="eslint-plugin-jsdoc-rules-check-values-options-7"></a>
3536#### Options
3537
3538<a name="eslint-plugin-jsdoc-rules-check-values-options-7-allowedauthors"></a>
3539##### <code>allowedAuthors</code>
3540
3541An array of allowable author values. If absent, only non-whitespace will
3542be checked for.
3543
3544<a name="eslint-plugin-jsdoc-rules-check-values-options-7-allowedlicenses"></a>
3545##### <code>allowedLicenses</code>
3546
3547An array of allowable license values or `true` to allow any license text.
3548If present as an array, will be used in place of SPDX identifiers.
3549
3550<a name="eslint-plugin-jsdoc-rules-check-values-options-7-licensepattern"></a>
3551##### <code>licensePattern</code>
3552
3553A string to be converted into a `RegExp` (with `u` flag) and whose first
3554parenthetical grouping, if present, will match the portion of the license
3555description to check (if no grouping is present, then the whole portion
3556matched will be used). Defaults to `([^\n]*)`, i.e., the SPDX expression
3557is expected before any line breaks.
3558
3559|||
3560|---|---|
3561|Context|everywhere|
3562|Tags|`@version`, `@since`, `@license`, `@author`|
3563|Options|`allowedAuthors`, `allowedLicenses`, `licensePattern`|
3564|Settings|`tagNamePreference`|
3565
3566The following patterns are considered problems:
3567
3568````js
3569/**
3570 * @version
3571 */
3572function quux (foo) {
3573
3574}
3575// Message: Missing JSDoc @version.
3576
3577/**
3578 * @version 3.1
3579 */
3580function quux (foo) {
3581
3582}
3583// Message: Invalid JSDoc @version: "3.1".
3584
3585/**
3586 * @since
3587 */
3588function quux (foo) {
3589
3590}
3591// Message: Missing JSDoc @since.
3592
3593/**
3594 * @since 3.1
3595 */
3596function quux (foo) {
3597
3598}
3599// Message: Invalid JSDoc @since: "3.1".
3600
3601/**
3602 * @license
3603 */
3604function quux (foo) {
3605
3606}
3607// Message: Missing JSDoc @license.
3608
3609/**
3610 * @license FOO
3611 */
3612function quux (foo) {
3613
3614}
3615// Message: Invalid JSDoc @license: "FOO"; expected SPDX expression: https://spdx.org/licenses/.
3616
3617/**
3618 * @license FOO
3619 */
3620function quux (foo) {
3621
3622}
3623// Options: [{"allowedLicenses":["BAR","BAX"]}]
3624// Message: Invalid JSDoc @license: "FOO"; expected one of BAR, BAX.
3625
3626/**
3627 * @license MIT-7
3628 * Some extra text...
3629 */
3630function quux (foo) {
3631
3632}
3633// Message: Invalid JSDoc @license: "MIT-7"; expected SPDX expression: https://spdx.org/licenses/.
3634
3635/**
3636 * @license (MIT OR GPL-2.5)
3637 */
3638function quux (foo) {
3639
3640}
3641// Message: Invalid JSDoc @license: "(MIT OR GPL-2.5)"; expected SPDX expression: https://spdx.org/licenses/.
3642
3643/**
3644 * @license MIT
3645 * Some extra text
3646 */
3647function quux (foo) {
3648
3649}
3650// Options: [{"licensePattern":"[\\s\\S]*"}]
3651// Message: Invalid JSDoc @license: "MIT
3652Some extra text"; expected SPDX expression: https://spdx.org/licenses/.
3653
3654/**
3655 * @author
3656 */
3657function quux (foo) {
3658
3659}
3660// Message: Missing JSDoc @author.
3661
3662/**
3663 * @author Brett Zamir
3664 */
3665function quux (foo) {
3666
3667}
3668// Options: [{"allowedAuthors":["Gajus Kuizinas","golopot"]}]
3669// Message: Invalid JSDoc @author: "Brett Zamir"; expected one of Gajus Kuizinas, golopot.
3670````
3671
3672The following patterns are not considered problems:
3673
3674````js
3675/**
3676 * @version 3.4.1
3677 */
3678function quux (foo) {
3679
3680}
3681
3682/**
3683 * @since 3.4.1
3684 */
3685function quux (foo) {
3686
3687}
3688
3689/**
3690 * @license MIT
3691 */
3692function quux (foo) {
3693
3694}
3695
3696/**
3697 * @license MIT
3698 * Some extra text...
3699 */
3700function quux (foo) {
3701
3702}
3703
3704/**
3705 * @license (MIT OR GPL-2.0)
3706 */
3707function quux (foo) {
3708
3709}
3710
3711/**
3712 * @license FOO
3713 */
3714function quux (foo) {
3715
3716}
3717// Options: [{"allowedLicenses":["FOO","BAR","BAX"]}]
3718
3719/**
3720 * @license FOO
3721 */
3722function quux (foo) {
3723
3724}
3725// Options: [{"allowedLicenses":true}]
3726
3727/**
3728 * @license MIT
3729 * Some extra text
3730 */
3731function quux (foo) {
3732
3733}
3734// Options: [{"licensePattern":"[^\n]*"}]
3735
3736/**
3737 * @author Gajus Kuizinas
3738 */
3739function quux (foo) {
3740
3741}
3742
3743/**
3744 * @author Brett Zamir
3745 */
3746function quux (foo) {
3747
3748}
3749// Options: [{"allowedAuthors":["Gajus Kuizinas","golopot","Brett Zamir"]}]
3750````
3751
3752
3753<a name="eslint-plugin-jsdoc-rules-empty-tags"></a>
3754### <code>empty-tags</code>
3755
3756Expects the following tags to be empty of any content:
3757
3758- `@abstract`
3759- `@async`
3760- `@generator`
3761- `@global`
3762- `@hideconstructor`
3763- `@ignore`
3764- `@inheritdoc`
3765- `@inner`
3766- `@instance`
3767- `@override`
3768- `@readonly`
3769
3770The following will also be expected to be empty unless `settings.jsdoc.mode`
3771is set to "closure" (which allows types).
3772
3773- `@package`
3774- `@private`
3775- `@protected`
3776- `@public`
3777- `@static`
3778
3779Note that `@private` will still be checked for content by this rule even with
3780`settings.jsdoc.ignorePrivate` set to `true` (a setting which normally
3781causes rules not to take effect).
3782
3783<a name="eslint-plugin-jsdoc-rules-empty-tags-options-8"></a>
3784#### Options
3785
3786<a name="eslint-plugin-jsdoc-rules-empty-tags-options-8-tags"></a>
3787##### <code>tags</code>
3788
3789If you want additional tags to be checked for their descriptions, you may
3790add them within this option.
3791
3792```js
3793{
3794 'jsdoc/empty-tags': ['error', {tags: ['event']}]
3795}
3796```
3797
3798|||
3799|---|---|
3800|Context|everywhere|
3801|Tags| and others added by `tags`|
3802|Aliases||
3803|Options|`tags`|
3804The following patterns are considered problems:
3805
3806````js
3807/**
3808 * @abstract extra text
3809 */
3810function quux () {
3811
3812}
3813// Message: @abstract should be empty.
3814
3815/**
3816 * @abstract extra text
3817 * @inheritdoc
3818 * @async out of place
3819 */
3820function quux () {
3821
3822}
3823// Message: @abstract should be empty.
3824
3825/**
3826 * @event anEvent
3827 */
3828function quux () {
3829
3830}
3831// Options: [{"tags":["event"]}]
3832// Message: @event should be empty.
3833
3834/**
3835 * @private {someType}
3836 */
3837function quux () {
3838
3839}
3840// Message: @private should be empty.
3841
3842/**
3843 * @private {someType}
3844 */
3845function quux () {
3846
3847}
3848// Settings: {"jsdoc":{"ignorePrivate":true}}
3849// Message: @private should be empty.
3850````
3851
3852The following patterns are not considered problems:
3853
3854````js
3855/**
3856 * @abstract
3857 */
3858function quux () {
3859
3860}
3861
3862/**
3863 *
3864 */
3865function quux () {
3866
3867}
3868
3869/**
3870 * @param aName
3871 */
3872function quux () {
3873
3874}
3875
3876/**
3877 * @abstract
3878 * @inheritdoc
3879 * @async
3880 */
3881function quux () {
3882
3883}
3884
3885/**
3886 * @private {someType}
3887 */
3888function quux () {
3889
3890}
3891// Settings: {"jsdoc":{"mode":"closure"}}
3892
3893/**
3894 * @private
3895 */
3896function quux () {
3897
3898}
3899````
3900
3901
3902<a name="eslint-plugin-jsdoc-rules-implements-on-classes"></a>
3903### <code>implements-on-classes</code>
3904
3905Reports an issue with any non-constructor function using `@implements`.
3906
3907Constructor functions, whether marked with `@class`, `@constructs`, or being
3908an ES6 class constructor, will not be flagged.
3909
3910To indicate that a function follows another function's signature, one might
3911instead use `@type` to indicate the `@function` or `@callback` to which the
3912funciton is adhering.
3913
3914<a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-9"></a>
3915#### Options
3916
3917<a name="eslint-plugin-jsdoc-rules-implements-on-classes-options-9-contexts"></a>
3918##### <code>contexts</code>
3919
3920Set this to an array of strings representing the AST context
3921where you wish the rule to be applied.
3922Overrides the default contexts (see below). Set to `"any"` if you want
3923the rule to apply to any jsdoc block throughout your files (as is necessary
3924for finding function blocks not attached to a function declaration or
3925expression, i.e., `@callback` or `@function` (or its aliases `@func` or
3926`@method`) (including those associated with an `@interface`).
3927
3928|||
3929|---|---|
3930|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
3931|Tags|`implements` (prevented)|
3932
3933The following patterns are considered problems:
3934
3935````js
3936/**
3937 * @implements {SomeClass}
3938 */
3939function quux () {
3940
3941}
3942// Message: @implements used on a non-constructor function
3943
3944/**
3945 * @implements {SomeClass}
3946 */
3947function quux () {
3948
3949}
3950// Options: [{"contexts":["any"]}]
3951// Message: @implements used on a non-constructor function
3952
3953/**
3954 * @function
3955 * @implements {SomeClass}
3956 */
3957function quux () {
3958
3959}
3960// Options: [{"contexts":["any"]}]
3961// Message: @implements used on a non-constructor function
3962
3963/**
3964 * @callback
3965 * @implements {SomeClass}
3966 */
3967// Options: [{"contexts":["any"]}]
3968// Message: @implements used on a non-constructor function
3969
3970/**
3971 * @implements {SomeClass}
3972 */
3973function quux () {
3974
3975}
3976// Settings: {"jsdoc":{"tagNamePreference":{"implements":false}}}
3977// Message: Unexpected tag `@implements`
3978````
3979
3980The following patterns are not considered problems:
3981
3982````js
3983/**
3984 * @implements {SomeClass}
3985 * @class
3986 */
3987function quux () {
3988
3989}
3990
3991/**
3992 * @implements {SomeClass}
3993 * @class
3994 */
3995function quux () {
3996
3997}
3998// Options: [{"contexts":["any"]}]
3999
4000/**
4001 * @implements {SomeClass}
4002 */
4003// Options: [{"contexts":["any"]}]
4004
4005/**
4006 * @implements {SomeClass}
4007 * @constructor
4008 */
4009function quux () {
4010
4011}
4012
4013/**
4014 *
4015 */
4016class quux {
4017 /**
4018 * @implements {SomeClass}
4019 */
4020 constructor () {
4021
4022 }
4023}
4024
4025/**
4026 *
4027 */
4028const quux = class {
4029 /**
4030 * @implements {SomeClass}
4031 */
4032 constructor () {
4033
4034 }
4035}
4036
4037/**
4038 *
4039 */
4040function quux () {
4041
4042}
4043
4044/**
4045 *
4046 */
4047function quux () {
4048
4049}
4050// Settings: {"jsdoc":{"tagNamePreference":{"implements":false}}}
4051
4052/**
4053 * @function
4054 * @implements {SomeClass}
4055 */
4056
4057/**
4058 * @callback
4059 * @implements {SomeClass}
4060 */
4061````
4062
4063
4064<a name="eslint-plugin-jsdoc-rules-match-description"></a>
4065### <code>match-description</code>
4066
4067Enforces a regular expression pattern on descriptions.
4068
4069The default is this basic expression to match English sentences (Support
4070for Unicode upper case may be added in a future version when it can be handled
4071by our supported Node versions):
4072
4073``^([A-Z]|[`\\d_])[\\s\\S]*[.?!`]$``
4074
4075Applies to the jsdoc block description and `@description` (or `@desc`)
4076by default but the `tags` option (see below) may be used to match other tags.
4077
4078<a name="eslint-plugin-jsdoc-rules-match-description-options-10"></a>
4079#### Options
4080
4081<a name="eslint-plugin-jsdoc-rules-match-description-options-10-matchdescription"></a>
4082##### <code>matchDescription</code>
4083
4084You can supply your own expression to override the default, passing a
4085`matchDescription` string on the options object.
4086
4087```js
4088{
4089 'jsdoc/match-description': ['error', {matchDescription: '[A-Z].*\\.'}]
4090}
4091```
4092
4093As with the default, the supplied regular expression will be applied with the
4094Unicode (`"u"`) flag and is *not* case-insensitive.
4095
4096<a name="eslint-plugin-jsdoc-rules-match-description-options-10-tags-1"></a>
4097##### <code>tags</code>
4098
4099If you want different regular expressions to apply to tags, you may use
4100the `tags` option object:
4101
4102```js
4103{
4104 'jsdoc/match-description': ['error', {tags: {
4105 param: '\\- [A-Z].*\\.',
4106 returns: '[A-Z].*\\.'
4107 }}]
4108}
4109```
4110
4111In place of a string, you can also add `true` to indicate that a particular
4112tag should be linted with the `matchDescription` value (or the default).
4113
4114```js
4115{
4116 'jsdoc/match-description': ['error', {tags: {
4117 param: true,
4118 returns: true
4119 }}]
4120}
4121```
4122
4123The tags `@param`/`@arg`/`@argument` and `@property`/`@prop` will be properly
4124parsed to ensure that the matched "description" text includes only the text
4125after the name.
4126
4127All other tags will treat the text following the tag name, a space, and
4128an optional curly-bracketed type expression (and another space) as part of
4129its "description" (e.g., for `@returns {someType} some description`, the
4130description is `some description` while for `@some-tag xyz`, the description
4131is `xyz`).
4132
4133<a name="eslint-plugin-jsdoc-rules-match-description-options-10-maindescription"></a>
4134##### <code>mainDescription</code>
4135
4136If you wish to override the main function description without changing the
4137default `match-description`, you may use `mainDescription`:
4138
4139```js
4140{
4141 'jsdoc/match-description': ['error', {
4142 mainDescription: '[A-Z].*\\.',
4143 tags: {
4144 param: true,
4145 returns: true
4146 }
4147 }]
4148}
4149```
4150
4151There is no need to add `mainDescription: true`, as by default, the main
4152function (and only the main function) is linted, though you may disable checking
4153it by setting it to `false`.
4154
4155<a name="eslint-plugin-jsdoc-rules-match-description-options-10-contexts-1"></a>
4156##### <code>contexts</code>
4157
4158Set this to an array of strings representing the AST context
4159where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
4160Overrides the default contexts (see below). Set to `"any"` if you want
4161the rule to apply to any jsdoc block throughout your files.
4162
4163|||
4164|---|---|
4165|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
4166|Tags|docblock and `@description` by default but more with `tags`|
4167|Aliases|`@desc`|
4168|Settings||
4169|Options|`contexts`, `tags` (accepts tags with names and optional type such as 'param', 'arg', 'argument', 'property', and 'prop', and accepts arbitrary list of other tags with an optional type (but without names), e.g., 'returns', 'return'), `mainDescription`, `matchDescription`|
4170
4171The following patterns are considered problems:
4172
4173````js
4174/**
4175 * foo.
4176 */
4177const q = class {
4178
4179}
4180// Options: [{"contexts":["ClassExpression"]}]
4181// Message: JSDoc description does not satisfy the regex pattern.
4182
4183/**
4184 * foo.
4185 */
4186// Options: [{"contexts":["any"]}]
4187// Message: JSDoc description does not satisfy the regex pattern.
4188
4189/**
4190 * foo.
4191 */
4192// Options: [{"contexts":["any"]}]
4193// Message: JSDoc description does not satisfy the regex pattern.
4194
4195/**
4196 * foo.
4197 */
4198const q = {
4199
4200};
4201// Options: [{"contexts":["ObjectExpression"]}]
4202// Message: JSDoc description does not satisfy the regex pattern.
4203
4204/**
4205 * foo.
4206 */
4207function quux () {
4208
4209}
4210// Message: JSDoc description does not satisfy the regex pattern.
4211
4212/**
4213 * Foo)
4214 */
4215function quux () {
4216
4217}
4218// Message: JSDoc description does not satisfy the regex pattern.
4219
4220/**
4221 * тест.
4222 */
4223function quux () {
4224
4225}
4226// Options: [{"matchDescription":"[А-Я][А-я]+\\."}]
4227// Message: JSDoc description does not satisfy the regex pattern.
4228
4229/**
4230 * Abc.
4231 */
4232function quux () {
4233
4234}
4235// Options: [{"mainDescription":"[А-Я][А-я]+\\.","tags":{"param":true}}]
4236// Message: JSDoc description does not satisfy the regex pattern.
4237
4238/**
4239 * Foo
4240 */
4241function quux () {
4242
4243}
4244// Message: JSDoc description does not satisfy the regex pattern.
4245
4246/**
4247 * Foo.
4248 *
4249 * @param foo foo.
4250 */
4251function quux (foo) {
4252
4253}
4254// Options: [{"tags":{"param":true}}]
4255// Message: JSDoc description does not satisfy the regex pattern.
4256
4257/**
4258 * Foo.
4259 *
4260 * @prop foo foo.
4261 */
4262function quux (foo) {
4263
4264}
4265// Options: [{"tags":{"prop":true}}]
4266// Message: JSDoc description does not satisfy the regex pattern.
4267
4268/**
4269 * Foo.
4270 *
4271 * @summary foo.
4272 */
4273function quux () {
4274
4275}
4276// Options: [{"tags":{"summary":true}}]
4277// Message: JSDoc description does not satisfy the regex pattern.
4278
4279/**
4280 * Foo.
4281 *
4282 * @author
4283 */
4284function quux () {
4285
4286}
4287// Options: [{"tags":{"author":".+"}}]
4288// Message: JSDoc description does not satisfy the regex pattern.
4289
4290/**
4291 * Foo.
4292 *
4293 * @x-tag
4294 */
4295function quux () {
4296
4297}
4298// Options: [{"tags":{"x-tag":".+"}}]
4299// Message: JSDoc description does not satisfy the regex pattern.
4300
4301/**
4302 * Foo.
4303 *
4304 * @description foo foo.
4305 */
4306function quux (foo) {
4307
4308}
4309// Options: [{"tags":{"description":true}}]
4310// Message: JSDoc description does not satisfy the regex pattern.
4311
4312/**
4313 * Foo
4314 *
4315 * @param foo foo.
4316 */
4317function quux (foo) {
4318
4319}
4320// Options: [{"mainDescription":"^[a-zA-Z]*$","tags":{"param":true}}]
4321// Message: JSDoc description does not satisfy the regex pattern.
4322
4323/**
4324 * Foo
4325 *
4326 * @param foo foo.
4327 */
4328function quux (foo) {
4329
4330}
4331// Options: [{"mainDescription":false,"tags":{"param":true}}]
4332// Message: JSDoc description does not satisfy the regex pattern.
4333
4334/**
4335 * Foo.
4336 *
4337 * @param foo bar
4338 */
4339function quux (foo) {
4340
4341}
4342// Options: [{"tags":{"param":true}}]
4343// Message: JSDoc description does not satisfy the regex pattern.
4344
4345/**
4346 * {@see Foo.bar} buz
4347 */
4348function quux (foo) {
4349
4350}
4351// Message: JSDoc description does not satisfy the regex pattern.
4352
4353/**
4354 * Foo.
4355 *
4356 * @returns {number} foo
4357 */
4358function quux (foo) {
4359
4360}
4361// Options: [{"tags":{"returns":true}}]
4362// Message: JSDoc description does not satisfy the regex pattern.
4363
4364/**
4365 * Foo.
4366 *
4367 * @returns foo.
4368 */
4369function quux (foo) {
4370
4371}
4372// Options: [{"tags":{"returns":true}}]
4373// Message: JSDoc description does not satisfy the regex pattern.
4374
4375/**
4376 * lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque elit diam,
4377 * iaculis eu dignissim sed, ultrices sed nisi. nulla at ligula auctor, consectetur neque sed,
4378 * tincidunt nibh. vivamus sit amet vulputate ligula. vivamus interdum elementum nisl,
4379 * vitae rutrum tortor semper ut. morbi porta ante vitae dictum fermentum.
4380 * proin ut nulla at quam convallis gravida in id elit. sed dolor mauris, blandit quis ante at,
4381 * consequat auctor magna. duis pharetra purus in porttitor mollis.
4382 */
4383function longDescription (foo) {
4384
4385}
4386// Message: JSDoc description does not satisfy the regex pattern.
4387
4388/**
4389 * @arg {number} foo - Foo
4390 */
4391function quux (foo) {
4392
4393}
4394// Options: [{"tags":{"arg":true}}]
4395// Message: JSDoc description does not satisfy the regex pattern.
4396
4397/**
4398 * @argument {number} foo - Foo
4399 */
4400function quux (foo) {
4401
4402}
4403// Options: [{"tags":{"argument":true}}]
4404// Message: JSDoc description does not satisfy the regex pattern.
4405
4406/**
4407 * @return {number} foo
4408 */
4409function quux (foo) {
4410
4411}
4412// Options: [{"tags":{"return":true}}]
4413// Message: JSDoc description does not satisfy the regex pattern.
4414
4415/**
4416 * Returns bar.
4417 *
4418 * @return {number} bar
4419 */
4420function quux (foo) {
4421
4422}
4423// Options: [{"tags":{"return":true}}]
4424// Message: JSDoc description does not satisfy the regex pattern.
4425
4426/**
4427 * @param notRet
4428 * @returns Тест.
4429 */
4430function quux () {
4431
4432}
4433// Options: [{"tags":{"param":"[А-Я][А-я]+\\."}}]
4434// Message: JSDoc description does not satisfy the regex pattern.
4435
4436/**
4437 * @description notRet
4438 * @returns Тест.
4439 */
4440function quux () {
4441
4442}
4443// Options: [{"tags":{"description":"[А-Я][А-я]+\\."}}]
4444// Message: JSDoc description does not satisfy the regex pattern.
4445
4446/**
4447 * foo.
4448 */
4449class quux {
4450
4451}
4452// Options: [{"contexts":["ClassDeclaration"]}]
4453// Message: JSDoc description does not satisfy the regex pattern.
4454
4455class MyClass {
4456 /**
4457 * Abc
4458 */
4459 myClassField = 1
4460}
4461// Options: [{"contexts":["ClassProperty"]}]
4462// Message: JSDoc description does not satisfy the regex pattern.
4463
4464/**
4465 * foo.
4466 */
4467interface quux {
4468
4469}
4470// Options: [{"contexts":["TSInterfaceDeclaration"]}]
4471// Message: JSDoc description does not satisfy the regex pattern.
4472
4473const myObject = {
4474 /**
4475 * Bad description
4476 */
4477 myProp: true
4478};
4479// Options: [{"contexts":["Property"]}]
4480// Message: JSDoc description does not satisfy the regex pattern.
4481
4482/**
4483 * @param foo Foo bar
4484 */
4485function quux (foo) {
4486
4487}
4488// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
4489// Options: [{"tags":{"param":true}}]
4490// Message: JSDoc description does not satisfy the regex pattern.
4491
4492/**
4493 * Foo bar
4494 */
4495function quux (foo) {
4496
4497}
4498// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
4499// Message: JSDoc description does not satisfy the regex pattern.
4500````
4501
4502The following patterns are not considered problems:
4503
4504````js
4505/**
4506 *
4507 */
4508
4509/**
4510 *
4511 */
4512 function quux () {
4513
4514 }
4515
4516/**
4517 * @param foo - Foo.
4518 */
4519function quux () {
4520
4521}
4522// Options: [{"tags":{"param":true}}]
4523
4524/**
4525 * Foo.
4526 */
4527function quux () {
4528
4529}
4530
4531/**
4532 * Foo.
4533 * Bar.
4534 */
4535function quux () {
4536
4537}
4538
4539/**
4540 * Foo.
4541 *
4542 * Bar.
4543 */
4544function quux () {
4545
4546}
4547
4548/**
4549 * Тест.
4550 */
4551function quux () {
4552
4553}
4554// Options: [{"matchDescription":"[А-Я][А-я]+\\."}]
4555
4556/**
4557 * @param notRet
4558 * @returns Тест.
4559 */
4560function quux () {
4561
4562}
4563// Options: [{"tags":{"returns":"[А-Я][А-я]+\\."}}]
4564
4565/**
4566 * @param notRet
4567 * @description Тест.
4568 */
4569function quux () {
4570
4571}
4572// Options: [{"tags":{"description":"[А-Я][А-я]+\\."}}]
4573
4574/**
4575 * Foo
4576 * bar.
4577 */
4578function quux () {
4579
4580}
4581
4582/**
4583 * @returns Foo bar.
4584 */
4585function quux () {
4586
4587}
4588// Options: [{"tags":{"returns":true}}]
4589
4590/**
4591 * @returns {type1} Foo bar.
4592 */
4593function quux () {
4594
4595}
4596// Options: [{"tags":{"returns":true}}]
4597
4598/**
4599 * @description Foo bar.
4600 */
4601function quux () {
4602
4603}
4604// Options: [{"tags":{"description":true}}]
4605
4606/**
4607 * Foo. {@see Math.sin}.
4608 */
4609function quux () {
4610
4611}
4612
4613/**
4614 * Foo {@see Math.sin} bar.
4615 */
4616function quux () {
4617
4618}
4619
4620/**
4621 * Foo?
4622 *
4623 * Bar!
4624 *
4625 * Baz:
4626 * 1. Foo.
4627 * 2. Bar.
4628 */
4629function quux () {
4630
4631}
4632
4633/**
4634 * Hello:
4635 * World.
4636 */
4637function quux () {
4638
4639}
4640
4641/**
4642 * Hello: world.
4643 */
4644function quux () {
4645
4646}
4647
4648/**
4649 * Foo
4650 * Bar.
4651 */
4652function quux () {
4653
4654}
4655
4656/**
4657 * Foo.
4658 *
4659 * foo.
4660 */
4661function quux () {
4662
4663}
4664
4665/**
4666 * foo.
4667 */
4668function quux () {
4669
4670}
4671// Options: [{"mainDescription":false}]
4672
4673/**
4674 * foo.
4675 */
4676class quux {
4677
4678}
4679
4680/**
4681 * foo.
4682 */
4683class quux {
4684
4685}
4686// Options: [{"mainDescription":true}]
4687
4688class MyClass {
4689 /**
4690 * Abc.
4691 */
4692 myClassField = 1
4693}
4694// Options: [{"contexts":["ClassProperty"]}]
4695
4696/**
4697 * Foo.
4698 */
4699interface quux {
4700
4701}
4702// Options: [{"contexts":["TSInterfaceDeclaration"]}]
4703
4704const myObject = {
4705 /**
4706 * Bad description
4707 */
4708 myProp: true
4709};
4710// Options: [{"contexts":[]}]
4711
4712/**
4713 * foo.
4714 */
4715const q = class {
4716
4717}
4718// Options: [{"contexts":[]}]
4719
4720/**
4721 * foo.
4722 */
4723const q = {
4724
4725};
4726// Options: [{"contexts":[]}]
4727
4728/**
4729 * @description foo.
4730 */
4731function quux () {
4732
4733}
4734// Options: [{"tags":{"param":true}}]
4735
4736/**
4737 * Foo.
4738 *
4739 * @summary Foo.
4740 */
4741function quux () {
4742
4743}
4744// Options: [{"tags":{"summary":true}}]
4745
4746/**
4747 * Foo.
4748 *
4749 * @author Somebody
4750 */
4751function quux () {
4752
4753}
4754// Options: [{"tags":{"author":".+"}}]
4755
4756/**
4757 * Foo.
4758 *
4759 * @x-tag something
4760 */
4761function quux () {
4762
4763}
4764// Options: [{"tags":{"x-tag":".+"}}]
4765
4766/**
4767 * Foo.
4768 *
4769 * @prop foo Foo.
4770 */
4771function quux (foo) {
4772
4773}
4774// Options: [{"tags":{"prop":true}}]
4775
4776/**
4777 * @param foo Foo bar.
4778 */
4779function quux (foo) {
4780
4781}
4782// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
4783
4784/**
4785 *
4786 */
4787function quux () {
4788
4789}
4790// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
4791````
4792
4793
4794<a name="eslint-plugin-jsdoc-rules-newline-after-description"></a>
4795### <code>newline-after-description</code>
4796
4797Enforces a consistent padding of the block description.
4798
4799<a name="eslint-plugin-jsdoc-rules-newline-after-description-options-11"></a>
4800#### Options
4801
4802This rule allows one optional string argument. If it is `"always"` then a problem is raised when there is no newline after the description. If it is `"never"` then a problem is raised when there is a newline after the description. The default value is `"always"`.
4803
4804|||
4805|---|---|
4806|Context|everywhere|
4807|Options|(a string matching `"always"|"never"`)|
4808|Tags|N/A (doc block)|
4809
4810The following patterns are considered problems:
4811
4812````js
4813/**
4814 * Foo.
4815 *
4816 * Foo.
4817 * @foo
4818 */
4819function quux () {
4820
4821}
4822// Options: ["always"]
4823// Message: There must be a newline after the description of the JSDoc block.
4824
4825/**
4826 * Foo.
4827 * @foo
4828 *
4829 * Foo.
4830 */
4831function quux () {
4832
4833}
4834// Options: ["always"]
4835// Message: There must be a newline after the description of the JSDoc block.
4836
4837/**
4838 * Foo.
4839 *
4840 * Foo.
4841 * @foo
4842 */
4843function quux () {
4844
4845}
4846// Message: There must be a newline after the description of the JSDoc block.
4847
4848/**
4849 * Bar.
4850 *
4851 * Bar.
4852 *
4853 * @bar
4854 */
4855function quux () {
4856
4857}
4858// Options: ["never"]
4859// Message: There must be no newline after the description of the JSDoc block.
4860
4861/**
4862 * Bar.
4863 *
4864 * @bar
4865 *
4866 * Bar.
4867 */
4868function quux () {
4869
4870}
4871// Options: ["never"]
4872// Message: There must be no newline after the description of the JSDoc block.
4873
4874
4875 /**
4876 * Bar.
4877 *
4878 * Bar.
4879 *
4880 * @bar
4881 */
4882 function quux () {
4883
4884 }
4885// Options: ["never"]
4886// Message: There must be no newline after the description of the JSDoc block.
4887
4888/**
4889 * A.
4890 *
4891 * @typedef {object} A
4892 * @prop {boolean} a A.
4893 */
4894// Options: ["never"]
4895// Message: There must be no newline after the description of the JSDoc block.
4896
4897/**
4898 * A.
4899 * @typedef {object} A
4900 * @prop {boolean} a A.
4901 */
4902// Options: ["always"]
4903// Message: There must be a newline after the description of the JSDoc block.
4904
4905
4906 /**
4907 * Service for fetching symbols.
4908 * @param {object} $http - Injected http helper.
4909 * @param {object} $q - Injected Promise api helper.
4910 * @param {object} $location - Injected window location object.
4911 * @param {object} REPORT_DIALOG_CONSTANTS - Injected handle.
4912 */
4913// Message: There must be a newline after the description of the JSDoc block.
4914````
4915
4916The following patterns are not considered problems:
4917
4918````js
4919/**
4920 * Foo.
4921 */
4922function quux () {
4923
4924}
4925// Options: ["always"]
4926
4927/**
4928 * Bar.
4929 */
4930function quux () {
4931
4932}
4933// Options: ["never"]
4934
4935/**
4936 * Foo.
4937 *
4938 * @foo
4939 */
4940function quux () {
4941
4942}
4943// Options: ["always"]
4944
4945/**
4946 * Bar.
4947 * @bar
4948 */
4949function quux () {
4950
4951}
4952// Options: ["never"]
4953
4954
4955 /**
4956 * @foo
4957 * Test 
4958 * abc 
4959 * @bar 
4960 */
4961
4962
4963 /**
4964 *
4965 * @foo
4966 * Test 
4967 * abc 
4968 * @bar 
4969 */
4970
4971/***
4972 *
4973 */
4974function quux () {
4975
4976}
4977// Options: ["always"]
4978
4979/**
4980 * Parses query string to object containing URL parameters
4981 *
4982 * @param queryString
4983 * Input string
4984 *
4985 * @returns
4986 * Object containing URL parameters
4987 */
4988export function parseQueryString(queryString: string): { [key: string]: string } { // <-- Line 10 that fails
4989
4990}
4991````
4992
4993
4994<a name="eslint-plugin-jsdoc-rules-no-types"></a>
4995### <code>no-types</code>
4996
4997This rule reports types being used on `@param` or `@returns`.
4998
4999The rule is intended to prevent the indication of types on tags where
5000the type information would be redundant with TypeScript.
5001
5002<a name="eslint-plugin-jsdoc-rules-no-types-options-12"></a>
5003#### Options
5004
5005<a name="eslint-plugin-jsdoc-rules-no-types-options-12-contexts-2"></a>
5006##### <code>contexts</code>
5007
5008Set this to an array of strings representing the AST context
5009where you wish the rule to be applied.
5010Overrides the default contexts (see below). Set to `"any"` if you want
5011the rule to apply to any jsdoc block throughout your files (as is necessary
5012for finding function blocks not attached to a function declaration or
5013expression, i.e., `@callback` or `@function` (or its aliases `@func` or
5014`@method`) (including those associated with an `@interface`).
5015
5016|||
5017|---|---|
5018|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
5019|Tags|`param`, `returns`|
5020|Aliases|`arg`, `argument`, `return`|
5021
5022The following patterns are considered problems:
5023
5024````js
5025/**
5026 * @param {number} foo
5027 */
5028function quux (foo) {
5029
5030}
5031// Message: Types are not permitted on @param.
5032
5033/**
5034 * @param {number} foo
5035 */
5036function quux (foo) {
5037
5038}
5039// Options: [{"contexts":["any"]}]
5040// Message: Types are not permitted on @param.
5041
5042/**
5043 * @function
5044 * @param {number} foo
5045 */
5046// Options: [{"contexts":["any"]}]
5047// Message: Types are not permitted on @param.
5048
5049/**
5050 * @callback
5051 * @param {number} foo
5052 */
5053// Options: [{"contexts":["any"]}]
5054// Message: Types are not permitted on @param.
5055
5056/**
5057 * @returns {number}
5058 */
5059function quux () {
5060
5061}
5062// Message: Types are not permitted on @returns.
5063````
5064
5065The following patterns are not considered problems:
5066
5067````js
5068/**
5069 * @param foo
5070 */
5071function quux (foo) {
5072
5073}
5074
5075/**
5076 * @param foo
5077 */
5078// Options: [{"contexts":["any"]}]
5079
5080/**
5081 * @function
5082 * @param {number} foo
5083 */
5084
5085/**
5086 * @callback
5087 * @param {number} foo
5088 */
5089````
5090
5091
5092<a name="eslint-plugin-jsdoc-rules-no-undefined-types"></a>
5093### <code>no-undefined-types</code>
5094
5095Checks that types in jsdoc comments are defined. This can be used to check
5096unimported types.
5097
5098When enabling this rule, types in jsdoc comments will resolve as used
5099variables, i.e. will not be marked as unused by `no-unused-vars`.
5100
5101In addition to considering globals found in code (or in ESLint-indicated
5102`globals`) as defined, the following tags will also be checked for
5103name(path) definitions to also serve as a potential "type" for checking
5104the tag types in the table below:
5105
5106`@callback`, `@class` (or `@constructor`), `@constant` (or `@const`), `@event`, `@external` (or `@host`), `@function` (or `@func` or `@method`), `@interface`, `@member` (or `@var`), `@mixin`, `@name`, `@namespace`, `@template` (for "closure" or "typescript" `settings.jsdoc.mode` only), `@typedef`.
5107
5108The following tags will also be checked but only when the mode is `closure`:
5109
5110`@package`, `@private`, `@protected`, `@public`, `@static`
5111
5112The following types are always considered defined.
5113
5114- `null`, `undefined`, `void`, `string`, `boolean`, `object`, `function`
5115- `number`, `NaN`, `Infinity`
5116- `any`, `*`
5117- `Array`, `Object`, `RegExp`, `Date`, `Function`
5118
5119Note that preferred types indicated within `settings.jsdoc.preferredTypes` will
5120also be assumed to be defined.
5121
5122<a name="eslint-plugin-jsdoc-rules-no-undefined-types-options-13"></a>
5123#### Options
5124
5125An option object may have the following key:
5126
5127- `definedTypes` - This array can be populated to indicate other types which
5128 are automatically considered as defined (in addition to globals, etc.).
5129 Defaults to an empty array.
5130
5131|||
5132|---|---|
5133|Context|everywhere|
5134|Tags|`augments`, `class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
5135|Aliases|`constructor`, `const`, `extends`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
5136|Closure-only|`package`, `private`, `protected`, `public`, `static`|
5137|Options|`definedTypes`|
5138|Settings|`preferredTypes`, `mode`|
5139
5140The following patterns are considered problems:
5141
5142````js
5143/**
5144 * @param {HerType} baz - Foo.
5145 */
5146function quux(foo, bar, baz) {
5147
5148}
5149// Settings: {"jsdoc":{"preferredTypes":{"HerType":1000}}}
5150// Message: Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.
5151
5152/**
5153 * @param {HerType} baz - Foo.
5154 */
5155function quux(foo, bar, baz) {
5156
5157}
5158// Settings: {"jsdoc":{"preferredTypes":{"HerType":false}}}
5159// Message: The type 'HerType' is undefined.
5160
5161/**
5162 * @param {strnig} foo - Bar.
5163 */
5164function quux(foo) {
5165
5166}
5167// Message: The type 'strnig' is undefined.
5168
5169/**
5170 * @param {MyType} foo - Bar.
5171 * @param {HisType} bar - Foo.
5172 */
5173function quux(foo, bar) {
5174
5175}
5176// Options: [{"definedTypes":["MyType"]}]
5177// Message: The type 'HisType' is undefined.
5178
5179/**
5180 * @param {MyType} foo - Bar.
5181 * @param {HisType} bar - Foo.
5182 * @param {HerType} baz - Foo.
5183 */
5184function quux(foo, bar, baz) {
5185
5186}
5187// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"}}}}
5188// Options: [{"definedTypes":["MyType"]}]
5189// Message: The type 'HisType' is undefined.
5190
5191 /**
5192 * @param {MyType} foo - Bar.
5193 * @param {HisType} bar - Foo.
5194 * @param {HerType} baz - Foo.
5195 */
5196function quux(foo, bar, baz) {
5197
5198}
5199// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":false},"histype":"HisType"}}}
5200// Options: [{"definedTypes":["MyType"]}]
5201// Message: The type 'HerType' is undefined.
5202
5203/**
5204 * @template TEMPLATE_TYPE
5205 * @param {WRONG_TEMPLATE_TYPE} bar
5206 */
5207function foo (bar) {
5208};
5209// Settings: {"jsdoc":{"mode":"closure"}}
5210// Message: The type 'WRONG_TEMPLATE_TYPE' is undefined.
5211
5212class Foo {
5213 /**
5214 * @return {TEMPLATE_TYPE}
5215 */
5216 bar () {
5217 }
5218}
5219// Message: The type 'TEMPLATE_TYPE' is undefined.
5220
5221class Foo {
5222 /**
5223 * @return {TEMPLATE_TYPE}
5224 */
5225 invalidTemplateReference () {
5226 }
5227}
5228
5229/**
5230 * @template TEMPLATE_TYPE
5231 */
5232class Bar {
5233 /**
5234 * @return {TEMPLATE_TYPE}
5235 */
5236 validTemplateReference () {
5237 }
5238}
5239// Settings: {"jsdoc":{"mode":"typescript"}}
5240// Message: The type 'TEMPLATE_TYPE' is undefined.
5241
5242/**
5243 * @type {strnig}
5244 */
5245var quux = {
5246
5247};
5248// Message: The type 'strnig' is undefined.
5249
5250/**
5251 * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
5252 */
5253class Foo {
5254 /**
5255 * @param {TEMPLATE_TYPE_A} baz
5256 * @return {TEMPLATE_TYPE_B}
5257 */
5258 bar (baz) {
5259 }
5260}
5261// Message: The type 'TEMPLATE_TYPE_A' is undefined.
5262
5263/**
5264 * @param {...VAR_TYPE} varargs
5265 */
5266function quux (varargs) {
5267}
5268// Message: The type 'VAR_TYPE' is undefined.
5269
5270/**
5271 * @this {Navigator}
5272 */
5273function quux () {}
5274// Settings: {"jsdoc":{"mode":"closure"}}
5275// Message: The type 'Navigator' is undefined.
5276
5277/**
5278 * @export {SomeType}
5279 */
5280function quux () {}
5281// Settings: {"jsdoc":{"mode":"closure"}}
5282// Message: The type 'SomeType' is undefined.
5283````
5284
5285The following patterns are not considered problems:
5286
5287````js
5288/**
5289 * @param {string} foo - Bar.
5290 */
5291function quux(foo) {
5292
5293}
5294
5295/**
5296 * @param {Promise} foo - Bar.
5297 */
5298function quux(foo) {
5299
5300}
5301
5302class MyClass {}
5303
5304/**
5305 * @param {MyClass} foo - Bar.
5306 */
5307function quux(foo) {
5308 console.log(foo);
5309}
5310
5311quux(0);
5312
5313const MyType = require('my-library').MyType;
5314
5315/**
5316 * @param {MyType} foo - Bar.
5317 */
5318 function quux(foo) {
5319
5320}
5321
5322const MyType = require('my-library').MyType;
5323
5324/**
5325 * @param {MyType} foo - Bar.
5326 */
5327 function quux(foo) {
5328
5329}
5330
5331import {MyType} from 'my-library';
5332
5333/**
5334 * @param {MyType} foo - Bar.
5335 * @param {object<string, number>} foo
5336 * @param {Array<string>} baz
5337 */
5338 function quux(foo, bar, baz) {
5339
5340}
5341
5342/*globals MyType*/
5343
5344/**
5345 * @param {MyType} foo - Bar.
5346 * @param {HisType} bar - Foo.
5347 */
5348 function quux(foo, bar) {
5349
5350}
5351
5352/**
5353 * @typedef {object} hello
5354 * @property {string} a - a.
5355 */
5356
5357/**
5358 * @param {hello} foo
5359 */
5360function quux(foo) {
5361
5362}
5363
5364/**
5365 * @param {Array<syntaxError} foo
5366 */
5367function quux(foo) {
5368
5369}
5370
5371/**
5372 * Callback test.
5373 *
5374 * @callback addStuffCallback
5375 * @param {String} sum - An test integer.
5376 */
5377/**
5378 * Test Eslint.
5379 *
5380 * @param {addStuffCallback} callback - A callback to run.
5381 */
5382function testFunction(callback) {
5383 callback();
5384}
5385
5386/**
5387 *
5388 *
5389 */
5390function foo () {
5391
5392}
5393
5394/**
5395 *
5396 *
5397 */
5398function foo () {
5399
5400}
5401
5402/**
5403 * @param {MyType} foo - Bar.
5404 * @param {HisType} bar - Foo.
5405 */
5406function quux(foo, bar) {
5407
5408}
5409// Options: [{"definedTypes":["MyType","HisType"]}]
5410
5411/**
5412 * @param {MyType} foo - Bar.
5413 * @param {HisType} bar - Foo.
5414 * @param {HerType} baz - Foo.
5415 */
5416function quux(foo, bar, baz) {
5417
5418}
5419// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"},"histype":"HisType"}}}
5420// Options: [{"definedTypes":["MyType"]}]
5421
5422/**
5423 * @param {MyType} foo - Bar.
5424 * @param {HisType} bar - Foo.
5425 * @param {HerType} baz - Foo.
5426 */
5427function quux(foo, bar, baz) {
5428
5429}
5430// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType<>"},"histype":"HisType.<>"}}}
5431// Options: [{"definedTypes":["MyType"]}]
5432
5433/**
5434 * @template TEMPLATE_TYPE
5435 * @param {TEMPLATE_TYPE} bar
5436 * @return {TEMPLATE_TYPE}
5437 */
5438function foo (bar) {
5439};
5440// Settings: {"jsdoc":{"mode":"closure"}}
5441
5442/**
5443 * @template TEMPLATE_TYPE
5444 */
5445class Foo {
5446 /**
5447 * @return {TEMPLATE_TYPE}
5448 */
5449 bar () {
5450 }
5451}
5452// Settings: {"jsdoc":{"mode":"closure"}}
5453
5454/**
5455 * @template TEMPLATE_TYPE
5456 */
5457class Foo {
5458 /**
5459 * @return {TEMPLATE_TYPE}
5460 */
5461 bar () {}
5462
5463 /**
5464 * @return {TEMPLATE_TYPE}
5465 */
5466 baz () {}
5467}
5468// Settings: {"jsdoc":{"mode":"closure"}}
5469
5470/**
5471 * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
5472 */
5473class Foo {
5474 /**
5475 * @param {TEMPLATE_TYPE_A} baz
5476 * @return {TEMPLATE_TYPE_B}
5477 */
5478 bar (baz) {
5479 }
5480}
5481// Settings: {"jsdoc":{"mode":"closure"}}
5482
5483/****/
5484
5485/**
5486 *
5487 */
5488function quux () {
5489
5490}
5491
5492/**
5493 * Run callback when hooked method is called.
5494 *
5495 * @template {BaseObject} T
5496 * @param {T} obj - object whose method should be hooked.
5497 * @param {string} method - method which should be hooked.
5498 * @param {(sender: T) => void} callback - callback which should
5499 * be called when the hooked method was invoked.
5500 */
5501function registerEvent(obj, method, callback) {
5502
5503}
5504// Settings: {"jsdoc":{"mode":"typescript"}}
5505
5506 /**
5507 * @param {...} varargs
5508 */
5509function quux (varargs) {
5510}
5511
5512/**
5513 * @param {...number} varargs
5514 */
5515function quux (varargs) {
5516}
5517
5518class Navigator {}
5519/**
5520 * @this {Navigator}
5521 */
5522function quux () {}
5523// Settings: {"jsdoc":{"mode":"closure"}}
5524
5525class SomeType {}
5526/**
5527 * @export {SomeType}
5528 */
5529function quux () {}
5530// Settings: {"jsdoc":{"mode":"closure"}}
5531````
5532
5533
5534<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence"></a>
5535### <code>require-description-complete-sentence</code>
5536
5537Requires that block description, explicit `@description`, and `@param`/`@returns`
5538tag descriptions are written in complete sentences, i.e.,
5539
5540* Description must start with an uppercase alphabetical character.
5541* Paragraphs must start with an uppercase alphabetical character.
5542* Sentences must end with a period.
5543* Every line in a paragraph (except the first) which starts with an uppercase
5544 character must be preceded by a line ending with a period.
5545* A colon or semi-colon followed by two line breaks is still part of the
5546 containing paragraph (unlike normal dual line breaks).
5547* Text within inline tags `{...}` are not checked for sentence divisions.
5548* Periods after items within the `abbreviations` option array are not treated
5549 as sentence endings.
5550
5551<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-14"></a>
5552#### Options
5553
5554<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-14-tags-2"></a>
5555##### <code>tags</code>
5556
5557If you want additional tags to be checked for their descriptions, you may
5558add them within this option.
5559
5560```js
5561{
5562 'jsdoc/require-description-complete-sentence': ['error', {tags: ['see', 'copyright']}]
5563}
5564```
5565
5566The tags `@param`/`@arg`/`@argument` and `@property`/`@prop` will be properly
5567parsed to ensure that the checked "description" text includes only the text
5568after the name.
5569
5570All other tags will treat the text following the tag name, a space, and
5571an optional curly-bracketed type expression (and another space) as part of
5572its "description" (e.g., for `@returns {someType} some description`, the
5573description is `some description` while for `@some-tag xyz`, the description
5574is `xyz`).
5575
5576<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-14-abbreviations"></a>
5577##### <code>abbreviations</code>
5578
5579You can provide an `abbreviations` options array to avoid such strings of text
5580being treated as sentence endings when followed by dots. The `.` is not
5581necessary at the end of the array items.
5582
5583|||
5584|---|---|
5585|Context|everywhere|
5586|Tags|doc block, `param`, `returns`, `description`, `property`, `summary`, `file`, `classdesc`, `todo`, `deprecated`, `throws`, 'yields' and others added by `tags`|
5587|Aliases|`arg`, `argument`, `return`, `desc`, `prop`, `fileoverview`, `overview`, `exception`, `yield`|
5588|Options|`tags`, `abbreviations`|
5589The following patterns are considered problems:
5590
5591````js
5592/**
5593 * foo.
5594 */
5595function quux () {
5596
5597}
5598// Message: Sentence should start with an uppercase character.
5599
5600/**
5601 * foo?
5602 */
5603function quux () {
5604
5605}
5606// Message: Sentence should start with an uppercase character.
5607
5608/**
5609 * @description foo.
5610 */
5611function quux () {
5612
5613}
5614// Message: Sentence should start with an uppercase character.
5615
5616/**
5617 * Foo)
5618 */
5619function quux () {
5620
5621}
5622// Message: Sentence must end with a period.
5623
5624/**
5625 * `foo` is a variable
5626 */
5627function quux () {
5628
5629}
5630// Message: Sentence must end with a period.
5631
5632/**
5633 * Foo.
5634 *
5635 * foo.
5636 */
5637function quux () {
5638
5639}
5640// Message: Sentence should start with an uppercase character.
5641
5642/**
5643 * тест.
5644 */
5645function quux () {
5646
5647}
5648// Message: Sentence should start with an uppercase character.
5649
5650/**
5651 * Foo
5652 */
5653function quux () {
5654
5655}
5656// Message: Sentence must end with a period.
5657
5658/**
5659 * Foo
5660 * Bar.
5661 */
5662function quux () {
5663
5664}
5665// Message: A line of text is started with an uppercase character, but preceding line does not end the sentence.
5666
5667/**
5668 * Foo.
5669 *
5670 * @param foo foo.
5671 */
5672function quux (foo) {
5673
5674}
5675// Message: Sentence should start with an uppercase character.
5676
5677/**
5678 * Foo.
5679 *
5680 * @param foo bar
5681 */
5682function quux (foo) {
5683
5684}
5685// Message: Sentence should start with an uppercase character.
5686
5687/**
5688 * {@see Foo.bar} buz
5689 */
5690function quux (foo) {
5691
5692}
5693// Message: Sentence should start with an uppercase character.
5694
5695/**
5696 * Foo.
5697 *
5698 * @returns {number} foo
5699 */
5700function quux (foo) {
5701
5702}
5703// Message: Sentence should start with an uppercase character.
5704
5705/**
5706 * Foo.
5707 *
5708 * @returns foo.
5709 */
5710function quux (foo) {
5711
5712}
5713// Message: Sentence should start with an uppercase character.
5714
5715/**
5716 * lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque elit diam,
5717 * iaculis eu dignissim sed, ultrices sed nisi. nulla at ligula auctor, consectetur neque sed,
5718 * tincidunt nibh. vivamus sit amet vulputate ligula. vivamus interdum elementum nisl,
5719 * vitae rutrum tortor semper ut. morbi porta ante vitae dictum fermentum.
5720 * proin ut nulla at quam convallis gravida in id elit. sed dolor mauris, blandit quis ante at,
5721 * consequat auctor magna. duis pharetra purus in porttitor mollis.
5722 */
5723function longDescription (foo) {
5724
5725}
5726// Message: Sentence should start with an uppercase character.
5727
5728/**
5729 * @arg {number} foo - Foo
5730 */
5731function quux (foo) {
5732
5733}
5734// Message: Sentence must end with a period.
5735
5736/**
5737 * @argument {number} foo - Foo
5738 */
5739function quux (foo) {
5740
5741}
5742// Message: Sentence must end with a period.
5743
5744/**
5745 * @return {number} foo
5746 */
5747function quux (foo) {
5748
5749}
5750// Message: Sentence should start with an uppercase character.
5751
5752/**
5753 * Returns bar.
5754 *
5755 * @return {number} bar
5756 */
5757function quux (foo) {
5758
5759}
5760// Message: Sentence should start with an uppercase character.
5761
5762/**
5763 * @throws {object} Hello World
5764 * hello world
5765*/
5766// Message: Sentence must end with a period.
5767
5768/**
5769 * @summary Foo
5770 */
5771function quux () {
5772
5773}
5774// Message: Sentence must end with a period.
5775
5776/**
5777 * @throws {SomeType} Foo
5778 */
5779function quux () {
5780
5781}
5782// Message: Sentence must end with a period.
5783
5784/**
5785 * @see Foo
5786 */
5787function quux () {
5788
5789}
5790// Options: [{"tags":["see"]}]
5791// Message: Sentence must end with a period.
5792
5793/**
5794 * @param foo Foo bar
5795 */
5796function quux (foo) {
5797
5798}
5799// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5800// Options: [{"tags":["param"]}]
5801// Message: Sentence must end with a period.
5802
5803/**
5804 * Sorry, but this isn't a complete sentence, Mr.
5805 */
5806function quux () {
5807
5808}
5809// Options: [{"abbreviations":["Mr"]}]
5810// Message: Sentence must end with a period.
5811
5812/**
5813 * Sorry, but this isn't a complete sentence Mr.
5814 */
5815function quux () {
5816
5817}
5818// Options: [{"abbreviations":["Mr."]}]
5819// Message: Sentence must end with a period.
5820
5821/**
5822 * Sorry, but this isn't a complete sentence Mr.
5823 */
5824function quux () {
5825
5826}
5827// Options: [{"abbreviations":["Mr"]}]
5828// Message: Sentence must end with a period.
5829
5830/**
5831 * Sorry, but this isn't a complete sentence Mr. and Mrs.
5832 */
5833function quux () {
5834
5835}
5836// Options: [{"abbreviations":["Mr","Mrs"]}]
5837// Message: Sentence must end with a period.
5838
5839/**
5840 * This is a complete sentence. But this isn't, Mr.
5841 */
5842function quux () {
5843
5844}
5845// Options: [{"abbreviations":["Mr"]}]
5846// Message: Sentence must end with a period.
5847
5848/**
5849 * This is a complete Mr. sentence. But this isn't, Mr.
5850 */
5851function quux () {
5852
5853}
5854// Options: [{"abbreviations":["Mr"]}]
5855// Message: Sentence must end with a period.
5856
5857/**
5858 * This is a complete Mr. sentence.
5859 */
5860function quux () {
5861
5862}
5863// Message: Sentence should start with an uppercase character.
5864
5865/**
5866 * This is fun, i.e. enjoyable, but not superlatively so, e.g. not
5867 * super, wonderful, etc..
5868 */
5869function quux () {
5870
5871}
5872// Message: Sentence should start with an uppercase character.
5873
5874/**
5875 * Do not have dynamic content; e.g. homepage. Here a simple unique id
5876 * suffices.
5877 */
5878 function quux () {
5879
5880 }
5881// Message: Sentence should start with an uppercase character.
5882````
5883
5884The following patterns are not considered problems:
5885
5886````js
5887/**
5888 * @param foo - Foo.
5889 */
5890function quux () {
5891
5892}
5893
5894/**
5895 * Foo.
5896 */
5897function quux () {
5898
5899}
5900
5901/**
5902 * Foo.
5903 * Bar.
5904 */
5905function quux () {
5906
5907}
5908
5909/**
5910 * Foo.
5911 *
5912 * Bar.
5913 */
5914function quux () {
5915
5916}
5917
5918/**
5919 * Тест.
5920 */
5921function quux () {
5922
5923}
5924
5925/**
5926 * Foo
5927 * bar.
5928 */
5929function quux () {
5930
5931}
5932
5933/**
5934 * @returns Foo bar.
5935 */
5936function quux () {
5937
5938}
5939
5940/**
5941 * Foo. {@see Math.sin}.
5942 */
5943function quux () {
5944
5945}
5946
5947/**
5948 * Foo {@see Math.sin} bar.
5949 */
5950function quux () {
5951
5952}
5953
5954/**
5955 * Foo?
5956 *
5957 * Bar!
5958 *
5959 * Baz:
5960 * 1. Foo.
5961 * 2. Bar.
5962 */
5963function quux () {
5964
5965}
5966
5967/**
5968 * Hello:
5969 * World.
5970 */
5971function quux () {
5972
5973}
5974
5975/**
5976 * Hello: world.
5977 */
5978function quux () {
5979
5980}
5981
5982/**
5983 *
5984 */
5985function quux () {
5986
5987}
5988
5989/**
5990 * @description Foo.
5991 */
5992function quux () {
5993
5994}
5995
5996/**
5997 * `foo` is a variable.
5998 */
5999function quux () {
6000
6001}
6002
6003/**
6004 * Foo.
6005 *
6006 * `foo`.
6007 */
6008function quux () {
6009
6010}
6011
6012/**
6013 * @param foo - `bar`.
6014 */
6015function quux () {
6016
6017}
6018
6019/**
6020 * @returns {number} `foo`.
6021 */
6022function quux () {
6023
6024}
6025
6026/**
6027 * Foo
6028 * `bar`.
6029 */
6030function quux () {
6031
6032}
6033
6034/**
6035 * @example Foo
6036 */
6037function quux () {
6038
6039}
6040
6041/**
6042 * @see Foo
6043 */
6044function quux () {
6045
6046}
6047
6048/**
6049 * Foo.
6050 *
6051 * @param foo Foo.
6052 */
6053function quux (foo) {
6054
6055}
6056
6057/**
6058 * Foo.
6059 *
6060 * @param foo Foo.
6061 */
6062function quux (foo) {
6063
6064}
6065// Options: [{"tags":["param"]}]
6066
6067/**
6068 * @param foo Foo bar.
6069 */
6070function quux (foo) {
6071
6072}
6073// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
6074// Options: [{"tags":["param"]}]
6075
6076/**
6077 *
6078 */
6079function quux (foo) {
6080
6081}
6082// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
6083
6084/**
6085* We stop loading Items when we have loaded:
6086*
6087* 1) The main Item;
6088* 2) All its variants.
6089*/
6090
6091/**
6092 * This method is working on 2 steps.
6093 *
6094 * | Step | Comment |
6095 * |------|-------------|
6096 * | 1 | do it |
6097 * | 2 | do it again |
6098 */
6099
6100/**
6101 * This is something that
6102 * I want to test.
6103 */
6104function quux () {
6105
6106}
6107
6108/**
6109 * When making HTTP requests, the
6110 * URL is super important.
6111 */
6112function quux () {
6113
6114}
6115
6116/**
6117 * Sorry, but this isn't a complete sentence, Mr.
6118 */
6119function quux () {
6120
6121}
6122
6123/**
6124 * Sorry, but this isn't a complete sentence Mr..
6125 */
6126function quux () {
6127
6128}
6129// Options: [{"abbreviations":["Mr."]}]
6130
6131/**
6132 * Sorry, but this isn't a complete sentence Mr.
6133 */
6134function quux () {
6135
6136}
6137
6138/**
6139 * Sorry, but this isn't a complete sentence Mr. and Mrs..
6140 */
6141function quux () {
6142
6143}
6144// Options: [{"abbreviations":["Mr","Mrs"]}]
6145
6146/**
6147 * This is a complete sentence aMr.
6148 */
6149function quux () {
6150
6151}
6152// Options: [{"abbreviations":["Mr"]}]
6153
6154/**
6155 * This is a complete sentence. But this isn't, Mr.
6156 */
6157function quux () {
6158
6159}
6160
6161/**
6162 * This is a complete Mr. Sentence. But this isn't, Mr.
6163 */
6164function quux () {
6165
6166}
6167
6168/**
6169 * This is a complete Mr. sentence.
6170 */
6171function quux () {
6172
6173}
6174// Options: [{"abbreviations":["Mr"]}]
6175
6176/**
6177 * This is fun, i.e. enjoyable, but not superlatively so, e.g. not
6178 * super, wonderful, etc..
6179 */
6180function quux () {
6181
6182}
6183// Options: [{"abbreviations":["etc","e.g.","i.e."]}]
6184
6185
6186**
6187* Do not have dynamic content; e.g. homepage. Here a simple unique id
6188* suffices.
6189*/
6190function quux () {
6191
6192}
6193// Options: [{"abbreviations":["etc","e.g.","i.e."]}]
6194````
6195
6196
6197<a name="eslint-plugin-jsdoc-rules-require-description"></a>
6198### <code>require-description</code>
6199
6200Requires that all functions have a description.
6201
6202* All functions must have an implicit description or have the option
6203 `descriptionStyle` set to `tag`.
6204* Every jsdoc block description (or description tag if `descriptionStyle` is
6205 `"tag"`) must have a non-empty description that explains the purpose of the
6206 method.
6207
6208<a name="eslint-plugin-jsdoc-rules-require-description-options-15"></a>
6209#### Options
6210
6211An options object may have any of the following properties:
6212
6213- `contexts` - Set to an array of strings representing the AST context
6214 where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6
6215 classes). Overrides the default contexts (see below). Set to `"any"` if
6216 you want the rule to apply to any jsdoc block throughout your files.
6217- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the
6218 document block avoids the need for a `@description`. Defaults to an
6219 empty array.
6220- `descriptionStyle` - Whether to accept implicit descriptions (`"body"`) or
6221 `@description` tags (`"tag"`) as satisfying the rule. Set to `"any"` to
6222 accept either style. Defaults to `"body"`.
6223
6224|||
6225|---|---|
6226|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
6227|Tags|`description` or jsdoc block|
6228|Aliases|`desc`|
6229|Options|`contexts`, `exemptedBy`, `descriptionStyle`|
6230|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
6231
6232The following patterns are considered problems:
6233
6234````js
6235/**
6236 *
6237 */
6238function quux () {
6239
6240}
6241// Options: [{"descriptionStyle":"tag"}]
6242// Message: Missing JSDoc @description declaration.
6243
6244/**
6245 *
6246 */
6247function quux () {
6248
6249}
6250// Options: [{"descriptionStyle":"any"}]
6251// Message: Missing JSDoc block description or @description declaration.
6252
6253/**
6254 *
6255 */
6256function quux () {
6257
6258}
6259// Options: [{"descriptionStyle":"body"}]
6260// Message: Missing JSDoc block description.
6261
6262/**
6263 *
6264 */
6265class quux {
6266
6267}
6268// Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
6269// Message: Missing JSDoc @description declaration.
6270
6271/**
6272 *
6273 */
6274// Options: [{"contexts":["any"],"descriptionStyle":"tag"}]
6275// Message: Missing JSDoc @description declaration.
6276
6277/**
6278 *
6279 */
6280class quux {
6281
6282}
6283// Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
6284// Message: Missing JSDoc @description declaration.
6285
6286/**
6287 *
6288 */
6289class quux {
6290
6291}
6292// Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
6293// Message: Missing JSDoc @description declaration.
6294
6295/**
6296 * @description
6297 */
6298function quux () {
6299
6300}
6301// Options: [{"descriptionStyle":"tag"}]
6302// Message: Missing JSDoc @description description.
6303
6304/**
6305 *
6306 */
6307interface quux {
6308
6309}
6310// Options: [{"contexts":["TSInterfaceDeclaration"],"descriptionStyle":"tag"}]
6311// Message: Missing JSDoc @description declaration.
6312
6313/**
6314 *
6315 */
6316var quux = class {
6317
6318};
6319// Options: [{"contexts":["ClassExpression"],"descriptionStyle":"tag"}]
6320// Message: Missing JSDoc @description declaration.
6321
6322/**
6323 *
6324 */
6325var quux = {
6326
6327};
6328// Options: [{"contexts":["ObjectExpression"],"descriptionStyle":"tag"}]
6329// Message: Missing JSDoc @description declaration.
6330
6331/**
6332 * @someDesc
6333 */
6334function quux () {
6335
6336}
6337// Settings: {"jsdoc":{"tagNamePreference":{"description":{"message":"Please avoid `{{tagName}}`; use `{{replacement}}` instead","replacement":"someDesc"}}}}
6338// Options: [{"descriptionStyle":"tag"}]
6339// Message: Missing JSDoc @someDesc description.
6340
6341/**
6342 * @description
6343 */
6344function quux () {
6345
6346}
6347// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
6348// Options: [{"descriptionStyle":"tag"}]
6349// Message: Unexpected tag `@description`
6350
6351/**
6352 * @description
6353 */
6354function quux () {
6355
6356}
6357// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
6358// Options: [{"descriptionStyle":"any"}]
6359// Message: Missing JSDoc block description or @description declaration.
6360
6361/**
6362 *
6363 */
6364function quux () {
6365}
6366// Options: [{"exemptedBy":["notPresent"]}]
6367// Message: Missing JSDoc block description.
6368````
6369
6370The following patterns are not considered problems:
6371
6372````js
6373/**
6374 *
6375 */
6376
6377/**
6378 * @description
6379 * // arbitrary description content
6380 */
6381function quux () {
6382
6383}
6384// Options: [{"descriptionStyle":"tag"}]
6385
6386/**
6387 * @description
6388 * quux(); // does something useful
6389 */
6390function quux () {
6391
6392}
6393// Options: [{"descriptionStyle":"tag"}]
6394
6395/**
6396 * @description <caption>Valid usage</caption>
6397 * quux(); // does something useful
6398 *
6399 * @description <caption>Invalid usage</caption>
6400 * quux('random unwanted arg'); // results in an error
6401 */
6402function quux () {
6403
6404}
6405// Options: [{"descriptionStyle":"tag"}]
6406
6407/**
6408 *
6409 */
6410class quux {
6411
6412}
6413// Options: [{"descriptionStyle":"tag"}]
6414
6415/**
6416 *
6417 */
6418function quux () {
6419
6420}
6421// Options: [{"contexts":["ClassDeclaration"]}]
6422
6423/**
6424 * @type {MyCallback}
6425 */
6426function quux () {
6427
6428}
6429// Options: [{"exemptedBy":["type"]}]
6430
6431/**
6432 *
6433 */
6434interface quux {
6435
6436}
6437// Options: [{"descriptionStyle":"tag"}]
6438
6439/**
6440 *
6441 */
6442var quux = class {
6443
6444};
6445// Options: [{"descriptionStyle":"tag"}]
6446
6447/**
6448 *
6449 */
6450var quux = {
6451
6452};
6453// Options: [{"descriptionStyle":"tag"}]
6454
6455/**
6456 * Has an implicit description
6457 */
6458function quux () {
6459
6460}
6461// Options: [{"descriptionStyle":"body"}]
6462
6463/**
6464 * Has an implicit description
6465 */
6466function quux () {
6467
6468}
6469
6470/**
6471 * Has an implicit description
6472 */
6473function quux () {
6474
6475}
6476// Options: [{"descriptionStyle":"any"}]
6477
6478/**
6479 * @description Has an explicit description
6480 */
6481function quux () {
6482
6483}
6484// Options: [{"descriptionStyle":"any"}]
6485
6486/**
6487 *
6488 */
6489function quux () {
6490
6491}
6492// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
6493````
6494
6495
6496<a name="eslint-plugin-jsdoc-rules-require-example"></a>
6497### <code>require-example</code>
6498
6499Requires that all functions have examples.
6500
6501* All functions must have one or more `@example` tags.
6502* Every example tag must have a non-empty description that explains the method's usage.
6503
6504<a name="eslint-plugin-jsdoc-rules-require-example-options-16"></a>
6505#### Options
6506
6507This rule has an object option.
6508
6509<a name="eslint-plugin-jsdoc-rules-require-example-options-16-exemptedby"></a>
6510##### <code>exemptedBy</code>
6511
6512Array of tags (e.g., `['type']`) whose presence on the document
6513block avoids the need for an `@example`. Defaults to an empty array.
6514
6515<a name="eslint-plugin-jsdoc-rules-require-example-options-16-avoidexampleonconstructors"></a>
6516##### <code>avoidExampleOnConstructors</code>
6517
6518Set to `true` to avoid the need for an example on a constructor (whether
6519indicated as such by a jsdoc tag or by being within an ES6 `class`).
6520Defaults to `false`.
6521
6522<a name="eslint-plugin-jsdoc-rules-require-example-options-16-contexts-3"></a>
6523##### <code>contexts</code>
6524
6525Set this to an array of strings representing the AST context
6526where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
6527Overrides the default contexts (see below). Set to `"any"` if you want
6528the rule to apply to any jsdoc block throughout your files.
6529
6530<a name="eslint-plugin-jsdoc-rules-require-example-fixer"></a>
6531#### Fixer
6532
6533The fixer for `require-example` will add an empty `@example`, but it will still
6534report a missing example description after this is added.
6535
6536|||
6537|---|---|
6538|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
6539|Tags|`example`|
6540|Options|`exemptedBy`, `avoidExampleOnConstructors`, `contexts`|
6541|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
6542
6543The following patterns are considered problems:
6544
6545````js
6546/**
6547 *
6548 */
6549function quux () {
6550
6551}
6552// Message: Missing JSDoc @example declaration.
6553
6554/**
6555 * @example
6556 */
6557function quux () {
6558
6559}
6560// Message: Missing JSDoc @example description.
6561
6562/**
6563 * @constructor
6564 */
6565function f () {
6566
6567}
6568// Settings: {"jsdoc":{"avoidExampleOnConstructors":true}}
6569// Message: `settings.jsdoc.avoidExampleOnConstructors` has been removed, use options in the rule `require-example` instead.
6570
6571/**
6572 * @constructor
6573 */
6574function quux () {
6575
6576}
6577// Message: Missing JSDoc @example declaration.
6578
6579/**
6580 * @constructor
6581 * @example
6582 */
6583function quux () {
6584
6585}
6586// Message: Missing JSDoc @example description.
6587
6588/**
6589 *
6590 */
6591class quux {
6592
6593}
6594// Options: [{"contexts":["ClassDeclaration"]}]
6595// Message: Missing JSDoc @example declaration.
6596
6597/**
6598 *
6599 */
6600// Options: [{"contexts":["any"]}]
6601// Message: Missing JSDoc @example declaration.
6602
6603/**
6604 *
6605 */
6606function quux () {
6607}
6608// Options: [{"exemptedBy":["notPresent"]}]
6609// Message: Missing JSDoc @example declaration.
6610````
6611
6612The following patterns are not considered problems:
6613
6614````js
6615/**
6616 *
6617 */
6618
6619/**
6620 * @example
6621 * // arbitrary example content
6622 */
6623function quux () {
6624
6625}
6626
6627/**
6628 * @example
6629 * quux(); // does something useful
6630 */
6631function quux () {
6632
6633}
6634
6635/**
6636 * @example <caption>Valid usage</caption>
6637 * quux(); // does something useful
6638 *
6639 * @example <caption>Invalid usage</caption>
6640 * quux('random unwanted arg'); // results in an error
6641 */
6642function quux () {
6643
6644}
6645
6646/**
6647 * @constructor
6648 */
6649function quux () {
6650
6651}
6652// Options: [{"avoidExampleOnConstructors":true}]
6653
6654/**
6655 * @constructor
6656 * @example
6657 */
6658function quux () {
6659
6660}
6661// Options: [{"avoidExampleOnConstructors":true}]
6662
6663class Foo {
6664 /**
6665 *
6666 */
6667 constructor () {
6668
6669 }
6670}
6671// Options: [{"avoidExampleOnConstructors":true}]
6672
6673/**
6674 * @inheritdoc
6675 */
6676function quux () {
6677
6678}
6679
6680/**
6681 * @type {MyCallback}
6682 */
6683function quux () {
6684
6685}
6686// Options: [{"exemptedBy":["type"]}]
6687
6688/**
6689 * @example Some example code
6690 */
6691class quux {
6692
6693}
6694// Options: [{"contexts":["ClassDeclaration"]}]
6695
6696/**
6697 *
6698 */
6699function quux () {
6700
6701}
6702// Options: [{"contexts":["ClassDeclaration"]}]
6703````
6704
6705
6706<a name="eslint-plugin-jsdoc-rules-require-file-overview"></a>
6707### <code>require-file-overview</code>
6708
6709Checks that:
6710
67111. All files have a `@file`, `@fileoverview`, or `@overview` tag.
67122. Duplicate file overview tags within a given file will be reported
67133. File overview tags will be reported which are not, as per
6714 [the docs](https://jsdoc.app/tags-file.html), "at the beginning of
6715 the file"–where beginning of the file is interpreted in this rule
6716 as being when the overview tag is not preceded by anything other than
6717 a comment.
6718
6719|||
6720|---|---|
6721|Context|Everywhere|
6722|Tags|`file`|
6723|Aliases|`fileoverview`, `overview`|
6724
6725The following patterns are considered problems:
6726
6727````js
6728
6729// Message: Missing @file
6730
6731/**
6732 *
6733 */
6734// Message: Missing @file
6735
6736/**
6737 *
6738 */
6739function quux () {}
6740// Message: Missing @file
6741
6742/**
6743 *
6744 */
6745function quux () {}
6746// Settings: {"jsdoc":{"tagNamePreference":{"file":"fileoverview"}}}
6747// Message: Missing @fileoverview
6748
6749/**
6750 *
6751 */
6752function quux () {}
6753// Settings: {"jsdoc":{"tagNamePreference":{"file":"overview"}}}
6754// Message: Missing @overview
6755
6756/**
6757 *
6758 */
6759function quux () {}
6760// Settings: {"jsdoc":{"tagNamePreference":{"file":false}}}
6761// Message: `settings.jsdoc.tagNamePreference` cannot block @file for the `require-file-overview` rule
6762
6763/**
6764 *
6765 */
6766function quux () {}
6767// Settings: {"jsdoc":{"tagNamePreference":{"file":{"message":"Don't use file"}}}}
6768// Message: `settings.jsdoc.tagNamePreference` cannot block @file for the `require-file-overview` rule
6769
6770/**
6771 * @param a
6772 */
6773function quux (a) {}
6774// Message: Missing @file
6775
6776/**
6777 * @param a
6778 */
6779function quux (a) {}
6780
6781/**
6782 * @param b
6783 */
6784function bar (b) {}
6785// Message: Missing @file
6786
6787/**
6788 * @file
6789 */
6790
6791 /**
6792 * @file
6793 */
6794// Message: Duplicate @file
6795
6796function quux () {
6797}
6798/**
6799 * @file
6800 */
6801// Message: @file should be at the beginning of the file
6802````
6803
6804The following patterns are not considered problems:
6805
6806````js
6807/**
6808 * @file
6809 */
6810
6811// Ok preceded by comment
6812/**
6813 * @file
6814 */
6815
6816/**
6817 * @fileoverview
6818 */
6819// Settings: {"jsdoc":{"tagNamePreference":{"file":"fileoverview"}}}
6820
6821/**
6822 * @overview
6823 */
6824// Settings: {"jsdoc":{"tagNamePreference":{"file":"overview"}}}
6825
6826/**
6827 * @file Description of file
6828 */
6829
6830/**
6831 * @file Description of file
6832 */
6833function quux () {
6834}
6835
6836/**
6837 *
6838 */
6839````
6840
6841
6842<a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description"></a>
6843### <code>require-hyphen-before-param-description</code>
6844
6845Requires a hyphen before the `@param` description.
6846
6847<a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description-options-17"></a>
6848#### Options
6849
6850This rule takes one optional string argument. If it is `"always"` then a problem is raised when there is no hyphen before the description. If it is `"never"` then a problem is raised when there is a hyphen before the description. The default value is `"always"`.
6851
6852|||
6853|---|---|
6854|Context|everywhere|
6855|Tags|`param`|
6856|Aliases|`arg`, `argument`|
6857|Options|(a string matching `"always"|"never"`)|
6858
6859The following patterns are considered problems:
6860
6861````js
6862/**
6863 * @param foo Foo.
6864 */
6865function quux () {
6866
6867}
6868// Options: ["always"]
6869// Message: There must be a hyphen before @param description.
6870
6871/**
6872 * @param foo Foo.
6873 */
6874function quux () {
6875
6876}
6877// Message: There must be a hyphen before @param description.
6878
6879/**
6880 * @param foo - Foo.
6881 */
6882function quux () {
6883
6884}
6885// Options: ["never"]
6886// Message: There must be no hyphen before @param description.
6887
6888/**
6889 * @param foo - foo
6890 * @param foo foo
6891 */
6892function quux () {
6893
6894}
6895// Options: ["always"]
6896// Message: There must be a hyphen before @param description.
6897
6898/**
6899 * @param foo foo
6900 * bar
6901 * @param bar - bar
6902 */
6903function quux () {
6904
6905}
6906// Options: ["always"]
6907// Message: There must be a hyphen before @param description.
6908
6909/**
6910 * @param foo
6911 */
6912function quux (foo) {
6913
6914}
6915// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
6916// Message: Unexpected tag `@param`
6917````
6918
6919The following patterns are not considered problems:
6920
6921````js
6922/**
6923 * @param foo - Foo.
6924 */
6925function quux () {
6926
6927}
6928// Options: ["always"]
6929
6930/**
6931 * @param foo Foo.
6932 */
6933function quux () {
6934
6935}
6936// Options: ["never"]
6937
6938/**
6939 * @param foo
6940 */
6941function quux () {
6942
6943}
6944````
6945
6946
6947<a name="eslint-plugin-jsdoc-rules-require-jsdoc"></a>
6948### <code>require-jsdoc</code>
6949
6950Checks for presence of jsdoc comments, on class declarations as well as
6951functions.
6952
6953<a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-18"></a>
6954#### Options
6955
6956Accepts one optional options object with the following optional keys.
6957
6958- `publicOnly` - This option will insist that missing jsdoc blocks are
6959 only reported for function bodies / class declarations that are exported
6960 from the module. May be a boolean or object. If set to `true`, the defaults
6961 below will be used. If unset, jsdoc block reporting will not be limited to
6962 exports.
6963
6964 This object supports the following optional boolean keys (`false` unless
6965 otherwise noted):
6966
6967 - `ancestorsOnly` - Only check node ancestors to check if node is exported
6968 - `esm` - ESM exports are checked for JSDoc comments (Defaults to `true`)
6969 - `cjs` - CommonJS exports are checked for JSDoc comments (Defaults to `true`)
6970 - `window` - Window global exports are checked for JSDoc comments
6971
6972- `require` - An object with the following optional boolean keys which all
6973 default to `false` except as noted, indicating the contexts where the rule
6974 will apply:
6975
6976 - `ArrowFunctionExpression`
6977 - `ClassDeclaration`
6978 - `ClassExpression`
6979 - `FunctionDeclaration` (defaults to `true`)
6980 - `FunctionExpression`
6981 - `MethodDefinition`
6982
6983- `contexts` - Set this to an array of strings representing the additional
6984 AST contexts where you wish the rule to be applied (e.g., `Property` for
6985 properties). Defaults to an empty array.
6986
6987- `exemptEmptyFunctions` (default: false) - When `true`, the rule will not report
6988 missing jsdoc blocks above functions/methods with no parameters or return values
6989 (intended where variable names are sufficient for themselves as documentation).
6990
6991|||
6992|---|---|
6993|Context|`ArrowFunctionExpression`, `ClassDeclaration`, `ClassExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
6994|Tags|N/A|
6995|Options|`publicOnly`, `require`, `contexts`, `exemptEmptyFunctions`|
6996
6997The following patterns are considered problems:
6998
6999````js
7000/**
7001 * @func myFunction
7002 */
7003function myFunction() {
7004
7005}
7006// Settings: {"jsdoc":{"maxLines":3,"minLines":2}}
7007// Message: Missing JSDoc comment.
7008
7009/**
7010 * @func myFunction
7011 */
7012
7013
7014function myFunction() {
7015
7016}
7017// Settings: {"jsdoc":{"maxLines":2}}
7018// Message: Missing JSDoc comment.
7019
7020/** @func myFunction */ function myFunction() {
7021
7022}
7023// Settings: {"jsdoc":{"minLines":1}}
7024// Message: Missing JSDoc comment.
7025
7026export var test = function () {
7027
7028};
7029// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7030// Message: Missing JSDoc comment.
7031
7032function test () {
7033
7034}
7035export var test2 = test;
7036// Options: [{"publicOnly":true,"require":{"FunctionDeclaration":true}}]
7037// Message: Missing JSDoc comment.
7038
7039export const test = () => {
7040
7041};
7042// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
7043// Message: Missing JSDoc comment.
7044
7045export let test = class {
7046
7047};
7048// Options: [{"publicOnly":true,"require":{"ClassExpression":true}}]
7049// Message: Missing JSDoc comment.
7050
7051export default function () {}
7052// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
7053// Message: Missing JSDoc comment.
7054
7055export default () => {}
7056// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"ArrowFunctionExpression":true}}]
7057// Message: Missing JSDoc comment.
7058
7059export default (function () {})
7060// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
7061// Message: Missing JSDoc comment.
7062
7063export default class {}
7064// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"ClassDeclaration":true}}]
7065// Message: Missing JSDoc comment.
7066
7067function quux (foo) {
7068
7069}
7070// Message: Missing JSDoc comment.
7071
7072
7073// Settings: {"jsdoc":{"exemptEmptyFunctions":true}}
7074// Message: `settings.jsdoc.exemptEmptyFunctions` has been removed, use options in the rule `require-jsdoc` instead.
7075
7076function quux (foo) {
7077
7078}
7079// Options: [{"exemptEmptyFunctions":true}]
7080// Message: Missing JSDoc comment.
7081
7082function quux (foo) {
7083
7084}
7085// Settings: {"jsdoc":{"minLines":2}}
7086// Options: [{"exemptEmptyFunctions":true}]
7087// Message: Missing JSDoc comment.
7088
7089function myFunction() {}
7090// Message: Missing JSDoc comment.
7091
7092/**
7093 * Description for A.
7094 */
7095class A {
7096 constructor(xs) {
7097 this.a = xs;
7098 }
7099}
7100// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7101// Message: Missing JSDoc comment.
7102
7103class A {
7104 /**
7105 * Description for constructor.
7106 * @param {object[]} xs - xs
7107 */
7108 constructor(xs) {
7109 this.a = xs;
7110 }
7111}
7112// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7113// Message: Missing JSDoc comment.
7114
7115class A extends B {
7116 /**
7117 * Description for constructor.
7118 * @param {object[]} xs - xs
7119 */
7120 constructor(xs) {
7121 this.a = xs;
7122 }
7123}
7124// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7125// Message: Missing JSDoc comment.
7126
7127export class A extends B {
7128 /**
7129 * Description for constructor.
7130 * @param {object[]} xs - xs
7131 */
7132 constructor(xs) {
7133 this.a = xs;
7134 }
7135}
7136// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7137// Message: Missing JSDoc comment.
7138
7139export default class A extends B {
7140 /**
7141 * Description for constructor.
7142 * @param {object[]} xs - xs
7143 */
7144 constructor(xs) {
7145 this.a = xs;
7146 }
7147}
7148// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7149// Message: Missing JSDoc comment.
7150
7151var myFunction = () => {}
7152// Options: [{"require":{"ArrowFunctionExpression":true}}]
7153// Message: Missing JSDoc comment.
7154
7155var myFunction = () => () => {}
7156// Options: [{"require":{"ArrowFunctionExpression":true}}]
7157// Message: Missing JSDoc comment.
7158
7159var foo = function() {}
7160// Options: [{"require":{"FunctionExpression":true}}]
7161// Message: Missing JSDoc comment.
7162
7163const foo = {bar() {}}
7164// Options: [{"require":{"FunctionExpression":true}}]
7165// Message: Missing JSDoc comment.
7166
7167var foo = {bar: function() {}}
7168// Options: [{"require":{"FunctionExpression":true}}]
7169// Message: Missing JSDoc comment.
7170
7171function foo (abc) {}
7172// Options: [{"exemptEmptyFunctions":false}]
7173// Message: Missing JSDoc comment.
7174
7175function foo () {
7176 return true;
7177}
7178// Options: [{"exemptEmptyFunctions":false}]
7179// Message: Missing JSDoc comment.
7180
7181module.exports = function quux () {
7182
7183}
7184// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7185// Message: Missing JSDoc comment.
7186
7187module.exports = function quux () {
7188
7189}
7190// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7191// Message: Missing JSDoc comment.
7192
7193module.exports = {
7194 method: function() {
7195
7196 }
7197}
7198// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7199// Message: Missing JSDoc comment.
7200
7201module.exports = {
7202 test: {
7203 test2: function() {
7204
7205 }
7206 }
7207}
7208// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7209// Message: Missing JSDoc comment.
7210
7211module.exports = {
7212 test: {
7213 test2: function() {
7214
7215 }
7216 }
7217}
7218// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7219// Message: Missing JSDoc comment.
7220
7221const test = module.exports = function () {
7222
7223}
7224// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7225// Message: Missing JSDoc comment.
7226
7227/**
7228*
7229*/
7230const test = module.exports = function () {
7231
7232}
7233
7234test.prototype.method = function() {}
7235// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7236// Message: Missing JSDoc comment.
7237
7238const test = function () {
7239
7240}
7241module.exports = {
7242 test: test
7243}
7244// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7245// Message: Missing JSDoc comment.
7246
7247const test = () => {
7248
7249}
7250module.exports = {
7251 test: test
7252}
7253// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
7254// Message: Missing JSDoc comment.
7255
7256class Test {
7257 method() {
7258
7259 }
7260}
7261module.exports = Test;
7262// Options: [{"publicOnly":true,"require":{"MethodDefinition":true}}]
7263// Message: Missing JSDoc comment.
7264
7265export default function quux () {
7266
7267}
7268// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7269// Message: Missing JSDoc comment.
7270
7271export default function quux () {
7272
7273}
7274// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7275// Message: Missing JSDoc comment.
7276
7277function quux () {
7278
7279}
7280export default quux;
7281// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7282// Message: Missing JSDoc comment.
7283
7284export function test() {
7285
7286}
7287// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7288// Message: Missing JSDoc comment.
7289
7290export function test() {
7291
7292}
7293// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7294// Message: Missing JSDoc comment.
7295
7296var test = function () {
7297
7298}
7299var test2 = 2;
7300export { test, test2 }
7301// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7302// Message: Missing JSDoc comment.
7303
7304var test = function () {
7305
7306}
7307export { test as test2 }
7308// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7309// Message: Missing JSDoc comment.
7310
7311export default class A {
7312
7313}
7314// Options: [{"publicOnly":true,"require":{"ClassDeclaration":true}}]
7315// Message: Missing JSDoc comment.
7316
7317export default class A {
7318
7319}
7320// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true}}]
7321// Message: Missing JSDoc comment.
7322
7323var test = function () {
7324
7325}
7326// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
7327// Message: Missing JSDoc comment.
7328
7329window.test = function () {
7330
7331}
7332// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
7333// Message: Missing JSDoc comment.
7334
7335function test () {
7336
7337}
7338// Options: [{"publicOnly":{"window":true}}]
7339// Message: Missing JSDoc comment.
7340
7341module.exports = function() {
7342
7343}
7344// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionExpression":true}}]
7345// Message: Missing JSDoc comment.
7346
7347export function someMethod() {
7348
7349}
7350// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
7351// Message: Missing JSDoc comment.
7352
7353export function someMethod() {
7354
7355}
7356// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
7357// Message: Missing JSDoc comment.
7358
7359const myObject = {
7360 myProp: true
7361};
7362// Options: [{"contexts":["Property"]}]
7363// Message: Missing JSDoc comment.
7364````
7365
7366The following patterns are not considered problems:
7367
7368````js
7369/**
7370 *
7371 */
7372
7373var array = [1,2,3];
7374array.forEach(function() {});
7375
7376/**
7377 * @class MyClass
7378 **/
7379function MyClass() {}
7380
7381/**
7382 Function doing something
7383 */
7384function myFunction() {}
7385/**
7386 Function doing something
7387 */
7388var myFunction = function() {};
7389/**
7390 Function doing something
7391 */
7392Object.myFunction = function () {};
7393var obj = {
7394 /**
7395 * Function doing something
7396 **/
7397 myFunction: function () {} };
7398
7399/**
7400 @func myFunction
7401 */
7402function myFunction() {}
7403/**
7404 @method myFunction
7405 */
7406function myFunction() {}
7407/**
7408 @function myFunction
7409 */
7410function myFunction() {}
7411
7412/**
7413 @func myFunction
7414 */
7415var myFunction = function () {}
7416/**
7417 @method myFunction
7418 */
7419var myFunction = function () {}
7420/**
7421 @function myFunction
7422 */
7423var myFunction = function () {}
7424
7425/**
7426 @func myFunction
7427 */
7428Object.myFunction = function() {}
7429/**
7430 @method myFunction
7431 */
7432Object.myFunction = function() {}
7433/**
7434 @function myFunction
7435 */
7436Object.myFunction = function() {}
7437(function(){})();
7438
7439var object = {
7440 /**
7441 * @func myFunction - Some function
7442 */
7443 myFunction: function() {} }
7444var object = {
7445 /**
7446 * @method myFunction - Some function
7447 */
7448 myFunction: function() {} }
7449var object = {
7450 /**
7451 * @function myFunction - Some function
7452 */
7453 myFunction: function() {} }
7454
7455var array = [1,2,3];
7456array.filter(function() {});
7457Object.keys(this.options.rules || {}).forEach(function(name) {}.bind(this));
7458var object = { name: 'key'};
7459Object.keys(object).forEach(function() {})
7460
7461/**
7462 * @func myFunction
7463 */
7464
7465function myFunction() {
7466
7467}
7468// Settings: {"jsdoc":{"maxLines":2,"minLines":0}}
7469
7470/**
7471 * @func myFunction
7472 */
7473
7474
7475function myFunction() {
7476
7477}
7478// Settings: {"jsdoc":{"maxLines":3,"minLines":0}}
7479
7480/** @func myFunction */ function myFunction() {
7481
7482}
7483// Settings: {"jsdoc":{"maxLines":0,"minLines":0}}
7484
7485/**
7486 * @func myFunction
7487 */
7488
7489function myFunction() {
7490
7491}
7492// Settings: {"jsdoc":{"maxLines":3,"minLines":2}}
7493
7494function myFunction() {}
7495// Options: [{"require":{"ClassDeclaration":true,"FunctionDeclaration":false,"MethodDefinition":true}}]
7496
7497var myFunction = function() {}
7498// Options: [{"require":{"ClassDeclaration":true,"FunctionDeclaration":false,"MethodDefinition":true}}]
7499
7500/**
7501 * Description for A.
7502 */
7503class A {
7504 /**
7505 * Description for constructor.
7506 * @param {object[]} xs - xs
7507 */
7508 constructor(xs) {
7509 this.a = xs;
7510 }
7511}
7512// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7513
7514/**
7515 * Description for A.
7516 */
7517class App extends Component {
7518 /**
7519 * Description for constructor.
7520 * @param {object[]} xs - xs
7521 */
7522 constructor(xs) {
7523 this.a = xs;
7524 }
7525}
7526// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7527
7528/**
7529 * Description for A.
7530 */
7531export default class App extends Component {
7532 /**
7533 * Description for constructor.
7534 * @param {object[]} xs - xs
7535 */
7536 constructor(xs) {
7537 this.a = xs;
7538 }
7539}
7540// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7541
7542/**
7543 * Description for A.
7544 */
7545export class App extends Component {
7546 /**
7547 * Description for constructor.
7548 * @param {object[]} xs - xs
7549 */
7550 constructor(xs) {
7551 this.a = xs;
7552 }
7553}
7554// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7555
7556class A {
7557 constructor(xs) {
7558 this.a = xs;
7559 }
7560}
7561// Options: [{"require":{"ClassDeclaration":false,"MethodDefinition":false}}]
7562
7563/**
7564* Function doing something
7565*/
7566var myFunction = () => {}
7567// Options: [{"require":{"ArrowFunctionExpression":true}}]
7568
7569/**
7570* Function doing something
7571*/
7572var myFunction = function () {}
7573// Options: [{"require":{"ArrowFunctionExpression":true}}]
7574
7575/**
7576* Function doing something
7577*/
7578var myFunction = () => {}
7579// Options: [{"require":{"ArrowFunctionExpression":false}}]
7580
7581/**
7582 Function doing something
7583*/
7584var myFunction = () => () => {}
7585// Options: [{"require":{"ArrowFunctionExpression":true}}]
7586
7587setTimeout(() => {}, 10);
7588// Options: [{"require":{"ArrowFunctionExpression":true}}]
7589
7590/**
7591JSDoc Block
7592*/
7593var foo = function() {}
7594// Options: [{"require":{"FunctionExpression":true}}]
7595
7596const foo = {/**
7597JSDoc Block
7598*/
7599bar() {}}
7600// Options: [{"require":{"FunctionExpression":true}}]
7601
7602var foo = {/**
7603JSDoc Block
7604*/
7605bar: function() {}}
7606// Options: [{"require":{"FunctionExpression":true}}]
7607
7608var foo = { [function() {}]: 1 };
7609// Options: [{"require":{"FunctionExpression":true}}]
7610
7611function foo () {}
7612// Options: [{"exemptEmptyFunctions":true}]
7613
7614function foo () {
7615 return;
7616}
7617// Options: [{"exemptEmptyFunctions":true}]
7618
7619const test = {};
7620/**
7621 * test
7622 */
7623 test.method = function () {
7624
7625}
7626module.exports = {
7627 prop: { prop2: test.method }
7628}
7629// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7630
7631/**
7632 *
7633 */
7634function test() {
7635
7636}
7637
7638module.exports = {
7639 prop: { prop2: test }
7640}
7641// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7642
7643/**
7644 *
7645 */
7646test = function() {
7647
7648}
7649
7650module.exports = {
7651 prop: { prop2: test }
7652}
7653// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionExpression":true}}]
7654
7655/**
7656 *
7657 */
7658test = function() {
7659
7660}
7661
7662exports.someMethod = {
7663 prop: { prop2: test }
7664}
7665// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
7666
7667/**
7668 *
7669 */
7670const test = () => {
7671
7672}
7673
7674module.exports = {
7675prop: { prop2: test }
7676}
7677// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
7678
7679const test = () => {
7680
7681}
7682module.exports = {
7683 prop: { prop2: test }
7684}
7685// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"ArrowFunctionExpression":true}}]
7686
7687/**
7688 *
7689 */
7690window.test = function() {
7691
7692}
7693
7694module.exports = {
7695prop: window
7696}
7697// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7698
7699test = function() {
7700
7701}
7702
7703/**
7704 *
7705 */
7706test = function() {
7707
7708}
7709
7710module.exports = {
7711prop: { prop2: test }
7712}
7713// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7714
7715test = function() {
7716
7717}
7718
7719test = 2;
7720
7721module.exports = {
7722prop: { prop2: test }
7723}
7724// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7725
7726/**
7727 *
7728 */
7729function test() {
7730
7731}
7732
7733/**
7734 *
7735 */
7736test.prototype.method = function() {
7737
7738}
7739
7740module.exports = {
7741prop: { prop2: test }
7742}
7743// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7744
7745class Test {
7746 /**
7747 * Test
7748 */
7749 method() {
7750
7751 }
7752}
7753module.exports = Test;
7754// Options: [{"publicOnly":true,"require":{"MethodDefinition":true}}]
7755
7756/**
7757 *
7758 */
7759export default function quux () {
7760
7761}
7762// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7763
7764/**
7765 *
7766 */
7767export default function quux () {
7768
7769}
7770// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7771
7772/**
7773 *
7774 */
7775function quux () {
7776
7777}
7778export default quux;
7779// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7780
7781function quux () {
7782
7783}
7784export default quux;
7785// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7786
7787/**
7788 *
7789 */
7790export function test() {
7791
7792}
7793// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7794
7795/**
7796 *
7797 */
7798export function test() {
7799
7800}
7801// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7802
7803/**
7804 *
7805 */
7806var test = function () {
7807
7808}
7809var test2 = 2;
7810export { test, test2 }
7811// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7812
7813/**
7814 *
7815 */
7816var test = function () {
7817
7818}
7819export { test as test2 }
7820// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7821
7822/**
7823 *
7824 */
7825export default class A {
7826
7827}
7828// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true}}]
7829
7830/**
7831 *
7832 */
7833var test = function () {
7834
7835}
7836// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
7837
7838let test = function () {
7839
7840}
7841// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
7842
7843let test = class {
7844
7845}
7846// Options: [{"publicOnly":true,"require":{"ClassExpression":false}}]
7847
7848/**
7849 *
7850 */
7851let test = class {
7852
7853}
7854// Options: [{"publicOnly":true,"require":{"ClassExpression":true}}]
7855
7856export function someMethod() {
7857
7858}
7859// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionDeclaration":true}}]
7860
7861export function someMethod() {
7862
7863}
7864// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionDeclaration":true}}]
7865
7866exports.someMethod = function() {
7867
7868}
7869// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
7870
7871const myObject = {
7872 myProp: true
7873};
7874// Options: [{"contexts":[]}]
7875
7876function bear() {}
7877/**
7878 *
7879 */
7880function quux () {
7881}
7882export default quux;
7883// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7884
7885/**
7886 * This example interface is great!
7887 */
7888export interface Example {
7889 /**
7890 * My super test string!
7891 */
7892 test: string
7893}
7894// Options: [{"contexts":["TSInterfaceDeclaration"]}]
7895
7896/**
7897 * This example interface is great!
7898 */
7899interface Example {
7900 /**
7901 * My super test string!
7902 */
7903 test: string
7904}
7905// Options: [{"contexts":["TSInterfaceDeclaration"]}]
7906
7907/**
7908 * This example type is great!
7909 */
7910export type Example = {
7911 /**
7912 * My super test string!
7913 */
7914 test: string
7915};
7916// Options: [{"contexts":["TSTypeAliasDeclaration"]}]
7917
7918/**
7919 * This example type is great!
7920 */
7921type Example = {
7922 /**
7923 * My super test string!
7924 */
7925 test: string
7926};
7927// Options: [{"contexts":["TSTypeAliasDeclaration"]}]
7928
7929/**
7930 * This example enum is great!
7931 */
7932export enum Example {
7933 /**
7934 * My super test enum!
7935 */
7936 test = 123
7937}
7938// Options: [{"contexts":["TSEnumDeclaration"]}]
7939
7940/**
7941 * This example enum is great!
7942 */
7943enum Example {
7944 /**
7945 * My super test enum!
7946 */
7947 test = 123
7948}
7949// Options: [{"contexts":["TSEnumDeclaration"]}]
7950
7951const foo = {...{}};
7952function bar() {}
7953// Options: [{"exemptEmptyFunctions":false,"publicOnly":true,"require":{"ArrowFunctionExpression":true,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":false,"MethodDefinition":true}}]
7954
7955/**
7956 * Class documentation
7957 */
7958 @logged
7959export default class Foo {
7960 // ....
7961}
7962// Options: [{"exemptEmptyFunctions":false,"require":{"ClassDeclaration":true}}]
7963````
7964
7965
7966<a name="eslint-plugin-jsdoc-rules-require-param-description"></a>
7967### <code>require-param-description</code>
7968
7969Requires that each `@param` tag has a `description` value.
7970
7971<a name="eslint-plugin-jsdoc-rules-require-param-description-options-19"></a>
7972#### Options
7973
7974<a name="eslint-plugin-jsdoc-rules-require-param-description-options-19-contexts-4"></a>
7975##### <code>contexts</code>
7976
7977Set this to an array of strings representing the AST context
7978where you wish the rule to be applied.
7979Overrides the default contexts (see below). Set to `"any"` if you want
7980the rule to apply to any jsdoc block throughout your files (as is necessary
7981for finding function blocks not attached to a function declaration or
7982expression, i.e., `@callback` or `@function` (or its aliases `@func` or
7983`@method`) (including those associated with an `@interface`).
7984
7985|||
7986|---|---|
7987|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
7988|Tags|`param`|
7989|Aliases|`arg`, `argument`|
7990|Options|`contexts`|
7991
7992The following patterns are considered problems:
7993
7994````js
7995/**
7996 * @param foo
7997 */
7998function quux (foo) {
7999
8000}
8001// Message: Missing JSDoc @param "foo" description.
8002
8003/**
8004 * @param foo
8005 */
8006function quux (foo) {
8007
8008}
8009// Options: [{"contexts":["any"]}]
8010// Message: Missing JSDoc @param "foo" description.
8011
8012/**
8013 * @function
8014 * @param foo
8015 */
8016// Options: [{"contexts":["any"]}]
8017// Message: Missing JSDoc @param "foo" description.
8018
8019/**
8020 * @callback
8021 * @param foo
8022 */
8023// Options: [{"contexts":["any"]}]
8024// Message: Missing JSDoc @param "foo" description.
8025
8026/**
8027 * @arg foo
8028 */
8029function quux (foo) {
8030
8031}
8032// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
8033// Message: Missing JSDoc @arg "foo" description.
8034
8035/**
8036 * @param foo
8037 */
8038function quux (foo) {
8039
8040}
8041// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
8042// Message: Unexpected tag `@param`
8043````
8044
8045The following patterns are not considered problems:
8046
8047````js
8048/**
8049 *
8050 */
8051function quux (foo) {
8052
8053}
8054
8055/**
8056 * @param foo Foo.
8057 */
8058function quux (foo) {
8059
8060}
8061
8062/**
8063 * @param foo Foo.
8064 */
8065function quux (foo) {
8066
8067}
8068// Options: [{"contexts":["any"]}]
8069
8070/**
8071 * @function
8072 * @param foo
8073 */
8074
8075/**
8076 * @callback
8077 * @param foo
8078 */
8079````
8080
8081
8082<a name="eslint-plugin-jsdoc-rules-require-param-name"></a>
8083### <code>require-param-name</code>
8084
8085Requires that all function parameters have names.
8086
8087> The `@param` tag requires you to specify the name of the parameter you are documenting. You can also include the parameter's type, enclosed in curly brackets, and a description of the parameter.
8088>
8089> [JSDoc](https://jsdoc.app/tags-param.html#overview)
8090
8091<a name="eslint-plugin-jsdoc-rules-require-param-name-options-20"></a>
8092#### Options
8093
8094<a name="eslint-plugin-jsdoc-rules-require-param-name-options-20-contexts-5"></a>
8095##### <code>contexts</code>
8096
8097Set this to an array of strings representing the AST context
8098where you wish the rule to be applied.
8099Overrides the default contexts (see below). Set to `"any"` if you want
8100the rule to apply to any jsdoc block throughout your files (as is necessary
8101for finding function blocks not attached to a function declaration or
8102expression, i.e., `@callback` or `@function` (or its aliases `@func` or
8103`@method`) (including those associated with an `@interface`).
8104
8105|||
8106|---|---|
8107|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
8108|Tags|`param`|
8109|Aliases|`arg`, `argument`|
8110|Options|`contexts`|
8111
8112The following patterns are considered problems:
8113
8114````js
8115/**
8116 * @param
8117 */
8118function quux (foo) {
8119
8120}
8121// Message: There must be an identifier after @param type.
8122
8123/**
8124 * @param {string}
8125 */
8126function quux (foo) {
8127
8128}
8129// Message: There must be an identifier after @param tag.
8130
8131/**
8132 * @param {string}
8133 */
8134function quux (foo) {
8135
8136}
8137// Options: [{"contexts":["any"]}]
8138// Message: There must be an identifier after @param tag.
8139
8140/**
8141 * @function
8142 * @param {string}
8143 */
8144// Options: [{"contexts":["any"]}]
8145// Message: There must be an identifier after @param tag.
8146
8147/**
8148 * @callback
8149 * @param {string}
8150 */
8151// Options: [{"contexts":["any"]}]
8152// Message: There must be an identifier after @param tag.
8153
8154/**
8155 * @param foo
8156 */
8157function quux (foo) {
8158
8159}
8160// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
8161// Message: Unexpected tag `@param`
8162````
8163
8164The following patterns are not considered problems:
8165
8166````js
8167/**
8168 * @param foo
8169 */
8170function quux (foo) {
8171
8172}
8173
8174/**
8175 * @param foo
8176 */
8177function quux (foo) {
8178
8179}
8180// Options: [{"contexts":["any"]}]
8181
8182/**
8183 * @param {string} foo
8184 */
8185function quux (foo) {
8186
8187}
8188
8189/**
8190 * @function
8191 * @param
8192 */
8193
8194/**
8195 * @callback
8196 * @param
8197 */
8198````
8199
8200
8201<a name="eslint-plugin-jsdoc-rules-require-param-type"></a>
8202### <code>require-param-type</code>
8203
8204Requires that each `@param` tag has a `type` value.
8205
8206<a name="eslint-plugin-jsdoc-rules-require-param-type-options-21"></a>
8207#### Options
8208
8209<a name="eslint-plugin-jsdoc-rules-require-param-type-options-21-contexts-6"></a>
8210##### <code>contexts</code>
8211
8212Set this to an array of strings representing the AST context
8213where you wish the rule to be applied.
8214Overrides the default contexts (see below). Set to `"any"` if you want
8215the rule to apply to any jsdoc block throughout your files (as is necessary
8216for finding function blocks not attached to a function declaration or
8217expression, i.e., `@callback` or `@function` (or its aliases `@func` or
8218`@method`) (including those associated with an `@interface`).
8219
8220|||
8221|---|---|
8222|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
8223|Tags|`param`|
8224|Aliases|`arg`, `argument`|
8225|Options|`contexts`|
8226
8227The following patterns are considered problems:
8228
8229````js
8230/**
8231 * @param foo
8232 */
8233function quux (foo) {
8234
8235}
8236// Message: Missing JSDoc @param "foo" type.
8237
8238/**
8239 * @param foo
8240 */
8241function quux (foo) {
8242
8243}
8244// Options: [{"contexts":["any"]}]
8245// Message: Missing JSDoc @param "foo" type.
8246
8247/**
8248 * @function
8249 * @param foo
8250 */
8251// Options: [{"contexts":["any"]}]
8252// Message: Missing JSDoc @param "foo" type.
8253
8254/**
8255 * @callback
8256 * @param foo
8257 */
8258// Options: [{"contexts":["any"]}]
8259// Message: Missing JSDoc @param "foo" type.
8260
8261/**
8262 * @arg foo
8263 */
8264function quux (foo) {
8265
8266}
8267// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
8268// Message: Missing JSDoc @arg "foo" type.
8269
8270/**
8271 * @param foo
8272 */
8273function quux (foo) {
8274
8275}
8276// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
8277// Message: Unexpected tag `@param`
8278````
8279
8280The following patterns are not considered problems:
8281
8282````js
8283/**
8284 *
8285 */
8286function quux (foo) {
8287
8288}
8289
8290/**
8291 * @param {number} foo
8292 */
8293function quux (foo) {
8294
8295}
8296
8297/**
8298 * @param {number} foo
8299 */
8300function quux (foo) {
8301
8302}
8303// Options: [{"contexts":["any"]}]
8304
8305/**
8306 * @function
8307 * @param foo
8308 */
8309
8310/**
8311 * @callback
8312 * @param foo
8313 */
8314````
8315
8316
8317<a name="eslint-plugin-jsdoc-rules-require-param"></a>
8318### <code>require-param</code>
8319
8320Requires that all function parameters are documented.
8321
8322<a name="eslint-plugin-jsdoc-rules-require-param-options-22"></a>
8323#### Options
8324
8325An options object accepts one optional property:
8326
8327- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
8328 block avoids the need for a `@param`. Defaults to an empty array.
8329
8330|||
8331|---|---|
8332|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
8333|Tags|`param`|
8334|Aliases|`arg`, `argument`|
8335|Options|`exemptedBy`|
8336|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
8337
8338The following patterns are considered problems:
8339
8340````js
8341/**
8342 *
8343 */
8344function quux (foo) {
8345
8346}
8347// Message: Missing JSDoc @param "foo" declaration.
8348
8349/**
8350 *
8351 */
8352function quux (foo, bar) {
8353
8354}
8355// Message: Missing JSDoc @param "foo" declaration.
8356
8357/**
8358 * @param foo
8359 */
8360function quux (foo, bar) {
8361
8362}
8363// Message: Missing JSDoc @param "bar" declaration.
8364
8365/**
8366 * @param bar
8367 */
8368function quux (foo, bar, baz) {
8369
8370}
8371// Message: Missing JSDoc @param "foo" declaration.
8372
8373/**
8374 * @param foo
8375 * @param bar
8376 */
8377function quux (foo, bar, baz) {
8378
8379}
8380// Message: Missing JSDoc @param "baz" declaration.
8381
8382/**
8383 * @param baz
8384 */
8385function quux (foo, bar, baz) {
8386
8387}
8388// Message: Missing JSDoc @param "foo" declaration.
8389
8390/**
8391 * @param
8392 */
8393function quux (foo) {
8394
8395}
8396// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
8397// Message: Missing JSDoc @arg "foo" declaration.
8398
8399/**
8400 * @param foo
8401 */
8402function quux (foo, bar) {
8403
8404}
8405// Message: Missing JSDoc @param "bar" declaration.
8406
8407/**
8408 * @override
8409 */
8410function quux (foo) {
8411
8412}
8413// Settings: {"jsdoc":{"overrideReplacesDocs":false}}
8414// Message: Missing JSDoc @param "foo" declaration.
8415
8416/**
8417 * @implements
8418 */
8419function quux (foo) {
8420
8421}
8422// Settings: {"jsdoc":{"implementsReplacesDocs":false}}
8423// Message: Missing JSDoc @param "foo" declaration.
8424
8425/**
8426 * @augments
8427 */
8428function quux (foo) {
8429
8430}
8431// Message: Missing JSDoc @param "foo" declaration.
8432
8433/**
8434 * @extends
8435 */
8436function quux (foo) {
8437
8438}
8439// Message: Missing JSDoc @param "foo" declaration.
8440
8441/**
8442 * @override
8443 */
8444class A {
8445 /**
8446 *
8447 */
8448 quux (foo) {
8449
8450 }
8451}
8452// Settings: {"jsdoc":{"overrideReplacesDocs":false}}
8453// Message: Missing JSDoc @param "foo" declaration.
8454
8455/**
8456 * @implements
8457 */
8458class A {
8459 /**
8460 *
8461 */
8462 quux (foo) {
8463
8464 }
8465}
8466// Settings: {"jsdoc":{"implementsReplacesDocs":false}}
8467// Message: Missing JSDoc @param "foo" declaration.
8468
8469/**
8470 * @augments
8471 */
8472class A {
8473 /**
8474 *
8475 */
8476 quux (foo) {
8477
8478 }
8479}
8480// Message: Missing JSDoc @param "foo" declaration.
8481
8482/**
8483 * @extends
8484 */
8485class A {
8486 /**
8487 *
8488 */
8489 quux (foo) {
8490
8491 }
8492}
8493// Message: Missing JSDoc @param "foo" declaration.
8494
8495export class SomeClass {
8496 /**
8497 * @param property
8498 */
8499 constructor(private property: string, private foo: number) {}
8500}
8501// Message: Missing JSDoc @param "foo" declaration.
8502
8503/**
8504 * @param
8505 */
8506function quux (foo) {
8507
8508}
8509// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
8510// Message: Unexpected tag `@param`
8511
8512/**
8513 *
8514 */
8515function quux ({bar, baz}, foo) {
8516}
8517// Message: Missing JSDoc @param "foo" declaration.
8518
8519/**
8520 *
8521 */
8522function quux (foo, {bar, baz}) {
8523}
8524// Message: Missing JSDoc @param "foo" declaration.
8525
8526/**
8527 *
8528 */
8529function quux ([bar, baz], foo) {
8530}
8531// Message: Missing JSDoc @param "foo" declaration.
8532
8533/**
8534 *
8535 */
8536function quux (foo) {
8537}
8538// Options: [{"exemptedBy":["notPresent"]}]
8539// Message: Missing JSDoc @param "foo" declaration.
8540````
8541
8542The following patterns are not considered problems:
8543
8544````js
8545/**
8546 * @param foo
8547 */
8548function quux (foo) {
8549
8550}
8551
8552/**
8553 * @inheritdoc
8554 */
8555function quux (foo) {
8556
8557}
8558
8559/**
8560 * @arg foo
8561 */
8562function quux (foo) {
8563
8564}
8565// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
8566
8567/**
8568 * @override
8569 * @param foo
8570 */
8571function quux (foo) {
8572
8573}
8574
8575/**
8576 * @override
8577 */
8578function quux (foo) {
8579
8580}
8581
8582/**
8583 * @override
8584 */
8585class A {
8586 /**
8587 *
8588 */
8589 quux (foo) {
8590
8591 }
8592}
8593
8594/**
8595 * @override
8596 */
8597function quux (foo) {
8598
8599}
8600// Settings: {"jsdoc":{"overrideReplacesDocs":true}}
8601
8602/**
8603 * @implements
8604 */
8605class A {
8606 /**
8607 *
8608 */
8609 quux (foo) {
8610
8611 }
8612}
8613
8614/**
8615 * @implements
8616 */
8617function quux (foo) {
8618
8619}
8620
8621/**
8622 * @implements
8623 */
8624function quux (foo) {
8625
8626}
8627// Settings: {"jsdoc":{"implementsReplacesDocs":true}}
8628
8629/**
8630 * @implements
8631 * @param foo
8632 */
8633function quux (foo) {
8634
8635}
8636
8637/**
8638 * @augments
8639 */
8640function quux (foo) {
8641
8642}
8643// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8644
8645/**
8646 * @augments
8647 * @param foo
8648 */
8649function quux (foo) {
8650
8651}
8652
8653/**
8654 * @extends
8655 */
8656function quux (foo) {
8657
8658}
8659// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8660
8661/**
8662 * @extends
8663 * @param foo
8664 */
8665function quux (foo) {
8666
8667}
8668
8669/**
8670 * @augments
8671 */
8672function quux (foo) {
8673
8674}
8675// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8676
8677/**
8678 * @extends
8679 */
8680function quux (foo) {
8681
8682}
8683// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8684
8685/**
8686 * @override
8687 */
8688class A {
8689 /**
8690 * @param foo
8691 */
8692 quux (foo) {
8693
8694 }
8695}
8696
8697/**
8698 * @override
8699 */
8700class A {
8701 /**
8702 *
8703 */
8704 quux (foo) {
8705
8706 }
8707}
8708// Settings: {"jsdoc":{"overrideReplacesDocs":true}}
8709
8710/**
8711 * @implements
8712 */
8713class A {
8714 /**
8715 *
8716 */
8717 quux (foo) {
8718
8719 }
8720}
8721// Settings: {"jsdoc":{"implementsReplacesDocs":true}}
8722
8723/**
8724 * @implements
8725 */
8726class A {
8727 /**
8728 * @param foo
8729 */
8730 quux (foo) {
8731
8732 }
8733}
8734
8735/**
8736 * @augments
8737 */
8738class A {
8739 /**
8740 *
8741 */
8742 quux (foo) {
8743
8744 }
8745}
8746// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8747
8748/**
8749 * @augments
8750 */
8751class A {
8752 /**
8753 * @param foo
8754 */
8755 quux (foo) {
8756
8757 }
8758}
8759
8760/**
8761 * @extends
8762 */
8763class A {
8764 /**
8765 *
8766 */
8767 quux (foo) {
8768
8769 }
8770}
8771// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8772
8773/**
8774 * @extends
8775 */
8776class A {
8777 /**
8778 * @param foo
8779 */
8780 quux (foo) {
8781
8782 }
8783}
8784
8785/**
8786 * @augments
8787 */
8788class A {
8789 /**
8790 *
8791 */
8792 quux (foo) {
8793
8794 }
8795}
8796// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8797
8798/**
8799 * @extends
8800 */
8801class A {
8802 /**
8803 *
8804 */
8805 quux (foo) {
8806
8807 }
8808}
8809// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8810
8811/**
8812 * @private
8813 */
8814function quux (foo) {
8815
8816}
8817// Settings: {"jsdoc":{"ignorePrivate":true}}
8818
8819/**
8820 * @access private
8821 */
8822function quux (foo) {
8823
8824}
8825// Settings: {"jsdoc":{"ignorePrivate":true}}
8826
8827// issue 182: optional chaining
8828/** @const {boolean} test */
8829const test = something?.find(_ => _)
8830
8831/** @type {RequestHandler} */
8832function foo(req, res, next) {}
8833
8834/**
8835 * @type {MyCallback}
8836 */
8837function quux () {
8838
8839}
8840// Options: [{"exemptedBy":["type"]}]
8841
8842/**
8843 * @override
8844 */
8845var A = class {
8846 /**
8847 *
8848 */
8849 quux (foo) {
8850
8851 }
8852}
8853
8854export class SomeClass {
8855 /**
8856 * @param property
8857 */
8858 constructor(private property: string) {}
8859}
8860
8861/**
8862 * Assign the project to an employee.
8863 *
8864 * @param {object} employee - The employee who is responsible for the project.
8865 * @param {string} employee.name - The name of the employee.
8866 * @param {string} employee.department - The employee's department.
8867 */
8868function assign({name, department}) {
8869 // ...
8870}
8871
8872export abstract class StephanPlugin<O, D> {
8873
8874 /**
8875 * Called right after Stephan loads the plugin file.
8876 *
8877 * @example
8878 *```typescript
8879 * type Options = {
8880 * verbose?: boolean;
8881 * token?: string;
8882 * }
8883 * ```
8884 *
8885 * Note that your Options type should only have optional properties...
8886 *
8887 * @param args Arguments compiled and provided by StephanClient.
8888 * @param args.options The options as provided by the user, or an empty object if not provided.
8889 * @param defaultOptions The default options as provided by the plugin, or an empty object.
8890 */
8891 public constructor({options, client}: {
8892 options: O;
8893 client: unknown;
8894 }, defaultOptions: D) {
8895
8896 }
8897}
8898````
8899
8900
8901<a name="eslint-plugin-jsdoc-rules-require-property"></a>
8902### <code>require-property</code>
8903
8904Requires that all `@typedef` and `@namespace` tags have `@property`
8905when their type is a plain `object`, `Object`, or `PlainObject`.
8906
8907Note that if any other type, including a subtype of object such as
8908`object<string, string>`, will not be reported.
8909
8910<a name="eslint-plugin-jsdoc-rules-require-property-fixer-1"></a>
8911#### Fixer
8912
8913The fixer for `require-example` will add an empty `@property`.
8914
8915|||
8916|---|---|
8917|Context|Everywhere|
8918|Tags|`typedef`, `namespace`|
8919
8920The following patterns are considered problems:
8921
8922````js
8923/**
8924 * @typedef {object} SomeTypedef
8925 */
8926// Message: Missing JSDoc @property.
8927
8928/**
8929 * @typedef {PlainObject} SomeTypedef
8930 */
8931// Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
8932// Message: Missing JSDoc @prop.
8933
8934/**
8935 * @namespace {Object} SomeName
8936 */
8937// Message: Missing JSDoc @property.
8938````
8939
8940The following patterns are not considered problems:
8941
8942````js
8943/**
8944 *
8945 */
8946
8947/**
8948 * @property
8949 */
8950
8951/**
8952 * @typedef {Object} SomeTypedef
8953 * @property {SomeType} propName Prop description
8954 */
8955
8956/**
8957 * @typedef {object} SomeTypedef
8958 * @prop {SomeType} propName Prop description
8959 */
8960// Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
8961
8962/**
8963 * @typedef {object} SomeTypedef
8964 * @property
8965 * // arbitrary property content
8966 */
8967
8968/**
8969 * @typedef {object<string, string>} SomeTypedef
8970 */
8971
8972/**
8973 * @typedef {string} SomeTypedef
8974 */
8975
8976/**
8977 * @namespace {object} SomeName
8978 * @property {SomeType} propName Prop description
8979 */
8980
8981/**
8982 * @namespace {object} SomeName
8983 * @property
8984 * // arbitrary property content
8985 */
8986
8987/**
8988 * @typedef {object} SomeTypedef
8989 * @property someProp
8990 * @property anotherProp This with a description
8991 * @property {anotherType} yetAnotherProp This with a type and desc.
8992 */
8993function quux () {
8994
8995}
8996````
8997
8998
8999<a name="eslint-plugin-jsdoc-rules-require-property-description"></a>
9000### <code>require-property-description</code>
9001
9002Requires that each `@property` tag has a `description` value.
9003
9004|||
9005|---|---|
9006|Context|everywhere|
9007|Tags|N/A|
9008
9009The following patterns are considered problems:
9010
9011````js
9012/**
9013 * @typedef {SomeType} SomeTypedef
9014 * @property foo
9015 */
9016// Message: Missing JSDoc @property "foo" description.
9017
9018/**
9019 * @typedef {SomeType} SomeTypedef
9020 * @prop foo
9021 */
9022// Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
9023// Message: Missing JSDoc @prop "foo" description.
9024
9025/**
9026 * @typedef {SomeType} SomeTypedef
9027 * @property foo
9028 */
9029// Settings: {"jsdoc":{"tagNamePreference":{"property":false}}}
9030// Message: Unexpected tag `@property`
9031````
9032
9033The following patterns are not considered problems:
9034
9035````js
9036/**
9037 * @typedef {SomeType} SomeTypedef
9038 */
9039
9040/**
9041 * @typedef {SomeType} SomeTypedef
9042 * @property foo Foo.
9043 */
9044
9045/**
9046 * @namespace {SomeType} SomeName
9047 * @property foo Foo.
9048 */
9049
9050/**
9051 * @class
9052 * @property foo Foo.
9053 */
9054````
9055
9056
9057<a name="eslint-plugin-jsdoc-rules-require-property-name"></a>
9058### <code>require-property-name</code>
9059
9060Requires that all function `@property` tags have names.
9061
9062|||
9063|---|---|
9064|Context|everywhere|
9065|Tags|N/A|
9066
9067The following patterns are considered problems:
9068
9069````js
9070/**
9071 * @typedef {SomeType} SomeTypedef
9072 * @property
9073 */
9074// Message: There must be an identifier after @property type.
9075
9076/**
9077 * @typedef {SomeType} SomeTypedef
9078 * @property {string}
9079 */
9080// Message: There must be an identifier after @property tag.
9081
9082/**
9083 * @typedef {SomeType} SomeTypedef
9084 * @property foo
9085 */
9086// Settings: {"jsdoc":{"tagNamePreference":{"property":false}}}
9087// Message: Unexpected tag `@property`
9088````
9089
9090The following patterns are not considered problems:
9091
9092````js
9093/**
9094 * @typedef {SomeType} SomeTypedef
9095 * @property foo
9096 */
9097
9098/**
9099 * @typedef {SomeType} SomeTypedef
9100 * @property {string} foo
9101 */
9102
9103/**
9104 * @namespace {SomeType} SomeName
9105 * @property {string} foo
9106 */
9107
9108/**
9109 * @class
9110 * @property {string} foo
9111 */
9112````
9113
9114
9115<a name="eslint-plugin-jsdoc-rules-require-property-type"></a>
9116### <code>require-property-type</code>
9117
9118Requires that each `@property` tag has a `type` value.
9119
9120|||
9121|---|---|
9122|Context|everywhere|
9123|Tags|N/A|
9124
9125The following patterns are considered problems:
9126
9127````js
9128/**
9129 * @typedef {SomeType} SomeTypedef
9130 * @property foo
9131 */
9132// Message: Missing JSDoc @property "foo" type.
9133
9134/**
9135 * @typedef {SomeType} SomeTypedef
9136 * @prop foo
9137 */
9138// Settings: {"jsdoc":{"tagNamePreference":{"property":"prop"}}}
9139// Message: Missing JSDoc @prop "foo" type.
9140
9141/**
9142 * @typedef {SomeType} SomeTypedef
9143 * @property foo
9144 */
9145// Settings: {"jsdoc":{"tagNamePreference":{"property":false}}}
9146// Message: Unexpected tag `@property`
9147````
9148
9149The following patterns are not considered problems:
9150
9151````js
9152/**
9153 * @typedef {SomeType} SomeTypedef
9154 */
9155
9156/**
9157 * @typedef {SomeType} SomeTypedef
9158 * @property {number} foo
9159 */
9160
9161/**
9162 * @namespace {SomeType} SomeName
9163 * @property {number} foo
9164 */
9165
9166/**
9167 * @class
9168 * @property {number} foo
9169 */
9170````
9171
9172
9173<a name="eslint-plugin-jsdoc-rules-require-returns-check"></a>
9174### <code>require-returns-check</code>
9175
9176Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.
9177
9178Will also report if multiple `@returns` tags are present.
9179
9180|||
9181|---|---|
9182|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
9183|Tags|`returns`|
9184|Aliases|`return`|
9185
9186The following patterns are considered problems:
9187
9188````js
9189/**
9190 * @returns
9191 */
9192function quux (foo) {
9193
9194}
9195// Message: JSDoc @returns declaration present but return expression not available in function.
9196
9197/**
9198 * @return
9199 */
9200function quux (foo) {
9201
9202}
9203// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
9204// Message: JSDoc @return declaration present but return expression not available in function.
9205
9206/**
9207 * @returns
9208 */
9209const quux = () => {}
9210// Message: JSDoc @returns declaration present but return expression not available in function.
9211
9212/**
9213 * @returns {undefined} Foo.
9214 * @returns {String} Foo.
9215 */
9216function quux () {
9217
9218 return foo;
9219}
9220// Message: Found more than one @returns declaration.
9221
9222const language = {
9223 /**
9224 * @param {string} name
9225 * @returns {string}
9226 */
9227 get name() {
9228 this._name = name;
9229 }
9230}
9231// Message: JSDoc @returns declaration present but return expression not available in function.
9232
9233class Foo {
9234 /**
9235 * @returns {string}
9236 */
9237 bar () {
9238 }
9239}
9240// Message: JSDoc @returns declaration present but return expression not available in function.
9241
9242/**
9243 * @returns
9244 */
9245function quux () {
9246
9247}
9248// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
9249// Message: Unexpected tag `@returns`
9250
9251/**
9252 * @returns {string}
9253 */
9254function f () {
9255 function g() {
9256 return 'foo'
9257 }
9258
9259 () => {
9260 return 5
9261 }
9262}
9263// Message: JSDoc @returns declaration present but return expression not available in function.
9264````
9265
9266The following patterns are not considered problems:
9267
9268````js
9269/**
9270 * @returns Foo.
9271 */
9272function quux () {
9273
9274 return foo;
9275}
9276
9277/**
9278 * @returns {string} Foo.
9279 */
9280function quux () {
9281
9282 return foo;
9283}
9284
9285/**
9286 * @returns {string} Foo.
9287 */
9288function quux () {
9289
9290 return foo;
9291}
9292
9293/**
9294 *
9295 */
9296function quux () {
9297}
9298
9299/**
9300 * @returns {*} Foo.
9301 */
9302const quux = () => foo;
9303
9304/**
9305 * @returns {undefined} Foo.
9306 */
9307function quux () {}
9308
9309/**
9310 * @returns { void } Foo.
9311 */
9312function quux () {}
9313
9314/**
9315 * @returns {Promise<void>}
9316 */
9317async function quux() {}
9318
9319/**
9320 * @returns {Promise<void>}
9321 */
9322const quux = async function () {}
9323
9324/**
9325 * @returns {Promise<void>}
9326 */
9327const quux = async () => {}
9328
9329/**
9330 * @returns Foo.
9331 * @abstract
9332 */
9333function quux () {
9334 throw new Error('must be implemented by subclass!');
9335}
9336
9337/**
9338 * @returns Foo.
9339 * @virtual
9340 */
9341function quux () {
9342 throw new Error('must be implemented by subclass!');
9343}
9344
9345/**
9346 * @returns Foo.
9347 * @constructor
9348 */
9349function quux () {
9350}
9351
9352/**
9353 * @interface
9354 */
9355class Foo {
9356 /**
9357 * @returns {string}
9358 */
9359 bar () {
9360 }
9361}
9362
9363/**
9364 * @returns {undefined} Foo.
9365 */
9366function quux () {
9367}
9368
9369/**
9370 * @returns {void} Foo.
9371 */
9372function quux () {
9373}
9374
9375/**
9376 * @returns {void} Foo.
9377 */
9378function quux () {
9379 return undefined;
9380}
9381
9382/**
9383 * @returns {void} Foo.
9384 */
9385function quux () {
9386 return;
9387}
9388
9389/**
9390 *
9391 */
9392function quux () {
9393 return undefined;
9394}
9395
9396/**
9397 *
9398 */
9399function quux () {
9400 return;
9401}
9402
9403/**
9404 * @returns {true}
9405 */
9406function quux () {
9407 try {
9408 return true;
9409 } catch (err) {
9410 }
9411 return;
9412}
9413
9414/**
9415 * @returns {true}
9416 */
9417function quux () {
9418 try {
9419 } finally {
9420 return true;
9421 }
9422 return;
9423}
9424
9425/**
9426 * @returns {true}
9427 */
9428function quux () {
9429 try {
9430 return;
9431 } catch (err) {
9432 }
9433 return true;
9434}
9435
9436/**
9437 * @returns {true}
9438 */
9439function quux () {
9440 try {
9441 something();
9442 } catch (err) {
9443 return true;
9444 }
9445 return;
9446}
9447
9448/**
9449 * @returns {true}
9450 */
9451function quux () {
9452 switch (true) {
9453 case 'abc':
9454 return true;
9455 }
9456 return;
9457}
9458
9459/**
9460 * @returns {true}
9461 */
9462function quux () {
9463 switch (true) {
9464 case 'abc':
9465 return;
9466 }
9467 return true;
9468}
9469
9470/**
9471 * @returns {true}
9472 */
9473function quux () {
9474 for (const i of abc) {
9475 return true;
9476 }
9477 return;
9478}
9479
9480/**
9481 * @returns {true}
9482 */
9483function quux () {
9484 for (const a in b) {
9485 return true;
9486 }
9487}
9488
9489/**
9490 * @returns {true}
9491 */
9492function quux () {
9493 for (let i=0; i<n; i+=1) {
9494 return true;
9495 }
9496}
9497
9498/**
9499 * @returns {true}
9500 */
9501function quux () {
9502 while(true) {
9503 return true
9504 }
9505}
9506
9507/**
9508 * @returns {true}
9509 */
9510function quux () {
9511 do {
9512 return true
9513 }
9514 while(true)
9515}
9516
9517/**
9518 * @returns {true}
9519 */
9520function quux () {
9521 if (true) {
9522 return;
9523 }
9524 return true;
9525}
9526
9527/**
9528 * @returns {true}
9529 */
9530function quux () {
9531 if (true) {
9532 return true;
9533 }
9534}
9535
9536/**
9537 * @returns {true}
9538 */
9539function quux () {
9540 var a = {};
9541 with (a) {
9542 return true;
9543 }
9544}
9545
9546/**
9547 * @returns {true}
9548 */
9549function quux () {
9550 if (true) {
9551 return;
9552 } else {
9553 return true;
9554 }
9555 return;
9556}
9557````
9558
9559
9560<a name="eslint-plugin-jsdoc-rules-require-returns-description"></a>
9561### <code>require-returns-description</code>
9562
9563Requires that the `@returns` tag has a `description` value. The error
9564will not be reported if the return value is `void` or `undefined`.
9565
9566<a name="eslint-plugin-jsdoc-rules-require-returns-description-options-23"></a>
9567#### Options
9568
9569<a name="eslint-plugin-jsdoc-rules-require-returns-description-options-23-contexts-7"></a>
9570##### <code>contexts</code>
9571
9572Set this to an array of strings representing the AST context
9573where you wish the rule to be applied.
9574Overrides the default contexts (see below). Set to `"any"` if you want
9575the rule to apply to any jsdoc block throughout your files (as is necessary
9576for finding function blocks not attached to a function declaration or
9577expression, i.e., `@callback` or `@function` (or its aliases `@func` or
9578`@method`) (including those associated with an `@interface`).
9579
9580|||
9581|---|---|
9582|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
9583|Tags|`returns`|
9584|Aliases|`return`|
9585|Options|`contexts`|
9586
9587The following patterns are considered problems:
9588
9589````js
9590/**
9591 * @returns
9592 */
9593function quux (foo) {
9594
9595}
9596// Message: Missing JSDoc @returns description.
9597
9598/**
9599 * @returns {string}
9600 */
9601function quux (foo) {
9602
9603}
9604// Message: Missing JSDoc @returns description.
9605
9606/**
9607 * @returns {string}
9608 */
9609function quux (foo) {
9610
9611}
9612// Options: [{"contexts":["any"]}]
9613// Message: Missing JSDoc @returns description.
9614
9615/**
9616 * @function
9617 * @returns {string}
9618 */
9619// Options: [{"contexts":["any"]}]
9620// Message: Missing JSDoc @returns description.
9621
9622/**
9623 * @callback
9624 * @returns {string}
9625 */
9626// Options: [{"contexts":["any"]}]
9627// Message: Missing JSDoc @returns description.
9628
9629/**
9630 * @return
9631 */
9632function quux (foo) {
9633
9634}
9635// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
9636// Message: Missing JSDoc @return description.
9637
9638/**
9639 * @returns
9640 */
9641function quux () {
9642
9643}
9644// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
9645// Message: Unexpected tag `@returns`
9646````
9647
9648The following patterns are not considered problems:
9649
9650````js
9651/**
9652 *
9653 */
9654function quux () {
9655
9656}
9657
9658/**
9659 * @returns Foo.
9660 */
9661function quux () {
9662
9663}
9664
9665/**
9666 * @returns Foo.
9667 */
9668function quux () {
9669
9670}
9671// Options: [{"contexts":["any"]}]
9672
9673/**
9674 * @returns {undefined}
9675 */
9676function quux () {
9677
9678}
9679
9680/**
9681 * @returns {void}
9682 */
9683function quux () {
9684
9685}
9686
9687/**
9688 * @function
9689 * @returns
9690 */
9691
9692/**
9693 * @callback
9694 * @returns
9695 */
9696````
9697
9698
9699<a name="eslint-plugin-jsdoc-rules-require-returns-type"></a>
9700### <code>require-returns-type</code>
9701
9702Requires that `@returns` tag has `type` value.
9703
9704<a name="eslint-plugin-jsdoc-rules-require-returns-type-options-24"></a>
9705#### Options
9706
9707<a name="eslint-plugin-jsdoc-rules-require-returns-type-options-24-contexts-8"></a>
9708##### <code>contexts</code>
9709
9710Set this to an array of strings representing the AST context
9711where you wish the rule to be applied.
9712Overrides the default contexts (see below). Set to `"any"` if you want
9713the rule to apply to any jsdoc block throughout your files (as is necessary
9714for finding function blocks not attached to a function declaration or
9715expression, i.e., `@callback` or `@function` (or its aliases `@func` or
9716`@method`) (including those associated with an `@interface`).
9717
9718|||
9719|---|---|
9720|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
9721|Tags|`returns`|
9722|Aliases|`return`|
9723|Options|`contexts`|
9724|Options|`contexts`|
9725
9726The following patterns are considered problems:
9727
9728````js
9729/**
9730 * @returns
9731 */
9732function quux () {
9733
9734}
9735// Message: Missing JSDoc @returns type.
9736
9737/**
9738 * @returns Foo.
9739 */
9740function quux () {
9741
9742}
9743// Message: Missing JSDoc @returns type.
9744
9745/**
9746 * @returns Foo.
9747 */
9748function quux () {
9749
9750}
9751// Options: [{"contexts":["any"]}]
9752// Message: Missing JSDoc @returns type.
9753
9754/**
9755 * @function
9756 * @returns Foo.
9757 */
9758// Options: [{"contexts":["any"]}]
9759// Message: Missing JSDoc @returns type.
9760
9761/**
9762 * @callback
9763 * @returns Foo.
9764 */
9765// Options: [{"contexts":["any"]}]
9766// Message: Missing JSDoc @returns type.
9767
9768/**
9769 * @return Foo.
9770 */
9771function quux () {
9772
9773}
9774// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
9775// Message: Missing JSDoc @return type.
9776
9777/**
9778 * @returns
9779 */
9780function quux () {
9781
9782}
9783// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
9784// Message: Unexpected tag `@returns`
9785````
9786
9787The following patterns are not considered problems:
9788
9789````js
9790/**
9791 * @returns {number}
9792 */
9793function quux () {
9794
9795}
9796
9797/**
9798 * @returns {number}
9799 */
9800function quux () {
9801
9802}
9803// Options: [{"contexts":["any"]}]
9804
9805/**
9806 * @function
9807 * @returns Foo.
9808 */
9809
9810/**
9811 * @callback
9812 * @returns Foo.
9813 */
9814````
9815
9816
9817<a name="eslint-plugin-jsdoc-rules-require-returns"></a>
9818### <code>require-returns</code>
9819
9820Requires returns are documented.
9821
9822Will also report if multiple `@returns` tags are present.
9823
9824<a name="eslint-plugin-jsdoc-rules-require-returns-options-25"></a>
9825#### Options
9826
9827- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
9828 block avoids the need for a `@returns`. Defaults to an empty array.
9829- `forceRequireReturn` - Set to `true` to always insist on
9830 `@returns` documentation regardless of implicit or explicit `return`'s
9831 in the function. May be desired to flag that a project is aware of an
9832 `undefined`/`void` return. Defaults to `false`.
9833- `forceReturnsWithAsync` - By default `async` functions that do not explicitly
9834 return a value pass this rule as an `async` function will always return a
9835 `Promise`, even if the `Promise` resolves to void. You can force all `async`
9836 functions to require return statements by setting `forceReturnsWithAsync`
9837 to `true` on the options object. This may be useful for flagging that there
9838 has been consideration of return type. Defaults to `false`.
9839- `contexts` - Set this to an array of strings representing the AST context
9840 where you wish the rule to be applied.
9841 Overrides the default contexts (see below). Set to `"any"` if you want
9842 the rule to apply to any jsdoc block throughout your files (as is necessary
9843 for finding function blocks not attached to a function declaration or
9844 expression, i.e., `@callback` or `@function` (or its aliases `@func` or
9845 `@method`) (including those associated with an `@interface`). This
9846 rule will only apply on non-default contexts when there is such a tag
9847 present and the `forceRequireReturn` option is set or if the
9848 `forceReturnsWithAsync` option is set with a present `@async` tag
9849 (since we are not checking against the actual `return` values in these
9850 cases).
9851
9852```js
9853'jsdoc/require-returns': ['error', {forceReturnsWithAsync: true}]
9854```
9855
9856|||
9857|---|---|
9858|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
9859|Tags|`returns`|
9860|Aliases|`return`|
9861|Options|`contexts`, `exemptedBy`, `forceRequireReturn`, `forceReturnsWithAsync`|
9862|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
9863
9864The following patterns are considered problems:
9865
9866````js
9867/**
9868 *
9869 */
9870function quux (foo) {
9871
9872 return foo;
9873}
9874// Message: Missing JSDoc @returns declaration.
9875
9876/**
9877 *
9878 */
9879const foo = () => ({
9880 bar: 'baz'
9881})
9882// Message: Missing JSDoc @returns declaration.
9883
9884/**
9885 *
9886 */
9887const foo = bar=>({ bar })
9888// Message: Missing JSDoc @returns declaration.
9889
9890/**
9891 *
9892 */
9893const foo = bar => bar.baz()
9894// Message: Missing JSDoc @returns declaration.
9895
9896/**
9897 *
9898 */
9899function quux (foo) {
9900
9901 return foo;
9902}
9903// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
9904// Message: Missing JSDoc @return declaration.
9905
9906/**
9907 *
9908 */
9909function foo() {}
9910
9911/**
9912 *
9913 */
9914function bar() {}
9915// Settings: {"jsdoc":{"forceRequireReturn":true}}
9916// Message: `settings.jsdoc.forceRequireReturn` has been removed, use options in the rule `require-returns` instead.
9917
9918/**
9919 *
9920 */
9921async function quux() {
9922}
9923// Options: [{"forceRequireReturn":true}]
9924// Message: Missing JSDoc @returns declaration.
9925
9926/**
9927 *
9928 */
9929const quux = async function () {}
9930// Options: [{"forceRequireReturn":true}]
9931// Message: Missing JSDoc @returns declaration.
9932
9933/**
9934 *
9935 */
9936const quux = async () => {}
9937// Options: [{"forceRequireReturn":true}]
9938// Message: Missing JSDoc @returns declaration.
9939
9940/**
9941 *
9942 */
9943async function quux () {}
9944// Options: [{"forceRequireReturn":true}]
9945// Message: Missing JSDoc @returns declaration.
9946
9947/**
9948 *
9949 */
9950function quux () {
9951}
9952// Options: [{"forceRequireReturn":true}]
9953// Message: Missing JSDoc @returns declaration.
9954
9955/**
9956 *
9957 */
9958function quux () {
9959}
9960// Options: [{"contexts":["any"],"forceRequireReturn":true}]
9961// Message: Missing JSDoc @returns declaration.
9962
9963/**
9964 * @function
9965 */
9966// Options: [{"contexts":["any"],"forceRequireReturn":true}]
9967// Message: Missing JSDoc @returns declaration.
9968
9969/**
9970 * @callback
9971 */
9972// Options: [{"contexts":["any"],"forceRequireReturn":true}]
9973// Message: Missing JSDoc @returns declaration.
9974
9975const language = {
9976 /**
9977 * @param {string} name
9978 */
9979 get name() {
9980 return this._name;
9981 }
9982}
9983// Message: Missing JSDoc @returns declaration.
9984
9985/**
9986 *
9987 */
9988async function quux () {
9989}
9990// Options: [{"forceReturnsWithAsync":true}]
9991// Message: Missing JSDoc @returns declaration.
9992
9993/**
9994 * @function
9995 * @async
9996 */
9997// Options: [{"contexts":["any"],"forceReturnsWithAsync":true}]
9998// Message: Missing JSDoc @returns declaration.
9999
10000/**
10001 * @callback
10002 * @async
10003 */
10004// Options: [{"contexts":["any"],"forceReturnsWithAsync":true}]
10005// Message: Missing JSDoc @returns declaration.
10006
10007/**
10008 * @returns {undefined}
10009 * @returns {void}
10010 */
10011function quux (foo) {
10012
10013 return foo;
10014}
10015// Message: Found more than one @returns declaration.
10016
10017/**
10018 * @returns
10019 */
10020function quux () {
10021
10022}
10023// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
10024// Message: Unexpected tag `@returns`
10025
10026/**
10027 * @param foo
10028 */
10029function quux (foo) {
10030 return 'bar';
10031}
10032// Options: [{"exemptedBy":["notPresent"]}]
10033// Message: Missing JSDoc @returns declaration.
10034
10035/**
10036 * @param {array} a
10037 */
10038async function foo(a) {
10039 return;
10040}
10041// Options: [{"forceReturnsWithAsync":true}]
10042// Message: Missing JSDoc @returns declaration.
10043
10044/**
10045 * @param {array} a
10046 */
10047async function foo(a) {
10048 return Promise.all(a);
10049}
10050// Options: [{"forceReturnsWithAsync":true}]
10051// Message: Missing JSDoc @returns declaration.
10052````
10053
10054The following patterns are not considered problems:
10055
10056````js
10057/**
10058 * @returns Foo.
10059 */
10060function quux () {
10061
10062 return foo;
10063}
10064
10065/**
10066 * @returns Foo.
10067 */
10068function quux () {
10069
10070 return foo;
10071}
10072// Options: [{"contexts":["any"]}]
10073
10074/**
10075 *
10076 */
10077function quux () {
10078}
10079
10080/**
10081 *
10082 */
10083function quux (bar) {
10084 bar.filter(baz => {
10085 return baz.corge();
10086 })
10087}
10088
10089/**
10090 * @returns Array
10091 */
10092function quux (bar) {
10093 return bar.filter(baz => {
10094 return baz.corge();
10095 })
10096}
10097
10098/**
10099 * @returns Array
10100 */
10101const quux = (bar) => bar.filter(({ corge }) => corge())
10102
10103/**
10104 * @inheritdoc
10105 */
10106function quux (foo) {
10107}
10108
10109/**
10110 * @override
10111 */
10112function quux (foo) {
10113}
10114
10115/**
10116 * @constructor
10117 */
10118function quux (foo) {
10119}
10120
10121/**
10122 * @implements
10123 */
10124function quux (foo) {
10125}
10126
10127/**
10128 * @override
10129 */
10130function quux (foo) {
10131
10132 return foo;
10133}
10134
10135/**
10136 * @class
10137 */
10138function quux (foo) {
10139
10140}
10141
10142/**
10143 * @constructor
10144 */
10145function quux (foo) {
10146
10147}
10148
10149/**
10150 * @returns {object}
10151 */
10152function quux () {
10153
10154 return {a: foo};
10155}
10156
10157/**
10158 * @returns {object}
10159 */
10160const quux = () => ({a: foo});
10161
10162/**
10163 * @returns {object}
10164 */
10165const quux = () => {
10166 return {a: foo}
10167};
10168
10169/**
10170 * @returns {void}
10171 */
10172function quux () {
10173}
10174
10175/**
10176 * @returns {void}
10177 */
10178const quux = () => {
10179
10180}
10181
10182/**
10183 * @returns {undefined}
10184 */
10185function quux () {
10186}
10187
10188/**
10189 * @returns {undefined}
10190 */
10191const quux = () => {
10192
10193}
10194
10195/**
10196 *
10197 */
10198function quux () {
10199}
10200
10201/**
10202 *
10203 */
10204const quux = () => {
10205
10206}
10207
10208class Foo {
10209 /**
10210 *
10211 */
10212 constructor () {
10213 }
10214}
10215// Options: [{"forceRequireReturn":true}]
10216
10217const language = {
10218 /**
10219 * @param {string} name
10220 */
10221 set name(name) {
10222 this._name = name;
10223 }
10224}
10225
10226/**
10227 * @returns {void}
10228 */
10229function quux () {
10230}
10231// Options: [{"forceRequireReturn":true}]
10232
10233/**
10234 * @returns {void}
10235 */
10236function quux () {
10237 return undefined;
10238}
10239
10240/**
10241 * @returns {void}
10242 */
10243function quux () {
10244 return undefined;
10245}
10246// Options: [{"forceRequireReturn":true}]
10247
10248/**
10249 * @returns {void}
10250 */
10251function quux () {
10252 return;
10253}
10254
10255/**
10256 * @returns {void}
10257 */
10258function quux () {
10259}
10260// Options: [{"forceRequireReturn":true}]
10261
10262/**
10263 * @returns {void}
10264 */
10265function quux () {
10266 return;
10267}
10268// Options: [{"forceRequireReturn":true}]
10269
10270/** @type {RequestHandler} */
10271function quux (req, res , next) {
10272 return;
10273}
10274
10275/**
10276 * @returns {Promise}
10277 */
10278async function quux () {
10279}
10280// Options: [{"forceRequireReturn":true}]
10281
10282/**
10283 * @returns {Promise}
10284 */
10285async function quux () {
10286}
10287// Options: [{"forceReturnsWithAsync":true}]
10288
10289/**
10290 *
10291 */
10292async function quux () {}
10293
10294/**
10295 *
10296 */
10297const quux = async function () {}
10298
10299/**
10300 *
10301 */
10302const quux = async () => {}
10303
10304/** foo class */
10305class foo {
10306 /** foo constructor */
10307 constructor () {
10308 // =>
10309 this.bar = true;
10310 }
10311}
10312
10313export default foo;
10314
10315/**
10316 *
10317 */
10318function quux () {
10319}
10320// Options: [{"forceReturnsWithAsync":true}]
10321
10322/**
10323 * @type {MyCallback}
10324 */
10325function quux () {
10326
10327}
10328// Options: [{"exemptedBy":["type"]}]
10329
10330/**
10331 * @param {array} a
10332 */
10333async function foo(a) {
10334 return Promise.all(a);
10335}
10336
10337/**
10338 * @param {array} a
10339 */
10340async function foo(a) {
10341 return;
10342}
10343
10344/**
10345 *
10346 */
10347// Options: [{"contexts":["any"]}]
10348
10349/**
10350 * @async
10351 */
10352// Options: [{"contexts":["any"]}]
10353
10354/**
10355 * @function
10356 */
10357// Options: [{"forceRequireReturn":true}]
10358
10359/**
10360 * @callback
10361 */
10362// Options: [{"forceRequireReturn":true}]
10363
10364/**
10365 * @function
10366 * @async
10367 */
10368// Options: [{"forceReturnsWithAsync":true}]
10369
10370/**
10371 * @callback
10372 * @async
10373 */
10374// Options: [{"forceReturnsWithAsync":true}]
10375
10376/**
10377 * @function
10378 */
10379// Options: [{"contexts":["any"],"forceReturnsWithAsync":true}]
10380
10381/**
10382 * @callback
10383 */
10384// Options: [{"contexts":["any"],"forceReturnsWithAsync":true}]
10385````
10386
10387
10388<a name="eslint-plugin-jsdoc-rules-valid-types"></a>
10389### <code>valid-types</code>
10390
10391Requires all types to be valid JSDoc or Closure compiler types without syntax errors.
10392
10393Also impacts behaviors on namepath (or event)-defining and pointing tags:
10394
103951. Name(path)-defining tags requiring namepath: `@external`, `@host`, `@name`, `@typedef`
103961. Name(path)-defining tags (which may have value without namepath or their
10397 namepath can be expressed elsewhere on the block): `@event`, `@callback`,
10398 `@class`, `@constructor`, `@constant`, `@const`,
10399 `@function`, `@func`, `@method`, `@interface`, `@member`, `@var`,
10400 `@mixin`, `@namespace`
104011. Name(path)-pointing tags requiring namepath: `@alias`, `@augments`, `@extends`, `@lends`, `@memberof`, `@memberof!`, `@mixes`, `@this`
104021. Name(path)-pointing tags (which may have value without namepath or their
10403 namepath can be expressed elsewhere on the block): `@listens`, `@fires`,
10404 `@emits`, and `@modifies`
104051. Name(path)-pointing tags (multiple names in one): `@borrows`
10406
10407...with the following applying to the above sets:
10408
10409- Expect tags in set 1-4 to have a valid namepath if present
10410- Prevent sets 2 and 4 from being empty by setting `allowEmptyNamepaths` to
10411 `false` as these tags might have some indicative value without a path
10412 or may allow a name expressed elsewhere on the block (but sets 1 and 3 will
10413 always fail if empty)
10414- For the special case of set 5, i.e., `@borrows <that namepath> as <this namepath>`,
10415 check that both namepaths are present and valid and ensure there is an `as `
10416 between them. In the case of `<this namepath>`, it can be preceded by
10417 one of the name path operators, `#`, `.`, or `~`.
10418- For the special case of `@memberof` and `@memberof!` (part of set 3), as
10419 per the [specification](https://jsdoc.app/tags-memberof.html), they also
10420 allow `#`, `.`, or `~` at the end (which is not allowed at the end of
10421 normal paths).
10422
10423<a name="eslint-plugin-jsdoc-rules-valid-types-options-26"></a>
10424#### Options
10425
10426- `allowEmptyNamepaths` (default: true) - Set to `false` to disallow
10427 empty name paths with `@callback`, `@event`, `@class`, `@constructor`,
10428 `@constant`, `@const`, `@function`, `@func`, `@method`, `@interface`,
10429 `@member`, `@var`, `@mixin`, `@namespace`, `@listens`, `@fires`,
10430 `@modifies`, or `@emits` (these might often be expected to have an
10431 accompanying name path, though they have some indicative value without
10432 one; these may also allow names to be defined in another manner elsewhere
10433 in the block)
10434- `checkSeesForNamepaths` (default: false) - Set this to `true` to insist
10435 that `@see` only use name paths (the tag is normally permitted to
10436 allow other text)
10437
10438
10439|||
10440|---|---|
10441|Context|everywhere|
10442|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), `this`, `throws` (for type), `type` (for type), `typedef` (for name and type), `yields` (for type)|
10443|Aliases|`extends`, `constructor`, `const`, `host`, `emits`, `func`, `method`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
10444|Closure-only|For type only: `package`, `private`, `protected`, `public`, `static`|
10445|Options|`allowEmptyNamepaths`, `checkSeesForNamepaths`|
10446|Settings|`mode`|
10447
10448The following patterns are considered problems:
10449
10450````js
10451/**
10452 * @param {Array<string} foo
10453 */
10454function quux() {
10455
10456}
10457// Message: Syntax error in type: Array<string
10458
10459/**
10460 * @memberof module:namespace.SomeClass<~
10461 */
10462function quux() {
10463
10464}
10465// Message: Syntax error in namepath: module:namespace.SomeClass<~
10466
10467/**
10468 * @memberof module:namespace.SomeClass~<
10469 */
10470function quux() {
10471
10472}
10473// Message: Syntax error in namepath: module:namespace.SomeClass~<
10474
10475/**
10476 * @borrows foo% as bar
10477 */
10478function quux() {
10479
10480}
10481// Message: Syntax error in namepath: foo%
10482
10483/**
10484 * @borrows #foo as bar
10485 */
10486function quux() {
10487
10488}
10489// Message: Syntax error in namepath: #foo
10490
10491/**
10492 * @borrows foo as bar%
10493 */
10494function quux() {
10495
10496}
10497// Message: Syntax error in namepath: bar%
10498
10499/**
10500 * @borrows foo
10501 */
10502function quux() {
10503
10504}
10505// Message: @borrows must have an "as" expression. Found ""
10506
10507/**
10508 * @see foo%
10509 */
10510function quux() {
10511
10512}
10513// Options: [{"checkSeesForNamepaths":true}]
10514// Message: Syntax error in namepath: foo%
10515
10516/** */
10517function foo() {}
10518// Settings: {"jsdoc":{"allowEmptyNamepaths":true,"checkSeesForNamepaths":true}}
10519// Message: `settings.jsdoc.allowEmptyNamepaths` has been removed, use options in the rule `valid-types` instead.
10520
10521/**
10522 * @alias module:abc#event:foo-bar
10523 */
10524function quux() {
10525
10526}
10527// Message: Syntax error in namepath: module:abc#event:foo-bar
10528
10529/**
10530 * @mixes module:namespace.SomeClass~
10531 */
10532function quux() {
10533
10534}
10535// Message: Syntax error in namepath: module:namespace.SomeClass~
10536
10537/**
10538 * @callback
10539 */
10540function quux() {
10541
10542}
10543// Options: [{"allowEmptyNamepaths":false}]
10544// Message: Tag @callback must have a name/namepath
10545
10546/**
10547 * @constant {str%ng}
10548 */
10549 const FOO = 'foo';
10550// Message: Syntax error in type: str%ng
10551
10552/**
10553 * @typedef {str%ng} UserString
10554 */
10555// Message: Syntax error in type: str%ng
10556
10557/**
10558 * @typedef {string} UserStr%ng
10559 */
10560// Message: Syntax error in namepath: UserStr%ng
10561
10562/**
10563 * @extends
10564 */
10565 class Bar {};
10566// Message: Tag @extends must have either a type or namepath
10567
10568/**
10569 * @type
10570 */
10571 let foo;
10572// Message: Tag @type must have a type
10573
10574/**
10575 * @modifies {bar|foo<}
10576 */
10577function quux (foo, bar, baz) {}
10578// Message: Syntax error in type: bar|foo<
10579
10580/**
10581 * @private {BadTypeChecked<}
10582 */
10583function quux () {}
10584// Settings: {"jsdoc":{"mode":"closure"}}
10585// Message: Syntax error in type: BadTypeChecked<
10586
10587/**
10588 * @this {BadTypeChecked<}
10589 */
10590function quux () {}
10591// Settings: {"jsdoc":{"mode":"closure"}}
10592// Message: Syntax error in type: BadTypeChecked<
10593
10594/**
10595 * @define
10596 */
10597 function quux () {}
10598// Settings: {"jsdoc":{"mode":"closure"}}
10599// Message: Tag @define must have a type
10600
10601/**
10602 * @this
10603 */
10604 let foo;
10605// Settings: {"jsdoc":{"mode":"closure"}}
10606// Message: Tag @this must have a type
10607````
10608
10609The following patterns are not considered problems:
10610
10611````js
10612/**
10613 * @param {Array<string>} foo
10614 */
10615function quux() {
10616
10617}
10618
10619/**
10620 * @param {string} foo
10621 */
10622function quux() {
10623
10624}
10625
10626/**
10627 * @param foo
10628 */
10629function quux() {
10630
10631}
10632
10633/**
10634 * @borrows foo as bar
10635 */
10636function quux() {
10637
10638}
10639
10640/**
10641 * @borrows foo as #bar
10642 */
10643function quux() {
10644
10645}
10646
10647/**
10648 * @see foo%
10649 */
10650function quux() {
10651
10652}
10653
10654/**
10655 * @alias module:namespace.SomeClass#event:ext_anevent
10656 */
10657function quux() {
10658
10659}
10660
10661/**
10662 * @callback foo
10663 */
10664function quux() {
10665
10666}
10667
10668/**
10669 * @callback
10670 */
10671function quux() {
10672
10673}
10674// Options: [{"allowEmptyNamepaths":true}]
10675
10676/**
10677 * @class
10678 */
10679function quux() {
10680
10681}
10682
10683/**
10684 * @see {@link foo}
10685 */
10686function quux() {
10687
10688}
10689// Options: [{"checkSeesForNamepaths":true}]
10690
10691/**
10692 *
10693 * @fires {module:namespace.SomeClass#event:ext_anevent}
10694 */
10695function quux() {
10696
10697}
10698
10699/**
10700 * @memberof module:namespace.SomeClass~
10701 */
10702function quux() {
10703
10704}
10705
10706/**
10707 * @memberof! module:namespace.SomeClass.
10708 */
10709function quux() {
10710
10711}
10712
10713/**
10714 *
10715 */
10716function quux() {
10717
10718}
10719
10720/**
10721 * @constant {string}
10722 */
10723 const FOO = 'foo';
10724
10725/**
10726 * @constant {string} FOO
10727 */
10728 const FOO = 'foo';
10729
10730/**
10731 * @extends Foo
10732 */
10733 class Bar {};
10734
10735/**
10736 * @extends {Foo<String>}
10737 */
10738 class Bar {};
10739
10740/**
10741 * @typedef {number|string} UserDefinedType
10742 */
10743
10744/**
10745 * @typedef {number|string}
10746 */
10747let UserDefinedGCCType;
10748
10749/**
10750 * @modifies {foo|bar}
10751 */
10752function quux (foo, bar, baz) {}
10753
10754/**
10755 * @private {BadTypeNotCheckedInJsdoc<}
10756 */
10757function quux () {}
10758
10759/**
10760 * @this {Navigator}
10761 */
10762function quux () {}
10763// Settings: {"jsdoc":{"mode":"closure"}}
10764
10765/**
10766 * @export {SomeType}
10767 */
10768function quux () {}
10769// Settings: {"jsdoc":{"mode":"closure"}}
10770
10771/**
10772 * @define {boolean}
10773 */
10774function quux () {}
10775// Settings: {"jsdoc":{"mode":"closure"}}
10776
10777/**
10778 * @define
10779 */
10780 function quux () {}
10781````
10782
10783
10784
\No newline at end of file