Upgrade linter and formatter to Ultracite (#1224)
This commit is contained in:
parent
b1d254283b
commit
0e320b391d
177 changed files with 6951 additions and 8342 deletions
14
lib/utils.ts
14
lib/utils.ts
|
|
@ -5,11 +5,11 @@ import type {
|
|||
UIMessagePart,
|
||||
} from 'ai';
|
||||
import { type ClassValue, clsx } from 'clsx';
|
||||
import { formatISO } from 'date-fns';
|
||||
import { twMerge } from 'tailwind-merge';
|
||||
import type { DBMessage, Document } from '@/lib/db/schema';
|
||||
import { ChatSDKError, type ErrorCode } from './errors';
|
||||
import type { ChatMessage, ChatTools, CustomUIDataTypes } from './types';
|
||||
import { formatISO } from 'date-fns';
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
|
|
@ -66,17 +66,17 @@ export function generateUUID(): string {
|
|||
type ResponseMessageWithoutId = CoreToolMessage | CoreAssistantMessage;
|
||||
type ResponseMessage = ResponseMessageWithoutId & { id: string };
|
||||
|
||||
export function getMostRecentUserMessage(messages: Array<UIMessage>) {
|
||||
export function getMostRecentUserMessage(messages: UIMessage[]) {
|
||||
const userMessages = messages.filter((message) => message.role === 'user');
|
||||
return userMessages.at(-1);
|
||||
}
|
||||
|
||||
export function getDocumentTimestampByIndex(
|
||||
documents: Array<Document>,
|
||||
documents: Document[],
|
||||
index: number,
|
||||
) {
|
||||
if (!documents) return new Date();
|
||||
if (index > documents.length) return new Date();
|
||||
if (!documents) { return new Date(); }
|
||||
if (index > documents.length) { return new Date(); }
|
||||
|
||||
return documents[index].createdAt;
|
||||
}
|
||||
|
|
@ -84,11 +84,11 @@ export function getDocumentTimestampByIndex(
|
|||
export function getTrailingMessageId({
|
||||
messages,
|
||||
}: {
|
||||
messages: Array<ResponseMessage>;
|
||||
messages: ResponseMessage[];
|
||||
}): string | null {
|
||||
const trailingMessage = messages.at(-1);
|
||||
|
||||
if (!trailingMessage) return null;
|
||||
if (!trailingMessage) { return null; }
|
||||
|
||||
return trailingMessage.id;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue