Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting and Prettier formatting #139

Merged
merged 8 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
## Summary of the problem

<!-- Why these changes are being made? What problem does it solve? Link any related issues to provide more details. -->

## Describe your changes

<!-- Explain your thought process to the solution and provide a quick summary of the changes. -->

## Checklist
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: CI
on:
push:
branches:
- '**'
branches:
- "**"
pull_request:
branches:
- '**'
- "**"
jobs:
eslint:
name: ESLint
Expand Down
17 changes: 9 additions & 8 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,20 @@ const linking: LinkingOptions<TabParamList> = {

export default function App() {
const [fontsLoaded] = useFonts({
'JetBrainsMono-Regular': require('./assets/fonts/JetBrainsMono-Regular.ttf'),
'JetBrainsMono-Bold': require('./assets/fonts/JetBrainsMono-Bold.ttf'),
'Consolas-Bold': require('./assets/fonts/CONSOLAB.ttf'),
'Damion': require('./assets/fonts/Damion-Regular.ttf'),
"JetBrainsMono-Regular": require("./assets/fonts/JetBrainsMono-Regular.ttf"),
"JetBrainsMono-Bold": require("./assets/fonts/JetBrainsMono-Bold.ttf"),
"Consolas-Bold": require("./assets/fonts/CONSOLAB.ttf"),
Damion: require("./assets/fonts/Damion-Regular.ttf"),
});

const [isLoading, setIsLoading] = useState(true);
const [token, setToken] = useState<string | null>(null);
const hcb = useClient(token);
const scheme = useColorScheme();
useStripeTerminal()
useStripeTerminal();

const fetcher = useCallback(
async (url: string, options: any) => {
async (url: string, options: RequestInit) => {
try {
return await hcb(url, options).json();
} catch (error) {
Expand Down Expand Up @@ -114,7 +114,8 @@ export default function App() {

<SWRConfig
value={{
provider: asyncStorageProvider, fetcher
provider: asyncStorageProvider,
fetcher,
}}
>
<SafeAreaProvider>
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Contributing

Thank you for choosing to contribute to HCB Mobile! Please follow the guidelines before on how to contribute.

- Use the PR template
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,5 @@ EXPO_PUBLIC_CLIENT_ID=<uid field from the Doorkeeper app>
- Bonus task: painfully watch Gradle attempt to work

## Contributing
Please see [CONTRIBUTING.md](CONTRIBUTING.md).

Please see [CONTRIBUTING.md](CONTRIBUTING.md).
24 changes: 12 additions & 12 deletions app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@ export default {
[
"@stripe/stripe-terminal-react-native",
{
"bluetoothBackgroundMode": true,
"locationWhenInUsePermission": "Location access is required in order to accept payments.",
"bluetoothPeripheralPermission": "Bluetooth access is required in order to connect to supported bluetooth card readers.",
"bluetoothAlwaysUsagePermission": "This app uses Bluetooth to connect to supported card readers."
}
bluetoothBackgroundMode: true,
locationWhenInUsePermission:
"Location access is required in order to accept payments.",
bluetoothPeripheralPermission:
"Bluetooth access is required in order to connect to supported bluetooth card readers.",
bluetoothAlwaysUsagePermission:
"This app uses Bluetooth to connect to supported card readers.",
},
],
[
"expo-build-properties",
{
android: {
minSdkVersion: 26
}
minSdkVersion: 26,
},
},
],
[
"expo-alternate-app-icons",
appIcons
]
["expo-alternate-app-icons", appIcons],
],
},
};
};
12 changes: 6 additions & 6 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
declare namespace NodeJS {
interface ProcessEnv {
EXPO_PUBLIC_API_BASE: string;
EXPO_PUBLIC_CLIENT_ID: string;
EXPO_PUBLIC_STRIPE_API_KEY: string;
}
}
interface ProcessEnv {
EXPO_PUBLIC_API_BASE: string;
EXPO_PUBLIC_CLIENT_ID: string;
EXPO_PUBLIC_STRIPE_API_KEY: string;
}
}
6 changes: 3 additions & 3 deletions src/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import Home from "./pages/index";
import InvitationPage from "./pages/Invitation";
import OrganizationPage from "./pages/organization";
import AccountNumberPage from "./pages/organization/AccountNumber";
import OrganizationDonationPage from "./pages/organization/Donation";
import ProcessDonationPage from "./pages/organization/ProcessDonation";
import OrganizationSettingsPage from "./pages/organization/Settings";
import TransferPage from "./pages/organization/transfer";
import ReceiptsPage from "./pages/Receipts";
import RenameTransactionPage from "./pages/RenameTransaction";
import SettingsPage from "./pages/Settings";
import TransactionPage from "./pages/Transaction";
import { palette } from "./theme";
import OrganizationDonationPage from "./pages/organization/Donation";
import ProcessDonationPage from "./pages/organization/ProcessDonation";

const Stack = createNativeStackNavigator<StackParamList>();
const CardsStack = createNativeStackNavigator<CardsStackParamList>();
Expand Down Expand Up @@ -202,7 +202,7 @@ export default function Navigator() {
<CardsStack.Screen
name="Card"
component={CardPage}
options={({ route }) => ({
options={() => ({
title: "Card",
})}
/>
Expand Down
20 changes: 10 additions & 10 deletions src/cacheProvider.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import AsyncStorage from '@react-native-async-storage/async-storage';
import { AppState } from 'react-native';
import AsyncStorage from "@react-native-async-storage/async-storage";
import { AppState } from "react-native";

export default function asyncStorageProvider() {
const map = new Map();
// Initialize the map with data from AsyncStorage
(async () => {
try {
const appCache = await AsyncStorage.getItem('app-cache');
const appCache = await AsyncStorage.getItem("app-cache");
if (appCache) {
JSON.parse(appCache).forEach(([key, value]) => {
JSON.parse(appCache).forEach(([key, value]: [string, unknown]) => {
map.set(key, value);
});
}
} catch (error) {
console.error('Error initializing asyncStorageProvider:', error);
console.error("Error initializing asyncStorageProvider:", error);

Check warning on line 16 in src/cacheProvider.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected console statement
}
})();
// Save the map to AsyncStorage before the app goes to the background
const saveAppCache = async () => {
try {
const appCache = JSON.stringify(Array.from(map.entries()));
await AsyncStorage.setItem('app-cache', appCache);
await AsyncStorage.setItem("app-cache", appCache);
} catch (error) {
console.error('Error saving asyncStorageProvider cache:', error);
console.error("Error saving asyncStorageProvider cache:", error);

Check warning on line 25 in src/cacheProvider.ts

View workflow job for this annotation

GitHub Actions / ESLint

Unexpected console statement
}
};
AppState.addEventListener('change', (nextAppState) => {
if (nextAppState === 'background' || nextAppState === 'inactive') {
AppState.addEventListener("change", (nextAppState) => {
if (nextAppState === "background" || nextAppState === "inactive") {
saveAppCache();
}
});
return map;
}
}
16 changes: 11 additions & 5 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@ export default function Button(
) {
return (
<Pressable
style={{ ...styles.button, ...(props.style as object), ...(props.disabled ? {
backgroundColor: palette.muted,
borderColor: palette.muted,
opacity: 0.6
} : {}) }}
style={{
...styles.button,
...(props.style as object),
...(props.disabled
? {
backgroundColor: palette.muted,
borderColor: palette.muted,
opacity: 0.6,
}
: {}),
}}
onPress={() => props.onPress && props.onPress()}
disabled={props.loading || props.disabled}
>
Expand Down
23 changes: 13 additions & 10 deletions src/components/PaymentCard.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useTheme } from "@react-navigation/native";
import Constants from "expo-constants";
// @ts-expect-error will be removed later
import * as Geopattern from "geopattern";
import { useEffect, useRef, useState } from "react";
import {
Expand Down Expand Up @@ -38,21 +39,21 @@
}: ViewProps & {
card: Card;
details?: CardDetails;
onCardLoad?: (cardId: string, dimensions: { width: number; height: number }) => void;
onCardLoad?: (
cardId: string,
dimensions: { width: number; height: number },
) => void;
}) {
const { colors: themeColors, dark } = useTheme();

console.log("PaymentCard", card);

const patternForMeasurements = Geopattern.generate(card.id, {
scalePattern: 1.1,
grayscale: card.status != "active",
}).toSvg();

const pattern = Geopattern.generate(card.id, {
scalePattern: 1.1,
grayscale:
card.status == "active" ? false : true,
grayscale: card.status == "active" ? false : true,
}).toDataUri();

const extractDimensions = (svg: string) => {
Expand All @@ -74,12 +75,11 @@
card.type = "virtual";
}


useEffect(() => {
if (onCardLoad) {
onCardLoad(card.id, { width: svgWidth, height: svgHeight });
}
}, []);

Check warning on line 82 in src/components/PaymentCard.tsx

View workflow job for this annotation

GitHub Actions / ESLint

React Hook useEffect has missing dependencies: 'card.id', 'onCardLoad', 'svgHeight', and 'svgWidth'. Either include them or remove the dependency array. If 'onCardLoad' changes too often, find the parent component that defines it and wrap that definition in useCallback

useEffect(() => {
const subscription = AppState.addEventListener(
Expand Down Expand Up @@ -122,11 +122,14 @@
}}
>
{Constants.platform?.android ? (
<SvgXml xml={patternForMeasurements} width={svgWidth} height={svgHeight} />
<SvgXml
xml={patternForMeasurements}
width={svgWidth}
height={svgHeight}
/>
) : (
<SvgUri uri={pattern} width={svgWidth} height={svgHeight} />
)
}
)}
</View>
)}

Expand Down Expand Up @@ -158,7 +161,7 @@
<View>
<Text
style={{
color: 'white',
color: "white",
fontFamily: "Consolas-Bold",
fontSize: 18,
width: 180,
Expand Down
Loading
Loading