Skip to content

Commit

Permalink
Fix #127
Browse files Browse the repository at this point in the history
#127
Formatting breaks code, converting `else if` into `elseif` in some cases
  • Loading branch information
nvuillam committed Nov 12, 2020
1 parent 1b5ee71 commit b56ed9f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/test/lint-format.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,31 @@ private void doSomething() {
doSomething()
}
}
`
}
],
[
"ElseIfMustRemainSeparated",
{
totalFixed: 1,
codeNarcCallsCounter: 1,
before: `
boolean foo(boolean a, boolean b) {
if (a) {
return true
} else if(b) {
return true
}
}
`,
after: `
boolean foo(boolean a, boolean b) {
if (a) {
return true
} else if (b) {
return true
}
}
`
}
]
Expand Down
3 changes: 3 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ function addImport(allLineLs, classToImport) {

// Add space after a string in another string
function addSpaceAfterChar(line, char) {
if (char.length > 1) {
return line.replace(char, char + " ");
}
let pos = -1;
const lineIndent = line.search(/\S/);
const splits = line.split(char);
Expand Down

0 comments on commit b56ed9f

Please sign in to comment.