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

jsx-newline puts line breaks between comments and new JSX elements #3478

Closed
Sreejit7 opened this issue Nov 2, 2022 · 4 comments · Fixed by #3493
Closed

jsx-newline puts line breaks between comments and new JSX elements #3478

Sreejit7 opened this issue Nov 2, 2022 · 4 comments · Fixed by #3493

Comments

@Sreejit7
Copy link

Sreejit7 commented Nov 2, 2022

I have the jsx-newline rule turned on, which when run with the --fix option, puts line breaks between any comments (including eslint-disable comments) and JSX elements, thus undoing the whole point of using comments.

Let's say I have something like this:

<Element as="header" marginBottom="micro">
        {/* eslint-disable-next-line react/jsx-sort-props */}
        <Heading as="h6" align="right">
            Transaction value
        </Heading>
<Element>

The jsx-newline rule puts a line break between the eslint-disable comment and , therefore causing the eslint-disable-{some rule} to stop working.

Can we handle putting line breaks between comments & new JSX elements?

I saw something similar in #2926 (which was closed earlier as completed) but that doesn't work properly as of v7.31.10

@sujan-s
Copy link

sujan-s commented Nov 2, 2022

To demonstrate the above comment—

What we need—
Screenshot 2022-11-02 at 12 04 03 PM

But what actually happens—
Screenshot 2022-11-02 at 12 04 17 PM

Which we obviously don’t want.

Webstorm adds each line as individual comments—which I’d say is a better approach to commenting—and I’d rather have this rule ignoring that.

@ljharb
Copy link
Member

ljharb commented Nov 2, 2022

If this is new behavior in .10, then it’s a bug (cc @ROSSROSALES), and we should fix it.

@Sreejit7
Copy link
Author

Sreejit7 commented Nov 2, 2022

@ljharb it's not a new behavior in .10, we were using 7.31.8, upgraded to .10

@ROSSROSALES
Copy link
Contributor

@ljharb Thanks for pinging me, I can try and take a look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants