Skip to content

fix(tag-lines): startLines is intended to apply after tags only #1023

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .README/rules/tag-lines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23026,7 +23026,8 @@ added after tags should not be added after the final tag.
##### <code>startLines</code> (defaults to <code>0</code>)

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.

<a name="user-content-eslint-plugin-jsdoc-rules-tag-lines-options-41-endlines-defaults-to-0"></a>
<a name="eslint-plugin-jsdoc-rules-tag-lines-options-41-endlines-defaults-to-0"></a>
Expand Down Expand Up @@ -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}]
````


Expand Down
4 changes: 4 additions & 0 deletions src/rules/tagLines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
31 changes: 31 additions & 0 deletions test/rules/assertions/tagLines.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
],
},
],
};