Skip to content

Commit

Permalink
chore: fix eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Burtey committed Apr 17, 2024
1 parent a96fc97 commit 5de819d
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 58 deletions.
11 changes: 5 additions & 6 deletions __tests__/hooks/use-display-currency.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,11 @@ const wrapWithMocks =


(mocks) =>
({ children }: PropsWithChildren) =>
(
<IsAuthedContextProvider value={true}>
<MockedProvider mocks={mocks}>{children}</MockedProvider>
</IsAuthedContextProvider>
)
({ children }: PropsWithChildren) => (
<IsAuthedContextProvider value={true}>
<MockedProvider mocks={mocks}>{children}</MockedProvider>
</IsAuthedContextProvider>
)

describe("usePriceConversion", () => {
describe("testing moneyAmountToMajorUnitOrSats", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe("amount lightning payment details", () => {
const paymentDetails = createAmountLightningPaymentDetails(defaultParams)
const senderSpecifiedMemo = "sender memo"
if (!paymentDetails.canSetMemo) throw new Error("Memo is unable to be set")

const newPaymentDetails = paymentDetails.setMemo(senderSpecifiedMemo)
expect(newPaymentDetails.memo).toEqual(senderSpecifiedMemo)
})
Expand All @@ -174,7 +174,9 @@ describe("amount lightning payment details", () => {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(sendingWalletDescriptor)
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
6 changes: 4 additions & 2 deletions __tests__/payment-details/amount-onchain.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe("no amount onchain payment details", () => {
const paymentDetails = createAmountOnchainPaymentDetails(defaultParams)
const senderSpecifiedMemo = "sender memo"
if (!paymentDetails.canSetMemo) throw new Error("Memo is unable to be set")

const newPaymentDetails = paymentDetails.setMemo(senderSpecifiedMemo)
expect(newPaymentDetails.memo).toEqual(senderSpecifiedMemo)
})
Expand All @@ -180,7 +180,9 @@ describe("no amount onchain payment details", () => {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(sendingWalletDescriptor)
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
6 changes: 4 additions & 2 deletions __tests__/payment-details/intraledger-payment-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ describe("intraledger payment details", () => {
const paymentDetails = createIntraledgerPaymentDetails(defaultParams)
const senderSpecifiedMemo = "sender memo"
if (!paymentDetails.canSetMemo) throw new Error("Memo is unable to be set")

const newPaymentDetails = paymentDetails.setMemo(senderSpecifiedMemo)
expect(newPaymentDetails.memo).toEqual(senderSpecifiedMemo)
})
Expand All @@ -168,7 +168,9 @@ describe("intraledger payment details", () => {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(sendingWalletDescriptor)
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
4 changes: 3 additions & 1 deletion __tests__/payment-details/lnurl-payment-details.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ describe("lnurl payment details", () => {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(sendingWalletDescriptor)
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe("no amount lightning payment details", () => {
const paymentDetails = createNoAmountLightningPaymentDetails(defaultParams)
const senderSpecifiedMemo = "sender memo"
if (!paymentDetails.canSetMemo) throw new Error("Memo is unable to be set")

const newPaymentDetails = paymentDetails.setMemo(senderSpecifiedMemo)
expect(newPaymentDetails.memo).toEqual(senderSpecifiedMemo)
})
Expand All @@ -215,7 +215,9 @@ describe("no amount lightning payment details", () => {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(sendingWalletDescriptor)
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
6 changes: 4 additions & 2 deletions __tests__/payment-details/no-amount-onchain.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe("no amount lightning payment details", () => {
const paymentDetails = createNoAmountOnchainPaymentDetails(defaultParams)
const senderSpecifiedMemo = "sender memo"
if (!paymentDetails.canSetMemo) throw new Error("Memo is unable to be set")

const newPaymentDetails = paymentDetails.setMemo(senderSpecifiedMemo)
expect(newPaymentDetails.memo).toEqual(senderSpecifiedMemo)
})
Expand All @@ -212,7 +212,9 @@ describe("no amount lightning payment details", () => {
currency: WalletCurrency.Btc,
id: "newtestwallet",
}
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(sendingWalletDescriptor)
const newPaymentDetails = paymentDetails.setSendingWalletDescriptor(
sendingWalletDescriptor,
)
expect(newPaymentDetails.sendingWalletDescriptor).toEqual(sendingWalletDescriptor)
})
})
36 changes: 18 additions & 18 deletions app/components/transaction-item/index.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ type DeepPartialPrimitive = Primitive | Date | RegExp
export type DeepPartial<T> = T extends DeepPartialPrimitive
? T
: T extends Map<infer TKey, infer TValue>
? DeepPartialMap<TKey, TValue>
: T extends ReadonlyMap<infer TKey, infer TValue>
? DeepPartialReadonlyMap<TKey, TValue>
: T extends Set<infer TItem>
? DeepPartialSet<TItem>
: T extends ReadonlySet<infer TItem>
? DeepPartialReadonlySet<TItem>
: T extends (...args: unknown[]) => unknown
? T | undefined
: T extends object
? T extends ReadonlyArray<infer TItem>
? TItem[] extends T
? readonly TItem[] extends T
? ReadonlyArray<DeepPartial<TItem | undefined>>
: Array<DeepPartial<TItem | undefined>>
: DeepPartialObject<T>
: DeepPartialObject<T>
: unknown
? DeepPartialMap<TKey, TValue>
: T extends ReadonlyMap<infer TKey, infer TValue>
? DeepPartialReadonlyMap<TKey, TValue>
: T extends Set<infer TItem>
? DeepPartialSet<TItem>
: T extends ReadonlySet<infer TItem>
? DeepPartialReadonlySet<TItem>
: T extends (...args: unknown[]) => unknown
? T | undefined
: T extends object
? T extends ReadonlyArray<infer TItem>
? TItem[] extends T
? readonly TItem[] extends T
? ReadonlyArray<DeepPartial<TItem | undefined>>
: Array<DeepPartial<TItem | undefined>>
: DeepPartialObject<T>
: DeepPartialObject<T>
: unknown
export type DeepPartialObject<T extends object> = {
[K in keyof T]?: DeepPartial<T[K]>
}
4 changes: 2 additions & 2 deletions app/components/transaction-item/transaction-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ const TransactionItem: React.FC<Props> = ({
const amountStyle = isPending
? styles.pending
: isReceive
? styles.receive
: styles.send
? styles.receive
: styles.send

const walletCurrency = tx.settlementCurrency as WalletCurrency

Expand Down
11 changes: 7 additions & 4 deletions app/hooks/use-display-currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,13 @@ export const useDisplayCurrency = () => {

const displayCurrencyDictionary = useMemo(() => {
const currencyList = dataCurrencyList?.currencyList || []
return currencyList.reduce((acc, currency) => {
acc[currency.id] = currency
return acc
}, {} as Record<string, typeof defaultDisplayCurrency>)
return currencyList.reduce(
(acc, currency) => {
acc[currency.id] = currency
return acc
},
{} as Record<string, typeof defaultDisplayCurrency>,
)
}, [dataCurrencyList?.currencyList])

const displayCurrencyInfo =
Expand Down
4 changes: 2 additions & 2 deletions app/screens/earns-screen/earns-quiz.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ export const EarnQuiz = ({ route }: Props) => {
return recordedAnswer.indexOf(i) === -1
? styles.quizButtonStyle
: i === 0
? styles.quizCorrectButtonStyle
: styles.quizWrongButtonStyle
? styles.quizCorrectButtonStyle
: styles.quizWrongButtonStyle
}

let j: ZeroTo2 = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ const SendBitcoinConfirmationScreen: React.FC<Props> = ({ route }) => {
{hideAmount
? "****"
: sendingWalletDescriptor.currency === WalletCurrency.Btc
? btcWalletText
: usdWalletText}
? btcWalletText
: usdWalletText}
</Text>
</View>
<View />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ const SendBitcoinDetailsScreen: React.FC<Props> = ({ route }) => {
{hideAmount
? "****"
: sendingWalletDescriptor.currency === WalletCurrency.Btc
? btcWalletText
: usdWalletText}
? btcWalletText
: usdWalletText}
</Text>
</View>
</View>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"yalc:check": "yalc check",
"update-translations": "yarn typesafe-i18n && yarn typesafe-i18n:export",
"typesafe-i18n": "typesafe-i18n --no-watch",
"typesafe-i18n:export": "ts-node --cwdMode utils/export-language.ts",
"typesafe-i18n:export": "node utils/export-language.mjs",
"fonts": "npx react-native-asset",
"apk:debug": "cd android && ./gradlew assembleDebug",
"start:appium": "appium",
Expand Down
16 changes: 6 additions & 10 deletions utils/export-language.ts → utils/export-language.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import fs from "fs"
import { BaseTranslation } from "typesafe-i18n"
import path from "path"
import { fileURLToPath } from "url"
import { readTranslationFromDisk } from "typesafe-i18n/exporter"

// Getting the directory name from the URL of the current module
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const DEFAULT_RAW_EXPORT_PATH = `${__dirname}/../app/i18n/raw-i18n`

const writeToFile = async (
translation: BaseTranslation,
locale: string,
directory: string,
) => {
const writeToFile = async (translation, locale, directory) => {
const filePath = `${directory}/${locale}.json`
const data = JSON.stringify(translation, null, 4) + "\n"
fs.writeFile(filePath, data, (err) => {
Expand All @@ -19,10 +18,7 @@ const writeToFile = async (
})
}

const exportTranslationsForLocale = async (
locale: string,
directory: string,
): Promise<boolean> => {
const exportTranslationsForLocale = async (locale, directory) => {
const mapping = await readTranslationFromDisk(locale)
const translation = Array.isArray(mapping.translations)
? mapping.translations[0]
Expand Down

0 comments on commit 5de819d

Please sign in to comment.