Skip to content

Commit

Permalink
[Fix] jsx-newline: jsx-newline breaking with comments
Browse files Browse the repository at this point in the history
  • Loading branch information
akulsr0 authored and ljharb committed May 31, 2024
1 parent e27ef81 commit 7722f49
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/rules/jsx-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const messages = {
};

function isMultilined(node) {
return node && node.loc.start.line !== node.loc.end.line;
if (node) {
return node.loc.start.line !== node.loc.end.line;
}
}

/** @type {import('eslint').Rule.RuleModule} */
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/jsx-newline.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,19 @@ new RuleTester({ parserOptions }).run('jsx-newline', rule, {
`,
options: [{ prevent: true, allowMultilines: true }],
},
{
code: `
function Test() {
return (
<div>
<div />
{/* a comment */}
</div>
);
}
`,
options: [{ prevent: true, allowMultilines: true }],
},
]),
invalid: parsers.all([
{
Expand Down

0 comments on commit 7722f49

Please sign in to comment.