@putout/plugin-conditions 8.0.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,6 +14,9 @@ export const match = () => ({
|
|
|
14
14
|
if (!isBlockStatement(__b))
|
|
15
15
|
return isReturnLike(__b);
|
|
16
16
|
|
|
17
|
+
if (!__b.body.length)
|
|
18
|
+
return true;
|
|
19
|
+
|
|
17
20
|
const latest = __b.body.at(-1);
|
|
18
21
|
|
|
19
22
|
return isReturnLike(latest);
|
|
@@ -21,10 +24,15 @@ export const match = () => ({
|
|
|
21
24
|
});
|
|
22
25
|
|
|
23
26
|
export const replace = () => ({
|
|
24
|
-
'if (__a) __b; else __c':
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
'if (__a) __b; else __c': ({__b}) => {
|
|
28
|
+
if (isBlockStatement(__b) && !__b.body.length)
|
|
29
|
+
return 'if (!__a) __c';
|
|
30
|
+
|
|
31
|
+
return `{
|
|
32
|
+
if (__a) __b;
|
|
33
|
+
__c;
|
|
34
|
+
}`;
|
|
35
|
+
},
|
|
28
36
|
});
|
|
29
37
|
|
|
30
38
|
function isReturnLike(node) {
|
package/package.json
CHANGED