Skip to content

Commit 2690806

Browse files
committed
- Fix for matchDescription tags option
- Document `matchDescription` - Better alphabetize rules
1 parent 2781cc8 commit 2690806

File tree

5 files changed

+769
-331
lines changed

5 files changed

+769
-331
lines changed

.README/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,14 @@ Finally, enable all of the rules that you would like to use.
8282
"jsdoc/check-syntax": 1,
8383
"jsdoc/check-tag-names": 1,
8484
"jsdoc/check-types": 1,
85+
"jsdoc/match-description": 1,
8586
"jsdoc/newline-after-description": 1,
8687
"jsdoc/no-undefined-types": 1,
8788
"jsdoc/require-description": 1,
8889
"jsdoc/require-description-complete-sentence": 1,
8990
"jsdoc/require-example": 1,
9091
"jsdoc/require-hyphen-before-param-description": 1,
92+
"jsdoc/require-jsdoc": 1,
9193
"jsdoc/require-param": 1,
9294
"jsdoc/require-param-description": 1,
9395
"jsdoc/require-param-name": 1,
@@ -310,19 +312,20 @@ Finally, the following rule pertains to inline disable directives:
310312
{"gitdown": "include", "file": "./rules/check-syntax.md"}
311313
{"gitdown": "include", "file": "./rules/check-tag-names.md"}
312314
{"gitdown": "include", "file": "./rules/check-types.md"}
315+
{"gitdown": "include", "file": "./rules/match-description.md"}
313316
{"gitdown": "include", "file": "./rules/newline-after-description.md"}
314317
{"gitdown": "include", "file": "./rules/no-undefined-types.md"}
315318
{"gitdown": "include", "file": "./rules/require-description-complete-sentence.md"}
316319
{"gitdown": "include", "file": "./rules/require-description.md"}
317320
{"gitdown": "include", "file": "./rules/require-example.md"}
318-
{"gitdown": "include", "file": "./rules/require-jsdoc.md"}
319321
{"gitdown": "include", "file": "./rules/require-hyphen-before-param-description.md"}
322+
{"gitdown": "include", "file": "./rules/require-jsdoc.md"}
320323
{"gitdown": "include", "file": "./rules/require-param-description.md"}
321324
{"gitdown": "include", "file": "./rules/require-param-name.md"}
322325
{"gitdown": "include", "file": "./rules/require-param-type.md"}
323326
{"gitdown": "include", "file": "./rules/require-param.md"}
327+
{"gitdown": "include", "file": "./rules/require-returns-check.md"}
324328
{"gitdown": "include", "file": "./rules/require-returns-description.md"}
325329
{"gitdown": "include", "file": "./rules/require-returns-type.md"}
326-
{"gitdown": "include", "file": "./rules/require-returns-check.md"}
327330
{"gitdown": "include", "file": "./rules/require-returns.md"}
328331
{"gitdown": "include", "file": "./rules/valid-types.md"}

.README/rules/match-description.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
### `match-description`
2+
3+
Enforces a regular expression pattern on descriptions.
4+
5+
The default is this basic expression to match English sentences (Support
6+
for Unicode upper case may be added in a future version when it can be handled
7+
by our supported Node versions):
8+
9+
``^([A-Z]|[`\\d_])([\\s\\S]*[.?!`])?$``
10+
11+
You can supply your own expression passing a `matchDescription` string on
12+
the options object.
13+
14+
```js
15+
{
16+
'jsdoc/match-description': ['error', {matchDescription: '[A-Z].*\\.'}]
17+
}
18+
```
19+
20+
If you want different regular expressions to apply to tags, you may use
21+
the `tags` option object:
22+
23+
```js
24+
{
25+
'jsdoc/match-description': ['error', {tags: {
26+
param: '\\- [A-Z].*\\.',
27+
returns: '[A-Z].*\\.'
28+
}}]
29+
}
30+
```
31+
32+
In place of a string, you can also add `true` to indicate that a particular
33+
tag should be linted with the `matchDescription` value (or the default).
34+
35+
```js
36+
{
37+
'jsdoc/match-description': ['error', {tags: {
38+
param: true,
39+
returns: true
40+
}}]
41+
}
42+
```
43+
44+
45+
By default, only the main function description is linted.
46+
47+
|||
48+
|---|---|
49+
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
50+
|Tags|N/A by default but see `tags` options|
51+
|Settings||
52+
|Options|`tags` (allows for 'param', 'arg', 'argument', 'returns', 'return'), `matchDescription`|
53+
54+
<!-- assertions matchDescription -->

0 commit comments

Comments
 (0)