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). Set to `"any"` if you want
3977the rule to apply to any jsdoc block throughout your files.
3978
3979|||
3980|---|---|
3981|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
3982|Tags|docblock and `@description` by default but more with `tags`|
3983|Aliases|`@desc`|
3984|Settings||
3985|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`|
3986
3987The following patterns are considered problems:
3988
3989````js
3990/**
3991 * foo.
3992 */
3993const q = class {
3994
3995}
3996// Options: [{"contexts":["ClassExpression"]}]
3997// Message: JSDoc description does not satisfy the regex pattern.
3998
3999/**
4000 * foo.
4001 */
4002// Options: [{"contexts":["any"]}]
4003// Message: JSDoc description does not satisfy the regex pattern.
4004
4005/**
4006 * foo.
4007 */
4008// Options: [{"contexts":["any"]}]
4009// Message: JSDoc description does not satisfy the regex pattern.
4010
4011/**
4012 * foo.
4013 */
4014const q = {
4015
4016};
4017// Options: [{"contexts":["ObjectExpression"]}]
4018// Message: JSDoc description does not satisfy the regex pattern.
4019
4020/**
4021 * foo.
4022 */
4023function quux () {
4024
4025}
4026// Message: JSDoc description does not satisfy the regex pattern.
4027
4028/**
4029 * Foo)
4030 */
4031function quux () {
4032
4033}
4034// Message: JSDoc description does not satisfy the regex pattern.
4035
4036/**
4037 * тест.
4038 */
4039function quux () {
4040
4041}
4042// Options: [{"matchDescription":"[А-Я][А-я]+\\."}]
4043// Message: JSDoc description does not satisfy the regex pattern.
4044
4045/**
4046 * Abc.
4047 */
4048function quux () {
4049
4050}
4051// Options: [{"mainDescription":"[А-Я][А-я]+\\.","tags":{"param":true}}]
4052// Message: JSDoc description does not satisfy the regex pattern.
4053
4054/**
4055 * Foo
4056 */
4057function quux () {
4058
4059}
4060// Message: JSDoc description does not satisfy the regex pattern.
4061
4062/**
4063 * Foo.
4064 *
4065 * @param foo foo.
4066 */
4067function quux (foo) {
4068
4069}
4070// Options: [{"tags":{"param":true}}]
4071// Message: JSDoc description does not satisfy the regex pattern.
4072
4073/**
4074 * Foo.
4075 *
4076 * @prop foo foo.
4077 */
4078function quux (foo) {
4079
4080}
4081// Options: [{"tags":{"prop":true}}]
4082// Message: JSDoc description does not satisfy the regex pattern.
4083
4084/**
4085 * Foo.
4086 *
4087 * @summary foo.
4088 */
4089function quux () {
4090
4091}
4092// Options: [{"tags":{"summary":true}}]
4093// Message: JSDoc description does not satisfy the regex pattern.
4094
4095/**
4096 * Foo.
4097 *
4098 * @author
4099 */
4100function quux () {
4101
4102}
4103// Options: [{"tags":{"author":".+"}}]
4104// Message: JSDoc description does not satisfy the regex pattern.
4105
4106/**
4107 * Foo.
4108 *
4109 * @x-tag
4110 */
4111function quux () {
4112
4113}
4114// Options: [{"tags":{"x-tag":".+"}}]
4115// Message: JSDoc description does not satisfy the regex pattern.
4116
4117/**
4118 * Foo.
4119 *
4120 * @description foo foo.
4121 */
4122function quux (foo) {
4123
4124}
4125// Options: [{"tags":{"description":true}}]
4126// Message: JSDoc description does not satisfy the regex pattern.
4127
4128/**
4129 * Foo
4130 *
4131 * @param foo foo.
4132 */
4133function quux (foo) {
4134
4135}
4136// Options: [{"mainDescription":"^[a-zA-Z]*$","tags":{"param":true}}]
4137// Message: JSDoc description does not satisfy the regex pattern.
4138
4139/**
4140 * Foo
4141 *
4142 * @param foo foo.
4143 */
4144function quux (foo) {
4145
4146}
4147// Options: [{"mainDescription":false,"tags":{"param":true}}]
4148// Message: JSDoc description does not satisfy the regex pattern.
4149
4150/**
4151 * Foo.
4152 *
4153 * @param foo bar
4154 */
4155function quux (foo) {
4156
4157}
4158// Options: [{"tags":{"param":true}}]
4159// Message: JSDoc description does not satisfy the regex pattern.
4160
4161/**
4162 * {@see Foo.bar} buz
4163 */
4164function quux (foo) {
4165
4166}
4167// Message: JSDoc description does not satisfy the regex pattern.
4168
4169/**
4170 * Foo.
4171 *
4172 * @returns {number} foo
4173 */
4174function quux (foo) {
4175
4176}
4177// Options: [{"tags":{"returns":true}}]
4178// Message: JSDoc description does not satisfy the regex pattern.
4179
4180/**
4181 * Foo.
4182 *
4183 * @returns foo.
4184 */
4185function quux (foo) {
4186
4187}
4188// Options: [{"tags":{"returns":true}}]
4189// Message: JSDoc description does not satisfy the regex pattern.
4190
4191/**
4192 * lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque elit diam,
4193 * iaculis eu dignissim sed, ultrices sed nisi. nulla at ligula auctor, consectetur neque sed,
4194 * tincidunt nibh. vivamus sit amet vulputate ligula. vivamus interdum elementum nisl,
4195 * vitae rutrum tortor semper ut. morbi porta ante vitae dictum fermentum.
4196 * proin ut nulla at quam convallis gravida in id elit. sed dolor mauris, blandit quis ante at,
4197 * consequat auctor magna. duis pharetra purus in porttitor mollis.
4198 */
4199function longDescription (foo) {
4200
4201}
4202// Message: JSDoc description does not satisfy the regex pattern.
4203
4204/**
4205 * @arg {number} foo - Foo
4206 */
4207function quux (foo) {
4208
4209}
4210// Options: [{"tags":{"arg":true}}]
4211// Message: JSDoc description does not satisfy the regex pattern.
4212
4213/**
4214 * @argument {number} foo - Foo
4215 */
4216function quux (foo) {
4217
4218}
4219// Options: [{"tags":{"argument":true}}]
4220// Message: JSDoc description does not satisfy the regex pattern.
4221
4222/**
4223 * @return {number} foo
4224 */
4225function quux (foo) {
4226
4227}
4228// Options: [{"tags":{"return":true}}]
4229// Message: JSDoc description does not satisfy the regex pattern.
4230
4231/**
4232 * Returns bar.
4233 *
4234 * @return {number} bar
4235 */
4236function quux (foo) {
4237
4238}
4239// Options: [{"tags":{"return":true}}]
4240// Message: JSDoc description does not satisfy the regex pattern.
4241
4242/**
4243 * @param notRet
4244 * @returns Тест.
4245 */
4246function quux () {
4247
4248}
4249// Options: [{"tags":{"param":"[А-Я][А-я]+\\."}}]
4250// Message: JSDoc description does not satisfy the regex pattern.
4251
4252/**
4253 * @description notRet
4254 * @returns Тест.
4255 */
4256function quux () {
4257
4258}
4259// Options: [{"tags":{"description":"[А-Я][А-я]+\\."}}]
4260// Message: JSDoc description does not satisfy the regex pattern.
4261
4262/**
4263 * foo.
4264 */
4265class quux {
4266
4267}
4268// Options: [{"contexts":["ClassDeclaration"]}]
4269// Message: JSDoc description does not satisfy the regex pattern.
4270
4271class MyClass {
4272 /**
4273 * Abc
4274 */
4275 myClassField = 1
4276}
4277// Options: [{"contexts":["ClassProperty"]}]
4278// Message: JSDoc description does not satisfy the regex pattern.
4279
4280/**
4281 * foo.
4282 */
4283interface quux {
4284
4285}
4286// Options: [{"contexts":["TSInterfaceDeclaration"]}]
4287// Message: JSDoc description does not satisfy the regex pattern.
4288
4289const myObject = {
4290 /**
4291 * Bad description
4292 */
4293 myProp: true
4294};
4295// Options: [{"contexts":["Property"]}]
4296// Message: JSDoc description does not satisfy the regex pattern.
4297
4298/**
4299 * @param foo Foo bar
4300 */
4301function quux (foo) {
4302
4303}
4304// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
4305// Options: [{"tags":{"param":true}}]
4306// Message: JSDoc description does not satisfy the regex pattern.
4307
4308/**
4309 * Foo bar
4310 */
4311function quux (foo) {
4312
4313}
4314// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
4315// Message: JSDoc description does not satisfy the regex pattern.
4316````
4317
4318The following patterns are not considered problems:
4319
4320````js
4321/**
4322 *
4323 */
4324
4325/**
4326 *
4327 */
4328 function quux () {
4329
4330 }
4331
4332/**
4333 * @param foo - Foo.
4334 */
4335function quux () {
4336
4337}
4338// Options: [{"tags":{"param":true}}]
4339
4340/**
4341 * Foo.
4342 */
4343function quux () {
4344
4345}
4346
4347/**
4348 * Foo.
4349 * Bar.
4350 */
4351function quux () {
4352
4353}
4354
4355/**
4356 * Foo.
4357 *
4358 * Bar.
4359 */
4360function quux () {
4361
4362}
4363
4364/**
4365 * Тест.
4366 */
4367function quux () {
4368
4369}
4370// Options: [{"matchDescription":"[А-Я][А-я]+\\."}]
4371
4372/**
4373 * @param notRet
4374 * @returns Тест.
4375 */
4376function quux () {
4377
4378}
4379// Options: [{"tags":{"returns":"[А-Я][А-я]+\\."}}]
4380
4381/**
4382 * @param notRet
4383 * @description Тест.
4384 */
4385function quux () {
4386
4387}
4388// Options: [{"tags":{"description":"[А-Я][А-я]+\\."}}]
4389
4390/**
4391 * Foo
4392 * bar.
4393 */
4394function quux () {
4395
4396}
4397
4398/**
4399 * @returns Foo bar.
4400 */
4401function quux () {
4402
4403}
4404// Options: [{"tags":{"returns":true}}]
4405
4406/**
4407 * @returns {type1} Foo bar.
4408 */
4409function quux () {
4410
4411}
4412// Options: [{"tags":{"returns":true}}]
4413
4414/**
4415 * @description Foo bar.
4416 */
4417function quux () {
4418
4419}
4420// Options: [{"tags":{"description":true}}]
4421
4422/**
4423 * Foo. {@see Math.sin}.
4424 */
4425function quux () {
4426
4427}
4428
4429/**
4430 * Foo {@see Math.sin} bar.
4431 */
4432function quux () {
4433
4434}
4435
4436/**
4437 * Foo?
4438 *
4439 * Bar!
4440 *
4441 * Baz:
4442 * 1. Foo.
4443 * 2. Bar.
4444 */
4445function quux () {
4446
4447}
4448
4449/**
4450 * Hello:
4451 * World.
4452 */
4453function quux () {
4454
4455}
4456
4457/**
4458 * Hello: world.
4459 */
4460function quux () {
4461
4462}
4463
4464/**
4465 * Foo
4466 * Bar.
4467 */
4468function quux () {
4469
4470}
4471
4472/**
4473 * Foo.
4474 *
4475 * foo.
4476 */
4477function quux () {
4478
4479}
4480
4481/**
4482 * foo.
4483 */
4484function quux () {
4485
4486}
4487// Options: [{"mainDescription":false}]
4488
4489/**
4490 * foo.
4491 */
4492class quux {
4493
4494}
4495
4496/**
4497 * foo.
4498 */
4499class quux {
4500
4501}
4502// Options: [{"mainDescription":true}]
4503
4504class MyClass {
4505 /**
4506 * Abc.
4507 */
4508 myClassField = 1
4509}
4510// Options: [{"contexts":["ClassProperty"]}]
4511
4512/**
4513 * Foo.
4514 */
4515interface quux {
4516
4517}
4518// Options: [{"contexts":["TSInterfaceDeclaration"]}]
4519
4520const myObject = {
4521 /**
4522 * Bad description
4523 */
4524 myProp: true
4525};
4526// Options: [{"contexts":[]}]
4527
4528/**
4529 * foo.
4530 */
4531const q = class {
4532
4533}
4534// Options: [{"contexts":[]}]
4535
4536/**
4537 * foo.
4538 */
4539const q = {
4540
4541};
4542// Options: [{"contexts":[]}]
4543
4544/**
4545 * @description foo.
4546 */
4547function quux () {
4548
4549}
4550// Options: [{"tags":{"param":true}}]
4551
4552/**
4553 * Foo.
4554 *
4555 * @summary Foo.
4556 */
4557function quux () {
4558
4559}
4560// Options: [{"tags":{"summary":true}}]
4561
4562/**
4563 * Foo.
4564 *
4565 * @author Somebody
4566 */
4567function quux () {
4568
4569}
4570// Options: [{"tags":{"author":".+"}}]
4571
4572/**
4573 * Foo.
4574 *
4575 * @x-tag something
4576 */
4577function quux () {
4578
4579}
4580// Options: [{"tags":{"x-tag":".+"}}]
4581
4582/**
4583 * Foo.
4584 *
4585 * @prop foo Foo.
4586 */
4587function quux (foo) {
4588
4589}
4590// Options: [{"tags":{"prop":true}}]
4591
4592/**
4593 * @param foo Foo bar.
4594 */
4595function quux (foo) {
4596
4597}
4598// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
4599
4600/**
4601 *
4602 */
4603function quux () {
4604
4605}
4606// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
4607````
4608
4609
4610<a name="eslint-plugin-jsdoc-rules-newline-after-description"></a>
4611### <code>newline-after-description</code>
4612
4613Enforces a consistent padding of the block description.
4614
4615<a name="eslint-plugin-jsdoc-rules-newline-after-description-options-9"></a>
4616#### Options
4617
4618This 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"`.
4619
4620|||
4621|---|---|
4622|Context|everywhere|
4623|Options|(a string matching `"always"|"never"`)|
4624|Tags|N/A (doc block)|
4625
4626The following patterns are considered problems:
4627
4628````js
4629/**
4630 * Foo.
4631 *
4632 * Foo.
4633 * @foo
4634 */
4635function quux () {
4636
4637}
4638// Options: ["always"]
4639// Message: There must be a newline after the description of the JSDoc block.
4640
4641/**
4642 * Foo.
4643 * @foo
4644 *
4645 * Foo.
4646 */
4647function quux () {
4648
4649}
4650// Options: ["always"]
4651// Message: There must be a newline after the description of the JSDoc block.
4652
4653/**
4654 * Foo.
4655 *
4656 * Foo.
4657 * @foo
4658 */
4659function quux () {
4660
4661}
4662// Message: There must be a newline after the description of the JSDoc block.
4663
4664/**
4665 * Bar.
4666 *
4667 * Bar.
4668 *
4669 * @bar
4670 */
4671function quux () {
4672
4673}
4674// Options: ["never"]
4675// Message: There must be no newline after the description of the JSDoc block.
4676
4677/**
4678 * Bar.
4679 *
4680 * @bar
4681 *
4682 * Bar.
4683 */
4684function quux () {
4685
4686}
4687// Options: ["never"]
4688// Message: There must be no newline after the description of the JSDoc block.
4689
4690
4691 /**
4692 * Bar.
4693 *
4694 * Bar.
4695 *
4696 * @bar
4697 */
4698 function quux () {
4699
4700 }
4701// Options: ["never"]
4702// Message: There must be no newline after the description of the JSDoc block.
4703
4704/**
4705 * A.
4706 *
4707 * @typedef {object} A
4708 * @prop {boolean} a A.
4709 */
4710// Options: ["never"]
4711// Message: There must be no newline after the description of the JSDoc block.
4712
4713/**
4714 * A.
4715 * @typedef {object} A
4716 * @prop {boolean} a A.
4717 */
4718// Options: ["always"]
4719// Message: There must be a newline after the description of the JSDoc block.
4720
4721
4722 /**
4723 * Service for fetching symbols.
4724 * @param {object} $http - Injected http helper.
4725 * @param {object} $q - Injected Promise api helper.
4726 * @param {object} $location - Injected window location object.
4727 * @param {object} REPORT_DIALOG_CONSTANTS - Injected handle.
4728 */
4729// Message: There must be a newline after the description of the JSDoc block.
4730````
4731
4732The following patterns are not considered problems:
4733
4734````js
4735/**
4736 * Foo.
4737 */
4738function quux () {
4739
4740}
4741// Options: ["always"]
4742
4743/**
4744 * Bar.
4745 */
4746function quux () {
4747
4748}
4749// Options: ["never"]
4750
4751/**
4752 * Foo.
4753 *
4754 * @foo
4755 */
4756function quux () {
4757
4758}
4759// Options: ["always"]
4760
4761/**
4762 * Bar.
4763 * @bar
4764 */
4765function quux () {
4766
4767}
4768// Options: ["never"]
4769
4770
4771 /**
4772 * @foo
4773 * Test 
4774 * abc 
4775 * @bar 
4776 */
4777
4778
4779 /**
4780 *
4781 * @foo
4782 * Test 
4783 * abc 
4784 * @bar 
4785 */
4786
4787/***
4788 *
4789 */
4790function quux () {
4791
4792}
4793// Options: ["always"]
4794
4795/**
4796 * Parses query string to object containing URL parameters
4797 *
4798 * @param queryString
4799 * Input string
4800 *
4801 * @returns
4802 * Object containing URL parameters
4803 */
4804export function parseQueryString(queryString: string): { [key: string]: string } { // <-- Line 10 that fails
4805
4806}
4807````
4808
4809
4810<a name="eslint-plugin-jsdoc-rules-no-types"></a>
4811### <code>no-types</code>
4812
4813This rule reports types being used on `@param` or `@returns`.
4814
4815The rule is intended to prevent the indication of types on tags where
4816the type information would be redundant with TypeScript.
4817
4818|||
4819|---|---|
4820|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
4821|Tags|`param`, `returns`|
4822|Aliases|`arg`, `argument`, `return`|
4823
4824The following patterns are considered problems:
4825
4826````js
4827/**
4828 * @param {number} foo
4829 */
4830function quux (foo) {
4831
4832}
4833// Message: Types are not permitted on @param.
4834
4835/**
4836 * @returns {number}
4837 */
4838function quux () {
4839
4840}
4841// Message: Types are not permitted on @returns.
4842````
4843
4844The following patterns are not considered problems:
4845
4846````js
4847/**
4848 * @param foo
4849 */
4850function quux (foo) {
4851
4852}
4853````
4854
4855
4856<a name="eslint-plugin-jsdoc-rules-no-undefined-types"></a>
4857### <code>no-undefined-types</code>
4858
4859Checks that types in jsdoc comments are defined. This can be used to check
4860unimported types.
4861
4862When enabling this rule, types in jsdoc comments will resolve as used
4863variables, i.e. will not be marked as unused by `no-unused-vars`.
4864
4865In addition to considering globals found in code (or in ESLint-indicated
4866`globals`) as defined, the following tags will also be checked for
4867name(path) definitions to also serve as a potential "type" for checking
4868the tag types in the table below:
4869
4870`@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`.
4871
4872The following tags will also be checked but only when the mode is `closure`:
4873
4874`@package`, `@private`, `@protected`, `@public`, `@static`
4875
4876The following types are always considered defined.
4877
4878- `null`, `undefined`, `void`, `string`, `boolean`, `object`, `function`
4879- `number`, `NaN`, `Infinity`
4880- `any`, `*`
4881- `Array`, `Object`, `RegExp`, `Date`, `Function`
4882
4883Note that preferred types indicated within `settings.jsdoc.preferredTypes` will
4884also be assumed to be defined.
4885
4886<a name="eslint-plugin-jsdoc-rules-no-undefined-types-options-10"></a>
4887#### Options
4888
4889An option object may have the following key:
4890
4891- `definedTypes` - This array can be populated to indicate other types which
4892 are automatically considered as defined (in addition to globals, etc.).
4893 Defaults to an empty array.
4894
4895|||
4896|---|---|
4897|Context|everywhere|
4898|Tags|`augments`, `class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
4899|Aliases|`constructor`, `const`, `extends`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
4900|Closure-only|`package`, `private`, `protected`, `public`, `static`|
4901|Options|`definedTypes`|
4902|Settings|`preferredTypes`, `mode`|
4903
4904The following patterns are considered problems:
4905
4906````js
4907/**
4908 * @param {HerType} baz - Foo.
4909 */
4910function quux(foo, bar, baz) {
4911
4912}
4913// Settings: {"jsdoc":{"preferredTypes":{"HerType":1000}}}
4914// Message: Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.
4915
4916/**
4917 * @param {HerType} baz - Foo.
4918 */
4919function quux(foo, bar, baz) {
4920
4921}
4922// Settings: {"jsdoc":{"preferredTypes":{"HerType":false}}}
4923// Message: The type 'HerType' is undefined.
4924
4925/**
4926 * @param {strnig} foo - Bar.
4927 */
4928function quux(foo) {
4929
4930}
4931// Message: The type 'strnig' is undefined.
4932
4933/**
4934 * @param {MyType} foo - Bar.
4935 * @param {HisType} bar - Foo.
4936 */
4937function quux(foo, bar) {
4938
4939}
4940// Options: [{"definedTypes":["MyType"]}]
4941// Message: The type 'HisType' is undefined.
4942
4943/**
4944 * @param {MyType} foo - Bar.
4945 * @param {HisType} bar - Foo.
4946 * @param {HerType} baz - Foo.
4947 */
4948function quux(foo, bar, baz) {
4949
4950}
4951// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"}}}}
4952// Options: [{"definedTypes":["MyType"]}]
4953// Message: The type 'HisType' is undefined.
4954
4955 /**
4956 * @param {MyType} foo - Bar.
4957 * @param {HisType} bar - Foo.
4958 * @param {HerType} baz - Foo.
4959 */
4960function quux(foo, bar, baz) {
4961
4962}
4963// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":false},"histype":"HisType"}}}
4964// Options: [{"definedTypes":["MyType"]}]
4965// Message: The type 'HerType' is undefined.
4966
4967/**
4968 * @template TEMPLATE_TYPE
4969 * @param {WRONG_TEMPLATE_TYPE} bar
4970 */
4971function foo (bar) {
4972};
4973// Settings: {"jsdoc":{"mode":"closure"}}
4974// Message: The type 'WRONG_TEMPLATE_TYPE' is undefined.
4975
4976class Foo {
4977 /**
4978 * @return {TEMPLATE_TYPE}
4979 */
4980 bar () {
4981 }
4982}
4983// Message: The type 'TEMPLATE_TYPE' is undefined.
4984
4985class Foo {
4986 /**
4987 * @return {TEMPLATE_TYPE}
4988 */
4989 invalidTemplateReference () {
4990 }
4991}
4992
4993/**
4994 * @template TEMPLATE_TYPE
4995 */
4996class Bar {
4997 /**
4998 * @return {TEMPLATE_TYPE}
4999 */
5000 validTemplateReference () {
5001 }
5002}
5003// Settings: {"jsdoc":{"mode":"typescript"}}
5004// Message: The type 'TEMPLATE_TYPE' is undefined.
5005
5006/**
5007 * @type {strnig}
5008 */
5009var quux = {
5010
5011};
5012// Message: The type 'strnig' is undefined.
5013
5014/**
5015 * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
5016 */
5017class Foo {
5018 /**
5019 * @param {TEMPLATE_TYPE_A} baz
5020 * @return {TEMPLATE_TYPE_B}
5021 */
5022 bar (baz) {
5023 }
5024}
5025// Message: The type 'TEMPLATE_TYPE_A' is undefined.
5026
5027/**
5028 * @param {...VAR_TYPE} varargs
5029 */
5030function quux (varargs) {
5031}
5032// Message: The type 'VAR_TYPE' is undefined.
5033
5034/**
5035 * @this {Navigator}
5036 */
5037function quux () {}
5038// Settings: {"jsdoc":{"mode":"closure"}}
5039// Message: The type 'Navigator' is undefined.
5040
5041/**
5042 * @export {SomeType}
5043 */
5044function quux () {}
5045// Settings: {"jsdoc":{"mode":"closure"}}
5046// Message: The type 'SomeType' is undefined.
5047````
5048
5049The following patterns are not considered problems:
5050
5051````js
5052/**
5053 * @param {string} foo - Bar.
5054 */
5055function quux(foo) {
5056
5057}
5058
5059/**
5060 * @param {Promise} foo - Bar.
5061 */
5062function quux(foo) {
5063
5064}
5065
5066class MyClass {}
5067
5068/**
5069 * @param {MyClass} foo - Bar.
5070 */
5071function quux(foo) {
5072 console.log(foo);
5073}
5074
5075quux(0);
5076
5077const MyType = require('my-library').MyType;
5078
5079/**
5080 * @param {MyType} foo - Bar.
5081 */
5082 function quux(foo) {
5083
5084}
5085
5086const MyType = require('my-library').MyType;
5087
5088/**
5089 * @param {MyType} foo - Bar.
5090 */
5091 function quux(foo) {
5092
5093}
5094
5095import {MyType} from 'my-library';
5096
5097/**
5098 * @param {MyType} foo - Bar.
5099 * @param {object<string, number>} foo
5100 * @param {Array<string>} baz
5101 */
5102 function quux(foo, bar, baz) {
5103
5104}
5105
5106/*globals MyType*/
5107
5108/**
5109 * @param {MyType} foo - Bar.
5110 * @param {HisType} bar - Foo.
5111 */
5112 function quux(foo, bar) {
5113
5114}
5115
5116/**
5117 * @typedef {object} hello
5118 * @property {string} a - a.
5119 */
5120
5121/**
5122 * @param {hello} foo
5123 */
5124function quux(foo) {
5125
5126}
5127
5128/**
5129 * @param {Array<syntaxError} foo
5130 */
5131function quux(foo) {
5132
5133}
5134
5135/**
5136 * Callback test.
5137 *
5138 * @callback addStuffCallback
5139 * @param {String} sum - An test integer.
5140 */
5141/**
5142 * Test Eslint.
5143 *
5144 * @param {addStuffCallback} callback - A callback to run.
5145 */
5146function testFunction(callback) {
5147 callback();
5148}
5149
5150/**
5151 *
5152 *
5153 */
5154function foo () {
5155
5156}
5157
5158/**
5159 *
5160 *
5161 */
5162function foo () {
5163
5164}
5165
5166/**
5167 * @param {MyType} foo - Bar.
5168 * @param {HisType} bar - Foo.
5169 */
5170function quux(foo, bar) {
5171
5172}
5173// Options: [{"definedTypes":["MyType","HisType"]}]
5174
5175/**
5176 * @param {MyType} foo - Bar.
5177 * @param {HisType} bar - Foo.
5178 * @param {HerType} baz - Foo.
5179 */
5180function quux(foo, bar, baz) {
5181
5182}
5183// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"},"histype":"HisType"}}}
5184// Options: [{"definedTypes":["MyType"]}]
5185
5186/**
5187 * @param {MyType} foo - Bar.
5188 * @param {HisType} bar - Foo.
5189 * @param {HerType} baz - Foo.
5190 */
5191function quux(foo, bar, baz) {
5192
5193}
5194// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType<>"},"histype":"HisType.<>"}}}
5195// Options: [{"definedTypes":["MyType"]}]
5196
5197/**
5198 * @template TEMPLATE_TYPE
5199 * @param {TEMPLATE_TYPE} bar
5200 * @return {TEMPLATE_TYPE}
5201 */
5202function foo (bar) {
5203};
5204// Settings: {"jsdoc":{"mode":"closure"}}
5205
5206/**
5207 * @template TEMPLATE_TYPE
5208 */
5209class Foo {
5210 /**
5211 * @return {TEMPLATE_TYPE}
5212 */
5213 bar () {
5214 }
5215}
5216// Settings: {"jsdoc":{"mode":"closure"}}
5217
5218/**
5219 * @template TEMPLATE_TYPE
5220 */
5221class Foo {
5222 /**
5223 * @return {TEMPLATE_TYPE}
5224 */
5225 bar () {}
5226
5227 /**
5228 * @return {TEMPLATE_TYPE}
5229 */
5230 baz () {}
5231}
5232// Settings: {"jsdoc":{"mode":"closure"}}
5233
5234/**
5235 * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
5236 */
5237class Foo {
5238 /**
5239 * @param {TEMPLATE_TYPE_A} baz
5240 * @return {TEMPLATE_TYPE_B}
5241 */
5242 bar (baz) {
5243 }
5244}
5245// Settings: {"jsdoc":{"mode":"closure"}}
5246
5247/****/
5248
5249/**
5250 *
5251 */
5252function quux () {
5253
5254}
5255
5256/**
5257 * Run callback when hooked method is called.
5258 *
5259 * @template {BaseObject} T
5260 * @param {T} obj - object whose method should be hooked.
5261 * @param {string} method - method which should be hooked.
5262 * @param {(sender: T) => void} callback - callback which should
5263 * be called when the hooked method was invoked.
5264 */
5265function registerEvent(obj, method, callback) {
5266
5267}
5268// Settings: {"jsdoc":{"mode":"typescript"}}
5269
5270 /**
5271 * @param {...} varargs
5272 */
5273function quux (varargs) {
5274}
5275
5276/**
5277 * @param {...number} varargs
5278 */
5279function quux (varargs) {
5280}
5281
5282class Navigator {}
5283/**
5284 * @this {Navigator}
5285 */
5286function quux () {}
5287// Settings: {"jsdoc":{"mode":"closure"}}
5288
5289class SomeType {}
5290/**
5291 * @export {SomeType}
5292 */
5293function quux () {}
5294// Settings: {"jsdoc":{"mode":"closure"}}
5295````
5296
5297
5298<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence"></a>
5299### <code>require-description-complete-sentence</code>
5300
5301Requires that block description, explicit `@description`, and `@param`/`@returns`
5302tag descriptions are written in complete sentences, i.e.,
5303
5304* Description must start with an uppercase alphabetical character.
5305* Paragraphs must start with an uppercase alphabetical character.
5306* Sentences must end with a period.
5307* Every line in a paragraph (except the first) which starts with an uppercase
5308 character must be preceded by a line ending with a period.
5309* A colon or semi-colon followed by two line breaks is still part of the
5310 containing paragraph (unlike normal dual line breaks).
5311* Text within inline tags `{...}` are not checked for sentence divisions.
5312* Periods after items within the `abbreviations` option array are not treated
5313 as sentence endings.
5314
5315<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-11"></a>
5316#### Options
5317
5318<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-11-tags-2"></a>
5319##### <code>tags</code>
5320
5321If you want additional tags to be checked for their descriptions, you may
5322add them within this option.
5323
5324```js
5325{
5326 'jsdoc/require-description-complete-sentence': ['error', {tags: ['see', 'copyright']}]
5327}
5328```
5329
5330The tags `@param`/`@arg`/`@argument` and `@property`/`@prop` will be properly
5331parsed to ensure that the checked "description" text includes only the text
5332after the name.
5333
5334All other tags will treat the text following the tag name, a space, and
5335an optional curly-bracketed type expression (and another space) as part of
5336its "description" (e.g., for `@returns {someType} some description`, the
5337description is `some description` while for `@some-tag xyz`, the description
5338is `xyz`).
5339
5340<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-11-abbreviations"></a>
5341##### <code>abbreviations</code>
5342
5343You can provide an `abbreviations` options array to avoid such strings of text
5344being treated as sentence endings when followed by dots. The `.` is not
5345necessary at the end of the array items.
5346
5347|||
5348|---|---|
5349|Context|everywhere|
5350|Tags|doc block, `param`, `returns`, `description`, `property`, `summary`, `file`, `classdesc`, `todo`, `deprecated`, `throws`, 'yields' and others added by `tags`|
5351|Aliases|`arg`, `argument`, `return`, `desc`, `prop`, `fileoverview`, `overview`, `exception`, `yield`|
5352|Options|`tags`, `abbreviations`|
5353The following patterns are considered problems:
5354
5355````js
5356/**
5357 * foo.
5358 */
5359function quux () {
5360
5361}
5362// Message: Sentence should start with an uppercase character.
5363
5364/**
5365 * foo?
5366 */
5367function quux () {
5368
5369}
5370// Message: Sentence should start with an uppercase character.
5371
5372/**
5373 * @description foo.
5374 */
5375function quux () {
5376
5377}
5378// Message: Sentence should start with an uppercase character.
5379
5380/**
5381 * Foo)
5382 */
5383function quux () {
5384
5385}
5386// Message: Sentence must end with a period.
5387
5388/**
5389 * `foo` is a variable
5390 */
5391function quux () {
5392
5393}
5394// Message: Sentence must end with a period.
5395
5396/**
5397 * Foo.
5398 *
5399 * foo.
5400 */
5401function quux () {
5402
5403}
5404// Message: Sentence should start with an uppercase character.
5405
5406/**
5407 * тест.
5408 */
5409function quux () {
5410
5411}
5412// Message: Sentence should start with an uppercase character.
5413
5414/**
5415 * Foo
5416 */
5417function quux () {
5418
5419}
5420// Message: Sentence must end with a period.
5421
5422/**
5423 * Foo
5424 * Bar.
5425 */
5426function quux () {
5427
5428}
5429// Message: A line of text is started with an uppercase character, but preceding line does not end the sentence.
5430
5431/**
5432 * Foo.
5433 *
5434 * @param foo foo.
5435 */
5436function quux (foo) {
5437
5438}
5439// Message: Sentence should start with an uppercase character.
5440
5441/**
5442 * Foo.
5443 *
5444 * @param foo bar
5445 */
5446function quux (foo) {
5447
5448}
5449// Message: Sentence should start with an uppercase character.
5450
5451/**
5452 * {@see Foo.bar} buz
5453 */
5454function quux (foo) {
5455
5456}
5457// Message: Sentence should start with an uppercase character.
5458
5459/**
5460 * Foo.
5461 *
5462 * @returns {number} foo
5463 */
5464function quux (foo) {
5465
5466}
5467// Message: Sentence should start with an uppercase character.
5468
5469/**
5470 * Foo.
5471 *
5472 * @returns foo.
5473 */
5474function quux (foo) {
5475
5476}
5477// Message: Sentence should start with an uppercase character.
5478
5479/**
5480 * lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque elit diam,
5481 * iaculis eu dignissim sed, ultrices sed nisi. nulla at ligula auctor, consectetur neque sed,
5482 * tincidunt nibh. vivamus sit amet vulputate ligula. vivamus interdum elementum nisl,
5483 * vitae rutrum tortor semper ut. morbi porta ante vitae dictum fermentum.
5484 * proin ut nulla at quam convallis gravida in id elit. sed dolor mauris, blandit quis ante at,
5485 * consequat auctor magna. duis pharetra purus in porttitor mollis.
5486 */
5487function longDescription (foo) {
5488
5489}
5490// Message: Sentence should start with an uppercase character.
5491
5492/**
5493 * @arg {number} foo - Foo
5494 */
5495function quux (foo) {
5496
5497}
5498// Message: Sentence must end with a period.
5499
5500/**
5501 * @argument {number} foo - Foo
5502 */
5503function quux (foo) {
5504
5505}
5506// Message: Sentence must end with a period.
5507
5508/**
5509 * @return {number} foo
5510 */
5511function quux (foo) {
5512
5513}
5514// Message: Sentence should start with an uppercase character.
5515
5516/**
5517 * Returns bar.
5518 *
5519 * @return {number} bar
5520 */
5521function quux (foo) {
5522
5523}
5524// Message: Sentence should start with an uppercase character.
5525
5526/**
5527 * @throws {object} Hello World
5528 * hello world
5529*/
5530// Message: Sentence must end with a period.
5531
5532/**
5533 * @summary Foo
5534 */
5535function quux () {
5536
5537}
5538// Message: Sentence must end with a period.
5539
5540/**
5541 * @throws {SomeType} Foo
5542 */
5543function quux () {
5544
5545}
5546// Message: Sentence must end with a period.
5547
5548/**
5549 * @see Foo
5550 */
5551function quux () {
5552
5553}
5554// Options: [{"tags":["see"]}]
5555// Message: Sentence must end with a period.
5556
5557/**
5558 * @param foo Foo bar
5559 */
5560function quux (foo) {
5561
5562}
5563// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5564// Options: [{"tags":["param"]}]
5565// Message: Sentence must end with a period.
5566
5567/**
5568 * Sorry, but this isn't a complete sentence, Mr.
5569 */
5570function quux () {
5571
5572}
5573// Options: [{"abbreviations":["Mr"]}]
5574// Message: Sentence must end with a period.
5575
5576/**
5577 * Sorry, but this isn't a complete sentence Mr.
5578 */
5579function quux () {
5580
5581}
5582// Options: [{"abbreviations":["Mr."]}]
5583// Message: Sentence must end with a period.
5584
5585/**
5586 * Sorry, but this isn't a complete sentence Mr.
5587 */
5588function quux () {
5589
5590}
5591// Options: [{"abbreviations":["Mr"]}]
5592// Message: Sentence must end with a period.
5593
5594/**
5595 * Sorry, but this isn't a complete sentence Mr. and Mrs.
5596 */
5597function quux () {
5598
5599}
5600// Options: [{"abbreviations":["Mr","Mrs"]}]
5601// Message: Sentence must end with a period.
5602
5603/**
5604 * This is a complete sentence. But this isn't, Mr.
5605 */
5606function quux () {
5607
5608}
5609// Options: [{"abbreviations":["Mr"]}]
5610// Message: Sentence must end with a period.
5611
5612/**
5613 * This is a complete Mr. sentence. But this isn't, Mr.
5614 */
5615function quux () {
5616
5617}
5618// Options: [{"abbreviations":["Mr"]}]
5619// Message: Sentence must end with a period.
5620
5621/**
5622 * This is a complete Mr. sentence.
5623 */
5624function quux () {
5625
5626}
5627// Message: Sentence should start with an uppercase character.
5628
5629/**
5630 * This is fun, i.e. enjoyable, but not superlatively so, e.g. not
5631 * super, wonderful, etc..
5632 */
5633function quux () {
5634
5635}
5636// Message: Sentence should start with an uppercase character.
5637
5638/**
5639 * Do not have dynamic content; e.g. homepage. Here a simple unique id
5640 * suffices.
5641 */
5642 function quux () {
5643
5644 }
5645// Message: Sentence should start with an uppercase character.
5646````
5647
5648The following patterns are not considered problems:
5649
5650````js
5651/**
5652 * @param foo - Foo.
5653 */
5654function quux () {
5655
5656}
5657
5658/**
5659 * Foo.
5660 */
5661function quux () {
5662
5663}
5664
5665/**
5666 * Foo.
5667 * Bar.
5668 */
5669function quux () {
5670
5671}
5672
5673/**
5674 * Foo.
5675 *
5676 * Bar.
5677 */
5678function quux () {
5679
5680}
5681
5682/**
5683 * Тест.
5684 */
5685function quux () {
5686
5687}
5688
5689/**
5690 * Foo
5691 * bar.
5692 */
5693function quux () {
5694
5695}
5696
5697/**
5698 * @returns Foo bar.
5699 */
5700function quux () {
5701
5702}
5703
5704/**
5705 * Foo. {@see Math.sin}.
5706 */
5707function quux () {
5708
5709}
5710
5711/**
5712 * Foo {@see Math.sin} bar.
5713 */
5714function quux () {
5715
5716}
5717
5718/**
5719 * Foo?
5720 *
5721 * Bar!
5722 *
5723 * Baz:
5724 * 1. Foo.
5725 * 2. Bar.
5726 */
5727function quux () {
5728
5729}
5730
5731/**
5732 * Hello:
5733 * World.
5734 */
5735function quux () {
5736
5737}
5738
5739/**
5740 * Hello: world.
5741 */
5742function quux () {
5743
5744}
5745
5746/**
5747 *
5748 */
5749function quux () {
5750
5751}
5752
5753/**
5754 * @description Foo.
5755 */
5756function quux () {
5757
5758}
5759
5760/**
5761 * `foo` is a variable.
5762 */
5763function quux () {
5764
5765}
5766
5767/**
5768 * Foo.
5769 *
5770 * `foo`.
5771 */
5772function quux () {
5773
5774}
5775
5776/**
5777 * @param foo - `bar`.
5778 */
5779function quux () {
5780
5781}
5782
5783/**
5784 * @returns {number} `foo`.
5785 */
5786function quux () {
5787
5788}
5789
5790/**
5791 * Foo
5792 * `bar`.
5793 */
5794function quux () {
5795
5796}
5797
5798/**
5799 * @example Foo
5800 */
5801function quux () {
5802
5803}
5804
5805/**
5806 * @see Foo
5807 */
5808function quux () {
5809
5810}
5811
5812/**
5813 * Foo.
5814 *
5815 * @param foo Foo.
5816 */
5817function quux (foo) {
5818
5819}
5820
5821/**
5822 * Foo.
5823 *
5824 * @param foo Foo.
5825 */
5826function quux (foo) {
5827
5828}
5829// Options: [{"tags":["param"]}]
5830
5831/**
5832 * @param foo Foo bar.
5833 */
5834function quux (foo) {
5835
5836}
5837// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5838// Options: [{"tags":["param"]}]
5839
5840/**
5841 *
5842 */
5843function quux (foo) {
5844
5845}
5846// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5847
5848/**
5849* We stop loading Items when we have loaded:
5850*
5851* 1) The main Item;
5852* 2) All its variants.
5853*/
5854
5855/**
5856 * This method is working on 2 steps.
5857 *
5858 * | Step | Comment |
5859 * |------|-------------|
5860 * | 1 | do it |
5861 * | 2 | do it again |
5862 */
5863
5864/**
5865 * This is something that
5866 * I want to test.
5867 */
5868function quux () {
5869
5870}
5871
5872/**
5873 * When making HTTP requests, the
5874 * URL is super important.
5875 */
5876function quux () {
5877
5878}
5879
5880/**
5881 * Sorry, but this isn't a complete sentence, Mr.
5882 */
5883function quux () {
5884
5885}
5886
5887/**
5888 * Sorry, but this isn't a complete sentence Mr..
5889 */
5890function quux () {
5891
5892}
5893// Options: [{"abbreviations":["Mr."]}]
5894
5895/**
5896 * Sorry, but this isn't a complete sentence Mr.
5897 */
5898function quux () {
5899
5900}
5901
5902/**
5903 * Sorry, but this isn't a complete sentence Mr. and Mrs..
5904 */
5905function quux () {
5906
5907}
5908// Options: [{"abbreviations":["Mr","Mrs"]}]
5909
5910/**
5911 * This is a complete sentence aMr.
5912 */
5913function quux () {
5914
5915}
5916// Options: [{"abbreviations":["Mr"]}]
5917
5918/**
5919 * This is a complete sentence. But this isn't, Mr.
5920 */
5921function quux () {
5922
5923}
5924
5925/**
5926 * This is a complete Mr. Sentence. But this isn't, Mr.
5927 */
5928function quux () {
5929
5930}
5931
5932/**
5933 * This is a complete Mr. sentence.
5934 */
5935function quux () {
5936
5937}
5938// Options: [{"abbreviations":["Mr"]}]
5939
5940/**
5941 * This is fun, i.e. enjoyable, but not superlatively so, e.g. not
5942 * super, wonderful, etc..
5943 */
5944function quux () {
5945
5946}
5947// Options: [{"abbreviations":["etc","e.g.","i.e."]}]
5948
5949
5950**
5951* Do not have dynamic content; e.g. homepage. Here a simple unique id
5952* suffices.
5953*/
5954function quux () {
5955
5956}
5957// Options: [{"abbreviations":["etc","e.g.","i.e."]}]
5958````
5959
5960
5961<a name="eslint-plugin-jsdoc-rules-require-description"></a>
5962### <code>require-description</code>
5963
5964Requires that all functions have a description.
5965
5966* All functions must have an implicit description or have the option
5967 `descriptionStyle` set to `tag`.
5968* Every jsdoc block description (or description tag if `descriptionStyle` is
5969 `"tag"`) must have a non-empty description that explains the purpose of the
5970 method.
5971
5972<a name="eslint-plugin-jsdoc-rules-require-description-options-12"></a>
5973#### Options
5974
5975An options object may have any of the following properties:
5976
5977- `contexts` - Set to an array of strings representing the AST context
5978 where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6
5979 classes). Overrides the default contexts (see below). Set to `"any"` if
5980 you want the rule to apply to any jsdoc block throughout your files.
5981- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the
5982 document block avoids the need for a `@description`. Defaults to an
5983 empty array.
5984- `descriptionStyle` - Whether to accept implicit descriptions (`"body"`) or
5985 `@description` tags (`"tag"`) as satisfying the rule. Set to `"any"` to
5986 accept either style. Defaults to `"body"`.
5987
5988|||
5989|---|---|
5990|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
5991|Tags|`description` or jsdoc block|
5992|Aliases|`desc`|
5993|Options|`contexts`, `exemptedBy`, `descriptionStyle`|
5994|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
5995
5996The following patterns are considered problems:
5997
5998````js
5999/**
6000 *
6001 */
6002function quux () {
6003
6004}
6005// Options: [{"descriptionStyle":"tag"}]
6006// Message: Missing JSDoc @description declaration.
6007
6008/**
6009 *
6010 */
6011function quux () {
6012
6013}
6014// Options: [{"descriptionStyle":"any"}]
6015// Message: Missing JSDoc block description or @description declaration.
6016
6017/**
6018 *
6019 */
6020function quux () {
6021
6022}
6023// Options: [{"descriptionStyle":"body"}]
6024// Message: Missing JSDoc block description.
6025
6026/**
6027 *
6028 */
6029class quux {
6030
6031}
6032// Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
6033// Message: Missing JSDoc @description declaration.
6034
6035/**
6036 *
6037 */
6038// Options: [{"contexts":["any"],"descriptionStyle":"tag"}]
6039// Message: Missing JSDoc @description declaration.
6040
6041/**
6042 *
6043 */
6044class quux {
6045
6046}
6047// Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
6048// Message: Missing JSDoc @description declaration.
6049
6050/**
6051 *
6052 */
6053class quux {
6054
6055}
6056// Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
6057// Message: Missing JSDoc @description declaration.
6058
6059/**
6060 * @description
6061 */
6062function quux () {
6063
6064}
6065// Options: [{"descriptionStyle":"tag"}]
6066// Message: Missing JSDoc @description description.
6067
6068/**
6069 *
6070 */
6071interface quux {
6072
6073}
6074// Options: [{"contexts":["TSInterfaceDeclaration"],"descriptionStyle":"tag"}]
6075// Message: Missing JSDoc @description declaration.
6076
6077/**
6078 *
6079 */
6080var quux = class {
6081
6082};
6083// Options: [{"contexts":["ClassExpression"],"descriptionStyle":"tag"}]
6084// Message: Missing JSDoc @description declaration.
6085
6086/**
6087 *
6088 */
6089var quux = {
6090
6091};
6092// Options: [{"contexts":["ObjectExpression"],"descriptionStyle":"tag"}]
6093// Message: Missing JSDoc @description declaration.
6094
6095/**
6096 * @someDesc
6097 */
6098function quux () {
6099
6100}
6101// Settings: {"jsdoc":{"tagNamePreference":{"description":{"message":"Please avoid `{{tagName}}`; use `{{replacement}}` instead","replacement":"someDesc"}}}}
6102// Options: [{"descriptionStyle":"tag"}]
6103// Message: Missing JSDoc @someDesc description.
6104
6105/**
6106 * @description
6107 */
6108function quux () {
6109
6110}
6111// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
6112// Options: [{"descriptionStyle":"tag"}]
6113// Message: Unexpected tag `@description`
6114
6115/**
6116 * @description
6117 */
6118function quux () {
6119
6120}
6121// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
6122// Options: [{"descriptionStyle":"any"}]
6123// Message: Missing JSDoc block description or @description declaration.
6124
6125/**
6126 *
6127 */
6128function quux () {
6129}
6130// Options: [{"exemptedBy":["notPresent"]}]
6131// Message: Missing JSDoc block description.
6132````
6133
6134The following patterns are not considered problems:
6135
6136````js
6137/**
6138 *
6139 */
6140
6141/**
6142 * @description
6143 * // arbitrary description content
6144 */
6145function quux () {
6146
6147}
6148// Options: [{"descriptionStyle":"tag"}]
6149
6150/**
6151 * @description
6152 * quux(); // does something useful
6153 */
6154function quux () {
6155
6156}
6157// Options: [{"descriptionStyle":"tag"}]
6158
6159/**
6160 * @description <caption>Valid usage</caption>
6161 * quux(); // does something useful
6162 *
6163 * @description <caption>Invalid usage</caption>
6164 * quux('random unwanted arg'); // results in an error
6165 */
6166function quux () {
6167
6168}
6169// Options: [{"descriptionStyle":"tag"}]
6170
6171/**
6172 *
6173 */
6174class quux {
6175
6176}
6177// Options: [{"descriptionStyle":"tag"}]
6178
6179/**
6180 *
6181 */
6182function quux () {
6183
6184}
6185// Options: [{"contexts":["ClassDeclaration"]}]
6186
6187/**
6188 * @type {MyCallback}
6189 */
6190function quux () {
6191
6192}
6193// Options: [{"exemptedBy":["type"]}]
6194
6195/**
6196 *
6197 */
6198interface quux {
6199
6200}
6201// Options: [{"descriptionStyle":"tag"}]
6202
6203/**
6204 *
6205 */
6206var quux = class {
6207
6208};
6209// Options: [{"descriptionStyle":"tag"}]
6210
6211/**
6212 *
6213 */
6214var quux = {
6215
6216};
6217// Options: [{"descriptionStyle":"tag"}]
6218
6219/**
6220 * Has an implicit description
6221 */
6222function quux () {
6223
6224}
6225// Options: [{"descriptionStyle":"body"}]
6226
6227/**
6228 * Has an implicit description
6229 */
6230function quux () {
6231
6232}
6233
6234/**
6235 * Has an implicit description
6236 */
6237function quux () {
6238
6239}
6240// Options: [{"descriptionStyle":"any"}]
6241
6242/**
6243 * @description Has an explicit description
6244 */
6245function quux () {
6246
6247}
6248// Options: [{"descriptionStyle":"any"}]
6249
6250/**
6251 *
6252 */
6253function quux () {
6254
6255}
6256// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
6257````
6258
6259
6260<a name="eslint-plugin-jsdoc-rules-require-example"></a>
6261### <code>require-example</code>
6262
6263Requires that all functions have examples.
6264
6265* All functions must have one or more `@example` tags.
6266* Every example tag must have a non-empty description that explains the method's usage.
6267
6268<a name="eslint-plugin-jsdoc-rules-require-example-options-13"></a>
6269#### Options
6270
6271This rule has an object option.
6272
6273<a name="eslint-plugin-jsdoc-rules-require-example-options-13-exemptedby"></a>
6274##### <code>exemptedBy</code>
6275
6276Array of tags (e.g., `['type']`) whose presence on the document
6277block avoids the need for an `@example`. Defaults to an empty array.
6278
6279<a name="eslint-plugin-jsdoc-rules-require-example-options-13-avoidexampleonconstructors"></a>
6280##### <code>avoidExampleOnConstructors</code>
6281
6282Set to `true` to avoid the need for an example on a constructor (whether
6283indicated as such by a jsdoc tag or by being within an ES6 `class`).
6284Defaults to `false`.
6285
6286<a name="eslint-plugin-jsdoc-rules-require-example-options-13-contexts-1"></a>
6287##### <code>contexts</code>
6288
6289Set this to an array of strings representing the AST context
6290where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
6291Overrides the default contexts (see below). Set to `"any"` if you want
6292the rule to apply to any jsdoc block throughout your files.
6293
6294<a name="eslint-plugin-jsdoc-rules-require-example-fixer"></a>
6295#### Fixer
6296
6297The fixer for `require-example` will add an empty `@example`, but it will still
6298report a missing example description after this is added.
6299
6300|||
6301|---|---|
6302|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
6303|Tags|`example`|
6304|Options|`exemptedBy`, `avoidExampleOnConstructors`, `contexts`|
6305|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
6306
6307The following patterns are considered problems:
6308
6309````js
6310/**
6311 *
6312 */
6313function quux () {
6314
6315}
6316// Message: Missing JSDoc @example declaration.
6317
6318/**
6319 * @example
6320 */
6321function quux () {
6322
6323}
6324// Message: Missing JSDoc @example description.
6325
6326/**
6327 * @constructor
6328 */
6329function f () {
6330
6331}
6332// Settings: {"jsdoc":{"avoidExampleOnConstructors":true}}
6333// Message: `settings.jsdoc.avoidExampleOnConstructors` has been removed, use options in the rule `require-example` instead.
6334
6335/**
6336 * @constructor
6337 */
6338function quux () {
6339
6340}
6341// Message: Missing JSDoc @example declaration.
6342
6343/**
6344 * @constructor
6345 * @example
6346 */
6347function quux () {
6348
6349}
6350// Message: Missing JSDoc @example description.
6351
6352/**
6353 *
6354 */
6355class quux {
6356
6357}
6358// Options: [{"contexts":["ClassDeclaration"]}]
6359// Message: Missing JSDoc @example declaration.
6360
6361/**
6362 *
6363 */
6364// Options: [{"contexts":["any"]}]
6365// Message: Missing JSDoc @example declaration.
6366
6367/**
6368 *
6369 */
6370function quux () {
6371}
6372// Options: [{"exemptedBy":["notPresent"]}]
6373// Message: Missing JSDoc @example declaration.
6374````
6375
6376The following patterns are not considered problems:
6377
6378````js
6379/**
6380 *
6381 */
6382
6383/**
6384 * @example
6385 * // arbitrary example content
6386 */
6387function quux () {
6388
6389}
6390
6391/**
6392 * @example
6393 * quux(); // does something useful
6394 */
6395function quux () {
6396
6397}
6398
6399/**
6400 * @example <caption>Valid usage</caption>
6401 * quux(); // does something useful
6402 *
6403 * @example <caption>Invalid usage</caption>
6404 * quux('random unwanted arg'); // results in an error
6405 */
6406function quux () {
6407
6408}
6409
6410/**
6411 * @constructor
6412 */
6413function quux () {
6414
6415}
6416// Options: [{"avoidExampleOnConstructors":true}]
6417
6418/**
6419 * @constructor
6420 * @example
6421 */
6422function quux () {
6423
6424}
6425// Options: [{"avoidExampleOnConstructors":true}]
6426
6427class Foo {
6428 /**
6429 *
6430 */
6431 constructor () {
6432
6433 }
6434}
6435// Options: [{"avoidExampleOnConstructors":true}]
6436
6437/**
6438 * @inheritdoc
6439 */
6440function quux () {
6441
6442}
6443
6444/**
6445 * @type {MyCallback}
6446 */
6447function quux () {
6448
6449}
6450// Options: [{"exemptedBy":["type"]}]
6451
6452/**
6453 * @example Some example code
6454 */
6455class quux {
6456
6457}
6458// Options: [{"contexts":["ClassDeclaration"]}]
6459
6460/**
6461 *
6462 */
6463function quux () {
6464
6465}
6466// Options: [{"contexts":["ClassDeclaration"]}]
6467````
6468
6469
6470<a name="eslint-plugin-jsdoc-rules-require-file-overview"></a>
6471### <code>require-file-overview</code>
6472
6473Checks that:
6474
64751. All files have a `@file`, `@fileoverview`, or `@overview` tag.
64762. Duplicate file overview tags within a given file will be reported
64773. File overview tags will be reported which are not, as per
6478 [the docs](https://jsdoc.app/tags-file.html), "at the beginning of
6479 the file"–where beginning of the file is interpreted in this rule
6480 as being when the overview tag is not preceded by anything other than
6481 a comment.
6482
6483<a name="eslint-plugin-jsdoc-rules-require-file-overview-fixer-1"></a>
6484#### Fixer
6485
6486The fixer for `require-example` will add an empty `@file`. Note that if you
6487need to report a missing description for `file`, you can add `file` on
6488the `tags` option with `match-description` (and the `contexts` option
6489set to "any").
6490
6491|||
6492|---|---|
6493|Context|Everywhere|
6494|Tags|`file`|
6495|Aliases|`fileoverview`, `overview`|
6496
6497The following patterns are considered problems:
6498
6499````js
6500
6501// Message: Missing @file
6502
6503/**
6504 *
6505 */
6506// Message: Missing @file
6507
6508/**
6509 *
6510 */
6511function quux () {}
6512// Message: Missing @file
6513
6514/**
6515 *
6516 */
6517function quux () {}
6518// Settings: {"jsdoc":{"tagNamePreference":{"file":"fileoverview"}}}
6519// Message: Missing @fileoverview
6520
6521/**
6522 *
6523 */
6524function quux () {}
6525// Settings: {"jsdoc":{"tagNamePreference":{"file":"overview"}}}
6526// Message: Missing @overview
6527
6528/**
6529 *
6530 */
6531function quux () {}
6532// Settings: {"jsdoc":{"tagNamePreference":{"file":false}}}
6533// Message: `settings.jsdoc.tagNamePreference` cannot block @file for the `require-file-overview` rule
6534
6535/**
6536 *
6537 */
6538function quux () {}
6539// Settings: {"jsdoc":{"tagNamePreference":{"file":{"message":"Don't use file"}}}}
6540// Message: `settings.jsdoc.tagNamePreference` cannot block @file for the `require-file-overview` rule
6541
6542/**
6543 * @param a
6544 */
6545function quux (a) {}
6546// Message: Missing @file
6547
6548/**
6549 * @param a
6550 */
6551function quux (a) {}
6552
6553/**
6554 * @param b
6555 */
6556function bar (b) {}
6557// Message: Missing @file
6558
6559/**
6560 * @file
6561 */
6562
6563 /**
6564 * @file
6565 */
6566// Message: Duplicate @file
6567
6568function quux () {
6569}
6570/**
6571 * @file
6572 */
6573// Message: @file should be at the beginning of the file
6574````
6575
6576The following patterns are not considered problems:
6577
6578````js
6579/**
6580 * @file
6581 */
6582
6583// Ok preceded by comment
6584/**
6585 * @file
6586 */
6587
6588/**
6589 * @fileoverview
6590 */
6591// Settings: {"jsdoc":{"tagNamePreference":{"file":"fileoverview"}}}
6592
6593/**
6594 * @overview
6595 */
6596// Settings: {"jsdoc":{"tagNamePreference":{"file":"overview"}}}
6597
6598/**
6599 * @file Description of file
6600 */
6601
6602/**
6603 * @file Description of file
6604 */
6605function quux () {
6606}
6607
6608/**
6609 *
6610 */
6611````
6612
6613
6614<a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description"></a>
6615### <code>require-hyphen-before-param-description</code>
6616
6617Requires a hyphen before the `@param` description.
6618
6619<a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description-options-14"></a>
6620#### Options
6621
6622This 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"`.
6623
6624|||
6625|---|---|
6626|Context|everywhere|
6627|Tags|`param`|
6628|Aliases|`arg`, `argument`|
6629|Options|(a string matching `"always"|"never"`)|
6630
6631The following patterns are considered problems:
6632
6633````js
6634/**
6635 * @param foo Foo.
6636 */
6637function quux () {
6638
6639}
6640// Options: ["always"]
6641// Message: There must be a hyphen before @param description.
6642
6643/**
6644 * @param foo Foo.
6645 */
6646function quux () {
6647
6648}
6649// Message: There must be a hyphen before @param description.
6650
6651/**
6652 * @param foo - Foo.
6653 */
6654function quux () {
6655
6656}
6657// Options: ["never"]
6658// Message: There must be no hyphen before @param description.
6659
6660/**
6661 * @param foo - foo
6662 * @param foo foo
6663 */
6664function quux () {
6665
6666}
6667// Options: ["always"]
6668// Message: There must be a hyphen before @param description.
6669
6670/**
6671 * @param foo foo
6672 * bar
6673 * @param bar - bar
6674 */
6675function quux () {
6676
6677}
6678// Options: ["always"]
6679// Message: There must be a hyphen before @param description.
6680
6681/**
6682 * @param foo
6683 */
6684function quux (foo) {
6685
6686}
6687// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
6688// Message: Unexpected tag `@param`
6689````
6690
6691The following patterns are not considered problems:
6692
6693````js
6694/**
6695 * @param foo - Foo.
6696 */
6697function quux () {
6698
6699}
6700// Options: ["always"]
6701
6702/**
6703 * @param foo Foo.
6704 */
6705function quux () {
6706
6707}
6708// Options: ["never"]
6709
6710/**
6711 * @param foo
6712 */
6713function quux () {
6714
6715}
6716````
6717
6718
6719<a name="eslint-plugin-jsdoc-rules-require-jsdoc"></a>
6720### <code>require-jsdoc</code>
6721
6722Checks for presence of jsdoc comments, on class declarations as well as
6723functions.
6724
6725<a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-15"></a>
6726#### Options
6727
6728Accepts one optional options object with the following optional keys.
6729
6730- `publicOnly` - This option will insist that missing jsdoc blocks are
6731 only reported for function bodies / class declarations that are exported
6732 from the module. May be a boolean or object. If set to `true`, the defaults
6733 below will be used. If unset, jsdoc block reporting will not be limited to
6734 exports.
6735
6736 This object supports the following optional boolean keys (`false` unless
6737 otherwise noted):
6738
6739 - `ancestorsOnly` - Only check node ancestors to check if node is exported
6740 - `esm` - ESM exports are checked for JSDoc comments (Defaults to `true`)
6741 - `cjs` - CommonJS exports are checked for JSDoc comments (Defaults to `true`)
6742 - `window` - Window global exports are checked for JSDoc comments
6743
6744- `require` - An object with the following optional boolean keys which all
6745 default to `false` except as noted, indicating the contexts where the rule
6746 will apply:
6747
6748 - `ArrowFunctionExpression`
6749 - `ClassDeclaration`
6750 - `ClassExpression`
6751 - `FunctionDeclaration` (defaults to `true`)
6752 - `FunctionExpression`
6753 - `MethodDefinition`
6754
6755- `contexts` - Set this to an array of strings representing the additional
6756 AST contexts where you wish the rule to be applied (e.g., `Property` for
6757 properties). Defaults to an empty array.
6758
6759- `exemptEmptyFunctions` (default: false) - When `true`, the rule will not report
6760 missing jsdoc blocks above functions/methods with no parameters or return values
6761 (intended where variable names are sufficient for themselves as documentation).
6762
6763|||
6764|---|---|
6765|Context|`ArrowFunctionExpression`, `ClassDeclaration`, `ClassExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
6766|Tags|N/A|
6767|Options|`publicOnly`, `require`, `contexts`, `exemptEmptyFunctions`|
6768
6769The following patterns are considered problems:
6770
6771````js
6772/**
6773 * @func myFunction
6774 */
6775function myFunction() {
6776
6777}
6778// Settings: {"jsdoc":{"maxLines":3,"minLines":2}}
6779// Message: Missing JSDoc comment.
6780
6781/**
6782 * @func myFunction
6783 */
6784
6785
6786function myFunction() {
6787
6788}
6789// Settings: {"jsdoc":{"maxLines":2}}
6790// Message: Missing JSDoc comment.
6791
6792/** @func myFunction */ function myFunction() {
6793
6794}
6795// Settings: {"jsdoc":{"minLines":1}}
6796// Message: Missing JSDoc comment.
6797
6798export var test = function () {
6799
6800};
6801// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6802// Message: Missing JSDoc comment.
6803
6804function test () {
6805
6806}
6807export var test2 = test;
6808// Options: [{"publicOnly":true,"require":{"FunctionDeclaration":true}}]
6809// Message: Missing JSDoc comment.
6810
6811export const test = () => {
6812
6813};
6814// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
6815// Message: Missing JSDoc comment.
6816
6817export let test = class {
6818
6819};
6820// Options: [{"publicOnly":true,"require":{"ClassExpression":true}}]
6821// Message: Missing JSDoc comment.
6822
6823export default function () {}
6824// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
6825// Message: Missing JSDoc comment.
6826
6827export default () => {}
6828// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"ArrowFunctionExpression":true}}]
6829// Message: Missing JSDoc comment.
6830
6831export default (function () {})
6832// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
6833// Message: Missing JSDoc comment.
6834
6835export default class {}
6836// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"ClassDeclaration":true}}]
6837// Message: Missing JSDoc comment.
6838
6839function quux (foo) {
6840
6841}
6842// Message: Missing JSDoc comment.
6843
6844
6845// Settings: {"jsdoc":{"exemptEmptyFunctions":true}}
6846// Message: `settings.jsdoc.exemptEmptyFunctions` has been removed, use options in the rule `require-jsdoc` instead.
6847
6848function quux (foo) {
6849
6850}
6851// Options: [{"exemptEmptyFunctions":true}]
6852// Message: Missing JSDoc comment.
6853
6854function quux (foo) {
6855
6856}
6857// Settings: {"jsdoc":{"minLines":2}}
6858// Options: [{"exemptEmptyFunctions":true}]
6859// Message: Missing JSDoc comment.
6860
6861function myFunction() {}
6862// Message: Missing JSDoc comment.
6863
6864/**
6865 * Description for A.
6866 */
6867class A {
6868 constructor(xs) {
6869 this.a = xs;
6870 }
6871}
6872// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6873// Message: Missing JSDoc comment.
6874
6875class A {
6876 /**
6877 * Description for constructor.
6878 * @param {object[]} xs - xs
6879 */
6880 constructor(xs) {
6881 this.a = xs;
6882 }
6883}
6884// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6885// Message: Missing JSDoc comment.
6886
6887class A extends B {
6888 /**
6889 * Description for constructor.
6890 * @param {object[]} xs - xs
6891 */
6892 constructor(xs) {
6893 this.a = xs;
6894 }
6895}
6896// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6897// Message: Missing JSDoc comment.
6898
6899export class A extends B {
6900 /**
6901 * Description for constructor.
6902 * @param {object[]} xs - xs
6903 */
6904 constructor(xs) {
6905 this.a = xs;
6906 }
6907}
6908// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6909// Message: Missing JSDoc comment.
6910
6911export default class A extends B {
6912 /**
6913 * Description for constructor.
6914 * @param {object[]} xs - xs
6915 */
6916 constructor(xs) {
6917 this.a = xs;
6918 }
6919}
6920// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6921// Message: Missing JSDoc comment.
6922
6923var myFunction = () => {}
6924// Options: [{"require":{"ArrowFunctionExpression":true}}]
6925// Message: Missing JSDoc comment.
6926
6927var myFunction = () => () => {}
6928// Options: [{"require":{"ArrowFunctionExpression":true}}]
6929// Message: Missing JSDoc comment.
6930
6931var foo = function() {}
6932// Options: [{"require":{"FunctionExpression":true}}]
6933// Message: Missing JSDoc comment.
6934
6935const foo = {bar() {}}
6936// Options: [{"require":{"FunctionExpression":true}}]
6937// Message: Missing JSDoc comment.
6938
6939var foo = {bar: function() {}}
6940// Options: [{"require":{"FunctionExpression":true}}]
6941// Message: Missing JSDoc comment.
6942
6943function foo (abc) {}
6944// Options: [{"exemptEmptyFunctions":false}]
6945// Message: Missing JSDoc comment.
6946
6947function foo () {
6948 return true;
6949}
6950// Options: [{"exemptEmptyFunctions":false}]
6951// Message: Missing JSDoc comment.
6952
6953module.exports = function quux () {
6954
6955}
6956// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6957// Message: Missing JSDoc comment.
6958
6959module.exports = function quux () {
6960
6961}
6962// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
6963// Message: Missing JSDoc comment.
6964
6965module.exports = {
6966 method: function() {
6967
6968 }
6969}
6970// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6971// Message: Missing JSDoc comment.
6972
6973module.exports = {
6974 test: {
6975 test2: function() {
6976
6977 }
6978 }
6979}
6980// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6981// Message: Missing JSDoc comment.
6982
6983module.exports = {
6984 test: {
6985 test2: function() {
6986
6987 }
6988 }
6989}
6990// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
6991// Message: Missing JSDoc comment.
6992
6993const test = module.exports = function () {
6994
6995}
6996// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6997// Message: Missing JSDoc comment.
6998
6999/**
7000*
7001*/
7002const test = module.exports = function () {
7003
7004}
7005
7006test.prototype.method = function() {}
7007// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7008// Message: Missing JSDoc comment.
7009
7010const test = function () {
7011
7012}
7013module.exports = {
7014 test: test
7015}
7016// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7017// Message: Missing JSDoc comment.
7018
7019const test = () => {
7020
7021}
7022module.exports = {
7023 test: test
7024}
7025// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
7026// Message: Missing JSDoc comment.
7027
7028class Test {
7029 method() {
7030
7031 }
7032}
7033module.exports = Test;
7034// Options: [{"publicOnly":true,"require":{"MethodDefinition":true}}]
7035// Message: Missing JSDoc comment.
7036
7037export default function quux () {
7038
7039}
7040// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7041// Message: Missing JSDoc comment.
7042
7043export default function quux () {
7044
7045}
7046// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7047// Message: Missing JSDoc comment.
7048
7049function quux () {
7050
7051}
7052export default quux;
7053// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7054// Message: Missing JSDoc comment.
7055
7056export function test() {
7057
7058}
7059// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7060// Message: Missing JSDoc comment.
7061
7062export function test() {
7063
7064}
7065// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7066// Message: Missing JSDoc comment.
7067
7068var test = function () {
7069
7070}
7071var test2 = 2;
7072export { test, test2 }
7073// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7074// Message: Missing JSDoc comment.
7075
7076var test = function () {
7077
7078}
7079export { test as test2 }
7080// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7081// Message: Missing JSDoc comment.
7082
7083export default class A {
7084
7085}
7086// Options: [{"publicOnly":true,"require":{"ClassDeclaration":true}}]
7087// Message: Missing JSDoc comment.
7088
7089export default class A {
7090
7091}
7092// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true}}]
7093// Message: Missing JSDoc comment.
7094
7095var test = function () {
7096
7097}
7098// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
7099// Message: Missing JSDoc comment.
7100
7101window.test = function () {
7102
7103}
7104// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
7105// Message: Missing JSDoc comment.
7106
7107function test () {
7108
7109}
7110// Options: [{"publicOnly":{"window":true}}]
7111// Message: Missing JSDoc comment.
7112
7113module.exports = function() {
7114
7115}
7116// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionExpression":true}}]
7117// Message: Missing JSDoc comment.
7118
7119export function someMethod() {
7120
7121}
7122// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
7123// Message: Missing JSDoc comment.
7124
7125export function someMethod() {
7126
7127}
7128// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
7129// Message: Missing JSDoc comment.
7130
7131const myObject = {
7132 myProp: true
7133};
7134// Options: [{"contexts":["Property"]}]
7135// Message: Missing JSDoc comment.
7136````
7137
7138The following patterns are not considered problems:
7139
7140````js
7141/**
7142 *
7143 */
7144
7145var array = [1,2,3];
7146array.forEach(function() {});
7147
7148/**
7149 * @class MyClass
7150 **/
7151function MyClass() {}
7152
7153/**
7154 Function doing something
7155 */
7156function myFunction() {}
7157/**
7158 Function doing something
7159 */
7160var myFunction = function() {};
7161/**
7162 Function doing something
7163 */
7164Object.myFunction = function () {};
7165var obj = {
7166 /**
7167 * Function doing something
7168 **/
7169 myFunction: function () {} };
7170
7171/**
7172 @func myFunction
7173 */
7174function myFunction() {}
7175/**
7176 @method myFunction
7177 */
7178function myFunction() {}
7179/**
7180 @function myFunction
7181 */
7182function myFunction() {}
7183
7184/**
7185 @func myFunction
7186 */
7187var myFunction = function () {}
7188/**
7189 @method myFunction
7190 */
7191var myFunction = function () {}
7192/**
7193 @function myFunction
7194 */
7195var myFunction = function () {}
7196
7197/**
7198 @func myFunction
7199 */
7200Object.myFunction = function() {}
7201/**
7202 @method myFunction
7203 */
7204Object.myFunction = function() {}
7205/**
7206 @function myFunction
7207 */
7208Object.myFunction = function() {}
7209(function(){})();
7210
7211var object = {
7212 /**
7213 * @func myFunction - Some function
7214 */
7215 myFunction: function() {} }
7216var object = {
7217 /**
7218 * @method myFunction - Some function
7219 */
7220 myFunction: function() {} }
7221var object = {
7222 /**
7223 * @function myFunction - Some function
7224 */
7225 myFunction: function() {} }
7226
7227var array = [1,2,3];
7228array.filter(function() {});
7229Object.keys(this.options.rules || {}).forEach(function(name) {}.bind(this));
7230var object = { name: 'key'};
7231Object.keys(object).forEach(function() {})
7232
7233/**
7234 * @func myFunction
7235 */
7236
7237function myFunction() {
7238
7239}
7240// Settings: {"jsdoc":{"maxLines":2,"minLines":0}}
7241
7242/**
7243 * @func myFunction
7244 */
7245
7246
7247function myFunction() {
7248
7249}
7250// Settings: {"jsdoc":{"maxLines":3,"minLines":0}}
7251
7252/** @func myFunction */ function myFunction() {
7253
7254}
7255// Settings: {"jsdoc":{"maxLines":0,"minLines":0}}
7256
7257/**
7258 * @func myFunction
7259 */
7260
7261function myFunction() {
7262
7263}
7264// Settings: {"jsdoc":{"maxLines":3,"minLines":2}}
7265
7266function myFunction() {}
7267// Options: [{"require":{"ClassDeclaration":true,"FunctionDeclaration":false,"MethodDefinition":true}}]
7268
7269var myFunction = function() {}
7270// Options: [{"require":{"ClassDeclaration":true,"FunctionDeclaration":false,"MethodDefinition":true}}]
7271
7272/**
7273 * Description for A.
7274 */
7275class A {
7276 /**
7277 * Description for constructor.
7278 * @param {object[]} xs - xs
7279 */
7280 constructor(xs) {
7281 this.a = xs;
7282 }
7283}
7284// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7285
7286/**
7287 * Description for A.
7288 */
7289class App extends Component {
7290 /**
7291 * Description for constructor.
7292 * @param {object[]} xs - xs
7293 */
7294 constructor(xs) {
7295 this.a = xs;
7296 }
7297}
7298// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7299
7300/**
7301 * Description for A.
7302 */
7303export default class App extends Component {
7304 /**
7305 * Description for constructor.
7306 * @param {object[]} xs - xs
7307 */
7308 constructor(xs) {
7309 this.a = xs;
7310 }
7311}
7312// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7313
7314/**
7315 * Description for A.
7316 */
7317export class App extends Component {
7318 /**
7319 * Description for constructor.
7320 * @param {object[]} xs - xs
7321 */
7322 constructor(xs) {
7323 this.a = xs;
7324 }
7325}
7326// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
7327
7328class A {
7329 constructor(xs) {
7330 this.a = xs;
7331 }
7332}
7333// Options: [{"require":{"ClassDeclaration":false,"MethodDefinition":false}}]
7334
7335/**
7336* Function doing something
7337*/
7338var myFunction = () => {}
7339// Options: [{"require":{"ArrowFunctionExpression":true}}]
7340
7341/**
7342* Function doing something
7343*/
7344var myFunction = function () {}
7345// Options: [{"require":{"ArrowFunctionExpression":true}}]
7346
7347/**
7348* Function doing something
7349*/
7350var myFunction = () => {}
7351// Options: [{"require":{"ArrowFunctionExpression":false}}]
7352
7353/**
7354 Function doing something
7355*/
7356var myFunction = () => () => {}
7357// Options: [{"require":{"ArrowFunctionExpression":true}}]
7358
7359setTimeout(() => {}, 10);
7360// Options: [{"require":{"ArrowFunctionExpression":true}}]
7361
7362/**
7363JSDoc Block
7364*/
7365var foo = function() {}
7366// Options: [{"require":{"FunctionExpression":true}}]
7367
7368const foo = {/**
7369JSDoc Block
7370*/
7371bar() {}}
7372// Options: [{"require":{"FunctionExpression":true}}]
7373
7374var foo = {/**
7375JSDoc Block
7376*/
7377bar: function() {}}
7378// Options: [{"require":{"FunctionExpression":true}}]
7379
7380var foo = { [function() {}]: 1 };
7381// Options: [{"require":{"FunctionExpression":true}}]
7382
7383function foo () {}
7384// Options: [{"exemptEmptyFunctions":true}]
7385
7386function foo () {
7387 return;
7388}
7389// Options: [{"exemptEmptyFunctions":true}]
7390
7391const test = {};
7392/**
7393 * test
7394 */
7395 test.method = function () {
7396
7397}
7398module.exports = {
7399 prop: { prop2: test.method }
7400}
7401// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7402
7403/**
7404 *
7405 */
7406function test() {
7407
7408}
7409
7410module.exports = {
7411 prop: { prop2: test }
7412}
7413// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7414
7415/**
7416 *
7417 */
7418test = function() {
7419
7420}
7421
7422module.exports = {
7423 prop: { prop2: test }
7424}
7425// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionExpression":true}}]
7426
7427/**
7428 *
7429 */
7430test = function() {
7431
7432}
7433
7434exports.someMethod = {
7435 prop: { prop2: test }
7436}
7437// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
7438
7439/**
7440 *
7441 */
7442const test = () => {
7443
7444}
7445
7446module.exports = {
7447prop: { prop2: test }
7448}
7449// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
7450
7451const test = () => {
7452
7453}
7454module.exports = {
7455 prop: { prop2: test }
7456}
7457// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"ArrowFunctionExpression":true}}]
7458
7459/**
7460 *
7461 */
7462window.test = function() {
7463
7464}
7465
7466module.exports = {
7467prop: window
7468}
7469// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7470
7471test = function() {
7472
7473}
7474
7475/**
7476 *
7477 */
7478test = function() {
7479
7480}
7481
7482module.exports = {
7483prop: { prop2: test }
7484}
7485// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7486
7487test = function() {
7488
7489}
7490
7491test = 2;
7492
7493module.exports = {
7494prop: { prop2: test }
7495}
7496// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7497
7498/**
7499 *
7500 */
7501function test() {
7502
7503}
7504
7505/**
7506 *
7507 */
7508test.prototype.method = function() {
7509
7510}
7511
7512module.exports = {
7513prop: { prop2: test }
7514}
7515// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7516
7517class Test {
7518 /**
7519 * Test
7520 */
7521 method() {
7522
7523 }
7524}
7525module.exports = Test;
7526// Options: [{"publicOnly":true,"require":{"MethodDefinition":true}}]
7527
7528/**
7529 *
7530 */
7531export default function quux () {
7532
7533}
7534// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7535
7536/**
7537 *
7538 */
7539export default function quux () {
7540
7541}
7542// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7543
7544/**
7545 *
7546 */
7547function quux () {
7548
7549}
7550export default quux;
7551// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7552
7553function quux () {
7554
7555}
7556export default quux;
7557// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7558
7559/**
7560 *
7561 */
7562export function test() {
7563
7564}
7565// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7566
7567/**
7568 *
7569 */
7570export function test() {
7571
7572}
7573// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
7574
7575/**
7576 *
7577 */
7578var test = function () {
7579
7580}
7581var test2 = 2;
7582export { test, test2 }
7583// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7584
7585/**
7586 *
7587 */
7588var test = function () {
7589
7590}
7591export { test as test2 }
7592// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7593
7594/**
7595 *
7596 */
7597export default class A {
7598
7599}
7600// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true}}]
7601
7602/**
7603 *
7604 */
7605var test = function () {
7606
7607}
7608// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
7609
7610let test = function () {
7611
7612}
7613// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
7614
7615let test = class {
7616
7617}
7618// Options: [{"publicOnly":true,"require":{"ClassExpression":false}}]
7619
7620/**
7621 *
7622 */
7623let test = class {
7624
7625}
7626// Options: [{"publicOnly":true,"require":{"ClassExpression":true}}]
7627
7628export function someMethod() {
7629
7630}
7631// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionDeclaration":true}}]
7632
7633export function someMethod() {
7634
7635}
7636// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionDeclaration":true}}]
7637
7638exports.someMethod = function() {
7639
7640}
7641// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
7642
7643const myObject = {
7644 myProp: true
7645};
7646// Options: [{"contexts":[]}]
7647
7648function bear() {}
7649/**
7650 *
7651 */
7652function quux () {
7653}
7654export default quux;
7655// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
7656
7657/**
7658 * This example interface is great!
7659 */
7660export interface Example {
7661 /**
7662 * My super test string!
7663 */
7664 test: string
7665}
7666// Options: [{"contexts":["TSInterfaceDeclaration"]}]
7667
7668/**
7669 * This example interface is great!
7670 */
7671interface Example {
7672 /**
7673 * My super test string!
7674 */
7675 test: string
7676}
7677// Options: [{"contexts":["TSInterfaceDeclaration"]}]
7678
7679/**
7680 * This example type is great!
7681 */
7682export type Example = {
7683 /**
7684 * My super test string!
7685 */
7686 test: string
7687};
7688// Options: [{"contexts":["TSTypeAliasDeclaration"]}]
7689
7690/**
7691 * This example type is great!
7692 */
7693type Example = {
7694 /**
7695 * My super test string!
7696 */
7697 test: string
7698};
7699// Options: [{"contexts":["TSTypeAliasDeclaration"]}]
7700
7701/**
7702 * This example enum is great!
7703 */
7704export enum Example {
7705 /**
7706 * My super test enum!
7707 */
7708 test = 123
7709}
7710// Options: [{"contexts":["TSEnumDeclaration"]}]
7711
7712/**
7713 * This example enum is great!
7714 */
7715enum Example {
7716 /**
7717 * My super test enum!
7718 */
7719 test = 123
7720}
7721// Options: [{"contexts":["TSEnumDeclaration"]}]
7722
7723const foo = {...{}};
7724function bar() {}
7725// Options: [{"exemptEmptyFunctions":false,"publicOnly":true,"require":{"ArrowFunctionExpression":true,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":false,"MethodDefinition":true}}]
7726
7727/**
7728 * Class documentation
7729 */
7730 @logged
7731export default class Foo {
7732 // ....
7733}
7734// Options: [{"exemptEmptyFunctions":false,"require":{"ClassDeclaration":true}}]
7735````
7736
7737
7738<a name="eslint-plugin-jsdoc-rules-require-param-description"></a>
7739### <code>require-param-description</code>
7740
7741Requires that each `@param` tag has a `description` value.
7742
7743|||
7744|---|---|
7745|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
7746|Tags|`param`|
7747|Aliases|`arg`, `argument`|
7748
7749The following patterns are considered problems:
7750
7751````js
7752/**
7753 * @param foo
7754 */
7755function quux (foo) {
7756
7757}
7758// Message: Missing JSDoc @param "foo" description.
7759
7760/**
7761 * @arg foo
7762 */
7763function quux (foo) {
7764
7765}
7766// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
7767// Message: Missing JSDoc @arg "foo" description.
7768
7769/**
7770 * @param foo
7771 */
7772function quux (foo) {
7773
7774}
7775// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
7776// Message: Unexpected tag `@param`
7777````
7778
7779The following patterns are not considered problems:
7780
7781````js
7782/**
7783 *
7784 */
7785function quux (foo) {
7786
7787}
7788
7789/**
7790 * @param foo Foo.
7791 */
7792function quux (foo) {
7793
7794}
7795````
7796
7797
7798<a name="eslint-plugin-jsdoc-rules-require-param-name"></a>
7799### <code>require-param-name</code>
7800
7801Requires that all function parameters have names.
7802
7803> 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.
7804>
7805> [JSDoc](https://jsdoc.app/tags-param.html#overview)
7806
7807|||
7808|---|---|
7809|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
7810|Tags|`param`|
7811|Aliases|`arg`, `argument`|
7812
7813The following patterns are considered problems:
7814
7815````js
7816/**
7817 * @param
7818 */
7819function quux (foo) {
7820
7821}
7822// Message: There must be an identifier after @param type.
7823
7824/**
7825 * @param {string}
7826 */
7827function quux (foo) {
7828
7829}
7830// Message: There must be an identifier after @param tag.
7831
7832/**
7833 * @param foo
7834 */
7835function quux (foo) {
7836
7837}
7838// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
7839// Message: Unexpected tag `@param`
7840````
7841
7842The following patterns are not considered problems:
7843
7844````js
7845/**
7846 * @param foo
7847 */
7848function quux (foo) {
7849
7850}
7851
7852/**
7853 * @param {string} foo
7854 */
7855function quux (foo) {
7856
7857}
7858````
7859
7860
7861<a name="eslint-plugin-jsdoc-rules-require-param-type"></a>
7862### <code>require-param-type</code>
7863
7864Requires that each `@param` tag has a `type` value.
7865
7866|||
7867|---|---|
7868|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
7869|Tags|`param`|
7870|Aliases|`arg`, `argument`|
7871
7872The following patterns are considered problems:
7873
7874````js
7875/**
7876 * @param foo
7877 */
7878function quux (foo) {
7879
7880}
7881// Message: Missing JSDoc @param "foo" type.
7882
7883/**
7884 * @arg foo
7885 */
7886function quux (foo) {
7887
7888}
7889// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
7890// Message: Missing JSDoc @arg "foo" type.
7891
7892/**
7893 * @param foo
7894 */
7895function quux (foo) {
7896
7897}
7898// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
7899// Message: Unexpected tag `@param`
7900````
7901
7902The following patterns are not considered problems:
7903
7904````js
7905/**
7906 *
7907 */
7908function quux (foo) {
7909
7910}
7911
7912/**
7913 * @param {number} foo
7914 */
7915function quux (foo) {
7916
7917}
7918````
7919
7920
7921<a name="eslint-plugin-jsdoc-rules-require-param"></a>
7922### <code>require-param</code>
7923
7924Requires that all function parameters are documented.
7925
7926<a name="eslint-plugin-jsdoc-rules-require-param-options-16"></a>
7927#### Options
7928
7929An options object accepts one optional property:
7930
7931- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
7932 block avoids the need for a `@param`. Defaults to an empty array.
7933
7934|||
7935|---|---|
7936|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
7937|Tags|`param`|
7938|Aliases|`arg`, `argument`|
7939|Options|`exemptedBy`|
7940|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
7941
7942The following patterns are considered problems:
7943
7944````js
7945/**
7946 *
7947 */
7948function quux (foo) {
7949
7950}
7951// Message: Missing JSDoc @param "foo" declaration.
7952
7953/**
7954 *
7955 */
7956function quux (foo, bar) {
7957
7958}
7959// Message: Missing JSDoc @param "foo" declaration.
7960
7961/**
7962 * @param foo
7963 */
7964function quux (foo, bar) {
7965
7966}
7967// Message: Missing JSDoc @param "bar" declaration.
7968
7969/**
7970 * @param bar
7971 */
7972function quux (foo, bar, baz) {
7973
7974}
7975// Message: Missing JSDoc @param "foo" declaration.
7976
7977/**
7978 * @param foo
7979 * @param bar
7980 */
7981function quux (foo, bar, baz) {
7982
7983}
7984// Message: Missing JSDoc @param "baz" declaration.
7985
7986/**
7987 * @param baz
7988 */
7989function quux (foo, bar, baz) {
7990
7991}
7992// Message: Missing JSDoc @param "foo" declaration.
7993
7994/**
7995 * @param
7996 */
7997function quux (foo) {
7998
7999}
8000// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
8001// Message: Missing JSDoc @arg "foo" declaration.
8002
8003/**
8004 * @param foo
8005 */
8006function quux (foo, bar) {
8007
8008}
8009// Message: Missing JSDoc @param "bar" declaration.
8010
8011/**
8012 * @override
8013 */
8014function quux (foo) {
8015
8016}
8017// Settings: {"jsdoc":{"overrideReplacesDocs":false}}
8018// Message: Missing JSDoc @param "foo" declaration.
8019
8020/**
8021 * @implements
8022 */
8023function quux (foo) {
8024
8025}
8026// Settings: {"jsdoc":{"implementsReplacesDocs":false}}
8027// Message: Missing JSDoc @param "foo" declaration.
8028
8029/**
8030 * @augments
8031 */
8032function quux (foo) {
8033
8034}
8035// Message: Missing JSDoc @param "foo" declaration.
8036
8037/**
8038 * @extends
8039 */
8040function quux (foo) {
8041
8042}
8043// Message: Missing JSDoc @param "foo" declaration.
8044
8045/**
8046 * @override
8047 */
8048class A {
8049 /**
8050 *
8051 */
8052 quux (foo) {
8053
8054 }
8055}
8056// Settings: {"jsdoc":{"overrideReplacesDocs":false}}
8057// Message: Missing JSDoc @param "foo" declaration.
8058
8059/**
8060 * @implements
8061 */
8062class A {
8063 /**
8064 *
8065 */
8066 quux (foo) {
8067
8068 }
8069}
8070// Settings: {"jsdoc":{"implementsReplacesDocs":false}}
8071// Message: Missing JSDoc @param "foo" declaration.
8072
8073/**
8074 * @augments
8075 */
8076class A {
8077 /**
8078 *
8079 */
8080 quux (foo) {
8081
8082 }
8083}
8084// Message: Missing JSDoc @param "foo" declaration.
8085
8086/**
8087 * @extends
8088 */
8089class A {
8090 /**
8091 *
8092 */
8093 quux (foo) {
8094
8095 }
8096}
8097// Message: Missing JSDoc @param "foo" declaration.
8098
8099export class SomeClass {
8100 /**
8101 * @param property
8102 */
8103 constructor(private property: string, private foo: number) {}
8104}
8105// Message: Missing JSDoc @param "foo" declaration.
8106
8107/**
8108 * @param
8109 */
8110function quux (foo) {
8111
8112}
8113// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
8114// Message: Unexpected tag `@param`
8115
8116/**
8117 *
8118 */
8119function quux ({bar, baz}, foo) {
8120}
8121// Message: Missing JSDoc @param "foo" declaration.
8122
8123/**
8124 *
8125 */
8126function quux (foo, {bar, baz}) {
8127}
8128// Message: Missing JSDoc @param "foo" declaration.
8129
8130/**
8131 *
8132 */
8133function quux ([bar, baz], foo) {
8134}
8135// Message: Missing JSDoc @param "foo" declaration.
8136
8137/**
8138 *
8139 */
8140function quux (foo) {
8141}
8142// Options: [{"exemptedBy":["notPresent"]}]
8143// Message: Missing JSDoc @param "foo" declaration.
8144````
8145
8146The following patterns are not considered problems:
8147
8148````js
8149/**
8150 * @param foo
8151 */
8152function quux (foo) {
8153
8154}
8155
8156/**
8157 * @inheritdoc
8158 */
8159function quux (foo) {
8160
8161}
8162
8163/**
8164 * @arg foo
8165 */
8166function quux (foo) {
8167
8168}
8169// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
8170
8171/**
8172 * @override
8173 * @param foo
8174 */
8175function quux (foo) {
8176
8177}
8178
8179/**
8180 * @override
8181 */
8182function quux (foo) {
8183
8184}
8185
8186/**
8187 * @override
8188 */
8189class A {
8190 /**
8191 *
8192 */
8193 quux (foo) {
8194
8195 }
8196}
8197
8198/**
8199 * @override
8200 */
8201function quux (foo) {
8202
8203}
8204// Settings: {"jsdoc":{"overrideReplacesDocs":true}}
8205
8206/**
8207 * @implements
8208 */
8209class A {
8210 /**
8211 *
8212 */
8213 quux (foo) {
8214
8215 }
8216}
8217
8218/**
8219 * @implements
8220 */
8221function quux (foo) {
8222
8223}
8224
8225/**
8226 * @implements
8227 */
8228function quux (foo) {
8229
8230}
8231// Settings: {"jsdoc":{"implementsReplacesDocs":true}}
8232
8233/**
8234 * @implements
8235 * @param foo
8236 */
8237function quux (foo) {
8238
8239}
8240
8241/**
8242 * @augments
8243 */
8244function quux (foo) {
8245
8246}
8247// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8248
8249/**
8250 * @augments
8251 * @param foo
8252 */
8253function quux (foo) {
8254
8255}
8256
8257/**
8258 * @extends
8259 */
8260function quux (foo) {
8261
8262}
8263// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8264
8265/**
8266 * @extends
8267 * @param foo
8268 */
8269function quux (foo) {
8270
8271}
8272
8273/**
8274 * @augments
8275 */
8276function quux (foo) {
8277
8278}
8279// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8280
8281/**
8282 * @extends
8283 */
8284function quux (foo) {
8285
8286}
8287// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8288
8289/**
8290 * @override
8291 */
8292class A {
8293 /**
8294 * @param foo
8295 */
8296 quux (foo) {
8297
8298 }
8299}
8300
8301/**
8302 * @override
8303 */
8304class A {
8305 /**
8306 *
8307 */
8308 quux (foo) {
8309
8310 }
8311}
8312// Settings: {"jsdoc":{"overrideReplacesDocs":true}}
8313
8314/**
8315 * @implements
8316 */
8317class A {
8318 /**
8319 *
8320 */
8321 quux (foo) {
8322
8323 }
8324}
8325// Settings: {"jsdoc":{"implementsReplacesDocs":true}}
8326
8327/**
8328 * @implements
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 * @augments
8354 */
8355class A {
8356 /**
8357 * @param foo
8358 */
8359 quux (foo) {
8360
8361 }
8362}
8363
8364/**
8365 * @extends
8366 */
8367class A {
8368 /**
8369 *
8370 */
8371 quux (foo) {
8372
8373 }
8374}
8375// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8376
8377/**
8378 * @extends
8379 */
8380class A {
8381 /**
8382 * @param foo
8383 */
8384 quux (foo) {
8385
8386 }
8387}
8388
8389/**
8390 * @augments
8391 */
8392class A {
8393 /**
8394 *
8395 */
8396 quux (foo) {
8397
8398 }
8399}
8400// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8401
8402/**
8403 * @extends
8404 */
8405class A {
8406 /**
8407 *
8408 */
8409 quux (foo) {
8410
8411 }
8412}
8413// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
8414
8415/**
8416 * @private
8417 */
8418function quux (foo) {
8419
8420}
8421// Settings: {"jsdoc":{"ignorePrivate":true}}
8422
8423/**
8424 * @access private
8425 */
8426function quux (foo) {
8427
8428}
8429// Settings: {"jsdoc":{"ignorePrivate":true}}
8430
8431// issue 182: optional chaining
8432/** @const {boolean} test */
8433const test = something?.find(_ => _)
8434
8435/** @type {RequestHandler} */
8436function foo(req, res, next) {}
8437
8438/**
8439 * @type {MyCallback}
8440 */
8441function quux () {
8442
8443}
8444// Options: [{"exemptedBy":["type"]}]
8445
8446/**
8447 * @override
8448 */
8449var A = class {
8450 /**
8451 *
8452 */
8453 quux (foo) {
8454
8455 }
8456}
8457
8458export class SomeClass {
8459 /**
8460 * @param property
8461 */
8462 constructor(private property: string) {}
8463}
8464
8465/**
8466 * Assign the project to an employee.
8467 *
8468 * @param {object} employee - The employee who is responsible for the project.
8469 * @param {string} employee.name - The name of the employee.
8470 * @param {string} employee.department - The employee's department.
8471 */
8472function assign({name, department}) {
8473 // ...
8474}
8475
8476export abstract class StephanPlugin<O, D> {
8477
8478 /**
8479 * Called right after Stephan loads the plugin file.
8480 *
8481 * @example
8482 *```typescript
8483 * type Options = {
8484 * verbose?: boolean;
8485 * token?: string;
8486 * }
8487 * ```
8488 *
8489 * Note that your Options type should only have optional properties...
8490 *
8491 * @param args Arguments compiled and provided by StephanClient.
8492 * @param args.options The options as provided by the user, or an empty object if not provided.
8493 * @param defaultOptions The default options as provided by the plugin, or an empty object.
8494 */
8495 public constructor({options, client}: {
8496 options: O;
8497 client: unknown;
8498 }, defaultOptions: D) {
8499
8500 }
8501}
8502````
8503
8504
8505<a name="eslint-plugin-jsdoc-rules-require-returns-check"></a>
8506### <code>require-returns-check</code>
8507
8508Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.
8509
8510Will also report if multiple `@returns` tags are present.
8511
8512|||
8513|---|---|
8514|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
8515|Tags|`returns`|
8516|Aliases|`return`|
8517
8518The following patterns are considered problems:
8519
8520````js
8521/**
8522 * @returns
8523 */
8524function quux (foo) {
8525
8526}
8527// Message: JSDoc @returns declaration present but return expression not available in function.
8528
8529/**
8530 * @return
8531 */
8532function quux (foo) {
8533
8534}
8535// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
8536// Message: JSDoc @return declaration present but return expression not available in function.
8537
8538/**
8539 * @returns
8540 */
8541const quux = () => {}
8542// Message: JSDoc @returns declaration present but return expression not available in function.
8543
8544/**
8545 * @returns {undefined} Foo.
8546 * @returns {String} Foo.
8547 */
8548function quux () {
8549
8550 return foo;
8551}
8552// Message: Found more than one @returns declaration.
8553
8554const language = {
8555 /**
8556 * @param {string} name
8557 * @returns {string}
8558 */
8559 get name() {
8560 this._name = name;
8561 }
8562}
8563// Message: JSDoc @returns declaration present but return expression not available in function.
8564
8565class Foo {
8566 /**
8567 * @returns {string}
8568 */
8569 bar () {
8570 }
8571}
8572// Message: JSDoc @returns declaration present but return expression not available in function.
8573
8574/**
8575 * @returns
8576 */
8577function quux () {
8578
8579}
8580// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
8581// Message: Unexpected tag `@returns`
8582
8583/**
8584 * @returns {string}
8585 */
8586function f () {
8587 function g() {
8588 return 'foo'
8589 }
8590
8591 () => {
8592 return 5
8593 }
8594}
8595// Message: JSDoc @returns declaration present but return expression not available in function.
8596````
8597
8598The following patterns are not considered problems:
8599
8600````js
8601/**
8602 * @returns Foo.
8603 */
8604function quux () {
8605
8606 return foo;
8607}
8608
8609/**
8610 * @returns {string} Foo.
8611 */
8612function quux () {
8613
8614 return foo;
8615}
8616
8617/**
8618 * @returns {string} Foo.
8619 */
8620function quux () {
8621
8622 return foo;
8623}
8624
8625/**
8626 *
8627 */
8628function quux () {
8629}
8630
8631/**
8632 * @returns {*} Foo.
8633 */
8634const quux = () => foo;
8635
8636/**
8637 * @returns {undefined} Foo.
8638 */
8639function quux () {}
8640
8641/**
8642 * @returns { void } Foo.
8643 */
8644function quux () {}
8645
8646/**
8647 * @returns {Promise<void>}
8648 */
8649async function quux() {}
8650
8651/**
8652 * @returns {Promise<void>}
8653 */
8654const quux = async function () {}
8655
8656/**
8657 * @returns {Promise<void>}
8658 */
8659const quux = async () => {}
8660
8661/**
8662 * @returns Foo.
8663 * @abstract
8664 */
8665function quux () {
8666 throw new Error('must be implemented by subclass!');
8667}
8668
8669/**
8670 * @returns Foo.
8671 * @virtual
8672 */
8673function quux () {
8674 throw new Error('must be implemented by subclass!');
8675}
8676
8677/**
8678 * @returns Foo.
8679 * @constructor
8680 */
8681function quux () {
8682}
8683
8684/**
8685 * @interface
8686 */
8687class Foo {
8688 /**
8689 * @returns {string}
8690 */
8691 bar () {
8692 }
8693}
8694
8695/**
8696 * @returns {undefined} Foo.
8697 */
8698function quux () {
8699}
8700
8701/**
8702 * @returns {void} Foo.
8703 */
8704function quux () {
8705}
8706
8707/**
8708 * @returns {void} Foo.
8709 */
8710function quux () {
8711 return undefined;
8712}
8713
8714/**
8715 * @returns {void} Foo.
8716 */
8717function quux () {
8718 return;
8719}
8720
8721/**
8722 *
8723 */
8724function quux () {
8725 return undefined;
8726}
8727
8728/**
8729 *
8730 */
8731function quux () {
8732 return;
8733}
8734
8735/**
8736 * @returns {true}
8737 */
8738function quux () {
8739 try {
8740 return true;
8741 } catch (err) {
8742 }
8743 return;
8744}
8745
8746/**
8747 * @returns {true}
8748 */
8749function quux () {
8750 try {
8751 } finally {
8752 return true;
8753 }
8754 return;
8755}
8756
8757/**
8758 * @returns {true}
8759 */
8760function quux () {
8761 try {
8762 return;
8763 } catch (err) {
8764 }
8765 return true;
8766}
8767
8768/**
8769 * @returns {true}
8770 */
8771function quux () {
8772 try {
8773 something();
8774 } catch (err) {
8775 return true;
8776 }
8777 return;
8778}
8779
8780/**
8781 * @returns {true}
8782 */
8783function quux () {
8784 switch (true) {
8785 case 'abc':
8786 return true;
8787 }
8788 return;
8789}
8790
8791/**
8792 * @returns {true}
8793 */
8794function quux () {
8795 switch (true) {
8796 case 'abc':
8797 return;
8798 }
8799 return true;
8800}
8801
8802/**
8803 * @returns {true}
8804 */
8805function quux () {
8806 for (const i of abc) {
8807 return true;
8808 }
8809 return;
8810}
8811
8812/**
8813 * @returns {true}
8814 */
8815function quux () {
8816 for (const a in b) {
8817 return true;
8818 }
8819}
8820
8821/**
8822 * @returns {true}
8823 */
8824function quux () {
8825 for (let i=0; i<n; i+=1) {
8826 return true;
8827 }
8828}
8829
8830/**
8831 * @returns {true}
8832 */
8833function quux () {
8834 while(true) {
8835 return true
8836 }
8837}
8838
8839/**
8840 * @returns {true}
8841 */
8842function quux () {
8843 do {
8844 return true
8845 }
8846 while(true)
8847}
8848
8849/**
8850 * @returns {true}
8851 */
8852function quux () {
8853 if (true) {
8854 return;
8855 }
8856 return true;
8857}
8858
8859/**
8860 * @returns {true}
8861 */
8862function quux () {
8863 if (true) {
8864 return true;
8865 }
8866}
8867
8868/**
8869 * @returns {true}
8870 */
8871function quux () {
8872 var a = {};
8873 with (a) {
8874 return true;
8875 }
8876}
8877
8878/**
8879 * @returns {true}
8880 */
8881function quux () {
8882 if (true) {
8883 return;
8884 } else {
8885 return true;
8886 }
8887 return;
8888}
8889````
8890
8891
8892<a name="eslint-plugin-jsdoc-rules-require-returns-description"></a>
8893### <code>require-returns-description</code>
8894
8895Requires that the `@returns` tag has a `description` value. The error
8896will not be reported if the return value is `void` or `undefined`.
8897
8898|||
8899|---|---|
8900|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
8901|Tags|`returns`|
8902|Aliases|`return`|
8903
8904The following patterns are considered problems:
8905
8906````js
8907/**
8908 * @returns
8909 */
8910function quux (foo) {
8911
8912}
8913// Message: Missing JSDoc @returns description.
8914
8915/**
8916 * @returns {string}
8917 */
8918function quux (foo) {
8919
8920}
8921// Message: Missing JSDoc @returns description.
8922
8923/**
8924 * @return
8925 */
8926function quux (foo) {
8927
8928}
8929// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
8930// Message: Missing JSDoc @return description.
8931
8932/**
8933 * @returns
8934 */
8935function quux () {
8936
8937}
8938// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
8939// Message: Unexpected tag `@returns`
8940````
8941
8942The following patterns are not considered problems:
8943
8944````js
8945/**
8946 *
8947 */
8948function quux () {
8949
8950}
8951
8952/**
8953 * @returns Foo.
8954 */
8955function quux () {
8956
8957}
8958
8959/**
8960 * @returns {undefined}
8961 */
8962function quux () {
8963
8964}
8965
8966/**
8967 * @returns {void}
8968 */
8969function quux () {
8970
8971}
8972````
8973
8974
8975<a name="eslint-plugin-jsdoc-rules-require-returns-type"></a>
8976### <code>require-returns-type</code>
8977
8978Requires that `@returns` tag has `type` value.
8979
8980|||
8981|---|---|
8982|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
8983|Tags|`returns`|
8984|Aliases|`return`|
8985
8986The following patterns are considered problems:
8987
8988````js
8989/**
8990 * @returns
8991 */
8992function quux () {
8993
8994}
8995// Message: Missing JSDoc @returns type.
8996
8997/**
8998 * @returns Foo.
8999 */
9000function quux () {
9001
9002}
9003// Message: Missing JSDoc @returns type.
9004
9005/**
9006 * @return Foo.
9007 */
9008function quux () {
9009
9010}
9011// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
9012// Message: Missing JSDoc @return type.
9013
9014/**
9015 * @returns
9016 */
9017function quux () {
9018
9019}
9020// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
9021// Message: Unexpected tag `@returns`
9022````
9023
9024The following patterns are not considered problems:
9025
9026````js
9027/**
9028 * @returns {number}
9029 */
9030function quux () {
9031
9032}
9033````
9034
9035
9036<a name="eslint-plugin-jsdoc-rules-require-returns"></a>
9037### <code>require-returns</code>
9038
9039Requires returns are documented.
9040
9041Will also report if multiple `@returns` tags are present.
9042
9043<a name="eslint-plugin-jsdoc-rules-require-returns-options-17"></a>
9044#### Options
9045
9046- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
9047 block avoids the need for a `@returns`. Defaults to an empty array.
9048- `forceRequireReturn` - Set to `true` to always insist on
9049 `@returns` documentation regardless of implicit or explicit `return`'s
9050 in the function. May be desired to flag that a project is aware of an
9051 `undefined`/`void` return. Defaults to `false`.
9052- `forceReturnsWithAsync` - By default `async` functions that do not explicitly
9053 return a value pass this rule as an `async` function will always return a
9054 `Promise`, even if the `Promise` resolves to void. You can force all `async`
9055 functions to require return statements by setting `forceReturnsWithAsync`
9056 to `true` on the options object. This may be useful for flagging that there
9057 has been consideration of return type. Defaults to `false`.
9058
9059```js
9060'jsdoc/require-returns': ['error', {forceReturnsWithAsync: true}]
9061```
9062
9063|||
9064|---|---|
9065|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
9066|Tags|`returns`|
9067|Aliases|`return`|
9068|Options|`exemptedBy`, `forceRequireReturn`, `forceReturnsWithAsync`|
9069|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
9070
9071The following patterns are considered problems:
9072
9073````js
9074/**
9075 *
9076 */
9077function quux (foo) {
9078
9079 return foo;
9080}
9081// Message: Missing JSDoc @returns declaration.
9082
9083/**
9084 *
9085 */
9086const foo = () => ({
9087 bar: 'baz'
9088})
9089// Message: Missing JSDoc @returns declaration.
9090
9091/**
9092 *
9093 */
9094const foo = bar=>({ bar })
9095// Message: Missing JSDoc @returns declaration.
9096
9097/**
9098 *
9099 */
9100const foo = bar => bar.baz()
9101// Message: Missing JSDoc @returns declaration.
9102
9103/**
9104 *
9105 */
9106function quux (foo) {
9107
9108 return foo;
9109}
9110// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
9111// Message: Missing JSDoc @return declaration.
9112
9113/**
9114 *
9115 */
9116function foo() {}
9117
9118/**
9119 *
9120 */
9121function bar() {}
9122// Settings: {"jsdoc":{"forceRequireReturn":true}}
9123// Message: `settings.jsdoc.forceRequireReturn` has been removed, use options in the rule `require-returns` instead.
9124
9125/**
9126 *
9127 */
9128async function quux() {
9129}
9130// Options: [{"forceRequireReturn":true}]
9131// Message: Missing JSDoc @returns declaration.
9132
9133/**
9134 *
9135 */
9136const quux = async function () {}
9137// Options: [{"forceRequireReturn":true}]
9138// Message: Missing JSDoc @returns declaration.
9139
9140/**
9141 *
9142 */
9143const quux = async () => {}
9144// Options: [{"forceRequireReturn":true}]
9145// Message: Missing JSDoc @returns declaration.
9146
9147/**
9148 *
9149 */
9150async function quux () {}
9151// Options: [{"forceRequireReturn":true}]
9152// Message: Missing JSDoc @returns declaration.
9153
9154/**
9155 *
9156 */
9157function quux () {
9158}
9159// Options: [{"forceRequireReturn":true}]
9160// Message: Missing JSDoc @returns declaration.
9161
9162const language = {
9163 /**
9164 * @param {string} name
9165 */
9166 get name() {
9167 return this._name;
9168 }
9169}
9170// Message: Missing JSDoc @returns declaration.
9171
9172/**
9173 *
9174 */
9175async function quux () {
9176}
9177// Options: [{"forceReturnsWithAsync":true}]
9178// Message: Missing JSDoc @returns declaration.
9179
9180/**
9181 * @returns {undefined}
9182 * @returns {void}
9183 */
9184function quux (foo) {
9185
9186 return foo;
9187}
9188// Message: Found more than one @returns declaration.
9189
9190/**
9191 * @returns
9192 */
9193function quux () {
9194
9195}
9196// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
9197// Message: Unexpected tag `@returns`
9198
9199/**
9200 * @param foo
9201 */
9202function quux (foo) {
9203 return 'bar';
9204}
9205// Options: [{"exemptedBy":["notPresent"]}]
9206// Message: Missing JSDoc @returns declaration.
9207
9208/**
9209 * @param {array} a
9210 */
9211async function foo(a) {
9212 return;
9213}
9214// Options: [{"forceReturnsWithAsync":true}]
9215// Message: Missing JSDoc @returns declaration.
9216
9217/**
9218 * @param {array} a
9219 */
9220async function foo(a) {
9221 return Promise.all(a);
9222}
9223// Options: [{"forceReturnsWithAsync":true}]
9224// Message: Missing JSDoc @returns declaration.
9225````
9226
9227The following patterns are not considered problems:
9228
9229````js
9230/**
9231 * @returns Foo.
9232 */
9233function quux () {
9234
9235 return foo;
9236}
9237
9238/**
9239 *
9240 */
9241function quux () {
9242}
9243
9244/**
9245 *
9246 */
9247function quux (bar) {
9248 bar.filter(baz => {
9249 return baz.corge();
9250 })
9251}
9252
9253/**
9254 * @returns Array
9255 */
9256function quux (bar) {
9257 return bar.filter(baz => {
9258 return baz.corge();
9259 })
9260}
9261
9262/**
9263 * @returns Array
9264 */
9265const quux = (bar) => bar.filter(({ corge }) => corge())
9266
9267/**
9268 * @inheritdoc
9269 */
9270function quux (foo) {
9271}
9272
9273/**
9274 * @override
9275 */
9276function quux (foo) {
9277}
9278
9279/**
9280 * @constructor
9281 */
9282function quux (foo) {
9283}
9284
9285/**
9286 * @implements
9287 */
9288function quux (foo) {
9289}
9290
9291/**
9292 * @override
9293 */
9294function quux (foo) {
9295
9296 return foo;
9297}
9298
9299/**
9300 * @class
9301 */
9302function quux (foo) {
9303
9304}
9305
9306/**
9307 * @constructor
9308 */
9309function quux (foo) {
9310
9311}
9312
9313/**
9314 * @returns {object}
9315 */
9316function quux () {
9317
9318 return {a: foo};
9319}
9320
9321/**
9322 * @returns {object}
9323 */
9324const quux = () => ({a: foo});
9325
9326/**
9327 * @returns {object}
9328 */
9329const quux = () => {
9330 return {a: foo}
9331};
9332
9333/**
9334 * @returns {void}
9335 */
9336function quux () {
9337}
9338
9339/**
9340 * @returns {void}
9341 */
9342const quux = () => {
9343
9344}
9345
9346/**
9347 * @returns {undefined}
9348 */
9349function quux () {
9350}
9351
9352/**
9353 * @returns {undefined}
9354 */
9355const quux = () => {
9356
9357}
9358
9359/**
9360 *
9361 */
9362function quux () {
9363}
9364
9365/**
9366 *
9367 */
9368const quux = () => {
9369
9370}
9371
9372class Foo {
9373 /**
9374 *
9375 */
9376 constructor () {
9377 }
9378}
9379// Options: [{"forceRequireReturn":true}]
9380
9381const language = {
9382 /**
9383 * @param {string} name
9384 */
9385 set name(name) {
9386 this._name = name;
9387 }
9388}
9389
9390/**
9391 * @returns {void}
9392 */
9393function quux () {
9394}
9395// Options: [{"forceRequireReturn":true}]
9396
9397/**
9398 * @returns {void}
9399 */
9400function quux () {
9401 return undefined;
9402}
9403
9404/**
9405 * @returns {void}
9406 */
9407function quux () {
9408 return undefined;
9409}
9410// Options: [{"forceRequireReturn":true}]
9411
9412/**
9413 * @returns {void}
9414 */
9415function quux () {
9416 return;
9417}
9418
9419/**
9420 * @returns {void}
9421 */
9422function quux () {
9423}
9424// Options: [{"forceRequireReturn":true}]
9425
9426/**
9427 * @returns {void}
9428 */
9429function quux () {
9430 return;
9431}
9432// Options: [{"forceRequireReturn":true}]
9433
9434/** @type {RequestHandler} */
9435function quux (req, res , next) {
9436 return;
9437}
9438
9439/**
9440 * @returns {Promise}
9441 */
9442async function quux () {
9443}
9444// Options: [{"forceRequireReturn":true}]
9445
9446/**
9447 * @returns {Promise}
9448 */
9449async function quux () {
9450}
9451// Options: [{"forceReturnsWithAsync":true}]
9452
9453/**
9454 *
9455 */
9456async function quux () {}
9457
9458/**
9459 *
9460 */
9461const quux = async function () {}
9462
9463/**
9464 *
9465 */
9466const quux = async () => {}
9467
9468/** foo class */
9469class foo {
9470 /** foo constructor */
9471 constructor () {
9472 // =>
9473 this.bar = true;
9474 }
9475}
9476
9477export default foo;
9478
9479/**
9480 *
9481 */
9482function quux () {
9483}
9484// Options: [{"forceReturnsWithAsync":true}]
9485
9486/**
9487 * @type {MyCallback}
9488 */
9489function quux () {
9490
9491}
9492// Options: [{"exemptedBy":["type"]}]
9493
9494/**
9495 * @param {array} a
9496 */
9497async function foo(a) {
9498 return Promise.all(a);
9499}
9500
9501/**
9502 * @param {array} a
9503 */
9504async function foo(a) {
9505 return;
9506}
9507````
9508
9509
9510<a name="eslint-plugin-jsdoc-rules-valid-types"></a>
9511### <code>valid-types</code>
9512
9513Requires all types to be valid JSDoc or Closure compiler types without syntax errors.
9514
9515Also impacts behaviors on namepath (or event)-defining and pointing tags:
9516
95171. Name(path)-defining tags requiring namepath: `@external`, `@host`, `@name`, `@typedef`
95181. Name(path)-defining tags (which may have value without namepath or their
9519 namepath can be expressed elsewhere on the block): `@event`, `@callback`,
9520 `@class`, `@constructor`, `@constant`, `@const`,
9521 `@function`, `@func`, `@method`, `@interface`, `@member`, `@var`,
9522 `@mixin`, `@namespace`
95231. Name(path)-pointing tags requiring namepath: `@alias`, `@augments`, `@extends`, `@lends`, `@memberof`, `@memberof!`, `@mixes`, `@this`
95241. Name(path)-pointing tags (which may have value without namepath or their
9525 namepath can be expressed elsewhere on the block): `@listens`, `@fires`,
9526 `@emits`, and `@modifies`
95271. Name(path)-pointing tags (multiple names in one): `@borrows`
9528
9529...with the following applying to the above sets:
9530
9531- Expect tags in set 1-4 to have a valid namepath if present
9532- Prevent sets 2 and 4 from being empty by setting `allowEmptyNamepaths` to
9533 `false` as these tags might have some indicative value without a path
9534 or may allow a name expressed elsewhere on the block (but sets 1 and 3 will
9535 always fail if empty)
9536- For the special case of set 5, i.e., `@borrows <that namepath> as <this namepath>`,
9537 check that both namepaths are present and valid and ensure there is an `as `
9538 between them. In the case of `<this namepath>`, it can be preceded by
9539 one of the name path operators, `#`, `.`, or `~`.
9540- For the special case of `@memberof` and `@memberof!` (part of set 3), as
9541 per the [specification](https://jsdoc.app/tags-memberof.html), they also
9542 allow `#`, `.`, or `~` at the end (which is not allowed at the end of
9543 normal paths).
9544
9545<a name="eslint-plugin-jsdoc-rules-valid-types-options-18"></a>
9546#### Options
9547
9548- `allowEmptyNamepaths` (default: true) - Set to `false` to disallow
9549 empty name paths with `@callback`, `@event`, `@class`, `@constructor`,
9550 `@constant`, `@const`, `@function`, `@func`, `@method`, `@interface`,
9551 `@member`, `@var`, `@mixin`, `@namespace`, `@listens`, `@fires`,
9552 `@modifies`, or `@emits` (these might often be expected to have an
9553 accompanying name path, though they have some indicative value without
9554 one; these may also allow names to be defined in another manner elsewhere
9555 in the block)
9556- `checkSeesForNamepaths` (default: false) - Set this to `true` to insist
9557 that `@see` only use name paths (the tag is normally permitted to
9558 allow other text)
9559
9560
9561|||
9562|---|---|
9563|Context|everywhere|
9564|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)|
9565|Aliases|`extends`, `constructor`, `const`, `host`, `emits`, `func`, `method`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
9566|Closure-only|For type only: `package`, `private`, `protected`, `public`, `static`|
9567|Options|`allowEmptyNamepaths`, `checkSeesForNamepaths`|
9568|Settings|`mode`|
9569
9570The following patterns are considered problems:
9571
9572````js
9573/**
9574 * @param {Array<string} foo
9575 */
9576function quux() {
9577
9578}
9579// Message: Syntax error in type: Array<string
9580
9581/**
9582 * @memberof module:namespace.SomeClass<~
9583 */
9584function quux() {
9585
9586}
9587// Message: Syntax error in namepath: module:namespace.SomeClass<~
9588
9589/**
9590 * @memberof module:namespace.SomeClass~<
9591 */
9592function quux() {
9593
9594}
9595// Message: Syntax error in namepath: module:namespace.SomeClass~<
9596
9597/**
9598 * @borrows foo% as bar
9599 */
9600function quux() {
9601
9602}
9603// Message: Syntax error in namepath: foo%
9604
9605/**
9606 * @borrows #foo as bar
9607 */
9608function quux() {
9609
9610}
9611// Message: Syntax error in namepath: #foo
9612
9613/**
9614 * @borrows foo as bar%
9615 */
9616function quux() {
9617
9618}
9619// Message: Syntax error in namepath: bar%
9620
9621/**
9622 * @borrows foo
9623 */
9624function quux() {
9625
9626}
9627// Message: @borrows must have an "as" expression. Found ""
9628
9629/**
9630 * @see foo%
9631 */
9632function quux() {
9633
9634}
9635// Options: [{"checkSeesForNamepaths":true}]
9636// Message: Syntax error in namepath: foo%
9637
9638/** */
9639function foo() {}
9640// Settings: {"jsdoc":{"allowEmptyNamepaths":true,"checkSeesForNamepaths":true}}
9641// Message: `settings.jsdoc.allowEmptyNamepaths` has been removed, use options in the rule `valid-types` instead.
9642
9643/**
9644 * @alias module:abc#event:foo-bar
9645 */
9646function quux() {
9647
9648}
9649// Message: Syntax error in namepath: module:abc#event:foo-bar
9650
9651/**
9652 * @mixes module:namespace.SomeClass~
9653 */
9654function quux() {
9655
9656}
9657// Message: Syntax error in namepath: module:namespace.SomeClass~
9658
9659/**
9660 * @callback
9661 */
9662function quux() {
9663
9664}
9665// Options: [{"allowEmptyNamepaths":false}]
9666// Message: Tag @callback must have a name/namepath
9667
9668/**
9669 * @constant {str%ng}
9670 */
9671 const FOO = 'foo';
9672// Message: Syntax error in type: str%ng
9673
9674/**
9675 * @typedef {str%ng} UserString
9676 */
9677// Message: Syntax error in type: str%ng
9678
9679/**
9680 * @typedef {string} UserStr%ng
9681 */
9682// Message: Syntax error in namepath: UserStr%ng
9683
9684/**
9685 * @extends
9686 */
9687 class Bar {};
9688// Message: Tag @extends must have either a type or namepath
9689
9690/**
9691 * @type
9692 */
9693 let foo;
9694// Message: Tag @type must have a type
9695
9696/**
9697 * @modifies {bar|foo<}
9698 */
9699function quux (foo, bar, baz) {}
9700// Message: Syntax error in type: bar|foo<
9701
9702/**
9703 * @private {BadTypeChecked<}
9704 */
9705function quux () {}
9706// Settings: {"jsdoc":{"mode":"closure"}}
9707// Message: Syntax error in type: BadTypeChecked<
9708
9709/**
9710 * @this {BadTypeChecked<}
9711 */
9712function quux () {}
9713// Settings: {"jsdoc":{"mode":"closure"}}
9714// Message: Syntax error in type: BadTypeChecked<
9715
9716/**
9717 * @define
9718 */
9719 function quux () {}
9720// Settings: {"jsdoc":{"mode":"closure"}}
9721// Message: Tag @define must have a type
9722
9723/**
9724 * @this
9725 */
9726 let foo;
9727// Settings: {"jsdoc":{"mode":"closure"}}
9728// Message: Tag @this must have a type
9729````
9730
9731The following patterns are not considered problems:
9732
9733````js
9734/**
9735 * @param {Array<string>} foo
9736 */
9737function quux() {
9738
9739}
9740
9741/**
9742 * @param {string} foo
9743 */
9744function quux() {
9745
9746}
9747
9748/**
9749 * @param foo
9750 */
9751function quux() {
9752
9753}
9754
9755/**
9756 * @borrows foo as bar
9757 */
9758function quux() {
9759
9760}
9761
9762/**
9763 * @borrows foo as #bar
9764 */
9765function quux() {
9766
9767}
9768
9769/**
9770 * @see foo%
9771 */
9772function quux() {
9773
9774}
9775
9776/**
9777 * @alias module:namespace.SomeClass#event:ext_anevent
9778 */
9779function quux() {
9780
9781}
9782
9783/**
9784 * @callback foo
9785 */
9786function quux() {
9787
9788}
9789
9790/**
9791 * @callback
9792 */
9793function quux() {
9794
9795}
9796// Options: [{"allowEmptyNamepaths":true}]
9797
9798/**
9799 * @class
9800 */
9801function quux() {
9802
9803}
9804
9805/**
9806 * @see {@link foo}
9807 */
9808function quux() {
9809
9810}
9811// Options: [{"checkSeesForNamepaths":true}]
9812
9813/**
9814 *
9815 * @fires {module:namespace.SomeClass#event:ext_anevent}
9816 */
9817function quux() {
9818
9819}
9820
9821/**
9822 * @memberof module:namespace.SomeClass~
9823 */
9824function quux() {
9825
9826}
9827
9828/**
9829 * @memberof! module:namespace.SomeClass.
9830 */
9831function quux() {
9832
9833}
9834
9835/**
9836 *
9837 */
9838function quux() {
9839
9840}
9841
9842/**
9843 * @constant {string}
9844 */
9845 const FOO = 'foo';
9846
9847/**
9848 * @constant {string} FOO
9849 */
9850 const FOO = 'foo';
9851
9852/**
9853 * @extends Foo
9854 */
9855 class Bar {};
9856
9857/**
9858 * @extends {Foo<String>}
9859 */
9860 class Bar {};
9861
9862/**
9863 * @typedef {number|string} UserDefinedType
9864 */
9865
9866/**
9867 * @typedef {number|string}
9868 */
9869let UserDefinedGCCType;
9870
9871/**
9872 * @modifies {foo|bar}
9873 */
9874function quux (foo, bar, baz) {}
9875
9876/**
9877 * @private {BadTypeNotCheckedInJsdoc<}
9878 */
9879function quux () {}
9880
9881/**
9882 * @this {Navigator}
9883 */
9884function quux () {}
9885// Settings: {"jsdoc":{"mode":"closure"}}
9886
9887/**
9888 * @export {SomeType}
9889 */
9890function quux () {}
9891// Settings: {"jsdoc":{"mode":"closure"}}
9892
9893/**
9894 * @define {boolean}
9895 */
9896function quux () {}
9897// Settings: {"jsdoc":{"mode":"closure"}}
9898
9899/**
9900 * @define
9901 */
9902 function quux () {}
9903````
9904
9905
9906
\No newline at end of file