We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 02300ad commit ade8734Copy full SHA for ade8734
.DS_Store
0 Bytes
.babelrc
@@ -0,0 +1,3 @@
1
+{
2
+ "plugins": ["./index.js"]
3
+}
index.js
@@ -0,0 +1,29 @@
+
+module.exports = function (babel) {
+ const { types: t } = babel;
4
5
+ let hasLogID = false;
6
7
+ return {
8
+ name: "log-transform",
9
+ visitor: {
10
+ ReturnStatement: (path) => {
11
+ const identifierName = path.node.argument.name;
12
+ if (path.node.argument.type === "Identifier" && hasLogID) {
13
+ path.replaceWithMultiple([
14
+ t.identifier(
15
+ `console.log('Final Result 😛 ==> ', ${identifierName})`
16
+ ),
17
+ t.identifier(`return ${identifierName}`),
18
+ ]);
19
+ }
20
+ },
21
+ Identifier: (path) => {
22
+ if (path.isIdentifier({ name: "$log" })) {
23
+ hasLogID = true;
24
+ path.remove();
25
26
27
28
+ };
29
0 commit comments