Skip to content

Commit e444da0

Browse files
bryan-anthropicbryankthompson
authored andcommitted
fix: resolve linting errors
- Remove duplicate node:path import in test/icon-validation.test.ts - Replace 4 instances of 'any' type with 'unknown' in error handlers - Auto-format code with prettier (27 formatting fixes) Addresses review feedback from PR #136 All 6 errors and 27 warnings resolved
1 parent 95c2faa commit e444da0

4 files changed

Lines changed: 109 additions & 96 deletions

File tree

schemas/mcpb-manifest-v0.2.schema.json

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
},
77
"dxt_version": {
88
"type": "string",
9-
"const": "0.3",
9+
"const": "0.2",
1010
"description": "@deprecated Use manifest_version instead"
1111
},
1212
"manifest_version": {
1313
"type": "string",
14-
"const": "0.3"
14+
"const": "0.2"
1515
},
1616
"name": {
1717
"type": "string"
@@ -80,54 +80,12 @@
8080
"icon": {
8181
"type": "string"
8282
},
83-
"icons": {
84-
"type": "array",
85-
"items": {
86-
"type": "object",
87-
"properties": {
88-
"src": {
89-
"type": "string"
90-
},
91-
"sizes": {
92-
"type": "string",
93-
"pattern": "^\\d+x\\d+$"
94-
},
95-
"theme": {
96-
"type": "string",
97-
"minLength": 1
98-
}
99-
},
100-
"required": [
101-
"src",
102-
"sizes"
103-
],
104-
"additionalProperties": false
105-
}
106-
},
10783
"screenshots": {
10884
"type": "array",
10985
"items": {
11086
"type": "string"
11187
}
11288
},
113-
"localization": {
114-
"type": "object",
115-
"properties": {
116-
"resources": {
117-
"type": "string",
118-
"pattern": "\\$\\{locale\\}"
119-
},
120-
"default_locale": {
121-
"type": "string",
122-
"pattern": "^[A-Za-z0-9]{2,8}(?:-[A-Za-z0-9]{1,8})*$"
123-
}
124-
},
125-
"required": [
126-
"resources",
127-
"default_locale"
128-
],
129-
"additionalProperties": false
130-
},
13189
"server": {
13290
"type": "object",
13391
"properties": {
@@ -355,13 +313,6 @@
355313
],
356314
"additionalProperties": false
357315
}
358-
},
359-
"_meta": {
360-
"type": "object",
361-
"additionalProperties": {
362-
"type": "object",
363-
"additionalProperties": {}
364-
}
365316
}
366317
},
367318
"required": [

src/node/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function validateIcon(
5959
// Check for ${__dirname} variable (error - doesn't work)
6060
if (hasVariableSubstitution) {
6161
errors.push(
62-
'Icon path should not use ${__dirname} variable substitution. ' +
62+
"Icon path should not use ${__dirname} variable substitution. " +
6363
'Use a simple relative path like "icon.png" instead of "${__dirname}/icon.png".',
6464
);
6565
}

test/cli.test.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,12 @@ describe("DXT CLI", () => {
9191

9292
// Create a valid PNG file (1x1 transparent pixel)
9393
const validPngBuffer = Buffer.from([
94-
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
95-
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
96-
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
97-
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
98-
0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41,
99-
0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
100-
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
101-
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
102-
0x42, 0x60, 0x82,
94+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
95+
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
96+
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4, 0x89, 0x00, 0x00, 0x00,
97+
0x0a, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
98+
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x49,
99+
0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
103100
]);
104101
fs.writeFileSync(join(testDir, "icon.png"), validPngBuffer);
105102
});
@@ -127,7 +124,7 @@ describe("DXT CLI", () => {
127124
entry_point: "server/index.js",
128125
mcp_config: { command: "node" },
129126
},
130-
})
127+
}),
131128
);
132129

133130
const result = execSync(`node ${cliPath} validate ${manifestWithIcon}`, {
@@ -154,7 +151,7 @@ describe("DXT CLI", () => {
154151
entry_point: "server/index.js",
155152
mcp_config: { command: "node" },
156153
},
157-
})
154+
}),
158155
);
159156

160157
const result = execSync(`node ${cliPath} validate ${manifestWithUrl}`, {

test/icon-validation.test.ts

Lines changed: 98 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { execSync } from "node:child_process";
22
import fs from "node:fs";
33
import { join } from "node:path";
4-
import path from "node:path";
54

65
describe("Icon Validation", () => {
76
const cliPath = join(__dirname, "../dist/cli/cli.js");
@@ -18,20 +17,81 @@ describe("Icon Validation", () => {
1817

1918
// Create a valid PNG file (1x1 transparent pixel)
2019
const validPngBuffer = Buffer.from([
21-
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, // PNG signature
22-
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, // IHDR chunk
23-
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, // 1x1 dimensions
24-
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
25-
0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41,
26-
0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
27-
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
28-
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
29-
0x42, 0x60, 0x82,
20+
0x89,
21+
0x50,
22+
0x4e,
23+
0x47,
24+
0x0d,
25+
0x0a,
26+
0x1a,
27+
0x0a, // PNG signature
28+
0x00,
29+
0x00,
30+
0x00,
31+
0x0d,
32+
0x49,
33+
0x48,
34+
0x44,
35+
0x52, // IHDR chunk
36+
0x00,
37+
0x00,
38+
0x00,
39+
0x01,
40+
0x00,
41+
0x00,
42+
0x00,
43+
0x01, // 1x1 dimensions
44+
0x08,
45+
0x06,
46+
0x00,
47+
0x00,
48+
0x00,
49+
0x1f,
50+
0x15,
51+
0xc4,
52+
0x89,
53+
0x00,
54+
0x00,
55+
0x00,
56+
0x0a,
57+
0x49,
58+
0x44,
59+
0x41,
60+
0x54,
61+
0x78,
62+
0x9c,
63+
0x63,
64+
0x00,
65+
0x01,
66+
0x00,
67+
0x00,
68+
0x05,
69+
0x00,
70+
0x01,
71+
0x0d,
72+
0x0a,
73+
0x2d,
74+
0xb4,
75+
0x00,
76+
0x00,
77+
0x00,
78+
0x00,
79+
0x49,
80+
0x45,
81+
0x4e,
82+
0x44,
83+
0xae,
84+
0x42,
85+
0x60,
86+
0x82,
3087
]);
3188
fs.writeFileSync(join(testFixturesDir, "valid-icon.png"), validPngBuffer);
3289

3390
// Create an invalid (non-PNG) file
34-
fs.writeFileSync(join(testFixturesDir, "invalid-icon.jpg"), "Not a PNG file");
91+
fs.writeFileSync(
92+
join(testFixturesDir, "invalid-icon.jpg"),
93+
"Not a PNG file",
94+
);
3595

3696
// Create test manifests
3797
createTestManifest("valid-local-icon.json", {
@@ -92,7 +152,7 @@ describe("Icon Validation", () => {
92152

93153
fs.writeFileSync(
94154
join(testFixturesDir, filename),
95-
JSON.stringify(manifest, null, 2)
155+
JSON.stringify(manifest, null, 2),
96156
);
97157
}
98158

@@ -135,7 +195,10 @@ describe("Icon Validation", () => {
135195
});
136196

137197
it("should reject icons with ${__dirname} variable", () => {
138-
const manifestPath = join(testFixturesDir, "invalid-dirname-variable.json");
198+
const manifestPath = join(
199+
testFixturesDir,
200+
"invalid-dirname-variable.json",
201+
);
139202

140203
expect(() => {
141204
execSync(`node ${cliPath} validate ${manifestPath}`, {
@@ -149,8 +212,9 @@ describe("Icon Validation", () => {
149212
encoding: "utf-8",
150213
stdio: "pipe",
151214
});
152-
} catch (error: any) {
153-
const output = error.stdout?.toString() || "";
215+
} catch (error: unknown) {
216+
const execError = error as { stdout?: Buffer; stderr?: Buffer };
217+
const output = execError.stdout?.toString() || "";
154218
expect(output).toContain("Icon validation failed");
155219
expect(output).toContain("${__dirname}");
156220
expect(output).toContain("simple relative path");
@@ -172,8 +236,9 @@ describe("Icon Validation", () => {
172236
encoding: "utf-8",
173237
stdio: "pipe",
174238
});
175-
} catch (error: any) {
176-
const output = error.stdout?.toString() || "";
239+
} catch (error: unknown) {
240+
const execError = error as { stdout?: Buffer; stderr?: Buffer };
241+
const output = execError.stdout?.toString() || "";
177242
expect(output).toContain("Icon validation failed");
178243
expect(output).toContain("relative to the bundle root");
179244
}
@@ -194,8 +259,9 @@ describe("Icon Validation", () => {
194259
encoding: "utf-8",
195260
stdio: "pipe",
196261
});
197-
} catch (error: any) {
198-
const output = error.stdout?.toString() || "";
262+
} catch (error: unknown) {
263+
const execError = error as { stdout?: Buffer; stderr?: Buffer };
264+
const output = execError.stdout?.toString() || "";
199265
expect(output).toContain("Icon validation failed");
200266
expect(output).toContain("not found");
201267
}
@@ -216,8 +282,9 @@ describe("Icon Validation", () => {
216282
encoding: "utf-8",
217283
stdio: "pipe",
218284
});
219-
} catch (error: any) {
220-
const output = error.stdout?.toString() || "";
285+
} catch (error: unknown) {
286+
const execError = error as { stdout?: Buffer; stderr?: Buffer };
287+
const output = execError.stdout?.toString() || "";
221288
expect(output).toContain("Icon validation failed");
222289
expect(output).toContain("PNG format");
223290
}
@@ -233,23 +300,23 @@ describe("Icon Validation", () => {
233300
}
234301

235302
const validPngBuffer = Buffer.from([
236-
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
237-
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
238-
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
239-
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
240-
0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41,
241-
0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
242-
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
243-
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
244-
0x42, 0x60, 0x82,
303+
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
304+
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
305+
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4, 0x89, 0x00, 0x00, 0x00,
306+
0x0a, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
307+
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x49,
308+
0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
245309
]);
246310
fs.writeFileSync(join(assetsDir, "icon.png"), validPngBuffer);
247311

248312
createTestManifest("valid-subdirectory-icon.json", {
249313
icon: "assets/icon.png",
250314
});
251315

252-
const manifestPath = join(testFixturesDir, "valid-subdirectory-icon.json");
316+
const manifestPath = join(
317+
testFixturesDir,
318+
"valid-subdirectory-icon.json",
319+
);
253320
const result = execSync(`node ${cliPath} validate ${manifestPath}`, {
254321
encoding: "utf-8",
255322
});
@@ -258,6 +325,4 @@ describe("Icon Validation", () => {
258325
expect(result).toContain("Icon validation passed");
259326
});
260327
});
261-
262328
});
263-

0 commit comments

Comments
 (0)