From 3096934baebcfa2ebb005f90ae4af775fcfacd7e Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Fri, 19 Jan 2024 15:13:40 +0100 Subject: [PATCH] chore: apply suggestions from code review Co-authored-by: axel7083 <42176370+axel7083@users.noreply.github.com> --- packages/backend/src/models/AIConfig.ts | 2 +- packages/shared/src/messages/MessageProxy.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/models/AIConfig.ts b/packages/backend/src/models/AIConfig.ts index 147ac9432..cf8274c1d 100644 --- a/packages/backend/src/models/AIConfig.ts +++ b/packages/backend/src/models/AIConfig.ts @@ -33,7 +33,7 @@ export interface AIConfig { export function isString(value: unknown): value is string { // eslint-disable-next-line no-null/no-null - return (value !== undefined && value !== null && typeof value === 'string') || value instanceof String; + return (!!value && typeof value === 'string') || value instanceof String; } export function assertString(value: unknown): string { diff --git a/packages/shared/src/messages/MessageProxy.ts b/packages/shared/src/messages/MessageProxy.ts index 6cfc5889d..f5558557c 100644 --- a/packages/shared/src/messages/MessageProxy.ts +++ b/packages/shared/src/messages/MessageProxy.ts @@ -44,7 +44,7 @@ type UnaryRPC = (...args: unknown[]) => Promise; export function isMessageRequest(content: unknown): content is IMessageRequest { return ( // eslint-disable-next-line no-null/no-null - content !== undefined && content !== null && typeof content === 'object' && 'id' in content && 'channel' in content + !!content && typeof content === 'object' && 'id' in content && 'channel' in content ); } @@ -210,9 +210,7 @@ export class RpcBrowser { isSubscribedMessage(content: any): content is ISubscribedMessage { return ( - content !== undefined && - // eslint-disable-next-line no-null/no-null - content !== null && + !!content && 'id' in content && 'body' in content && this.subscribers.has(content.id)