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: preserve other children in useConsistentCurlyBraces #3925

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

suzak
Copy link
Contributor

@suzak suzak commented Sep 16, 2024

Summary

PR #3182 added the useConsistentCurlyBraces rule. However, the automatic fix provided by the rule inadvertently removes other child nodes under the parent node. This behavior should be corrected to preserve these nodes.

invalid.jsx:14:9 lint/nursery/useConsistentCurlyBraces  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  ! Should not have curly braces around expression.
  
    12 │ <Foo>{/*comment*/'Hello world'/*comment*/}</Foo>
    13 │ 
  > 14 │ <Foo>{x}{'y'}{z}</Foo>
       │         ^^^^^
    15 │ </>
    16 │ 
  
  i JSX child does not need to be wrapped in curly braces.
  
  i Unsafe fix: Remove curly braces around the expression.
  
    14 │ <Foo>{x}{'y'}{z}</Foo>
       │      ----- -----      

Test Plan

See test spec.

cargo test -p biome_js_analyze use_consistent_curly_braces

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Sep 16, 2024
@dyc3
Copy link
Contributor

dyc3 commented Sep 16, 2024

See our CONTRIBUTING.md for our PR title format.

Copy link
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

@suzak suzak changed the title Preserve other children in useConsistentCurlyBraces fix: Preserve other children in useConsistentCurlyBraces Sep 16, 2024
@suzak suzak changed the title fix: Preserve other children in useConsistentCurlyBraces fix: preserve other children in useConsistentCurlyBraces Sep 16, 2024
Copy link

codspeed-hq bot commented Sep 16, 2024

CodSpeed Performance Report

Merging #3925 will improve performances by 7.24%

Comparing suzak:use_consistent_curly_braces (0cc4472) with main (4968fa5)

Summary

⚡ 1 improvements
✅ 106 untouched benchmarks

Benchmarks breakdown

Benchmark main suzak:use_consistent_curly_braces Change
eucjp_1600564308684076393.json[cached] 863.5 µs 805.2 µs +7.24%

@dyc3 dyc3 merged commit 2eb6faa into biomejs:main Sep 16, 2024
12 of 14 checks passed
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.

2 participants