technical-debt-radar 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +32 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17804,6 +17804,8 @@ var require_dead_code_detector = __commonJS({
|
|
|
17804
17804
|
const sf = sourceFiles.get(filePath);
|
|
17805
17805
|
if (sf && exp.type === "class" && isNestJSDIRegistered(sf, exp.name))
|
|
17806
17806
|
continue;
|
|
17807
|
+
if (sf && isReferencedInOwnFile(sf, exp.name))
|
|
17808
|
+
continue;
|
|
17807
17809
|
unusedExports.push({
|
|
17808
17810
|
export: exp,
|
|
17809
17811
|
file: filePath,
|
|
@@ -17985,6 +17987,30 @@ var require_dead_code_detector = __commonJS({
|
|
|
17985
17987
|
function isTypeExport(type) {
|
|
17986
17988
|
return type === "type" || type === "interface" || type === "enum";
|
|
17987
17989
|
}
|
|
17990
|
+
function isReferencedInOwnFile(sourceFile, exportName) {
|
|
17991
|
+
const identifiers = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.Identifier).filter((id) => id.getText() === exportName);
|
|
17992
|
+
let declarationCount = 0;
|
|
17993
|
+
let totalCount = 0;
|
|
17994
|
+
for (const id of identifiers) {
|
|
17995
|
+
totalCount++;
|
|
17996
|
+
const parent = id.getParent();
|
|
17997
|
+
if (!parent)
|
|
17998
|
+
continue;
|
|
17999
|
+
const parentKind = parent.getKind();
|
|
18000
|
+
if (parentKind === ts_morph_1.SyntaxKind.ClassDeclaration || parentKind === ts_morph_1.SyntaxKind.FunctionDeclaration || parentKind === ts_morph_1.SyntaxKind.VariableDeclaration || parentKind === ts_morph_1.SyntaxKind.EnumDeclaration || parentKind === ts_morph_1.SyntaxKind.InterfaceDeclaration || parentKind === ts_morph_1.SyntaxKind.TypeAliasDeclaration) {
|
|
18001
|
+
const nameNode = parent.getNameNode?.();
|
|
18002
|
+
if (nameNode && nameNode.getPos() === id.getPos()) {
|
|
18003
|
+
declarationCount++;
|
|
18004
|
+
continue;
|
|
18005
|
+
}
|
|
18006
|
+
}
|
|
18007
|
+
if (parentKind === ts_morph_1.SyntaxKind.ExportSpecifier) {
|
|
18008
|
+
declarationCount++;
|
|
18009
|
+
continue;
|
|
18010
|
+
}
|
|
18011
|
+
}
|
|
18012
|
+
return totalCount > declarationCount;
|
|
18013
|
+
}
|
|
17988
18014
|
function parsePathAliases(input, projectRoot) {
|
|
17989
18015
|
let tsconfigContent;
|
|
17990
18016
|
const tsconfigFile = input.changedFiles.find((f) => f.status !== "deleted" && /tsconfig(?:\.build)?\.json$/.test(f.path));
|
|
@@ -18096,8 +18122,13 @@ var require_dead_code_detector = __commonJS({
|
|
|
18096
18122
|
return resolveInProject(resolved, project) ?? resolved;
|
|
18097
18123
|
}
|
|
18098
18124
|
if (aliases.length > 0) {
|
|
18099
|
-
|
|
18125
|
+
const aliasResolved = resolvePathAlias(specifier, aliases, project);
|
|
18126
|
+
if (aliasResolved)
|
|
18127
|
+
return aliasResolved;
|
|
18100
18128
|
}
|
|
18129
|
+
const directResolved = resolveInProject(specifier, project);
|
|
18130
|
+
if (directResolved)
|
|
18131
|
+
return directResolved;
|
|
18101
18132
|
return void 0;
|
|
18102
18133
|
}
|
|
18103
18134
|
function resolveInProject(resolved, project) {
|