Skip to content

Commit

Permalink
requireHyphenBeforeDescription: improve multiline support checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexej Yaroshevich committed Aug 2, 2015
1 parent d670802 commit c74cc59
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/rules/validate-jsdoc/require-hyphen-before-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ function requireHyphenBeforeDescription(node, tag, err) {
return;
}

// skip reporting if there is new line in description
// todo: check this with newline of name and description when it'll be possible
if (tag.value.indexOf('\n') !== -1 && tag.description.indexOf('\n') === -1) {
return;
}

if (tag.description.substring(0, 2) !== '- ') {
err('Missing hyphen before description', tag.loc);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,37 @@ describe('lib/rules/validate-jsdoc/require-hyphen-before-description', function
function yey(yay) {
}
}

}, {
it: 'should not report if description started with newline',
code: function () {
/**
* @param {number} yay
* Description without hyphen.
*/
function yey(yay) {
}
}
}, {
it: 'should report if description has newline inside',
errors: 1,
code: function () {
/**
* @param {number} yay Started on the original line
* without hyphen should be reported.
*/
function yey(yay) {
}
}
}, {
it: 'should not report if description has newline inside (with hyphen)',
code: function () {
/**
* @param {number} yay - Started on the original line
* without hyphen should be reported.
*/
function yey(yay) {
}
}
}
/* jshint ignore:end */
]);
Expand Down

0 comments on commit c74cc59

Please sign in to comment.