File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import warnRemovedSettings from '../warnRemovedSettings';
6
6
const zeroBasedLineIndexAdjust = - 1 ;
7
7
const likelyNestedJSDocIndentSpace = 1 ;
8
8
const preTagSpaceLength = 1 ;
9
- const hasCaptionRegex = / ^ \s * < c a p t i o n > .* ?< \/ c a p t i o n > / ;
9
+ const hasCaptionRegex = / ^ \s * < c a p t i o n > ( .* ?) < \/ c a p t i o n > / ;
10
10
11
11
const escapeStringRegexp = ( str ) => {
12
12
return str . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ;
@@ -81,7 +81,7 @@ export default iterateJsdoc(({
81
81
let source = tag . source . slice ( initialTagLength ) ;
82
82
const match = source . match ( hasCaptionRegex ) ;
83
83
84
- if ( captionRequired && ! match ) {
84
+ if ( captionRequired && ( ! match || ! match [ 1 ] . trim ( ) ) ) {
85
85
report ( 'Caption is expected for examples.' , null , tag ) ;
86
86
}
87
87
Original file line number Diff line number Diff line change @@ -443,6 +443,24 @@ export default {
443
443
reportUnusedDisableDirectives : true
444
444
}
445
445
}
446
+ } ,
447
+ {
448
+ code : `
449
+ /**
450
+ * @typedef {string} Foo
451
+ * @example <caption></caption>
452
+ * 'foo'
453
+ */
454
+ ` ,
455
+ errors : [
456
+ {
457
+ message : 'Caption is expected for examples.'
458
+ }
459
+ ] ,
460
+ options : [ {
461
+ captionRequired : true ,
462
+ eslintrcForExamples : false
463
+ } ]
446
464
}
447
465
] ,
448
466
valid : [
You can’t perform that action at this time.
0 commit comments