Skip to content

Commit ecc27c5

Browse files
authored
Merge pull request #294 from brettz9/match-description-options
match-description options
2 parents b1b231b + f075b67 commit ecc27c5

12 files changed

+729
-114
lines changed

.README/rules/match-description.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The default is this basic expression to match English sentences (Support
66
for Unicode upper case may be added in a future version when it can be handled
77
by our supported Node versions):
88

9-
``^([A-Z]|[`\\d_])([\\s\\S]*[.?!`])?$``
9+
``^([A-Z]|[`\\d_])[\\s\\S]*[.?!`]$``
1010

1111
#### Options
1212

@@ -50,14 +50,36 @@ tag should be linted with the `matchDescription` value (or the default).
5050
}
5151
```
5252

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

54-
By default, only the main function description is linted.
56+
```js
57+
{
58+
'jsdoc/match-description': ['error', {
59+
mainDescription: '[A-Z].*\\.',
60+
tags: {
61+
param: true,
62+
returns: true
63+
}
64+
}]
65+
}
66+
```
67+
68+
There is no need to add `mainDescription: true`, as by default, the main
69+
function (and only the main function) is linted, though you may disable checking
70+
it by setting it to `false`.
71+
72+
##### `contexts`
73+
74+
Set this to an array of strings representing the AST context
75+
where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
76+
Overrides the defaults.
5577

5678
|||
5779
|---|---|
58-
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
80+
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
5981
|Tags|N/A by default but see `tags` options|
6082
|Settings||
61-
|Options|`tags` (allows for 'param', 'arg', 'argument', 'returns', 'return'), `matchDescription`|
83+
|Options|`contexts`, `tags` (allows for 'param', 'arg', 'argument', 'returns', 'return'), `matchDescription`|
6284

6385
<!-- assertions matchDescription -->

.README/rules/require-description.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@ Requires that all functions have a description.
99

1010
An options object may have any of the following properties:
1111

12-
- `contexts` - Set to a string or array of strings representing the AST context
12+
- `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.
1415
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
1516
block avoids the need for a `@description`.
16-
- `noDefaults` - By default, `contexts` will permit `ArrowFunctionExpression`,
17-
`FunctionDeclaration`, and `FunctionExpression`. Set this instead to `true` to
18-
have `contexts` override these.
1917

2018
|||
2119
|---|---|
2220
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
2321
|Tags|`description`|
2422
|Aliases|`desc`|
25-
|Options|`contexts`, `exemptedBy`, `noDefaults`|
23+
|Options|`contexts`, `exemptedBy`|
2624

2725
<!-- assertions requireDescription -->

.README/rules/require-jsdoc.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ be checked by the rule.
3434
- `FunctionExpression`
3535
- `MethodDefinition`
3636

37+
- `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).
39+
3740
|||
3841
|---|---|
3942
|Context|`ArrowFunctionExpression`, `ClassDeclaration`, `ClassExpression`, `FunctionDeclaration`, `FunctionExpression`|

0 commit comments

Comments
 (0)