style: 将 biome lineWidth 从默认 80 调整为 120

This commit is contained in:
2026-03-05 12:28:18 +08:00
parent afc3b66efa
commit 58d7a453b6
13 changed files with 45 additions and 133 deletions

View File

@@ -28,8 +28,7 @@ const sidecar = createSidecarRuntime({
},
})
const toErrorMessage = (error: unknown): string =>
error instanceof Error ? error.message : String(error)
const toErrorMessage = (error: unknown): string => (error instanceof Error ? error.message : String(error))
const canOpenExternally = (url: string): boolean => {
try {

View File

@@ -29,12 +29,9 @@ type SidecarRuntime = {
stop: () => void
}
const sleep = (ms: number): Promise<void> =>
new Promise((resolve) => setTimeout(resolve, ms))
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms))
const isProcessAlive = (
processToCheck: ChildProcess | null,
): processToCheck is ChildProcess => {
const isProcessAlive = (processToCheck: ChildProcess | null): processToCheck is ChildProcess => {
if (!processToCheck || !processToCheck.pid) {
return false
}
@@ -81,11 +78,7 @@ const isServerReady = async (url: string): Promise<boolean> => {
return false
}
const waitForServer = async (
url: string,
isQuitting: () => boolean,
processRef?: ChildProcess,
): Promise<boolean> => {
const waitForServer = async (url: string, isQuitting: () => boolean, processRef?: ChildProcess): Promise<boolean> => {
const start = Date.now()
while (Date.now() - start < SERVER_READY_TIMEOUT_MS && !isQuitting()) {
if (processRef && processRef.exitCode !== null) {
@@ -119,9 +112,7 @@ const formatUnexpectedStopMessage = (
return `Server process exited unexpectedly (code ${code ?? 'unknown'}, signal ${signal ?? 'none'}).`
}
export const createSidecarRuntime = (
options: SidecarRuntimeOptions,
): SidecarRuntime => {
export const createSidecarRuntime = (options: SidecarRuntimeOptions): SidecarRuntime => {
const state: SidecarState = {
process: null,
startup: null,
@@ -162,9 +153,7 @@ export const createSidecarRuntime = (
resetState(processRef)
if (!options.isQuitting() && hadReadyServer) {
options.onUnexpectedStop(
'The background service crashed unexpectedly. Please restart the app.',
)
options.onUnexpectedStop('The background service crashed unexpectedly. Please restart the app.')
return
}
@@ -180,9 +169,7 @@ export const createSidecarRuntime = (
resetState(processRef)
if (!options.isQuitting() && hadReadyServer) {
options.onUnexpectedStop(
formatUnexpectedStopMessage(options.isPackaged, code, signal),
)
options.onUnexpectedStop(formatUnexpectedStopMessage(options.isPackaged, code, signal))
}
})
}
@@ -222,11 +209,7 @@ export const createSidecarRuntime = (
state.process = processRef
attachLifecycleHandlers(processRef)
const ready = await waitForServer(
nextServerUrl,
options.isQuitting,
processRef,
)
const ready = await waitForServer(nextServerUrl, options.isQuitting, processRef)
if (ready && isProcessAlive(processRef)) {
state.url = nextServerUrl
return nextServerUrl
@@ -253,9 +236,7 @@ export const createSidecarRuntime = (
const ready = await waitForServer(options.devServerUrl, options.isQuitting)
if (!ready) {
throw new Error(
'Dev server not responding. Run `bun dev` in apps/server first.',
)
throw new Error('Dev server not responding. Run `bun dev` in apps/server first.')
}
return options.devServerUrl

View File

@@ -13,12 +13,7 @@ export const SplashApp = () => {
ease: [0.16, 1, 0.3, 1],
}}
>
<img
alt="Logo"
className="h-20 w-auto object-contain"
draggable={false}
src={logoImage}
/>
<img alt="Logo" className="h-20 w-auto object-contain" draggable={false} src={logoImage} />
<div className="relative h-[4px] w-36 overflow-hidden rounded-full bg-zinc-100">
<motion.div

View File

@@ -10,11 +10,7 @@
"outputs": ["dist/**"]
},
"dist:linux": {
"dependsOn": [
"build",
"@furtherverse/server#compile:linux:arm64",
"@furtherverse/server#compile:linux:x64"
],
"dependsOn": ["build", "@furtherverse/server#compile:linux:arm64", "@furtherverse/server#compile:linux:x64"],
"outputs": ["dist/**"]
},
"dist:linux:arm64": {
@@ -26,11 +22,7 @@
"outputs": ["dist/**"]
},
"dist:mac": {
"dependsOn": [
"build",
"@furtherverse/server#compile:darwin:arm64",
"@furtherverse/server#compile:darwin:x64"
],
"dependsOn": ["build", "@furtherverse/server#compile:darwin:arm64", "@furtherverse/server#compile:darwin:x64"],
"outputs": ["dist/**"]
},
"dist:mac:arm64": {

View File

@@ -24,9 +24,7 @@ const { values } = parseArgs({
const resolveTarget = (): Bun.Build.CompileTarget => {
if (values.target !== undefined) {
if (!isSupportedTarget(values.target)) {
throw new Error(
`Invalid target: ${values.target}\nAllowed: ${SUPPORTED_TARGETS.join(', ')}`,
)
throw new Error(`Invalid target: ${values.target}\nAllowed: ${SUPPORTED_TARGETS.join(', ')}`)
}
return values.target
}
@@ -45,10 +43,7 @@ const main = async () => {
const outfile = `server-${suffix}`
await mkdir(OUTDIR, { recursive: true })
await Promise.all([
rm(`${OUTDIR}/${outfile}`, { force: true }),
rm(`${OUTDIR}/${outfile}.exe`, { force: true }),
])
await Promise.all([rm(`${OUTDIR}/${outfile}`, { force: true }), rm(`${OUTDIR}/${outfile}.exe`, { force: true })])
const result = await Bun.build({
entrypoints: [ENTRYPOINT],

View File

@@ -1,11 +1,7 @@
import { TanStackDevtools } from '@tanstack/react-devtools'
import type { QueryClient } from '@tanstack/react-query'
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
import {
createRootRouteWithContext,
HeadContent,
Scripts,
} from '@tanstack/react-router'
import { createRootRouteWithContext, HeadContent, Scripts } from '@tanstack/react-router'
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
import type { ReactNode } from 'react'
import { ErrorComponent } from '@/components/Error'

View File

@@ -53,9 +53,7 @@ function Todos() {
{/* Header */}
<div className="flex items-end justify-between">
<div>
<h1 className="text-3xl font-bold text-slate-900 tracking-tight">
</h1>
<h1 className="text-3xl font-bold text-slate-900 tracking-tight"></h1>
<p className="text-slate-500 mt-1"></p>
</div>
<div className="text-right">
@@ -63,9 +61,7 @@ function Todos() {
{completedCount}
<span className="text-slate-400 text-lg">/{totalCount}</span>
</div>
<div className="text-xs font-medium text-slate-400 uppercase tracking-wider">
</div>
<div className="text-xs font-medium text-slate-400 uppercase tracking-wider"></div>
</div>
</div>
@@ -112,18 +108,11 @@ function Todos() {
stroke="currentColor"
aria-hidden="true"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={1.5}
d="M12 6v6m0 0v6m0-6h6m-6 0H6"
/>
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1.5} d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
</svg>
</div>
<p className="text-slate-500 text-lg font-medium"></p>
<p className="text-slate-400 text-sm mt-1">
</p>
<p className="text-slate-400 text-sm mt-1"></p>
</div>
) : (
todos.map((todo) => (
@@ -151,11 +140,7 @@ function Todos() {
strokeWidth={3}
aria-hidden="true"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M5 13l4 4L19 7"
/>
<path strokeLinecap="round" strokeLinejoin="round" d="M5 13l4 4L19 7" />
</svg>
)}
</button>

View File

@@ -1,9 +1,5 @@
import { oc } from '@orpc/contract'
import {
createInsertSchema,
createSelectSchema,
createUpdateSchema,
} from 'drizzle-orm/zod'
import { createInsertSchema, createSelectSchema, createUpdateSchema } from 'drizzle-orm/zod'
import { z } from 'zod'
import { todoTable } from '@/server/db/schema'

View File

@@ -6,11 +6,7 @@ export const logError = (error: unknown) => {
}
export const handleValidationError = (error: unknown) => {
if (
error instanceof ORPCError &&
error.code === 'BAD_REQUEST' &&
error.cause instanceof ValidationError
) {
if (error instanceof ORPCError && error.code === 'BAD_REQUEST' && error.cause instanceof ValidationError) {
// If you only use Zod you can safely cast to ZodIssue[] (per ORPC official docs)
const zodError = new z.ZodError(error.cause.issues as z.core.$ZodIssue[])
@@ -22,11 +18,7 @@ export const handleValidationError = (error: unknown) => {
})
}
if (
error instanceof ORPCError &&
error.code === 'INTERNAL_SERVER_ERROR' &&
error.cause instanceof ValidationError
) {
if (error instanceof ORPCError && error.code === 'INTERNAL_SERVER_ERROR' && error.cause instanceof ValidationError) {
throw new ORPCError('OUTPUT_VALIDATION_FAILED', {
cause: error.cause,
})

View File

@@ -11,39 +11,26 @@ export const list = os.todo.list.use(db).handler(async ({ context }) => {
return todos
})
export const create = os.todo.create
.use(db)
.handler(async ({ context, input }) => {
const [newTodo] = await context.db
.insert(todoTable)
.values(input)
.returning()
export const create = os.todo.create.use(db).handler(async ({ context, input }) => {
const [newTodo] = await context.db.insert(todoTable).values(input).returning()
if (!newTodo) {
throw new ORPCError('NOT_FOUND')
}
if (!newTodo) {
throw new ORPCError('NOT_FOUND')
}
return newTodo
})
return newTodo
})
export const update = os.todo.update
.use(db)
.handler(async ({ context, input }) => {
const [updatedTodo] = await context.db
.update(todoTable)
.set(input.data)
.where(eq(todoTable.id, input.id))
.returning()
export const update = os.todo.update.use(db).handler(async ({ context, input }) => {
const [updatedTodo] = await context.db.update(todoTable).set(input.data).where(eq(todoTable.id, input.id)).returning()
if (!updatedTodo) {
throw new ORPCError('NOT_FOUND')
}
if (!updatedTodo) {
throw new ORPCError('NOT_FOUND')
}
return updatedTodo
})
return updatedTodo
})
export const remove = os.todo.remove
.use(db)
.handler(async ({ context, input }) => {
await context.db.delete(todoTable).where(eq(todoTable.id, input.id))
})
export const remove = os.todo.remove.use(db).handler(async ({ context, input }) => {
await context.db.delete(todoTable).where(eq(todoTable.id, input.id))
})

View File

@@ -1,8 +1,4 @@
import type {
ContractRouterClient,
InferContractRouterInputs,
InferContractRouterOutputs,
} from '@orpc/contract'
import type { ContractRouterClient, InferContractRouterInputs, InferContractRouterOutputs } from '@orpc/contract'
import type { Contract } from './contracts'
export type RouterClient = ContractRouterClient<Contract>

View File

@@ -25,8 +25,7 @@ export const pk = (name: string, strategy?: 'native' | 'extension') => {
// timestamp
export const createdAt = (name = 'created_at') =>
timestamp(name, { withTimezone: true }).notNull().defaultNow()
export const createdAt = (name = 'created_at') => timestamp(name, { withTimezone: true }).notNull().defaultNow()
export const updatedAt = (name = 'updated_at') =>
timestamp(name, { withTimezone: true })
@@ -43,9 +42,7 @@ export const generatedFields = {
}
// Helper to create omit keys from generatedFields
const createGeneratedFieldKeys = <T extends Record<string, unknown>>(
fields: T,
): Record<keyof T, true> => {
const createGeneratedFieldKeys = <T extends Record<string, unknown>>(fields: T): Record<keyof T, true> => {
return Object.keys(fields).reduce(
(acc, key) => {
acc[key as keyof T] = true

View File

@@ -11,7 +11,8 @@
"formatter": {
"enabled": true,
"indentStyle": "space",
"lineEnding": "lf"
"lineEnding": "lf",
"lineWidth": 120
},
"linter": {
"enabled": true,