Skip to content

Commit cddc09d

Browse files
committed
fix empty example error. add lint rule.
1 parent 39b0ae4 commit cddc09d

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/lint.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ function lintComments(comment) {
3434
}
3535
}
3636

37+
function checkEmptyExample(tag) {
38+
if (!tag.description) {
39+
comment.errors.push({
40+
message: 'empty example is found',
41+
commentLineNumber: tag.lineNumber
42+
});
43+
}
44+
}
45+
3746
function checkCanonical(type) {
3847
if (type.type === 'NameExpression') {
3948
nameInvariant(type.name);
@@ -51,6 +60,10 @@ function lintComments(comment) {
5160
if (tag.title === 'param' && tag.type) {
5261
checkCanonical(tag.type);
5362
}
63+
64+
if (tag.title === 'example') {
65+
checkEmptyExample(tag);
66+
}
5467
});
5568
return comment;
5669
}

lib/output/html.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ var walk = require('../walk'),
1414
function highlightString(auto) {
1515
return function (example) {
1616
if (auto) {
17-
return hljs.highlightAuto(example).value;
17+
return hljs.highlightAuto(example || '').value;
1818
}
19-
return hljs.highlight('js', example).value;
19+
return hljs.highlight('js', example || '').value;
2020
};
2121
}
2222

0 commit comments

Comments
 (0)