Skip to content

Commit 40be918

Browse files
committed
feature: @putout/plugin-conditions: apply-consistent-blocks: empty
1 parent 79b26de commit 40be918

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
if (compare(tokens, from)) {}
2+
3+
if (a) {
4+
try {
5+
} catch {}
6+
} else {}

packages/plugin-conditions/lib/apply-consistent-blocks/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,14 @@ export const filter = (path) => {
9797
const couple = [];
9898

9999
for (const path of paths) {
100-
const is = isBlockStatement(path) && path.node.body.length > 1;
100+
if (!isBlockStatement(path)) {
101+
couple.push(false);
102+
continue;
103+
}
104+
105+
const {length} = path.node.body;
106+
const is = length > 1 || !length;
107+
101108
couple.push(is);
102109
}
103110

0 commit comments

Comments
 (0)