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-no-useless-fragments: Allow whitespace when allowExpressions is true #3061

Merged
merged 1 commit into from Aug 30, 2021

Conversation

benj-dobs
Copy link
Contributor

Bug fix.

Problem: When react/jsx-no-useless-fragment has allowExpression set to true, the following code produces an error:

<>
  {foo ? (
    <Bar />
  ) : (
    <Baz />
  )}
</>

This PR amends the allowExpressions rule added in #3006 to allow insignificant whitespace around the expression.

@benj-dobs benj-dobs force-pushed the fix-allow-expressions branch 4 times, most recently from 341d471 to 70d9487 Compare August 30, 2021 11:17
@benj-dobs benj-dobs marked this pull request as ready for review August 30, 2021 11:18
@ljharb ljharb changed the title [Fix] [jsx-no-useless-fragment] Allow whitespace when allowExpressions: true [Fix] jsx-no-useless-fragments: Allow whitespace when allowExpressions: true Aug 30, 2021
@ljharb ljharb changed the title [Fix] jsx-no-useless-fragments: Allow whitespace when allowExpressions: true [Fix] jsx-no-useless-fragments: Allow whitespace when allowExpressions is true Aug 30, 2021
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.

awesome, thanks!

@codecov-commenter
Copy link

codecov-commenter commented Aug 30, 2021

Codecov Report

Merging #3061 (cc95a82) into master (9487a17) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3061   +/-   ##
=======================================
  Coverage   97.42%   97.42%           
=======================================
  Files         111      111           
  Lines        7502     7506    +4     
  Branches     2755     2758    +3     
=======================================
+ Hits         7309     7313    +4     
  Misses        193      193           
Impacted Files Coverage Δ
lib/rules/jsx-no-useless-fragment.js 98.90% <100.00%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9487a17...cc95a82. Read the comment docs.

@ljharb ljharb merged commit cc95a82 into jsx-eslint:master Aug 30, 2021
@benj-dobs benj-dobs deleted the fix-allow-expressions branch August 31, 2021 08:48
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.

None yet

3 participants