Skip to content

Commit

Permalink
fix(check-values): allow @version and @since to have versions s…
Browse files Browse the repository at this point in the history
…urrounded by whitespace

`semver.valid()` requires a trimmed string. With leading or trailing whitespace, `semver.valid()`
returns `false`.
  • Loading branch information
sbusch authored and brettz9 committed Jan 15, 2020
1 parent 422a48e commit 37466a8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -3890,13 +3890,27 @@ function quux (foo) {
}
/**
* @version 3.4.1
*/
function quux (foo) {
}
/**
* @since 3.4.1
*/
function quux (foo) {
}
/**
* @since 3.4.1
*/
function quux (foo) {
}
/**
* @license MIT
*/
Expand Down
8 changes: 4 additions & 4 deletions src/rules/checkValues.js
Expand Up @@ -15,8 +15,8 @@ export default iterateJsdoc(({
} = options;

utils.forEachPreferredTag('version', (jsdocParameter, targetTagName) => {
const version = jsdocParameter.description;
if (!version.trim()) {
const version = jsdocParameter.description.trim();
if (!version) {
report(
`Missing JSDoc @${targetTagName}.`,
null,
Expand All @@ -31,8 +31,8 @@ export default iterateJsdoc(({
}
});
utils.forEachPreferredTag('since', (jsdocParameter, targetTagName) => {
const version = jsdocParameter.description;
if (!version.trim()) {
const version = jsdocParameter.description.trim();
if (!version) {
report(
`Missing JSDoc @${targetTagName}.`,
null,
Expand Down
20 changes: 20 additions & 0 deletions test/rules/assertions/checkValues.js
Expand Up @@ -218,6 +218,16 @@ export default {
}
`,
},
{
code: `
/**
* @version 3.4.1
*/
function quux (foo) {
}
`,
},
{
code: `
/**
Expand All @@ -228,6 +238,16 @@ export default {
}
`,
},
{
code: `
/**
* @since 3.4.1
*/
function quux (foo) {
}
`,
},
{
code: `
/**
Expand Down

0 comments on commit 37466a8

Please sign in to comment.