Skip to content

Commit

Permalink
fix(tag-lines): allow any in tags[tag].lines option to allow li…
Browse files Browse the repository at this point in the history
…nes per tag when otherwise blocked
  • Loading branch information
brettz9 committed Jul 18, 2021
1 parent 3fccc8a commit 52d7eff
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .README/rules/tag-lines.md
Expand Up @@ -28,7 +28,7 @@ Overrides the default behavior depending on specific tags.
An object whose keys are tag names and whose values are objects with the
following keys:

1. `lines` - Set to `always` or `never` to override.
1. `lines` - Set to `always`, `never`, or `any` to override.
2. `count` - Overrides main `count` (for "always")

|||
Expand Down
17 changes: 16 additions & 1 deletion README.md
Expand Up @@ -19522,7 +19522,7 @@ Overrides the default behavior depending on specific tags.
An object whose keys are tag names and whose values are objects with the
following keys:

1. `lines` - Set to `always` or `never` to override.
1. `lines` - Set to `always`, `never`, or `any` to override.
2. `count` - Overrides main `count` (for "always")

|||
Expand Down Expand Up @@ -19730,6 +19730,13 @@ The following patterns are not considered problems:
*/
// "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"param":{"lines":"any"}}}]

/**
* Some description
* @param {string} a
* @param {number} b
*/
// "jsdoc/tag-lines": ["error"|"warn", "always",{"tags":{"param":{"lines":"any"}}}]

/**
* Some description
* @param {string} a
Expand All @@ -19744,6 +19751,14 @@ The following patterns are not considered problems:
*/
// "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"param":{"lines":"any"}}}]

/**
* Some description
* @param {number} a
*
* @param {number} b
*/
// "jsdoc/tag-lines": ["error"|"warn", "never",{"tags":{"param":{"lines":"any"}}}]

/**
* Some description
* @param {number} a
Expand Down
4 changes: 2 additions & 2 deletions src/rules/tagLines.js
Expand Up @@ -23,7 +23,7 @@ export default iterateJsdoc(({
if (description) {
reportIndex = null;
}
if (lastTag && tags[lastTag.slice(1)]?.lines === 'always') {
if (lastTag && ['any', 'always'].includes(tags[lastTag.slice(1)]?.lines)) {
return;
}

Expand Down Expand Up @@ -138,7 +138,7 @@ export default iterateJsdoc(({
type: 'integer',
},
lines: {
enum: ['always', 'never'],
enum: ['always', 'never', 'any'],
type: 'string',
},
},
Expand Down
33 changes: 33 additions & 0 deletions test/rules/assertions/tagLines.js
Expand Up @@ -499,6 +499,22 @@ export default {
},
}],
},
{
code: `
/**
* Some description
* @param {string} a
* @param {number} b
*/
`,
options: ['always', {
tags: {
param: {
lines: 'any',
},
},
}],
},
{
code: `
/**
Expand Down Expand Up @@ -531,6 +547,23 @@ export default {
},
}],
},
{
code: `
/**
* Some description
* @param {number} a
*
* @param {number} b
*/
`,
options: ['never', {
tags: {
param: {
lines: 'any',
},
},
}],
},
{
code: `
/**
Expand Down

0 comments on commit 52d7eff

Please sign in to comment.