Skip to content

Commit 9fa7b52

Browse files
committed
Merge branch 'master' into add-more-type-checks-to-valid-types
* master: feat(`require-description`): add `descriptionStyle` option to accept implicit descriptions as satisfying the rule by default (fixes #301) feat(`match-description`): allow arbitrary tags; also fixes `returns`/`return` to avoid skipping matching of an initial "name" and space
2 parents 89cd7f9 + 616bc83 commit 9fa7b52

File tree

7 files changed

+555
-44
lines changed

7 files changed

+555
-44
lines changed

.README/rules/match-description.md

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

53+
The tags `@param`/`@arg`/`@argument` will be properly parsed to ensure that
54+
the matched "description" text includes only the text after the name.
55+
All other tags will treat the text following the tag name, a space, and
56+
an optional curly-bracketed type expression (and another space) as part of
57+
its "description" (e.g., for `@returns {someType} some description`, the
58+
description is `some description` while for `@some-tag xyz`, the description
59+
is `xyz`).
60+
5361
##### `mainDescription`
5462

5563
If you wish to override the main function description without changing the
@@ -82,6 +90,6 @@ Overrides the default contexts (see below).
8290
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
8391
|Tags|N/A by default but see `tags` options|
8492
|Settings||
85-
|Options|`contexts`, `tags` (allows for 'param', 'arg', 'argument', 'returns', 'return', 'description', 'desc'), `mainDescription`, `matchDescription`|
93+
|Options|`contexts`, `tags` (allows for 'param', 'arg', 'argument', 'description', 'desc', and any added to `tags` option, e.g., 'returns', 'return'), `mainDescription`, `matchDescription`|
8694

8795
<!-- assertions matchDescription -->

.README/rules/require-description.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,32 @@
22

33
Requires that all functions have a description.
44

5-
* All functions must have a `@description` tag.
6-
* Every description tag must have a non-empty description that explains the purpose of the method.
5+
* All functions must have an implicit description or have the option
6+
`descriptionStyle` set to `tag`.
7+
* Every jsdoc block description (or description tag if `descriptionStyle` is
8+
`"tag"`) must have a non-empty description that explains the purpose of the
9+
method.
710

811
#### Options
912

1013
An options object may have any of the following properties:
1114

1215
- `contexts` - Set to an array of strings representing the AST context
13-
where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
14-
Overrides the default contexts (see below).
15-
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document
16-
block avoids the need for a `@description`. Defaults to an empty array.
16+
where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6
17+
classes). Overrides the default contexts (see below).
18+
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the
19+
document block avoids the need for a `@description`. Defaults to an
20+
empty array.
21+
- `descriptionStyle` - Whether to accept implicit descriptions (`"body"`) or
22+
`@description` tags (`"tag"`) as satisfying the rule. Set to `"any"` to
23+
accept either style. Defaults to `"body"`.
1724

1825
|||
1926
|---|---|
2027
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
21-
|Tags|`description`|
28+
|Tags|`description` or jsdoc block|
2229
|Aliases|`desc`|
23-
|Options|`contexts`, `exemptedBy`|
30+
|Options|`contexts`, `exemptedBy`, `descriptionStyle`|
2431
|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
2532

2633
<!-- assertions requireDescription -->

0 commit comments

Comments
 (0)