From d2d6a8944823678c05feadda9f2b5d7153cea2a8 Mon Sep 17 00:00:00 2001 From: Danila Poyarkov Date: Wed, 22 Apr 2026 18:01:52 +0300 Subject: [PATCH] fix(lint): resolve all linting warnings and errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scene-graph: replace non-null assertion with guard - figma-api: console.log → console.warn for notify() - editor/nodes: replace non-null assertion with guard - automation/server: console.log → console.debug - mcp/stdio: proper Buffer/ArrayBuffer/Buffer[] UTF-8 decoding - design-jsx/render: suppress no-implied-eval for Function constructor 0 warnings, 0 errors. --- packages/core/src/design-jsx/render.ts | 1 + packages/core/src/editor/nodes.ts | 4 ++-- packages/core/src/figma-api/index.ts | 2 +- packages/core/src/scene-graph/index.ts | 3 ++- packages/mcp/src/stdio.ts | 6 +++++- src/automation/server.ts | 2 +- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/core/src/design-jsx/render.ts b/packages/core/src/design-jsx/render.ts index 589d314dc..930b869c2 100644 --- a/packages/core/src/design-jsx/render.ts +++ b/packages/core/src/design-jsx/render.ts @@ -36,6 +36,7 @@ export function buildComponent(jsxString: string): () => unknown { code = transform(`${aliases}\nreturn function __render() { return <>${trimmed} }`, opts).code } + // eslint-disable-next-line typescript-eslint/no-implied-eval -- sucrase output must be evaluated at runtime return new Function('React', code)(React) as () => unknown } diff --git a/packages/core/src/editor/nodes.ts b/packages/core/src/editor/nodes.ts index f525ff512..bd65ee92b 100644 --- a/packages/core/src/editor/nodes.ts +++ b/packages/core/src/editor/nodes.ts @@ -205,8 +205,8 @@ export function createNodeActions(ctx: EditorContext) { if (!nudgeOriginals) { nudgeOriginals = new Map() for (const id of movable) { - const node = ctx.graph.getNode(id)! - nudgeOriginals.set(id, { x: node.x, y: node.y }) + const node = ctx.graph.getNode(id) + if (node) nudgeOriginals.set(id, { x: node.x, y: node.y }) } } diff --git a/packages/core/src/figma-api/index.ts b/packages/core/src/figma-api/index.ts index 5978d2b3a..dc22f011d 100644 --- a/packages/core/src/figma-api/index.ts +++ b/packages/core/src/figma-api/index.ts @@ -384,7 +384,7 @@ export class FigmaAPI implements NodeProxyHost { } notify(message: string): { cancel: () => void } { - if (typeof console !== 'undefined') console.log(`[figma.notify] ${message}`) + if (typeof console !== 'undefined') console.warn(`[figma.notify] ${message}`) // eslint-disable-next-line no-empty-function return { cancel() {} } } diff --git a/packages/core/src/scene-graph/index.ts b/packages/core/src/scene-graph/index.ts index 2ea633130..817f142bc 100644 --- a/packages/core/src/scene-graph/index.ts +++ b/packages/core/src/scene-graph/index.ts @@ -811,8 +811,9 @@ export class SceneGraph { if (cached) return cached const node = this.getNode(id) + if (!node) return { x: 0, y: 0 } - const result = getAbsolutePosition(node!, this) + const result = getAbsolutePosition(node, this) this.absPosCache.set(id, result) return result } diff --git a/packages/mcp/src/stdio.ts b/packages/mcp/src/stdio.ts index 929261ed4..b3598d9ab 100644 --- a/packages/mcp/src/stdio.ts +++ b/packages/mcp/src/stdio.ts @@ -32,7 +32,11 @@ function connect() { ws.on('message', (raw) => { try { - const msg = JSON.parse(String(raw)) as { + let text: string + if (Buffer.isBuffer(raw)) text = raw.toString('utf8') + else if (Array.isArray(raw)) text = Buffer.concat(raw).toString('utf8') + else text = Buffer.from(raw).toString('utf8') + const msg = JSON.parse(text) as { type: string id?: string token?: string diff --git a/src/automation/server.ts b/src/automation/server.ts index 51434346a..547ecb168 100644 --- a/src/automation/server.ts +++ b/src/automation/server.ts @@ -211,7 +211,7 @@ export function connectAutomation(getStore: () => EditorStore, authToken: string } ws.onopen = () => { - console.log('[Automation] WebSocket connected to MCP server') + console.debug('[Automation] WebSocket connected to MCP server') ws?.send(JSON.stringify({ type: 'register', token })) }