diff --git a/.README/rules/tag-lines.md b/.README/rules/tag-lines.md index 8e3b30b9c..ddabee506 100644 --- a/.README/rules/tag-lines.md +++ b/.README/rules/tag-lines.md @@ -34,7 +34,8 @@ added after tags should not be added after the final tag. ##### `startLines` (defaults to `0`) If not set to `null`, will enforce end lines to the given count before the -first tag only. +first tag only, unless there is only whitespace content, in which case, +a line count will not be enforced. ##### `endLines` (defaults to `0`) diff --git a/README.md b/README.md index f2960da3f..c055ef60d 100644 --- a/README.md +++ b/README.md @@ -23026,7 +23026,8 @@ added after tags should not be added after the final tag. ##### startLines (defaults to 0) If not set to `null`, will enforce end lines to the given count before the -first tag only. +first tag only, unless there is only whitespace content, in which case, +a line count will not be enforced. @@ -23465,6 +23466,21 @@ The following patterns are not considered problems: * @param {string} a */ // "jsdoc/tag-lines": ["error"|"warn", "never",{"startLines":null}] + +/** + * @param {string} input + */ +function processSass (input) { +} +// "jsdoc/tag-lines": ["error"|"warn", "never",{"startLines":1}] + +/** + * + * @param {string} input + */ +function processSass (input) { +} +// "jsdoc/tag-lines": ["error"|"warn", "never",{"startLines":1}] ```` diff --git a/src/rules/tagLines.js b/src/rules/tagLines.js index c651c1e16..7afc6e9b3 100644 --- a/src/rules/tagLines.js +++ b/src/rules/tagLines.js @@ -203,6 +203,10 @@ export default iterateJsdoc(({ description, lastDescriptionLine, } = utils.getDescription(); + if (!(/\S/u).test(description)) { + return; + } + const trailingLines = description.match(/\n+$/u)?.[0]?.length; const trailingDiff = (trailingLines ?? 0) - startLines; if (trailingDiff > 0) { diff --git a/test/rules/assertions/tagLines.js b/test/rules/assertions/tagLines.js index 839045380..1610f383f 100644 --- a/test/rules/assertions/tagLines.js +++ b/test/rules/assertions/tagLines.js @@ -1093,5 +1093,36 @@ export default { }, ], }, + { + code: ` + /** + * @param {string} input + */ + function processSass (input) { + } + `, + options: [ + 'never', + { + startLines: 1, + }, + ], + }, + { + code: ` + /** + * + * @param {string} input + */ + function processSass (input) { + } + `, + options: [ + 'never', + { + startLines: 1, + }, + ], + }, ], };