Skip to content

Commit c74cc59

Browse files
author
Alexej Yaroshevich
committed
requireHyphenBeforeDescription: improve multiline support checks
Fixes jscs-dev/node-jscs#1579
1 parent d670802 commit c74cc59

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

lib/rules/validate-jsdoc/require-hyphen-before-description.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ function requireHyphenBeforeDescription(node, tag, err) {
1717
return;
1818
}
1919

20+
// skip reporting if there is new line in description
21+
// todo: check this with newline of name and description when it'll be possible
22+
if (tag.value.indexOf('\n') !== -1 && tag.description.indexOf('\n') === -1) {
23+
return;
24+
}
25+
2026
if (tag.description.substring(0, 2) !== '- ') {
2127
err('Missing hyphen before description', tag.loc);
2228
}

test/lib/rules/validate-jsdoc/require-hyphen-before-description.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,37 @@ describe('lib/rules/validate-jsdoc/require-hyphen-before-description', function
5555
function yey(yay) {
5656
}
5757
}
58-
58+
}, {
59+
it: 'should not report if description started with newline',
60+
code: function () {
61+
/**
62+
* @param {number} yay
63+
* Description without hyphen.
64+
*/
65+
function yey(yay) {
66+
}
67+
}
68+
}, {
69+
it: 'should report if description has newline inside',
70+
errors: 1,
71+
code: function () {
72+
/**
73+
* @param {number} yay Started on the original line
74+
* without hyphen should be reported.
75+
*/
76+
function yey(yay) {
77+
}
78+
}
79+
}, {
80+
it: 'should not report if description has newline inside (with hyphen)',
81+
code: function () {
82+
/**
83+
* @param {number} yay - Started on the original line
84+
* without hyphen should be reported.
85+
*/
86+
function yey(yay) {
87+
}
88+
}
5989
}
6090
/* jshint ignore:end */
6191
]);

0 commit comments

Comments
 (0)