Skip to content

Commit 8edd16a

Browse files
committed
docs: indicate option usage; fixes #383
1 parent 87d4166 commit 8edd16a

File tree

2 files changed

+81
-29
lines changed

2 files changed

+81
-29
lines changed

.README/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,31 @@ above as "recommended":
8181

8282
You can then selectively add to or override the recommended rules.
8383

84+
## Options
85+
86+
Rules 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,
87+
such as, `exemptedBy` and `contexts`, may be used across different rules.
88+
89+
`eslint-plugin-jsdoc` options, if present, are in the form of an object
90+
supplied as the second argument in an array after the error level.
91+
92+
```js
93+
// `.eslintrc.js`
94+
{
95+
rules: {
96+
'jsdoc/require-example': [
97+
// The Error level should be `error`, `warn`, or `off` (or 2, 1, or 0)
98+
'error',
99+
// The options vary by rule, but are added to an options object:
100+
{
101+
avoidExampleOnConstructors: true,
102+
exemptedBy: ['type']
103+
}
104+
]
105+
}
106+
}
107+
```
108+
84109
## Settings
85110

86111
### Allow `@private` to disable rules for that comment block

README.md

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ JSDoc linting rules for ESLint.
1111
* [eslint-plugin-jsdoc](#eslint-plugin-jsdoc)
1212
* [Installation](#eslint-plugin-jsdoc-installation)
1313
* [Configuration](#eslint-plugin-jsdoc-configuration)
14+
* [Options](#eslint-plugin-jsdoc-options)
1415
* [Settings](#eslint-plugin-jsdoc-settings)
1516
* [Allow `@private` to disable rules for that comment block](#eslint-plugin-jsdoc-settings-allow-private-to-disable-rules-for-that-comment-block)
1617
* [Mode](#eslint-plugin-jsdoc-settings-mode)
@@ -120,6 +121,32 @@ above as "recommended":
120121

121122
You can then selectively add to or override the recommended rules.
122123

124+
<a name="eslint-plugin-jsdoc-options"></a>
125+
## Options
126+
127+
Rules 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,
128+
such as, `exemptedBy` and `contexts`, may be used across different rules.
129+
130+
`eslint-plugin-jsdoc` options, if present, are in the form of an object
131+
supplied as the second argument in an array after the error level.
132+
133+
```js
134+
// `.eslintrc.js`
135+
{
136+
rules: {
137+
'jsdoc/require-example': [
138+
// The Error level should be `error`, `warn`, or `off` (or 2, 1, or 0)
139+
'error',
140+
// The options vary by rule, but are added to an options object:
141+
{
142+
avoidExampleOnConstructors: true,
143+
exemptedBy: ['type']
144+
}
145+
]
146+
}
147+
}
148+
```
149+
123150
<a name="eslint-plugin-jsdoc-settings"></a>
124151
## Settings
125152

@@ -464,12 +491,12 @@ function quux (foo) {}
464491

465492
Ensures that (JavaScript) examples within JSDoc adhere to ESLint rules.
466493

467-
<a name="eslint-plugin-jsdoc-rules-check-examples-options"></a>
494+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-1"></a>
468495
#### Options
469496

470497
The options below all default to no-op/`false` except as noted.
471498

472-
<a name="eslint-plugin-jsdoc-rules-check-examples-options-captionrequired"></a>
499+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-1-captionrequired"></a>
473500
##### <code>captionRequired</code>
474501

475502
JSDoc specs use of an optional `<caption>` element at the beginning of
@@ -478,7 +505,7 @@ JSDoc specs use of an optional `<caption>` element at the beginning of
478505
The option `captionRequired` insists on a `<caption>` being present at
479506
the beginning of any `@example`.
480507

481-
<a name="eslint-plugin-jsdoc-rules-check-examples-options-examplecoderegex-and-rejectexamplecoderegex"></a>
508+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-1-examplecoderegex-and-rejectexamplecoderegex"></a>
482509
##### <code>exampleCodeRegex</code> and <code>rejectExampleCodeRegex</code>
483510

484511
JSDoc does not specify a formal means for delimiting code blocks within
@@ -502,7 +529,7 @@ If neither is in use, all examples will be matched. Note also that even if
502529
`captionRequired` is not set, any initial `<caption>` will be stripped out
503530
before doing the regex matching.
504531

505-
<a name="eslint-plugin-jsdoc-rules-check-examples-options-paddedindent"></a>
532+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-1-paddedindent"></a>
506533
##### <code>paddedIndent</code>
507534

508535
This integer property allows one to add a fixed amount of whitespace at the
@@ -521,7 +548,7 @@ out before evaluation.
521548
*/
522549
```
523550

524-
<a name="eslint-plugin-jsdoc-rules-check-examples-options-reportunuseddisabledirectives"></a>
551+
<a name="eslint-plugin-jsdoc-rules-check-examples-options-1-reportunuseddisabledirectives"></a>
525552
##### <code>reportUnusedDisableDirectives</code>
526553

527554
If not set to `false`, `reportUnusedDisableDirectives` will report disabled
@@ -908,12 +935,12 @@ the following description is not reported:
908935
*/
909936
```
910937

911-
<a name="eslint-plugin-jsdoc-rules-check-indentation-options-1"></a>
938+
<a name="eslint-plugin-jsdoc-rules-check-indentation-options-2"></a>
912939
#### Options
913940

914941
This rule has an object option.
915942

916-
<a name="eslint-plugin-jsdoc-rules-check-indentation-options-1-excludetags"></a>
943+
<a name="eslint-plugin-jsdoc-rules-check-indentation-options-2-excludetags"></a>
917944
##### <code>excludeTags</code>
918945

919946
Array of tags (e.g., `['example', 'description']`) whose content will be
@@ -1562,10 +1589,10 @@ wizaction
15621589

15631590
Note that the tags indicated as replacements in `settings.jsdoc.tagNamePreference` will automatically be considered as valid.
15641591

1565-
<a name="eslint-plugin-jsdoc-rules-check-tag-names-options-2"></a>
1592+
<a name="eslint-plugin-jsdoc-rules-check-tag-names-options-3"></a>
15661593
#### Options
15671594

1568-
<a name="eslint-plugin-jsdoc-rules-check-tag-names-options-2-definedtags"></a>
1595+
<a name="eslint-plugin-jsdoc-rules-check-tag-names-options-3-definedtags"></a>
15691596
##### <code>definedTags</code>
15701597

15711598
Use an array of `definedTags` strings to configure additional, allowed tags.
@@ -2165,7 +2192,7 @@ Date
21652192
RegExp
21662193
```
21672194

2168-
<a name="eslint-plugin-jsdoc-rules-check-types-options-3"></a>
2195+
<a name="eslint-plugin-jsdoc-rules-check-types-options-4"></a>
21692196
#### Options
21702197

21712198
`check-types` allows one option:
@@ -3069,10 +3096,10 @@ by our supported Node versions):
30693096
Applies to the jsdoc block description and `@description` (or `@desc`)
30703097
by default but the `tags` option (see below) may be used to match other tags.
30713098

3072-
<a name="eslint-plugin-jsdoc-rules-match-description-options-4"></a>
3099+
<a name="eslint-plugin-jsdoc-rules-match-description-options-5"></a>
30733100
#### Options
30743101

3075-
<a name="eslint-plugin-jsdoc-rules-match-description-options-4-matchdescription"></a>
3102+
<a name="eslint-plugin-jsdoc-rules-match-description-options-5-matchdescription"></a>
30763103
##### <code>matchDescription</code>
30773104

30783105
You can supply your own expression to override the default, passing a
@@ -3087,7 +3114,7 @@ You can supply your own expression to override the default, passing a
30873114
As with the default, the supplied regular expression will be applied with the
30883115
Unicode (`"u"`) flag and is *not* case-insensitive.
30893116

3090-
<a name="eslint-plugin-jsdoc-rules-match-description-options-4-tags"></a>
3117+
<a name="eslint-plugin-jsdoc-rules-match-description-options-5-tags"></a>
30913118
##### <code>tags</code>
30923119

30933120
If you want different regular expressions to apply to tags, you may use
@@ -3124,7 +3151,7 @@ its "description" (e.g., for `@returns {someType} some description`, the
31243151
description is `some description` while for `@some-tag xyz`, the description
31253152
is `xyz`).
31263153

3127-
<a name="eslint-plugin-jsdoc-rules-match-description-options-4-maindescription"></a>
3154+
<a name="eslint-plugin-jsdoc-rules-match-description-options-5-maindescription"></a>
31283155
##### <code>mainDescription</code>
31293156

31303157
If you wish to override the main function description without changing the
@@ -3146,7 +3173,7 @@ There is no need to add `mainDescription: true`, as by default, the main
31463173
function (and only the main function) is linted, though you may disable checking
31473174
it by setting it to `false`.
31483175

3149-
<a name="eslint-plugin-jsdoc-rules-match-description-options-4-contexts"></a>
3176+
<a name="eslint-plugin-jsdoc-rules-match-description-options-5-contexts"></a>
31503177
##### <code>contexts</code>
31513178

31523179
Set this to an array of strings representing the AST context
@@ -3766,7 +3793,7 @@ function quux () {
37663793

37673794
Enforces a consistent padding of the block description.
37683795

3769-
<a name="eslint-plugin-jsdoc-rules-newline-after-description-options-5"></a>
3796+
<a name="eslint-plugin-jsdoc-rules-newline-after-description-options-6"></a>
37703797
#### Options
37713798

37723799
This 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"`.
@@ -3950,7 +3977,7 @@ The following types are always considered defined.
39503977
Note that preferred types indicated within `settings.jsdoc.preferredTypes` will
39513978
also be assumed to be defined.
39523979

3953-
<a name="eslint-plugin-jsdoc-rules-no-undefined-types-options-6"></a>
3980+
<a name="eslint-plugin-jsdoc-rules-no-undefined-types-options-7"></a>
39543981
#### Options
39553982

39563983
An option object may have the following key:
@@ -4299,10 +4326,10 @@ tag descriptions are written in complete sentences, i.e.,
42994326
* A colon or semi-colon followed by two line breaks is still part of the
43004327
containing paragraph (unlike normal dual line breaks).
43014328

4302-
<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-7"></a>
4329+
<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-8"></a>
43034330
#### Options
43044331

4305-
<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-7-tags-1"></a>
4332+
<a name="eslint-plugin-jsdoc-rules-require-description-complete-sentence-options-8-tags-1"></a>
43064333
##### <code>tags</code>
43074334

43084335
If you want additional tags to be checked for their descriptions, you may
@@ -4765,7 +4792,7 @@ Requires that all functions have a description.
47654792
`"tag"`) must have a non-empty description that explains the purpose of the
47664793
method.
47674794

4768-
<a name="eslint-plugin-jsdoc-rules-require-description-options-8"></a>
4795+
<a name="eslint-plugin-jsdoc-rules-require-description-options-9"></a>
47694796
#### Options
47704797

47714798
An options object may have any of the following properties:
@@ -5050,25 +5077,25 @@ Requires that all functions have examples.
50505077
* All functions must have one or more `@example` tags.
50515078
* Every example tag must have a non-empty description that explains the method's usage.
50525079

5053-
<a name="eslint-plugin-jsdoc-rules-require-example-options-9"></a>
5080+
<a name="eslint-plugin-jsdoc-rules-require-example-options-10"></a>
50545081
#### Options
50555082

50565083
This rule has an object option.
50575084

5058-
<a name="eslint-plugin-jsdoc-rules-require-example-options-9-exemptedby"></a>
5085+
<a name="eslint-plugin-jsdoc-rules-require-example-options-10-exemptedby"></a>
50595086
##### <code>exemptedBy</code>
50605087

50615088
Array of tags (e.g., `['type']`) whose presence on the document
50625089
block avoids the need for an `@example`. Defaults to an empty array.
50635090

5064-
<a name="eslint-plugin-jsdoc-rules-require-example-options-9-avoidexampleonconstructors"></a>
5091+
<a name="eslint-plugin-jsdoc-rules-require-example-options-10-avoidexampleonconstructors"></a>
50655092
##### <code>avoidExampleOnConstructors</code>
50665093

50675094
Set to `true` to avoid the need for an example on a constructor (whether
50685095
indicated as such by a jsdoc tag or by being within an ES6 `class`).
50695096
Defaults to `false`.
50705097

5071-
<a name="eslint-plugin-jsdoc-rules-require-example-options-9-contexts-1"></a>
5098+
<a name="eslint-plugin-jsdoc-rules-require-example-options-10-contexts-1"></a>
50725099
##### <code>contexts</code>
50735100

50745101
Set this to an array of strings representing the AST context
@@ -5246,7 +5273,7 @@ function quux () {
52465273

52475274
Requires a hyphen before the `@param` description.
52485275

5249-
<a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description-options-10"></a>
5276+
<a name="eslint-plugin-jsdoc-rules-require-hyphen-before-param-description-options-11"></a>
52505277
#### Options
52515278

52525279
This 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"`.
@@ -5352,7 +5379,7 @@ function quux () {
53525379
Checks for presence of jsdoc comments, on class declarations as well as
53535380
functions.
53545381

5355-
<a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-11"></a>
5382+
<a name="eslint-plugin-jsdoc-rules-require-jsdoc-options-12"></a>
53565383
#### Options
53575384

53585385
Accepts one optional options object with the following optional keys.
@@ -6540,7 +6567,7 @@ function quux (foo) {
65406567

65416568
Requires that all function parameters are documented.
65426569

6543-
<a name="eslint-plugin-jsdoc-rules-require-param-options-12"></a>
6570+
<a name="eslint-plugin-jsdoc-rules-require-param-options-13"></a>
65446571
#### Options
65456572

65466573
An options object accepts one optional property:
@@ -7613,7 +7640,7 @@ Requires returns are documented.
76137640

76147641
Will also report if multiple `@returns` tags are present.
76157642

7616-
<a name="eslint-plugin-jsdoc-rules-require-returns-options-13"></a>
7643+
<a name="eslint-plugin-jsdoc-rules-require-returns-options-14"></a>
76177644
#### Options
76187645

76197646
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
@@ -8078,7 +8105,7 @@ Also impacts behaviors on namepath (or event)-defining and pointing tags:
80788105
allow `#`, `.`, or `~` at the end (which is not allowed at the end of
80798106
normal paths).
80808107

8081-
<a name="eslint-plugin-jsdoc-rules-valid-types-options-14"></a>
8108+
<a name="eslint-plugin-jsdoc-rules-valid-types-options-15"></a>
80828109
#### Options
80838110

80848111
- `allowEmptyNamepaths` (default: true) - Set to `false` to disallow

0 commit comments

Comments
 (0)