File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ var DEFAULTS = require( './defaults.json' );
30
30
// VARIABLES //
31
31
32
32
var RE_LETTERS = / ^ [ a - z A - Z ] / ;
33
+ var RE_SPECIAL_CHARS = / [ ^ a - z A - Z ] / ;
33
34
var OPTS = {
34
35
'includeComments' : true
35
36
} ;
@@ -126,7 +127,11 @@ function main( context ) {
126
127
}
127
128
if ( scope . set . has ( stext ) ) {
128
129
found = true ;
130
+ } else if ( RE_SPECIAL_CHARS . test ( stext ) ) {
131
+ // Do not flag first word if it contains special characters (e.g., `x-value`):
132
+ found = true ;
129
133
} else {
134
+ // Check if the first word is contained in the whitelist (e.g., `ndarray`):
130
135
for ( i = 0 ; i < opts . whitelist . length ; i ++ ) {
131
136
word = opts . whitelist [ i ] ;
132
137
if ( stext === word ) {
@@ -135,7 +140,7 @@ function main( context ) {
135
140
}
136
141
}
137
142
}
138
- // If not in whitelist or current scope, raise an error:
143
+ // If word is not in whitelist, has no special characters, and is not found in current scope, raise an error:
139
144
if ( ! found ) {
140
145
report ( comment ) ;
141
146
}
Original file line number Diff line number Diff line change @@ -464,6 +464,15 @@ test = {
464
464
} ;
465
465
valid . push ( test ) ;
466
466
467
+ test = {
468
+ 'code' : [
469
+ 'function square( x ) {' ,
470
+ ' return x*x; // x-value squared' ,
471
+ '}'
472
+ ] . join ( '\n' )
473
+ } ;
474
+ valid . push ( test ) ;
475
+
467
476
468
477
// EXPORTS //
469
478
You can’t perform that action at this time.
0 commit comments