Skip to content

Commit

Permalink
chore: lint biome (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zizzamia authored Jun 9, 2024
1 parent cb3a915 commit 6c8506f
Show file tree
Hide file tree
Showing 21 changed files with 38 additions and 31 deletions.
12 changes: 11 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@
".yarn",
".changeset",
".next",
"esm"
"coverage",
"esm",
"site",
"framegear",
"src/frame/",
"src/identity/",
"src/queries/",
"src/token/",
"src/utils/",
"src/wallet/",
"src/xmtp"
]
}
}
2 changes: 1 addition & 1 deletion jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import 'jest-extended';
// Enable jest-dom functions
import '@testing-library/jest-dom';

// biome-ignore lint: Running linting with `unsafe` flag changes import to 'node:util' which breaks the CI. See https://nodejs.org/docs/latest-v18.x/api/util.html
import { TextEncoder, TextDecoder } from 'util';

global.TextEncoder = TextEncoder;
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"format": "prettier --log-level warn --write .",
"format:check": "prettier --check .",
"format:biome": "biome format --write .",
"lint": "biome lint --write .",
"lint:unsafe": "biome lint --write --unsafe .",
"test": "jest --testPathIgnorePatterns=\\.integ\\.",
"test:integration": "jest --testPathIgnorePatterns=\\.test\\.",
"test:all": "jest .",
Expand Down
5 changes: 2 additions & 3 deletions src/OnchainKitConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import fs from 'fs';
import { baseSepolia } from 'viem/chains';
import { getOnchainKitConfig, setOnchainKitConfig } from './OnchainKitConfig';
import { getRPCUrl } from './getRPCUrl';
Expand All @@ -24,7 +23,7 @@ describe('OnchainKitConfig', () => {
const chain = baseSepolia;
const schemaId = '0x123';
const apiKey = 'test-api-key';
const rpcUrl = `https://api.developer.coinbase.com/rpc/v1/base-sepolia/test-api-key`;
const rpcUrl = 'https://api.developer.coinbase.com/rpc/v1/base-sepolia/test-api-key';
setOnchainKitConfig({ chain, schemaId, apiKey });
expect(getOnchainKitConfig('chain')).toEqual(chain);
expect(getOnchainKitConfig('schemaId')).toEqual(schemaId);
Expand All @@ -36,7 +35,7 @@ describe('OnchainKitConfig', () => {
const chain = baseSepolia;
const schemaId = '0x123';
const apiKey = 'updated-api-key';
const rpcUrl = `https://api.developer.coinbase.com/rpc/v1/base-sepolia/updated-api-key`;
const rpcUrl = 'https://api.developer.coinbase.com/rpc/v1/base-sepolia/updated-api-key';
setOnchainKitConfig({ chain, schemaId, apiKey, rpcUrl });
expect(getOnchainKitConfig('chain')).toEqual(chain);
expect(getOnchainKitConfig('schemaId')).toEqual(schemaId);
Expand Down
2 changes: 1 addition & 1 deletion src/OnchainKitConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { baseSepolia } from 'viem/chains';
import { OnchainKitConfig, SetOnchainKitConfig } from './types';
import type { OnchainKitConfig, SetOnchainKitConfig } from './types';

// The ONCHAIN_KIT_CONFIG is not exported at index.ts,
// but only acccessed through the get and set functions.
Expand Down
2 changes: 1 addition & 1 deletion src/OnchainKitProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { base } from 'viem/chains';
import { render, screen, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';

import { EASSchemaUid } from './identity/types';
import type { EASSchemaUid } from './identity/types';
import { OnchainKitProvider } from './OnchainKitProvider';
import { useOnchainKit } from './useOnchainKit';

Expand Down
2 changes: 1 addition & 1 deletion src/OnchainKitProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createContext, useMemo } from 'react';
import { checkHashLength } from './utils/checkHashLength';
import { ONCHAIN_KIT_CONFIG } from './OnchainKitConfig';
import { OnchainKitContextType, OnchainKitProviderReact } from './types';
import type { OnchainKitContextType, OnchainKitProviderReact } from './types';

export const OnchainKitContext = createContext<OnchainKitContextType>(ONCHAIN_KIT_CONFIG);

Expand Down
2 changes: 1 addition & 1 deletion src/definitions/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { base } from 'viem/chains';
import { EASChainDefinition } from '../identity/types';
import type { EASChainDefinition } from '../identity/types';

export const easChainBase: EASChainDefinition = {
id: base.id,
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/baseSepolia.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { baseSepolia } from 'viem/chains';
import { EASChainDefinition } from '../identity/types';
import type { EASChainDefinition } from '../identity/types';

export const easChainBaseSepolia: EASChainDefinition = {
id: baseSepolia.id,
Expand Down
2 changes: 1 addition & 1 deletion src/definitions/optimism.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { optimism } from 'viem/chains';
import { EASChainDefinition } from '../identity/types';
import type { EASChainDefinition } from '../identity/types';

// More details in https://docs.optimism.io/chain/identity/schemas
export const easChainOptimism: EASChainDefinition = {
Expand Down
2 changes: 1 addition & 1 deletion src/farcaster/getFarcasterUserAddress.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getCustodyAddressForFidNeynar } from '../utils/neynar/user/getCustodyAddressForFidNeynar';
import { getVerifiedAddressesForFidNeynar } from '../utils/neynar/user/getVerifiedAddressesForFidNeynar';
import { GetFarcasterUserAddressResponse } from './types';
import type { GetFarcasterUserAddressResponse } from './types';

type GetFarcasterUserAddressOptions =
| {
Expand Down
4 changes: 2 additions & 2 deletions src/getRPCUrl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('OnchainKitConfig RPC URL', () => {
it('should return the correct config value', () => {
const chain = baseSepolia;
const apiKey = 'test-api-key';
const rpcUrl = `https://api.developer.coinbase.com/rpc/v1/base-sepolia/test-api-key`;
const rpcUrl = 'https://api.developer.coinbase.com/rpc/v1/base-sepolia/test-api-key';
setOnchainKitConfig({ chain, apiKey });
expect(getOnchainKitConfig('chain')).toEqual(chain);
expect(getOnchainKitConfig('apiKey')).toEqual(apiKey);
Expand All @@ -25,7 +25,7 @@ describe('OnchainKitConfig RPC URL', () => {
const chain = baseSepolia;
const apiKey = 'test-api-key';
const newApiKey = 'updated-api-key';
const expectedRpcUrl = `https://api.developer.coinbase.com/rpc/v1/base-sepolia/updated-api-key`;
const expectedRpcUrl = 'https://api.developer.coinbase.com/rpc/v1/base-sepolia/updated-api-key';
setOnchainKitConfig({ chain, apiKey });
expect(getOnchainKitConfig('chain')).toEqual(chain);
expect(getOnchainKitConfig('apiKey')).toEqual(apiKey);
Expand Down
2 changes: 1 addition & 1 deletion src/isBase.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isBaseOptions } from './types';
import { baseSepolia, base } from 'viem/chains';
import type { isBaseOptions } from './types';

/**
* isBase
Expand Down
2 changes: 1 addition & 1 deletion src/queries/attestations.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
GetAttestationsByFilterOptions,
type GetAttestationsByFilterOptions,
getAttestationQueryVariables,
getAttestationsByFilter,
attestationQuery,
Expand Down
4 changes: 2 additions & 2 deletions src/queries/attestations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { gql } from 'graphql-request';
import type { Address, Chain } from 'viem';
import { getAddress } from 'viem';
import { EASSchemaUid, Attestation } from '../identity/types';
import { createEasGraphQLClient } from '../network/createEasGraphQLClient';
import type { Address, Chain } from 'viem';
import type { EASSchemaUid, Attestation } from '../identity/types';

/**
* Type representing the filter options used for querying EAS Attestations.
Expand Down
6 changes: 1 addition & 5 deletions src/swap/core/formatDecimals.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/**
* Formats an amount according to the decimals. Defaults to 18 decimals for ERC-20s.
*/
export function formatDecimals(
amount: string,
inputInDecimals: boolean = true,
decimals: number = 18,
): string {
export function formatDecimals(amount: string, inputInDecimals = true, decimals = 18): string {
if (inputInDecimals) {
return (Number(amount) / 10 ** decimals).toString();
}
Expand Down
2 changes: 1 addition & 1 deletion src/swap/core/getParamsForToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { GetQuoteParams, GetQuoteAPIParams } from '../types';
export function getParamsForToken(params: GetQuoteParams): GetQuoteAPIParams {
const { from, to, amount, amountReference, isAmountInDecimals } = params;

const decimals = amountReference == 'from' ? from.decimals : to.decimals;
const decimals = amountReference === 'from' ? from.decimals : to.decimals;

return {
from: from.address || 'ETH',
Expand Down
4 changes: 2 additions & 2 deletions src/swap/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Address } from 'viem';
import { Token } from '../token/types';
import type { Address } from 'viem';
import type { Token } from '../token/types';

export type AddressOrETH = Address | 'ETH';

Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode } from 'react';
import { Address, Chain } from 'viem';
import { EASSchemaUid } from './identity/types';
import type { ReactNode } from 'react';
import type { Address, Chain } from 'viem';
import type { EASSchemaUid } from './identity/types';

/**
* Note: exported as public Type
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/isValidAAEntrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ENTRYPOINT_ADDRESS_V06 } from 'permissionless';
import { IsValidAAEntrypointOptions } from './types';
import type { IsValidAAEntrypointOptions } from './types';

/**
* Verify the Account-Abstraction entrypoint before sponsoring a transaction.
Expand Down
2 changes: 1 addition & 1 deletion src/xmtp/getXmtpFrameMessage.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { XmtpOpenFramesRequest } from '@xmtp/frames-validator';
import type { XmtpOpenFramesRequest } from '@xmtp/frames-validator';
import { getXmtpFrameMessage } from './getXmtpFrameMessage';

describe('getXmtpFrameMessage', () => {
Expand Down

0 comments on commit 6c8506f

Please sign in to comment.