From 7a0162a0c39d792a2df38cf02d95b2ba20ca4214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ram=C3=B3n=20Huidobro?= Date: Sun, 29 Oct 2023 14:46:10 +0100 Subject: [PATCH] Add linting, fix errors --- guest-list-mobile/app/_layout.tsx | 36 +++++++------- guest-list-mobile/app/index.tsx | 42 +++++++++-------- guest-list-mobile/app/new-guest.tsx | 54 +++++++++++---------- guest-list-mobile/components/GuestItem.tsx | 55 +++++++++++----------- guest-list-mobile/components/Header.tsx | 29 ++++++------ guest-list-mobile/package.json | 3 +- 6 files changed, 114 insertions(+), 105 deletions(-) diff --git a/guest-list-mobile/app/_layout.tsx b/guest-list-mobile/app/_layout.tsx index d58c6b9..af2ef89 100644 --- a/guest-list-mobile/app/_layout.tsx +++ b/guest-list-mobile/app/_layout.tsx @@ -1,10 +1,25 @@ -import { useFonts, Pacifico_400Regular } from '@expo-google-fonts/pacifico'; -import { StyleSheet, Text, View } from 'react-native'; -import Header from '../components/Header'; -import { StatusBar } from 'expo-status-bar'; import { Slot, usePathname } from 'expo-router'; +import { StatusBar } from 'expo-status-bar'; +import { StyleSheet, View } from 'react-native'; + +import { Pacifico_400Regular, useFonts } from '@expo-google-fonts/pacifico'; + +import Header from '../components/Header'; import { colors } from '../styles/constants'; +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: colors.background, + paddingBottom: 40, + }, + slot: { + flex: 1, + paddingLeft: 30, + paddingRight: 30, + }, +}); + function routeMapping(pathname: string) { switch (pathname) { case '/': @@ -38,16 +53,3 @@ export default function HomeLayout() { ); } - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: colors.background, - paddingBottom: 40, - }, - slot: { - flex: 1, - paddingLeft: 30, - paddingRight: 30, - }, -}); diff --git a/guest-list-mobile/app/index.tsx b/guest-list-mobile/app/index.tsx index 50dbdbe..342d9ef 100644 --- a/guest-list-mobile/app/index.tsx +++ b/guest-list-mobile/app/index.tsx @@ -1,9 +1,29 @@ -import { FlatList, StyleSheet, Text, View } from 'react-native'; -import GuestItem from '../components/GuestItem'; import { useEffect, useState } from 'react'; + import { Link, useLocalSearchParams } from 'expo-router'; +import { FlatList, StyleSheet } from 'react-native'; + +import GuestItem from '../components/GuestItem'; import { colors } from '../styles/constants'; +const styles = StyleSheet.create({ + list: { + marginTop: 30, + paddingLeft: 30, + paddingRight: 30, + width: '100%', + }, + button: { + marginTop: 30, + paddingTop: 10, + paddingBottom: 10, + width: '100%', + textAlign: 'center', + backgroundColor: colors.cardBackground, + fontSize: 24, + }, +}); + type Guest = { id: string; firstName: string; @@ -61,21 +81,3 @@ export default function Index() { ); } - -const styles = StyleSheet.create({ - list: { - marginTop: 30, - paddingLeft: 30, - paddingRight: 30, - width: '100%', - }, - button: { - marginTop: 30, - paddingTop: 10, - paddingBottom: 10, - width: '100%', - textAlign: 'center', - backgroundColor: colors.cardBackground, - fontSize: 24, - }, -}); diff --git a/guest-list-mobile/app/new-guest.tsx b/guest-list-mobile/app/new-guest.tsx index 8e0e5ef..ef4b1e1 100644 --- a/guest-list-mobile/app/new-guest.tsx +++ b/guest-list-mobile/app/new-guest.tsx @@ -1,7 +1,33 @@ import { useState } from 'react'; -import { StyleSheet, Text, TextInput } from 'react-native'; -import { colors } from '../styles/constants'; + import { Link } from 'expo-router'; +import { StyleSheet, TextInput } from 'react-native'; + +import { colors } from '../styles/constants'; + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: colors.background, + alignItems: 'center', + justifyContent: 'center', + }, + input: { + marginTop: 30, + paddingLeft: 30, + paddingRight: 30, + width: '100%', + }, + button: { + marginTop: 30, + paddingTop: 10, + paddingBottom: 10, + width: '100%', + textAlign: 'center', + backgroundColor: colors.cardBackground, + fontSize: 24, + }, +}); export default function NewGuest() { const [firstName, setFirstName] = useState(''); @@ -29,27 +55,3 @@ export default function NewGuest() { ); } - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: colors.background, - alignItems: 'center', - justifyContent: 'center', - }, - input: { - marginTop: 30, - paddingLeft: 30, - paddingRight: 30, - width: '100%', - }, - button: { - marginTop: 30, - paddingTop: 10, - paddingBottom: 10, - width: '100%', - textAlign: 'center', - backgroundColor: colors.cardBackground, - fontSize: 24, - }, -}); diff --git a/guest-list-mobile/components/GuestItem.tsx b/guest-list-mobile/components/GuestItem.tsx index 5a48b1b..05f3558 100644 --- a/guest-list-mobile/components/GuestItem.tsx +++ b/guest-list-mobile/components/GuestItem.tsx @@ -1,32 +1,7 @@ -import { StyleSheet, Text, View } from 'react-native'; -import { colors } from '../styles/constants'; import { Link } from 'expo-router'; +import { StyleSheet, Text, View } from 'react-native'; -type Guest = { - id: string; - firstName: string; - lastName: string; - deadline?: string; - attending: boolean; -}; - -type Props = { - guest: Guest; -}; - -export default function GuestItem({ guest }: Props) { - const { firstName, lastName, attending } = guest; - - return ( - - - {firstName} {lastName} - - Check it out - {attending ? 'Coming!' : 'Not Coming'} - - ); -} +import { colors } from '../styles/constants'; const styles = StyleSheet.create({ right: { @@ -57,3 +32,29 @@ const styles = StyleSheet.create({ textAlign: 'left', }, }); + +type Guest = { + id: string; + firstName: string; + lastName: string; + deadline?: string; + attending: boolean; +}; + +type Props = { + guest: Guest; +}; + +export default function GuestItem({ guest }: Props) { + const { firstName, lastName, attending } = guest; + + return ( + + + {firstName} {lastName} + + Check it out + {attending ? 'Coming!' : 'Not Coming'} + + ); +} diff --git a/guest-list-mobile/components/Header.tsx b/guest-list-mobile/components/Header.tsx index 50fbdf5..b31374a 100644 --- a/guest-list-mobile/components/Header.tsx +++ b/guest-list-mobile/components/Header.tsx @@ -1,19 +1,7 @@ -import { SafeAreaView, View, Text, StyleSheet } from 'react-native'; -import { colors } from '../styles/constants'; import Constants from 'expo-constants'; +import { SafeAreaView, StyleSheet, Text, View } from 'react-native'; -type Props = { - label: string; -}; -export default function Header(props: Props) { - return ( - - - {props.label} - - - ); -} +import { colors } from '../styles/constants'; const styles = StyleSheet.create({ safeArea: { @@ -31,3 +19,16 @@ const styles = StyleSheet.create({ fontFamily: 'Pacifico_400Regular', }, }); + +type Props = { + label: string; +}; +export default function Header(props: Props) { + return ( + + + {props.label} + + + ); +} diff --git a/guest-list-mobile/package.json b/guest-list-mobile/package.json index e09e316..ab7a7a0 100644 --- a/guest-list-mobile/package.json +++ b/guest-list-mobile/package.json @@ -6,7 +6,8 @@ "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", - "web": "expo start --web" + "web": "expo start --web", + "lint": "eslint --ext .js --ignore-path .gitignore ." }, "dependencies": { "@expo-google-fonts/pacifico": "^0.2.3",