-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support --report-unused-ignore
- Loading branch information
1 parent
baf6a95
commit 7de9fd9
Showing
7 changed files
with
57 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
import * as ts from 'typescript' | ||
import * as utils from 'tsutils/util' | ||
|
||
export function collectIgnoreMap(sourceFile: ts.SourceFile, file: string) { | ||
const ingoreMap: { [file: string]: Set<number> } = {} | ||
|
||
export function collectIgnoreLines(sourceFile: ts.SourceFile) { | ||
let ignoreLines: Set<number> | undefined | ||
utils.forEachComment(sourceFile, (_, comment) => { | ||
const commentText = comment.kind === ts.SyntaxKind.SingleLineCommentTrivia | ||
? sourceFile.text.substring(comment.pos + 2, comment.end).trim() | ||
: sourceFile.text.substring(comment.pos + 2, comment.end - 2).trim() | ||
if (commentText.includes('type-coverage:ignore-next-line')) { | ||
if (!ingoreMap[file]) { | ||
ingoreMap[file] = new Set() | ||
if (!ignoreLines) { | ||
ignoreLines = new Set() | ||
} | ||
const line = ts.getLineAndCharacterOfPosition(sourceFile, comment.pos).line | ||
ingoreMap[file]?.add(line + 1) | ||
ignoreLines.add(line + 1) | ||
} else if (commentText.includes('type-coverage:ignore-line')) { | ||
if (!ingoreMap[file]) { | ||
ingoreMap[file] = new Set() | ||
if (!ignoreLines) { | ||
ignoreLines = new Set() | ||
} | ||
const line = ts.getLineAndCharacterOfPosition(sourceFile, comment.pos).line | ||
ingoreMap[file]?.add(line) | ||
ignoreLines.add(line) | ||
} | ||
}) | ||
|
||
return ingoreMap | ||
return ignoreLines | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters