Skip to content

Commit 11d82cd

Browse files
committed
Extract trimTrailingComments()
1 parent 60126db commit 11d82cd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/formatter/formatCommaPositions.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ function groupCommaDelimitedLines(lines: string[]): string[][] {
6363

6464
// makes all lines the same length by appending spaces before comma
6565
function formatTabular(commaLines: string[]): string[] {
66-
const commaLinesWithoutComments = commaLines.map(line => line.replace(/--.*/, ''));
67-
const commaPosition = maxLength(commaLinesWithoutComments) - 1;
66+
const commaPosition = maxLength(trimTrailingComments(commaLines)) - 1;
6867
return commaLines.map((line, i) => {
6968
if (i === commaLines.length - 1) {
7069
return line; // do not add comma for last item
@@ -101,3 +100,7 @@ function removeLastIndent(whitespace: string, indent: string): string {
101100
function trimTrailingCommas(lines: string[]): string[] {
102101
return lines.map(line => line.replace(/,(\s*(--.*)?$)/, '$1'));
103102
}
103+
104+
function trimTrailingComments(lines: string[]): string[] {
105+
return lines.map(line => line.replace(/--.*/, ''));
106+
}

0 commit comments

Comments
 (0)