Skip to content

Commit

Permalink
Update mobile eslint preset
Browse files Browse the repository at this point in the history
  • Loading branch information
aelassas committed Feb 27, 2024
1 parent fc82f21 commit 9df5669
Show file tree
Hide file tree
Showing 47 changed files with 95 additions and 98 deletions.
6 changes: 6 additions & 0 deletions mobile/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
],
"react/prop-types": "off",
"react-hooks/exhaustive-deps": "warn",
"react/function-component-definition": [
"warn",
{
"namedComponents": "arrow-function"
}
],
"no-console": "off",
"curly": "error",
"@typescript-eslint/no-explicit-any": "off",
Expand Down
2 changes: 1 addition & 1 deletion mobile/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SplashScreen.preventAutoHideAsync()
.then((result) => console.log(`SplashScreen.preventAutoHideAsync() succeeded: ${result}`))
.catch(console.warn) // it's good to explicitly catch and inspect any error

function App() {
const App = () => {
const [appIsReady, setAppIsReady] = useState(false)
const responseListener = useRef<Notifications.Subscription>()
const navigationRef = useRef<NavigationContainerRef<StackParams>>(null)
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ interface AccordionProps {
children?: React.ReactNode
}

function Accordion({
const Accordion = ({
style,
title,
children
}: AccordionProps) {
}: AccordionProps) => {
const [open, setOpen] = useState(false)
const animatedController = useRef(new Animated.Value(0)).current

Expand Down
4 changes: 2 additions & 2 deletions mobile/components/AgencyFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ interface AgencyFilterProps {
onChange?: (checkedAgencies: string[]) => void
}

function AgencyFilter({
const AgencyFilter = ({
visible,
style,
onLoad,
onChange
}: AgencyFilterProps) {
}: AgencyFilterProps) => {
const [agencies, setAgencies] = useState<movininTypes.User[]>([])
const [checkedAgencies, setCheckedAgencies] = useState<string[]>([])
const [allChecked, setAllChecked] = useState(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useRef } from 'react'
import { Animated, Easing } from 'react-native'

export const withFadeAnimation = (WrappedComponent: () => React.JSX.Element, containerStyle?: object) => {
function FadeAnimation(props: object) {
const FadeAnimation = (props: object) => {
const opacityAnimationValue = useRef(new Animated.Value(0)).current

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion mobile/components/AutocompleteDropdown/NothingFound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { memo } from 'react'
import { StyleSheet, Text, View } from 'react-native'
import { withFadeAnimation } from './HOC/withFadeAnimation'

function EmptyResult({ ...props }) {
const EmptyResult = ({ ...props }) => {
const EL = withFadeAnimation(
() => (
<View style={{ ...styles.container }}>
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/AutocompleteDropdown/RightButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Feather from 'react-native-vector-icons/Feather'

Feather.loadFont()

function RightButtonComponent({
const RightButtonComponent = ({
inputHeight,
isOpened,
showChevron,
Expand All @@ -34,7 +34,7 @@ function RightButtonComponent({
ClearIconComponent?: boolean
onClearPress: () => void
onChevronPress: () => void
}) {
}) => {
const isOpenedAnimationValue = useRef(new Animated.Value(0)).current

useEffect(() => {
Expand Down
6 changes: 2 additions & 4 deletions mobile/components/AutocompleteDropdown/ScrollViewListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
View
} from 'react-native'

function ScrollViewListItemComponent({
const ScrollViewListItemComponent = ({
titleHighlighted,
titleStart,
titleEnd,
Expand All @@ -21,8 +21,7 @@ function ScrollViewListItemComponent({
style?: object
numberOfLines?: number
onPress: () => void
}) {
return (
}) => (
<Pressable onPress={onPress}>
<View style={styles.container}>
<Text numberOfLines={numberOfLines}>
Expand All @@ -39,7 +38,6 @@ function ScrollViewListItemComponent({
</View>
</Pressable>
)
}

export const ScrollViewListItem = memo(ScrollViewListItemComponent)

Expand Down
4 changes: 1 addition & 3 deletions mobile/components/Backdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ interface BackdropProps {
message?: string
}

function Backdrop({ message }: BackdropProps) {
return (
const Backdrop = ({ message }: BackdropProps) => (
<View style={styles.container}>
{message && <Text style={styles.text}>{message}</Text>}
</View>
)
}

const styles = StyleSheet.create({
container: {
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/Booking.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ const iconColor = '#000'
const extraIconColor = '#1f9201'
const extraIconSize = 16

function Booking({
const Booking = ({
booking,
locale,
fr,
onCancel
}: BookingProps) {
}: BookingProps) => {
const from = new Date(booking.from)
const to = new Date(booking.to)
const property = booking.property as movininTypes.Property
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/BookingFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ interface BookingFilterProps {
onSubmit: (filter: movininTypes.Filter) => void
}

function BookingFilter({
const BookingFilter = ({
visible,
style,
language,
onSubmit
}: BookingFilterProps) {
}: BookingFilterProps) => {
const [init, setInit] = useState(false)
const [from, setFrom] = useState<Date | undefined>(undefined)
const [to, setTo] = useState<Date | undefined>(undefined)
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/BookingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ interface BookingListProps {
header?: React.ReactElement
}

function BookingList({
const BookingList = ({
agencies,
statuses,
filter,
user,
booking: bookingId,
language,
header
}: BookingListProps) {
}: BookingListProps) => {
const [firstLoad, setFirstLoad] = useState(true)
const [onScrollEnd, setOnScrollEnd] = useState(false)
const [loading, setLoading] = useState(true)
Expand Down
6 changes: 2 additions & 4 deletions mobile/components/BookingStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ interface BookingStatusProps {
status: movininTypes.BookingStatus
}

function BookingStatus({
const BookingStatus = ({
style,
status
}: BookingStatusProps) {
return (
}: BookingStatusProps) => (
<View
style={{
...styles.container,
Expand All @@ -37,7 +36,6 @@ function BookingStatus({
<Text style={styles.text}>{Helper.getBookingStatus(status)}</Text>
</View>
)
}

const styles = StyleSheet.create({
container: {
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ interface ButtonProps {
onPress?: () => void
}

function Button({
const Button = ({
size,
color,
style,
label,
onPress: onButtonPress
}: ButtonProps) {
}: ButtonProps) => {
const small = size === 'small'

const onPress = () => {
Expand Down
6 changes: 2 additions & 4 deletions mobile/components/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ interface CheckboxProps {
onChange?: (_checked: boolean) => void
}

function Checkbox({
const Checkbox = ({
indeterminate,
checked,
onChange
}: CheckboxProps) {
return (
}: CheckboxProps) => (
<Pressable
onPress={() => {
if (onChange) {
Expand All @@ -26,7 +25,6 @@ function Checkbox({
<MaterialIcons name={indeterminate ? 'indeterminate-check-box' : checked ? 'check-box' : 'check-box-outline-blank'} size={24} color={indeterminate || checked ? '#1976d2' : '#606264'} />
</Pressable>
)
}

const styles = StyleSheet.create({
checkbox: {
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/DateTimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface DateTimePickerProps {
onChange?: (date: Date | undefined) => void
}

function DateTimePicker({
const DateTimePicker = ({
value: dateTimeValue,
locale: dateTimeLocale,
mode,
Expand All @@ -48,7 +48,7 @@ function DateTimePicker({
hidePickerMessage,
onPress,
onChange
}: DateTimePickerProps) {
}: DateTimePickerProps) => {
const [label, setLabel] = useState('')
const [value, setValue] = useState<Date | undefined>(dateTimeValue)
const [show, setShow] = useState(false)
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/DrawerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interface DrawerContentProps {

let yOffset = 0

function DrawerContent({
const DrawerContent = ({
language: drawerLanguage,
index,
drawerItems,
Expand All @@ -55,7 +55,7 @@ function DrawerContent({
labelStyle,
itemStyle,
props
}: DrawerContentProps) {
}: DrawerContentProps) => {
const navigation = useNavigation<NativeStackNavigationProp<StackParams, keyof StackParams>>()
const [openLanguageMenu, setopenLanguageMenu] = useState(false)
const [language, setLanguage] = useState(drawerLanguage)
Expand Down
2 changes: 1 addition & 1 deletion mobile/components/DrawerNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import DrawerContent from './DrawerContent'
import CheckoutScreen from '../screens/Checkout'
import NotificationsScreen from '../screens/NotificationsScreen'

function DrawerNavigator() {
const DrawerNavigator = () => {
const routes = useNavigationState((state) => state && state.routes)
const index = useNavigationState((state) => state && state.index)
const [loggedIn, setLoggedIn] = useState(false)
Expand Down
6 changes: 2 additions & 4 deletions mobile/components/Error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ interface ErrorProps {
message: string
}

function Error({
const Error = ({
style,
message
}: ErrorProps) {
return (
}: ErrorProps) => (
<View style={style}>
<Text style={styles.text}>{message}</Text>
</View>
)
}

const styles = StyleSheet.create({
text: {
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ interface HeaderProps {
_avatar?: string | null
}

function Header({
const Header = ({
title,
hideTitle,
loggedIn,
notificationCount,
reload,
_avatar
}: HeaderProps) {
}: HeaderProps) => {
const navigation = useNavigation<NativeStackNavigationProp<StackParams, keyof StackParams>>()
const [avatar, setAvatar] = useState<string | null | undefined>(null)

Expand Down
4 changes: 2 additions & 2 deletions mobile/components/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ interface LinkProps {
onPress?: () => void
}

function Link({
const Link = ({
style,
textStyle,
label,
onPress: onLinkPress
}: LinkProps) {
}: LinkProps) => {
const onPress = () => {
if (onLinkPress) {
onLinkPress()
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/LocationSelectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface LocationSelectListProps {
onFocus?: () => void
}

function LocationSelectList({
const LocationSelectList = ({
selectedItem: listSelectedItem,
size,
style,
Expand All @@ -33,7 +33,7 @@ function LocationSelectList({
onFetch,
onChangeText: listOnChangeText,
onFocus
}: LocationSelectListProps) {
}: LocationSelectListProps) => {
const [loading, setLoading] = useState(false)
const [rows, setRows] = useState<AutocompleteOption[]>([])
const [selectedItem, setSelectedItem] = useState<string>()
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/Master.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface MasterProps {
onLoad: (user?: movininTypes.User) => void
}

function Master({
const Master = ({
navigation,
strict,
route,
Expand All @@ -37,7 +37,7 @@ function Master({
avatar,
children,
onLoad
}: MasterProps) {
}: MasterProps) => {
const [loading, setLoading] = useState(true)
const [user, setUser] = useState<movininTypes.User | null>(null)
const [loggedIn, setLoggedIn] = useState(false)
Expand Down
4 changes: 2 additions & 2 deletions mobile/components/Property.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ const iconColor = '#000'
const getExtraIcon = (extra: number) =>
(extra === -1 ? 'clear' : extra === 0 ? 'check' : 'info')

function Property({
const Property = ({
property,
fr,
from,
to,
location,
navigation
}: PropertyProps) {
}: PropertyProps) => {
const { width } = useWindowDimensions()
const days = movininHelper.days(from, to)
const price = Helper.price(property, from, to)
Expand Down
Loading

0 comments on commit 9df5669

Please sign in to comment.