Skip to content

Commit 4aa4f77

Browse files
committed
fix: optional location
1 parent 0036260 commit 4aa4f77

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/linter/reporters/console.mjs

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ const levelToColorMap = {
1717
* @type {import('../types.d.ts').Reporter}
1818
*/
1919
export default issue => {
20+
const position = issue.location.position
21+
? ` (${issue.location.position.start}:${issue.location.position.end})`
22+
: '';
23+
2024
console.log(
2125
styleText(
2226
// @ts-expect-error ForegroundColors is not exported
2327
levelToColorMap[issue.level],
24-
`${issue.message} at ${issue.location.path} (${issue.location.position.start}:${issue.location.position.end})`
28+
`${issue.message} at ${issue.location.path}${position}`
2529
)
2630
);
2731
};

src/linter/types.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type IssueLevel = 'info' | 'warn' | 'error';
44

55
export interface LintIssueLocation {
66
path: string; // The absolute path to the file
7-
position: Position;
7+
position?: Position;
88
}
99

1010
export interface LintIssue {

0 commit comments

Comments
 (0)