Skip to content

Commit 37466a8

Browse files
sbuschbrettz9
authored andcommitted
fix(check-values): allow @version and @since to have versions surrounded by whitespace
`semver.valid()` requires a trimmed string. With leading or trailing whitespace, `semver.valid()` returns `false`.
1 parent 422a48e commit 37466a8

File tree

3 files changed

+38
-4
lines changed

3 files changed

+38
-4
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3890,13 +3890,27 @@ function quux (foo) {
38903890
38913891
}
38923892
3893+
/**
3894+
* @version 3.4.1
3895+
*/
3896+
function quux (foo) {
3897+
3898+
}
3899+
38933900
/**
38943901
* @since 3.4.1
38953902
*/
38963903
function quux (foo) {
38973904
38983905
}
38993906
3907+
/**
3908+
* @since 3.4.1
3909+
*/
3910+
function quux (foo) {
3911+
3912+
}
3913+
39003914
/**
39013915
* @license MIT
39023916
*/

src/rules/checkValues.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export default iterateJsdoc(({
1515
} = options;
1616

1717
utils.forEachPreferredTag('version', (jsdocParameter, targetTagName) => {
18-
const version = jsdocParameter.description;
19-
if (!version.trim()) {
18+
const version = jsdocParameter.description.trim();
19+
if (!version) {
2020
report(
2121
`Missing JSDoc @${targetTagName}.`,
2222
null,
@@ -31,8 +31,8 @@ export default iterateJsdoc(({
3131
}
3232
});
3333
utils.forEachPreferredTag('since', (jsdocParameter, targetTagName) => {
34-
const version = jsdocParameter.description;
35-
if (!version.trim()) {
34+
const version = jsdocParameter.description.trim();
35+
if (!version) {
3636
report(
3737
`Missing JSDoc @${targetTagName}.`,
3838
null,

test/rules/assertions/checkValues.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,16 @@ export default {
218218
}
219219
`,
220220
},
221+
{
222+
code: `
223+
/**
224+
* @version 3.4.1
225+
*/
226+
function quux (foo) {
227+
228+
}
229+
`,
230+
},
221231
{
222232
code: `
223233
/**
@@ -228,6 +238,16 @@ export default {
228238
}
229239
`,
230240
},
241+
{
242+
code: `
243+
/**
244+
* @since 3.4.1
245+
*/
246+
function quux (foo) {
247+
248+
}
249+
`,
250+
},
231251
{
232252
code: `
233253
/**

0 commit comments

Comments
 (0)