Skip to content

Commit ee83271

Browse files
author
Alexej Yaroshevich
committed
checkParamName: fixup throw on declared but unexistent params
Fixes #39 Closes #40
1 parent 0230100 commit ee83271

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/rules/validate-jsdoc/check-param-names.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ function validateCheckParamNames(node, err) {
2121
* @param {Number} i index
2222
*/
2323
function(tag, i) {
24-
var param = node.params[i];
25-
2624
// checking validity
2725
if (!tag.name) {
2826
return err('missing param name', tag.loc);
2927
}
3028

29+
var param = node.params[i];
30+
if (!param) {
31+
// skip if no param
32+
return;
33+
}
34+
3135
// checking name
3236
if (tag.name.value !== param.name) {
3337
return err('expected ' + param.name + ' but got ' + tag.name.value,

test/lib/rules/validate-jsdoc/check-param-names.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ describe('rules/validate-jsdoc', function () {
1313
code: function() {
1414
function yay(yey) {
1515
}
16+
17+
/**
18+
* @param {number} yay
19+
* @param {string} bar this shouldn't throw
20+
*/
21+
function yey(yay) {
22+
}
1623
}
1724

1825
}, {

0 commit comments

Comments
 (0)