UNPKG

171 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 /**
4355 * Bar.
4356 *
4357 * Bar.
4358 *
4359 * @bar
4360 */
4361 function quux () {
4362
4363 }
4364// Options: ["never"]
4365// Message: There must be no newline after the description of the JSDoc block.
4366
4367/**
4368 * A.
4369 *
4370 * @typedef {Object} A
4371 * @prop {boolean} a A.
4372 */
4373// Options: ["never"]
4374// Message: There must be no newline after the description of the JSDoc block.
4375
4376/**
4377 * A.
4378 * @typedef {Object} A
4379 * @prop {boolean} a A.
4380 */
4381// Options: ["always"]
4382// Message: There must be a newline after the description of the JSDoc block.
4383
4384
4385 /**
4386 * Service for fetching symbols.
4387 * @param {Object} $http - Injected http helper.
4388 * @param {Object} $q - Injected Promise api helper.
4389 * @param {Object} $location - Injected window location object.
4390 * @param {Object} REPORT_DIALOG_CONSTANTS - Injected handle.
4391 */
4392// Message: There must be a newline after the description of the JSDoc block.
4393````
4394
4395The following patterns are not considered problems:
4396
4397````js
4398/**
4399 * Foo.
4400 */
4401function quux () {
4402
4403}
4404// Options: ["always"]
4405
4406/**
4407 * Bar.
4408 */
4409function quux () {
4410
4411}
4412// Options: ["never"]
4413
4414/**
4415 * Foo.
4416 *
4417 * @foo
4418 */
4419function quux () {
4420
4421}
4422// Options: ["always"]
4423
4424/**
4425 * Bar.
4426 * @bar
4427 */
4428function quux () {
4429
4430}
4431// Options: ["never"]
4432
4433
4434 /**
4435 * @foo
4436 * Test 
4437 * abc 
4438 * @bar 
4439 */
4440
4441
4442 /**
4443 *
4444 * @foo
4445 * Test 
4446 * abc 
4447 * @bar 
4448 */
4449
4450/***
4451 *
4452 */
4453function quux () {
4454
4455}
4456// Options: ["always"]
4457````
4458
4459
4460<a name="eslint-plugin-jsdoc-rules-no-types"></a>
4461### <code>no-types</code>
4462
4463This rule reports types being used on `@param` or `@returns`.
4464
4465The rule is intended to prevent the indication of types on tags where
4466the type information would be redundant with TypeScript.
4467
4468|||
4469|---|---|
4470|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
4471|Tags|`param`, `returns`|
4472|Aliases|`arg`, `argument`, `return`|
4473
4474The following patterns are considered problems:
4475
4476````js
4477/**
4478 * @param {number} foo
4479 */
4480function quux (foo) {
4481
4482}
4483// Message: Types are not permitted on @param.
4484
4485/**
4486 * @returns {number}
4487 */
4488function quux () {
4489
4490}
4491// Message: Types are not permitted on @returns.
4492````
4493
4494The following patterns are not considered problems:
4495
4496````js
4497/**
4498 * @param foo
4499 */
4500function quux (foo) {
4501
4502}
4503````
4504
4505
4506<a name="eslint-plugin-jsdoc-rules-no-undefined-types"></a>
4507### <code>no-undefined-types</code>
4508
4509Checks that types in jsdoc comments are defined. This can be used to check
4510unimported types.
4511
4512When enabling this rule, types in jsdoc comments will resolve as used
4513variables, i.e. will not be marked as unused by `no-unused-vars`.
4514
4515In addition to considering globals found in code (or in ESLint-indicated
4516`globals`) as defined, the following tags will also be checked for
4517name(path) definitions to also serve as a potential "type" for checking
4518the tag types in the table below:
4519
4520`@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`.
4521
4522The following tags will also be checked but only when the mode is `closure`:
4523
4524`@package`, `@private`, `@protected`, `@public`, `@static`
4525
4526The following types are always considered defined.
4527
4528- `null`, `undefined`, `void`, `string`, `boolean`, `object`, `function`
4529- `number`, `NaN`, `Infinity`
4530- `any`, `*`
4531- `Array`, `Object`, `RegExp`, `Date`, `Function`
4532
4533Note that preferred types indicated within `settings.jsdoc.preferredTypes` will
4534also be assumed to be defined.
4535
4536<a name="eslint-plugin-jsdoc-rules-no-undefined-types-options-9"></a>
4537#### Options
4538
4539An option object may have the following key:
4540
4541- `definedTypes` - This array can be populated to indicate other types which
4542 are automatically considered as defined (in addition to globals, etc.).
4543 Defaults to an empty array.
4544
4545|||
4546|---|---|
4547|Context|everywhere|
4548|Tags|`augments`, `class`, `constant`, `enum`, `implements`, `member`, `module`, `namespace`, `param`, `property`, `returns`, `throws`, `type`, `typedef`, `yields`|
4549|Aliases|`constructor`, `const`, `extends`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
4550|Closure-only|`package`, `private`, `protected`, `public`, `static`|
4551|Options|`definedTypes`|
4552|Settings|`preferredTypes`, `mode`|
4553
4554The following patterns are considered problems:
4555
4556````js
4557/**
4558 * @param {HerType} baz - Foo.
4559 */
4560function quux(foo, bar, baz) {
4561
4562}
4563// Settings: {"jsdoc":{"preferredTypes":{"HerType":1000}}}
4564// Message: Invalid `settings.jsdoc.preferredTypes`. Values must be falsy, a string, or an object.
4565
4566/**
4567 * @param {HerType} baz - Foo.
4568 */
4569function quux(foo, bar, baz) {
4570
4571}
4572// Settings: {"jsdoc":{"preferredTypes":{"HerType":false}}}
4573// Message: The type 'HerType' is undefined.
4574
4575/**
4576 * @param {strnig} foo - Bar.
4577 */
4578function quux(foo) {
4579
4580}
4581// Message: The type 'strnig' is undefined.
4582
4583/**
4584 * @param {MyType} foo - Bar.
4585 * @param {HisType} bar - Foo.
4586 */
4587function quux(foo, bar) {
4588
4589}
4590// Options: [{"definedTypes":["MyType"]}]
4591// Message: The type 'HisType' is undefined.
4592
4593/**
4594 * @param {MyType} foo - Bar.
4595 * @param {HisType} bar - Foo.
4596 * @param {HerType} baz - Foo.
4597 */
4598function quux(foo, bar, baz) {
4599
4600}
4601// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"}}}}
4602// Options: [{"definedTypes":["MyType"]}]
4603// Message: The type 'HisType' is undefined.
4604
4605 /**
4606 * @param {MyType} foo - Bar.
4607 * @param {HisType} bar - Foo.
4608 * @param {HerType} baz - Foo.
4609 */
4610function quux(foo, bar, baz) {
4611
4612}
4613// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":false},"histype":"HisType"}}}
4614// Options: [{"definedTypes":["MyType"]}]
4615// Message: The type 'HerType' is undefined.
4616
4617/**
4618 * @template TEMPLATE_TYPE
4619 * @param {WRONG_TEMPLATE_TYPE} bar
4620 */
4621function foo (bar) {
4622};
4623// Settings: {"jsdoc":{"mode":"closure"}}
4624// Message: The type 'WRONG_TEMPLATE_TYPE' is undefined.
4625
4626class Foo {
4627 /**
4628 * @return {TEMPLATE_TYPE}
4629 */
4630 bar () {
4631 }
4632}
4633// Message: The type 'TEMPLATE_TYPE' is undefined.
4634
4635class Foo {
4636 /**
4637 * @return {TEMPLATE_TYPE}
4638 */
4639 invalidTemplateReference () {
4640 }
4641}
4642
4643/**
4644 * @template TEMPLATE_TYPE
4645 */
4646class Bar {
4647 /**
4648 * @return {TEMPLATE_TYPE}
4649 */
4650 validTemplateReference () {
4651 }
4652}
4653// Settings: {"jsdoc":{"mode":"typescript"}}
4654// Message: The type 'TEMPLATE_TYPE' is undefined.
4655
4656/**
4657 * @type {strnig}
4658 */
4659var quux = {
4660
4661};
4662// Message: The type 'strnig' is undefined.
4663
4664/**
4665 * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
4666 */
4667class Foo {
4668 /**
4669 * @param {TEMPLATE_TYPE_A} baz
4670 * @return {TEMPLATE_TYPE_B}
4671 */
4672 bar (baz) {
4673 }
4674}
4675// Message: The type 'TEMPLATE_TYPE_A' is undefined.
4676
4677/**
4678 * @param {...VAR_TYPE} varargs
4679 */
4680function quux (varargs) {
4681}
4682// Message: The type 'VAR_TYPE' is undefined.
4683````
4684
4685The following patterns are not considered problems:
4686
4687````js
4688/**
4689 * @param {string} foo - Bar.
4690 */
4691function quux(foo) {
4692
4693}
4694
4695/**
4696 * @param {Promise} foo - Bar.
4697 */
4698function quux(foo) {
4699
4700}
4701
4702class MyClass {}
4703
4704/**
4705 * @param {MyClass} foo - Bar.
4706 */
4707function quux(foo) {
4708 console.log(foo);
4709}
4710
4711quux(0);
4712
4713const MyType = require('my-library').MyType;
4714
4715/**
4716 * @param {MyType} foo - Bar.
4717 */
4718 function quux(foo) {
4719
4720}
4721
4722const MyType = require('my-library').MyType;
4723
4724/**
4725 * @param {MyType} foo - Bar.
4726 */
4727 function quux(foo) {
4728
4729}
4730
4731import {MyType} from 'my-library';
4732
4733/**
4734 * @param {MyType} foo - Bar.
4735 * @param {Object<string, number>} foo
4736 * @param {Array<string>} baz
4737 */
4738 function quux(foo, bar, baz) {
4739
4740}
4741
4742/*globals MyType*/
4743
4744/**
4745 * @param {MyType} foo - Bar.
4746 * @param {HisType} bar - Foo.
4747 */
4748 function quux(foo, bar) {
4749
4750}
4751
4752/**
4753 * @typedef {Object} hello
4754 * @property {string} a - a.
4755 */
4756
4757/**
4758 * @param {hello} foo
4759 */
4760function quux(foo) {
4761
4762}
4763
4764/**
4765 * @param {Array<syntaxError} foo
4766 */
4767function quux(foo) {
4768
4769}
4770
4771/**
4772 * Callback test.
4773 *
4774 * @callback addStuffCallback
4775 * @param {String} sum - An test integer.
4776 */
4777/**
4778 * Test Eslint.
4779 *
4780 * @param {addStuffCallback} callback - A callback to run.
4781 */
4782function testFunction(callback) {
4783 callback();
4784}
4785
4786/**
4787 *
4788 *
4789 */
4790function foo () {
4791
4792}
4793
4794/**
4795 *
4796 *
4797 */
4798function foo () {
4799
4800}
4801
4802/**
4803 * @param {MyType} foo - Bar.
4804 * @param {HisType} bar - Foo.
4805 */
4806function quux(foo, bar) {
4807
4808}
4809// Options: [{"definedTypes":["MyType","HisType"]}]
4810
4811/**
4812 * @param {MyType} foo - Bar.
4813 * @param {HisType} bar - Foo.
4814 * @param {HerType} baz - Foo.
4815 */
4816function quux(foo, bar, baz) {
4817
4818}
4819// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType"},"histype":"HisType"}}}
4820// Options: [{"definedTypes":["MyType"]}]
4821
4822/**
4823 * @param {MyType} foo - Bar.
4824 * @param {HisType} bar - Foo.
4825 * @param {HerType} baz - Foo.
4826 */
4827function quux(foo, bar, baz) {
4828
4829}
4830// Settings: {"jsdoc":{"preferredTypes":{"hertype":{"replacement":"HerType<>"},"histype":"HisType.<>"}}}
4831// Options: [{"definedTypes":["MyType"]}]
4832
4833/**
4834 * @template TEMPLATE_TYPE
4835 * @param {TEMPLATE_TYPE} bar
4836 * @return {TEMPLATE_TYPE}
4837 */
4838function foo (bar) {
4839};
4840// Settings: {"jsdoc":{"mode":"closure"}}
4841
4842/**
4843 * @template TEMPLATE_TYPE
4844 */
4845class Foo {
4846 /**
4847 * @return {TEMPLATE_TYPE}
4848 */
4849 bar () {
4850 }
4851}
4852// Settings: {"jsdoc":{"mode":"closure"}}
4853
4854/**
4855 * @template TEMPLATE_TYPE_A, TEMPLATE_TYPE_B
4856 */
4857class Foo {
4858 /**
4859 * @param {TEMPLATE_TYPE_A} baz
4860 * @return {TEMPLATE_TYPE_B}
4861 */
4862 bar (baz) {
4863 }
4864}
4865// Settings: {"jsdoc":{"mode":"closure"}}
4866
4867/****/
4868
4869/**
4870 *
4871 */
4872function quux () {
4873
4874}
4875
4876/**
4877 * Run callback when hooked method is called.
4878 *
4879 * @template {BaseObject} T
4880 * @param {T} obj - object whose method should be hooked.
4881 * @param {string} method - method which should be hooked.
4882 * @param {(sender: T) => void} callback - callback which should
4883 * be called when the hooked method was invoked.
4884 */
4885function registerEvent(obj, method, callback) {
4886
4887}
4888// Settings: {"jsdoc":{"mode":"typescript"}}
4889
4890 /**
4891 * @param {...} varargs
4892 */
4893function quux (varargs) {
4894}
4895
4896/**
4897 * @param {...number} varargs
4898 */
4899function quux (varargs) {
4900}
4901````
4902
4903
4904<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence"></a>
4905### <code>require-description-complete-sentence</code>
4906
4907Requires that block description, explicit `@description`, and `@param`/`@returns`
4908tag descriptions are written in complete sentences, i.e.,
4909
4910* Description must start with an uppercase alphabetical character.
4911* Paragraphs must start with an uppercase alphabetical character.
4912* Sentences must end with a period.
4913* Every line in a paragraph (except the first) which starts with an uppercase
4914 character must be preceded by a line ending with a period.
4915* A colon or semi-colon followed by two line breaks is still part of the
4916 containing paragraph (unlike normal dual line breaks).
4917
4918<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-10"></a>
4919#### Options
4920
4921<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-10-tags-2"></a>
4922##### <code>tags</code>
4923
4924If you want additional tags to be checked for their descriptions, you may
4925add them within this option.
4926
4927```js
4928{
4929 'jsdoc/require-description-complete-sentence': ['error', {tags: ['see', 'copyright']}]
4930}
4931```
4932
4933The tags `@param`/`@arg`/`@argument` and `@property`/`@prop` will be properly
4934parsed to ensure that the checked "description" text includes only the text
4935after the name.
4936
4937All other tags will treat the text following the tag name, a space, and
4938an optional curly-bracketed type expression (and another space) as part of
4939its "description" (e.g., for `@returns {someType} some description`, the
4940description is `some description` while for `@some-tag xyz`, the description
4941is `xyz`).
4942
4943|||
4944|---|---|
4945|Context|everywhere|
4946|Tags|doc block, `param`, `returns`, `description`, `property`, `summary`, `file`, `classdesc`, `todo`, `deprecated`, `throws`, 'yields' and others added by `tags`|
4947|Aliases|`arg`, `argument`, `return`, `desc`, `prop`, `fileoverview`, `overview`, `exception`, `yield`|
4948|Options|`tags`|
4949The following patterns are considered problems:
4950
4951````js
4952/**
4953 * foo.
4954 */
4955function quux () {
4956
4957}
4958// Message: Sentence should start with an uppercase character.
4959
4960/**
4961 * foo?
4962 */
4963function quux () {
4964
4965}
4966// Message: Sentence should start with an uppercase character.
4967
4968/**
4969 * @description foo.
4970 */
4971function quux () {
4972
4973}
4974// Message: Sentence should start with an uppercase character.
4975
4976/**
4977 * Foo)
4978 */
4979function quux () {
4980
4981}
4982// Message: Sentence must end with a period.
4983
4984/**
4985 * `foo` is a variable
4986 */
4987function quux () {
4988
4989}
4990// Message: Sentence must end with a period.
4991
4992/**
4993 * Foo.
4994 *
4995 * foo.
4996 */
4997function quux () {
4998
4999}
5000// Message: Sentence should start with an uppercase character.
5001
5002/**
5003 * тест.
5004 */
5005function quux () {
5006
5007}
5008// Message: Sentence should start with an uppercase character.
5009
5010/**
5011 * Foo
5012 */
5013function quux () {
5014
5015}
5016// Message: Sentence must end with a period.
5017
5018/**
5019 * Foo
5020 * Bar.
5021 */
5022function quux () {
5023
5024}
5025// Message: A line of text is started with an uppercase character, but preceding line does not end the sentence.
5026
5027/**
5028 * Foo.
5029 *
5030 * @param foo foo.
5031 */
5032function quux (foo) {
5033
5034}
5035// Message: Sentence should start with an uppercase character.
5036
5037/**
5038 * Foo.
5039 *
5040 * @param foo bar
5041 */
5042function quux (foo) {
5043
5044}
5045// Message: Sentence should start with an uppercase character.
5046
5047/**
5048 * {@see Foo.bar} buz
5049 */
5050function quux (foo) {
5051
5052}
5053// Message: Sentence should start with an uppercase character.
5054
5055/**
5056 * Foo.
5057 *
5058 * @returns {number} foo
5059 */
5060function quux (foo) {
5061
5062}
5063// Message: Sentence should start with an uppercase character.
5064
5065/**
5066 * Foo.
5067 *
5068 * @returns foo.
5069 */
5070function quux (foo) {
5071
5072}
5073// Message: Sentence should start with an uppercase character.
5074
5075/**
5076 * lorem ipsum dolor sit amet, consectetur adipiscing elit. pellentesque elit diam,
5077 * iaculis eu dignissim sed, ultrices sed nisi. nulla at ligula auctor, consectetur neque sed,
5078 * tincidunt nibh. vivamus sit amet vulputate ligula. vivamus interdum elementum nisl,
5079 * vitae rutrum tortor semper ut. morbi porta ante vitae dictum fermentum.
5080 * proin ut nulla at quam convallis gravida in id elit. sed dolor mauris, blandit quis ante at,
5081 * consequat auctor magna. duis pharetra purus in porttitor mollis.
5082 */
5083function longDescription (foo) {
5084
5085}
5086// Message: Sentence should start with an uppercase character.
5087
5088/**
5089 * @arg {number} foo - Foo
5090 */
5091function quux (foo) {
5092
5093}
5094// Message: Sentence must end with a period.
5095
5096/**
5097 * @argument {number} foo - Foo
5098 */
5099function quux (foo) {
5100
5101}
5102// Message: Sentence must end with a period.
5103
5104/**
5105 * @return {number} foo
5106 */
5107function quux (foo) {
5108
5109}
5110// Message: Sentence should start with an uppercase character.
5111
5112/**
5113 * Returns bar.
5114 *
5115 * @return {number} bar
5116 */
5117function quux (foo) {
5118
5119}
5120// Message: Sentence should start with an uppercase character.
5121
5122/**
5123 * @throws {Object} Hello World
5124 * hello world
5125*/
5126// Message: Sentence must end with a period.
5127
5128/**
5129 * @summary Foo
5130 */
5131function quux () {
5132
5133}
5134// Message: Sentence must end with a period.
5135
5136/**
5137 * @throws {SomeType} Foo
5138 */
5139function quux () {
5140
5141}
5142// Message: Sentence must end with a period.
5143
5144/**
5145 * @see Foo
5146 */
5147function quux () {
5148
5149}
5150// Options: [{"tags":["see"]}]
5151// Message: Sentence must end with a period.
5152
5153/**
5154 * @param foo Foo bar
5155 */
5156function quux (foo) {
5157
5158}
5159// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5160// Options: [{"tags":["param"]}]
5161// Message: Sentence must end with a period.
5162````
5163
5164The following patterns are not considered problems:
5165
5166````js
5167/**
5168 * @param foo - Foo.
5169 */
5170function quux () {
5171
5172}
5173
5174/**
5175 * Foo.
5176 */
5177function quux () {
5178
5179}
5180
5181/**
5182 * Foo.
5183 * Bar.
5184 */
5185function quux () {
5186
5187}
5188
5189/**
5190 * Foo.
5191 *
5192 * Bar.
5193 */
5194function quux () {
5195
5196}
5197
5198/**
5199 * Тест.
5200 */
5201function quux () {
5202
5203}
5204
5205/**
5206 * Foo
5207 * bar.
5208 */
5209function quux () {
5210
5211}
5212
5213/**
5214 * @returns Foo bar.
5215 */
5216function quux () {
5217
5218}
5219
5220/**
5221 * Foo. {@see Math.sin}.
5222 */
5223function quux () {
5224
5225}
5226
5227/**
5228 * Foo {@see Math.sin} bar.
5229 */
5230function quux () {
5231
5232}
5233
5234/**
5235 * Foo?
5236 *
5237 * Bar!
5238 *
5239 * Baz:
5240 * 1. Foo.
5241 * 2. Bar.
5242 */
5243function quux () {
5244
5245}
5246
5247/**
5248 * Hello:
5249 * World.
5250 */
5251function quux () {
5252
5253}
5254
5255/**
5256 * Hello: world.
5257 */
5258function quux () {
5259
5260}
5261
5262/**
5263 *
5264 */
5265function quux () {
5266
5267}
5268
5269/**
5270 * @description Foo.
5271 */
5272function quux () {
5273
5274}
5275
5276/**
5277 * `foo` is a variable.
5278 */
5279function quux () {
5280
5281}
5282
5283/**
5284 * Foo.
5285 *
5286 * `foo`.
5287 */
5288function quux () {
5289
5290}
5291
5292/**
5293 * @param foo - `bar`.
5294 */
5295function quux () {
5296
5297}
5298
5299/**
5300 * @returns {number} `foo`.
5301 */
5302function quux () {
5303
5304}
5305
5306/**
5307 * Foo
5308 * `bar`.
5309 */
5310function quux () {
5311
5312}
5313
5314/**
5315 * @example Foo
5316 */
5317function quux () {
5318
5319}
5320
5321/**
5322 * @see Foo
5323 */
5324function quux () {
5325
5326}
5327
5328/**
5329 * Foo.
5330 *
5331 * @param foo Foo.
5332 */
5333function quux (foo) {
5334
5335}
5336
5337/**
5338 * Foo.
5339 *
5340 * @param foo Foo.
5341 */
5342function quux (foo) {
5343
5344}
5345// Options: [{"tags":["param"]}]
5346
5347/**
5348 * @param foo Foo bar.
5349 */
5350function quux (foo) {
5351
5352}
5353// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5354// Options: [{"tags":["param"]}]
5355
5356/**
5357 *
5358 */
5359function quux (foo) {
5360
5361}
5362// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5363
5364/**
5365* We stop loading Items when we have loaded:
5366*
5367* 1) The main Item;
5368* 2) All its variants.
5369*/
5370
5371/**
5372 * This method is working on 2 steps.
5373 *
5374 * | Step | Comment |
5375 * |------|-------------|
5376 * | 1 | do it |
5377 * | 2 | do it again |
5378 */
5379````
5380
5381
5382<a name="eslint-plugin-jsdoc-rules-require-description"></a>
5383### <code>require-description</code>
5384
5385Requires that all functions have a description.
5386
5387* All functions must have an implicit description or have the option
5388 `descriptionStyle` set to `tag`.
5389* Every jsdoc block description (or description tag if `descriptionStyle` is
5390 `"tag"`) must have a non-empty description that explains the purpose of the
5391 method.
5392
5393<a name="eslint-plugin-jsdoc-rules-require-description-options-11"></a>
5394#### Options
5395
5396An options object may have any of the following properties:
5397
5398- `contexts` - Set to an array of strings representing the AST context
5399 where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6
5400 classes). Overrides the default contexts (see below).
5401- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the
5402 document block avoids the need for a `@description`. Defaults to an
5403 empty array.
5404- `descriptionStyle` - Whether to accept implicit descriptions (`"body"`) or
5405 `@description` tags (`"tag"`) as satisfying the rule. Set to `"any"` to
5406 accept either style. Defaults to `"body"`.
5407
5408|||
5409|---|---|
5410|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
5411|Tags|`description` or jsdoc block|
5412|Aliases|`desc`|
5413|Options|`contexts`, `exemptedBy`, `descriptionStyle`|
5414|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
5415
5416The following patterns are considered problems:
5417
5418````js
5419/**
5420 *
5421 */
5422function quux () {
5423
5424}
5425// Options: [{"descriptionStyle":"tag"}]
5426// Message: Missing JSDoc @description declaration.
5427
5428/**
5429 *
5430 */
5431function quux () {
5432
5433}
5434// Options: [{"descriptionStyle":"any"}]
5435// Message: Missing JSDoc block description or @description declaration.
5436
5437/**
5438 *
5439 */
5440function quux () {
5441
5442}
5443// Options: [{"descriptionStyle":"body"}]
5444// Message: Missing JSDoc block description.
5445
5446/**
5447 *
5448 */
5449class quux {
5450
5451}
5452// Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
5453// Message: Missing JSDoc @description declaration.
5454
5455/**
5456 *
5457 */
5458class quux {
5459
5460}
5461// Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
5462// Message: Missing JSDoc @description declaration.
5463
5464/**
5465 *
5466 */
5467class quux {
5468
5469}
5470// Options: [{"contexts":["ClassDeclaration"],"descriptionStyle":"tag"}]
5471// Message: Missing JSDoc @description declaration.
5472
5473/**
5474 * @description
5475 */
5476function quux () {
5477
5478}
5479// Options: [{"descriptionStyle":"tag"}]
5480// Message: Missing JSDoc @description description.
5481
5482/**
5483 *
5484 */
5485interface quux {
5486
5487}
5488// Options: [{"contexts":["TSInterfaceDeclaration"],"descriptionStyle":"tag"}]
5489// Message: Missing JSDoc @description declaration.
5490
5491/**
5492 *
5493 */
5494var quux = class {
5495
5496};
5497// Options: [{"contexts":["ClassExpression"],"descriptionStyle":"tag"}]
5498// Message: Missing JSDoc @description declaration.
5499
5500/**
5501 *
5502 */
5503var quux = {
5504
5505};
5506// Options: [{"contexts":["ObjectExpression"],"descriptionStyle":"tag"}]
5507// Message: Missing JSDoc @description declaration.
5508
5509/**
5510 * @someDesc
5511 */
5512function quux () {
5513
5514}
5515// Settings: {"jsdoc":{"tagNamePreference":{"description":{"message":"Please avoid `{{tagName}}`; use `{{replacement}}` instead","replacement":"someDesc"}}}}
5516// Options: [{"descriptionStyle":"tag"}]
5517// Message: Missing JSDoc @someDesc description.
5518
5519/**
5520 * @description
5521 */
5522function quux () {
5523
5524}
5525// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5526// Options: [{"descriptionStyle":"tag"}]
5527// Message: Unexpected tag `@description`
5528
5529/**
5530 * @description
5531 */
5532function quux () {
5533
5534}
5535// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5536// Options: [{"descriptionStyle":"any"}]
5537// Message: Missing JSDoc block description or @description declaration.
5538
5539/**
5540 *
5541 */
5542function quux () {
5543}
5544// Options: [{"exemptedBy":["notPresent"]}]
5545// Message: Missing JSDoc block description.
5546````
5547
5548The following patterns are not considered problems:
5549
5550````js
5551/**
5552 * @description
5553 * // arbitrary description content
5554 */
5555function quux () {
5556
5557}
5558// Options: [{"descriptionStyle":"tag"}]
5559
5560/**
5561 * @description
5562 * quux(); // does something useful
5563 */
5564function quux () {
5565
5566}
5567// Options: [{"descriptionStyle":"tag"}]
5568
5569/**
5570 * @description <caption>Valid usage</caption>
5571 * quux(); // does something useful
5572 *
5573 * @description <caption>Invalid usage</caption>
5574 * quux('random unwanted arg'); // results in an error
5575 */
5576function quux () {
5577
5578}
5579// Options: [{"descriptionStyle":"tag"}]
5580
5581/**
5582 *
5583 */
5584class quux {
5585
5586}
5587// Options: [{"descriptionStyle":"tag"}]
5588
5589/**
5590 *
5591 */
5592function quux () {
5593
5594}
5595// Options: [{"contexts":["ClassDeclaration"]}]
5596
5597/**
5598 * @type {MyCallback}
5599 */
5600function quux () {
5601
5602}
5603// Options: [{"exemptedBy":["type"]}]
5604
5605/**
5606 *
5607 */
5608interface quux {
5609
5610}
5611// Options: [{"descriptionStyle":"tag"}]
5612
5613/**
5614 *
5615 */
5616var quux = class {
5617
5618};
5619// Options: [{"descriptionStyle":"tag"}]
5620
5621/**
5622 *
5623 */
5624var quux = {
5625
5626};
5627// Options: [{"descriptionStyle":"tag"}]
5628
5629/**
5630 * Has an implicit description
5631 */
5632function quux () {
5633
5634}
5635// Options: [{"descriptionStyle":"body"}]
5636
5637/**
5638 * Has an implicit description
5639 */
5640function quux () {
5641
5642}
5643
5644/**
5645 * Has an implicit description
5646 */
5647function quux () {
5648
5649}
5650// Options: [{"descriptionStyle":"any"}]
5651
5652/**
5653 * @description Has an explicit description
5654 */
5655function quux () {
5656
5657}
5658// Options: [{"descriptionStyle":"any"}]
5659
5660/**
5661 *
5662 */
5663function quux () {
5664
5665}
5666// Settings: {"jsdoc":{"tagNamePreference":{"description":false}}}
5667````
5668
5669
5670<a name="eslint-plugin-jsdoc-rules-require-example"></a>
5671### <code>require-example</code>
5672
5673Requires that all functions have examples.
5674
5675* All functions must have one or more `@example` tags.
5676* Every example tag must have a non-empty description that explains the method's usage.
5677
5678<a name="eslint-plugin-jsdoc-rules-require-example-options-12"></a>
5679#### Options
5680
5681This rule has an object option.
5682
5683<a name="eslint-plugin-jsdoc-rules-require-example-options-12-exemptedby"></a>
5684##### <code>exemptedBy</code>
5685
5686Array of tags (e.g., `['type']`) whose presence on the document
5687block avoids the need for an `@example`. Defaults to an empty array.
5688
5689<a name="eslint-plugin-jsdoc-rules-require-example-options-12-avoidexampleonconstructors"></a>
5690##### <code>avoidExampleOnConstructors</code>
5691
5692Set to `true` to avoid the need for an example on a constructor (whether
5693indicated as such by a jsdoc tag or by being within an ES6 `class`).
5694Defaults to `false`.
5695
5696<a name="eslint-plugin-jsdoc-rules-require-example-options-12-contexts-1"></a>
5697##### <code>contexts</code>
5698
5699Set this to an array of strings representing the AST context
5700where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
5701Overrides the default contexts (see below).
5702
5703<a name="eslint-plugin-jsdoc-rules-require-example-fixer"></a>
5704#### Fixer
5705
5706The fixer for `require-example` will add an empty `@example`, but it will still
5707report a missing example description after this is added.
5708
5709|||
5710|---|---|
5711|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
5712|Tags|`example`|
5713|Options|`exemptedBy`, `avoidExampleOnConstructors`, `contexts`|
5714|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
5715
5716The following patterns are considered problems:
5717
5718````js
5719/**
5720 *
5721 */
5722function quux () {
5723
5724}
5725// Message: Missing JSDoc @example declaration.
5726
5727/**
5728 * @example
5729 */
5730function quux () {
5731
5732}
5733// Message: Missing JSDoc @example description.
5734
5735/**
5736 * @constructor
5737 */
5738function f () {
5739
5740}
5741// Settings: {"jsdoc":{"avoidExampleOnConstructors":true}}
5742// Message: `settings.jsdoc.avoidExampleOnConstructors` has been removed, use options in the rule `require-example` instead.
5743
5744/**
5745 * @constructor
5746 */
5747function quux () {
5748
5749}
5750// Message: Missing JSDoc @example declaration.
5751
5752/**
5753 * @constructor
5754 * @example
5755 */
5756function quux () {
5757
5758}
5759// Message: Missing JSDoc @example description.
5760
5761/**
5762 *
5763 */
5764class quux {
5765
5766}
5767// Options: [{"contexts":["ClassDeclaration"]}]
5768// Message: Missing JSDoc @example declaration.
5769
5770/**
5771 *
5772 */
5773function quux () {
5774}
5775// Options: [{"exemptedBy":["notPresent"]}]
5776// Message: Missing JSDoc @example declaration.
5777````
5778
5779The following patterns are not considered problems:
5780
5781````js
5782/**
5783 * @example
5784 * // arbitrary example content
5785 */
5786function quux () {
5787
5788}
5789
5790/**
5791 * @example
5792 * quux(); // does something useful
5793 */
5794function quux () {
5795
5796}
5797
5798/**
5799 * @example <caption>Valid usage</caption>
5800 * quux(); // does something useful
5801 *
5802 * @example <caption>Invalid usage</caption>
5803 * quux('random unwanted arg'); // results in an error
5804 */
5805function quux () {
5806
5807}
5808
5809/**
5810 * @constructor
5811 */
5812function quux () {
5813
5814}
5815// Options: [{"avoidExampleOnConstructors":true}]
5816
5817/**
5818 * @constructor
5819 * @example
5820 */
5821function quux () {
5822
5823}
5824// Options: [{"avoidExampleOnConstructors":true}]
5825
5826class Foo {
5827 /**
5828 *
5829 */
5830 constructor () {
5831
5832 }
5833}
5834// Options: [{"avoidExampleOnConstructors":true}]
5835
5836/**
5837 * @inheritdoc
5838 */
5839function quux () {
5840
5841}
5842
5843/**
5844 * @type {MyCallback}
5845 */
5846function quux () {
5847
5848}
5849// Options: [{"exemptedBy":["type"]}]
5850
5851/**
5852 * @example Some example code
5853 */
5854class quux {
5855
5856}
5857// Options: [{"contexts":["ClassDeclaration"]}]
5858
5859/**
5860 *
5861 */
5862function quux () {
5863
5864}
5865// Options: [{"contexts":["ClassDeclaration"]}]
5866````
5867
5868
5869<a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description"></a>
5870### <code>require-hyphen-before-param-description</code>
5871
5872Requires a hyphen before the `@param` description.
5873
5874<a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description-options-13"></a>
5875#### Options
5876
5877This 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"`.
5878
5879|||
5880|---|---|
5881|Context|everywhere|
5882|Tags|`param`|
5883|Aliases|`arg`, `argument`|
5884|Options|(a string matching `"always"|"never"`)|
5885
5886The following patterns are considered problems:
5887
5888````js
5889/**
5890 * @param foo Foo.
5891 */
5892function quux () {
5893
5894}
5895// Options: ["always"]
5896// Message: There must be a hyphen before @param description.
5897
5898/**
5899 * @param foo Foo.
5900 */
5901function quux () {
5902
5903}
5904// Message: There must be a hyphen before @param description.
5905
5906/**
5907 * @param foo - Foo.
5908 */
5909function quux () {
5910
5911}
5912// Options: ["never"]
5913// Message: There must be no hyphen before @param description.
5914
5915/**
5916 * @param foo - foo
5917 * @param foo foo
5918 */
5919function quux () {
5920
5921}
5922// Options: ["always"]
5923// Message: There must be a hyphen before @param description.
5924
5925/**
5926 * @param foo foo
5927 * bar
5928 * @param bar - bar
5929 */
5930function quux () {
5931
5932}
5933// Options: ["always"]
5934// Message: There must be a hyphen before @param description.
5935
5936/**
5937 * @param foo
5938 */
5939function quux (foo) {
5940
5941}
5942// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
5943// Message: Unexpected tag `@param`
5944````
5945
5946The following patterns are not considered problems:
5947
5948````js
5949/**
5950 * @param foo - Foo.
5951 */
5952function quux () {
5953
5954}
5955// Options: ["always"]
5956
5957/**
5958 * @param foo Foo.
5959 */
5960function quux () {
5961
5962}
5963// Options: ["never"]
5964
5965/**
5966 * @param foo
5967 */
5968function quux () {
5969
5970}
5971````
5972
5973
5974<a name="eslint-plugin-jsdoc-rules-require-jsdoc"></a>
5975### <code>require-jsdoc</code>
5976
5977Checks for presence of jsdoc comments, on class declarations as well as
5978functions.
5979
5980<a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-14"></a>
5981#### Options
5982
5983Accepts one optional options object with the following optional keys.
5984
5985- `publicOnly` - This option will insist that missing jsdoc blocks are
5986 only reported for function bodies / class declarations that are exported
5987 from the module. May be a boolean or object. If set to `true`, the defaults
5988 below will be used. If unset, jsdoc block reporting will not be limited to
5989 exports.
5990
5991 This object supports the following optional boolean keys (`false` unless
5992 otherwise noted):
5993
5994 - `ancestorsOnly` - Only check node ancestors to check if node is exported
5995 - `esm` - ESM exports are checked for JSDoc comments (Defaults to `true`)
5996 - `cjs` - CommonJS exports are checked for JSDoc comments (Defaults to `true`)
5997 - `window` - Window global exports are checked for JSDoc comments
5998
5999- `require` - An object with the following optional boolean keys which all
6000 default to `false` except as noted, indicating the contexts where the rule
6001 will apply:
6002
6003 - `ArrowFunctionExpression`
6004 - `ClassDeclaration`
6005 - `ClassExpression`
6006 - `FunctionDeclaration` (defaults to `true`)
6007 - `FunctionExpression`
6008 - `MethodDefinition`
6009
6010- `contexts` - Set this to an array of strings representing the additional
6011 AST contexts where you wish the rule to be applied (e.g., `Property` for
6012 properties). Defaults to an empty array.
6013
6014- `exemptEmptyFunctions` (default: false) - When `true`, the rule will not report
6015 missing jsdoc blocks above functions/methods with no parameters or return values
6016 (intended where variable names are sufficient for themselves as documentation).
6017
6018|||
6019|---|---|
6020|Context|`ArrowFunctionExpression`, `ClassDeclaration`, `ClassExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
6021|Tags|N/A|
6022|Options|`publicOnly`, `require`, `contexts`, `exemptEmptyFunctions`|
6023
6024The following patterns are considered problems:
6025
6026````js
6027/**
6028 * @func myFunction
6029 */
6030function myFunction() {
6031
6032}
6033// Settings: {"jsdoc":{"maxLines":3,"minLines":2}}
6034// Message: Missing JSDoc comment.
6035
6036/**
6037 * @func myFunction
6038 */
6039
6040
6041function myFunction() {
6042
6043}
6044// Settings: {"jsdoc":{"maxLines":2}}
6045// Message: Missing JSDoc comment.
6046
6047/** @func myFunction */ function myFunction() {
6048
6049}
6050// Settings: {"jsdoc":{"minLines":1}}
6051// Message: Missing JSDoc comment.
6052
6053export var test = function () {
6054
6055};
6056// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6057// Message: Missing JSDoc comment.
6058
6059function test () {
6060
6061}
6062export var test2 = test;
6063// Options: [{"publicOnly":true,"require":{"FunctionDeclaration":true}}]
6064// Message: Missing JSDoc comment.
6065
6066export const test = () => {
6067
6068};
6069// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
6070// Message: Missing JSDoc comment.
6071
6072export let test = class {
6073
6074};
6075// Options: [{"publicOnly":true,"require":{"ClassExpression":true}}]
6076// Message: Missing JSDoc comment.
6077
6078export default function () {}
6079// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
6080// Message: Missing JSDoc comment.
6081
6082export default () => {}
6083// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"ArrowFunctionExpression":true}}]
6084// Message: Missing JSDoc comment.
6085
6086export default (function () {})
6087// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
6088// Message: Missing JSDoc comment.
6089
6090export default class {}
6091// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"ClassDeclaration":true}}]
6092// Message: Missing JSDoc comment.
6093
6094function quux (foo) {
6095
6096}
6097// Message: Missing JSDoc comment.
6098
6099
6100// Settings: {"jsdoc":{"exemptEmptyFunctions":true}}
6101// Message: `settings.jsdoc.exemptEmptyFunctions` has been removed, use options in the rule `require-jsdoc` instead.
6102
6103function quux (foo) {
6104
6105}
6106// Options: [{"exemptEmptyFunctions":true}]
6107// Message: Missing JSDoc comment.
6108
6109function quux (foo) {
6110
6111}
6112// Settings: {"jsdoc":{"minLines":2}}
6113// Options: [{"exemptEmptyFunctions":true}]
6114// Message: Missing JSDoc comment.
6115
6116function myFunction() {}
6117// Message: Missing JSDoc comment.
6118
6119/**
6120 * Description for A.
6121 */
6122class A {
6123 constructor(xs) {
6124 this.a = xs;
6125 }
6126}
6127// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6128// Message: Missing JSDoc comment.
6129
6130class A {
6131 /**
6132 * Description for constructor.
6133 * @param {object[]} xs - xs
6134 */
6135 constructor(xs) {
6136 this.a = xs;
6137 }
6138}
6139// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6140// Message: Missing JSDoc comment.
6141
6142class A extends B {
6143 /**
6144 * Description for constructor.
6145 * @param {object[]} xs - xs
6146 */
6147 constructor(xs) {
6148 this.a = xs;
6149 }
6150}
6151// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6152// Message: Missing JSDoc comment.
6153
6154export class A extends B {
6155 /**
6156 * Description for constructor.
6157 * @param {object[]} xs - xs
6158 */
6159 constructor(xs) {
6160 this.a = xs;
6161 }
6162}
6163// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6164// Message: Missing JSDoc comment.
6165
6166export default class A extends B {
6167 /**
6168 * Description for constructor.
6169 * @param {object[]} xs - xs
6170 */
6171 constructor(xs) {
6172 this.a = xs;
6173 }
6174}
6175// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6176// Message: Missing JSDoc comment.
6177
6178var myFunction = () => {}
6179// Options: [{"require":{"ArrowFunctionExpression":true}}]
6180// Message: Missing JSDoc comment.
6181
6182var myFunction = () => () => {}
6183// Options: [{"require":{"ArrowFunctionExpression":true}}]
6184// Message: Missing JSDoc comment.
6185
6186var foo = function() {}
6187// Options: [{"require":{"FunctionExpression":true}}]
6188// Message: Missing JSDoc comment.
6189
6190const foo = {bar() {}}
6191// Options: [{"require":{"FunctionExpression":true}}]
6192// Message: Missing JSDoc comment.
6193
6194var foo = {bar: function() {}}
6195// Options: [{"require":{"FunctionExpression":true}}]
6196// Message: Missing JSDoc comment.
6197
6198function foo (abc) {}
6199// Options: [{"exemptEmptyFunctions":false}]
6200// Message: Missing JSDoc comment.
6201
6202function foo () {
6203 return true;
6204}
6205// Options: [{"exemptEmptyFunctions":false}]
6206// Message: Missing JSDoc comment.
6207
6208module.exports = function quux () {
6209
6210}
6211// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6212// Message: Missing JSDoc comment.
6213
6214module.exports = function quux () {
6215
6216}
6217// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
6218// Message: Missing JSDoc comment.
6219
6220module.exports = {
6221 method: function() {
6222
6223 }
6224}
6225// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6226// Message: Missing JSDoc comment.
6227
6228module.exports = {
6229 test: {
6230 test2: function() {
6231
6232 }
6233 }
6234}
6235// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6236// Message: Missing JSDoc comment.
6237
6238module.exports = {
6239 test: {
6240 test2: function() {
6241
6242 }
6243 }
6244}
6245// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
6246// Message: Missing JSDoc comment.
6247
6248const test = module.exports = function () {
6249
6250}
6251// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6252// Message: Missing JSDoc comment.
6253
6254/**
6255*
6256*/
6257const test = module.exports = function () {
6258
6259}
6260
6261test.prototype.method = function() {}
6262// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6263// Message: Missing JSDoc comment.
6264
6265const test = function () {
6266
6267}
6268module.exports = {
6269 test: test
6270}
6271// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6272// Message: Missing JSDoc comment.
6273
6274const test = () => {
6275
6276}
6277module.exports = {
6278 test: test
6279}
6280// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
6281// Message: Missing JSDoc comment.
6282
6283class Test {
6284 method() {
6285
6286 }
6287}
6288module.exports = Test;
6289// Options: [{"publicOnly":true,"require":{"MethodDefinition":true}}]
6290// Message: Missing JSDoc comment.
6291
6292export default function quux () {
6293
6294}
6295// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6296// Message: Missing JSDoc comment.
6297
6298export default function quux () {
6299
6300}
6301// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
6302// Message: Missing JSDoc comment.
6303
6304function quux () {
6305
6306}
6307export default quux;
6308// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6309// Message: Missing JSDoc comment.
6310
6311export function test() {
6312
6313}
6314// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6315// Message: Missing JSDoc comment.
6316
6317export function test() {
6318
6319}
6320// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
6321// Message: Missing JSDoc comment.
6322
6323var test = function () {
6324
6325}
6326var test2 = 2;
6327export { test, test2 }
6328// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6329// Message: Missing JSDoc comment.
6330
6331var test = function () {
6332
6333}
6334export { test as test2 }
6335// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6336// Message: Missing JSDoc comment.
6337
6338export default class A {
6339
6340}
6341// Options: [{"publicOnly":true,"require":{"ClassDeclaration":true}}]
6342// Message: Missing JSDoc comment.
6343
6344export default class A {
6345
6346}
6347// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true}}]
6348// Message: Missing JSDoc comment.
6349
6350var test = function () {
6351
6352}
6353// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
6354// Message: Missing JSDoc comment.
6355
6356window.test = function () {
6357
6358}
6359// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
6360// Message: Missing JSDoc comment.
6361
6362function test () {
6363
6364}
6365// Options: [{"publicOnly":{"window":true}}]
6366// Message: Missing JSDoc comment.
6367
6368module.exports = function() {
6369
6370}
6371// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionExpression":true}}]
6372// Message: Missing JSDoc comment.
6373
6374export function someMethod() {
6375
6376}
6377// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
6378// Message: Missing JSDoc comment.
6379
6380export function someMethod() {
6381
6382}
6383// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionDeclaration":true}}]
6384// Message: Missing JSDoc comment.
6385
6386const myObject = {
6387 myProp: true
6388};
6389// Options: [{"contexts":["Property"]}]
6390// Message: Missing JSDoc comment.
6391````
6392
6393The following patterns are not considered problems:
6394
6395````js
6396var array = [1,2,3];
6397array.forEach(function() {});
6398
6399/**
6400 * @class MyClass
6401 **/
6402function MyClass() {}
6403
6404/**
6405 Function doing something
6406 */
6407function myFunction() {}
6408/**
6409 Function doing something
6410 */
6411var myFunction = function() {};
6412/**
6413 Function doing something
6414 */
6415Object.myFunction = function () {};
6416var obj = {
6417 /**
6418 * Function doing something
6419 **/
6420 myFunction: function () {} };
6421
6422/**
6423 @func myFunction
6424 */
6425function myFunction() {}
6426/**
6427 @method myFunction
6428 */
6429function myFunction() {}
6430/**
6431 @function myFunction
6432 */
6433function myFunction() {}
6434
6435/**
6436 @func myFunction
6437 */
6438var myFunction = function () {}
6439/**
6440 @method myFunction
6441 */
6442var myFunction = function () {}
6443/**
6444 @function myFunction
6445 */
6446var myFunction = function () {}
6447
6448/**
6449 @func myFunction
6450 */
6451Object.myFunction = function() {}
6452/**
6453 @method myFunction
6454 */
6455Object.myFunction = function() {}
6456/**
6457 @function myFunction
6458 */
6459Object.myFunction = function() {}
6460(function(){})();
6461
6462var object = {
6463 /**
6464 * @func myFunction - Some function
6465 */
6466 myFunction: function() {} }
6467var object = {
6468 /**
6469 * @method myFunction - Some function
6470 */
6471 myFunction: function() {} }
6472var object = {
6473 /**
6474 * @function myFunction - Some function
6475 */
6476 myFunction: function() {} }
6477
6478var array = [1,2,3];
6479array.filter(function() {});
6480Object.keys(this.options.rules || {}).forEach(function(name) {}.bind(this));
6481var object = { name: 'key'};
6482Object.keys(object).forEach(function() {})
6483
6484/**
6485 * @func myFunction
6486 */
6487
6488function myFunction() {
6489
6490}
6491// Settings: {"jsdoc":{"maxLines":2,"minLines":0}}
6492
6493/**
6494 * @func myFunction
6495 */
6496
6497
6498function myFunction() {
6499
6500}
6501// Settings: {"jsdoc":{"maxLines":3,"minLines":0}}
6502
6503/** @func myFunction */ function myFunction() {
6504
6505}
6506// Settings: {"jsdoc":{"maxLines":0,"minLines":0}}
6507
6508/**
6509 * @func myFunction
6510 */
6511
6512function myFunction() {
6513
6514}
6515// Settings: {"jsdoc":{"maxLines":3,"minLines":2}}
6516
6517function myFunction() {}
6518// Options: [{"require":{"ClassDeclaration":true,"FunctionDeclaration":false,"MethodDefinition":true}}]
6519
6520var myFunction = function() {}
6521// Options: [{"require":{"ClassDeclaration":true,"FunctionDeclaration":false,"MethodDefinition":true}}]
6522
6523/**
6524 * Description for A.
6525 */
6526class A {
6527 /**
6528 * Description for constructor.
6529 * @param {object[]} xs - xs
6530 */
6531 constructor(xs) {
6532 this.a = xs;
6533 }
6534}
6535// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6536
6537/**
6538 * Description for A.
6539 */
6540class App extends Component {
6541 /**
6542 * Description for constructor.
6543 * @param {object[]} xs - xs
6544 */
6545 constructor(xs) {
6546 this.a = xs;
6547 }
6548}
6549// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6550
6551/**
6552 * Description for A.
6553 */
6554export default class App extends Component {
6555 /**
6556 * Description for constructor.
6557 * @param {object[]} xs - xs
6558 */
6559 constructor(xs) {
6560 this.a = xs;
6561 }
6562}
6563// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6564
6565/**
6566 * Description for A.
6567 */
6568export class App extends Component {
6569 /**
6570 * Description for constructor.
6571 * @param {object[]} xs - xs
6572 */
6573 constructor(xs) {
6574 this.a = xs;
6575 }
6576}
6577// Options: [{"require":{"ClassDeclaration":true,"MethodDefinition":true}}]
6578
6579class A {
6580 constructor(xs) {
6581 this.a = xs;
6582 }
6583}
6584// Options: [{"require":{"ClassDeclaration":false,"MethodDefinition":false}}]
6585
6586/**
6587* Function doing something
6588*/
6589var myFunction = () => {}
6590// Options: [{"require":{"ArrowFunctionExpression":true}}]
6591
6592/**
6593* Function doing something
6594*/
6595var myFunction = function () {}
6596// Options: [{"require":{"ArrowFunctionExpression":true}}]
6597
6598/**
6599* Function doing something
6600*/
6601var myFunction = () => {}
6602// Options: [{"require":{"ArrowFunctionExpression":false}}]
6603
6604/**
6605 Function doing something
6606*/
6607var myFunction = () => () => {}
6608// Options: [{"require":{"ArrowFunctionExpression":true}}]
6609
6610setTimeout(() => {}, 10);
6611// Options: [{"require":{"ArrowFunctionExpression":true}}]
6612
6613/**
6614JSDoc Block
6615*/
6616var foo = function() {}
6617// Options: [{"require":{"FunctionExpression":true}}]
6618
6619const foo = {/**
6620JSDoc Block
6621*/
6622bar() {}}
6623// Options: [{"require":{"FunctionExpression":true}}]
6624
6625var foo = {/**
6626JSDoc Block
6627*/
6628bar: function() {}}
6629// Options: [{"require":{"FunctionExpression":true}}]
6630
6631var foo = { [function() {}]: 1 };
6632// Options: [{"require":{"FunctionExpression":true}}]
6633
6634function foo () {}
6635// Options: [{"exemptEmptyFunctions":true}]
6636
6637function foo () {
6638 return;
6639}
6640// Options: [{"exemptEmptyFunctions":true}]
6641
6642const test = {};
6643/**
6644 * test
6645 */
6646 test.method = function () {
6647
6648}
6649module.exports = {
6650 prop: { prop2: test.method }
6651}
6652// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6653
6654/**
6655 *
6656 */
6657function test() {
6658
6659}
6660
6661module.exports = {
6662 prop: { prop2: test }
6663}
6664// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6665
6666/**
6667 *
6668 */
6669test = function() {
6670
6671}
6672
6673module.exports = {
6674 prop: { prop2: test }
6675}
6676// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionExpression":true}}]
6677
6678/**
6679 *
6680 */
6681test = function() {
6682
6683}
6684
6685exports.someMethod = {
6686 prop: { prop2: test }
6687}
6688// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
6689
6690/**
6691 *
6692 */
6693const test = () => {
6694
6695}
6696
6697module.exports = {
6698prop: { prop2: test }
6699}
6700// Options: [{"publicOnly":true,"require":{"ArrowFunctionExpression":true}}]
6701
6702const test = () => {
6703
6704}
6705module.exports = {
6706 prop: { prop2: test }
6707}
6708// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"ArrowFunctionExpression":true}}]
6709
6710/**
6711 *
6712 */
6713window.test = function() {
6714
6715}
6716
6717module.exports = {
6718prop: window
6719}
6720// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6721
6722test = function() {
6723
6724}
6725
6726/**
6727 *
6728 */
6729test = function() {
6730
6731}
6732
6733module.exports = {
6734prop: { prop2: test }
6735}
6736// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6737
6738test = function() {
6739
6740}
6741
6742test = 2;
6743
6744module.exports = {
6745prop: { prop2: test }
6746}
6747// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6748
6749/**
6750 *
6751 */
6752function test() {
6753
6754}
6755
6756/**
6757 *
6758 */
6759test.prototype.method = function() {
6760
6761}
6762
6763module.exports = {
6764prop: { prop2: test }
6765}
6766// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6767
6768class Test {
6769 /**
6770 * Test
6771 */
6772 method() {
6773
6774 }
6775}
6776module.exports = Test;
6777// Options: [{"publicOnly":true,"require":{"MethodDefinition":true}}]
6778
6779/**
6780 *
6781 */
6782export default function quux () {
6783
6784}
6785// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6786
6787/**
6788 *
6789 */
6790export default function quux () {
6791
6792}
6793// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
6794
6795/**
6796 *
6797 */
6798function quux () {
6799
6800}
6801export default quux;
6802// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6803
6804function quux () {
6805
6806}
6807export default quux;
6808// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
6809
6810/**
6811 *
6812 */
6813export function test() {
6814
6815}
6816// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6817
6818/**
6819 *
6820 */
6821export function test() {
6822
6823}
6824// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"FunctionExpression":true}}]
6825
6826/**
6827 *
6828 */
6829var test = function () {
6830
6831}
6832var test2 = 2;
6833export { test, test2 }
6834// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6835
6836/**
6837 *
6838 */
6839var test = function () {
6840
6841}
6842export { test as test2 }
6843// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6844
6845/**
6846 *
6847 */
6848export default class A {
6849
6850}
6851// Options: [{"publicOnly":{"ancestorsOnly":true},"require":{"ClassDeclaration":true}}]
6852
6853/**
6854 *
6855 */
6856var test = function () {
6857
6858}
6859// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
6860
6861let test = function () {
6862
6863}
6864// Options: [{"publicOnly":{"window":true},"require":{"FunctionExpression":true}}]
6865
6866let test = class {
6867
6868}
6869// Options: [{"publicOnly":true,"require":{"ClassExpression":false}}]
6870
6871/**
6872 *
6873 */
6874let test = class {
6875
6876}
6877// Options: [{"publicOnly":true,"require":{"ClassExpression":true}}]
6878
6879export function someMethod() {
6880
6881}
6882// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionDeclaration":true}}]
6883
6884export function someMethod() {
6885
6886}
6887// Options: [{"publicOnly":{"cjs":true,"esm":false,"window":false},"require":{"FunctionDeclaration":true}}]
6888
6889exports.someMethod = function() {
6890
6891}
6892// Options: [{"publicOnly":{"cjs":false,"esm":true,"window":false},"require":{"FunctionExpression":true}}]
6893
6894const myObject = {
6895 myProp: true
6896};
6897// Options: [{"contexts":[]}]
6898
6899function bear() {}
6900/**
6901 *
6902 */
6903function quux () {
6904}
6905export default quux;
6906// Options: [{"publicOnly":true,"require":{"FunctionExpression":true}}]
6907
6908/**
6909 * This example interface is great!
6910 */
6911export interface Example {
6912 /**
6913 * My super test string!
6914 */
6915 test: string
6916}
6917// Options: [{"contexts":["TSInterfaceDeclaration"]}]
6918
6919/**
6920 * This example interface is great!
6921 */
6922interface Example {
6923 /**
6924 * My super test string!
6925 */
6926 test: string
6927}
6928// Options: [{"contexts":["TSInterfaceDeclaration"]}]
6929
6930/**
6931 * This example type is great!
6932 */
6933export type Example = {
6934 /**
6935 * My super test string!
6936 */
6937 test: string
6938};
6939// Options: [{"contexts":["TSTypeAliasDeclaration"]}]
6940
6941/**
6942 * This example type is great!
6943 */
6944type Example = {
6945 /**
6946 * My super test string!
6947 */
6948 test: string
6949};
6950// Options: [{"contexts":["TSTypeAliasDeclaration"]}]
6951
6952/**
6953 * This example enum is great!
6954 */
6955export enum Example {
6956 /**
6957 * My super test enum!
6958 */
6959 test = 123
6960}
6961// Options: [{"contexts":["TSEnumDeclaration"]}]
6962
6963/**
6964 * This example enum is great!
6965 */
6966enum Example {
6967 /**
6968 * My super test enum!
6969 */
6970 test = 123
6971}
6972// Options: [{"contexts":["TSEnumDeclaration"]}]
6973
6974const foo = {...{}};
6975function bar() {}
6976// Options: [{"exemptEmptyFunctions":false,"publicOnly":true,"require":{"ArrowFunctionExpression":true,"ClassDeclaration":true,"ClassExpression":true,"FunctionDeclaration":true,"FunctionExpression":false,"MethodDefinition":true}}]
6977````
6978
6979
6980<a name="eslint-plugin-jsdoc-rules-require-param-description"></a>
6981### <code>require-param-description</code>
6982
6983Requires that `@param` tag has `description` value.
6984
6985|||
6986|---|---|
6987|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
6988|Tags|`param`|
6989|Aliases|`arg`, `argument`|
6990
6991The following patterns are considered problems:
6992
6993````js
6994/**
6995 * @param foo
6996 */
6997function quux (foo) {
6998
6999}
7000// Message: Missing JSDoc @param "foo" description.
7001
7002/**
7003 * @arg foo
7004 */
7005function quux (foo) {
7006
7007}
7008// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
7009// Message: Missing JSDoc @arg "foo" description.
7010
7011/**
7012 * @param foo
7013 */
7014function quux (foo) {
7015
7016}
7017// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
7018// Message: Unexpected tag `@param`
7019````
7020
7021The following patterns are not considered problems:
7022
7023````js
7024/**
7025 *
7026 */
7027function quux (foo) {
7028
7029}
7030
7031/**
7032 * @param foo Foo.
7033 */
7034function quux (foo) {
7035
7036}
7037````
7038
7039
7040<a name="eslint-plugin-jsdoc-rules-require-param-name"></a>
7041### <code>require-param-name</code>
7042
7043Requires that all function parameters have name.
7044
7045> 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.
7046>
7047> [JSDoc](https://jsdoc.app/tags-param.html#overview)
7048
7049|||
7050|---|---|
7051|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
7052|Tags|`param`|
7053|Aliases|`arg`, `argument`|
7054
7055The following patterns are considered problems:
7056
7057````js
7058/**
7059 * @param
7060 */
7061function quux (foo) {
7062
7063}
7064// Message: There must be an identifier after @param type.
7065
7066/**
7067 * @param {string}
7068 */
7069function quux (foo) {
7070
7071}
7072// Message: There must be an identifier after @param tag.
7073
7074/**
7075 * @param foo
7076 */
7077function quux (foo) {
7078
7079}
7080// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
7081// Message: Unexpected tag `@param`
7082````
7083
7084The following patterns are not considered problems:
7085
7086````js
7087/**
7088 * @param foo
7089 */
7090function quux (foo) {
7091
7092}
7093
7094/**
7095 * @param {string} foo
7096 */
7097function quux (foo) {
7098
7099}
7100````
7101
7102
7103<a name="eslint-plugin-jsdoc-rules-require-param-type"></a>
7104### <code>require-param-type</code>
7105
7106Requires that `@param` tag has `type` value.
7107
7108|||
7109|---|---|
7110|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
7111|Tags|`param`|
7112|Aliases|`arg`, `argument`|
7113
7114The following patterns are considered problems:
7115
7116````js
7117/**
7118 * @param foo
7119 */
7120function quux (foo) {
7121
7122}
7123// Message: Missing JSDoc @param "foo" type.
7124
7125/**
7126 * @arg foo
7127 */
7128function quux (foo) {
7129
7130}
7131// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
7132// Message: Missing JSDoc @arg "foo" type.
7133
7134/**
7135 * @param foo
7136 */
7137function quux (foo) {
7138
7139}
7140// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
7141// Message: Unexpected tag `@param`
7142````
7143
7144The following patterns are not considered problems:
7145
7146````js
7147/**
7148 *
7149 */
7150function quux (foo) {
7151
7152}
7153
7154/**
7155 * @param {number} foo
7156 */
7157function quux (foo) {
7158
7159}
7160````
7161
7162
7163<a name="eslint-plugin-jsdoc-rules-require-param"></a>
7164### <code>require-param</code>
7165
7166Requires that all function parameters are documented.
7167
7168<a name="eslint-plugin-jsdoc-rules-require-param-options-15"></a>
7169#### Options
7170
7171An options object accepts one optional property:
7172
7173- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
7174 block avoids the need for a `@param`. Defaults to an empty array.
7175
7176|||
7177|---|---|
7178|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
7179|Tags|`param`|
7180|Aliases|`arg`, `argument`|
7181|Options|`exemptedBy`|
7182|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
7183
7184The following patterns are considered problems:
7185
7186````js
7187/**
7188 *
7189 */
7190function quux (foo) {
7191
7192}
7193// Message: Missing JSDoc @param "foo" declaration.
7194
7195/**
7196 *
7197 */
7198function quux (foo, bar) {
7199
7200}
7201// Message: Missing JSDoc @param "foo" declaration.
7202
7203/**
7204 * @param foo
7205 */
7206function quux (foo, bar) {
7207
7208}
7209// Message: Missing JSDoc @param "bar" declaration.
7210
7211/**
7212 * @param bar
7213 */
7214function quux (foo, bar, baz) {
7215
7216}
7217// Message: Missing JSDoc @param "foo" declaration.
7218
7219/**
7220 * @param foo
7221 * @param bar
7222 */
7223function quux (foo, bar, baz) {
7224
7225}
7226// Message: Missing JSDoc @param "baz" declaration.
7227
7228/**
7229 * @param baz
7230 */
7231function quux (foo, bar, baz) {
7232
7233}
7234// Message: Missing JSDoc @param "foo" declaration.
7235
7236/**
7237 * @param
7238 */
7239function quux (foo) {
7240
7241}
7242// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
7243// Message: Missing JSDoc @arg "foo" declaration.
7244
7245/**
7246 * @param foo
7247 */
7248function quux (foo, bar) {
7249
7250}
7251// Message: Missing JSDoc @param "bar" declaration.
7252
7253/**
7254 * @override
7255 */
7256function quux (foo) {
7257
7258}
7259// Settings: {"jsdoc":{"overrideReplacesDocs":false}}
7260// Message: Missing JSDoc @param "foo" declaration.
7261
7262/**
7263 * @implements
7264 */
7265function quux (foo) {
7266
7267}
7268// Settings: {"jsdoc":{"implementsReplacesDocs":false}}
7269// Message: Missing JSDoc @param "foo" declaration.
7270
7271/**
7272 * @augments
7273 */
7274function quux (foo) {
7275
7276}
7277// Message: Missing JSDoc @param "foo" declaration.
7278
7279/**
7280 * @extends
7281 */
7282function quux (foo) {
7283
7284}
7285// Message: Missing JSDoc @param "foo" declaration.
7286
7287/**
7288 * @override
7289 */
7290class A {
7291 /**
7292 *
7293 */
7294 quux (foo) {
7295
7296 }
7297}
7298// Settings: {"jsdoc":{"overrideReplacesDocs":false}}
7299// Message: Missing JSDoc @param "foo" declaration.
7300
7301/**
7302 * @implements
7303 */
7304class A {
7305 /**
7306 *
7307 */
7308 quux (foo) {
7309
7310 }
7311}
7312// Settings: {"jsdoc":{"implementsReplacesDocs":false}}
7313// Message: Missing JSDoc @param "foo" declaration.
7314
7315/**
7316 * @augments
7317 */
7318class A {
7319 /**
7320 *
7321 */
7322 quux (foo) {
7323
7324 }
7325}
7326// Message: Missing JSDoc @param "foo" declaration.
7327
7328/**
7329 * @extends
7330 */
7331class A {
7332 /**
7333 *
7334 */
7335 quux (foo) {
7336
7337 }
7338}
7339// Message: Missing JSDoc @param "foo" declaration.
7340
7341export class SomeClass {
7342 /**
7343 * @param property
7344 */
7345 constructor(private property: string, private foo: number) {}
7346}
7347// Message: Missing JSDoc @param "foo" declaration.
7348
7349/**
7350 * @param
7351 */
7352function quux (foo) {
7353
7354}
7355// Settings: {"jsdoc":{"tagNamePreference":{"param":false}}}
7356// Message: Unexpected tag `@param`
7357
7358/**
7359 *
7360 */
7361function quux ({bar, baz}, foo) {
7362}
7363// Message: Missing JSDoc @param "foo" declaration.
7364
7365/**
7366 *
7367 */
7368function quux (foo, {bar, baz}) {
7369}
7370// Message: Missing JSDoc @param "foo" declaration.
7371
7372/**
7373 *
7374 */
7375function quux ([bar, baz], foo) {
7376}
7377// Message: Missing JSDoc @param "foo" declaration.
7378
7379/**
7380 *
7381 */
7382function quux (foo) {
7383}
7384// Options: [{"exemptedBy":["notPresent"]}]
7385// Message: Missing JSDoc @param "foo" declaration.
7386````
7387
7388The following patterns are not considered problems:
7389
7390````js
7391/**
7392 * @param foo
7393 */
7394function quux (foo) {
7395
7396}
7397
7398/**
7399 * @inheritdoc
7400 */
7401function quux (foo) {
7402
7403}
7404
7405/**
7406 * @arg foo
7407 */
7408function quux (foo) {
7409
7410}
7411// Settings: {"jsdoc":{"tagNamePreference":{"param":"arg"}}}
7412
7413/**
7414 * @override
7415 * @param foo
7416 */
7417function quux (foo) {
7418
7419}
7420
7421/**
7422 * @override
7423 */
7424function quux (foo) {
7425
7426}
7427
7428/**
7429 * @override
7430 */
7431class A {
7432 /**
7433 *
7434 */
7435 quux (foo) {
7436
7437 }
7438}
7439
7440/**
7441 * @override
7442 */
7443function quux (foo) {
7444
7445}
7446// Settings: {"jsdoc":{"overrideReplacesDocs":true}}
7447
7448/**
7449 * @implements
7450 */
7451class A {
7452 /**
7453 *
7454 */
7455 quux (foo) {
7456
7457 }
7458}
7459
7460/**
7461 * @implements
7462 */
7463function quux (foo) {
7464
7465}
7466
7467/**
7468 * @implements
7469 */
7470function quux (foo) {
7471
7472}
7473// Settings: {"jsdoc":{"implementsReplacesDocs":true}}
7474
7475/**
7476 * @implements
7477 * @param foo
7478 */
7479function quux (foo) {
7480
7481}
7482
7483/**
7484 * @augments
7485 */
7486function quux (foo) {
7487
7488}
7489// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
7490
7491/**
7492 * @augments
7493 * @param foo
7494 */
7495function quux (foo) {
7496
7497}
7498
7499/**
7500 * @extends
7501 */
7502function quux (foo) {
7503
7504}
7505// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
7506
7507/**
7508 * @extends
7509 * @param foo
7510 */
7511function quux (foo) {
7512
7513}
7514
7515/**
7516 * @augments
7517 */
7518function quux (foo) {
7519
7520}
7521// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
7522
7523/**
7524 * @extends
7525 */
7526function quux (foo) {
7527
7528}
7529// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
7530
7531/**
7532 * @override
7533 */
7534class A {
7535 /**
7536 * @param foo
7537 */
7538 quux (foo) {
7539
7540 }
7541}
7542
7543/**
7544 * @override
7545 */
7546class A {
7547 /**
7548 *
7549 */
7550 quux (foo) {
7551
7552 }
7553}
7554// Settings: {"jsdoc":{"overrideReplacesDocs":true}}
7555
7556/**
7557 * @implements
7558 */
7559class A {
7560 /**
7561 *
7562 */
7563 quux (foo) {
7564
7565 }
7566}
7567// Settings: {"jsdoc":{"implementsReplacesDocs":true}}
7568
7569/**
7570 * @implements
7571 */
7572class A {
7573 /**
7574 * @param foo
7575 */
7576 quux (foo) {
7577
7578 }
7579}
7580
7581/**
7582 * @augments
7583 */
7584class A {
7585 /**
7586 *
7587 */
7588 quux (foo) {
7589
7590 }
7591}
7592// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
7593
7594/**
7595 * @augments
7596 */
7597class A {
7598 /**
7599 * @param foo
7600 */
7601 quux (foo) {
7602
7603 }
7604}
7605
7606/**
7607 * @extends
7608 */
7609class A {
7610 /**
7611 *
7612 */
7613 quux (foo) {
7614
7615 }
7616}
7617// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
7618
7619/**
7620 * @extends
7621 */
7622class A {
7623 /**
7624 * @param foo
7625 */
7626 quux (foo) {
7627
7628 }
7629}
7630
7631/**
7632 * @augments
7633 */
7634class A {
7635 /**
7636 *
7637 */
7638 quux (foo) {
7639
7640 }
7641}
7642// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
7643
7644/**
7645 * @extends
7646 */
7647class A {
7648 /**
7649 *
7650 */
7651 quux (foo) {
7652
7653 }
7654}
7655// Settings: {"jsdoc":{"augmentsExtendsReplacesDocs":true}}
7656
7657/**
7658 * @private
7659 */
7660function quux (foo) {
7661
7662}
7663// Settings: {"jsdoc":{"ignorePrivate":true}}
7664
7665// issue 182: optional chaining
7666/** @const {boolean} test */
7667const test = something?.find(_ => _)
7668
7669/** @type {RequestHandler} */
7670function foo(req, res, next) {}
7671
7672/**
7673 * @type {MyCallback}
7674 */
7675function quux () {
7676
7677}
7678// Options: [{"exemptedBy":["type"]}]
7679
7680/**
7681 * @override
7682 */
7683var A = class {
7684 /**
7685 *
7686 */
7687 quux (foo) {
7688
7689 }
7690}
7691
7692export class SomeClass {
7693 /**
7694 * @param property
7695 */
7696 constructor(private property: string) {}
7697}
7698
7699/**
7700 * Assign the project to an employee.
7701 *
7702 * @param {object} employee - The employee who is responsible for the project.
7703 * @param {string} employee.name - The name of the employee.
7704 * @param {string} employee.department - The employee's department.
7705 */
7706function assign({name, department}) {
7707 // ...
7708}
7709````
7710
7711
7712<a name="eslint-plugin-jsdoc-rules-require-returns-check"></a>
7713### <code>require-returns-check</code>
7714
7715Requires a return statement in function body if a `@returns` tag is specified in jsdoc comment.
7716
7717Will also report if multiple `@returns` tags are present.
7718
7719|||
7720|---|---|
7721|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
7722|Tags|`returns`|
7723|Aliases|`return`|
7724
7725The following patterns are considered problems:
7726
7727````js
7728/**
7729 * @returns
7730 */
7731function quux (foo) {
7732
7733}
7734// Message: JSDoc @returns declaration present but return expression not available in function.
7735
7736/**
7737 * @return
7738 */
7739function quux (foo) {
7740
7741}
7742// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
7743// Message: JSDoc @return declaration present but return expression not available in function.
7744
7745/**
7746 * @returns
7747 */
7748const quux = () => {}
7749// Message: JSDoc @returns declaration present but return expression not available in function.
7750
7751/**
7752 * @returns {undefined} Foo.
7753 * @returns {String} Foo.
7754 */
7755function quux () {
7756
7757 return foo;
7758}
7759// Message: Found more than one @returns declaration.
7760
7761const language = {
7762 /**
7763 * @param {string} name
7764 * @returns {string}
7765 */
7766 get name() {
7767 this._name = name;
7768 }
7769}
7770// Message: JSDoc @returns declaration present but return expression not available in function.
7771
7772class Foo {
7773 /**
7774 * @returns {string}
7775 */
7776 bar () {
7777 }
7778}
7779// Message: JSDoc @returns declaration present but return expression not available in function.
7780
7781/**
7782 * @returns
7783 */
7784function quux () {
7785
7786}
7787// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
7788// Message: Unexpected tag `@returns`
7789
7790/**
7791 * @returns {string}
7792 */
7793function f () {
7794 function g() {
7795 return 'foo'
7796 }
7797
7798 () => {
7799 return 5
7800 }
7801}
7802// Message: JSDoc @returns declaration present but return expression not available in function.
7803````
7804
7805The following patterns are not considered problems:
7806
7807````js
7808/**
7809 * @returns Foo.
7810 */
7811function quux () {
7812
7813 return foo;
7814}
7815
7816/**
7817 * @returns {string} Foo.
7818 */
7819function quux () {
7820
7821 return foo;
7822}
7823
7824/**
7825 * @returns {string} Foo.
7826 */
7827function quux () {
7828
7829 return foo;
7830}
7831
7832/**
7833 *
7834 */
7835function quux () {
7836}
7837
7838/**
7839 * @returns {*} Foo.
7840 */
7841const quux = () => foo;
7842
7843/**
7844 * @returns {undefined} Foo.
7845 */
7846function quux () {}
7847
7848/**
7849 * @returns { void } Foo.
7850 */
7851function quux () {}
7852
7853/**
7854 * @returns {Promise<void>}
7855 */
7856async function quux() {}
7857
7858/**
7859 * @returns {Promise<void>}
7860 */
7861const quux = async function () {}
7862
7863/**
7864 * @returns {Promise<void>}
7865 */
7866const quux = async () => {}
7867
7868/**
7869 * @returns Foo.
7870 * @abstract
7871 */
7872function quux () {
7873 throw new Error('must be implemented by subclass!');
7874}
7875
7876/**
7877 * @returns Foo.
7878 * @virtual
7879 */
7880function quux () {
7881 throw new Error('must be implemented by subclass!');
7882}
7883
7884/**
7885 * @returns Foo.
7886 * @constructor
7887 */
7888function quux () {
7889}
7890
7891/**
7892 * @interface
7893 */
7894class Foo {
7895 /**
7896 * @returns {string}
7897 */
7898 bar () {
7899 }
7900}
7901
7902/**
7903 * @returns {undefined} Foo.
7904 */
7905function quux () {
7906}
7907
7908/**
7909 * @returns {void} Foo.
7910 */
7911function quux () {
7912}
7913
7914/**
7915 * @returns {void} Foo.
7916 */
7917function quux () {
7918 return undefined;
7919}
7920
7921/**
7922 * @returns {void} Foo.
7923 */
7924function quux () {
7925 return;
7926}
7927
7928/**
7929 *
7930 */
7931function quux () {
7932 return undefined;
7933}
7934
7935/**
7936 *
7937 */
7938function quux () {
7939 return;
7940}
7941
7942/**
7943 * @returns {true}
7944 */
7945function quux () {
7946 try {
7947 return true;
7948 } catch (err) {
7949 }
7950 return;
7951}
7952
7953/**
7954 * @returns {true}
7955 */
7956function quux () {
7957 try {
7958 } finally {
7959 return true;
7960 }
7961 return;
7962}
7963
7964/**
7965 * @returns {true}
7966 */
7967function quux () {
7968 try {
7969 return;
7970 } catch (err) {
7971 }
7972 return true;
7973}
7974
7975/**
7976 * @returns {true}
7977 */
7978function quux () {
7979 try {
7980 something();
7981 } catch (err) {
7982 return true;
7983 }
7984 return;
7985}
7986
7987/**
7988 * @returns {true}
7989 */
7990function quux () {
7991 switch (true) {
7992 case 'abc':
7993 return true;
7994 }
7995 return;
7996}
7997
7998/**
7999 * @returns {true}
8000 */
8001function quux () {
8002 switch (true) {
8003 case 'abc':
8004 return;
8005 }
8006 return true;
8007}
8008
8009/**
8010 * @returns {true}
8011 */
8012function quux () {
8013 for (const i of abc) {
8014 return true;
8015 }
8016 return;
8017}
8018
8019/**
8020 * @returns {true}
8021 */
8022function quux () {
8023 for (const a in b) {
8024 return true;
8025 }
8026}
8027
8028/**
8029 * @returns {true}
8030 */
8031function quux () {
8032 for (let i=0; i<n; i+=1) {
8033 return true;
8034 }
8035}
8036
8037/**
8038 * @returns {true}
8039 */
8040function quux () {
8041 while(true) {
8042 return true
8043 }
8044}
8045
8046/**
8047 * @returns {true}
8048 */
8049function quux () {
8050 do {
8051 return true
8052 }
8053 while(true)
8054}
8055
8056/**
8057 * @returns {true}
8058 */
8059function quux () {
8060 if (true) {
8061 return;
8062 }
8063 return true;
8064}
8065
8066/**
8067 * @returns {true}
8068 */
8069function quux () {
8070 if (true) {
8071 return true;
8072 }
8073}
8074
8075/**
8076 * @returns {true}
8077 */
8078function quux () {
8079 var a = {};
8080 with (a) {
8081 return true;
8082 }
8083}
8084
8085/**
8086 * @returns {true}
8087 */
8088function quux () {
8089 if (true) {
8090 return;
8091 } else {
8092 return true;
8093 }
8094 return;
8095}
8096````
8097
8098
8099<a name="eslint-plugin-jsdoc-rules-require-returns-description"></a>
8100### <code>require-returns-description</code>
8101
8102Requires that `@returns` tag has `description` value.
8103
8104|||
8105|---|---|
8106|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
8107|Tags|`returns`|
8108|Aliases|`return`|
8109
8110The following patterns are considered problems:
8111
8112````js
8113/**
8114 * @returns
8115 */
8116function quux (foo) {
8117
8118}
8119// Message: Missing JSDoc @returns description.
8120
8121/**
8122 * @return
8123 */
8124function quux (foo) {
8125
8126}
8127// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
8128// Message: Missing JSDoc @return description.
8129
8130/**
8131 * @returns
8132 */
8133function quux () {
8134
8135}
8136// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
8137// Message: Unexpected tag `@returns`
8138````
8139
8140The following patterns are not considered problems:
8141
8142````js
8143/**
8144 *
8145 */
8146function quux () {
8147
8148}
8149
8150/**
8151 * @returns Foo.
8152 */
8153function quux () {
8154
8155}
8156
8157/**
8158 * @returns {undefined}
8159 */
8160function quux () {
8161
8162}
8163
8164/**
8165 * @returns {void}
8166 */
8167function quux () {
8168
8169}
8170````
8171
8172
8173<a name="eslint-plugin-jsdoc-rules-require-returns-type"></a>
8174### <code>require-returns-type</code>
8175
8176Requires that `@returns` tag has `type` value.
8177
8178|||
8179|---|---|
8180|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
8181|Tags|`returns`|
8182|Aliases|`return`|
8183
8184The following patterns are considered problems:
8185
8186````js
8187/**
8188 * @returns
8189 */
8190function quux () {
8191
8192}
8193// Message: Missing JSDoc @returns type.
8194
8195/**
8196 * @returns Foo.
8197 */
8198function quux () {
8199
8200}
8201// Message: Missing JSDoc @returns type.
8202
8203/**
8204 * @return Foo.
8205 */
8206function quux () {
8207
8208}
8209// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
8210// Message: Missing JSDoc @return type.
8211
8212/**
8213 * @returns
8214 */
8215function quux () {
8216
8217}
8218// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
8219// Message: Unexpected tag `@returns`
8220````
8221
8222The following patterns are not considered problems:
8223
8224````js
8225/**
8226 * @returns {number}
8227 */
8228function quux () {
8229
8230}
8231````
8232
8233
8234<a name="eslint-plugin-jsdoc-rules-require-returns"></a>
8235### <code>require-returns</code>
8236
8237Requires returns are documented.
8238
8239Will also report if multiple `@returns` tags are present.
8240
8241<a name="eslint-plugin-jsdoc-rules-require-returns-options-16"></a>
8242#### Options
8243
8244- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
8245 block avoids the need for a `@returns`. Defaults to an empty array.
8246- `forceRequireReturn` - Set to `true` to always insist on
8247 `@returns` documentation regardless of implicit or explicit `return`'s
8248 in the function. May be desired to flag that a project is aware of an
8249 `undefined`/`void` return. Defaults to `false`.
8250- `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`.
8251
8252```js
8253'jsdoc/require-returns': ['error', {forceReturnsWithAsync: true}]
8254```
8255
8256|||
8257|---|---|
8258|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
8259|Tags|`returns`|
8260|Aliases|`return`|
8261|Options|`exemptedBy`, `forceRequireReturn`, `forceReturnsWithAsync`|
8262|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
8263
8264The following patterns are considered problems:
8265
8266````js
8267/**
8268 *
8269 */
8270function quux (foo) {
8271
8272 return foo;
8273}
8274// Message: Missing JSDoc @returns declaration.
8275
8276/**
8277 *
8278 */
8279const foo = () => ({
8280 bar: 'baz'
8281})
8282// Message: Missing JSDoc @returns declaration.
8283
8284/**
8285 *
8286 */
8287const foo = bar=>({ bar })
8288// Message: Missing JSDoc @returns declaration.
8289
8290/**
8291 *
8292 */
8293const foo = bar => bar.baz()
8294// Message: Missing JSDoc @returns declaration.
8295
8296/**
8297 *
8298 */
8299function quux (foo) {
8300
8301 return foo;
8302}
8303// Settings: {"jsdoc":{"tagNamePreference":{"returns":"return"}}}
8304// Message: Missing JSDoc @return declaration.
8305
8306/**
8307 *
8308 */
8309function foo() {}
8310
8311/**
8312 *
8313 */
8314function bar() {}
8315// Settings: {"jsdoc":{"forceRequireReturn":true}}
8316// Message: `settings.jsdoc.forceRequireReturn` has been removed, use options in the rule `require-returns` instead.
8317
8318/**
8319 *
8320 */
8321async function quux() {
8322}
8323// Options: [{"forceRequireReturn":true}]
8324// Message: Missing JSDoc @returns declaration.
8325
8326/**
8327 *
8328 */
8329const quux = async function () {}
8330// Options: [{"forceRequireReturn":true}]
8331// Message: Missing JSDoc @returns declaration.
8332
8333/**
8334 *
8335 */
8336const quux = async () => {}
8337// Options: [{"forceRequireReturn":true}]
8338// Message: Missing JSDoc @returns declaration.
8339
8340/**
8341 *
8342 */
8343async function quux () {}
8344// Options: [{"forceRequireReturn":true}]
8345// Message: Missing JSDoc @returns declaration.
8346
8347/**
8348 *
8349 */
8350function quux () {
8351}
8352// Options: [{"forceRequireReturn":true}]
8353// Message: Missing JSDoc @returns declaration.
8354
8355const language = {
8356 /**
8357 * @param {string} name
8358 */
8359 get name() {
8360 return this._name;
8361 }
8362}
8363// Message: Missing JSDoc @returns declaration.
8364
8365/**
8366 *
8367 */
8368async function quux () {
8369}
8370// Options: [{"forceReturnsWithAsync":true}]
8371// Message: Missing JSDoc @returns declaration.
8372
8373/**
8374 * @returns {undefined}
8375 * @returns {void}
8376 */
8377function quux (foo) {
8378
8379 return foo;
8380}
8381// Message: Found more than one @returns declaration.
8382
8383/**
8384 * @returns
8385 */
8386function quux () {
8387
8388}
8389// Settings: {"jsdoc":{"tagNamePreference":{"returns":false}}}
8390// Message: Unexpected tag `@returns`
8391
8392/**
8393 * @param foo
8394 */
8395function quux (foo) {
8396 return 'bar';
8397}
8398// Options: [{"exemptedBy":["notPresent"]}]
8399// Message: Missing JSDoc @returns declaration.
8400````
8401
8402The following patterns are not considered problems:
8403
8404````js
8405/**
8406 * @returns Foo.
8407 */
8408function quux () {
8409
8410 return foo;
8411}
8412
8413/**
8414 *
8415 */
8416function quux () {
8417}
8418
8419/**
8420 *
8421 */
8422function quux (bar) {
8423 bar.filter(baz => {
8424 return baz.corge();
8425 })
8426}
8427
8428/**
8429 * @returns Array
8430 */
8431function quux (bar) {
8432 return bar.filter(baz => {
8433 return baz.corge();
8434 })
8435}
8436
8437/**
8438 * @returns Array
8439 */
8440const quux = (bar) => bar.filter(({ corge }) => corge())
8441
8442/**
8443 * @inheritdoc
8444 */
8445function quux (foo) {
8446}
8447
8448/**
8449 * @override
8450 */
8451function quux (foo) {
8452}
8453
8454/**
8455 * @constructor
8456 */
8457function quux (foo) {
8458}
8459
8460/**
8461 * @implements
8462 */
8463function quux (foo) {
8464}
8465
8466/**
8467 * @override
8468 */
8469function quux (foo) {
8470
8471 return foo;
8472}
8473
8474/**
8475 * @class
8476 */
8477function quux (foo) {
8478
8479}
8480
8481/**
8482 * @constructor
8483 */
8484function quux (foo) {
8485
8486}
8487
8488/**
8489 * @returns {Object}
8490 */
8491function quux () {
8492
8493 return {a: foo};
8494}
8495
8496/**
8497 * @returns {Object}
8498 */
8499const quux = () => ({a: foo});
8500
8501/**
8502 * @returns {Object}
8503 */
8504const quux = () => {
8505 return {a: foo}
8506};
8507
8508/**
8509 * @returns {void}
8510 */
8511function quux () {
8512}
8513
8514/**
8515 * @returns {void}
8516 */
8517const quux = () => {
8518
8519}
8520
8521/**
8522 * @returns {undefined}
8523 */
8524function quux () {
8525}
8526
8527/**
8528 * @returns {undefined}
8529 */
8530const quux = () => {
8531
8532}
8533
8534/**
8535 *
8536 */
8537function quux () {
8538}
8539
8540/**
8541 *
8542 */
8543const quux = () => {
8544
8545}
8546
8547class Foo {
8548 /**
8549 *
8550 */
8551 constructor () {
8552 }
8553}
8554// Options: [{"forceRequireReturn":true}]
8555
8556const language = {
8557 /**
8558 * @param {string} name
8559 */
8560 set name(name) {
8561 this._name = name;
8562 }
8563}
8564
8565/**
8566 * @returns {void}
8567 */
8568function quux () {
8569}
8570// Options: [{"forceRequireReturn":true}]
8571
8572/**
8573 * @returns {void}
8574 */
8575function quux () {
8576 return undefined;
8577}
8578
8579/**
8580 * @returns {void}
8581 */
8582function quux () {
8583 return undefined;
8584}
8585// Options: [{"forceRequireReturn":true}]
8586
8587/**
8588 * @returns {void}
8589 */
8590function quux () {
8591 return;
8592}
8593
8594/**
8595 * @returns {void}
8596 */
8597function quux () {
8598}
8599// Options: [{"forceRequireReturn":true}]
8600
8601/**
8602 * @returns {void}
8603 */
8604function quux () {
8605 return;
8606}
8607// Options: [{"forceRequireReturn":true}]
8608
8609/** @type {RequestHandler} */
8610function quux (req, res , next) {
8611 return;
8612}
8613
8614/**
8615 * @returns {Promise}
8616 */
8617async function quux () {
8618}
8619// Options: [{"forceRequireReturn":true}]
8620
8621/**
8622 * @returns {Promise}
8623 */
8624async function quux () {
8625}
8626// Options: [{"forceReturnsWithAsync":true}]
8627
8628/**
8629 *
8630 */
8631async function quux () {}
8632
8633/**
8634 *
8635 */
8636const quux = async function () {}
8637
8638/**
8639 *
8640 */
8641const quux = async () => {}
8642
8643/** foo class */
8644class foo {
8645 /** foo constructor */
8646 constructor () {
8647 // =>
8648 this.bar = true;
8649 }
8650}
8651
8652export default foo;
8653
8654/**
8655 *
8656 */
8657function quux () {
8658}
8659// Options: [{"forceReturnsWithAsync":true}]
8660
8661/**
8662 * @type {MyCallback}
8663 */
8664function quux () {
8665
8666}
8667// Options: [{"exemptedBy":["type"]}]
8668````
8669
8670
8671<a name="eslint-plugin-jsdoc-rules-valid-types"></a>
8672### <code>valid-types</code>
8673
8674Requires all types to be valid JSDoc or Closure compiler types without syntax errors.
8675
8676Also impacts behaviors on namepath (or event)-defining and pointing tags:
8677
86781. Name(path)-defining tags requiring namepath: `@external`, `@host`, `@name`, `@typedef`
86791. Name(path)-defining tags (which may have value without namepath or their
8680 namepath can be expressed elsewhere on the block): `@event`, `@callback`,
8681 `@class`, `@constructor`, `@constant`, `@const`,
8682 `@function`, `@func`, `@method`, `@interface`, `@member`, `@var`,
8683 `@mixin`, `@namespace`
86841. Name(path)-pointing tags requiring namepath: `@alias`, `@augments`, `@extends`, `@lends`, `@memberof`, `@memberof!`, `@mixes`, `@this`
86851. Name(path)-pointing tags (which may have value without namepath or their
8686 namepath can be expressed elsewhere on the block): `@listens`, `@fires`,
8687 `@emits`, and `@modifies`
86881. Name(path)-pointing tags (multiple names in one): `@borrows`
8689
8690...with the following applying to the above sets:
8691
8692- Expect tags in set 1-4 to have a valid namepath if present
8693- Prevent sets 2 and 4 from being empty by setting `allowEmptyNamepaths` to
8694 `false` as these tags might have some indicative value without a path
8695 or may allow a name expressed elsewhere on the block (but sets 1 and 3 will
8696 always fail if empty)
8697- For the special case of set 5, i.e., `@borrows <that namepath> as <this namepath>`,
8698 check that both namepaths are present and valid and ensure there is an `as `
8699 between them. In the case of `<this namepath>`, it can be preceded by
8700 one of the name path operators, `#`, `.`, or `~`.
8701- For the special case of `@memberof` and `@memberof!` (part of set 3), as
8702 per the [specification](https://jsdoc.app/tags-memberof.html), they also
8703 allow `#`, `.`, or `~` at the end (which is not allowed at the end of
8704 normal paths).
8705
8706<a name="eslint-plugin-jsdoc-rules-valid-types-options-17"></a>
8707#### Options
8708
8709- `allowEmptyNamepaths` (default: true) - Set to `false` to disallow
8710 empty name paths with `@callback`, `@event`, `@class`, `@constructor`,
8711 `@constant`, `@const`, `@function`, `@func`, `@method`, `@interface`,
8712 `@member`, `@var`, `@mixin`, `@namespace`, `@listens`, `@fires`,
8713 `@modifies`, or `@emits` (these might often be expected to have an
8714 accompanying name path, though they have some indicative value without
8715 one; these may also allow names to be defined in another manner elsewhere
8716 in the block)
8717- `checkSeesForNamepaths` (default: false) - Set this to `true` to insist
8718 that `@see` only use name paths (the tag is normally permitted to
8719 allow other text)
8720
8721
8722|||
8723|---|---|
8724|Context|everywhere|
8725|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)|
8726|Aliases|`extends`, `constructor`, `const`, `host`, `emits`, `func`, `method`, `var`, `arg`, `argument`, `prop`, `return`, `exception`, `yield`|
8727|Closure-only|For type only: `package`, `private`, `protected`, `public`, `static`|
8728|Options|`allowEmptyNamepaths`, `checkSeesForNamepaths`|
8729|Settings|`mode`|
8730
8731The following patterns are considered problems:
8732
8733````js
8734/**
8735 * @param {Array<string} foo
8736 */
8737function quux() {
8738
8739}
8740// Message: Syntax error in type: Array<string
8741
8742/**
8743 * @memberof module:namespace.SomeClass<~
8744 */
8745function quux() {
8746
8747}
8748// Message: Syntax error in namepath: module:namespace.SomeClass<~
8749
8750/**
8751 * @memberof module:namespace.SomeClass~<
8752 */
8753function quux() {
8754
8755}
8756// Message: Syntax error in namepath: module:namespace.SomeClass~<
8757
8758/**
8759 * @borrows foo% as bar
8760 */
8761function quux() {
8762
8763}
8764// Message: Syntax error in namepath: foo%
8765
8766/**
8767 * @borrows #foo as bar
8768 */
8769function quux() {
8770
8771}
8772// Message: Syntax error in namepath: #foo
8773
8774/**
8775 * @borrows foo as bar%
8776 */
8777function quux() {
8778
8779}
8780// Message: Syntax error in namepath: bar%
8781
8782/**
8783 * @borrows foo
8784 */
8785function quux() {
8786
8787}
8788// Message: @borrows must have an "as" expression. Found ""
8789
8790/**
8791 * @see foo%
8792 */
8793function quux() {
8794
8795}
8796// Options: [{"checkSeesForNamepaths":true}]
8797// Message: Syntax error in namepath: foo%
8798
8799/** */
8800function foo() {}
8801// Settings: {"jsdoc":{"allowEmptyNamepaths":true,"checkSeesForNamepaths":true}}
8802// Message: `settings.jsdoc.allowEmptyNamepaths` has been removed, use options in the rule `valid-types` instead.
8803
8804/**
8805 * @alias module:abc#event:foo-bar
8806 */
8807function quux() {
8808
8809}
8810// Message: Syntax error in namepath: module:abc#event:foo-bar
8811
8812/**
8813 * @mixes module:namespace.SomeClass~
8814 */
8815function quux() {
8816
8817}
8818// Message: Syntax error in namepath: module:namespace.SomeClass~
8819
8820/**
8821 * @callback
8822 */
8823function quux() {
8824
8825}
8826// Options: [{"allowEmptyNamepaths":false}]
8827// Message: Tag @callback must have a namepath
8828
8829/**
8830 * @constant {str%ng}
8831 */
8832 const FOO = 'foo';
8833// Message: Syntax error in type: str%ng
8834
8835/**
8836 * @typedef {str%ng} UserString
8837 */
8838// Message: Syntax error in type: str%ng
8839
8840/**
8841 * @typedef {string} UserStr%ng
8842 */
8843// Message: Syntax error in namepath: UserStr%ng
8844
8845/**
8846 * @extends
8847 */
8848 class Bar {};
8849// Message: Tag @extends must have either a type or namepath
8850
8851/**
8852 * @type
8853 */
8854 let foo;
8855// Message: Tag @type must have a type
8856
8857/**
8858 * @modifies {bar|foo<}
8859 */
8860function quux (foo, bar, baz) {}
8861// Message: Syntax error in type: bar|foo<
8862
8863/**
8864 * @private {BadTypeChecked<}
8865 */
8866function quux () {}
8867// Settings: {"jsdoc":{"mode":"closure"}}
8868// Message: Syntax error in type: BadTypeChecked<
8869````
8870
8871The following patterns are not considered problems:
8872
8873````js
8874/**
8875 * @param {Array<string>} foo
8876 */
8877function quux() {
8878
8879}
8880
8881/**
8882 * @param {string} foo
8883 */
8884function quux() {
8885
8886}
8887
8888/**
8889 * @param foo
8890 */
8891function quux() {
8892
8893}
8894
8895/**
8896 * @borrows foo as bar
8897 */
8898function quux() {
8899
8900}
8901
8902/**
8903 * @borrows foo as #bar
8904 */
8905function quux() {
8906
8907}
8908
8909/**
8910 * @see foo%
8911 */
8912function quux() {
8913
8914}
8915
8916/**
8917 * @alias module:namespace.SomeClass#event:ext_anevent
8918 */
8919function quux() {
8920
8921}
8922
8923/**
8924 * @callback foo
8925 */
8926function quux() {
8927
8928}
8929
8930/**
8931 * @callback
8932 */
8933function quux() {
8934
8935}
8936// Options: [{"allowEmptyNamepaths":true}]
8937
8938/**
8939 * @class
8940 */
8941function quux() {
8942
8943}
8944
8945/**
8946 * @see {@link foo}
8947 */
8948function quux() {
8949
8950}
8951// Options: [{"checkSeesForNamepaths":true}]
8952
8953/**
8954 *
8955 * @fires {module:namespace.SomeClass#event:ext_anevent}
8956 */
8957function quux() {
8958
8959}
8960
8961/**
8962 * @memberof module:namespace.SomeClass~
8963 */
8964function quux() {
8965
8966}
8967
8968/**
8969 * @memberof! module:namespace.SomeClass.
8970 */
8971function quux() {
8972
8973}
8974
8975/**
8976 *
8977 */
8978function quux() {
8979
8980}
8981
8982/**
8983 * @constant {string}
8984 */
8985 const FOO = 'foo';
8986
8987/**
8988 * @constant {string} FOO
8989 */
8990 const FOO = 'foo';
8991
8992/**
8993 * @extends Foo
8994 */
8995 class Bar {};
8996
8997/**
8998 * @extends {Foo<String>}
8999 */
9000 class Bar {};
9001
9002/**
9003 * @typedef {number|string} UserDefinedType
9004 */
9005
9006/**
9007 * @typedef {number|string}
9008 */
9009let UserDefinedGCCType;
9010
9011/**
9012 * @modifies {foo|bar}
9013 */
9014function quux (foo, bar, baz) {}
9015
9016/**
9017 * @private {BadTypeNotCheckedInJsdoc<}
9018 */
9019function quux () {}
9020````
9021
9022
9023
\No newline at end of file