UNPKG

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