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

@benj-dobs benj-dobs commented Aug 30, 2021

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 Aug 30, 2021
@benj-dobs benj-dobs marked this pull request as ready for review Aug 30, 2021
@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
@ljharb ljharb force-pushed the fix-allow-expressions branch from 70d9487 to cc95a82 Aug 30, 2021
ljharb
ljharb approved these changes Aug 30, 2021
Copy link
Collaborator

@ljharb ljharb left a comment

awesome, thanks!

@codecov-commenter
Copy link

@codecov-commenter 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 yannickcr:master Aug 30, 2021
123 checks passed
@benj-dobs benj-dobs deleted the fix-allow-expressions branch Aug 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants