11/**
22 * require a consistent DI syntax
33 *
4- * All your DI should use the same syntax : the Array, function, or $inject syntaxes ("di" : [2, " array, function, or $inject" ])
4+ * All your DI should use the same syntax : the Array, function, or $inject syntaxes ('di' : [2, ' array, function, or $inject' ])
55 *
66 * @version 0.1.0
77 * @category conventions
88 * @sinceAngularVersion 1.x
99 */
10- " use strict" ;
10+ ' use strict' ;
1111
12- var utils = require ( " ./utils/utils" ) ;
12+ var utils = require ( ' ./utils/utils' ) ;
1313
14- var angularRule = require ( " ./utils/angular-rule" ) ;
14+ var angularRule = require ( ' ./utils/angular-rule' ) ;
1515
1616module . exports = {
1717 meta : {
1818 docs : {
1919 url :
20- " https://github.com/Gillespie59/eslint-plugin-angular/blob/master/docs/rules/di.md" ,
20+ ' https://github.com/Gillespie59/eslint-plugin-angular/blob/master/docs/rules/di.md' ,
2121 } ,
2222 schema : [
2323 {
24- enum : [ " function" , " array" , " $inject" ] ,
24+ enum : [ ' function' , ' array' , ' $inject' ] ,
2525 } ,
2626 {
27- type : " object" ,
27+ type : ' object' ,
2828 properties : {
2929 matchNames : {
30- type : " boolean" ,
30+ type : ' boolean' ,
3131 } ,
3232 stripUnderscores : {
33- type : " boolean" ,
33+ type : ' boolean' ,
3434 } ,
3535 } ,
3636 } ,
3737 ] ,
3838 } ,
3939 create : angularRule ( function ( context ) {
40- var syntax = context . options [ 0 ] || " function" ;
40+ var syntax = context . options [ 0 ] || ' function' ;
4141
4242 var extra = context . options [ 1 ] || { } ;
4343 var matchNames = extra . matchNames !== false ;
@@ -46,7 +46,7 @@ module.exports = {
4646 function report ( node ) {
4747 context . report (
4848 node ,
49- " You should use the {{syntax}} syntax for DI" ,
49+ ' You should use the {{syntax}} syntax for DI' ,
5050 {
5151 syntax : syntax ,
5252 }
@@ -57,13 +57,13 @@ module.exports = {
5757
5858 function maybeNoteInjection ( node ) {
5959 if (
60- syntax === " $inject" &&
60+ syntax === ' $inject' &&
6161 node . left &&
6262 node . left . property &&
6363 ( ( utils . isLiteralType ( node . left . property ) &&
64- node . left . property . value === " $inject" ) ||
64+ node . left . property . value === ' $inject' ) ||
6565 ( utils . isIdentifierType ( node . left . property ) &&
66- node . left . property . name === " $inject" ) )
66+ node . left . property . name === ' $inject' ) )
6767 ) {
6868 $injectProperties [ node . left . object . name ] = node . right ;
6969 }
@@ -80,12 +80,12 @@ module.exports = {
8080 return ;
8181 }
8282
83- if ( syntax === " array" ) {
83+ if ( syntax === ' array' ) {
8484 if ( utils . isArrayType ( fn . parent ) ) {
8585 if ( fn . parent . elements . length - 1 !== fn . params . length ) {
8686 context . report (
8787 fn ,
88- " The signature of the method is incorrect" ,
88+ ' The signature of the method is incorrect' ,
8989 { }
9090 ) ;
9191 return ;
@@ -104,7 +104,7 @@ module.exports = {
104104 if ( invalidArray . length > 0 ) {
105105 context . report (
106106 fn ,
107- " You have an error in your DI configuration. Each items of the array should match exactly one function parameter" ,
107+ ' You have an error in your DI configuration. Each items of the array should match exactly one function parameter' ,
108108 { }
109109 ) ;
110110 return ;
@@ -118,21 +118,21 @@ module.exports = {
118118 }
119119 }
120120
121- if ( syntax === " function" ) {
121+ if ( syntax === ' function' ) {
122122 if ( utils . isArrayType ( fn . parent ) ) {
123123 report ( fn ) ;
124124 }
125125 }
126126
127- if ( syntax === " $inject" ) {
127+ if ( syntax === ' $inject' ) {
128128 if ( fn && fn . id && utils . isIdentifierType ( fn . id ) ) {
129129 var $injectArray = $injectProperties [ fn . id . name ] ;
130130
131131 if ( $injectArray && utils . isArrayType ( $injectArray ) ) {
132132 if ( $injectArray . elements . length !== fn . params . length ) {
133133 context . report (
134134 fn ,
135- " The signature of the method is incorrect" ,
135+ ' The signature of the method is incorrect' ,
136136 { }
137137 ) ;
138138 return ;
@@ -154,7 +154,7 @@ module.exports = {
154154 if ( invalidInjectArray . length > 0 ) {
155155 context . report (
156156 fn ,
157- " You have an error in your DI configuration. Each items of the array should match exactly one function parameter" ,
157+ ' You have an error in your DI configuration. Each items of the array should match exactly one function parameter' ,
158158 { }
159159 ) ;
160160 return ;
@@ -170,20 +170,20 @@ module.exports = {
170170 }
171171
172172 return {
173- " angular?animation" : checkDi ,
174- " angular?config" : checkDi ,
175- " angular?controller" : checkDi ,
176- " angular?directive" : checkDi ,
177- " angular?factory" : checkDi ,
178- " angular?filter" : checkDi ,
179- " angular?inject" : checkDi ,
180- " angular?run" : checkDi ,
181- " angular?service" : checkDi ,
182- " angular?provider" : function ( callee , providerFn , $get ) {
173+ ' angular?animation' : checkDi ,
174+ ' angular?config' : checkDi ,
175+ ' angular?controller' : checkDi ,
176+ ' angular?directive' : checkDi ,
177+ ' angular?factory' : checkDi ,
178+ ' angular?filter' : checkDi ,
179+ ' angular?inject' : checkDi ,
180+ ' angular?run' : checkDi ,
181+ ' angular?service' : checkDi ,
182+ ' angular?provider' : function ( callee , providerFn , $get ) {
183183 checkDi ( null , providerFn ) ;
184184 checkDi ( null , $get ) ;
185185 } ,
186- " angular?component" : function ( callee ) {
186+ ' angular?component' : function ( callee ) {
187187 var routeObject = callee . parent . arguments [ 1 ] ;
188188
189189 var elementLength = 0 ;
@@ -192,13 +192,13 @@ module.exports = {
192192
193193 if ( routeObject . properties ) {
194194 routeObject . properties . forEach ( function ( prop ) {
195- if ( prop . key . name === " controller" ) {
195+ if ( prop . key . name === ' controller' ) {
196196 elements = prop . value . elements ;
197197 if ( elements . length ) {
198198 elementLength = elements . length - 1 ;
199199 }
200200 prop . value . elements . forEach ( function ( element ) {
201- if ( element . type === " FunctionExpression" ) {
201+ if ( element . type === ' FunctionExpression' ) {
202202 parameters = element . params ;
203203 }
204204 } ) ;
@@ -209,7 +209,7 @@ module.exports = {
209209 if ( elementLength !== parameters . length ) {
210210 context . report (
211211 routeObject ,
212- " The signature of the method is incorrect" ,
212+ ' The signature of the method is incorrect' ,
213213 { }
214214 ) ;
215215 return ;
@@ -229,7 +229,7 @@ module.exports = {
229229 if ( invalidArray . length > 0 ) {
230230 context . report (
231231 routeObject ,
232- " You have an error in your DI configuration. Each items of the array should match exactly one function parameter" ,
232+ ' You have an error in your DI configuration. Each items of the array should match exactly one function parameter' ,
233233 { }
234234 ) ;
235235 return ;
0 commit comments