Skip to content

Commit 9e34919

Browse files
authored
Merge pull request #5833 from EdgeApp/william/lint-fixes
Fix lint warnings in various files
2 parents 297c434 + 6aa6b92 commit 9e34919

File tree

8 files changed

+41
-28
lines changed

8 files changed

+41
-28
lines changed

eslint.config.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export default [
159159
'src/components/modals/FiatListModal.tsx',
160160
'src/components/modals/FioCreateHandleModal.tsx',
161161
'src/components/modals/FioExpiredModal.tsx',
162-
'src/components/modals/FlipInputModal2.tsx',
162+
163163
'src/components/modals/FundAccountModal.tsx',
164164
'src/components/modals/GradientFadeout.tsx',
165165
'src/components/modals/HelpModal.tsx',
@@ -175,7 +175,7 @@ export default [
175175
'src/components/modals/ScamWarningModal.tsx',
176176
'src/components/modals/ScanModal.tsx',
177177
'src/components/modals/StateProvinceListModal.tsx',
178-
'src/components/modals/SurveyModal.tsx',
178+
179179
'src/components/modals/SwapVerifyTermsModal.tsx',
180180
'src/components/modals/TextInputModal.tsx',
181181
'src/components/modals/TransferModal.tsx',
@@ -260,7 +260,7 @@ export default [
260260
'src/components/scenes/inputs/DigitInput/PinDots.tsx',
261261
'src/components/scenes/LoadingScene.tsx',
262262
'src/components/scenes/Loans/LoanCloseScene.tsx',
263-
'src/components/scenes/Loans/LoanCreateConfirmationScene.tsx',
263+
264264
'src/components/scenes/Loans/LoanCreateScene.tsx',
265265
'src/components/scenes/Loans/LoanDashboardScene.tsx',
266266
'src/components/scenes/Loans/LoanDetailsScene.tsx',
@@ -334,14 +334,13 @@ export default [
334334
'src/components/text/AssetChangeText.tsx',
335335
'src/components/text/FiatText.tsx',
336336

337-
'src/components/text/SectionHeading.tsx',
338337
'src/components/text/TitleText.tsx',
339338
'src/components/themed/Alert.tsx',
340339
'src/components/themed/BuyCrypto.tsx',
341340
'src/components/themed/CreateWalletSelectCryptoRow.tsx',
342341
'src/components/themed/DividerLine.tsx',
343342
'src/components/themed/EdgeProviderComponent.tsx',
344-
'src/components/themed/EdgeText.tsx',
343+
345344
'src/components/themed/ExplorerCard.tsx',
346345
'src/components/themed/Fade.tsx',
347346

@@ -442,7 +441,6 @@ export default [
442441
'src/plugins/borrow-plugins/plugins/aave/index.ts',
443442

444443
'src/plugins/gui/providers/bityProvider.ts',
445-
'src/plugins/gui/providers/ioniaProvider.ts',
446444

447445
'src/plugins/gui/providers/moonpayProvider.ts',
448446
'src/plugins/gui/providers/mtpelerinProvider.ts',
@@ -489,7 +487,7 @@ export default [
489487
'src/types/reactRedux.ts',
490488
'src/util/borrowUtils.ts',
491489
'src/util/cleaners.ts',
492-
'src/util/cleanFetch.ts',
490+
493491
'src/util/crypto.ts',
494492
'src/util/CryptoAmount.ts',
495493
'src/util/cryptoTextUtils.ts',

src/components/modals/FlipInputModal2.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ const FlipInputModal2Component = React.forwardRef<FlipInputModalRef, Props>(
165165
}
166166
})
167167

168-
const renderErrorMessage = () => {
168+
const renderErrorMessage = (): React.ReactElement => {
169169
const opacity = errorMessage == null ? 0 : 1
170170
return (
171171
<EdgeText
@@ -177,7 +177,7 @@ const FlipInputModal2Component = React.forwardRef<FlipInputModalRef, Props>(
177177
)
178178
}
179179

180-
const renderExchangeRates = () => {
180+
const renderExchangeRates = (): React.ReactElement => {
181181
return (
182182
<View style={styles.rateBalanceContainer}>
183183
<EdgeText style={styles.secondaryTitle}>
@@ -188,7 +188,7 @@ const FlipInputModal2Component = React.forwardRef<FlipInputModalRef, Props>(
188188
)
189189
}
190190

191-
const renderBalance = () => {
191+
const renderBalance = (): React.ReactElement => {
192192
const { multiplier, name } = displayDenom
193193
const balance = `${formatNumber(
194194
div(balanceCrypto, multiplier, DECIMAL_PRECISION)
@@ -208,7 +208,7 @@ const FlipInputModal2Component = React.forwardRef<FlipInputModalRef, Props>(
208208
)
209209
}
210210

211-
const renderFees = () => {
211+
const renderFees = (): React.ReactElement => {
212212
const feeDisplayAmountTemp = div(
213213
feeNativeAmount,
214214
feeDisplayDenom.multiplier,
@@ -234,7 +234,7 @@ const FlipInputModal2Component = React.forwardRef<FlipInputModalRef, Props>(
234234
<EdgeText style={styles.primaryTitle}>
235235
{lstrings.string_fee}
236236
</EdgeText>
237-
{onFeesChange ? (
237+
{onFeesChange != null ? (
238238
<FontAwesomeIcon
239239
name="edit"
240240
style={styles.feeIcon}
@@ -251,7 +251,7 @@ const FlipInputModal2Component = React.forwardRef<FlipInputModalRef, Props>(
251251
)
252252
}
253253

254-
const renderFlipInput = () => {
254+
const renderFlipInput = (): React.ReactElement => {
255255
return (
256256
<EdgeCard marginRem={[0, 0.5, 0.5]}>
257257
<ExchangedFlipInput2

src/components/modals/SurveyModal.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ type LocaleSubcategory = Record<string, string>
4747

4848
type SurveyOption2Keys = keyof InstallSurvey2['surveyOptions2']
4949

50-
export const SurveyModal = (props: { bridge: AirshipBridge<void> }) => {
50+
interface Props {
51+
bridge: AirshipBridge<void>
52+
}
53+
54+
export const SurveyModal: React.FC<Props> = props => {
5155
const { bridge } = props
5256
const dispatch = useDispatch()
5357
const theme = useTheme()
@@ -220,10 +224,10 @@ export const SurveyModal = (props: { bridge: AirshipBridge<void> }) => {
220224
)
221225
}
222226

223-
const SurveyModal2 = (props: {
227+
const SurveyModal2: React.FC<{
224228
bridge: AirshipBridge<boolean>
225229
category: SurveyOption2Keys
226-
}) => {
230+
}> = props => {
227231
const { bridge, category } = props
228232
const dispatch = useDispatch()
229233
const theme = useTheme()

src/components/scenes/Loans/LoanCreateConfirmationScene.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const FEE_VOLATILITY_MULTIPLIER: Record<string, string> = {
6666

6767
interface Props extends EdgeAppSceneProps<'loanCreateConfirmation'> {}
6868

69-
export const LoanCreateConfirmationScene = (props: Props) => {
69+
export const LoanCreateConfirmationScene: React.FC<Props> = props => {
7070
const dispatch = useDispatch()
7171

7272
const { navigation, route } = props
@@ -238,7 +238,9 @@ export const LoanCreateConfirmationScene = (props: Props) => {
238238
? max(minFeeSwapAmount, networkFeeAmount)
239239
: networkFeeAmount
240240

241-
const handleSliderComplete = async (resetSlider: () => void) => {
241+
const handleSliderComplete = async (
242+
resetSlider: () => void
243+
): Promise<void> => {
242244
if (actionProgram != null && loanAccount != null) {
243245
try {
244246
// Make sure to start the borrow engine

src/components/text/SectionHeading.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface Props {
1010
}
1111

1212
/** @deprecated Use SectionHeader component **/
13-
export function SectionHeading(props: Props) {
13+
export const SectionHeading: React.FC<Props> = props => {
1414
const { children, style } = props
1515

1616
const theme = useTheme()

src/components/themed/EdgeText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { fixSides, mapSides, sidesToMargin } from '../../util/sides'
1111
import { cacheStyles, type Theme, useTheme } from '../services/ThemeContext'
1212

13-
export const androidAdjustTextStyle = (theme: Theme) => {
13+
export const androidAdjustTextStyle = (theme: Theme): TextStyle | null => {
1414
const styles = getStyles(theme)
1515
return Platform.OS === 'android' ? styles.androidAdjust : null
1616
}

src/plugins/gui/providers/ioniaProvider.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ export const asIoniaPurchaseCard = asObject({
106106
userId: asNumber
107107
})
108108

109-
const asIoniaResponse = <Data>(asData: Cleaner<Data>) =>
109+
const asIoniaResponse = <Data>(
110+
asData: Cleaner<Data>
111+
): Cleaner<{
112+
Data: Data
113+
Successful: boolean
114+
ErrorMessage: string
115+
}> =>
110116
asObject({
111117
Data: asData,
112118
Successful: asBoolean,
@@ -295,7 +301,7 @@ export const makeIoniaProvider: FiatProviderFactory<IoniaMethods> = {
295301
//
296302

297303
let hiddenCardIds: number[] = asStoreHiddenCards(
298-
await store.getItem(STORE_HIDDEN_CARDS_KEY).catch(_ => undefined)
304+
await store.getItem(STORE_HIDDEN_CARDS_KEY).catch(() => {})
299305
)
300306
let purchaseCardTimeoutId: NodeJS.Timeout
301307
const ratesCache: Record<
@@ -357,7 +363,7 @@ export const makeIoniaProvider: FiatProviderFactory<IoniaMethods> = {
357363
return rate
358364
}
359365

360-
function checkAmountMinMax(fiatAmount: number) {
366+
function checkAmountMinMax(fiatAmount: number): void {
361367
if (fiatAmount > MAX_FIAT_CARD_PURCHASE_AMOUNT) {
362368
throw new Error(
363369
sprintf(
@@ -576,8 +582,8 @@ export const makeIoniaProvider: FiatProviderFactory<IoniaMethods> = {
576582
}
577583
}
578584
})
579-
.catch(err => {
580-
console.error(new Error(err))
585+
.catch((err: unknown) => {
586+
console.error(err)
581587
reject(err)
582588
})
583589
})
@@ -592,7 +598,7 @@ export const makeIoniaProvider: FiatProviderFactory<IoniaMethods> = {
592598
async authenticate(shouldCreate = false) {
593599
const localUserName = await store
594600
.getItem(STORE_USERNAME_KEY)
595-
.catch(_ => undefined)
601+
.catch(() => {})
596602

597603
if (localUserName == null && !shouldCreate) return false
598604

src/util/cleanFetch.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ export function cleanFetch<RequestPayload, ResponsePayload>(
8484
schema: FetchSchema<RequestPayload, ResponsePayload>
8585
): Fetcher<RequestPayload, ResponsePayload> {
8686
const { asRequest, asResponse, resource } = schema
87-
const wasRequest = asRequest ? uncleaner(asRequest) : (r: unknown) => r
87+
const wasRequest =
88+
asRequest != null ? uncleaner(asRequest) : (r: unknown) => r
8889

8990
const fetcher = async (
9091
input?: FetchInput<RequestPayload>
@@ -103,7 +104,9 @@ export function cleanFetch<RequestPayload, ResponsePayload>(
103104
if (!fetchResponse.ok) {
104105
const message = await fetchResponse.text()
105106
throw new Error(
106-
`${String(url)} ${fetchResponse.status}${message ? `: ${message}` : ''}`
107+
`${String(url)} ${fetchResponse.status}${
108+
message !== '' ? `: ${message}` : ''
109+
}`
107110
)
108111
}
109112

0 commit comments

Comments
 (0)