Skip to content
This repository was archived by the owner on Oct 3, 2024. It is now read-only.

Commit 4f7f4db

Browse files
improve suggestion for 'no-same-line-conditional' (#342)
1 parent debcea1 commit 4f7f4db

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/rules/no-same-line-conditional.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ const rule: TSESLint.RuleModule<string, string[]> = {
8181
{
8282
messageId: 'suggestAddingNewline',
8383
fix: fixer =>
84-
fixer.insertTextBefore(
85-
followingIf,
84+
fixer.replaceTextRange(
85+
[precedingIf.range[1], followingIf.range[0]],
8686
'\n' + ' '.repeat(precedingIf.loc.start.column),
8787
),
8888
},

tests/rules/no-same-line-conditional.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ ruleTester.run('Conditionals should start on new lines', rule, {
112112
messageId: 'suggestAddingNewline',
113113
output: `
114114
if (cond1) {
115-
}
115+
}
116116
if (cond2) {
117117
}`,
118118
},
@@ -307,7 +307,7 @@ ruleTester.run('Conditionals should start on new lines', rule, {
307307
output: `
308308
function myFunc() {
309309
foo(); if (cond1) {
310-
}
310+
}
311311
if (cond2) {
312312
}
313313
}`,

0 commit comments

Comments
 (0)