Skip to content

Commit b59e66b

Browse files
authored
Merge pull request #5730 from EdgeApp/william/lint-fixes
Lint fixes
2 parents 62dc6ae + f1649f8 commit b59e66b

File tree

17 files changed

+44
-72
lines changed

17 files changed

+44
-72
lines changed

eslint.config.mjs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ export default [
5757
'scripts/secretFiles.ts',
5858
'scripts/themeServer.ts',
5959
'scripts/updateVersion.ts',
60-
'src/__tests__/components/CreateWalletSelectCryptoRow.test.tsx',
61-
'src/__tests__/components/MenuTabs.test.tsx',
62-
'src/__tests__/utils.test.ts',
63-
'src/__tests__/utils/parseMarkedText.test.ts',
6460
'src/actions/BackupModalActions.tsx',
6561
'src/actions/CategoriesActions.ts',
6662
'src/actions/CountryListActions.tsx',
@@ -212,13 +208,10 @@ export default [
212208
'src/components/notification/NotificationView.tsx',
213209
'src/components/progress-indicators/AccountSyncBar.tsx',
214210
'src/components/progress-indicators/CancellableProcessingScene.tsx',
215-
'src/components/progress-indicators/CircleTimer.tsx',
216-
'src/components/progress-indicators/FillLoader.tsx',
217211
'src/components/progress-indicators/FullScreenLoader.tsx',
218212
'src/components/progress-indicators/LoadingSplashScreen.tsx',
219213
'src/components/progress-indicators/Shimmer.tsx',
220214
'src/components/progress-indicators/StepProgressBar.tsx',
221-
'src/components/progress-indicators/WalletSyncCircle.tsx',
222215
'src/components/rows/CoinRankRow.tsx',
223216
'src/components/rows/CryptoFiatAmountRow.tsx',
224217
'src/components/rows/CurrencyRow.tsx',
@@ -574,7 +567,6 @@ export default [
574567
'@typescript-eslint/no-dynamic-delete': 'warn',
575568
'@typescript-eslint/no-misused-promises': 'warn',
576569
'@typescript-eslint/prefer-nullish-coalescing': 'warn',
577-
'@typescript-eslint/prefer-optional-chain': 'warn',
578570
'@typescript-eslint/require-array-sort-compare': 'warn',
579571
'@typescript-eslint/restrict-plus-operands': 'warn',
580572
'@typescript-eslint/restrict-template-expressions': 'warn',

src/__tests__/components/CreateWalletSelectCryptoRow.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('WalletListRow', () => {
2323
it('should render with loading props', () => {
2424
const pluginId = 'bitcoin'
2525
const walletName = 'My bitcoin wallet'
26-
const onPress = () => undefined
26+
const onPress = (): void => {}
2727
const rightSide = (
2828
<IonIcon size={26} color="#66EDA8" name="chevron-forward-outline" />
2929
)

src/__tests__/components/MenuTabs.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ describe('MenuTabs', () => {
1111
const rendered = render(
1212
<FakeProviders>
1313
<MenuTabs
14-
// @ts-expect-error
14+
// @ts-expect-error The menu expects a special navigation object,
15+
// but our mock one is close enough:
1516
navigation={fakeNavigation}
16-
// @ts-expect-error
17+
// @ts-expect-error The subset of router state we need:
1718
state={{ index: 0, routes: [] }}
1819
/>
1920
</FakeProviders>

src/__tests__/utils.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,8 @@ describe('precisionAdjust', function () {
316316
}
317317
}
318318

319-
for (const key in tests) {
320-
// @ts-expect-error
321-
const { input, output } = tests[key]
319+
for (const key of Object.keys(tests)) {
320+
const { input, output } = tests[key as keyof typeof tests]
322321
const {
323322
displayDenominationMultiplier,
324323
primaryExchangeMultiplier,

src/__tests__/utils/parseMarkedText.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { describe, it } from '@jest/globals'
2-
import { asObject, asTuple, asUnknown, asValue, type Cleaner } from 'cleaners'
2+
import { asObject, asTuple, asValue, type Cleaner } from 'cleaners'
33

44
import { parseMarkedText } from '../../util/parseMarkedText'
55

66
describe('parseMarkedText', () => {
7-
const asJsxElement = (asChildren: Cleaner<any> = asUnknown) =>
7+
const asJsxElement = <T>(
8+
asChildren: Cleaner<T>
9+
): Cleaner<{ props: { children: T } }> =>
810
asObject({
911
props: asObject({
1012
children: asChildren

src/actions/NotificationActions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ async function legacyGet(path: string) {
362362
'X-Api-Key': ENV.EDGE_API_KEY
363363
}
364364
})
365-
if (response != null && response.ok) {
365+
if (response.ok) {
366366
return await response.json()
367367
} else {
368368
throw new Error('Error accessing notification server')

src/components/common/DotsBackground.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function DotsBackground(props: Props): React.ReactElement {
5151
cy: overrideDot.cy ?? dot.cy
5252
}
5353
if (mergedDot.accentColor != null) {
54-
const ac = (accentColors ?? {})[mergedDot.accentColor]
54+
const ac = accentColors?.[mergedDot.accentColor]
5555
if (ac == null) {
5656
throw new Error('Missing accentColors')
5757
}

src/components/modals/CountryListModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const CountryListModal = ({
4848
const upperCaseText = searchText.toUpperCase()
4949
return (
5050
country.name.toLowerCase().includes(lowerCaseText) ||
51-
(country.filename != null && country.filename.includes(lowerCaseText)) ||
51+
country.filename?.includes(lowerCaseText) === true ||
5252
country['alpha-2'].includes(upperCaseText) ||
5353
country['alpha-3'].includes(upperCaseText)
5454
)

src/components/progress-indicators/CircleTimer.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ interface Props {
99

1010
export const TEN_MINUTES = 600
1111

12-
export const CircleTimer: React.FC<Props> = ({ expiration, timeExpired }) => {
12+
export const CircleTimer: React.FC<Props> = props => {
13+
const { expiration, timeExpired } = props
1314
const componentMounted = useRef(true)
1415
const timeoutId = useRef<ReturnType<typeof setTimeout> | null>(null)
1516
const isFocused = useIsFocused()
1617

17-
const timerTick = () => {
18+
const timerTick = (): void => {
1819
if (!componentMounted.current || !isFocused) {
1920
if (timeoutId.current != null) {
2021
clearTimeout(timeoutId.current)
@@ -24,7 +25,7 @@ export const CircleTimer: React.FC<Props> = ({ expiration, timeExpired }) => {
2425
const now = new Date()
2526
const nowMilli = now.getTime()
2627
const expMil = expiration.getTime()
27-
if (expiration && nowMilli >= expMil) {
28+
if (nowMilli >= expMil) {
2829
timeExpired()
2930
return
3031
}
@@ -50,18 +51,12 @@ export const CircleTimer: React.FC<Props> = ({ expiration, timeExpired }) => {
5051
}, [])
5152

5253
useEffect(() => {
53-
if (expiration !== null) {
54-
if (timeoutId.current != null) {
55-
clearTimeout(timeoutId.current)
56-
}
57-
timeoutId.current = setTimeout(timerTick, 1000)
54+
if (timeoutId.current != null) {
55+
clearTimeout(timeoutId.current)
5856
}
57+
timeoutId.current = setTimeout(timerTick, 1000)
5958
// eslint-disable-next-line react-hooks/exhaustive-deps
60-
}, [expiration])
61-
62-
if (!expiration) {
63-
return null
64-
}
59+
}, [])
6560

6661
return <View style={{ width: 1, height: 1 }} />
6762
}

src/components/progress-indicators/FillLoader.tsx

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
import * as React from 'react'
2-
import {
3-
ActivityIndicator,
4-
StyleSheet,
5-
View,
6-
type ViewStyle
7-
} from 'react-native'
2+
import { ActivityIndicator, StyleSheet, View } from 'react-native'
83

9-
import { THEME } from '../../theme/variables/airbitz'
4+
import { useTheme } from '../services/ThemeContext'
105

11-
interface Props {
12-
indicatorStyles?: ViewStyle
13-
size?: 'large' | 'small'
14-
}
6+
export const FillLoader: React.FC = props => {
7+
const theme = useTheme()
158

16-
export class FillLoader extends React.Component<Props> {
17-
render() {
18-
const { size, indicatorStyles } = this.props
19-
return (
20-
<View style={styles.loadingContainer}>
21-
<ActivityIndicator
22-
color={THEME.COLORS.ACCENT_MINT}
23-
style={[styles.indicator, indicatorStyles]}
24-
size={size || 'large'}
25-
/>
26-
</View>
27-
)
28-
}
9+
return (
10+
<View style={styles.loadingContainer}>
11+
<ActivityIndicator
12+
color={theme.icon}
13+
style={styles.indicator}
14+
size="large"
15+
/>
16+
</View>
17+
)
2918
}
3019

3120
const styles = StyleSheet.create({

0 commit comments

Comments
 (0)