Skip to content

Commit 38671b7

Browse files
committed
test cases for prefer-for chain expression
1 parent e518d11 commit 38671b7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/rules/prefer-for.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@ export const cases = run("prefer-for", rule, {
3333
return <ol><For each={props.data}>{d => <li>{d.text}</li>}</For></ol>;
3434
}`,
3535
},
36+
{
37+
code: `
38+
function Component(props) {
39+
return <ol>{props.data?.map(d => <li>{d.text}</li>)}</ol>;
40+
}`,
41+
errors: [{ messageId: "preferFor" }],
42+
output: `
43+
function Component(props) {
44+
return <ol>{<For each={props.data}>{(d) => <li>{d.text}</li>}</For>}</ol>;
45+
}`,
46+
},
3647
// deopts
3748
{
3849
code: `let Component = (props) => <ol>{props.data.map(() => <li />)}</ol>;`,

0 commit comments

Comments
 (0)