@@ -11,9 +11,9 @@ module.exports.options = {
1111 * does not start with an upper case letter.
1212 * It also matches a period not fllowed by an upper case letter.
1313 */
14- var RE_NEW_LINE_START_WITH_UPPER_CASE = / [ * ] * ( ( \n [ * \s ] * \n ) | [ . ] ) [ * \s ] * [ a - z ] / g;
14+ var RE_NEW_LINE_START_WITH_UPPER_CASE = / ( ( \n \s * \n ) | \. ) \s * [ a - z ] / g;
1515
16- var START_DESCRIPTION = / ^ [ * \s ] * [ a - z ] / g;
16+ var START_DESCRIPTION = / ^ \s * [ a - z ] / g;
1717
1818var RE_END_DESCRIPTION = / \n / g;
1919
@@ -24,7 +24,7 @@ var RE_END_DESCRIPTION = /\n/g;
2424 * upper case letter where the previous line does not have a period
2525 * Note that numbers count as word characters.
2626 */
27- var RE_NEW_LINE_UPPERCASE = / \w (? ! [ . ] ) ( \W ) * \n \W * [ A - Z ] / g;
27+ var RE_NEW_LINE_UPPERCASE = / \w (? ! \. ) ( \W ) * \n \W * [ A - Z ] / g;
2828
2929/**
3030 * Checks that a sentence followed by a blank line has a period
@@ -34,7 +34,7 @@ var RE_NEW_LINE_UPPERCASE = /\w(?![.])(\W)*\n\W*[A-Z]/g;
3434 *
3535 * This also matches white-space followed by a period.
3636 */
37- var RE_END_WITH_PERIOD = / ( \s \. | [ ^ \s \. ] ) (? ! \. ) ( \n | $ ) [ * \s ] * ( \n | $ ) / g;
37+ var RE_END_WITH_PERIOD = / ( \s \. | [ ^ \s \. ] ) (? ! \. ) ( \n | $ ) \s * ( \n | $ ) / g;
3838
3939/**
4040 * Requires description to be a complete sentence in a jsdoc comment.
@@ -47,44 +47,47 @@ var RE_END_WITH_PERIOD = /(\s\.|[^\s\.])(?!\.)(\n|$)[*\s]*(\n|$)/g;
4747 */
4848function requireDescriptionCompleteSentence ( node , err ) {
4949 var doc = node . jsdoc ;
50- if ( ! doc || ! doc . tags . length || ! doc . description || ! doc . description . length ) {
50+ if ( ! doc || ! doc . description || ! doc . description . length ) {
5151 return ;
5252 }
5353
5454 var loc = doc . loc . start ;
55- var lines = doc . description . split ( RE_END_DESCRIPTION ) ;
55+ var sanitized = doc . description . replace ( / \{ ( [ ^ } ] + ) \} / , function ( _ , m ) {
56+ return '{' + ( new Array ( m . length + 1 ) ) . join ( '*' ) + '}' ;
57+ } ) ;
58+ var lines = sanitized . split ( RE_END_DESCRIPTION ) ;
5659
5760 var errors = [ ] ;
5861
59- if ( START_DESCRIPTION . test ( doc . description ) ) {
60- var matches = returnAllMatches ( doc . description , START_DESCRIPTION ) ;
62+ if ( START_DESCRIPTION . test ( sanitized ) ) {
63+ var matches = returnAllMatches ( sanitized , START_DESCRIPTION ) ;
6164 matches . map ( function ( match ) {
6265 match . message = 'Description must start with an upper case letter' ;
6366 match . index = match . start ;
6467 } ) ;
6568 errors = errors . concat ( matches ) ;
6669 }
6770
68- if ( RE_NEW_LINE_START_WITH_UPPER_CASE . test ( doc . description ) ) {
69- var matches1 = returnAllMatches ( doc . description , RE_NEW_LINE_START_WITH_UPPER_CASE ) ;
71+ if ( RE_NEW_LINE_START_WITH_UPPER_CASE . test ( sanitized ) ) {
72+ var matches1 = returnAllMatches ( sanitized , RE_NEW_LINE_START_WITH_UPPER_CASE ) ;
7073 matches1 . map ( function ( match ) {
7174 match . message = 'Sentence must start with an upper case letter' ;
7275 match . index = match . end - 1 ;
7376 } ) ;
7477 errors = errors . concat ( matches1 ) ;
7578 }
7679
77- if ( RE_END_WITH_PERIOD . test ( doc . description ) ) {
78- var matches2 = returnAllMatches ( doc . description , RE_END_WITH_PERIOD ) ;
80+ if ( RE_END_WITH_PERIOD . test ( sanitized ) ) {
81+ var matches2 = returnAllMatches ( sanitized , RE_END_WITH_PERIOD ) ;
7982 matches2 . map ( function ( match ) {
8083 match . message = 'Sentence must end with a period' ;
8184 match . index = match . start ;
8285 } ) ;
8386 errors = errors . concat ( matches2 ) ;
8487 }
8588
86- if ( RE_NEW_LINE_UPPERCASE . test ( doc . description ) ) {
87- var matches3 = returnAllMatches ( doc . description , RE_NEW_LINE_UPPERCASE ) ;
89+ if ( RE_NEW_LINE_UPPERCASE . test ( sanitized ) ) {
90+ var matches3 = returnAllMatches ( sanitized , RE_NEW_LINE_UPPERCASE ) ;
8891 matches3 . map ( function ( match ) {
8992 match . message = 'You started a new line with an upper case letter but ' +
9093 'previous line does not end with a period' ;
0 commit comments