chore: update prettier

This commit is contained in:
Jan Komarek
2024-01-30 16:43:47 +01:00
committed by Jan Komárek
parent 886a75567a
commit 00fe229e01
35 changed files with 116 additions and 121 deletions

View File

@@ -4,7 +4,6 @@
"bracketSpacing": true,
"singleQuote": true,
"semi": true,
"trailingComma": "all",
"tabWidth": 4,
"useTabs": false,
"bracketSameLine": false,
@@ -25,6 +24,7 @@
{
"files": ["tsconfig.json"],
"options": {
"trailingComma": "none",
"printWidth": 50
}
}

View File

@@ -86,7 +86,7 @@
"resolutions": {
"typescript": "5.3.2",
"react-native": "0.73.2",
"prettier": "3.0.3",
"prettier": "3.2.4",
"type-fest": "2.12.2",
"bcrypto": "5.4.0",
"react": "18.2.0",
@@ -137,7 +137,7 @@
"npm-run-all": "^4.1.5",
"nx": "^17.2.8",
"patch-package": "8.0.0",
"prettier": "3.0.3",
"prettier": "3.2.4",
"prettier-eslint": "^16.3.0",
"rimraf": "^5.0.5",
"semver": "^7.5.4",

View File

@@ -22,26 +22,26 @@ type MessageType = Message['type'];
type ResponseType<T extends MessageType> = T extends typeof MESSAGES.GET_INFO
? typeof RESPONSES.GET_INFO
: T extends typeof MESSAGES.GET_BLOCK_HASH
? typeof RESPONSES.GET_BLOCK_HASH
: T extends typeof MESSAGES.GET_ACCOUNT_INFO
? typeof RESPONSES.GET_ACCOUNT_INFO
: T extends typeof MESSAGES.GET_ACCOUNT_UTXO
? typeof RESPONSES.GET_ACCOUNT_UTXO
: T extends typeof MESSAGES.GET_TRANSACTION
? typeof RESPONSES.GET_TRANSACTION
: T extends typeof MESSAGES.GET_TRANSACTION_HEX
? typeof RESPONSES.GET_TRANSACTION_HEX
: T extends typeof MESSAGES.GET_ACCOUNT_BALANCE_HISTORY
? typeof RESPONSES.GET_ACCOUNT_BALANCE_HISTORY
: T extends typeof MESSAGES.ESTIMATE_FEE
? typeof RESPONSES.ESTIMATE_FEE
: T extends typeof MESSAGES.PUSH_TRANSACTION
? typeof RESPONSES.PUSH_TRANSACTION
: T extends typeof MESSAGES.SUBSCRIBE
? typeof RESPONSES.SUBSCRIBE
: T extends typeof MESSAGES.UNSUBSCRIBE
? typeof RESPONSES.UNSUBSCRIBE
: never;
? typeof RESPONSES.GET_BLOCK_HASH
: T extends typeof MESSAGES.GET_ACCOUNT_INFO
? typeof RESPONSES.GET_ACCOUNT_INFO
: T extends typeof MESSAGES.GET_ACCOUNT_UTXO
? typeof RESPONSES.GET_ACCOUNT_UTXO
: T extends typeof MESSAGES.GET_TRANSACTION
? typeof RESPONSES.GET_TRANSACTION
: T extends typeof MESSAGES.GET_TRANSACTION_HEX
? typeof RESPONSES.GET_TRANSACTION_HEX
: T extends typeof MESSAGES.GET_ACCOUNT_BALANCE_HISTORY
? typeof RESPONSES.GET_ACCOUNT_BALANCE_HISTORY
: T extends typeof MESSAGES.ESTIMATE_FEE
? typeof RESPONSES.ESTIMATE_FEE
: T extends typeof MESSAGES.PUSH_TRANSACTION
? typeof RESPONSES.PUSH_TRANSACTION
: T extends typeof MESSAGES.SUBSCRIBE
? typeof RESPONSES.SUBSCRIBE
: T extends typeof MESSAGES.UNSUBSCRIBE
? typeof RESPONSES.UNSUBSCRIBE
: never;
type Reply<T extends MessageType> = Without<Extract<Response, { type: ResponseType<T> }>, 'id'>;
const onRequest = async <T extends Message>(

View File

@@ -328,14 +328,12 @@ const findTokenAccountOwner = (
accounts: SubscriptionAccountInfo[],
accountDescriptor: string,
): SubscriptionAccountInfo | undefined =>
accounts.find(
account =>
account.tokens?.find(
token =>
token.accounts?.find(
tokenAccount => tokenAccount.publicKey.toString() === accountDescriptor,
),
accounts.find(account =>
account.tokens?.find(token =>
token.accounts?.find(
tokenAccount => tokenAccount.publicKey.toString() === accountDescriptor,
),
),
);
const subscribeAccounts = async (

View File

@@ -24,8 +24,8 @@ export const useElevation = (forceElevation?: Elevation) => {
forceElevation !== undefined
? forceElevation
: elevation !== null
? nextElevation[elevation]
: 0,
? nextElevation[elevation]
: 0,
[elevation, forceElevation],
);

View File

@@ -7,7 +7,9 @@
]
},
"plugins": [
{ "name": "typescript-styled-plugin" }
{
"name": "typescript-styled-plugin"
}
],
"outDir": "./libDev"
},

View File

@@ -265,8 +265,8 @@ export default class SignTransaction extends AbstractMethod<'signTransaction', P
);
if (bitcoinTx.hasWitnesses()) {
response.witnesses = bitcoinTx.ins.map(
(_, i) => bitcoinTx?.getWitness(i)?.toString('hex'),
response.witnesses = bitcoinTx.ins.map((_, i) =>
bitcoinTx?.getWitness(i)?.toString('hex'),
);
}
}

View File

@@ -4,11 +4,8 @@ import type { TrezorConnect } from '../types/api';
import type { CommonParams } from '../types/params';
// conditionally unwrap TrezorConnect api method Success<T> response
type UnwrappedResponse<T> = T extends Promise<infer R>
? R extends { success: true; payload: infer P }
? P
: never
: void;
type UnwrappedResponse<T> =
T extends Promise<infer R> ? (R extends { success: true; payload: infer P } ? P : never) : void;
// https://github.com/microsoft/TypeScript/issues/32164
// there is no native way how to get Parameters<Fn> for overloaded function
@@ -19,8 +16,8 @@ type OverloadedMethod<T, E extends Record<string, string>> = T extends {
}
? ((params: P1 & E) => R1) | ((params: P2 & E) => R2) // - method IS overloaded, result depends on params (example: getAddress)
: T extends (...args: infer P) => infer R
? (params: E & P[0]) => R // - method in NOT overloaded, one set of params and one set of result (example: signTransaction)
: never;
? (params: E & P[0]) => R // - method in NOT overloaded, one set of params and one set of result (example: signTransaction)
: never;
type UnwrappedMethod<T, M extends Record<string, string>> = T extends () => infer R
? (params: M & CommonParams) => R // - method doesn't have params (example: dispose, disableWebUSB)

View File

@@ -19,7 +19,7 @@
},
"devDependencies": {
"@sinclair/typebox-codegen": "^0.8.13",
"prettier": "^3.0.3",
"prettier": "3.2.4",
"tsx": "^4.6.2",
"typescript": "5.3.2"
},

View File

@@ -8,11 +8,10 @@ type UnionToIntersection<U> = (U extends unknown ? (arg: U) => 0 : never) extend
: never;
// LastInUnion<A | B> = B
type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (
x: infer L,
) => 0
? L
: never;
type LastInUnion<U> =
UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer L) => 0
? L
: never;
// Build a tuple for the object
// Strategy - take the last key, add it to the tuple, and recurse on the rest
@@ -20,10 +19,10 @@ type LastInUnion<U> = UnionToIntersection<U extends unknown ? (x: U) => 0 : neve
type ObjectKeysToTuple<T, Last = LastInUnion<keyof T>> = [T] extends [never]
? []
: [Last] extends [never]
? []
: Last extends string | number
? [...ObjectKeysToTuple<Omit<T, Last>>, TLiteral<Last>]
: [];
? []
: Last extends string | number
? [...ObjectKeysToTuple<Omit<T, Last>>, TLiteral<Last>]
: [];
export interface TKeyOfEnum<T extends Record<string, string | number>>
extends TUnion<ObjectKeysToTuple<T>> {

View File

@@ -102,6 +102,7 @@ export type Status = {
process: boolean;
};
export type InvokeResult<Payload = undefined> = ExtractUndefined<Payload> extends undefined
? { success: true; payload?: Payload } | { success: false; error: string; code?: string }
: { success: true; payload: Payload } | { success: false; error: string; code?: string };
export type InvokeResult<Payload = undefined> =
ExtractUndefined<Payload> extends undefined
? { success: true; payload?: Payload } | { success: false; error: string; code?: string }
: { success: true; payload: Payload } | { success: false; error: string; code?: string };

View File

@@ -17,9 +17,10 @@ export type ExtractUndefined<U> = (U extends undefined ? (k: U) => void : never)
? I
: never;
type OptionalParams<C, P> = ExtractUndefined<P> extends undefined
? (channel: C, payload?: P) => void
: (channel: C, payload: P) => void;
type OptionalParams<C, P> =
ExtractUndefined<P> extends undefined
? (channel: C, payload?: P) => void
: (channel: C, payload: P) => void;
export type StrictChannel = { [name: string]: any };

View File

@@ -139,7 +139,7 @@
"@types/zxcvbn": "^4.4.3",
"jest-canvas-mock": "^2.5.2",
"jest-watch-typeahead": "2.2.2",
"prettier": "3.0.3",
"prettier": "3.2.4",
"react-test-renderer": "^18.2.0",
"redux-devtools-extension": "^2.13.9",
"redux-mock-store": "^1.5.4",

View File

@@ -31,8 +31,8 @@ export const CoinGroup = ({ onToggle, networks, selectedNetworks, className }: C
const supportedNetworks = networks.filter(network =>
deviceSupportedNetworkSymbols.includes(network.symbol),
);
const isAtLeastOneActive = supportedNetworks.some(
({ symbol }) => selectedNetworks?.includes(symbol),
const isAtLeastOneActive = supportedNetworks.some(({ symbol }) =>
selectedNetworks?.includes(symbol),
);
const onSettings = (symbol: Network['symbol']) => {

View File

@@ -42,8 +42,8 @@ export const useSavingsSetup = ({
const providers = useSelector(
state => state.wallet.coinmarket.savings.savingsInfo?.savingsList?.providers,
);
const userCountry = useSelector(
state => state.wallet.coinmarket.savings.savingsInfo?.country?.toUpperCase(),
const userCountry = useSelector(state =>
state.wallet.coinmarket.savings.savingsInfo?.country?.toUpperCase(),
);
const savingsTrade = useSelector(state => state.wallet.coinmarket.savings.savingsTrade);
const isSavingsTradeLoading = useSelector(

View File

@@ -285,8 +285,8 @@ export const coinjoinMiddleware =
const { accountKeys } = action.payload;
const isAlreadyPaused = api
.getState()
.wallet.coinjoin.accounts.find(({ key }) => key === accountKeys[0])?.session
?.paused;
.wallet.coinjoin.accounts.find(({ key }) => key === accountKeys[0])
?.session?.paused;
if (action.payload.phase === SessionPhase.CriticalError && !isAlreadyPaused) {
action.payload.accountKeys.forEach(key =>

View File

@@ -90,9 +90,8 @@ export const initialState: CoinjoinState = {
},
};
type ExtractActionPayload<A> = Extract<Action, { type: A }> extends { type: A; payload: infer P }
? P
: never;
type ExtractActionPayload<A> =
Extract<Action, { type: A }> extends { type: A; payload: infer P } ? P : never;
const getAccount = (draft: CoinjoinState, accountKey: string) =>
draft.accounts.find(a => a.key === accountKey);

View File

@@ -36,9 +36,8 @@ export const isStepUsed = (step: Step, getState: GetState) => {
if (path.length === 0) {
return true;
}
return path.every(
(pathMember: AnyPath) =>
step.path?.some((stepPathMember: AnyPath) => stepPathMember === pathMember),
return path.every((pathMember: AnyPath) =>
step.path?.some((stepPathMember: AnyPath) => stepPathMember === pathMember),
);
};

View File

@@ -83,15 +83,15 @@ export const splitToQuoteCategories = (
fixedOK.length > 0
? fixedOK.concat(fixedMinMax)
: okLength > 0
? []
: fixedMinMax.concat(fixedError);
? []
: fixedMinMax.concat(fixedError);
const floatQuotes =
// eslint-disable-next-line no-nested-ternary
floatOK.length > 0
? floatOK.concat(floatMinMax)
: okLength > 0
? []
: floatMinMax.concat(floatError);
? []
: floatMinMax.concat(floatError);
const dexQuotes =
// eslint-disable-next-line no-nested-ternary
dexOK.length > 0 ? dexOK.concat(dexMinMax) : okLength > 0 ? [] : dexMinMax.concat(dexError);

View File

@@ -4,8 +4,8 @@ import { AggregatedAccountHistory, AggregatedDashboardHistory } from 'src/types/
export type ObjectType<T> = T extends 'account'
? AggregatedAccountHistory
: T extends 'dashboard'
? AggregatedDashboardHistory
: never;
? AggregatedDashboardHistory
: never;
export type TypeName = 'account' | 'dashboard';

View File

@@ -148,8 +148,8 @@ const CoinmarketSavingsSetup = (props: WithSelectedAccountLoadedProps) => {
<StyledSelect
value={value}
label={<Translation id="TR_SAVINGS_UNSUPPORTED_COUNTRY_SELECT_LABEL" />}
options={regional.countriesOptions.filter(
item => supportedCountries?.has(item.value),
options={regional.countriesOptions.filter(item =>
supportedCountries?.has(item.value),
)}
isSearchable
formatOptionLabel={(option: CountryOption) => {

View File

@@ -12,7 +12,7 @@
"dependencies": {
"@mobily/ts-belt": "^3.13.1",
"csstype": "^3.1.2",
"prettier": "3.0.3"
"prettier": "3.2.4"
},
"devDependencies": {
"tsx": "^4.7.0",

View File

@@ -93,8 +93,8 @@ export interface HandleMessageApi {
type UnwrapParams<T, Fn> = Fn extends () => any
? Params & { type: T }
: Fn extends (payload: infer P) => any
? Params & { type: T; payload: P }
: never;
? Params & { type: T; payload: P }
: never;
type UnwrappedParams = {
[K in keyof HandleMessageApi]: UnwrapParams<K, HandleMessageApi[K]>;

View File

@@ -42,8 +42,8 @@ export type Await<T> = T extends {
export type DeepPartial<T> = T extends () => any
? T
: T extends { [key: string]: any }
? { [P in keyof T]?: DeepPartial<T[P]> }
: T;
? { [P in keyof T]?: DeepPartial<T[P]> }
: T;
export type PrimitiveType = string | number | boolean | Date | null | undefined;

View File

@@ -19,10 +19,10 @@ type TPrimitives = string | number | boolean | bigint | symbol | Date | TFunctio
type TMerged<T> = [T] extends [Array<any>]
? { [K in keyof T]: TMerged<T[K]> }
: [T] extends [TPrimitives]
? T
: [T] extends [object]
? TPartialKeys<{ [K in TAllKeys<T>]: TMerged<TIndexValue<T, K>> }, never>
: T;
? T
: [T] extends [object]
? TPartialKeys<{ [K in TAllKeys<T>]: TMerged<TIndexValue<T, K>> }, never>
: T;
// istanbul ignore next
const isObject = (obj: any) => {

View File

@@ -25,13 +25,14 @@ type EventKey<T extends EventMap> = string & keyof T;
type IsUnion<T, U extends T = T> = T extends unknown ? ([U] extends [T] ? 0 : 1) : 2;
// NOTE: case 1. looks like case 4. but works differently. the order matters
type EventReceiver<T> = IsUnion<T> extends 1
? (event: T) => void // 1. use union payload
: T extends (...args: any[]) => any
? T // 2. use custom callback
: T extends undefined
? () => void // 3. enforce empty params
: (event: T) => void; // 4. default
type EventReceiver<T> =
IsUnion<T> extends 1
? (event: T) => void // 1. use union payload
: T extends (...args: any[]) => any
? T // 2. use custom callback
: T extends undefined
? () => void // 3. enforce empty params
: (event: T) => void; // 4. default
export interface TypedEmitter<T extends EventMap> {
on<K extends EventKey<T>>(eventName: K, fn: EventReceiver<T[K]>): this;

View File

@@ -90,8 +90,8 @@ export interface ComposeRequest<
type ComposedTransactionOutputs<T> = T extends ComposeOutputSendMax
? Omit<T, 'type'> & ComposeOutputPayment // NOTE: replace ComposeOutputSendMax (no amount) with ComposeOutputPayment (with amount)
: T extends ComposeFinalOutput
? T
: never;
? T
: never;
export interface ComposedTransaction<
Input extends ComposeInput,

View File

@@ -12,7 +12,7 @@
"dotenv": "^16.4.1",
"fs-extra": "^11.1.1",
"octokit": "3.1.2",
"prettier": "3.0.3",
"prettier": "3.2.4",
"sort-package-json": "^1.57.0",
"yargs": "17.7.2"
},

View File

@@ -76,8 +76,8 @@ export const selectContextMessageContent = memoizeWithArgs(
export const selectFeatureMessage = memoizeWithArgs(
(state: MessageSystemRootState, domain: FeatureDomain) => {
const activeFeatureMessages = selectActiveFeatureMessages(state);
return activeFeatureMessages.find(
message => message.feature?.some(feature => feature.domain === domain),
return activeFeatureMessages.find(message =>
message.feature?.some(feature => feature.domain === domain),
);
},
);

View File

@@ -196,8 +196,8 @@ export const selectPendingAccountAddresses = memoizeWithArgs(
const pendingAddresses: string[] = [];
const pendingTxs = accountTransactions.filter(isPending);
pendingTxs.forEach(t =>
t.targets.forEach(
target => target.addresses?.forEach(a => pendingAddresses.unshift(a)),
t.targets.forEach(target =>
target.addresses?.forEach(a => pendingAddresses.unshift(a)),
),
);
return pendingAddresses;

View File

@@ -30,9 +30,8 @@ export const blockchainMiddleware = createMiddleware(
break;
case TREZOR_CONNECT_BLOCKCHAIN_ACTIONS.BLOCK:
const networksWithPendingTransactions = selectNetworksWithPendingTransactions(
getState(),
);
const networksWithPendingTransactions =
selectNetworksWithPendingTransactions(getState());
const symbol = action.payload.coin.shortcut.toLowerCase() as NetworkSymbol;
if (networksWithPendingTransactions.includes(symbol)) {

View File

@@ -451,9 +451,8 @@ export const startDescriptorPreloadedDiscoveryThunk = createThunk(
// For development purposes, you can disable some networks to have quicker discovery in dev utils
if (isDebugEnv()) {
const disabledNetworkSymbols = selectDisabledDiscoveryNetworkSymbolsForDevelopment(
getState(),
);
const disabledNetworkSymbols =
selectDisabledDiscoveryNetworkSymbolsForDevelopment(getState());
supportedNetworks = supportedNetworks.filter(
n => !disabledNetworkSymbols.includes(n.symbol),
);

View File

@@ -17,5 +17,5 @@ type RecursiveKeyOfInner<TObj extends object> = {
type RecursiveKeyOfHandleValue<TValue, Text extends string> = TValue extends any[]
? Text
: TValue extends object
? Text | `${Text}${RecursiveKeyOfInner<TValue>}`
: Text;
? Text | `${Text}${RecursiveKeyOfInner<TValue>}`
: Text;

View File

@@ -15,7 +15,7 @@
"@suite-native/atoms": "workspace:*",
"@trezor/styles": "workspace:*",
"expo-av": "13.10.3",
"prettier": "3.0.3",
"prettier": "3.2.4",
"react": "18.2.0",
"react-native": "0.73.2",
"tsx": "^4.7.0"

View File

@@ -8701,7 +8701,7 @@ __metadata:
"@suite-native/atoms": "workspace:*"
"@trezor/styles": "workspace:*"
expo-av: "npm:13.10.3"
prettier: "npm:3.0.3"
prettier: "npm:3.2.4"
react: "npm:18.2.0"
react-native: "npm:0.73.2"
tsx: "npm:^4.7.0"
@@ -9544,7 +9544,7 @@ __metadata:
dependencies:
"@sinclair/typebox": "npm:^0.31.28"
"@sinclair/typebox-codegen": "npm:^0.8.13"
prettier: "npm:^3.0.3"
prettier: "npm:3.2.4"
ts-mixer: "npm:^6.0.3"
tsx: "npm:^4.6.2"
typescript: "npm:5.3.2"
@@ -9561,7 +9561,7 @@ __metadata:
chalk: "npm:^4.1.2"
dotenv: "npm:^16.4.1"
fs-extra: "npm:^11.1.1"
prettier: "npm:3.0.3"
prettier: "npm:3.2.4"
sort-package-json: "npm:^1.57.0"
tsx: "npm:4.6.2"
typescript: "npm:5.3.2"
@@ -9931,7 +9931,7 @@ __metadata:
pako: "npm:^2.1.0"
pdfmake: "npm:^0.2.7"
polished: "npm:^4.2.2"
prettier: "npm:3.0.3"
prettier: "npm:3.2.4"
qrcode.react: "npm:^3.1.0"
react: "npm:18.2.0"
react-dom: "npm:18.2.0"
@@ -9975,7 +9975,7 @@ __metadata:
dependencies:
"@mobily/ts-belt": "npm:^3.13.1"
csstype: "npm:^3.1.2"
prettier: "npm:3.0.3"
prettier: "npm:3.2.4"
tsx: "npm:^4.7.0"
typescript: "npm:5.3.2"
languageName: unknown
@@ -27522,12 +27522,12 @@ __metadata:
languageName: node
linkType: hard
"prettier@npm:3.0.3":
version: 3.0.3
resolution: "prettier@npm:3.0.3"
"prettier@npm:3.2.4":
version: 3.2.4
resolution: "prettier@npm:3.2.4"
bin:
prettier: bin/prettier.cjs
checksum: ccf1ead9794b017be6b42d0873f459070beef2069eb393c8b4c0d11aa3430acefc54f6d5f44a5b7ce9af05ad8daf694b912f0aa2808d1c22dfa86e61e9d563f8
checksum: e2b735d0552501b3a7ac8bd3ba3b6de2920bb35bd4cd02d08cb9057ebe3e96d83b9a7e4b903d987b7530a50223b12c74d107c154337236ae2c68156ba1e65cd2
languageName: node
linkType: hard
@@ -32283,7 +32283,7 @@ __metadata:
npm-run-all: "npm:^4.1.5"
nx: "npm:^17.2.8"
patch-package: "npm:8.0.0"
prettier: "npm:3.0.3"
prettier: "npm:3.2.4"
prettier-eslint: "npm:^16.3.0"
rimraf: "npm:^5.0.5"
semver: "npm:^7.5.4"