@@ -17,28 +17,30 @@ function isValidAttribute(name) {
17
17
return validSVGAttributeSet . has ( name ) || ( validAttributeName . test ( name ) && ! invalidSVGAttributeSet . has ( name ) )
18
18
}
19
19
20
- module . exports = function ( context ) {
21
- return {
22
- CallExpression ( node ) {
23
- if ( ! node . callee . property ) return
24
-
25
- const calleeName = node . callee . property . name
26
- if ( ! attributeCalls . test ( calleeName ) ) return
27
-
28
- const attributeNameNode = node . arguments [ 0 ]
29
- if ( ! attributeNameNode ) return
30
-
31
- if ( ! isValidAttribute ( attributeNameNode . value ) ) {
32
- context . report ( {
33
- meta : {
34
- fixable : 'code'
35
- } ,
36
- node : attributeNameNode ,
37
- message : 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.' ,
38
- fix ( fixer ) {
39
- return fixer . replaceText ( attributeNameNode , `'${ attributeNameNode . value . toLowerCase ( ) } '` )
40
- }
41
- } )
20
+ module . exports = {
21
+ meta : {
22
+ fixable : 'code'
23
+ } ,
24
+ create ( context ) {
25
+ return {
26
+ CallExpression ( node ) {
27
+ if ( ! node . callee . property ) return
28
+
29
+ const calleeName = node . callee . property . name
30
+ if ( ! attributeCalls . test ( calleeName ) ) return
31
+
32
+ const attributeNameNode = node . arguments [ 0 ]
33
+ if ( ! attributeNameNode ) return
34
+
35
+ if ( ! isValidAttribute ( attributeNameNode . value ) ) {
36
+ context . report ( {
37
+ node : attributeNameNode ,
38
+ message : 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.' ,
39
+ fix ( fixer ) {
40
+ return fixer . replaceText ( attributeNameNode , `'${ attributeNameNode . value . toLowerCase ( ) } '` )
41
+ }
42
+ } )
43
+ }
42
44
}
43
45
}
44
46
}
0 commit comments