Socket
Socket
Sign inDemoInstall

type-coverage-core

Package Overview
Dependencies
25
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.27.2 to 2.28.0

9

dist/checker.js

@@ -6,4 +6,3 @@ "use strict";

function collectAny(node, context, kind) {
var _a;
const { file, sourceFile, typeCheckResult, ingoreMap, ignoreUnreadAnys, debug, processAny } = context;
const { file, sourceFile, typeCheckResult, ignoreLines, ignoreUnreadAnys, debug, processAny } = context;
if (processAny !== undefined) {

@@ -13,3 +12,7 @@ return processAny(node, context);

const { line, character } = ts.getLineAndCharacterOfPosition(sourceFile, node.getStart(sourceFile));
if (ingoreMap[file] && ((_a = ingoreMap[file]) === null || _a === void 0 ? void 0 : _a.has(line))) {
if (ignoreLines === null || ignoreLines === void 0 ? void 0 : ignoreLines.has(line)) {
if (!context.usedIgnoreLines) {
context.usedIgnoreLines = new Set();
}
context.usedIgnoreLines.add(line);
return false;

@@ -16,0 +19,0 @@ }

@@ -16,2 +16,3 @@ "use strict";

async function lint(project, options) {
var _a;
const lintOptions = { ...defaultLintOptions, ...options };

@@ -94,3 +95,3 @@ const { rootNames, compilerOptions } = await (0, tsconfig_1.getProjectRootNamesAndCompilerOptions)(project);

}
const ingoreMap = (0, ignore_1.collectIgnoreMap)(sourceFile, file);
const ignoreLines = (0, ignore_1.collectIgnoreLines)(sourceFile);
const context = {

@@ -111,3 +112,3 @@ file,

checker,
ingoreMap,
ignoreLines,
ignoreNested: lintOptions.ignoreNested,

@@ -146,2 +147,15 @@ ignoreAsAssertion: lintOptions.ignoreAsAssertion,

});
if (lintOptions.reportUnusedIgnore && ignoreLines) {
for (const line of ignoreLines) {
if (!((_a = context.usedIgnoreLines) === null || _a === void 0 ? void 0 : _a.has(line))) {
anys.push({
line,
character: 0,
text: 'Unused ignore line directive(no problems reported on that line)',
kind: 7 /* FileAnyInfoKind.unusedIgnore */,
file,
});
}
}
}
correctCount += context.typeCheckResult.correctCount;

@@ -195,2 +209,3 @@ totalCount += context.typeCheckResult.totalCount;

reportSemanticError: false,
reportUnusedIgnore: false,
};

@@ -235,3 +250,3 @@ /**

for (const { sourceFile, file } of sourceFileInfos) {
const ingoreMap = (0, ignore_1.collectIgnoreMap)(sourceFile, file);
const ignoreLines = (0, ignore_1.collectIgnoreLines)(sourceFile);
const context = {

@@ -252,3 +267,3 @@ file,

checker,
ingoreMap,
ignoreLines,
ignoreNested: lintOptions.ignoreNested,

@@ -255,0 +270,0 @@ ignoreAsAssertion: lintOptions.ignoreAsAssertion,

import * as ts from 'typescript';
export declare function collectIgnoreMap(sourceFile: ts.SourceFile, file: string): {
[file: string]: Set<number>;
};
export declare function collectIgnoreLines(sourceFile: ts.SourceFile): Set<number> | undefined;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.collectIgnoreMap = void 0;
exports.collectIgnoreLines = void 0;
const ts = require("typescript");
const utils = require("tsutils/util");
function collectIgnoreMap(sourceFile, file) {
const ingoreMap = {};
function collectIgnoreLines(sourceFile) {
let ignoreLines;
utils.forEachComment(sourceFile, (_, comment) => {
var _a, _b;
const commentText = comment.kind === ts.SyntaxKind.SingleLineCommentTrivia

@@ -14,18 +13,18 @@ ? sourceFile.text.substring(comment.pos + 2, comment.end).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;
(_a = ingoreMap[file]) === null || _a === void 0 ? void 0 : _a.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;
(_b = ingoreMap[file]) === null || _b === void 0 ? void 0 : _b.add(line);
ignoreLines.add(line);
}
});
return ingoreMap;
return ignoreLines;
}
exports.collectIgnoreMap = collectIgnoreMap;
exports.collectIgnoreLines = collectIgnoreLines;

@@ -28,3 +28,4 @@ import * as ts from 'typescript';

unsafeNonNull = 5,// foo!
semanticError = 6
semanticError = 6,
unusedIgnore = 7
}

@@ -43,2 +44,3 @@ /**

reportSemanticError: boolean;
reportUnusedIgnore: boolean;
cacheDirectory?: string;

@@ -86,5 +88,4 @@ notOnlyInCWD?: boolean;

};
ingoreMap: {
[file: string]: Set<number>;
};
ignoreLines?: Set<number>;
usedIgnoreLines?: Set<number>;
}

@@ -91,0 +92,0 @@ interface TypeCheckCache extends FileTypeCheckResult {

{
"name": "type-coverage-core",
"version": "2.27.2",
"version": "2.28.0",
"description": "A library to check type coverage for typescript code",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc