Skip to content

Commit 78a0cba

Browse files
committed
Merge branch 'master' into add-more-type-checks-to-valid-types
* master: (46 commits) feat(require-description-complete-sentence): limit checking to certain default tags likely to have descriptions or by `tags` array for additional choices; fixes #337 docs(newline-after-description): indicate applies on doc block docs(match-description): add alias `desc` to separate column docs(match-description): indicate application by default to `description`/`desc` and allowance for `property`/`prop`; clarify fix(match-description): ensure `prop` and `property` matching excludes name testing(require-param): fix test source (part of #332) testing(require-param): fix test expectation (part of #332) docs: generate docs chore: update devDeps (eslint-config-canonical, gitdown) fix(no-undefined-types): ensure working in all contexts; fixes #324 refactor(iterateJsdoc): reduce retrieval calls docs(check-examples): allow for whitespace at end feat(check-examples): add `paddedIndent` option fix(check-examples): preserve whitespace so as to report issues with whitespace-related rules such as `indent` (fixes #211) chore(travis): fix Travis to use older unicorn version that supports Node 6 (and the canonical config that requires the earlier unicorn version) docs(require-returns, require-returns-check): indicate that these will report if multiple `returns` tags are present refactor: use `String.prototype.repeat` over lodash `repeat` refactor: apply (jsdoc-related) eslint rule fixes chore: add `lint-fix` script fix(newline-after-description): avoid matching duplicate or partial matches within tag descriptions after the block description; fixes #328 ...
2 parents 9fa7b52 + 0eb7a0c commit 78a0cba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1441
-215
lines changed

.README/rules/check-examples.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ syntax highlighting). The following options determine whether a given
2626
so you may wish to use `(?:...)` groups where you do not wish the
2727
first such group treated as one to include. If no parenthetical group
2828
exists or matches, the whole matching expression will be used.
29-
An example might be ````"^```(?:js|javascript)([\\s\\S]*)```$"````
29+
An example might be ````"^```(?:js|javascript)([\\s\\S]*)```\s*$"````
3030
to only match explicitly fenced JavaScript blocks.
3131
* `rejectExampleCodeRegex` - Regex blacklist which rejects
3232
non-lintable examples (has priority over `exampleCodeRegex`). An example
@@ -37,6 +37,24 @@ If neither is in use, all examples will be matched. Note also that even if
3737
`captionRequired` is not set, any initial `<caption>` will be stripped out
3838
before doing the regex matching.
3939

40+
#### `paddedIndent`
41+
42+
This integer property allows one to add a fixed amount of whitespace at the
43+
beginning of the second or later lines of the example to be stripped so as
44+
to avoid linting issues with the decorative whitespace. For example, if set
45+
to a value of `4`, the initial whitespace below will not trigger `indent`
46+
rule errors as the extra 4 spaces on each subsequent line will be stripped
47+
out before evaluation.
48+
49+
```js
50+
/**
51+
* @example
52+
* anArray.filter((a) => {
53+
* return a.b;
54+
* });
55+
*/
56+
```
57+
4058
#### `reportUnusedDisableDirectives`
4159

4260
If not set to `false`, `reportUnusedDisableDirectives` will report disabled
@@ -98,7 +116,7 @@ decreasing precedence:
98116

99117
|||
100118
|---|---|
101-
|Context|`ArrowFunctionExpression`, `ClassDeclaration`, `FunctionDeclaration`, `FunctionExpression`|
119+
|Context|everywhere|
102120
|Tags|`example`|
103121
|Options| *See above* |
104122

.README/rules/match-description.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ by our supported Node versions):
88

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

11+
Applies to the jsdoc block description and `@description` (or `@desc`)
12+
by default but the `tags` option (see below) may be used to match other tags.
13+
1114
#### Options
1215

1316
##### `matchDescription`
@@ -50,8 +53,10 @@ tag should be linted with the `matchDescription` value (or the default).
5053
}
5154
```
5255

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.
56+
The tags `@param`/`@arg`/`@argument` and `@property`/`@prop` will be properly
57+
parsed to ensure that the matched "description" text includes only the text
58+
after the name.
59+
5560
All other tags will treat the text following the tag name, a space, and
5661
an optional curly-bracketed type expression (and another space) as part of
5762
its "description" (e.g., for `@returns {someType} some description`, the
@@ -88,8 +93,9 @@ Overrides the default contexts (see below).
8893
|||
8994
|---|---|
9095
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
91-
|Tags|N/A by default but see `tags` options|
96+
|Tags|docblock and `@description` by default but more with `tags`|
97+
|Aliases|`@desc`|
9298
|Settings||
93-
|Options|`contexts`, `tags` (allows for 'param', 'arg', 'argument', 'description', 'desc', and any added to `tags` option, e.g., 'returns', 'return'), `mainDescription`, `matchDescription`|
99+
|Options|`contexts`, `tags` (accepts tags with names and optional type such as 'param', 'arg', 'argument', 'property', and 'prop', and accepts arbitrary list of other tags with an optional type (but without names), e.g., 'returns', 'return'), `mainDescription`, `matchDescription`|
94100

95101
<!-- assertions matchDescription -->

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ This rule allows one optional string argument. If it is `"always"` then a proble
1010
|---|---|
1111
|Context|everywhere|
1212
|Options|(a string matching `"always"|"never"`)|
13-
|Tags|N/A|
13+
|Tags|N/A (doc block)|
1414

1515
<!-- assertions newlineAfterDescription -->

.README/rules/require-description-complete-sentence.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,33 @@ tag descriptions are written in complete sentences, i.e.,
99
* Every line in a paragraph (except the first) which starts with an uppercase
1010
character must be preceded by a line ending with a period.
1111

12+
#### Options
13+
14+
##### `tags`
15+
16+
If you want additional tags to be checked for their descriptions, you may
17+
add them within this option.
18+
19+
```js
20+
{
21+
'jsdoc/require-description-complete-sentence': ['error', {tags: ['see', 'copyright']}]
22+
}
23+
```
24+
25+
The tags `@param`/`@arg`/`@argument` and `@property`/`@prop` will be properly
26+
parsed to ensure that the checked "description" text includes only the text
27+
after the name.
28+
29+
All other tags will treat the text following the tag name, a space, and
30+
an optional curly-bracketed type expression (and another space) as part of
31+
its "description" (e.g., for `@returns {someType} some description`, the
32+
description is `some description` while for `@some-tag xyz`, the description
33+
is `xyz`).
34+
1235
|||
1336
|---|---|
1437
|Context|everywhere|
15-
|Tags|`param`, `returns`, `description`|
16-
|Aliases|`arg`, `argument`, `return`, `desc`|
17-
38+
|Tags|doc block, `param`, `returns`, `description`, `property`, `summary`, `file`, `classdesc`, `todo`, `deprecated`, `throws`, 'yields' and others added by `tags`|
39+
|Aliases|`arg`, `argument`, `return`, `desc`, `prop`, `fileoverview`, `overview`, `exception`, `yield`|
40+
|Options|`tags`|
1841
<!-- assertions requireDescriptionCompleteSentence -->

.README/rules/require-example.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,30 @@ Requires that all functions have examples.
77

88
#### Options
99

10-
This rule has an object option:
10+
This rule has an object option.
1111

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

15-
- `avoidExampleOnConstructors` (default: false) - Set to `true` to avoid the
16-
need for an example on a constructor (whether indicated as such by a
17-
jsdoc tag or by being within an ES6 `class`).
14+
Array of tags (e.g., `['type']`) whose presence on the document
15+
block avoids the need for an `@example`. Defaults to an empty array.
16+
17+
##### `avoidExampleOnConstructors`
18+
19+
Set to `true` to avoid the need for an example on a constructor (whether
20+
indicated as such by a jsdoc tag or by being within an ES6 `class`).
21+
Defaults to `false`.
22+
23+
##### `contexts`
24+
25+
Set this to an array of strings representing the AST context
26+
where you wish the rule to be applied (e.g., `ClassDeclaration` for ES6 classes).
27+
Overrides the default contexts (see below).
1828

1929
|||
2030
|---|---|
21-
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|
31+
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`; others when `contexts` option enabled|
2232
|Tags|`example`|
23-
|Options|`exemptedBy`, `avoidExampleOnConstructors`|
33+
|Options|`exemptedBy`, `avoidExampleOnConstructors`, `contexts`|
2434
|Settings|`overrideReplacesDocs`, `augmentsExtendsReplacesDocs`, `implementsReplacesDocs`|
2535

2636
<!-- assertions requireExample -->

.README/rules/require-returns-check.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Checks if the return expression exists in function body and in the comment.
44

5+
Will also report if multiple `@returns` tags are present.
6+
57
|||
68
|---|---|
79
|Context|`ArrowFunctionExpression`, `FunctionDeclaration`, `FunctionExpression`|

.README/rules/require-returns.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Requires returns are documented.
44

5+
Will also report if multiple `@returns` tags are present.
6+
57
#### Options
68

79
- `exemptedBy` - Array of tags (e.g., `['type']`) whose presence on the document

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ node_js:
77
before_install:
88
- npm config set depth 0
99
before_script:
10-
- 'if [ -n "${ESLINT-}" ]; then npm install --no-save "eslint@${ESLINT}" ; fi'
10+
- 'if [ "${ESLINT-}" == "6" ]; then npm install --no-save "eslint@${ESLINT}" ; fi'
11+
- 'if [ "${ESLINT-}" == "5" ]; then npm install --no-save "eslint@${ESLINT}" [email protected] [email protected] ; fi'
1112
notifications:
1213
email: false
1314
sudo: false

0 commit comments

Comments
 (0)