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] jsx-key: detect conditional returns #3630

Merged

Conversation

yialo
Copy link
Contributor

@yialo yialo commented Sep 5, 2023

Catch React key absence for conditional return without block statement:

const TestCase = () => {
  const list = [1, 2, 3, 4, 5];
  return (
    <div>
      {list.map(item => {
        if (item < 2) return <div>{item}</div>;
        else if (item < 5) return <div />;
        else return <div />;
      })}
    </div>
  );
};

@yialo yialo marked this pull request as ready for review September 5, 2023 10:08
@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Merging #3630 (9acfec2) into master (422ff33) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 9acfec2 differs from pull request most recent head ecadb92. Consider uploading reports for the commit ecadb92 to get more accurate results

@@           Coverage Diff           @@
##           master    #3630   +/-   ##
=======================================
  Coverage   97.64%   97.64%           
=======================================
  Files         132      132           
  Lines        9358     9360    +2     
  Branches     3425     3426    +1     
=======================================
+ Hits         9138     9140    +2     
  Misses        220      220           
Files Changed Coverage Δ
lib/rules/jsx-key.js 99.16% <100.00%> (+0.01%) ⬆️

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

Seems straightforward, thanks!

@ljharb ljharb force-pushed the fix/jsx-key-unblocked-conditional-return branch from 9acfec2 to ecadb92 Compare September 5, 2023 17:22
@ljharb ljharb changed the title [fix] jsx-key: unblocked conditional return [Fix] jsx-key: detect conditional returns Sep 5, 2023
@ljharb ljharb merged commit ecadb92 into jsx-eslint:master Sep 5, 2023
290 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants