@@ -17,6 +17,18 @@ function changeToLiteral(node) {
1717 }
1818}
1919
20+ function changeComments ( nodeComments ) {
21+ for ( var i = 0 ; i < nodeComments . length ; i ++ ) {
22+ var comment = nodeComments [ i ] ;
23+ if ( comment . type === "CommentLine" ) {
24+ comment . type = "Line" ;
25+ } else if ( comment . type === "CommentBlock" ) {
26+ comment . type = "Block" ;
27+ }
28+ comment . range = [ comment . start , comment . end ] ;
29+ }
30+ }
31+
2032var astTransformVisitor = {
2133 noScope : true ,
2234 enter : function ( path ) {
@@ -33,27 +45,11 @@ var astTransformVisitor = {
3345 }
3446
3547 if ( node . trailingComments ) {
36- for ( var i = 0 ; i < node . trailingComments . length ; i ++ ) {
37- var comment = node . trailingComments [ i ] ;
38- if ( comment . type === "CommentLine" ) {
39- comment . type = "Line" ;
40- } else if ( comment . type === "CommentBlock" ) {
41- comment . type = "Block" ;
42- }
43- comment . range = [ comment . start , comment . end ] ;
44- }
48+ changeComments ( node . trailingComments ) ;
4549 }
4650
4751 if ( node . leadingComments ) {
48- for ( var i = 0 ; i < node . leadingComments . length ; i ++ ) {
49- var comment = node . leadingComments [ i ] ;
50- if ( comment . type === "CommentLine" ) {
51- comment . type = "Line" ;
52- } else if ( comment . type === "CommentBlock" ) {
53- comment . type = "Block" ;
54- }
55- comment . range = [ comment . start , comment . end ] ;
56- }
52+ changeComments ( node . leadingComments ) ;
5753 }
5854
5955 // make '_paths' non-enumerable (babel-eslint #200)
0 commit comments