Skip to content

Commit

Permalink
fix: incorrect newline
Browse files Browse the repository at this point in the history
  • Loading branch information
urielvan committed Apr 15, 2024
1 parent 6df9977 commit 9eee88a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/newline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,11 @@ const rule: Rule.RuleModule = {
},
fix: getFixer(source, node, false),
});
} else if (inSameLine) {
} else if (
inSameLine
|| isSameLine(openBrace, source.getTokenAfter(openBrace) as Token)
|| isSameLine(source.getTokenBefore(closeBrace) as Token, closeBrace)
) {
ctx.report({
node,
messageId: CONSIST_NEWLINE,
Expand Down
8 changes: 8 additions & 0 deletions test/newline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,14 @@ runner.run('option `allowAllPropertiesOnSameLine`', newline, {
errors: [{ messageId: CONSIST_NEWLINE }],
output: 'const {\na,\nb,\nc\n} = foo;',
},
{
code: 'const {a,\nb} = foo;',
options: [{
allowAllPropertiesOnSameLine: true,
}],
errors: [{ messageId: CONSIST_NEWLINE }],
output: 'const {\na,\nb\n} = foo;',
},
],
});

Expand Down

0 comments on commit 9eee88a

Please sign in to comment.