diff --git a/lib/rules/validate-jsdoc/require-hyphen-before-description.js b/lib/rules/validate-jsdoc/require-hyphen-before-description.js index 43131c5..e5009e1 100644 --- a/lib/rules/validate-jsdoc/require-hyphen-before-description.js +++ b/lib/rules/validate-jsdoc/require-hyphen-before-description.js @@ -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); } diff --git a/test/lib/rules/validate-jsdoc/require-hyphen-before-description.js b/test/lib/rules/validate-jsdoc/require-hyphen-before-description.js index 7d905d5..59f3fc6 100644 --- a/test/lib/rules/validate-jsdoc/require-hyphen-before-description.js +++ b/test/lib/rules/validate-jsdoc/require-hyphen-before-description.js @@ -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 */ ]);