@@ -11,14 +11,7 @@ export default function transformer(
11
11
) {
12
12
const source = j ( file . source ) ;
13
13
14
- /**
15
- * Early exit condition
16
- * -----
17
- * It is often good practice to exit early and return the original source file
18
- * if it does not contain code relevant to the codemod.
19
- * See this page for more information:
20
- * https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/your-first-codemod#output
21
- */
14
+ // Exit early if file is not importing memoize-one
22
15
if ( ! hasImportDeclaration ( j , source , 'memoize-one' ) ) {
23
16
return file . source ;
24
17
}
@@ -40,6 +33,9 @@ export default function transformer(
40
33
if ( second == null ) {
41
34
return ;
42
35
}
36
+ // We are going to wrap the existing customEqualityFn in our new one
37
+ // 4.0.0 EqualityFn → (a, b) => boolean [called for each argument]
38
+ // 5.0.0 EqualityFn → ([newArgs], [lastArgs]) => boolean [called once with all arguments]
43
39
if (
44
40
second . type === 'FunctionExpression' ||
45
41
second . type === 'ArrowFunctionExpression' ||
@@ -95,22 +91,5 @@ export default function transformer(
95
91
}
96
92
} ) ;
97
93
98
- /**
99
- * Codemod logic goes here 👇
100
- * -----
101
- * This is where the core logic for your codemod will go,
102
- * consider grouping specific actions into 'motions' and running them in sequence
103
- *
104
- * See this page for more information:
105
- * https://codeshiftcommunity.github.io/CodeshiftCommunity/docs/authoring#motions
106
- */
107
- // source.findVariableDeclarators('foo').renameTo('bar');
108
-
109
- /**
110
- * Return your modified AST here 👇
111
- * -----
112
- * This is where your modified AST will be transformed back into a string
113
- * and written back to the file.
114
- */
115
94
return source . toSource ( options . printOptions ) ;
116
95
}
0 commit comments