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
This commit is contained in:
parent
ccf9470979
commit
55e3c3cfd8
4 changed files with 109 additions and 96 deletions
|
|
@ -6,12 +6,12 @@
|
||||||
},
|
},
|
||||||
"dxt_version": {
|
"dxt_version": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "0.3",
|
"const": "0.2",
|
||||||
"description": "@deprecated Use manifest_version instead"
|
"description": "@deprecated Use manifest_version instead"
|
||||||
},
|
},
|
||||||
"manifest_version": {
|
"manifest_version": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"const": "0.3"
|
"const": "0.2"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|
@ -80,54 +80,12 @@
|
||||||
"icon": {
|
"icon": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"icons": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"src": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"sizes": {
|
|
||||||
"type": "string",
|
|
||||||
"pattern": "^\\d+x\\d+$"
|
|
||||||
},
|
|
||||||
"theme": {
|
|
||||||
"type": "string",
|
|
||||||
"minLength": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"src",
|
|
||||||
"sizes"
|
|
||||||
],
|
|
||||||
"additionalProperties": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"screenshots": {
|
"screenshots": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"localization": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"resources": {
|
|
||||||
"type": "string",
|
|
||||||
"pattern": "\\$\\{locale\\}"
|
|
||||||
},
|
|
||||||
"default_locale": {
|
|
||||||
"type": "string",
|
|
||||||
"pattern": "^[A-Za-z0-9]{2,8}(?:-[A-Za-z0-9]{1,8})*$"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": [
|
|
||||||
"resources",
|
|
||||||
"default_locale"
|
|
||||||
],
|
|
||||||
"additionalProperties": false
|
|
||||||
},
|
|
||||||
"server": {
|
"server": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
@ -355,13 +313,6 @@
|
||||||
],
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"_meta": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {
|
|
||||||
"type": "object",
|
|
||||||
"additionalProperties": {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ function validateIcon(
|
||||||
// Check for ${__dirname} variable (error - doesn't work)
|
// Check for ${__dirname} variable (error - doesn't work)
|
||||||
if (hasVariableSubstitution) {
|
if (hasVariableSubstitution) {
|
||||||
errors.push(
|
errors.push(
|
||||||
'Icon path should not use ${__dirname} variable substitution. ' +
|
"Icon path should not use ${__dirname} variable substitution. " +
|
||||||
'Use a simple relative path like "icon.png" instead of "${__dirname}/icon.png".',
|
'Use a simple relative path like "icon.png" instead of "${__dirname}/icon.png".',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,15 +91,12 @@ describe("DXT CLI", () => {
|
||||||
|
|
||||||
// Create a valid PNG file (1x1 transparent pixel)
|
// Create a valid PNG file (1x1 transparent pixel)
|
||||||
const validPngBuffer = Buffer.from([
|
const validPngBuffer = Buffer.from([
|
||||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
|
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
||||||
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4, 0x89, 0x00, 0x00, 0x00,
|
||||||
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
|
0x0a, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
|
||||||
0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41,
|
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x49,
|
||||||
0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
|
0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
|
||||||
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
|
|
||||||
0x42, 0x60, 0x82,
|
|
||||||
]);
|
]);
|
||||||
fs.writeFileSync(join(testDir, "icon.png"), validPngBuffer);
|
fs.writeFileSync(join(testDir, "icon.png"), validPngBuffer);
|
||||||
});
|
});
|
||||||
|
|
@ -127,7 +124,7 @@ describe("DXT CLI", () => {
|
||||||
entry_point: "server/index.js",
|
entry_point: "server/index.js",
|
||||||
mcp_config: { command: "node" },
|
mcp_config: { command: "node" },
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = execSync(`node ${cliPath} validate ${manifestWithIcon}`, {
|
const result = execSync(`node ${cliPath} validate ${manifestWithIcon}`, {
|
||||||
|
|
@ -154,7 +151,7 @@ describe("DXT CLI", () => {
|
||||||
entry_point: "server/index.js",
|
entry_point: "server/index.js",
|
||||||
mcp_config: { command: "node" },
|
mcp_config: { command: "node" },
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const result = execSync(`node ${cliPath} validate ${manifestWithUrl}`, {
|
const result = execSync(`node ${cliPath} validate ${manifestWithUrl}`, {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { execSync } from "node:child_process";
|
import { execSync } from "node:child_process";
|
||||||
import fs from "node:fs";
|
import fs from "node:fs";
|
||||||
import { join } from "node:path";
|
import { join } from "node:path";
|
||||||
import path from "node:path";
|
|
||||||
|
|
||||||
describe("Icon Validation", () => {
|
describe("Icon Validation", () => {
|
||||||
const cliPath = join(__dirname, "../dist/cli/cli.js");
|
const cliPath = join(__dirname, "../dist/cli/cli.js");
|
||||||
|
|
@ -18,20 +17,81 @@ describe("Icon Validation", () => {
|
||||||
|
|
||||||
// Create a valid PNG file (1x1 transparent pixel)
|
// Create a valid PNG file (1x1 transparent pixel)
|
||||||
const validPngBuffer = Buffer.from([
|
const validPngBuffer = Buffer.from([
|
||||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, // PNG signature
|
0x89,
|
||||||
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, // IHDR chunk
|
0x50,
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, // 1x1 dimensions
|
0x4e,
|
||||||
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
|
0x47,
|
||||||
0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41,
|
0x0d,
|
||||||
0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
|
0x0a,
|
||||||
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
|
0x1a,
|
||||||
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
|
0x0a, // PNG signature
|
||||||
0x42, 0x60, 0x82,
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x0d,
|
||||||
|
0x49,
|
||||||
|
0x48,
|
||||||
|
0x44,
|
||||||
|
0x52, // IHDR chunk
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x01, // 1x1 dimensions
|
||||||
|
0x08,
|
||||||
|
0x06,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x1f,
|
||||||
|
0x15,
|
||||||
|
0xc4,
|
||||||
|
0x89,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x0a,
|
||||||
|
0x49,
|
||||||
|
0x44,
|
||||||
|
0x41,
|
||||||
|
0x54,
|
||||||
|
0x78,
|
||||||
|
0x9c,
|
||||||
|
0x63,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x05,
|
||||||
|
0x00,
|
||||||
|
0x01,
|
||||||
|
0x0d,
|
||||||
|
0x0a,
|
||||||
|
0x2d,
|
||||||
|
0xb4,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x00,
|
||||||
|
0x49,
|
||||||
|
0x45,
|
||||||
|
0x4e,
|
||||||
|
0x44,
|
||||||
|
0xae,
|
||||||
|
0x42,
|
||||||
|
0x60,
|
||||||
|
0x82,
|
||||||
]);
|
]);
|
||||||
fs.writeFileSync(join(testFixturesDir, "valid-icon.png"), validPngBuffer);
|
fs.writeFileSync(join(testFixturesDir, "valid-icon.png"), validPngBuffer);
|
||||||
|
|
||||||
// Create an invalid (non-PNG) file
|
// Create an invalid (non-PNG) file
|
||||||
fs.writeFileSync(join(testFixturesDir, "invalid-icon.jpg"), "Not a PNG file");
|
fs.writeFileSync(
|
||||||
|
join(testFixturesDir, "invalid-icon.jpg"),
|
||||||
|
"Not a PNG file",
|
||||||
|
);
|
||||||
|
|
||||||
// Create test manifests
|
// Create test manifests
|
||||||
createTestManifest("valid-local-icon.json", {
|
createTestManifest("valid-local-icon.json", {
|
||||||
|
|
@ -92,7 +152,7 @@ describe("Icon Validation", () => {
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
join(testFixturesDir, filename),
|
join(testFixturesDir, filename),
|
||||||
JSON.stringify(manifest, null, 2)
|
JSON.stringify(manifest, null, 2),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +195,10 @@ describe("Icon Validation", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should reject icons with ${__dirname} variable", () => {
|
it("should reject icons with ${__dirname} variable", () => {
|
||||||
const manifestPath = join(testFixturesDir, "invalid-dirname-variable.json");
|
const manifestPath = join(
|
||||||
|
testFixturesDir,
|
||||||
|
"invalid-dirname-variable.json",
|
||||||
|
);
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
execSync(`node ${cliPath} validate ${manifestPath}`, {
|
execSync(`node ${cliPath} validate ${manifestPath}`, {
|
||||||
|
|
@ -149,8 +212,9 @@ describe("Icon Validation", () => {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
stdio: "pipe",
|
stdio: "pipe",
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
const output = error.stdout?.toString() || "";
|
const execError = error as { stdout?: Buffer; stderr?: Buffer };
|
||||||
|
const output = execError.stdout?.toString() || "";
|
||||||
expect(output).toContain("Icon validation failed");
|
expect(output).toContain("Icon validation failed");
|
||||||
expect(output).toContain("${__dirname}");
|
expect(output).toContain("${__dirname}");
|
||||||
expect(output).toContain("simple relative path");
|
expect(output).toContain("simple relative path");
|
||||||
|
|
@ -172,8 +236,9 @@ describe("Icon Validation", () => {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
stdio: "pipe",
|
stdio: "pipe",
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
const output = error.stdout?.toString() || "";
|
const execError = error as { stdout?: Buffer; stderr?: Buffer };
|
||||||
|
const output = execError.stdout?.toString() || "";
|
||||||
expect(output).toContain("Icon validation failed");
|
expect(output).toContain("Icon validation failed");
|
||||||
expect(output).toContain("relative to the bundle root");
|
expect(output).toContain("relative to the bundle root");
|
||||||
}
|
}
|
||||||
|
|
@ -194,8 +259,9 @@ describe("Icon Validation", () => {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
stdio: "pipe",
|
stdio: "pipe",
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
const output = error.stdout?.toString() || "";
|
const execError = error as { stdout?: Buffer; stderr?: Buffer };
|
||||||
|
const output = execError.stdout?.toString() || "";
|
||||||
expect(output).toContain("Icon validation failed");
|
expect(output).toContain("Icon validation failed");
|
||||||
expect(output).toContain("not found");
|
expect(output).toContain("not found");
|
||||||
}
|
}
|
||||||
|
|
@ -216,8 +282,9 @@ describe("Icon Validation", () => {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
stdio: "pipe",
|
stdio: "pipe",
|
||||||
});
|
});
|
||||||
} catch (error: any) {
|
} catch (error: unknown) {
|
||||||
const output = error.stdout?.toString() || "";
|
const execError = error as { stdout?: Buffer; stderr?: Buffer };
|
||||||
|
const output = execError.stdout?.toString() || "";
|
||||||
expect(output).toContain("Icon validation failed");
|
expect(output).toContain("Icon validation failed");
|
||||||
expect(output).toContain("PNG format");
|
expect(output).toContain("PNG format");
|
||||||
}
|
}
|
||||||
|
|
@ -233,15 +300,12 @@ describe("Icon Validation", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const validPngBuffer = Buffer.from([
|
const validPngBuffer = Buffer.from([
|
||||||
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
|
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d,
|
||||||
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
|
0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4, 0x89, 0x00, 0x00, 0x00,
|
||||||
0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
|
0x0a, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
|
||||||
0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41,
|
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x49,
|
||||||
0x54, 0x78, 0x9c, 0x63, 0x00, 0x01, 0x00, 0x00,
|
0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82,
|
||||||
0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae,
|
|
||||||
0x42, 0x60, 0x82,
|
|
||||||
]);
|
]);
|
||||||
fs.writeFileSync(join(assetsDir, "icon.png"), validPngBuffer);
|
fs.writeFileSync(join(assetsDir, "icon.png"), validPngBuffer);
|
||||||
|
|
||||||
|
|
@ -249,7 +313,10 @@ describe("Icon Validation", () => {
|
||||||
icon: "assets/icon.png",
|
icon: "assets/icon.png",
|
||||||
});
|
});
|
||||||
|
|
||||||
const manifestPath = join(testFixturesDir, "valid-subdirectory-icon.json");
|
const manifestPath = join(
|
||||||
|
testFixturesDir,
|
||||||
|
"valid-subdirectory-icon.json",
|
||||||
|
);
|
||||||
const result = execSync(`node ${cliPath} validate ${manifestPath}`, {
|
const result = execSync(`node ${cliPath} validate ${manifestPath}`, {
|
||||||
encoding: "utf-8",
|
encoding: "utf-8",
|
||||||
});
|
});
|
||||||
|
|
@ -258,6 +325,4 @@ describe("Icon Validation", () => {
|
||||||
expect(result).toContain("Icon validation passed");
|
expect(result).toContain("Icon validation passed");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue