|
3 | 3 | # <code>lines-before-block</code> |
4 | 4 |
|
5 | 5 | This rule enforces minimum number of newlines before JSDoc comment blocks |
6 | | -(except at the beginning of a file). |
| 6 | +(except at the beginning of a block or file). |
7 | 7 |
|
8 | 8 | <a name="user-content-lines-before-block-options"></a> |
9 | 9 | <a name="lines-before-block-options"></a> |
10 | 10 | ## Options |
11 | 11 |
|
| 12 | +<a name="user-content-lines-before-block-options-checkblockstarts"></a> |
| 13 | +<a name="lines-before-block-options-checkblockstarts"></a> |
| 14 | +### <code>checkBlockStarts</code> |
| 15 | + |
| 16 | +Whether to additionally check the start of blocks, such as classes or functions. |
| 17 | +Defaults to `false`. |
| 18 | + |
12 | 19 | <a name="user-content-lines-before-block-options-lines"></a> |
13 | 20 | <a name="lines-before-block-options-lines"></a> |
14 | 21 | ### <code>lines</code> |
@@ -36,7 +43,7 @@ lines before the block will not be added). |
36 | 43 | |Tags|N/A| |
37 | 44 | |Recommended|false| |
38 | 45 | |Settings|| |
39 | | -|Options|`excludedTags`, `ignoreSameLine`, `lines`| |
| 46 | +|Options|`checkBlockStarts`, `excludedTags`, `ignoreSameLine`, `lines`| |
40 | 47 |
|
41 | 48 | <a name="user-content-lines-before-block-failing-examples"></a> |
42 | 49 | <a name="lines-before-block-failing-examples"></a> |
@@ -87,6 +94,42 @@ someCode; |
87 | 94 | * |
88 | 95 | */ |
89 | 96 | // Message: Required 1 line(s) before JSDoc block |
| 97 | + |
| 98 | +{ |
| 99 | + /** |
| 100 | + * Description. |
| 101 | + */ |
| 102 | + let value; |
| 103 | +} |
| 104 | +// "jsdoc/lines-before-block": ["error"|"warn", {"checkBlockStarts":true}] |
| 105 | +// Message: Required 1 line(s) before JSDoc block |
| 106 | + |
| 107 | +class MyClass { |
| 108 | + /** |
| 109 | + * Description. |
| 110 | + */ |
| 111 | + method() {} |
| 112 | +} |
| 113 | +// "jsdoc/lines-before-block": ["error"|"warn", {"checkBlockStarts":true}] |
| 114 | +// Message: Required 1 line(s) before JSDoc block |
| 115 | + |
| 116 | +function myFunction() { |
| 117 | + /** |
| 118 | + * Description. |
| 119 | + */ |
| 120 | + let value; |
| 121 | +} |
| 122 | +// "jsdoc/lines-before-block": ["error"|"warn", {"checkBlockStarts":true}] |
| 123 | +// Message: Required 1 line(s) before JSDoc block |
| 124 | + |
| 125 | +const values = [ |
| 126 | + /** |
| 127 | + * Description. |
| 128 | + */ |
| 129 | + value, |
| 130 | +]; |
| 131 | +// "jsdoc/lines-before-block": ["error"|"warn", {"checkBlockStarts":true}] |
| 132 | +// Message: Required 1 line(s) before JSDoc block |
90 | 133 | ```` |
91 | 134 |
|
92 | 135 |
|
@@ -146,5 +189,26 @@ const a = /** @lends SomeClass */ { |
146 | 189 | someProp: (someVal) |
147 | 190 | }; |
148 | 191 | // "jsdoc/lines-before-block": ["error"|"warn", {"excludedTags":["lends"],"ignoreSameLine":false}] |
| 192 | + |
| 193 | +{ |
| 194 | + /** |
| 195 | + * Description. |
| 196 | + */ |
| 197 | + let value; |
| 198 | +} |
| 199 | + |
| 200 | +class MyClass { |
| 201 | + /** |
| 202 | + * Description. |
| 203 | + */ |
| 204 | + method() {} |
| 205 | +} |
| 206 | + |
| 207 | +function myFunction() { |
| 208 | + /** |
| 209 | + * Description. |
| 210 | + */ |
| 211 | + let value; |
| 212 | +} |
149 | 213 | ```` |
150 | 214 |
|
0 commit comments