Skip to content

Commit 7722f49

Browse files
akulsr0ljharb
authored andcommitted
[Fix] jsx-newline: jsx-newline breaking with comments
1 parent e27ef81 commit 7722f49

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/rules/jsx-newline.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const messages = {
2121
};
2222

2323
function isMultilined(node) {
24-
return node && node.loc.start.line !== node.loc.end.line;
24+
if (node) {
25+
return node.loc.start.line !== node.loc.end.line;
26+
}
2527
}
2628

2729
/** @type {import('eslint').Rule.RuleModule} */

tests/lib/rules/jsx-newline.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,19 @@ new RuleTester({ parserOptions }).run('jsx-newline', rule, {
203203
`,
204204
options: [{ prevent: true, allowMultilines: true }],
205205
},
206+
{
207+
code: `
208+
function Test() {
209+
return (
210+
<div>
211+
<div />
212+
{/* a comment */}
213+
</div>
214+
);
215+
}
216+
`,
217+
options: [{ prevent: true, allowMultilines: true }],
218+
},
206219
]),
207220
invalid: parsers.all([
208221
{

0 commit comments

Comments
 (0)