pi-lens 2.0.7 → 2.0.8

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.
Files changed (34) hide show
  1. package/clients/ast-grep-client.test.ts +146 -116
  2. package/clients/ast-grep-client.ts +645 -551
  3. package/clients/biome-client.test.ts +154 -137
  4. package/clients/biome-client.ts +397 -337
  5. package/clients/complexity-client.test.ts +188 -200
  6. package/clients/complexity-client.ts +815 -667
  7. package/clients/dependency-checker.test.ts +55 -55
  8. package/clients/dependency-checker.ts +358 -333
  9. package/clients/go-client.test.ts +121 -111
  10. package/clients/go-client.ts +218 -216
  11. package/clients/jscpd-client.test.ts +132 -132
  12. package/clients/jscpd-client.ts +155 -118
  13. package/clients/knip-client.test.ts +123 -133
  14. package/clients/knip-client.ts +231 -218
  15. package/clients/metrics-client.test.ts +171 -167
  16. package/clients/metrics-client.ts +283 -252
  17. package/clients/ruff-client.test.ts +128 -117
  18. package/clients/ruff-client.ts +300 -269
  19. package/clients/rust-client.test.ts +104 -85
  20. package/clients/rust-client.ts +241 -234
  21. package/clients/subprocess-client.ts +1 -1
  22. package/clients/test-runner-client.test.ts +248 -215
  23. package/clients/test-runner-client.ts +728 -608
  24. package/clients/test-utils.ts +10 -3
  25. package/clients/todo-scanner.test.ts +288 -202
  26. package/clients/todo-scanner.ts +225 -187
  27. package/clients/type-coverage-client.test.ts +119 -119
  28. package/clients/type-coverage-client.ts +142 -115
  29. package/clients/types.ts +28 -28
  30. package/clients/typescript-client.test.ts +99 -93
  31. package/clients/typescript-client.ts +527 -502
  32. package/index.ts +662 -212
  33. package/package.json +1 -1
  34. package/tsconfig.json +12 -12
@@ -1,138 +1,128 @@
1
- import { describe, it, expect, beforeEach, afterEach } from "vitest";
1
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
2
  import { KnipClient } from "./knip-client.js";
3
3
  import { setupTestEnvironment } from "./test-utils.js";
4
4
 
5
5
  describe("KnipClient", () => {
6
- let client: KnipClient;
7
- let tmpDir: string;
8
- let cleanup: () => void;
9
-
10
- beforeEach(() => {
11
- client = new KnipClient();
12
- ({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-knip-test-"));
13
- });
14
-
15
- afterEach(() => {
16
- cleanup();
17
- });
18
-
19
- afterEach(() => {
20
- cleanup();
21
- });
22
-
23
- describe("isAvailable", () => {
24
- it("should check knip availability", () => {
25
- const available = client.isAvailable();
26
- expect(typeof available).toBe("boolean");
27
- });
28
- });
29
-
30
- describe("analyze", () => {
31
- it("should return success=false when not available", () => {
32
- const mockClient = new KnipClient();
33
- if (mockClient.isAvailable()) return;
34
-
35
- const result = mockClient.analyze(tmpDir);
36
- expect(result.success).toBe(false);
37
- });
38
- });
39
-
40
- describe("formatResult", () => {
41
- it("should return empty string for no issues", () => {
42
- const result = {
43
- success: true,
44
- issues: [],
45
- unusedExports: [],
46
- unusedFiles: [],
47
- unusedDeps: [],
48
- unlistedDeps: [],
49
- summary: "",
50
- };
51
-
52
- expect(client.formatResult(result)).toBe("");
53
- });
54
-
55
- it("should format unused exports", () => {
56
- const result = {
57
- success: true,
58
- issues: [
59
- { type: "export" as const, name: "unusedFunc", file: "utils.ts" },
60
- ],
61
- unusedExports: [
62
- { type: "export" as const, name: "unusedFunc", file: "utils.ts" },
63
- ],
64
- unusedFiles: [],
65
- unusedDeps: [],
66
- unlistedDeps: [],
67
- summary: "Found 1 issue",
68
- };
69
-
70
- const formatted = client.formatResult(result);
71
- expect(formatted).toContain("Knip");
72
- expect(formatted).toContain("unusedFunc");
73
- });
74
-
75
- it("should format unused dependencies", () => {
76
- const result = {
77
- success: true,
78
- issues: [
79
- { type: "dependency" as const, name: "lodash" },
80
- ],
81
- unusedExports: [],
82
- unusedFiles: [],
83
- unusedDeps: [
84
- { type: "dependency" as const, name: "lodash" },
85
- ],
86
- unlistedDeps: [],
87
- summary: "",
88
- };
89
-
90
- const formatted = client.formatResult(result);
91
- expect(formatted).toContain("lodash");
92
- expect(formatted).toContain("unused dep");
93
- });
94
-
95
- it("should show unlisted dependencies count", () => {
96
- const result = {
97
- success: true,
98
- issues: [
99
- { type: "unlisted" as const, name: "axios" },
100
- ],
101
- unusedExports: [],
102
- unusedFiles: [],
103
- unusedDeps: [],
104
- unlistedDeps: [
105
- { type: "unlisted" as const, name: "axios" },
106
- ],
107
- summary: "",
108
- };
109
-
110
- const formatted = client.formatResult(result);
111
- expect(formatted).toContain("unlisted dep");
112
- });
113
-
114
- it("should format multiple issue types", () => {
115
- const result = {
116
- success: true,
117
- issues: [
118
- { type: "export" as const, name: "func1", file: "a.ts" },
119
- { type: "file" as const, name: "old.ts" },
120
- ],
121
- unusedExports: [
122
- { type: "export" as const, name: "func1", file: "a.ts" },
123
- { type: "export" as const, name: "func2", file: "b.ts" },
124
- ],
125
- unusedFiles: [
126
- { type: "file" as const, name: "old.ts" },
127
- ],
128
- unusedDeps: [],
129
- unlistedDeps: [],
130
- summary: "",
131
- };
132
-
133
- const formatted = client.formatResult(result);
134
- expect(formatted).toContain("2 unused export(s)");
135
- expect(formatted).toContain("1 unused file(s)");
136
- });
137
- });
6
+ let client: KnipClient;
7
+ let tmpDir: string;
8
+ let cleanup: () => void;
9
+
10
+ beforeEach(() => {
11
+ client = new KnipClient();
12
+ ({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-knip-test-"));
13
+ });
14
+
15
+ afterEach(() => {
16
+ cleanup();
17
+ });
18
+
19
+ afterEach(() => {
20
+ cleanup();
21
+ });
22
+
23
+ describe("isAvailable", () => {
24
+ it("should check knip availability", () => {
25
+ const available = client.isAvailable();
26
+ expect(typeof available).toBe("boolean");
27
+ });
28
+ });
29
+
30
+ describe("analyze", () => {
31
+ it("should return success=false when not available", () => {
32
+ const mockClient = new KnipClient();
33
+ if (mockClient.isAvailable()) return;
34
+
35
+ const result = mockClient.analyze(tmpDir);
36
+ expect(result.success).toBe(false);
37
+ });
38
+ });
39
+
40
+ describe("formatResult", () => {
41
+ it("should return empty string for no issues", () => {
42
+ const result = {
43
+ success: true,
44
+ issues: [],
45
+ unusedExports: [],
46
+ unusedFiles: [],
47
+ unusedDeps: [],
48
+ unlistedDeps: [],
49
+ summary: "",
50
+ };
51
+
52
+ expect(client.formatResult(result)).toBe("");
53
+ });
54
+
55
+ it("should format unused exports", () => {
56
+ const result = {
57
+ success: true,
58
+ issues: [
59
+ { type: "export" as const, name: "unusedFunc", file: "utils.ts" },
60
+ ],
61
+ unusedExports: [
62
+ { type: "export" as const, name: "unusedFunc", file: "utils.ts" },
63
+ ],
64
+ unusedFiles: [],
65
+ unusedDeps: [],
66
+ unlistedDeps: [],
67
+ summary: "Found 1 issue",
68
+ };
69
+
70
+ const formatted = client.formatResult(result);
71
+ expect(formatted).toContain("Knip");
72
+ expect(formatted).toContain("unusedFunc");
73
+ });
74
+
75
+ it("should format unused dependencies", () => {
76
+ const result = {
77
+ success: true,
78
+ issues: [{ type: "dependency" as const, name: "lodash" }],
79
+ unusedExports: [],
80
+ unusedFiles: [],
81
+ unusedDeps: [{ type: "dependency" as const, name: "lodash" }],
82
+ unlistedDeps: [],
83
+ summary: "",
84
+ };
85
+
86
+ const formatted = client.formatResult(result);
87
+ expect(formatted).toContain("lodash");
88
+ expect(formatted).toContain("unused dep");
89
+ });
90
+
91
+ it("should show unlisted dependencies count", () => {
92
+ const result = {
93
+ success: true,
94
+ issues: [{ type: "unlisted" as const, name: "axios" }],
95
+ unusedExports: [],
96
+ unusedFiles: [],
97
+ unusedDeps: [],
98
+ unlistedDeps: [{ type: "unlisted" as const, name: "axios" }],
99
+ summary: "",
100
+ };
101
+
102
+ const formatted = client.formatResult(result);
103
+ expect(formatted).toContain("unlisted dep");
104
+ });
105
+
106
+ it("should format multiple issue types", () => {
107
+ const result = {
108
+ success: true,
109
+ issues: [
110
+ { type: "export" as const, name: "func1", file: "a.ts" },
111
+ { type: "file" as const, name: "old.ts" },
112
+ ],
113
+ unusedExports: [
114
+ { type: "export" as const, name: "func1", file: "a.ts" },
115
+ { type: "export" as const, name: "func2", file: "b.ts" },
116
+ ],
117
+ unusedFiles: [{ type: "file" as const, name: "old.ts" }],
118
+ unusedDeps: [],
119
+ unlistedDeps: [],
120
+ summary: "",
121
+ };
122
+
123
+ const formatted = client.formatResult(result);
124
+ expect(formatted).toContain("2 unused export(s)");
125
+ expect(formatted).toContain("1 unused file(s)");
126
+ });
127
+ });
138
128
  });