Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ module.exports.filter = (path) => {

const is = !isIntersect(bindings, path.parentPath);

return is && (parentPath.isBlockStatement() || parentPath.isProgram());
if (!parentPath.isBlockStatement() && !parentPath.isProgram())
return false;

return is || path.container.length === 1;
};

function isReturnWithoutArg(path) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function fun1(f) {
let x1;
{
let x1 = f;
return x1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let x1;

function fun1(f) {
let x1 = f;
return x1;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
let x1;
function fun1(f) {
{
let x1 = f;
return x1;
}
}
10 changes: 10 additions & 0 deletions packages/plugin-remove-nested-blocks/test/remove-nested-blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,13 @@ test('plugin-remove-nested-blocks: no report: return', (t) => {
t.noReport('return');
t.end();
});

test('plugin-remove-nested-blocks: transform: intersect-single', (t) => {
t.transform('intersect-single');
t.end();
});

test('plugin-remove-nested-blocks: no report: intersect-multi', (t) => {
t.noReport('intersect-multi');
t.end();
});
Loading