Skip to content

Commit

Permalink
chore: setup prettier and eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
MattAgn committed Dec 2, 2024
1 parent 9662742 commit cd58580
Show file tree
Hide file tree
Showing 31 changed files with 3,696 additions and 356 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { defineConfig } = require("eslint-define-config");

module.exports = defineConfig({
extends: [
// see source: https://github.com/bamlab/react-native-project-config/blob/main/packages/eslint-plugin/lib/configs/recommended.js
"plugin:@bam.tech/recommended",
],
});
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ node_modules/
dist/
web-build/
expo-env.d.ts
.cache

# Native
*.orig.*
Expand Down
Empty file added .vscode/extensions.json
Empty file.
22 changes: 22 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true,
"eslint.format.enable": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[javascriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescriptreact]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
}
Empty file added .vscode/tasks.json
Empty file.
35 changes: 20 additions & 15 deletions app/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
import { Tabs } from 'expo-router';
import React from 'react';
import { Platform } from 'react-native';
/* eslint-disable react/no-unstable-nested-components */
import { Tabs } from "expo-router";
import { Platform } from "react-native";

import { HapticTab } from '@/components/HapticTab';
import { IconSymbol } from '@/components/ui/IconSymbol';
import TabBarBackground from '@/components/ui/TabBarBackground';
import { Colors } from '@/constants/Colors';
import { useColorScheme } from '@/hooks/useColorScheme';
import { HapticTab } from "@/components/HapticTab";
import { IconSymbol } from "@/components/ui/IconSymbol";
import TabBarBackground from "@/components/ui/TabBarBackground";
import { Colors } from "@/constants/Colors";
import { useColorScheme } from "@/hooks/useColorScheme";

export default function TabLayout() {
const colorScheme = useColorScheme();

return (
<Tabs
screenOptions={{
tabBarActiveTintColor: Colors[colorScheme ?? 'light'].tint,
tabBarActiveTintColor: Colors[colorScheme ?? "light"].tint,
headerShown: false,
tabBarButton: HapticTab,
tabBarBackground: TabBarBackground,
tabBarStyle: Platform.select({
ios: {
// Use a transparent background on iOS to show the blur effect
position: 'absolute',
position: "absolute",
},
default: {},
}),
}}>
}}
>
<Tabs.Screen
name="index"
options={{
title: 'Home',
tabBarIcon: ({ color }) => <IconSymbol size={28} name="house.fill" color={color} />,
title: "Home",
tabBarIcon: ({ color }) => (
<IconSymbol size={28} name="house.fill" color={color} />
),
}}
/>
<Tabs.Screen
name="explore"
options={{
title: 'Explore',
tabBarIcon: ({ color }) => <IconSymbol size={28} name="paperplane.fill" color={color} />,
title: "Explore",
tabBarIcon: ({ color }) => (
<IconSymbol size={28} name="paperplane.fill" color={color} />
),
}}
/>
</Tabs>
Expand Down
92 changes: 11 additions & 81 deletions app/(tabs)/explore.tsx
Original file line number Diff line number Diff line change
@@ -1,109 +1,39 @@
import { StyleSheet, Image, Platform } from 'react-native';
import { StyleSheet } from "react-native";

import { Collapsible } from '@/components/Collapsible';
import { ExternalLink } from '@/components/ExternalLink';
import ParallaxScrollView from '@/components/ParallaxScrollView';
import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';
import { IconSymbol } from '@/components/ui/IconSymbol';
import ParallaxScrollView from "@/components/ParallaxScrollView";
import { ThemedText } from "@/components/ThemedText";
import { ThemedView } from "@/components/ThemedView";
import { IconSymbol } from "@/components/ui/IconSymbol";

export default function TabTwoScreen() {
return (
<ParallaxScrollView
headerBackgroundColor={{ light: '#D0D0D0', dark: '#353636' }}
headerBackgroundColor={{ light: "#D0D0D0", dark: "#353636" }}
headerImage={
<IconSymbol
size={310}
color="#808080"
name="chevron.left.forwardslash.chevron.right"
style={styles.headerImage}
/>
}>
}
>
<ThemedView style={styles.titleContainer}>
<ThemedText type="title">Explore</ThemedText>
</ThemedView>
<ThemedText>This app includes example code to help you get started.</ThemedText>
<Collapsible title="File-based routing">
<ThemedText>
This app has two screens:{' '}
<ThemedText type="defaultSemiBold">app/(tabs)/index.tsx</ThemedText> and{' '}
<ThemedText type="defaultSemiBold">app/(tabs)/explore.tsx</ThemedText>
</ThemedText>
<ThemedText>
The layout file in <ThemedText type="defaultSemiBold">app/(tabs)/_layout.tsx</ThemedText>{' '}
sets up the tab navigator.
</ThemedText>
<ExternalLink href="https://docs.expo.dev/router/introduction">
<ThemedText type="link">Learn more</ThemedText>
</ExternalLink>
</Collapsible>
<Collapsible title="Android, iOS, and web support">
<ThemedText>
You can open this project on Android, iOS, and the web. To open the web version, press{' '}
<ThemedText type="defaultSemiBold">w</ThemedText> in the terminal running this project.
</ThemedText>
</Collapsible>
<Collapsible title="Images">
<ThemedText>
For static images, you can use the <ThemedText type="defaultSemiBold">@2x</ThemedText> and{' '}
<ThemedText type="defaultSemiBold">@3x</ThemedText> suffixes to provide files for
different screen densities
</ThemedText>
<Image source={require('@/assets/images/react-logo.png')} style={{ alignSelf: 'center' }} />
<ExternalLink href="https://reactnative.dev/docs/images">
<ThemedText type="link">Learn more</ThemedText>
</ExternalLink>
</Collapsible>
<Collapsible title="Custom fonts">
<ThemedText>
Open <ThemedText type="defaultSemiBold">app/_layout.tsx</ThemedText> to see how to load{' '}
<ThemedText style={{ fontFamily: 'SpaceMono' }}>
custom fonts such as this one.
</ThemedText>
</ThemedText>
<ExternalLink href="https://docs.expo.dev/versions/latest/sdk/font">
<ThemedText type="link">Learn more</ThemedText>
</ExternalLink>
</Collapsible>
<Collapsible title="Light and dark mode components">
<ThemedText>
This template has light and dark mode support. The{' '}
<ThemedText type="defaultSemiBold">useColorScheme()</ThemedText> hook lets you inspect
what the user's current color scheme is, and so you can adjust UI colors accordingly.
</ThemedText>
<ExternalLink href="https://docs.expo.dev/develop/user-interface/color-themes/">
<ThemedText type="link">Learn more</ThemedText>
</ExternalLink>
</Collapsible>
<Collapsible title="Animations">
<ThemedText>
This template includes an example of an animated component. The{' '}
<ThemedText type="defaultSemiBold">components/HelloWave.tsx</ThemedText> component uses
the powerful <ThemedText type="defaultSemiBold">react-native-reanimated</ThemedText>{' '}
library to create a waving hand animation.
</ThemedText>
{Platform.select({
ios: (
<ThemedText>
The <ThemedText type="defaultSemiBold">components/ParallaxScrollView.tsx</ThemedText>{' '}
component provides a parallax effect for the header image.
</ThemedText>
),
})}
</Collapsible>
</ParallaxScrollView>
);
}

const styles = StyleSheet.create({
headerImage: {
color: '#808080',
color: "#808080",
bottom: -90,
left: -35,
position: 'absolute',
position: "absolute",
},
titleContainer: {
flexDirection: 'row',
flexDirection: "row",
gap: 8,
},
});
45 changes: 29 additions & 16 deletions app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
import { PlusCircle } from "@tamagui/lucide-icons";
import { router } from "expo-router";
import { FlatList } from "react-native";
import {
SafeAreaView,
useSafeAreaInsets,
} from "react-native-safe-area-context";
import { Button, Card, Spacer, styled, Text, View } from "tamagui";

import { Colors } from '@/constants/Colors';
import { DiaryEntry } from '@/domain/DiaryEntry';
import { fakeDiaryEntries } from '@/utils/fakeDiaryEntries';
import { FlatList } from 'react-native';
import { SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
import { Button, Card, Spacer, Text, View } from 'tamagui';
import { PlusCircle } from '@tamagui/lucide-icons';
import { router } from 'expo-router';
import { Colors } from "@/constants/Colors";
import type { DiaryEntry } from "@/domain/DiaryEntry";
import { fakeDiaryEntries } from "@/utils/fakeDiaryEntries";

export default function HomeScreen() {
const { bottom } = useSafeAreaInsets()
const { bottom } = useSafeAreaInsets();

const renderItem = ({ item }: { item: DiaryEntry }) => {
return (
<Card p="$3" marginTop="$4">
<Card.Header flexDirection="row" justifyContent="space-between">
<Text>{item.title}</Text>
<Text fontSize={10} >{item.createdAt.toLocaleDateString()}</Text>
<Text fontSize={10}>{item.createdAt.toLocaleDateString()}</Text>
</Card.Header>
<Text numberOfLines={3}>{item.content}</Text>
<Card.Footer>
</Card.Footer>
<Card.Footer></Card.Footer>
</Card>
);
};

return (
<SafeAreaView style={{ flex: 1, padding: 30, backgroundColor: Colors["light"].background, marginBottom: bottom }}>
<View flex={1} >
<StyledSafeAreaView marginBottom={bottom}>
<View flex={1}>
<Text>Mon journal</Text>
<FlatList data={fakeDiaryEntries} renderItem={renderItem} />
<Spacer scaleY={1} />
<Button icon={PlusCircle} color={Colors["light"].tint} onPress={() => router.push('/new-diary-entry')}>Nouvelle entrée</Button>
<Button
icon={PlusCircle}
color={Colors["light"].tint}
onPress={() => router.push("/new-diary-entry")}
>
Nouvelle entrée
</Button>
</View>
</SafeAreaView>
</StyledSafeAreaView>
);
}

const StyledSafeAreaView = styled(SafeAreaView, {
flex: 1,
padding: 30,
backgroundColor: Colors["light"].background,
});
16 changes: 8 additions & 8 deletions app/+not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Link, Stack } from 'expo-router';
import { StyleSheet } from 'react-native';
import { Link, Stack } from "expo-router";
import { StyleSheet } from "react-native";

import { ThemedText } from '@/components/ThemedText';
import { ThemedView } from '@/components/ThemedView';
import { ThemedText } from "@/components/ThemedText";
import { ThemedView } from "@/components/ThemedView";

export default function NotFoundScreen() {
return (
<>
<Stack.Screen options={{ title: 'Oops!' }} />
<Stack.Screen options={{ title: "Oops!" }} />
<ThemedView style={styles.container}>
<ThemedText type="title">This screen doesn't exist.</ThemedText>
<ThemedText type="title">This screen does not exist.</ThemedText>
<Link href="/" style={styles.link}>
<ThemedText type="link">Go to home screen!</ThemedText>
</Link>
Expand All @@ -21,8 +21,8 @@ export default function NotFoundScreen() {
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
alignItems: "center",
justifyContent: "center",
padding: 20,
},
link: {
Expand Down
Loading

0 comments on commit cd58580

Please sign in to comment.