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,144 +1,161 @@
1
- import { describe, it, expect, beforeEach, afterEach } from "vitest";
1
+ import * as fs from "node:fs";
2
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
3
  import { BiomeClient } from "./biome-client.js";
3
4
  import { createTempFile, setupTestEnvironment } from "./test-utils.js";
4
- import * as fs from "node:fs";
5
- import * as path from "node:path";
6
5
 
7
6
  describe("BiomeClient", () => {
8
- let client: BiomeClient;
9
- let tmpDir: string;
10
- let cleanup: () => void;
11
-
12
- beforeEach(() => {
13
- client = new BiomeClient();
14
- ({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-biome-test-"));
15
- });
16
-
17
- afterEach(() => {
18
- cleanup();
19
- });
20
-
21
- afterEach(() => {
22
- cleanup();
23
- });
24
-
25
- describe("isSupportedFile", () => {
26
- it("should support JS/TS files", () => {
27
- expect(client.isSupportedFile("test.js")).toBe(true);
28
- expect(client.isSupportedFile("test.jsx")).toBe(true);
29
- expect(client.isSupportedFile("test.ts")).toBe(true);
30
- expect(client.isSupportedFile("test.tsx")).toBe(true);
31
- expect(client.isSupportedFile("test.mjs")).toBe(true);
32
- expect(client.isSupportedFile("test.cjs")).toBe(true);
33
- });
34
-
35
- it("should support CSS and JSON", () => {
36
- expect(client.isSupportedFile("style.css")).toBe(true);
37
- expect(client.isSupportedFile("config.json")).toBe(true);
38
- });
39
-
40
- it("should not support unsupported files", () => {
41
- expect(client.isSupportedFile("test.py")).toBe(false);
42
- expect(client.isSupportedFile("test.md")).toBe(false);
43
- expect(client.isSupportedFile("test.txt")).toBe(false);
44
- });
45
- });
46
-
47
- describe("isAvailable", () => {
48
- it("should check biome availability", () => {
49
- const available = client.isAvailable();
50
- // Just verify it doesn't throw - actual availability depends on environment
51
- expect(typeof available).toBe("boolean");
52
- });
53
- });
54
-
55
- describe("checkFile", () => {
56
- it("should return empty array for non-existent files", () => {
57
- if (!client.isAvailable()) return;
58
- const result = client.checkFile("/nonexistent/file.ts");
59
- expect(result).toEqual([]);
60
- });
61
-
62
- it("should return array of diagnostics for TS files", () => {
63
- if (!client.isAvailable()) return;
64
-
65
- const content = `
7
+ let client: BiomeClient;
8
+ let tmpDir: string;
9
+ let cleanup: () => void;
10
+
11
+ beforeEach(() => {
12
+ client = new BiomeClient();
13
+ ({ tmpDir, cleanup } = setupTestEnvironment("pi-lens-biome-test-"));
14
+ });
15
+
16
+ afterEach(() => {
17
+ cleanup();
18
+ });
19
+
20
+ afterEach(() => {
21
+ cleanup();
22
+ });
23
+
24
+ describe("isSupportedFile", () => {
25
+ it("should support JS/TS files", () => {
26
+ expect(client.isSupportedFile("test.js")).toBe(true);
27
+ expect(client.isSupportedFile("test.jsx")).toBe(true);
28
+ expect(client.isSupportedFile("test.ts")).toBe(true);
29
+ expect(client.isSupportedFile("test.tsx")).toBe(true);
30
+ expect(client.isSupportedFile("test.mjs")).toBe(true);
31
+ expect(client.isSupportedFile("test.cjs")).toBe(true);
32
+ });
33
+
34
+ it("should support CSS and JSON", () => {
35
+ expect(client.isSupportedFile("style.css")).toBe(true);
36
+ expect(client.isSupportedFile("config.json")).toBe(true);
37
+ });
38
+
39
+ it("should not support unsupported files", () => {
40
+ expect(client.isSupportedFile("test.py")).toBe(false);
41
+ expect(client.isSupportedFile("test.md")).toBe(false);
42
+ expect(client.isSupportedFile("test.txt")).toBe(false);
43
+ });
44
+ });
45
+
46
+ describe("isAvailable", () => {
47
+ it("should check biome availability", () => {
48
+ const available = client.isAvailable();
49
+ // Just verify it doesn't throw - actual availability depends on environment
50
+ expect(typeof available).toBe("boolean");
51
+ });
52
+ });
53
+
54
+ describe("checkFile", () => {
55
+ it("should return empty array for non-existent files", () => {
56
+ if (!client.isAvailable()) return;
57
+ const result = client.checkFile("/nonexistent/file.ts");
58
+ expect(result).toEqual([]);
59
+ });
60
+
61
+ it("should return array of diagnostics for TS files", () => {
62
+ if (!client.isAvailable()) return;
63
+
64
+ const content = `
66
65
  const x: number = "string";
67
66
  `;
68
- const filePath = createTempFile(tmpDir, "test.ts", content);
69
- const result = client.checkFile(filePath);
70
-
71
- // Should return an array (may or may not have issues)
72
- expect(Array.isArray(result)).toBe(true);
73
- });
74
- });
75
-
76
- describe("formatDiagnostics", () => {
77
- it("should format diagnostics for display", () => {
78
- const diags = [
79
- {
80
- line: 1,
81
- column: 0,
82
- endLine: 1,
83
- endColumn: 10,
84
- severity: "error" as const,
85
- message: "Unexpected var",
86
- rule: "noVar",
87
- category: "lint" as const,
88
- fixable: true,
89
- },
90
- ];
91
-
92
- const formatted = client.formatDiagnostics(diags, "test.ts");
93
- expect(formatted).toContain("Biome");
94
- expect(formatted).toContain("1 issue");
95
- expect(formatted).toContain("noVar");
96
- });
97
-
98
- it("should show fixable count", () => {
99
- const diags = [
100
- {
101
- line: 1, column: 0, endLine: 1, endColumn: 10,
102
- severity: "error" as const, message: "Error 1", rule: "rule1",
103
- category: "lint" as const, fixable: true,
104
- },
105
- {
106
- line: 2, column: 0, endLine: 2, endColumn: 10,
107
- severity: "warning" as const, message: "Warning 1", rule: "rule2",
108
- category: "lint" as const, fixable: false,
109
- },
110
- ];
111
-
112
- const formatted = client.formatDiagnostics(diags, "test.ts");
113
- expect(formatted).toContain("1 fixable");
114
- });
115
-
116
- it("should truncate long diagnostic lists", () => {
117
- const diags = Array.from({ length: 20 }, (_, i) => ({
118
- line: i + 1, column: 0, endLine: i + 1, endColumn: 10,
119
- severity: "warning" as const, message: `Warning ${i}`, rule: `rule${i}`,
120
- category: "lint" as const, fixable: false,
121
- }));
122
-
123
- const formatted = client.formatDiagnostics(diags, "test.ts");
124
- expect(formatted).toContain("...");
125
- expect(formatted).toContain("5 more");
126
- });
127
- });
128
-
129
- describe("formatFile", () => {
130
- it("should format a file", () => {
131
- if (!client.isAvailable()) return;
132
-
133
- const content = `const x={a:1,b:2}`;
134
- const filePath = createTempFile(tmpDir, "test.ts", content);
135
-
136
- const result = client.formatFile(filePath);
137
- expect(result.success).toBe(true);
138
-
139
- // Check if file was formatted (should have spaces)
140
- const formatted = fs.readFileSync(filePath, "utf-8");
141
- expect(formatted).toContain(": "); // Should have spaces after colons
142
- });
143
- });
67
+ const filePath = createTempFile(tmpDir, "test.ts", content);
68
+ const result = client.checkFile(filePath);
69
+
70
+ // Should return an array (may or may not have issues)
71
+ expect(Array.isArray(result)).toBe(true);
72
+ });
73
+ });
74
+
75
+ describe("formatDiagnostics", () => {
76
+ it("should format diagnostics for display", () => {
77
+ const diags = [
78
+ {
79
+ line: 1,
80
+ column: 0,
81
+ endLine: 1,
82
+ endColumn: 10,
83
+ severity: "error" as const,
84
+ message: "Unexpected var",
85
+ rule: "noVar",
86
+ category: "lint" as const,
87
+ fixable: true,
88
+ },
89
+ ];
90
+
91
+ const formatted = client.formatDiagnostics(diags, "test.ts");
92
+ expect(formatted).toContain("Biome");
93
+ expect(formatted).toContain("1 issue");
94
+ expect(formatted).toContain("noVar");
95
+ });
96
+
97
+ it("should show fixable count", () => {
98
+ const diags = [
99
+ {
100
+ line: 1,
101
+ column: 0,
102
+ endLine: 1,
103
+ endColumn: 10,
104
+ severity: "error" as const,
105
+ message: "Error 1",
106
+ rule: "rule1",
107
+ category: "lint" as const,
108
+ fixable: true,
109
+ },
110
+ {
111
+ line: 2,
112
+ column: 0,
113
+ endLine: 2,
114
+ endColumn: 10,
115
+ severity: "warning" as const,
116
+ message: "Warning 1",
117
+ rule: "rule2",
118
+ category: "lint" as const,
119
+ fixable: false,
120
+ },
121
+ ];
122
+
123
+ const formatted = client.formatDiagnostics(diags, "test.ts");
124
+ expect(formatted).toContain("1 fixable");
125
+ });
126
+
127
+ it("should truncate long diagnostic lists", () => {
128
+ const diags = Array.from({ length: 20 }, (_, i) => ({
129
+ line: i + 1,
130
+ column: 0,
131
+ endLine: i + 1,
132
+ endColumn: 10,
133
+ severity: "warning" as const,
134
+ message: `Warning ${i}`,
135
+ rule: `rule${i}`,
136
+ category: "lint" as const,
137
+ fixable: false,
138
+ }));
139
+
140
+ const formatted = client.formatDiagnostics(diags, "test.ts");
141
+ expect(formatted).toContain("...");
142
+ expect(formatted).toContain("5 more");
143
+ });
144
+ });
145
+
146
+ describe("formatFile", () => {
147
+ it("should format a file", () => {
148
+ if (!client.isAvailable()) return;
149
+
150
+ const content = `const x={a:1,b:2}`;
151
+ const filePath = createTempFile(tmpDir, "test.ts", content);
152
+
153
+ const result = client.formatFile(filePath);
154
+ expect(result.success).toBe(true);
155
+
156
+ // Check if file was formatted (should have spaces)
157
+ const formatted = fs.readFileSync(filePath, "utf-8");
158
+ expect(formatted).toContain(": "); // Should have spaces after colons
159
+ });
160
+ });
144
161
  });