File tree Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Expand file tree Collapse file tree 2 files changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ describe('AST Unit Tests', () => {
71
71
expect ( getHooksNames ( elementType ) ) . toEqual ( [ 'testCount' , 'setTestCount' ] ) ;
72
72
} ) ;
73
73
74
- it ( 'Should output the right number of properties when taking in multiple function definitions ' , ( ) => {
74
+ it ( 'Should output the right number of properties when given multiple hooks ' , ( ) => {
75
75
const elementType = `function SingleUseFakeComponent() {
76
76
const [testCount, setTestCount] = useState(0);
77
77
const [biscuitCount, setBiscuitCount] = useState(0);
Original file line number Diff line number Diff line change @@ -91,9 +91,8 @@ export const getHooksNames = (elementType: string): Array<string> => {
91
91
// * Works for useState hooks
92
92
if ( hook . id . type === 'ArrayPattern' ) {
93
93
hook . id . elements . forEach ( ( hook ) => {
94
+ statements . push ( `_useWildcard${ tsCount } ` ) ;
94
95
statements . push ( hook . name ) ;
95
- // * Unshift a wildcard name to achieve similar functionality as before
96
- statements . unshift ( `_useWildcard${ tsCount } ` ) ;
97
96
tsCount += 1 ;
98
97
} ) ;
99
98
} else {
@@ -111,7 +110,7 @@ export const getHooksNames = (elementType: string): Array<string> => {
111
110
}
112
111
} ) ;
113
112
statements . forEach ( ( el , i ) => {
114
- if ( el . match ( / _ u s e / ) ) hooksNames [ el ] = statements [ i + 2 ] ;
113
+ if ( el . match ( / _ u s e / ) ) hooksNames [ el ] = statements [ i + 1 ] ;
115
114
} ) ;
116
115
} ) ;
117
116
}
You can’t perform that action at this time.
0 commit comments