Skip to content

Commit e31a13c

Browse files
committed
1 parent edc037c commit e31a13c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/plugins/eslint-plugin-react-x/src/rules/no-leaked-conditional-rendering.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,5 +587,34 @@ ruleTesterWithTypes.run(RULE_NAME, rule, {
587587
);
588588
}
589589
`,
590+
dedent`
591+
declare function getData(): { id: number; name: string }[] | undefined;
592+
function List({ items }: { items: string[] }) {
593+
return <div>{items.map(item => <div key={item}>{item}</div>)}</div>;
594+
}
595+
type Item = { id: number; name: string };
596+
function App() {
597+
let data: Item[] | undefined = getData();
598+
599+
return (
600+
<div>
601+
{data && <List items={data} />}
602+
</div>
603+
);
604+
}
605+
`,
606+
dedent`
607+
export const MyComponent = ({ isVisible1 }: { isVisible1: boolean }) => {
608+
const isVisible2 = true;
609+
const isVisible3 = 1 > 2;
610+
return (
611+
<>
612+
{isVisible1 && <div />}
613+
{isVisible2 && <div />}
614+
{isVisible3 && <div />}
615+
</>
616+
);
617+
};
618+
`,
590619
],
591620
});

0 commit comments

Comments
 (0)