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,120 +1,126 @@
1
- import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
- import { TypeScriptClient } from "./typescript-client.js";
1
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
3
2
  import { createTempFile, setupTestEnvironment } from "./test-utils.js";
3
+ import { TypeScriptClient } from "./typescript-client.js";
4
4
 
5
5
  describe("TypeScriptClient", () => {
6
- let client: TypeScriptClient;
7
- let tmpDir: string;
8
- let cleanup: () => void;
9
-
10
- beforeEach(() => {
11
- client = new TypeScriptClient();
12
- ({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-ts-test-"));
13
- });
14
-
15
- afterEach(() => {
16
- cleanup();
17
- });
18
-
19
- afterEach(() => {
20
- cleanup();
21
- });
22
-
23
- describe("isTypeScriptFile", () => {
24
- it("should recognize TypeScript files", () => {
25
- expect(client.isTypeScriptFile("test.ts")).toBe(true);
26
- expect(client.isTypeScriptFile("test.tsx")).toBe(true);
27
- });
28
-
29
- it("should also recognize JavaScript files (for type checking)", () => {
30
- expect(client.isTypeScriptFile("test.js")).toBe(true);
31
- expect(client.isTypeScriptFile("test.jsx")).toBe(true);
32
- });
33
-
34
- it("should not recognize non-JS/TS files", () => {
35
- expect(client.isTypeScriptFile("test.py")).toBe(false);
36
- expect(client.isTypeScriptFile("test.md")).toBe(false);
37
- });
38
- });
39
-
40
- describe("updateFile and getDiagnostics", () => {
41
- it("should detect type errors", () => {
42
- const content = `
6
+ let client: TypeScriptClient;
7
+ let tmpDir: string;
8
+ let cleanup: () => void;
9
+
10
+ beforeEach(() => {
11
+ client = new TypeScriptClient();
12
+ ({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-ts-test-"));
13
+ });
14
+
15
+ afterEach(() => {
16
+ cleanup();
17
+ });
18
+
19
+ afterEach(() => {
20
+ cleanup();
21
+ });
22
+
23
+ describe("isTypeScriptFile", () => {
24
+ it("should recognize TypeScript files", () => {
25
+ expect(client.isTypeScriptFile("test.ts")).toBe(true);
26
+ expect(client.isTypeScriptFile("test.tsx")).toBe(true);
27
+ });
28
+
29
+ it("should also recognize JavaScript files (for type checking)", () => {
30
+ expect(client.isTypeScriptFile("test.js")).toBe(true);
31
+ expect(client.isTypeScriptFile("test.jsx")).toBe(true);
32
+ });
33
+
34
+ it("should not recognize non-JS/TS files", () => {
35
+ expect(client.isTypeScriptFile("test.py")).toBe(false);
36
+ expect(client.isTypeScriptFile("test.md")).toBe(false);
37
+ });
38
+ });
39
+
40
+ describe("updateFile and getDiagnostics", () => {
41
+ it("should detect type errors", () => {
42
+ const content = `
43
43
  const x: number = "string"; // Type error
44
44
  `;
45
- const filePath = createTempFile(tmpDir, "test.ts", content);
45
+ const filePath = createTempFile(tmpDir, "test.ts", content);
46
46
 
47
- client.updateFile(filePath, content);
48
- const diags = client.getDiagnostics(filePath);
47
+ client.updateFile(filePath, content);
48
+ const diags = client.getDiagnostics(filePath);
49
49
 
50
- expect(diags.length).toBeGreaterThan(0);
51
- expect(diags.some(d => d.message.includes("string"))).toBe(true);
52
- });
50
+ expect(diags.length).toBeGreaterThan(0);
51
+ expect(diags.some((d) => d.message.includes("string"))).toBe(true);
52
+ });
53
53
 
54
- it("should not report errors for valid code", () => {
55
- const content = `
54
+ it("should not report errors for valid code", () => {
55
+ const content = `
56
56
  const x: number = 42;
57
57
  const y: string = "hello";
58
58
  `;
59
- const filePath = createTempFile(tmpDir, "test.ts", content);
59
+ const filePath = createTempFile(tmpDir, "test.ts", content);
60
60
 
61
- client.updateFile(filePath, content);
62
- const diags = client.getDiagnostics(filePath);
61
+ client.updateFile(filePath, content);
62
+ const diags = client.getDiagnostics(filePath);
63
63
 
64
- // May have warnings but no errors for valid code
65
- const errors = diags.filter(d => d.severity === 1); // Error severity
66
- expect(errors.length).toBe(0);
67
- });
64
+ // May have warnings but no errors for valid code
65
+ const errors = diags.filter((d) => d.severity === 1); // Error severity
66
+ expect(errors.length).toBe(0);
67
+ });
68
68
 
69
- it("should detect undefined variables", () => {
70
- const content = `
69
+ it("should detect undefined variables", () => {
70
+ const content = `
71
71
  function test() {
72
72
  return undefinedVariable;
73
73
  }
74
74
  `;
75
- const filePath = createTempFile(tmpDir, "test.ts", content);
75
+ const filePath = createTempFile(tmpDir, "test.ts", content);
76
76
 
77
- client.updateFile(filePath, content);
78
- const diags = client.getDiagnostics(filePath);
77
+ client.updateFile(filePath, content);
78
+ const diags = client.getDiagnostics(filePath);
79
79
 
80
- expect(diags.some(d => d.message.includes("undefined"))).toBe(true);
81
- });
80
+ expect(diags.some((d) => d.message.includes("undefined"))).toBe(true);
81
+ });
82
82
 
83
- it("should detect missing function arguments", () => {
84
- const content = `
83
+ it("should detect missing function arguments", () => {
84
+ const content = `
85
85
  function add(a: number, b: number): number {
86
86
  return a + b;
87
87
  }
88
88
  const result = add(1);
89
89
  `;
90
- const filePath = createTempFile(tmpDir, "test.ts", content);
91
-
92
- client.updateFile(filePath, content);
93
- const diags = client.getDiagnostics(filePath);
94
-
95
- expect(diags.some(d => d.message.includes("Expected"))).toBe(true);
96
- });
97
- });
98
-
99
- describe("diagnostic severity", () => {
100
- it("should have correct severity levels", () => {
101
- const diags = [
102
- {
103
- range: { start: { line: 0, character: 0 }, end: { line: 0, character: 10 } },
104
- severity: 1, // Error
105
- message: "Error message",
106
- },
107
- {
108
- range: { start: { line: 1, character: 0 }, end: { line: 1, character: 10 } },
109
- severity: 2, // Warning
110
- message: "Warning message",
111
- },
112
- ];
113
-
114
- // Test that diagnostics have expected structure
115
- expect(diags[0].severity).toBe(1); // Error
116
- expect(diags[1].severity).toBe(2); // Warning
117
- expect(diags[0].message).toContain("Error");
118
- });
119
- });
90
+ const filePath = createTempFile(tmpDir, "test.ts", content);
91
+
92
+ client.updateFile(filePath, content);
93
+ const diags = client.getDiagnostics(filePath);
94
+
95
+ expect(diags.some((d) => d.message.includes("Expected"))).toBe(true);
96
+ });
97
+ });
98
+
99
+ describe("diagnostic severity", () => {
100
+ it("should have correct severity levels", () => {
101
+ const diags = [
102
+ {
103
+ range: {
104
+ start: { line: 0, character: 0 },
105
+ end: { line: 0, character: 10 },
106
+ },
107
+ severity: 1, // Error
108
+ message: "Error message",
109
+ },
110
+ {
111
+ range: {
112
+ start: { line: 1, character: 0 },
113
+ end: { line: 1, character: 10 },
114
+ },
115
+ severity: 2, // Warning
116
+ message: "Warning message",
117
+ },
118
+ ];
119
+
120
+ // Test that diagnostics have expected structure
121
+ expect(diags[0].severity).toBe(1); // Error
122
+ expect(diags[1].severity).toBe(2); // Warning
123
+ expect(diags[0].message).toContain("Error");
124
+ });
125
+ });
120
126
  });