Skip to content

Commit 9bb4bfd

Browse files
committed
fix(tag-lines): startLines is intended to apply after tags only; fixes #1022
1 parent 9b8c653 commit 9bb4bfd

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

.README/rules/tag-lines.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ added after tags should not be added after the final tag.
3434
##### `startLines` (defaults to `0`)
3535

3636
If not set to `null`, will enforce end lines to the given count before the
37-
first tag only.
37+
first tag only, unless there is only whitespace content, in which case,
38+
a line count will not be enforced.
3839

3940
##### `endLines` (defaults to `0`)
4041

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -23026,7 +23026,8 @@ added after tags should not be added after the final tag.
2302623026
##### <code>startLines</code> (defaults to <code>0</code>)
2302723027

2302823028
If not set to `null`, will enforce end lines to the given count before the
23029-
first tag only.
23029+
first tag only, unless there is only whitespace content, in which case,
23030+
a line count will not be enforced.
2303023031

2303123032
<a name="user-content-eslint-plugin-jsdoc-rules-tag-lines-options-41-endlines-defaults-to-0"></a>
2303223033
<a name="eslint-plugin-jsdoc-rules-tag-lines-options-41-endlines-defaults-to-0"></a>
@@ -23465,6 +23466,21 @@ The following patterns are not considered problems:
2346523466
* @param {string} a
2346623467
*/
2346723468
// "jsdoc/tag-lines": ["error"|"warn", "never",{"startLines":null}]
23469+
23470+
/**
23471+
* @param {string} input
23472+
*/
23473+
function processSass (input) {
23474+
}
23475+
// "jsdoc/tag-lines": ["error"|"warn", "never",{"startLines":1}]
23476+
23477+
/**
23478+
*
23479+
* @param {string} input
23480+
*/
23481+
function processSass (input) {
23482+
}
23483+
// "jsdoc/tag-lines": ["error"|"warn", "never",{"startLines":1}]
2346823484
````
2346923485

2347023486

src/rules/tagLines.js

+4
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ export default iterateJsdoc(({
203203
description,
204204
lastDescriptionLine,
205205
} = utils.getDescription();
206+
if (!(/\S/u).test(description)) {
207+
return;
208+
}
209+
206210
const trailingLines = description.match(/\n+$/u)?.[0]?.length;
207211
const trailingDiff = (trailingLines ?? 0) - startLines;
208212
if (trailingDiff > 0) {

test/rules/assertions/tagLines.js

+31
Original file line numberDiff line numberDiff line change
@@ -1093,5 +1093,36 @@ export default {
10931093
},
10941094
],
10951095
},
1096+
{
1097+
code: `
1098+
/**
1099+
* @param {string} input
1100+
*/
1101+
function processSass (input) {
1102+
}
1103+
`,
1104+
options: [
1105+
'never',
1106+
{
1107+
startLines: 1,
1108+
},
1109+
],
1110+
},
1111+
{
1112+
code: `
1113+
/**
1114+
*
1115+
* @param {string} input
1116+
*/
1117+
function processSass (input) {
1118+
}
1119+
`,
1120+
options: [
1121+
'never',
1122+
{
1123+
startLines: 1,
1124+
},
1125+
],
1126+
},
10961127
],
10971128
};

0 commit comments

Comments
 (0)