ts-unused 1.0.0 → 1.0.2
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/README.md +67 -2
- package/dist/analyzeFunctionReturnTypes.d.ts +6 -0
- package/dist/analyzeInterfaces.d.ts +3 -0
- package/dist/analyzeProject.d.ts +2 -0
- package/dist/analyzeTypeAliases.d.ts +5 -0
- package/dist/checkExportUsage.d.ts +3 -0
- package/dist/checkGitStatus.d.ts +7 -0
- package/dist/cli.js +477 -64
- package/dist/extractTodoComment.d.ts +6 -0
- package/dist/findNeverReturnedTypes.d.ts +3 -0
- package/dist/findStructurallyEquivalentProperties.d.ts +12 -0
- package/dist/findUnusedExports.d.ts +3 -0
- package/dist/findUnusedProperties.d.ts +3 -0
- package/dist/fixProject.d.ts +13 -0
- package/dist/formatResults.d.ts +2 -0
- package/dist/hasNoCheck.d.ts +2 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1251 -0
- package/dist/isPropertyUnused.d.ts +7 -0
- package/dist/isTestFile.d.ts +2 -0
- package/dist/types.d.ts +40 -0
- package/package.json +15 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Project, PropertyDeclaration, PropertySignature } from "ts-morph";
|
|
2
|
+
import type { IsTestFileFn } from "./types";
|
|
3
|
+
export interface PropertyUsageResult {
|
|
4
|
+
isUnusedOrTestOnly: boolean;
|
|
5
|
+
onlyUsedInTests: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function isPropertyUnused(prop: PropertySignature | PropertyDeclaration, isTestFile: IsTestFileFn, project: Project): PropertyUsageResult;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SourceFile } from "ts-morph";
|
|
2
|
+
export type Severity = "error" | "warning" | "info";
|
|
3
|
+
export type ExportKind = "function" | "class" | "interface" | "type" | "const" | "variable" | "enum" | "namespace" | "export";
|
|
4
|
+
export interface UnusedExportResult {
|
|
5
|
+
filePath: string;
|
|
6
|
+
exportName: string;
|
|
7
|
+
line: number;
|
|
8
|
+
character: number;
|
|
9
|
+
endCharacter: number;
|
|
10
|
+
kind: ExportKind;
|
|
11
|
+
severity: Severity;
|
|
12
|
+
onlyUsedInTests: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface UnusedPropertyResult {
|
|
15
|
+
filePath: string;
|
|
16
|
+
typeName: string;
|
|
17
|
+
propertyName: string;
|
|
18
|
+
line: number;
|
|
19
|
+
character: number;
|
|
20
|
+
endCharacter: number;
|
|
21
|
+
todoComment?: string;
|
|
22
|
+
severity: Severity;
|
|
23
|
+
onlyUsedInTests: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface NeverReturnedTypeResult {
|
|
26
|
+
filePath: string;
|
|
27
|
+
functionName: string;
|
|
28
|
+
neverReturnedType: string;
|
|
29
|
+
line: number;
|
|
30
|
+
character: number;
|
|
31
|
+
endCharacter: number;
|
|
32
|
+
severity: Severity;
|
|
33
|
+
}
|
|
34
|
+
export interface AnalysisResults {
|
|
35
|
+
unusedExports: UnusedExportResult[];
|
|
36
|
+
unusedProperties: UnusedPropertyResult[];
|
|
37
|
+
unusedFiles: string[];
|
|
38
|
+
neverReturnedTypes?: NeverReturnedTypeResult[];
|
|
39
|
+
}
|
|
40
|
+
export type IsTestFileFn = (sourceFile: SourceFile) => boolean;
|
package/package.json
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-unused",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Find unused exports and properties in TypeScript projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ts-unused": "dist/cli.js"
|
|
8
8
|
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
9
17
|
"files": [
|
|
10
18
|
"dist"
|
|
11
19
|
],
|
|
12
20
|
"type": "module",
|
|
13
21
|
"scripts": {
|
|
14
22
|
"clean": "rm -rf dist",
|
|
15
|
-
"build:js": "bun build src/cli.ts --outdir dist --target node --external ts-morph --external typescript",
|
|
16
|
-
"build": "
|
|
23
|
+
"build:js": "bun build src/cli.ts --outdir dist --target node --external ts-morph --external typescript && bun build src/index.ts --outdir dist --target node --external ts-morph --external typescript",
|
|
24
|
+
"build:types": "tsgo --project tsconfig.build.json",
|
|
25
|
+
"build": "bun clean && bun build:js && bun build:types",
|
|
17
26
|
"typecheck": "tsgo --noEmit",
|
|
18
27
|
"lint": "bun run fix && biome check src",
|
|
19
28
|
"fix": "biome check --write --unsafe src",
|
|
20
|
-
"sanity-check": "bun run scripts/sanity-check.ts"
|
|
29
|
+
"sanity-check": "bun run scripts/sanity-check.ts",
|
|
30
|
+
"prepublish": "bun lint && bun test && bun run build && bun sanity-check --no-build",
|
|
31
|
+
"cli": "bun run src/cli.ts"
|
|
21
32
|
},
|
|
22
33
|
"devDependencies": {
|
|
23
34
|
"@biomejs/biome": "^2.3.8",
|