Skip to content

Commit 07e59f1

Browse files
committed
feature: @putout/plugin-remove-iife: exclude JSXExpressionContainer
1 parent 4f1c6ff commit 07e59f1

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

packages/plugin-remove-iife/lib/remove-iife.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ const {isReturnStatement} = types;
66
export const report = () => 'Avoid IIFE';
77

88
export const filter = (path) => {
9+
const {parentPath} = path;
10+
11+
if (parentPath.isJSXExpressionContainer())
12+
return false;
13+
914
const {callee} = path.node;
1015
const {body} = callee.body;
1116

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const Hello = () => (
2+
<script>
3+
{
4+
(function() {
5+
window.a = b;
6+
})()
7+
}
8+
</script>
9+
);

packages/plugin-remove-iife/test/remove-iife.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ test('remove iife: no transform: var', (t) => {
4646
t.noTransform('var');
4747
t.end();
4848
});
49+
50+
test('remove iife: no report: jsx', (t) => {
51+
t.noReport('jsx');
52+
t.end();
53+
});

0 commit comments

Comments
 (0)