@@ -11,9 +11,9 @@ module.exports.options = {
11
11
* does not start with an upper case letter.
12
12
* It also matches a period not fllowed by an upper case letter.
13
13
*/
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;
15
15
16
- var START_DESCRIPTION = / ^ [ * \s ] * [ a - z ] / g;
16
+ var START_DESCRIPTION = / ^ \s * [ a - z ] / g;
17
17
18
18
var RE_END_DESCRIPTION = / \n / g;
19
19
@@ -24,7 +24,7 @@ var RE_END_DESCRIPTION = /\n/g;
24
24
* upper case letter where the previous line does not have a period
25
25
* Note that numbers count as word characters.
26
26
*/
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;
28
28
29
29
/**
30
30
* 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;
34
34
*
35
35
* This also matches white-space followed by a period.
36
36
*/
37
- var RE_END_WITH_PERIOD = / ( \s \. | [ ^ \s \. ] ) (? ! \. ) ( \n | $ ) [ * \s ] * ( \n | $ ) / g;
37
+ var RE_END_WITH_PERIOD = / ( \s \. | [ ^ \s \. ] ) (? ! \. ) ( \n | $ ) \s * ( \n | $ ) / g;
38
38
39
39
/**
40
40
* 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;
47
47
*/
48
48
function requireDescriptionCompleteSentence ( node , err ) {
49
49
var doc = node . jsdoc ;
50
- if ( ! doc || ! doc . tags . length || ! doc . description || ! doc . description . length ) {
50
+ if ( ! doc || ! doc . description || ! doc . description . length ) {
51
51
return ;
52
52
}
53
53
54
54
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 ) ;
56
59
57
60
var errors = [ ] ;
58
61
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 ) ;
61
64
matches . map ( function ( match ) {
62
65
match . message = 'Description must start with an upper case letter' ;
63
66
match . index = match . start ;
64
67
} ) ;
65
68
errors = errors . concat ( matches ) ;
66
69
}
67
70
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 ) ;
70
73
matches1 . map ( function ( match ) {
71
74
match . message = 'Sentence must start with an upper case letter' ;
72
75
match . index = match . end - 1 ;
73
76
} ) ;
74
77
errors = errors . concat ( matches1 ) ;
75
78
}
76
79
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 ) ;
79
82
matches2 . map ( function ( match ) {
80
83
match . message = 'Sentence must end with a period' ;
81
84
match . index = match . start ;
82
85
} ) ;
83
86
errors = errors . concat ( matches2 ) ;
84
87
}
85
88
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 ) ;
88
91
matches3 . map ( function ( match ) {
89
92
match . message = 'You started a new line with an upper case letter but ' +
90
93
'previous line does not end with a period' ;
0 commit comments