From 7b4e900bd246436b735e143f968dee52a76fd9ca Mon Sep 17 00:00:00 2001 From: Ni55aN Date: Fri, 30 Aug 2024 19:24:35 +0300 Subject: [PATCH] fix(lint): type coverage end line and column --- src/lint/type-coverage/index.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/lint/type-coverage/index.ts b/src/lint/type-coverage/index.ts index 9154f59..6201ad5 100644 --- a/src/lint/type-coverage/index.ts +++ b/src/lint/type-coverage/index.ts @@ -19,14 +19,25 @@ export class TypeCoverage implements BaseLinter { const results = Object.entries(groups).map(([file, anys]) => { return { filePath: file, - messages: anys.map(any => ({ - ruleId: getRuleId(any), - message: getMessages(any), - severity: 1, - line: any.line + 1, - column: any.character + 1, - endColumn: any.character + 1 + any.text.length - })) + messages: anys.map(any => { + const line = any.line + 1 + const column = any.character + 1 + const lines = any.text.split('\n') + const [firstLine, ...rest] = lines + const lastLine = [...rest].pop() ?? firstLine + + return { + ruleId: getRuleId(any), + message: getMessages(any), + severity: 1, + line, + endLine: line + lines.length - 1, + column, + endColumn: lines.length === 1 + ? column + lastLine.length + : lastLine.length + } + }) } satisfies LintResult }) const rules = Object.entries(groups)