|
| 1 | +<a name="user-content-no-lines-before-blocks"></a> |
| 2 | +<a name="no-lines-before-blocks"></a> |
| 3 | +# <code>no-lines-before-blocks</code> |
| 4 | + |
| 5 | +Reports extra lines between functions (and other language structures) and their |
| 6 | +JSDoc blocks. |
| 7 | + |
| 8 | +<a name="user-content-no-lines-before-blocks-fixer"></a> |
| 9 | +<a name="no-lines-before-blocks-fixer"></a> |
| 10 | +## Fixer |
| 11 | + |
| 12 | +Removes extra lines between functions (and other language structures) and their |
| 13 | +JSDoc blocks. Uses the `maxLines` setting to determine whether to remove lines. |
| 14 | + |
| 15 | +<a name="user-content-no-lines-before-blocks-options"></a> |
| 16 | +<a name="no-lines-before-blocks-options"></a> |
| 17 | +## Options |
| 18 | + |
| 19 | +A single options object has the following properties. |
| 20 | + |
| 21 | +<a name="user-content-no-lines-before-blocks-options-enablefixer"></a> |
| 22 | +<a name="no-lines-before-blocks-options-enablefixer"></a> |
| 23 | +### <code>enableFixer</code> |
| 24 | + |
| 25 | +Whether to enable the fixer to remove line breaks |
| 26 | +<a name="user-content-no-lines-before-blocks-options-preferminlines"></a> |
| 27 | +<a name="no-lines-before-blocks-options-preferminlines"></a> |
| 28 | +### <code>preferMinLines</code> |
| 29 | + |
| 30 | +Whether to use the setting `minLines` as the basis for fixing lines going past `maxLines` |
| 31 | + |
| 32 | + |
| 33 | +||| |
| 34 | +|---|---| |
| 35 | +|Context|everywhere| |
| 36 | +|Tags|N/A| |
| 37 | +|Recommended|true| |
| 38 | +|Settings|`maxLines`, `minLines`| |
| 39 | +|Options|`enableFixer`, `preferMinLines`| |
| 40 | + |
| 41 | +<a name="user-content-no-lines-before-blocks-failing-examples"></a> |
| 42 | +<a name="no-lines-before-blocks-failing-examples"></a> |
| 43 | +## Failing examples |
| 44 | + |
| 45 | +The following patterns are considered problems: |
| 46 | + |
| 47 | +````ts |
| 48 | +/** This is a description of some function!*/ |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +function someFunction() {} |
| 56 | +// Message: There should be no extra lines above structures with JSDoc blocks |
| 57 | + |
| 58 | +/** This is a description of some function!*/ |
| 59 | + |
| 60 | +function someFunction() {} |
| 61 | +// "jsdoc/no-lines-before-blocks": ["error"|"warn", {"enableFixer":false}] |
| 62 | +// Message: There should be no extra lines above structures with JSDoc blocks |
| 63 | + |
| 64 | +/** This is a description of some function!*/ |
| 65 | + |
| 66 | + |
| 67 | +function someFunction() {} |
| 68 | +// Settings: {"jsdoc":{"maxLines":2}} |
| 69 | +// Message: There should be no extra lines above structures with JSDoc blocks |
| 70 | + |
| 71 | +/** This is a description of some function!*/ |
| 72 | + |
| 73 | + |
| 74 | +function someFunction() {} |
| 75 | +// Settings: {"jsdoc":{"maxLines":2,"minLines":1}} |
| 76 | +// "jsdoc/no-lines-before-blocks": ["error"|"warn", {"preferMinLines":true}] |
| 77 | +// Message: There should be no extra lines above structures with JSDoc blocks |
| 78 | +```` |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +<a name="user-content-no-lines-before-blocks-passing-examples"></a> |
| 83 | +<a name="no-lines-before-blocks-passing-examples"></a> |
| 84 | +## Passing examples |
| 85 | + |
| 86 | +The following patterns are not considered problems: |
| 87 | + |
| 88 | +````ts |
| 89 | +function someFunction() {} |
| 90 | + |
| 91 | +/** JSDoc */ function someFunction() {} |
| 92 | + |
| 93 | +/** This is a description of some function! */ |
| 94 | +// extra comment |
| 95 | +function someFunction() {} |
| 96 | + |
| 97 | +/** Standalone comment (e.g. a type definition) */ |
| 98 | + |
| 99 | +/** The actual description */ |
| 100 | +function someFunction() {} |
| 101 | + |
| 102 | +/* Regular block comment */ |
| 103 | + |
| 104 | +function someFunction() {} |
| 105 | + |
| 106 | +// Regular line comment |
| 107 | + |
| 108 | +function someFunction() {} |
| 109 | + |
| 110 | +/** This is a description of some function!*/ |
| 111 | + |
| 112 | +function someFunction() {} |
| 113 | +// Settings: {"jsdoc":{"maxLines":2}} |
| 114 | +```` |
| 115 | + |
0 commit comments