Skip to content

Commit 94feb06

Browse files
committed
Require explicit function return types w/ ESLint.
1 parent 9870cad commit 94feb06

34 files changed

+112
-80
lines changed

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ module.exports = {
3333
'@typescript-eslint/restrict-plus-operands': 'off',
3434
'@typescript-eslint/no-dynamic-delete': 'off',
3535
'@typescript-eslint/no-var-requires': 'off',
36-
'@typescript-eslint/explicit-function-return-type': 'off', // TODO: Enable later.
3736
// Adjust to Prettier's presence. (Maybe we should do away with it later.)
3837
'@typescript-eslint/space-before-function-paren': 'off',
3938
'@typescript-eslint/member-delimiter-style': 'off',

src/App.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ export interface RootStackParamList {
4343
Home: undefined
4444
Chat: { serverName: string; version: number }
4545
}
46-
type HomeNavigationProp = NativeStackNavigationProp<RootStackParamList, 'Home'>
46+
type HomeProp = NativeStackNavigationProp<RootStackParamList, 'Home'>
4747

48-
const HomeScreen = ({ navigation }: { navigation: HomeNavigationProp }) => {
48+
const HomeScreen = ({ navigation }: { navigation: HomeProp }): JSX.Element => {
4949
const { connection } = React.useContext(ConnectionContext)
5050
React.useEffect(() => {
5151
if (connection) {
@@ -92,7 +92,7 @@ const HomeScreen = ({ navigation }: { navigation: HomeNavigationProp }) => {
9292
)
9393
}
9494

95-
const App = () => {
95+
const App = (): JSX.Element => {
9696
const [connection, setConnection] = React.useState<
9797
ServerConnection | undefined
9898
>()
@@ -109,9 +109,9 @@ const App = () => {
109109
const [serversStore, setServersStore] = useAsyncStorage('@servers', '{}')
110110
const accounts: Accounts = JSON.parse(accountsStore)
111111
const servers: Servers = JSON.parse(serversStore)
112-
const setAccounts = (newAccounts: Accounts) =>
112+
const setAccounts = (newAccounts: Accounts): void =>
113113
setAccountsStore(JSON.stringify(newAccounts))
114-
const setServers = (newServers: Servers) =>
114+
const setServers = (newServers: Servers): void =>
115115
setServersStore(JSON.stringify(newServers))
116116

117117
const colorScheme = useColorScheme()

src/components/Dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Dialog = ({
1717
visible: boolean
1818
onRequestClose: () => void
1919
containerStyles?: ViewStyle
20-
}>) => (
20+
}>): JSX.Element => (
2121
<Modal
2222
animationType='fade'
2323
transparent

src/components/DisconnectDialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import Dialog, { dialogStyles } from './Dialog'
1212
import Text from './Text'
1313

14-
const DisconnectDialog = () => {
14+
const DisconnectDialog = (): JSX.Element => {
1515
const darkMode = useDarkMode()
1616
const { disconnectReason, setDisconnectReason } =
1717
useContext(ConnectionContext)

src/components/ElevatedView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import useDarkMode from '../context/useDarkMode'
44

55
const ElevatedView = (
66
props: React.PropsWithChildren<{ style?: ViewStyle }>
7-
) => (
7+
): JSX.Element => (
88
<View
99
{...props}
1010
style={Object.assign(

src/components/Text.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from 'react-native'
88
import useDarkMode from '../context/useDarkMode'
99

10-
const Text = (props: React.PropsWithChildren<TextProps>) => (
10+
const Text = (props: React.PropsWithChildren<TextProps>): JSX.Element => (
1111
<RNText
1212
{...props}
1313
style={[

src/components/TextField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import { TextInput, StyleSheet, type TextInputProps } from 'react-native'
33
import useDarkMode from '../context/useDarkMode'
44

5-
const TextField = (props: TextInputProps & { red?: boolean }) => {
5+
const TextField = (props: TextInputProps & { red?: boolean }): JSX.Element => {
66
const style = props.style?.valueOf()
77
const darkMode = useDarkMode()
88
return (

src/components/TextFieldDialog.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ const TextFieldDialog = ({
2424
closeModal: () => void
2525
initialState: string
2626
setFinalState: (state: string) => void
27-
}) => {
27+
}): JSX.Element => {
2828
const [modalContent, setModalContent] = useState(initialState)
29-
const closeModalAndSaveState = () => {
29+
const closeModalAndSaveState = (): void => {
3030
setFinalState(modalContent)
3131
closeModal()
3232
}
33-
const closeModalAndReset = () => {
33+
const closeModalAndReset = (): void => {
3434
setModalContent(initialState)
3535
closeModal()
3636
}

src/components/accounts/AccountDisplay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const AccountDisplay = ({
1616
darkMode: boolean
1717
setActiveAccount: (uuid: string) => void
1818
setDeleteAccount: (uuid: string) => void
19-
}) => (
19+
}): JSX.Element => (
2020
<ElevatedView style={styles.accountView}>
2121
<Pressable
2222
onPress={() => setActiveAccount(uuid)}

src/components/accounts/AddAccountDialog.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const AddAccountDialog = ({
1616
}: {
1717
open: boolean
1818
setOpen: React.Dispatch<React.SetStateAction<boolean>>
19-
}) => {
19+
}): JSX.Element => {
2020
const darkMode = useDarkMode()
2121
const { accounts, setAccounts } = useContext(UsersContext)
2222

@@ -32,7 +32,7 @@ const AddAccountDialog = ({
3232
!/^[A-Za-z0-9_]{3,16}$/.test(newUser) &&
3333
(password === null ? true : !/^[^\s@]+@[^\s@]+$/.test(newUser))
3434

35-
const cancelAddAccount = () => {
35+
const cancelAddAccount = (): void => {
3636
setMicrosoftLogin(false)
3737
setOpen(false)
3838
setUserRed(false)
@@ -41,7 +41,7 @@ const AddAccountDialog = ({
4141
setPassword(null) // setPassword('')
4242
setDialogError('')
4343
}
44-
const addAccount = () => {
44+
const addAccount = (): void => {
4545
const accountExists =
4646
!!accounts[newUser] ||
4747
!!Object.keys(accounts).find(id => accounts[id].email === newUser)

0 commit comments

Comments
 (0)