Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lint/useJsxKeyInIterable): handle ternaries properly #2701

Conversation

dyc3
Copy link
Contributor

@dyc3 dyc3 commented May 3, 2024

Summary

This is a continuation of #2667, and as such fixes somethings related to #2590.

Specifically, it handles ternaries in expressions like this:

<>{data.map(a => a > 4 ? <h1 key={a}>{a}</h1> : <h2 key={a}>{a}</h2>)}</>

related to: #2590
fixes #2468

Test Plan

Added tests.

cargo test -p biome_js_analyze use_jsx_key_in_iterable

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels May 3, 2024
Copy link

codspeed-hq bot commented May 3, 2024

CodSpeed Performance Report

Merging #2701 will not alter performance

Comparing dyc3:05-03-fix_lint_usejsxkeyiniterable_handle_ternaries_properly (bee365b) with main (ba4f93b)

Summary

✅ 85 untouched benchmarks

@dyc3 dyc3 force-pushed the 05-03-fix_lint_usejsxkeyiniterable_handle_ternaries_properly branch from a58c2ed to d854949 Compare May 5, 2024 12:18
@dyc3 dyc3 requested a review from ematipico May 5, 2024 12:18
@dyc3 dyc3 force-pushed the 05-03-fix_lint_usejsxkeyiniterable_handle_ternaries_properly branch from d854949 to bee365b Compare May 5, 2024 12:19
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better!

@ematipico ematipico merged commit 84b256f into biomejs:main May 5, 2024
12 checks passed
@dyc3 dyc3 deleted the 05-03-fix_lint_usejsxkeyiniterable_handle_ternaries_properly branch May 5, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Linter Area: linter L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

💅 useJsxKeyInIterable incorrect behavior: Cannot determine whether this child has the required key prop.
3 participants