Closed
Description
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
Activity
sujan-s commentedon Nov 2, 2022
To demonstrate the above comment—
What we need—

But what actually happens—

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 commentedon Nov 2, 2022
If this is new behavior in .10, then it’s a bug (cc @ROSSROSALES), and we should fix it.
Sreejit7 commentedon Nov 2, 2022
@ljharb it's not a new behavior in .10, we were using 7.31.8, upgraded to .10
ROSSROSALES commentedon Nov 2, 2022
@ljharb Thanks for pinging me, I can try and take a look into it
jsx-newline
: No newline between comments and jsx elements #3493