Skip to content

Commit af1c346

Browse files
committed
feat(multiline-blocks): allow control of how and whether jsdoc blocks can be expressed as single or multiple line blocks
1 parent 1b305f0 commit af1c346

File tree

8 files changed

+1421
-78
lines changed

8 files changed

+1421
-78
lines changed

.README/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ selector).
552552
{"gitdown": "include", "file": "./rules/empty-tags.md"}
553553
{"gitdown": "include", "file": "./rules/implements-on-classes.md"}
554554
{"gitdown": "include", "file": "./rules/match-description.md"}
555+
{"gitdown": "include", "file": "./rules/multiline-blocks.md"}
555556
{"gitdown": "include", "file": "./rules/newline-after-description.md"}
556557
{"gitdown": "include", "file": "./rules/no-bad-blocks.md"}
557558
{"gitdown": "include", "file": "./rules/no-defaults.md"}

.README/rules/multiline-blocks.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
### `multiline-blocks`
2+
3+
Controls how and whether jsdoc blocks can be expressed as single or multiple
4+
line blocks.
5+
6+
Note that if you set `noSingleLineBlocks` and `noMultilineBlocks` to `true`
7+
and configure them in a certain manner, you might effectively be prohibiting
8+
all jsdoc blocks!
9+
10+
#### Options
11+
12+
A single options object with the following properties.
13+
14+
##### `noZeroLineText` (defaults to `true`)
15+
16+
For multiline blocks, any non-whitespace text immediately after the `/**` and
17+
space will be reported. (Text after a newline is not reported.)
18+
19+
`noMultilineBlocks` will have priority over this rule if it applies.
20+
21+
##### `noSingleLineBlocks` (defaults to `false`)
22+
23+
If this is `true`, any single line blocks will be reported, except those which
24+
are whitelisted in `singleLineTags`.
25+
26+
##### `singleLineTags` (defaults to `['lends', 'type']`)
27+
28+
An array of tags which can nevertheless be allowed as single line blocks when
29+
`noSingleLineBlocks` is set. You may set this to a empty array to
30+
cause all single line blocks to be reported. If `'*'` is present, then
31+
the presence of a tag will allow single line blocks (but not if a tag is
32+
missing).
33+
34+
##### `noMultilineBlocks` (defaults to `false`)
35+
36+
Requires that jsdoc blocks are restricted to single lines only unless impacted
37+
by the options `minimumLengthForMultiline`, `multilineTags`, or
38+
`allowMultipleTags`.
39+
40+
##### `minimumLengthForMultiline` (defaults to not being in effect)
41+
42+
If `noMultilineBlocks` is set with this numeric option, multiline blocks will
43+
be permitted if containing at least the given amount of text.
44+
45+
If not set, multiline blocks will not be permitted regardless of length unless
46+
a relevant tag is present and `multilineTags` is set.
47+
48+
##### `multilineTags` (defaults to `['*']`)
49+
50+
If `noMultilineBlocks` is set with this option, multiline blocks may be allowed
51+
regardless of length as long as a tag or a tag of a certain type is present.
52+
53+
If `*` is included in the array, the presence of a tags will allow for
54+
multiline blocks (but not when without any tags unless the amount of text is
55+
over an amount specified by `minimumLengthForMultiline`).
56+
57+
If the array does not include `*` but lists certain tags, the presence of
58+
such a tag will cause multiline blocks to be allowed.
59+
60+
You may set this to an empty array to prevent any tag from permitting multiple
61+
lines.
62+
63+
##### `allowMultipleTags` (defaults to `true`)
64+
65+
If `noMultilineBlocks` is set to `true` with this option and multiple tags are
66+
found in a block, an error will not be reported.
67+
68+
Since multiple-tagged lines cannot be collapsed into a single line, this option
69+
prevents them from being reported. Set to `false` if you really want to report
70+
any blocks.
71+
72+
This option will also be applied when there is a block description and a single
73+
tag (since a description cannot precede a tag on a single line, and also
74+
cannot be reliably added after the tag either).
75+
76+
|||
77+
|---|---|
78+
|Context|everywhere|
79+
|Tags|Any (though `singleLineTags` and `multilineTags` control the application)|
80+
|Recommended|true|
81+
|Settings||
82+
|Options|`noZeroLineText`, `noSingleLineBlocks`, `singleLineTags`, `noMultilineBlocks`, `minimumLengthForMultiline`, `multilineTags`, `allowMultipleTags`|
83+
84+
<!-- assertions multilineBlocks -->

0 commit comments

Comments
 (0)