diff --git a/oxlint.json b/oxlint.json index b911cb815..8847f4171 100644 --- a/oxlint.json +++ b/oxlint.json @@ -19,13 +19,19 @@ }] }], + "no-empty-function": "error", + "typescript/no-explicit-any": "warn", "typescript/no-non-null-assertion": "warn", "typescript/no-floating-promises": "error", "typescript/no-misused-promises": "error", "typescript/consistent-type-imports": "error", + "typescript/consistent-return": "error", + "typescript/no-unnecessary-condition": "error", "typescript/no-unnecessary-type-assertion": "error", + "typescript/no-unnecessary-type-parameters": "error", "typescript/prefer-optional-chain": "error", + "typescript/prefer-for-of": "error", "import/no-cycle": "error", "import/no-self-import": "error", @@ -34,6 +40,8 @@ "unicorn/no-instanceof-array": "error", "unicorn/no-typeof-undefined": "error", + "unicorn/no-nested-ternary": "error", + "unicorn/consistent-existence-index-check": "error", "vue/no-arrow-functions-in-watch": "error", "vue/no-deprecated-destroyed-lifecycle": "error", diff --git a/src/automation/bridge.ts b/src/automation/bridge.ts index eae491de6..d9ee2301a 100644 --- a/src/automation/bridge.ts +++ b/src/automation/bridge.ts @@ -156,7 +156,7 @@ export function startAutomationBridge(server: ViteServer) { if (provided !== authToken) { return c.json({ error: 'Unauthorized' }, 401) } - await next() + return next() }) app.post('/rpc', async (c) => { diff --git a/src/automation/server.ts b/src/automation/server.ts index e3dc042b8..00932d422 100644 --- a/src/automation/server.ts +++ b/src/automation/server.ts @@ -39,10 +39,10 @@ export function connectAutomation(getStore: () => EditorStore) { const store = getStore() if (command === 'eval') { - const code = (args as { code?: string })?.code + const code = (args as { code?: string }).code if (!code) throw new Error('Missing "code" in args') const figma = makeFigma() - const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor + const AsyncFunction = Object.getPrototypeOf(async function () { /* noop */ }).constructor const wrappedCode = code.trim().startsWith('return') ? code : `return (async () => { ${code} })()` @@ -53,14 +53,14 @@ export function connectAutomation(getStore: () => EditorStore) { } if (command === 'tool') { - const toolName = (args as { name?: string })?.name - const toolArgs = (args as { args?: Record })?.args ?? {} + const toolName = (args as { name?: string }).name + const toolArgs = (args as { args?: Record }).args ?? {} if (!toolName) throw new Error('Missing "name" in args') if (toolName === 'render' && toolArgs.tree) { const tree = toolArgs.tree as Parameters[1] const result = renderTreeNode(store.graph, tree, { - parentId: (toolArgs.parent_id as string) ?? store.state.currentPageId, + parentId: (toolArgs.parent_id as string | undefined) ?? store.state.currentPageId, x: toolArgs.x as number | undefined, y: toolArgs.y as number | undefined }) @@ -96,7 +96,7 @@ export function connectAutomation(getStore: () => EditorStore) { ) if (!data) throw new Error('Export failed') let binary = '' - for (let i = 0; i < data.length; i++) binary += String.fromCharCode(data[i]) + for (const byte of data) binary += String.fromCharCode(byte) const base64 = btoa(binary) return { ok: true, @@ -113,7 +113,7 @@ export function connectAutomation(getStore: () => EditorStore) { nodeIds.length === 1 ? sceneNodeToJSX(nodeIds[0], store.graph, style) : selectionToJSX(nodeIds, store.graph, style) - return { ok: true, result: { jsx: jsx ?? '' } } + return { ok: true, result: { jsx } } } const result = executeRpcCommand(store.graph, command, args ?? {}) diff --git a/src/components/ChatPanel.vue b/src/components/ChatPanel.vue index e238cad12..eead37d45 100644 --- a/src/components/ChatPanel.vue +++ b/src/components/ChatPanel.vue @@ -31,7 +31,7 @@ function handleSubmit(text: string) { const c = ensureChat() if (c) chat.value = markRaw(c) } - chat.value?.sendMessage({ text }).catch(() => {}) + chat.value?.sendMessage({ text }).catch(() => { /* user-facing error handled by UI */ }) } function handleStop() { diff --git a/src/components/LayerTree.vue b/src/components/LayerTree.vue index d2fd7b4bc..8535adb91 100644 --- a/src/components/LayerTree.vue +++ b/src/components/LayerTree.vue @@ -117,7 +117,7 @@ function onLayerRightClick(e: MouseEvent) { function toggleExpand(id: string) { const idx = expanded.value.indexOf(id) - if (idx >= 0) { + if (idx !== -1) { expanded.value = expanded.value.filter((e) => e !== id) } else { expanded.value = [...expanded.value, id] diff --git a/src/components/VariablesDialog.vue b/src/components/VariablesDialog.vue index 2624de3f8..23c4d3fb5 100644 --- a/src/components/VariablesDialog.vue +++ b/src/components/VariablesDialog.vue @@ -1,5 +1,5 @@