Skip to content

Commit e6eb0fa

Browse files
committed
fix: fix some checks
1 parent 6696db2 commit e6eb0fa

File tree

7 files changed

+42
-12
lines changed

7 files changed

+42
-12
lines changed

eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import enforceZodV4 from "./eslint-rules/enforce-zod-v4.js";
99

1010
const testFiles = ["tests/**/*.test.ts", "tests/**/*.ts"];
1111

12-
const files = [...testFiles, "src/**/*.ts", "scripts/**/*.ts"];
12+
const files = [...testFiles, "src/**/*.ts", "src/**/*.tsx", "scripts/**/*.ts"];
1313

1414
export default defineConfig([
1515
{ files, plugins: { js }, extends: ["js/recommended"] },
@@ -85,6 +85,7 @@ export default defineConfig([
8585
"global.d.ts",
8686
"eslint.config.js",
8787
"vitest.config.ts",
88+
"vite.ui.config.ts",
8889
"src/types/*.d.ts",
8990
"tests/integration/fixtures/",
9091
"eslint-rules",

knip.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,26 @@
33
"src/index.ts!",
44
"src/lib.ts!",
55
"src/tools/index.ts!",
6+
"src/ui/index.ts!",
67
"tests/**/*.ts",
78
"scripts/**/*.ts",
8-
"eslint-rules/*.js"
9+
"eslint-rules/*.js",
10+
"vite.ui.config.ts"
11+
],
12+
"ignore": [
13+
"tests/integration/fixtures/curl.mjs",
14+
"tests/vitest.d.ts",
15+
"src/ui/build/mount.tsx",
16+
"src/ui/components/**/*.ts",
17+
"src/ui/components/**/*.tsx",
18+
"src/ui/hooks/**/*.ts"
19+
],
20+
"ignoreDependencies": [
21+
"@mongodb-js/atlas-local",
22+
"@emotion/css",
23+
"@leafygreen-ui/table",
24+
"react",
25+
"react-dom"
926
],
10-
"ignore": ["tests/integration/fixtures/curl.mjs", "tests/vitest.d.ts"],
11-
"ignoreDependencies": ["@mongodb-js/atlas-local"],
1227
"ignoreExportsUsedInFile": true
1328
}

src/ui/build/mount.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ for (const [path, module] of Object.entries(componentModules)) {
3333
}
3434
}
3535

36-
function mount() {
36+
function mount(): void {
3737
const container = document.getElementById("root");
3838
if (!container) {
3939
console.error("[mount] No #root element found");
@@ -62,4 +62,3 @@ function mount() {
6262
}
6363

6464
mount();
65-

src/ui/components/ListDatabases/ListDatabases.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function formatBytes(bytes: number): string {
2929
return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + " " + sizes[i];
3030
}
3131

32-
export const ListDatabases = () => {
32+
export const ListDatabases = (): React.ReactElement | null => {
3333
const { data, isLoading, error } = useRenderData<ListDatabasesOutput>();
3434

3535
if (isLoading) {

src/ui/hooks/useRenderData.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
import { useEffect, useState } from "react";
22

3+
/** Expected structure of the postMessage data from parent window */
4+
interface RenderDataMessage {
5+
type: string;
6+
payload?: {
7+
renderData?: unknown;
8+
};
9+
}
10+
11+
/** Return type for the useRenderData hook */
12+
interface UseRenderDataResult<T> {
13+
data: T | null;
14+
isLoading: boolean;
15+
error: string | null;
16+
}
17+
318
/**
419
* Hook for receiving render data from parent window via postMessage
520
* This is used by iframe-based UI components that receive data from an MCP client
@@ -22,13 +37,13 @@ import { useEffect, useState } from "react";
2237
* }
2338
* ```
2439
*/
25-
export function useRenderData<T = unknown>() {
40+
export function useRenderData<T = unknown>(): UseRenderDataResult<T> {
2641
const [data, setData] = useState<T | null>(null);
2742
const [isLoading, setIsLoading] = useState(true);
2843
const [error, setError] = useState<string | null>(null);
2944

3045
useEffect(() => {
31-
const handleMessage = (event: MessageEvent) => {
46+
const handleMessage = (event: MessageEvent<RenderDataMessage>): void => {
3247
if (event.data?.type !== "ui-lifecycle-iframe-render-data") {
3348
// Silently ignore messages that aren't for us
3449
return;
@@ -64,7 +79,7 @@ export function useRenderData<T = unknown>() {
6479
window.addEventListener("message", handleMessage);
6580
window.parent.postMessage({ type: "ui-lifecycle-iframe-ready" }, "*");
6681

67-
return () => {
82+
return (): void => {
6883
window.removeEventListener("message", handleMessage);
6984
};
7085
}, []);

src/ui/registry/registry.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ function getCurrentDir(): string {
1010
if (typeof __dirname !== "undefined") {
1111
return __dirname;
1212
}
13-
// @ts-ignore - import.meta is only available in ESM, but this code path is only executed in ESM
1413
return dirname(fileURLToPath(import.meta.url));
1514
}
1615

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"rootDir": ".",
55
"skipLibCheck": true
66
},
7-
"include": ["**/*"]
7+
"include": ["**/*"],
8+
"exclude": ["dist", "node_modules"]
89
}

0 commit comments

Comments
 (0)