Skip to content

fix(jsx-curly-brace-presence): do not flag empty string literals in JSX children#3996

Open
ordinary9843 wants to merge 1 commit intojsx-eslint:masterfrom
ordinary9843:fix/jsx-curly-brace-whitespace
Open

fix(jsx-curly-brace-presence): do not flag empty string literals in JSX children#3996
ordinary9843 wants to merge 1 commit intojsx-eslint:masterfrom
ordinary9843:fix/jsx-curly-brace-whitespace

Conversation

@ordinary9843
Copy link
Copy Markdown

When {""} or {''} appears in JSX children and the children option is set to never, the rule reports it as an unnecessary curly brace and auto-fixes it by removing the expression entirely. This changes the JSX tree — an empty string literal in children is a distinct node from no node — and autofixes should never introduce semantic changes.

This fix adds a guard in shouldCheckForUnnecessaryCurly to skip empty string literals when their parent is a JSX element (children context). The behavior for props is unchanged: bar={""} is still flagged and correctly auto-fixed to bar="", since both forms pass an identical empty string to the prop.

Fixes #3995

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.58%. Comparing base (9af8845) to head (fbec3ee).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3996      +/-   ##
==========================================
+ Coverage   94.76%   97.58%   +2.81%     
==========================================
  Files         134      137       +3     
  Lines       10165    10183      +18     
  Branches     3794     3799       +5     
==========================================
+ Hits         9633     9937     +304     
+ Misses        532      246     -286     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

[Bug]: jsx-curly-brace-presence incorrectly removes {""} used for whitespace preservation

2 participants