Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

refactor: simplify conditional checks with optional chaining and clean up lint warnings

aoright3534e4cb6a86
diff --git a/apps/api/src/mcp/controllers/oauth-consent.ts b/apps/api/src/mcp/controllers/oauth-consent.ts
index f234f1dc7..c9c51910a 100644
--- a/apps/api/src/mcp/controllers/oauth-consent.ts
+++ b/apps/api/src/mcp/controllers/oauth-consent.ts
@@ -123,7 +123,7 @@ export async function decideMcpAuthorizationRequest(params: {
if (!request) throwOAuthError(404, "invalid_or_expired_request");
const client = await getClient(request.clientId);
- if (!client || !client.redirectUris.includes(request.redirectUri)) {
+ if (!client?.redirectUris.includes(request.redirectUri)) {
throwOAuthError(400, "invalid_client");
}
diff --git a/apps/api/src/plugins/gitea/webhook-handler.ts b/apps/api/src/plugins/gitea/webhook-handler.ts
index 6b0502cf6..3c467af5d 100644
--- a/apps/api/src/plugins/gitea/webhook-handler.ts
+++ b/apps/api/src/plugins/gitea/webhook-handler.ts
@@ -81,7 +81,7 @@ export async function handleGiteaWebhookRequest(
where: eq(integrationTable.id, integrationId),
});
- if (!integration || integration.type !== "gitea") {
+ if (integration?.type !== "gitea") {
return { success: false, error: "Gitea integration not found" };
}
diff --git a/apps/api/src/plugins/github/utils/sync-label-to-github.ts b/apps/api/src/plugins/github/utils/sync-label-to-github.ts
index cfddfff99..60bb12f08 100644
--- a/apps/api/src/plugins/github/utils/sync-label-to-github.ts
+++ b/apps/api/src/plugins/github/utils/sync-label-to-github.ts
@@ -51,12 +51,12 @@ async function getGitHubContext(taskId: string) {
},
});
- if (!externalLink || externalLink.resourceType !== "issue") {
+ if (externalLink?.resourceType !== "issue") {
return null;
}
const integration = externalLink.integration;
- if (!integration || integration.type !== "github") {
+ if (integration?.type !== "github") {
return null;
}
diff --git a/apps/web/src/components/activity/comment-editor.tsx b/apps/web/src/components/activity/comment-editor.tsx
index 4210d73dd..4a2aa56d0 100644
--- a/apps/web/src/components/activity/comment-editor.tsx
+++ b/apps/web/src/components/activity/comment-editor.tsx
@@ -1157,7 +1157,7 @@ export default function CommentEditor({
const resolvedLanguage = language === "auto" ? "" : language;
const { nodePos } = hoveredCodeBlock;
const node = editor.state.doc.nodeAt(nodePos);
- if (!node || node.type.name !== "codeBlock") return;
+ if (node?.type.name !== "codeBlock") return;
editor
.chain()
@@ -1404,7 +1404,7 @@ export default function CommentEditor({
const copyHoveredCodeBlock = useCallback(async () => {
if (!editor || !hoveredCodeBlock) return;
const node = editor.state.doc.nodeAt(hoveredCodeBlock.nodePos);
- if (!node || node.type.name !== "codeBlock") return;
+ if (node?.type.name !== "codeBlock") return;
const content = node.textContent || "";
if (!content) return;
diff --git a/apps/web/src/components/kanban-board/index.tsx b/apps/web/src/components/kanban-board/index.tsx
index 012a39a95..80f877574 100644
--- a/apps/web/src/components/kanban-board/index.tsx
+++ b/apps/web/src/components/kanban-board/index.tsx
@@ -187,7 +187,7 @@ function KanbanBoard({ project, disableDragDrop = false }: KanbanBoardProps) {
setActiveId(null);
};
- if (!project || !project?.columns) {
+ if (!project?.columns) {
return (
<div className="flex h-full w-full flex-col bg-linear-to-b from-muted/25 to-background">
<header className="mb-6 mt-6 space-y-6 shrink-0 px-6">
diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx
index 0395d5525..a2431a4ad 100644
--- a/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx
+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/workspace/$workspaceId/index.tsx
@@ -390,8 +390,7 @@ function RouteComponent() {
strategy={verticalListSortingStrategy}
>
{orderedProjects?.map((project) => {
- if (!project || !project.id || !project.statistics)
- return null;
+ if (!project?.id || !project.statistics) return null;
const IconComponent =
icons[project.icon as keyof typeof icons] || icons.Layout;
diff --git a/packages/planka-import/src/mapping.ts b/packages/planka-import/src/mapping.ts
index 0e4a54896..2a3824ece 100644
--- a/packages/planka-import/src/mapping.ts
+++ b/packages/planka-import/src/mapping.ts
@@ -95,7 +95,7 @@ export function displayName(user: PlankaUser | undefined): string {
export function formatComment(
comment: PlankaComment,
- author: PlankaUser | undefined,
+ _author: PlankaUser | undefined,
): string {
const date = comment.createdAt
? new Date(comment.createdAt).toISOString().slice(0, 10)