Skip to content

Commit 2a153d2

Browse files
committed
docs: indicate option defaults (fixes part of #256) and ensure optioins all listed in docs
1 parent 40d681d commit 2a153d2

11 files changed

+75
-56
lines changed

.README/rules/check-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RegExp
2424
- An option object:
2525
- with the key `noDefaults` to insist that only the supplied option type
2626
map is to be used, and that the default preferences (such as "string"
27-
over "String") will not be enforced.
27+
over "String") will not be enforced. The option's default is `false`.
2828
- with the key `unifyParentAndChildTypeChecks` which will treat
2929
`settings.jsdoc.preferredTypes` keys such as `SomeType` as matching
3030
not only child types such as an unadorned `SomeType` but also

.README/rules/match-description.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ tag should be linted with the `matchDescription` value (or the default).
5050
}
5151
```
5252

53+
##### `mainDescription`
54+
5355
If you wish to override the main function description without changing the
5456
default `match-description`, you may use `mainDescription`:
5557

@@ -73,13 +75,13 @@ it by setting it to `false`.
7375

7476
Set this to an array of strings representing the AST context
7577
where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
76-
Overrides the defaults.
78+
Overrides the default contexts (see below).
7779

7880
|||
7981
|---|---|
8082
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
8183
|Tags|N/A by default but see `tags` options|
8284
|Settings||
83-
|Options|`contexts`, `tags` (allows for 'param', 'arg', 'argument', 'returns', 'return'), `matchDescription`|
85+
|Options|`contexts`, `tags` (allows for 'param', 'arg', 'argument', 'returns', 'return'), `mainDescription`, `matchDescription`|
8486

8587
<!-- assertions matchDescription -->

.README/rules/newline-after-description.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22

33
Enforces a consistent padding of the block description.
44

5-
This rule takes one argument. If it is `"always"` then a problem is raised when there is a newline after the description. If it is `"never"` then a problem is raised when there is no newline after the description. The default value is `"always"`.
5+
#### Options
6+
7+
This rule allows one optional string argument. If it is `"always"` then a problem is raised when there is a newline after the description. If it is `"never"` then a problem is raised when there is no newline after the description. The default value is `"always"`.
68

79
|||
810
|---|---|
911
|Context|everywhere|
12+
|Options|(a string matching `"always"|"never"`)|
1013
|Tags|N/A|
1114

1215
<!-- assertions newlineAfterDescription -->

.README/rules/no-undefined-types.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ An option object may have the following keys:
2626

2727
- `preferredTypesDefined` - If this option is set to `true` and preferred
2828
types are indicated within `settings.jsdoc.preferredTypes`, any such
29-
types will be assumed to be defined as well.
29+
types will be assumed to be defined as well. Defaults to `false`.
3030
- `definedTypes` - This array can be populated to indicate other types which
31-
are automatically considered as defined (in addition to globals, etc.)
31+
are automatically considered as defined (in addition to globals, etc.).
32+
Defaults to an empty array.
3233

3334
|||
3435
|---|---|

.README/rules/require-description.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ An options object may have any of the following properties:
1111

1212
- `contexts` - Set to an array of strings representing the AST context
1313
where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
14-
Overrides the defaults.
14+
Overrides the default contexts (see below).
1515
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
16-
block avoids the need for a `@description`.
16+
block avoids the need for a `@description`. Defaults to an empty array.
1717

1818
|||
1919
|---|---|

.README/rules/require-example.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Requires that all functions have examples.
1010
Has an object option with one optional property:
1111

1212
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
13-
block avoids the need for an `@example`.
13+
block avoids the need for an `@example`. Defaults to an empty array.
1414

1515
|||
1616
|---|---|

.README/rules/require-hyphen-before-param-description.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
Requires a hyphen before the `@param` description.
44

5-
This rule takes one 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"`.
5+
#### Options
6+
7+
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"`.
68

79
|||
810
|---|---|
911
|Context|everywhere|
1012
|Tags|`param`|
1113
|Aliases|`arg`, `argument`|
14+
|Options|(a string matching `"always"|"never"`)|
1215

1316
<!-- assertions requireHyphenBeforeParamDescription -->

.README/rules/require-jsdoc.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ functions.
55

66
#### Options
77

8-
Accepts one optional options object, with two optional keys, `publicOnly`
9-
for confining JSDoc comments to be checked to exported functions (with "exported"
10-
allowing for ESM exports, CJS exports, or browser window global export)
11-
in `require-jsdoc`, and `require` for limiting the contexts which are to
12-
be checked by the rule.
8+
Accepts one optional options object with the following optional keys.
139

14-
- `publicOnly` - Missing jsdoc blocks are only reported for function
15-
bodies / class declarations that are exported from the module.
16-
May be a boolean or object. If set to `true`, the defaults below will
17-
be used.
10+
- `publicOnly` - This option will insist that missing jsdoc blocks are
11+
only reported for function bodies / class declarations that are exported
12+
from the module. May be a boolean or object. If set to `true`, the defaults
13+
below will be used. If unset, jsdoc block reporting will not be limited to
14+
exports.
1815

1916
This object supports the following optional boolean keys (`false` unless
2017
otherwise noted):
@@ -25,7 +22,8 @@ be checked by the rule.
2522
- `window` - Window global exports are checked for JSDoc comments
2623

2724
- `require` - An object with the following optional boolean keys which all
28-
default to `false` except as noted:
25+
default to `false` except as noted, indicating the contexts where the rule
26+
will apply:
2927

3028
- `ArrowFunctionExpression`
3129
- `ClassDeclaration`
@@ -35,13 +33,14 @@ be checked by the rule.
3533
- `MethodDefinition`
3634

3735
- `contexts` - Set this to an array of strings representing the additional
38-
AST context where you wish the rule to be applied (e.g., `Property` for properties).
36+
AST contexts where you wish the rule to be applied (e.g., `Property` for
37+
properties). Defaults to an empty array.
3938

4039
|||
4140
|---|---|
4241
|Context|`ArrowFunctionExpression`, `ClassDeclaration`, `ClassExpression`, `FunctionDeclaration`, `FunctionExpression`|
4342
|Tags|N/A|
44-
|Options|`publicOnly`|
43+
|Options|`publicOnly`, `require`, `contexts`|
4544
|Settings|`exemptEmptyFunctions`|
4645

4746
<!-- assertions requireJsdoc -->

.README/rules/require-param.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Requires that all function parameters are documented.
77
An options object accepts one optional property:
88

99
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
10-
block avoids the need for a `@param`.
10+
block avoids the need for a `@param`. Defaults to an empty array.
1111

1212
|||
1313
|---|---|

.README/rules/require-returns.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Requires returns are documented.
55
#### Options
66

77
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
8-
block avoids the need for a `@returns`.
9-
- `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` as true on the options object. This may be useful as an `async` function will always return a Promise, even if the Promise returns void.
8+
block avoids the need for a `@returns`. Defaults to an empty array.
9+
- `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`.
1010

1111
```js
1212
'jsdoc/require-jsdoc': ['error', {forceReturnsWithAsync: true}]

0 commit comments

Comments
 (0)