eslint-plugin-react
eslint-plugin-react copied to clipboard
[Fix]: detect missing keys in return statement with ternary operator
Fix #3925
Invalid Test Cases (4)
| Case | Scenario | AST Patterns Covered |
|---|---|---|
| 1: Basic Pattern | return + ternary in map with ArrowFunction | • ArrowFunction + BlockStatement + ReturnStatement • ConditionalExpression with JSX elements • Missing key detection in ternary branches |
| 2: Function Expression | return + ternary in map with regular function | • FunctionExpression + BlockStatement + ReturnStatement • ConditionalExpression handling across function types • Same logic applies to function() syntax |
| 3: Array.from Method | return + ternary in Array.from iteration | • Array.from + checkFunctionsBlockStatement call • ConditionalExpression in different iteration contexts • Multiple iteration method support |
| 4: Fragment Context | return + ternary within Fragment (Original Issue) | • Fragment + map + return + ternary pattern • Real-world user scenario reproduction • Issue #3925 exact replication |
Valid Test Cases (1)
| Case | Scenario | Corresponding Invalid Case |
|---|---|---|
| 1: Proper Keys | return + ternary with correct key props | Invalid 1 |