UNPKG

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