Skip to content

Commit ced89ec

Browse files
committed
Merge pull request #40 from zxqfox/hotfix/param-name-throw
fix param name throws
2 parents c84f5f8 + ee83271 commit ced89ec

File tree

9 files changed

+62
-2
lines changed

9 files changed

+62
-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
}, {

test/lib/rules/validate-jsdoc/check-redundant-access.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ describe('rules/validate-jsdoc', function () {
99
checker.cases([
1010
/* jshint ignore:start */
1111
{
12+
it: 'should not throw',
13+
code: function() {
14+
function yay(yey) {
15+
}
16+
}
17+
18+
}, {
1219
it: 'should report confusing multiaccess',
1320
errors: 1,
1421
code: function () {

test/lib/rules/validate-jsdoc/check-redundant-returns.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ describe('rules/validate-jsdoc', function () {
99
checker.cases([
1010
/* jshint ignore:start */
1111
{
12+
it: 'should not throw',
13+
code: function() {
14+
function yay(yey) {
15+
}
16+
}
17+
18+
}, {
1219
it: 'should report redundant @returns for function',
1320
errors: 3,
1421
code: function () {

test/lib/rules/validate-jsdoc/check-return-types.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ describe('rules/validate-jsdoc', function () {
99
checker.cases([
1010
/* jshint ignore:start */
1111
{
12+
it: 'should not throw',
13+
code: function() {
14+
function yay(yey) {
15+
}
16+
}
17+
18+
}, {
1219
it: 'should throw invalid type',
1320
errors: 1,
1421
code: function () {

test/lib/rules/validate-jsdoc/check-types.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ describe('rules/validate-jsdoc', function() {
99
checker.cases([
1010
/* jshint ignore:start */
1111
{
12+
it: 'should not throw',
13+
code: function() {
14+
function yay(yey) {
15+
}
16+
}
17+
18+
}, {
1219
it: 'should report invalid typedef',
1320
errors: 1,
1421
code: function() {

test/lib/rules/validate-jsdoc/leading-underscore-access.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ describe('rules/validate-jsdoc', function () {
88
checker.cases([
99
/* jshint ignore:start */
1010
{
11+
it: 'should not throw',
12+
code: function() {
13+
function yay(yey) {
14+
}
15+
}
16+
17+
}, {
1118
it: 'should report enforcing @private on leading underscores',
1219
rules: {leadingUnderscoreAccess: 'private'},
1320
errors: 1,

test/lib/rules/validate-jsdoc/require-param-types.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ describe('rules/validate-jsdoc', function () {
99
checker.cases([
1010
/* jshint ignore:start */
1111
{
12+
it: 'should not throw',
13+
code: function() {
14+
function yay(yey) {
15+
}
16+
}
17+
18+
}, {
1219
it: 'should report missing jsdoc-param type for function',
1320
errors: 1,
1421
code: function () {

test/lib/rules/validate-jsdoc/require-return-types.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ describe('rules/validate-jsdoc', function () {
99
checker.cases([
1010
/* jshint ignore:start */
1111
{
12+
it: 'should not throw',
13+
code: function() {
14+
function yay(yey) {
15+
}
16+
}
17+
18+
}, {
1219
it: 'should report invalid @returns',
1320
errors: 1,
1421
code: function() {

0 commit comments

Comments
 (0)