Skip to content

Commit

Permalink
chore: update biome
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Apr 9, 2024
1 parent 61061b6 commit 2a16307
Show file tree
Hide file tree
Showing 35 changed files with 63 additions and 65 deletions.
15 changes: 9 additions & 6 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"$schema": "https://biomejs.dev/schemas/1.0.0/schema.json",
"$schema": "https://biomejs.dev/schemas/1.6.4/schema.json",
"files": {
"ignore": [
"node_modules",
"public",
"dist",
"contracts/cache",
"contracts/out",
"contracts/generated",
"contracts/generated.ts",
"keys.json",
"symbols/generated"
]
Expand All @@ -16,20 +16,22 @@
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentSize": 2,
"indentWidth": 2,
"lineWidth": 80
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"nursery": {
"useExhaustiveDependencies": "error"
"complexity": {
"noForEach": "off"
},
"correctness": {
"noUnusedVariables": "error"
"noUnusedVariables": "error",
"useExhaustiveDependencies": "off"
},
"performance": {
"noAccumulatingSpread": "off",
"noDelete": "off"
},
"style": {
Expand All @@ -39,6 +41,7 @@
"suspicious": {
"noArrayIndexKey": "off",
"noAssignInExpressions": "off",
"noConfusingVoidType": "off",
"noExplicitAny": "off"
}
}
Expand Down
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"zustand": "^4.3.8"
},
"devDependencies": {
"@biomejs/biome": "1.0.0",
"@biomejs/biome": "1.6.4",
"@samrum/vite-plugin-web-extension": "^5.1.0",
"@types/chroma-js": "^2.4.0",
"@types/chrome": "^0.0.266",
Expand Down
3 changes: 0 additions & 3 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ function AccountsChangedEmitter() {
const { sessions } = useSessionsStore()

const prevAccounts = useRef<AccountState['accounts']>()
// rome-ignore lint/nursery/useExhaustiveDependencies:
useEffect(() => {
if (!account) {
prevAccounts.current = []
Expand Down Expand Up @@ -212,7 +211,6 @@ function NetworkChangedEmitter() {
const { sessions } = useSessionsStore()

const prevNetwork = useRef<NetworkState['network']>()
// rome-ignore lint/nursery/useExhaustiveDependencies:
useEffect(() => {
if (!network.chainId) return

Expand Down Expand Up @@ -241,7 +239,6 @@ function SyncJsonRpcAccounts() {
const client = useClient()
const { getAccounts, setJsonRpcAccounts } = useAccountStore()

// rome-ignore lint/nursery/useExhaustiveDependencies: <explanation>
useEffect(() => {
;(async () => {
const addresses = await client.getAddresses()
Expand Down
8 changes: 4 additions & 4 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ function RpcUrl() {
status === 'pending'
? 'surface/invert@0.5'
: listening
? 'surface/green'
: 'surface/red'
? 'surface/green'
: 'surface/red'
}
borderWidth="1px"
borderRadius="round"
Expand Down Expand Up @@ -368,8 +368,8 @@ function MiningStatus() {
? automining
? 'Automine'
: network.blockTime
? `Interval: ${network.blockTime}s`
: 'On Demand'
? `Interval: ${network.blockTime}s`
: 'On Demand'
: ''}
</Text>
</HeaderItem>
Expand Down
2 changes: 1 addition & 1 deletion src/components/abi/AbiParametersInputs.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type AbiFunction, type AbiParameter } from 'abitype'
import type { AbiFunction, AbiParameter } from 'abitype'
import { useEffect, useMemo } from 'react'
import {
type RegisterOptions,
Expand Down
11 changes: 6 additions & 5 deletions src/components/abi/DecodedAbiParameters.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as Accordion from '@radix-ui/react-accordion'
import {
type AbiParameter,
type AbiParameterToPrimitiveType,
type AbiParametersToPrimitiveTypes,
import type {
AbiParameter,
AbiParameterToPrimitiveType,
AbiParametersToPrimitiveTypes,
} from 'abitype'
import React, { useEffect, useMemo, useState } from 'react'
import type React from 'react'
import { useEffect, useMemo, useState } from 'react'
import { type Hex, concat, decodeAbiParameters, stringify } from 'viem'

import { Tooltip } from '~/components'
Expand Down
2 changes: 1 addition & 1 deletion src/design-system/components/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const Box = forwardRef(
) as [BackgroundColor, string]
const applyColorScheme =
(backgroundColor === 'accent' || backgroundColors[baseBackgroundColor]) &&
(!opacity || parseFloat(opacity) > 0.5)
(!opacity || Number.parseFloat(opacity) > 0.5)

const {
scheme: accentColorScheme,
Expand Down
2 changes: 1 addition & 1 deletion src/design-system/components/Button.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ export const buttonVariants = [
'tint green',
'tint red',
] as const satisfies readonly `${ButtonKind} ${string}`[]
export type ButtonVariant = typeof buttonVariants[number]
export type ButtonVariant = (typeof buttonVariants)[number]
2 changes: 1 addition & 1 deletion src/design-system/components/ButtonSymbol.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { UnionOmit } from '~/utils/types'
import { Tooltip } from '../../components'
import type { SymbolName } from '../tokens'
import { ButtonRoot, type ButtonRootProps } from './Button'
import { type ButtonHeight, type ButtonVariant } from './Button.css'
import type { ButtonHeight, ButtonVariant } from './Button.css'
import { widthForHeight } from './ButtonSymbol.css'
import { SFSymbol } from './SFSymbol'
import type { SFSymbolProps } from './SFSymbol'
Expand Down
2 changes: 1 addition & 1 deletion src/design-system/components/ButtonText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { forwardRef } from 'react'
import { Box } from './Box'
import type { BoxStyles } from './Box.css'
import { ButtonRoot, type ButtonRootProps } from './Button'
import { type ButtonHeight, type ButtonVariant } from './Button.css'
import type { ButtonHeight, ButtonVariant } from './Button.css'
import { Text, type TextProps } from './Text'

type ButtonTextProps = ButtonRootProps
Expand Down
2 changes: 1 addition & 1 deletion src/design-system/components/Input.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export type InputKind = 'solid'
export const inputVariants = [
'solid',
] as const satisfies readonly `${InputKind}`[]
export type InputVariant = typeof inputVariants[number]
export type InputVariant = (typeof inputVariants)[number]

export const heightStyles = styleVariants(inputHeights, (height) => [
{ height },
Expand Down
3 changes: 2 additions & 1 deletion src/design-system/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { forwardRef, useContext } from 'react'
import type React from 'react'
import { forwardRef, useContext } from 'react'
import { Link as RouterLink } from 'react-router-dom'

import { Box } from './Box'
Expand Down
2 changes: 1 addition & 1 deletion src/design-system/components/Select.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type SelectKind = 'solid'
export const selectVariants = [
'solid',
] as const satisfies readonly `${SelectKind}`[]
export type SelectVariant = typeof selectVariants[number]
export type SelectVariant = (typeof selectVariants)[number]

export const heightStyles = styleVariants(selectHeights, (height) => [
{ height },
Expand Down
4 changes: 2 additions & 2 deletions src/design-system/components/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export const TextTruncated = forwardRef<HTMLDivElement, TextTruncatedProps>(
const letterWidth = fontAttributes[size].letterWidth

const width_ = width
? width - parseInt(heightForSize[size].replace('px', ''))
? width - Number.parseInt(heightForSize[size].replace('px', ''))
: undefined
return typeof width_ === 'number'
? truncate(children || '', {
Expand Down Expand Up @@ -235,7 +235,7 @@ export const TextTruncated = forwardRef<HTMLDivElement, TextTruncatedProps>(
<Box
position="absolute"
style={{
right: -parseInt(heightForSize[size].replace('px', '')),
right: -Number.parseInt(heightForSize[size].replace('px', '')),
top: -3,
width: heightForSize[size],
}}
Expand Down
6 changes: 3 additions & 3 deletions src/design-system/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ function defineType(fontAttributes: FontAttributes, inline: boolean) {
const leading =
typeof lineHeight === 'number'
? lineHeight
: (fontSize * parseInt(lineHeight)) / 100
: (fontSize * Number.parseInt(lineHeight)) / 100

if (inline) return { fontSize, letterSpacing }
return {
Expand Down Expand Up @@ -658,7 +658,7 @@ export const symbolNames = [
'backward.fill',
'arrow.counterclockwise',
] as const
export type SymbolName = typeof symbolNames[number]
export type SymbolName = (typeof symbolNames)[number]

export const textAlignment = ['left', 'center', 'right'] as const
export type TextAlignment = typeof textAlignment[number]
export type TextAlignment = (typeof textAlignment)[number]
2 changes: 1 addition & 1 deletion src/design-system/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join } from 'path'
import { join } from 'node:path'
import { defineConfig } from 'vite'

// https://vitejs.dev/config/
Expand Down
4 changes: 2 additions & 2 deletions src/errors/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export class BaseError extends Error {
args.cause instanceof BaseError
? args.cause.details
: args.cause?.message
? args.cause.message
: args.details!
? args.cause.message
: args.details!

this.message = [
shortMessage || 'An error occurred.',
Expand Down
1 change: 0 additions & 1 deletion src/hooks/useAccounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export function useAccounts() {
const { accounts, getAccounts } = useAccountStore()
const { network } = useNetworkStore()

// rome-ignore lint/nursery/useExhaustiveDependencies:
return useMemo(
() => getAccounts({ rpcUrl: network.rpcUrl }),
[accounts, network.rpcUrl],
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useAutoloadAbi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { loaders, whatsabi } from '@shazow/whatsabi'
import { queryOptions, useQuery } from '@tanstack/react-query'
import { type Address, type Client } from 'viem'
import type { Address, Client } from 'viem'
import { createQueryKey } from '~/react-query'
import { etherscanApiUrls } from '../constants/etherscan'
import { useClient } from './useClient'
Expand All @@ -22,8 +22,8 @@ export function useAutoloadAbiQueryOptions({
const client = useClient()
return queryOptions({
enabled: enabled && Boolean(address),
gcTime: Infinity,
staleTime: Infinity,
gcTime: Number.POSITIVE_INFINITY,
staleTime: Number.POSITIVE_INFINITY,
queryKey: autoloadAbiQueryKey([client.key, address!]),
async queryFn() {
if (!address) throw new Error('address is required')
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function useContractsQueryOptions({
const client = useClient()

return queryOptions({
staleTime: Infinity,
staleTime: Number.POSITIVE_INFINITY,
enabled: Boolean(
enabled &&
block?.number &&
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useGetLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ export function getLogsQueryOptions<
enabled,
gcTime:
typeof fromBlock === 'bigint' && typeof toBlock === 'bigint'
? Infinity
? Number.POSITIVE_INFINITY
: undefined,
staleTime:
typeof fromBlock === 'bigint' && typeof toBlock === 'bigint'
? Infinity
? Number.POSITIVE_INFINITY
: undefined,
queryKey: getLogsQueryKey([client.key, stringify(args)]),
async queryFn() {
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useLookupSignature.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { loaders } from '@shazow/whatsabi'
import { queryOptions, useQuery } from '@tanstack/react-query'
import { type Client, type Hex } from 'viem'
import type { Client, Hex } from 'viem'
import { createQueryKey } from '~/react-query'
import { useClient } from './useClient'

Expand All @@ -21,8 +21,8 @@ export function useLookupSignatureQueryOptions({
const client = useClient()
return queryOptions({
enabled: enabled && Boolean(selector),
gcTime: Infinity,
staleTime: Infinity,
gcTime: Number.POSITIVE_INFINITY,
staleTime: Number.POSITIVE_INFINITY,
queryKey: lookupSignatureQueryKey([client.key, selector!]),
async queryFn() {
if (!selector) throw new Error('selector is required')
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/usePendingBlock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type InfiniteData, useQuery } from '@tanstack/react-query'
import { type Block, type Client, type Transaction } from 'viem'
import type { Block, Client, Transaction } from 'viem'

import {
createQueryKey,
Expand Down
1 change: 0 additions & 1 deletion src/hooks/usePrevious.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useEffect, useRef } from 'react'
export function usePrevious<T>(newValue: T) {
const previousRef = useRef<T>()

// rome-ignore lint/nursery/useExhaustiveDependencies:
useEffect(() => {
previousRef.current = newValue
})
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useSnapshotQueryOptions({
}: UseSnapshotParameters) {
const client = useClient()
return queryOptions({
gcTime: Infinity,
gcTime: Number.POSITIVE_INFINITY,
staleTime: 0,
enabled: Boolean(enabled && blockNumber),
queryKey: getSnapshotQueryKey([client.key, (blockNumber || '').toString()]),
Expand Down
2 changes: 1 addition & 1 deletion src/messengers/transports/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export type Transport<
},
) => Promise<TSchema extends TransportSchema ? TSchema[TTopic][1] : unknown>
/** Replies to `send`. */
reply: <TTopic extends keyof TSchema,>(
reply: <TTopic extends keyof TSchema>(
/** A scoped topic that was sent from `send`. */
topic: TTopic,
callback: CallbackFunction<
Expand Down
4 changes: 2 additions & 2 deletions src/messengers/transports/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export const createWindowTransport = <TConnection extends string>(
const sender = event.source
if (sender !== window) return

let error
let response
let error: unknown
let response: unknown
try {
response = await callback(event.data.payload, {
connection: event.data.connection,
Expand Down
1 change: 0 additions & 1 deletion src/screens/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export default function Layout() {
const showHeader = onboarded

const isNetworkOffline = Boolean(network.rpcUrl && onboarded && !online)
// rome-ignore lint/nursery/useExhaustiveDependencies:
useEffect(() => {
contentMessenger.reply('pushRoute', async (route) => {
navigate(route)
Expand Down
2 changes: 1 addition & 1 deletion src/screens/account-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
import { toast } from 'sonner'
import {
type Address,
BaseError,
type BaseError,
formatUnits,
isAddress,
parseUnits,
Expand Down
8 changes: 4 additions & 4 deletions src/screens/contract-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export default function ContractDetails() {
.filter((abiItem) => abiItem.type === 'function')
.map((abiItem) => ({
...abiItem,
inputs: (abiItem as {} as AbiFunction).inputs || [],
outputs: (abiItem as {} as AbiFunction).outputs || [],
})) as {} as AbiFunction[]
inputs: (abiItem as unknown as AbiFunction).inputs || [],
outputs: (abiItem as unknown as AbiFunction).outputs || [],
})) as unknown as AbiFunction[]
}, [abi])

const hasStateMutability = !abiFunctions?.some(
Expand All @@ -74,7 +74,7 @@ export default function ContractDetails() {
(abiItem.stateMutability === 'nonpayable' ||
abiItem.stateMutability === 'payable'),
)
return [read as {} as AbiFunction[], write as {} as AbiFunction[]]
return [read as unknown as AbiFunction[], write as unknown as AbiFunction[]]
}, [abiFunctions, hasStateMutability])

////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 2a16307

Please sign in to comment.