1- <h1 id =" eslint-plugin-jsdoc " >eslint-plugin-jsdoc</h1 >
1+ <a name =" eslint-plugin-jsdoc " ></a >
2+ # eslint-plugin-jsdoc
23
34[ ![ NPM version] ( http://img.shields.io/npm/v/eslint-plugin-jsdoc.svg?style=flat-square )] ( https://www.npmjs.org/package/eslint-plugin-jsdoc )
45[ ![ 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 )
@@ -12,6 +13,7 @@ JSDoc linting rules for ESLint.
1213 * [ Configuration] ( #eslint-plugin-jsdoc-configuration )
1314 * [ Settings] ( #eslint-plugin-jsdoc-settings )
1415 * [ Alias Preference] ( #eslint-plugin-jsdoc-settings-alias-preference )
16+ * [ Additional Tag Names] ( #eslint-plugin-jsdoc-settings-additional-tag-names )
1517 * [ Rules] ( #eslint-plugin-jsdoc-rules )
1618 * [ ` check-param-names ` ] ( #eslint-plugin-jsdoc-rules-check-param-names )
1719 * [ ` check-tag-names ` ] ( #eslint-plugin-jsdoc-rules-check-tag-names )
@@ -26,7 +28,8 @@ JSDoc linting rules for ESLint.
2628 * [ ` require-returns-type ` ] ( #eslint-plugin-jsdoc-rules-require-returns-type )
2729
2830
29- <h3 id =" eslint-plugin-jsdoc-reference-to-jscs-jsdoc " >Reference to jscs-jsdoc</h3 >
31+ <a name =" eslint-plugin-jsdoc-reference-to-jscs-jsdoc " ></a >
32+ ### Reference to jscs-jsdoc
3033
3134This table maps the rules between ` eslint-plugin-jsdoc ` and ` jscs-jsdoc ` .
3235
@@ -50,7 +53,8 @@ This table maps the rules between `eslint-plugin-jsdoc` and `jscs-jsdoc`.
5053| N/A | [ ` enforceExistence ` ] ( https://github.com/jscs-dev/jscs-jsdoc#enforceexistence ) |
5154| N/A | [ ` leadingUnderscoreAccess ` ] ( https://github.com/jscs-dev/jscs-jsdoc#leadingunderscoreaccess ) |
5255
53- <h2 id =" eslint-plugin-jsdoc-installation " >Installation</h2 >
56+ <a name =" eslint-plugin-jsdoc-installation " ></a >
57+ ## Installation
5458
5559Install [ ESLint] ( https://www.github.com/eslint/eslint ) either locally or globally.
5660
@@ -64,7 +68,8 @@ If you have installed `ESLint` globally, you have to install JSDoc plugin global
6468npm install eslint-plugin-jsdoc
6569```
6670
67- <h2 id =" eslint-plugin-jsdoc-configuration " >Configuration</h2 >
71+ <a name =" eslint-plugin-jsdoc-configuration " ></a >
72+ ## Configuration
6873
6974Add ` plugins ` section and specify ` eslint-plugin-jsdoc ` as a plugin.
7075
@@ -96,9 +101,11 @@ Finally, enable all of the rules that you would like to use.
96101}
97102```
98103
99- <h2 id =" eslint-plugin-jsdoc-settings " >Settings</h2 >
104+ <a name =" eslint-plugin-jsdoc-settings " ></a >
105+ ## Settings
100106
101- <h3 id =" eslint-plugin-jsdoc-settings-alias-preference " >Alias Preference</h3 >
107+ <a name =" eslint-plugin-jsdoc-settings-alias-preference " ></a >
108+ ### Alias Preference
102109
103110Use ` 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.
104111
@@ -116,9 +123,30 @@ Use `settings.jsdoc.tagNamePreference` to configure a preferred alias name for a
116123}
117124```
118125
119- <h2 id =" eslint-plugin-jsdoc-rules " >Rules</h2 >
120126
121- <h3 id =" eslint-plugin-jsdoc-rules-check-param-names " ><code >check-param-names</code ></h3 >
127+ <a name =" eslint-plugin-jsdoc-settings-additional-tag-names " ></a >
128+ ### Additional Tag Names
129+
130+ Use ` settings.jsdoc.additionalTagNames ` to configure additional, allowed JSDoc tags. The format of the configuration is as follows:
131+
132+ ``` json
133+ {
134+ "rules" : {},
135+ "settings" : {
136+ "jsdoc" : {
137+ "additionalTagNames" : {
138+ "customTags" : [" define" , " extends" , " record" ]
139+ }
140+ }
141+ }
142+ }
143+ ```
144+
145+ <a name =" eslint-plugin-jsdoc-rules " ></a >
146+ ## Rules
147+
148+ <a name =" eslint-plugin-jsdoc-rules-check-param-names " ></a >
149+ ### <code >check-param-names</code >
122150
123151Ensures that parameter names in JSDoc match those in the function declaration.
124152
@@ -249,7 +277,8 @@ function quux ({a, b}) {
249277```
250278
251279
252- <h4 id =" eslint-plugin-jsdoc-rules-check-param-names-deconstructing-function-parameter " >Deconstructing Function Parameter</h4 >
280+ <a name =" eslint-plugin-jsdoc-rules-check-param-names-deconstructing-function-parameter " ></a >
281+ #### Deconstructing Function Parameter
253282
254283` eslint-plugin-jsdoc ` does not validate names of parameters in function deconstruction, e.g.
255284
@@ -267,7 +296,8 @@ function quux ({
267296
268297` {a, b} ` is an [ ` ObjectPattern ` ] ( https://github.com/estree/estree/blob/master/es6.md#objectpattern ) AST type and does not have a name. Therefore, the associated parameter in JSDoc block can have any name.
269298
270- <h3 id =" eslint-plugin-jsdoc-rules-check-tag-names " ><code >check-tag-names</code ></h3 >
299+ <a name =" eslint-plugin-jsdoc-rules-check-tag-names " ></a >
300+ ### <code >check-tag-names</code >
271301
272302Reports invalid block tag names.
273303
@@ -377,6 +407,31 @@ function quux (foo) {
377407
378408}
379409// Message: Invalid JSDoc tag (preference). Replace "param" JSDoc tag with "arg".
410+
411+ /**
412+ * @bar foo
413+ */
414+ function quux (foo ) {
415+
416+ }
417+ // Message: Invalid JSDoc tag name "bar".
418+
419+ /**
420+ * @baz @bar foo
421+ */
422+ function quux (foo ) {
423+
424+ }
425+ // Message: Invalid JSDoc tag name "baz".
426+
427+ /**
428+ * @bar
429+ * @baz
430+ */
431+ function quux (foo ) {
432+
433+ }
434+ // Message: Invalid JSDoc tag name "baz".
380435```
381436
382437The following patterns are not considered problems:
@@ -395,10 +450,91 @@ function quux (foo) {
395450function quux (foo ) {
396451
397452}
453+
454+ /**
455+ * @bar foo
456+ */
457+ function quux (foo ) {
458+
459+ }
460+
461+ /**
462+ * @baz @bar foo
463+ */
464+ function quux (foo ) {
465+
466+ }
467+
468+ /**
469+ * @abstract
470+ * @access
471+ * @alias
472+ * @augments
473+ * @author
474+ * @borrows
475+ * @callback
476+ * @class
477+ * @classdesc
478+ * @constant
479+ * @constructs
480+ * @copyright
481+ * @default
482+ * @deprecated
483+ * @description
484+ * @enum
485+ * @event
486+ * @example
487+ * @exports
488+ * @external
489+ * @file
490+ * @fires
491+ * @function
492+ * @global
493+ * @ignore
494+ * @implements
495+ * @inheritdoc
496+ * @inner
497+ * @instance
498+ * @interface
499+ * @kind
500+ * @lends
501+ * @license
502+ * @listens
503+ * @member
504+ * @memberof
505+ * @mixes
506+ * @mixin
507+ * @module
508+ * @name
509+ * @namespace
510+ * @override
511+ * @param
512+ * @private
513+ * @property
514+ * @protected
515+ * @public
516+ * @readonly
517+ * @requires
518+ * @returns
519+ * @see
520+ * @since
521+ * @static
522+ * @summary
523+ * @this
524+ * @throws
525+ * @todo
526+ * @tutorial
527+ * @type
528+ * @typedef
529+ * @variation
530+ * @version
531+ */
532+ function quux (foo ) {}
398533```
399534
400535
401- <h3 id =" eslint-plugin-jsdoc-rules-check-types " ><code >check-types</code ></h3 >
536+ <a name =" eslint-plugin-jsdoc-rules-check-types " ></a >
537+ ### <code >check-types</code >
402538
403539Reports invalid types.
404540
@@ -414,6 +550,37 @@ Date
414550RegExp
415551```
416552
553+ <a name =" eslint-plugin-jsdoc-rules-check-types-why-not-capital-case-everything " ></a >
554+ #### Why not capital case everything?
555+
556+ Why 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() ` .
557+
558+ Fortunately 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.
559+
560+ So 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.
561+
562+ ``` js
563+ new String (' lard' ) // String {0: "l", 1: "a", 2: "r", 3: "d", length: 4}
564+ ' lard' // "lard"
565+ new String (' lard' ) === ' lard' // false
566+ ```
567+
568+ To 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.
569+
570+ Basically, 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} ` .
571+
572+ In short: It's not about consistency, rather about the 99.9% use case.
573+
574+ type name | ` typeof ` | check-types | testcase
575+ --|--|--|--
576+ ** Object** | object | ** Object** | ` ({}) instanceof Object ` -> ` true `
577+ ** Array** | object | ** Array** | ` ([]) instanceof Array ` -> ` true `
578+ ** Date** | object | ** Date** | ` (new Date()) instanceof Date ` -> ` true `
579+ ** RegExp** | object | ** RegExp** | ` (new RegExp(/.+/)) instanceof RegExp ` -> ` true `
580+ Boolean | ** boolean** | ** boolean** | ` (true) instanceof Boolean ` -> ** ` false ` **
581+ Number | ** number** | ** number** | ` (41) instanceof Number ` -> ** ` false ` **
582+ String | ** string** | ** string** | ` ("test") instanceof String ` -> ** ` false ` **
583+
417584|||
418585| ---| ---|
419586| Context| ` ArrowFunctionExpression ` , ` FunctionDeclaration ` , ` FunctionExpression ` |
@@ -462,7 +629,8 @@ function quux (foo, bar, baz) {
462629```
463630
464631
465- <h3 id =" eslint-plugin-jsdoc-rules-newline-after-description " ><code >newline-after-description</code ></h3 >
632+ <a name =" eslint-plugin-jsdoc-rules-newline-after-description " ></a >
633+ ### <code >newline-after-description</code >
466634
467635Enforces a consistent padding of the block description.
468636
@@ -542,7 +710,8 @@ function quux () {
542710```
543711
544712
545- <h3 id =" eslint-plugin-jsdoc-rules-require-description-complete-sentence " ><code >require-description-complete-sentence</code ></h3 >
713+ <a name =" eslint-plugin-jsdoc-rules-require-description-complete-sentence " ></a >
714+ ### <code >require-description-complete-sentence</code >
546715
547716Requires that block description and tag description are written in complete sentences, i.e.,
548717
@@ -666,7 +835,8 @@ function quux () {
666835```
667836
668837
669- <h3 id =" eslint-plugin-jsdoc-rules-require-hyphen-before-param-description " ><code >require-hyphen-before-param-description</code ></h3 >
838+ <a name =" eslint-plugin-jsdoc-rules-require-hyphen-before-param-description " ></a >
839+ ### <code >require-hyphen-before-param-description</code >
670840
671841Requires a hyphen before the ` @param ` description.
672842
@@ -699,7 +869,8 @@ function quux () {
699869```
700870
701871
702- <h3 id =" eslint-plugin-jsdoc-rules-require-param " ><code >require-param</code ></h3 >
872+ <a name =" eslint-plugin-jsdoc-rules-require-param " ></a >
873+ ### <code >require-param</code >
703874
704875Requires that all function parameters are documented.
705876
@@ -746,6 +917,13 @@ function quux (foo) {
746917
747918}
748919
920+ /**
921+ * @inheritdoc
922+ */
923+ function quux (foo ) {
924+
925+ }
926+
749927/**
750928 * @arg foo
751929 */
@@ -755,7 +933,8 @@ function quux (foo) {
755933```
756934
757935
758- <h3 id =" eslint-plugin-jsdoc-rules-require-param-description " ><code >require-param-description</code ></h3 >
936+ <a name =" eslint-plugin-jsdoc-rules-require-param-description " ></a >
937+ ### <code >require-param-description</code >
759938
760939Requires that ` @param ` tag has ` description ` value.
761940
@@ -803,7 +982,8 @@ function quux (foo) {
803982```
804983
805984
806- <h3 id =" eslint-plugin-jsdoc-rules-require-param-type " ><code >require-param-type</code ></h3 >
985+ <a name =" eslint-plugin-jsdoc-rules-require-param-type " ></a >
986+ ### <code >require-param-type</code >
807987
808988Requires that ` @param ` tag has ` type ` value.
809989
@@ -851,7 +1031,8 @@ function quux (foo) {
8511031```
8521032
8531033
854- <h3 id =" eslint-plugin-jsdoc-rules-require-returns-description " ><code >require-returns-description</code ></h3 >
1034+ <a name =" eslint-plugin-jsdoc-rules-require-returns-description " ></a >
1035+ ### <code >require-returns-description</code >
8551036
8561037Requires that ` @returns ` tag has ` description ` value.
8571038
@@ -899,7 +1080,8 @@ function quux () {
8991080```
9001081
9011082
902- <h3 id =" eslint-plugin-jsdoc-rules-require-returns-type " ><code >require-returns-type</code ></h3 >
1083+ <a name =" eslint-plugin-jsdoc-rules-require-returns-type " ></a >
1084+ ### <code >require-returns-type</code >
9031085
9041086Requires that ` @returns ` tag has ` type ` value.
9051087
0 commit comments