File tree Expand file tree Collapse file tree 1 file changed +17
-17
lines changed Expand file tree Collapse file tree 1 file changed +17
-17
lines changed Original file line number Diff line number Diff line change
1
+ /* eslint-disable no-inner-declarations */
1
2
const acorn = require ( 'acorn' ) ; // javascript parser
2
3
// eslint-disable-next-line import/newline-after-import
3
4
const jsx = require ( 'acorn-jsx' ) ;
@@ -14,6 +15,22 @@ module.exports = elementType => {
14
15
ast = ast . body ;
15
16
const statements = [ ] ;
16
17
18
+ function stMent ( st ) {
19
+ st . forEach ( ( el , i ) => {
20
+ if ( el . match ( / _ u s e / ) ) hookState [ el ] = statements [ i + 2 ] ;
21
+ } ) ;
22
+ }
23
+
24
+ function hookDeclare ( astVal ) {
25
+ astVal . forEach ( elem => {
26
+ if ( elem . type === 'VariableDeclaration' ) {
27
+ elem . declarations . forEach ( decClar => {
28
+ statements . push ( decClar . id . name ) ;
29
+ } ) ;
30
+ }
31
+ } ) ;
32
+ }
33
+
17
34
// handle useState useContext
18
35
if ( ast [ 0 ] . expression . body . body ) {
19
36
ast = ast [ 0 ] . expression . body . body ;
@@ -33,22 +50,5 @@ module.exports = elementType => {
33
50
} ) ;
34
51
}
35
52
}
36
-
37
- function stMent ( st ) {
38
- st . forEach ( ( el , i ) => {
39
- if ( el . match ( / _ u s e / ) ) hookState [ el ] = statements [ i + 2 ] ;
40
- } ) ;
41
- }
42
-
43
- function hookDeclare ( astVal ) {
44
- astVal . forEach ( elem => {
45
- if ( elem . type === 'VariableDeclaration' ) {
46
- elem . declarations . forEach ( decClar => {
47
- statements . push ( decClar . id . name ) ;
48
- } ) ;
49
- }
50
- } ) ;
51
- }
52
-
53
53
return hookState ;
54
54
} ;
You can’t perform that action at this time.
0 commit comments