Skip to content

Commit

Permalink
chore: remove eslint, prettier, tslint and replace with biome (elizaO…
Browse files Browse the repository at this point in the history
…S#2439)

* remove eslint, and prettier. replace with biome-js

* full lint and biome switch

* lint check fix

* warn

* warn

* biome ci

* Update ci.yaml

---------

Co-authored-by: Sero <[email protected]>
Co-authored-by: Sayo <[email protected]>
  • Loading branch information
3 people authored Jan 18, 2025
1 parent 87793af commit d30b341
Show file tree
Hide file tree
Showing 855 changed files with 2,590 additions and 3,194 deletions.
36 changes: 0 additions & 36 deletions .eslintrc.json

This file was deleted.

10 changes: 6 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ jobs:
- name: Install dependencies
run: pnpm install -r --no-frozen-lockfile

- name: Run Prettier
run: pnpm run prettier --check .
- name: Setup Biome CLI
uses: biomejs/setup-biome@v2
with:
version: latest

- name: Run Linter
run: pnpm run lint
- name: Run Biome
run: biome ci

- name: Create test env file
run: |
Expand Down
2 changes: 1 addition & 1 deletion agent/src/__tests__/client-type-identification.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, IAgentRuntime } from "@elizaos/core";
import type { Client, IAgentRuntime } from "@elizaos/core";
import { describe, it, expect } from "@jest/globals";

// Helper function to identify client types
Expand Down
30 changes: 15 additions & 15 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ import {
AgentRuntime,
CacheManager,
CacheStore,
Character,
Client,
type Character,
type Client,
Clients,
DbCacheAdapter,
defaultCharacter,
elizaLogger,
FsCacheAdapter,
IAgentRuntime,
ICacheManager,
IDatabaseAdapter,
IDatabaseCacheAdapter,
type IAgentRuntime,
type ICacheManager,
type IDatabaseAdapter,
type IDatabaseCacheAdapter,
ModelProviderName,
parseBooleanFromText,
settings,
Expand Down Expand Up @@ -116,7 +116,7 @@ import yargs from "yargs";
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
const __dirname = path.dirname(__filename); // get the name of the directory

export const wait = (minTime: number = 1000, maxTime: number = 3000) => {
export const wait = (minTime = 1000, maxTime = 3000) => {
const waitTime =
Math.floor(Math.random() * (maxTime - minTime + 1)) + minTime;
return new Promise((resolve) => setTimeout(resolve, waitTime));
Expand Down Expand Up @@ -300,7 +300,7 @@ async function loadCharacter(filePath: string): Promise<Character> {
if (!content) {
throw new Error(`Character file not found: ${filePath}`);
}
let character = JSON.parse(content);
const character = JSON.parse(content);
return jsonToCharacter(filePath, character);
}

Expand All @@ -311,7 +311,7 @@ function commaSeparatedStringToArray(commaSeparated: string): string[] {
export async function loadCharacters(
charactersArg: string
): Promise<Character[]> {
let characterPaths = commaSeparatedStringToArray(charactersArg);
const characterPaths = commaSeparatedStringToArray(charactersArg);
const loadedCharacters: Character[] = [];

if (characterPaths?.length > 0) {
Expand Down Expand Up @@ -385,7 +385,7 @@ export async function loadCharacters(

if (hasValidRemoteUrls()) {
elizaLogger.info("Loading characters from remote URLs");
let characterUrls = commaSeparatedStringToArray(
const characterUrls = commaSeparatedStringToArray(
process.env.REMOTE_CHARACTER_URLS
);
for (const characterUrl of characterUrls) {
Expand Down Expand Up @@ -1191,9 +1191,9 @@ const hasValidRemoteUrls = () =>

const startAgents = async () => {
const directClient = new DirectClient();
let serverPort = parseInt(settings.SERVER_PORT || "3000");
let serverPort = Number.parseInt(settings.SERVER_PORT || "3000");
const args = parseArguments();
let charactersArg = args.characters || args.character;
const charactersArg = args.characters || args.character;
let characters = [defaultCharacter];

if (process.env.IQ_WALLET_ADDRESS && process.env.IQSOlRPC) {
Expand Down Expand Up @@ -1231,7 +1231,7 @@ const startAgents = async () => {

directClient.start(serverPort);

if (serverPort !== parseInt(settings.SERVER_PORT || "3000")) {
if (serverPort !== Number.parseInt(settings.SERVER_PORT || "3000")) {
elizaLogger.log(`Server started on alternate port ${serverPort}`);
}

Expand All @@ -1251,12 +1251,12 @@ if (
parseBooleanFromText(process.env.PREVENT_UNHANDLED_EXIT)
) {
// Handle uncaught exceptions to prevent the process from crashing
process.on("uncaughtException", function (err) {
process.on("uncaughtException", (err) => {
console.error("uncaughtException", err);
});

// Handle unhandled rejections to prevent the process from crashing
process.on("unhandledRejection", function (err) {
process.on("unhandledRejection", (err) => {
console.error("unhandledRejection", err);
});
}
88 changes: 88 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "warn",
"noArrayIndexKey": "warn",
"noPrototypeBuiltins": "warn",
"noDuplicateObjectKeys": "warn",
"noGlobalIsNan": "warn",
"noDuplicateFontNames": "warn",
"noSelfCompare": "warn",
"noDoubleEquals": "warn",
"noImplicitAnyLet": "warn",
"noAssignInExpressions": "warn",
"noExportsInTest": "warn",
"noConstEnum": "warn",
"noEmptyInterface": "warn"
},
"correctness": {
"noUnusedVariables": "warn",
"noUnreachable": "warn",
"useExhaustiveDependencies": "warn",
"noSwitchDeclarations": "warn",
"noUnnecessaryContinue": "warn",
"noInnerDeclarations": "warn"
},
"style": {
"useConst": "warn",
"useTemplate": "warn",
"useImportType": "warn",
"useNodejsImportProtocol": "warn",
"noUselessElse": "warn",
"useSelfClosingElements": "warn",
"useNumberNamespace": "warn",
"noUnusedTemplateLiteral": "warn",
"noInferrableTypes": "warn",
"noNonNullAssertion": "warn",
"noParameterAssign": "warn",
"useDefaultParameterLast": "warn",
"useExponentiationOperator": "warn",
"noVar": "warn",
"useSingleVarDeclarator": "warn",
"useExportType": "warn"
},
"a11y": {
"useAltText": "warn",
"useFocusableInteractive": "warn",
"useMediaCaption": "warn",
"noSvgWithoutTitle": "warn",
"useKeyWithClickEvents": "warn"
},
"complexity": {
"noForEach": "warn",
"useOptionalChain": "warn",
"useArrowFunction": "warn",
"useFlatMap": "warn",
"useLiteralKeys": "warn",
"noBannedTypes": "warn",
"noStaticOnlyClass": "warn",
"noThisInStatic": "warn",
"noUselessConstructor": "warn",
"noUselessTernary": "warn",
"noUselessSwitchCase": "warn",
"noUselessCatch": "warn"
},
"performance": {
"noDelete": "warn",
"noAccumulatingSpread": "warn"
}
},
"ignore": ["**/dist/**", "**/node_modules/**", "**/coverage/**", "**/*.json"]
},
"formatter": {
"enabled": false
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "always"
}
}
}
28 changes: 0 additions & 28 deletions client/eslint.config.js

This file was deleted.

3 changes: 1 addition & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"extract-version": "sh version.sh",
"dev": "pnpm run extract-version && vite",
"build": "pnpm run extract-version && tsc -b && vite build",
"preview": "vite preview",
"lint": "eslint ."
"preview": "vite preview"
},
"dependencies": {
"@elizaos/core": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import useVersion from "./hooks/use-version";
const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: Infinity,
staleTime: Number.POSITIVE_INFINITY,
},
},
});
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/app-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from "@/components/ui/sidebar";
import { apiClient } from "@/lib/api";
import { NavLink, useLocation } from "react-router";
import { type UUID } from "@elizaos/core";
import type { UUID } from "@elizaos/core";
import { Book, Cog, User } from "lucide-react";
import ConnectionStatus from "./connection-status";

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/audio-recorder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Ellipsis, Mic, Send, Trash } from "lucide-react";
import { cn } from "@/lib/utils";
import { useToast } from "@/hooks/use-toast";
import { useMutation } from "@tanstack/react-query";
import { UUID } from "@elizaos/core";
import type { UUID } from "@elizaos/core";
import { apiClient } from "@/lib/api";

type Props = {
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ChatMessageList } from "@/components/ui/chat/chat-message-list";
import { useTransition, animated, AnimatedProps } from "@react-spring/web";
import { Paperclip, Send, X } from "lucide-react";
import { useEffect, useRef, useState } from "react";
import { Content, UUID } from "@elizaos/core";
import type { Content, UUID } from "@elizaos/core";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { apiClient } from "@/lib/api";
import { cn, moment } from "@/lib/utils";
Expand All @@ -19,7 +19,7 @@ import ChatTtsButton from "./ui/chat/chat-tts-button";
import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip";
import { useToast } from "@/hooks/use-toast";
import AIWriter from "react-aiwriter";
import { IAttachment } from "@/types";
import type { IAttachment } from "@/types";
import { AudioRecorder } from "./audio-recorder";
import { Badge } from "./ui/badge";

Expand Down
2 changes: 1 addition & 1 deletion client/src/components/overview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Character } from "@elizaos/core";
import type { Character } from "@elizaos/core";
import ArrayInput from "@/components/array-input";
import InputCopy from "@/components/input-copy";
import PageTitle from "./page-title";
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ui/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from "react"
import type * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "@/lib/utils"
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ui/chat/chat-bubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
import { Avatar, AvatarImage, AvatarFallback } from "@/components/ui/avatar";
import MessageLoading from "./message-loading";
import { Button, ButtonProps } from "../button";
import { Button, type ButtonProps } from "../button";

// ChatBubble
const chatBubbleVariant = cva(
Expand Down
3 changes: 2 additions & 1 deletion client/src/components/ui/chat/expandable-chat.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useRef, useState } from "react";
import type React from "react";
import { useRef, useState } from "react";
import { X, MessageCircle } from "lucide-react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/ui/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { VariantProps, cva } from "class-variance-authority";
import { type VariantProps, cva } from "class-variance-authority";
import { PanelLeft } from "lucide-react";
import { useIsMobile } from "@/hooks/use-mobile";
import { cn } from "@/lib/utils";
Expand Down
8 changes: 3 additions & 5 deletions client/src/components/ui/toaster.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ export function Toaster() {

return (
<ToastProvider>
{toasts.map(function ({
{toasts.map(({
id,
title,
description,
action,
...props
}) {
return (
}) => (
<Toast key={id} {...props}>
<div className="grid gap-1">
{title && <ToastTitle>{title}</ToastTitle>}
Expand All @@ -33,8 +32,7 @@ export function Toaster() {
{action}
<ToastClose />
</Toast>
);
})}
))}
<ToastViewport />
</ToastProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion client/src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type UUID, type Character } from "@elizaos/core";
import type { UUID, Character } from "@elizaos/core";

const BASE_URL = `http://localhost:${import.meta.env.VITE_SERVER_PORT ?? 3000}`;

Expand Down
Loading

0 comments on commit d30b341

Please sign in to comment.