Fix jsx-sort-props autofix with trailing line comments#4011
Open
sjh9714 wants to merge 2 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #4011 +/- ##
=======================================
Coverage 97.71% 97.71%
=======================================
Files 137 137
Lines 10188 10199 +11
Branches 3797 3800 +3
=======================================
+ Hits 9955 9966 +11
Misses 233 233 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
8b57742 to
05b25ec
Compare
ljharb
approved these changes
May 17, 2026
ljharb
left a comment
Member
There was a problem hiding this comment.
I'll check this locally, but it looks good at a quick glance
| code: ` | ||
| <div | ||
| onClick={() => console.log()} // Comment | ||
| className="flex"> |
Member
There was a problem hiding this comment.
Suggested change
| className="flex"> | |
| className="flex" | |
| > |
Author
There was a problem hiding this comment.
Applied this formatting suggestion in the current diff; the output block now keeps className="flex" and the closing > on separate lines as suggested. All PR checks are passing.
e26ca9b to
b278c53
Compare
Author
|
The outstanding review thread is outdated now; the current fixture has the suggested formatting with
|
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.
Summary
Fixes an unsafe autofix in
jsx-sort-propswhen a JSX prop has a trailing line comment.What changed
//comment.Why
Issue #3936 reports that sorting a prop with a trailing line comment can move JSX syntax after the comment, producing invalid output.
Testing
./node_modules/.bin/mocha tests/lib/rules/jsx-sort-props.js --grep "Comment"./node_modules/.bin/mocha tests/lib/rules/jsx-sort-props.jsnpm run lintnpm run unit-testnpm testFixes #3936