Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

chore: migrate from rome to biome #117

Merged
merged 8 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"recommendations": ["rome.rome"],
"unwantedRecommendations": []
"recommendations": ["biomejs.biome"],
"unwantedRecommendations": ["rome.rome"]
}
9 changes: 5 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"editor.codeActionsOnSave": {
"source.organizeImports.rome": true
"quickfix.biome": true,
"source.organizeImports.biome": true
},
"editor.formatOnSave": true,
"editor.defaultFormatter": "rome.rome",
"editor.defaultFormatter": "biomejs.biome",
"[typescript]": {
"editor.defaultFormatter": "rome.rome"
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "rome.rome"
"editor.defaultFormatter": "biomejs.biome"
}
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ issue)
We use the following tools to enforce linting rules, formatting and spell
checking

- [`yarn lint`](https://rome.tools/)
- [`pnpm lint`](https://biomejs.dev/)
- [`cspell`](https://cspell.org/)

We encourage adding the [recommended](.vscode/extensions.json) (or similar)
Expand Down
40 changes: 40 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"$schema": "https://biomejs.dev/schemas/1.0.0/schema.json",
"files": {
"ignore": [
"**/node_modules",
".next",
"public",
"dist",
"**/*.json",
"*.yaml",
".vscode"
]
},
"organizeImports": {
"enabled": true
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentSize": 2,
"lineWidth": 80
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingComma": "all",
"semicolons": "always"
}
}
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
"scripts": {
"build": "pnpm --filter useink build && cp ./README.md ./packages/useink/",
"dev": "pnpm --filter useink watch & pnpm --filter playground dev",
"format": "rome format . --write",
"lint": "rome check .",
"format": "biome format . --write",
"lint": "biome check .",
"lint:fix": "pnpm lint --apply-unsafe",
"lint:ci": "rome ci ."
"lint:ci": "biome ci ."
},
"dependencies": {
"@polkadot/api": "^10.9.1",
"@polkadot/api-contract": "^10.9.1",
"@polkadot/api-derive": "^10.9.1",
"@polkadot/api": "^10.9.1",
"@polkadot/extension-dapp": "^0.46.5",
"@polkadot/extension-inject": "^0.46.5",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2",
"@talismn/connect-wallets": "^1.2.3"
},
"devDependencies": {
"rome": "12.1.3"
"@biomejs/biome": "^1.2.2"
},
"packageManager": "[email protected]"
}
4 changes: 2 additions & 2 deletions packages/useink/src/core/types/api-contract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ISubmittableResult } from './substrate.ts';
import { SubmittableResult } from '@polkadot/api';
import { ISubmittableResult } from './substrate.ts';

export {
BlueprintPromise,
Expand Down Expand Up @@ -28,7 +28,7 @@ export type {
} from '@polkadot/api-contract/types';
export { Abi, ContractPromise } from '@polkadot/api-contract';

// rome-ignore lint/correctness/noUnusedVariables: The Release flow breaks when exporting from '@polkadot/api-contract/base/contract';
// biome-ignore lint/correctness/noUnusedVariables: The Release flow breaks when exporting from '@polkadot/api-contract/base/contract';
export declare class ContractSubmittableResult extends SubmittableResult {
readonly contractEvents?: DecodedEvent[] | undefined;
constructor(result: ISubmittableResult, contractEvents?: DecodedEvent[]);
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/notifications/context.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createContext } from 'react';
import {
AddNotificationPayload,
Config,
DEFAULT_NOTIFICATIONS,
Notifications,
} from './model.ts';
import { createContext } from 'react';

export const NotificationsContext = createContext<{
config?: Config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useContext, useMemo } from 'react';
import { HALF_A_SECOND } from '../../react/constants.ts';
import { useInterval } from '../../react/hooks/internal/useInterval.ts';
import { getExpiredItem } from '../../utils/index';
Expand All @@ -7,7 +8,6 @@ import {
Notification,
Notifications,
} from '../model.ts';
import { useContext, useMemo } from 'react';

export interface UseNotifications {
notifications: Notifications;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';
import { ChainId } from '../../chains/types.ts';
import { Tx } from '../../index';
import { useNotifications } from './useNotifications.ts';
import { useEffect } from 'react';

type TxInfo<T> = Pick<Tx<T>, 'status'> & Pick<Tx<T>, 'result'>;

Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/notifications/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import React, { useCallback, useReducer } from 'react';
import { useIsMounted } from '../react/hooks/internal/useIsMounted.ts';
import { pseudoRandomId } from '../utils/index';
import { NotificationsContext } from './context.ts';
Expand All @@ -7,7 +8,6 @@ import {
DEFAULT_NOTIFICATIONS,
} from './model.ts';
import { notificationReducer } from './reducer.ts';
import React, { useCallback, useReducer } from 'react';

export const NotificationsProvider: React.FC<
React.PropsWithChildren<{
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/config/useChain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'react';
import { Chain, ChainId } from '../../../chains/index';
import { useConfig } from './useConfig.ts';
import { useMemo } from 'react';

export const useChain = (chainId?: ChainId): Chain | undefined => {
const { chains } = useConfig();
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/config/useConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from 'react';
import { ConfigContext } from '../../providers/config/context.ts';
import { Config } from '../../providers/config/model.ts';
import { useContext } from 'react';

export const useConfig = (): Config => useContext<Config>(ConfigContext);
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/config/useDefaultCaller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';
import { ChainId } from '../../../chains/index';
import { useChain } from './useChain.ts';
import { useConfig } from './useConfig.ts';
import { useMemo } from 'react';

export const useDefaultCaller = (chainId?: ChainId): string | undefined => {
const { caller } = useConfig();
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BN } from '@polkadot/util';
import { ChainId } from '../../../chains/types.ts';
import { Abi, ContractOptions, ContractPromise } from '../../../core/index';
import { BN } from '@polkadot/util';

export type CallOptions = Omit<ContractOptions, 'value'> & {
defaultCaller?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/useAbiMessage.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useMemo } from 'react';
import {
AbiMessage,
ContractPromise,
toContractAbiMessage,
} from '../../../core/index';
import { useMemo } from 'react';

export function useAbiMessage(
contract: ContractPromise | undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/useCall.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCallback, useState } from 'react';
import {
DecodedContractResult,
LazyCallOptions,
Expand All @@ -6,7 +7,6 @@ import {
import { ChainContract, useDefaultCaller } from '../index';
import { useWallet } from '../wallets/useWallet.ts';
import { useAbiMessage } from './useAbiMessage.ts';
import { useCallback, useState } from 'react';

export type CallSend<T> = (
args?: unknown[],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect } from 'react';
import { LazyCallOptions } from '../../../core/index.ts';
import { useBlockHeader } from '../substrate/useBlockHeader.ts';
import { ChainContract } from './types.ts';
import { Call, useCall } from './useCall.ts';
import { useEffect } from 'react';

export function useCallSubscription<T>(
chainContract: ChainContract | undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/useCodeHash.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isValidHash } from '../../../utils';
import { useCallback, useEffect, useState } from 'react';
import { isValidHash } from '../../../utils';

export enum CodeHashError {
InvalidHash = 'Invalid code hash value.',
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/useContract.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect, useMemo, useState } from 'react';
import { ChainId } from '../../../chains/index';
import { Abi, ContractPromise } from '../../../core/index';
import { useChain } from '../config/useChain.ts';
import { useApi } from '../substrate/useApi.ts';
import { ChainContract } from './types.ts';
import { useEffect, useMemo, useState } from 'react';

export function useContract<T extends ContractPromise = ContractPromise>(
address: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCallback, useEffect, useMemo, useState } from 'react';
import { ChainId } from '../../../../chains/index.ts';
import {
BlueprintPromise,
Expand Down Expand Up @@ -26,7 +27,6 @@ import { useApi } from '../../substrate/useApi.ts';
import { useWallet } from '../../wallets/useWallet.ts';
import { useTxEvents } from '../useTxEvents.ts';
import { Deploy, DeploySignAndSend, DeployTx, DeployerError } from './types.ts';
import { useCallback, useEffect, useMemo, useState } from 'react';

export function useDeployer<T>(chainId?: ChainId): Deploy<T> {
const { account } = useWallet();
Expand Down
4 changes: 2 additions & 2 deletions packages/useink/src/react/hooks/contracts/useDryRun.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMemo, useState } from 'react';
import {
DecodedTxResult,
LazyCallOptions,
Expand All @@ -8,7 +9,6 @@ import { useDefaultCaller } from '../config/index';
import { useWallet } from '../wallets/useWallet.ts';
import { ChainContract } from './types.ts';
import { useAbiMessage } from './useAbiMessage.ts';
import { useMemo, useState } from 'react';

export type DryRunResult<T> = DecodedTxResult<T>;

Expand All @@ -21,7 +21,7 @@ export interface DryRun<T> {
send: Send<T>;
isSubmitting: boolean;
result?: DryRunResult<T>;
resolved: Boolean;
resolved: boolean;
resetState: () => void;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { IEventLike } from '@polkadot/types/types/events';
import { useContext, useEffect } from 'react';
import { Bytes } from '../../../core/index';
import { getExpiredItem } from '../../../utils/index';
import { FIVE_SECONDS, HALF_A_SECOND } from '../../constants.ts';
Expand All @@ -6,8 +8,6 @@ import { useConfig } from '../config/useConfig.ts';
import { useInterval } from '../internal/useInterval.ts';
import { useBlockHeader } from '../substrate/useBlockHeader.ts';
import { ChainContract } from './types.ts';
import { IEventLike } from '@polkadot/types/types/events';
import { useContext, useEffect } from 'react';

export const useEventSubscription = (
chainContract: ChainContract | undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/useEvents.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useContext, useMemo } from 'react';
import { AccountId } from '../../../core/index';
import { Event, EventsContext } from '../../providers/events/index';
import { RemoveEventPayload } from '../../providers/events/model.ts';
import { useContext, useMemo } from 'react';

export interface Events {
events: Event[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useState } from 'react';
import { SignatureResult } from '../../../core/index.ts';
import { useWallet } from '../wallets/useWallet.ts';
import { useCallback, useState } from 'react';

export type Sign = (data?: string) => void;

Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/useMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useEffect, useState } from 'react';
import { ChainId } from '../../../chains';
import {
DEFAULT,
Expand All @@ -7,7 +8,6 @@ import {
} from '../../../core';
import { MetadataError, toBasicMetadata } from '../../../utils';
import { useApi } from '../substrate/useApi';
import { useEffect, useState } from 'react';

export interface BasicMetadataFile {
data: Uint8Array;
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/useSalter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isValidHash, pseudoRandomHex } from '../../../utils';
import { useCallback, useState } from 'react';
import { isValidHash, pseudoRandomHex } from '../../../utils';

export enum SalterError {
InvalidHash = 'Invalid salt hash value.',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { signatureVerify } from '../../../utils';
import { useCallback, useState } from 'react';
import { signatureVerify } from '../../../utils';

type VerificationParams = Parameters<typeof signatureVerify>;

Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/useTx.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useMemo, useState } from 'react';
import {
ApiBase,
ContractSubmittableResult,
Expand All @@ -10,7 +11,6 @@ import { useWallet } from '../wallets/useWallet.ts';
import { ChainContract } from './types.ts';
import { useDryRun } from './useDryRun.ts';
import { useTxEvents } from './useTxEvents.ts';
import { useMemo, useState } from 'react';

export type ContractSubmittableResultCallback = (
result?: ContractSubmittableResult,
Expand Down
2 changes: 1 addition & 1 deletion packages/useink/src/react/hooks/contracts/useTxEvents.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useState } from 'react';
import { EventRecord } from '../../../core';
import { isInBlock } from '../../../utils';
import { Tx } from './useTx';
import { useCallback, useEffect, useState } from 'react';

type Eventable = Pick<Tx<unknown>, 'status'> & Pick<Tx<unknown>, 'result'>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCallback, useState } from 'react';
import { ChainContract, useDefaultCaller } from '..';
import {
LazyCallOptions,
Expand All @@ -6,7 +7,6 @@ import {
txPaymentInfo,
} from '../../../core';
import { useWallet } from '../wallets/useWallet.ts';
import { useCallback, useState } from 'react';

type Send = (
params?: unknown[],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { unixMilliToDate } from '../../../utils/helpers/unixMilliToDate';
import { useMemo } from 'react';
import { unixMilliToDate } from '../../../utils/helpers/unixMilliToDate';

export const useUnixMilliToDate = (
unixInMilliSeconds: number | undefined,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useEffect, useState } from 'react';
import { ChainId } from '../../../../chains/index';
import { DeriveBalancesAccount, WithAddress } from '../../../../core/index';
import { getBalance } from '../../../../core/index';
import { useChain } from '../../index';
import { useApi } from '../useApi.ts';
import { useBlockHeader } from '../useBlockHeader.ts';
import { useEffect, useState } from 'react';

export const useBalance = (
account: WithAddress | undefined,
Expand Down
Loading