@@ -347,7 +347,7 @@ module.exports.prototype = {
347
347
348
348
buildAllowedIndex ( ) ;
349
349
350
- function isAllowed ( context , as , name , line ) {
350
+ function isAllowed ( context , name , line ) {
351
351
var allowed = false ;
352
352
allowedIndex . some ( function ( region ) {
353
353
// once the comment we're inspecting occurs after the location of the error,
@@ -356,42 +356,32 @@ module.exports.prototype = {
356
356
return true ;
357
357
}
358
358
359
- var contextRe = new RegExp ( [
360
- '^allow' ,
361
- as === 'name' ? 'Names(|As' : 'Words(|In' ,
362
- context === 'identifier' ? 'Identifiers)' : 'Properties)' ,
363
- '$'
364
- ] . join ( '' ) ) ;
365
-
366
- if ( contextRe . test ( region . rule ) ) {
367
- if ( as === 'name' && / ^ a l l o w N a m e s / . test ( region . rule ) ) {
368
- if ( region . name === name ) {
369
- allowed = region . allowed ;
370
- }
371
- } else if ( as === 'word' && / ^ a l l o w W o r d s / . test ( region . rule ) ) {
372
- if ( name . match ( reWords ) . indexOf ( region . name ) > - 1 ) {
373
- allowed = region . allowed ;
374
- }
359
+ var inverseContextRe = new RegExp (
360
+ ( context === 'identifier' ? 'Properties' : 'Identifiers' ) + '$'
361
+ ) ;
362
+
363
+ if ( inverseContextRe . test ( region . rule ) ) {
364
+ return ;
365
+ }
366
+
367
+ if ( / ^ a l l o w N a m e s / . test ( region . rule ) ) {
368
+ if ( region . name === name ) {
369
+ allowed = region . allowed ;
370
+ }
371
+ } else if ( / ^ a l l o w W o r d s / . test ( region . rule ) ) {
372
+ if ( name . match ( reWords ) . indexOf ( region . name ) > - 1 ) {
373
+ allowed = region . allowed ;
375
374
}
376
375
}
377
376
} ) ;
378
377
379
378
return allowed ;
380
379
}
381
380
382
- function isAllowedName ( context , name , line ) {
383
- return isAllowed ( context , 'name' , name , line ) ;
384
- }
385
-
386
- function isAllowedWord ( context , name , line ) {
387
- return isAllowed ( context , 'word' , name , line ) ;
388
- }
389
-
390
381
function check ( context , wordDictionaries , nameDictionaries , name , start ) {
391
382
if (
392
- isAllowedName ( context , name , start . line ) ||
393
- dictionariesHaveWord ( nameDictionaries , name ) ||
394
- isAllowedWord ( context , name , start . line )
383
+ isAllowed ( context , name , start . line ) ||
384
+ dictionariesHaveWord ( nameDictionaries , name )
395
385
) {
396
386
return ;
397
387
}
0 commit comments