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.
- package/clients/ast-grep-client.test.ts +146 -116
- package/clients/ast-grep-client.ts +645 -551
- package/clients/biome-client.test.ts +154 -137
- package/clients/biome-client.ts +397 -337
- package/clients/complexity-client.test.ts +188 -200
- package/clients/complexity-client.ts +815 -667
- package/clients/dependency-checker.test.ts +55 -55
- package/clients/dependency-checker.ts +358 -333
- package/clients/go-client.test.ts +121 -111
- package/clients/go-client.ts +218 -216
- package/clients/jscpd-client.test.ts +132 -132
- package/clients/jscpd-client.ts +155 -118
- package/clients/knip-client.test.ts +123 -133
- package/clients/knip-client.ts +231 -218
- package/clients/metrics-client.test.ts +171 -167
- package/clients/metrics-client.ts +283 -252
- package/clients/ruff-client.test.ts +128 -117
- package/clients/ruff-client.ts +300 -269
- package/clients/rust-client.test.ts +104 -85
- package/clients/rust-client.ts +241 -234
- package/clients/subprocess-client.ts +1 -1
- package/clients/test-runner-client.test.ts +248 -215
- package/clients/test-runner-client.ts +728 -608
- package/clients/test-utils.ts +10 -3
- package/clients/todo-scanner.test.ts +288 -202
- package/clients/todo-scanner.ts +225 -187
- package/clients/type-coverage-client.test.ts +119 -119
- package/clients/type-coverage-client.ts +142 -115
- package/clients/types.ts +28 -28
- package/clients/typescript-client.test.ts +99 -93
- package/clients/typescript-client.ts +527 -502
- package/index.ts +662 -212
- package/package.json +1 -1
- package/tsconfig.json +12 -12
|
@@ -1,144 +1,161 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
});
|