@@ -17,37 +17,36 @@ function isValidAttribute(name) {
1717 return validSVGAttributeSet . has ( name ) || ( validAttributeName . test ( name ) && ! invalidSVGAttributeSet . has ( name ) )
1818}
1919
20- module . exports = function ( context ) {
21- return {
22- meta : {
23- type : 'problem' ,
24- docs : {
25- description : 'disallow wrong usage of attribute names' ,
26- url : require ( '../url' ) ( module )
27- } ,
28- fixable : 'code' ,
29- schema : [ ]
20+ module . exports = {
21+ meta : {
22+ type : 'problem' ,
23+ docs : {
24+ description : 'disallow wrong usage of attribute names' ,
25+ url : require ( '../url' ) ( module )
3026 } ,
31- CallExpression ( node ) {
32- if ( ! node . callee . property ) return
33-
34- const calleeName = node . callee . property . name
35- if ( ! attributeCalls . test ( calleeName ) ) return
36-
37- const attributeNameNode = node . arguments [ 0 ]
38- if ( ! attributeNameNode ) return
39-
40- if ( ! isValidAttribute ( attributeNameNode . value ) ) {
41- context . report ( {
42- meta : {
43- fixable : 'code'
44- } ,
45- node : attributeNameNode ,
46- message : 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.' ,
47- fix ( fixer ) {
48- return fixer . replaceText ( attributeNameNode , `'${ attributeNameNode . value . toLowerCase ( ) } '` )
49- }
50- } )
27+ fixable : 'code' ,
28+ schema : [ ]
29+ } ,
30+ create ( context ) {
31+ return {
32+ CallExpression ( node ) {
33+ if ( ! node . callee . property ) return
34+
35+ const calleeName = node . callee . property . name
36+ if ( ! attributeCalls . test ( calleeName ) ) return
37+
38+ const attributeNameNode = node . arguments [ 0 ]
39+ if ( ! attributeNameNode ) return
40+
41+ if ( ! isValidAttribute ( attributeNameNode . value ) ) {
42+ context . report ( {
43+ node : attributeNameNode ,
44+ message : 'Attributes should be lowercase and hyphen separated, or part of the SVG whitelist.' ,
45+ fix ( fixer ) {
46+ return fixer . replaceText ( attributeNameNode , `'${ attributeNameNode . value . toLowerCase ( ) } '` )
47+ }
48+ } )
49+ }
5150 }
5251 }
5352 }
0 commit comments