Skip to content

Commit

Permalink
refactor(utils): tweak lint range formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
hanna-skryl committed Oct 1, 2024
1 parent 6f42d61 commit 690db7f
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/utils/src/lib/reports/formatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ export function formatSourceLine(
return '';
}
const { startLine, endLine } = position;
return endLine
? startLine === endLine
? `${startLine}`
: `${startLine}-${endLine}`
return endLine && startLine !== endLine
? `${startLine}-${endLine}`
: `${startLine}`;
}

Expand All @@ -112,14 +110,13 @@ export function formatGitHubLink(
return `${baseUrl}/${file}`;
}
const { startLine, endLine, startColumn, endColumn } = position;

const start = startColumn ? `L${startLine}C${startColumn}` : `L${startLine}`;
const end = endLine
? endColumn
? `L${endLine}C${endColumn}`
: `L${endLine}`
: '';
const lineRange = end ? (start === end ? start : `${start}-${end}`) : start;
const lineRange = end && start !== end ? `${start}-${end}` : start;
return `${baseUrl}/${file}#${lineRange}`;
}

Expand Down

0 comments on commit 690db7f

Please sign in to comment.