@@ -4,25 +4,19 @@ module.exports = function(context) {
44 var utils = require ( './utils/utils' ) ;
55 var angularObjectList = [ 'controller' , 'filter' , 'factory' , 'service' ] ;
66 var configType = context . options [ 0 ] ;
7- var message ;
8-
9- function isArray ( item ) {
10- return Object . prototype . toString . call ( item ) === '[object Array]' ;
11- }
7+ var messageByConfigType = {
8+ anonymous : 'Use anonymous functions instead of named function' ,
9+ named : 'Use named functions instead of anonymous function'
10+ } ;
11+ var message = messageByConfigType [ configType ] ;
1212
13- if ( isArray ( context . options [ 1 ] ) ) {
13+ if ( context . options [ 1 ] ) {
1414 angularObjectList = context . options [ 1 ] ;
1515 }
1616
17- if ( configType === 'anonymous' ) {
18- message = 'Use anonymous functions instead of named function' ;
19- } else if ( configType === 'named' ) {
20- message = 'Use named functions instead of anonymous function' ;
21- }
22-
2317 function checkType ( arg ) {
24- return ( configType === 'named' && utils . isIdentifierType ( arg ) ) ||
25- ( configType === 'anonymous' && utils . isFunctionType ( arg ) ) ;
18+ return ( configType === 'named' && ( utils . isIdentifierType ( arg ) || utils . isNamedInlineFunction ( arg ) ) ) ||
19+ ( configType === 'anonymous' && utils . isFunctionType ( arg ) && ! utils . isNamedInlineFunction ( arg ) ) ;
2620 }
2721
2822 return {
@@ -51,7 +45,13 @@ module.exports = function(context) {
5145} ;
5246
5347module . exports . schema = [ {
54- type : 'string'
48+ enum : [
49+ 'named' ,
50+ 'anonymous'
51+ ]
5552} , {
56- type : 'array'
53+ type : 'array' ,
54+ items : {
55+ type : 'string'
56+ }
5757} ] ;
0 commit comments