@@ -42,9 +42,9 @@ new Synvert.Rewriter("react", "transform-class-components-to-functions", () => {
42
42
findNode (
43
43
".VariableDeclarationList[declarations.length=1][declarations.0.initializer=.PropertyAccessExpression[expression=this][name=props]]" ,
44
44
( ) => {
45
- this . currentNode . declarations [ 0 ] . name . elements . forEach ( ( element ) =>
46
- addThisProp ( currentFilePath , this . mutationAdapter . getSource ( element ) ) ,
47
- ) ;
45
+ for ( const element of this . currentNode . declarations [ 0 ] . name . elements ) {
46
+ addThisProp ( currentFilePath , this . mutationAdapter . getSource ( element ) ) ;
47
+ }
48
48
} ,
49
49
) ;
50
50
@@ -55,7 +55,7 @@ new Synvert.Rewriter("react", "transform-class-components-to-functions", () => {
55
55
56
56
// state = { key: value };
57
57
findNode ( ".PropertyDeclaration[name=state]" , ( ) => {
58
- this . currentNode . initializer . properties . forEach ( ( property ) => {
58
+ for ( const property of this . currentNode . initializer . properties ) {
59
59
const name = property . name . escapedText ;
60
60
const value = this . mutationAdapter . getSource ( property . initializer ) ;
61
61
functionBody . push (
@@ -64,7 +64,7 @@ new Synvert.Rewriter("react", "transform-class-components-to-functions", () => {
64
64
1 ,
65
65
) ,
66
66
) ;
67
- } ) ;
67
+ }
68
68
} ) ;
69
69
70
70
// foo = () => {}
@@ -84,15 +84,15 @@ new Synvert.Rewriter("react", "transform-class-components-to-functions", () => {
84
84
if ( lifecycleMethods . length > 0 ) {
85
85
functionBody . push ( addLeadingSpaces ( "// Synvert TODO: convert lifecycle methods to useEffect by yourself" ) ) ;
86
86
setUseEffect ( currentFilePath ) ;
87
- lifecycleMethods . forEach ( ( lifecycleMethod ) => {
87
+ for ( const lifecycleMethod of lifecycleMethods ) {
88
88
const lines = this . mutationAdapter . getSource ( lifecycleMethod , { fixIndent : true } ) . split ( "\n" ) ;
89
89
functionBody . push (
90
90
indentCode (
91
91
lines . map ( ( line ) => ( line . length > 0 ? "// " + line : "//" ) ) . join ( "\n" ) ,
92
92
1 ,
93
93
) ,
94
94
) ;
95
- } ) ;
95
+ }
96
96
}
97
97
98
98
// render() {}
@@ -218,9 +218,9 @@ ${functionBody.join("\n")}
218
218
( ) => {
219
219
const tabWidth = this . mutationAdapter . getIndent ( this . currentNode ) / Synvert . Configuration . tabWidth ;
220
220
const body = [ ] ;
221
- this . currentNode . declarations [ 0 ] . initializer . body . statements . forEach ( ( statement ) => {
221
+ for ( const statement of this . currentNode . declarations [ 0 ] . initializer . body . statements ) {
222
222
body . push ( this . mutationAdapter . getSource ( statement , { fixIndent : true } ) ) ;
223
- } ) ;
223
+ }
224
224
replaceWith ( indentCode ( body . join ( "\n" ) , tabWidth , { skipFirstLine : true } ) ) ;
225
225
} ,
226
226
) ;
0 commit comments