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
Open
fix(jsx-curly-brace-presence): do not flag empty string literals in JSX children#3996ordinary9843 wants to merge 1 commit intojsx-eslint:masterfrom
ordinary9843 wants to merge 1 commit intojsx-eslint:masterfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
{""}or{''}appears in JSX children and thechildrenoption is set tonever, 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
shouldCheckForUnnecessaryCurlyto 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 tobar="", since both forms pass an identical empty string to the prop.Fixes #3995