From b762872ac2b1ff464d4fb6930945e4c78f7a49ca Mon Sep 17 00:00:00 2001 From: Andrew Bierman <94939237+andrew-bierman@users.noreply.github.com> Date: Thu, 16 May 2024 21:56:25 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20linting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/app/api/getGeoCode.ts | 4 +- packages/app/api/getTrails.ts | 1 - packages/app/auth/hooks/useGoogleAuth.ts | 6 ++- packages/app/auth/provider.tsx | 6 +-- packages/app/components/Dropdown.tsx | 2 +- packages/app/components/card/CustomCard.tsx | 1 - .../app/components/card/CustomCardHeader.tsx | 5 ++- .../app/components/map/MapButtonsOverlay.tsx | 1 - .../app/components/map/NativeMap.native.tsx | 2 - packages/app/components/map/useGpxUpload.tsx | 3 +- .../components/pack_table/packtable.style.tsx | 2 +- .../app/components/weather/WeatherCard.tsx | 1 - packages/app/constants/api.ts | 2 +- packages/app/context/Auth/SessionProvider.tsx | 2 - packages/app/context/theme.tsx | 2 - packages/app/hooks/chat/useChat.ts | 4 +- packages/app/hooks/chat/useGetAIResponse.ts | 4 +- packages/app/hooks/common/useCopyClipboard.ts | 8 +--- .../app/hooks/common/useValidateSchema.ts | 3 +- .../app/hooks/favorites/useAddFavorite.ts | 1 - packages/app/hooks/map/useNativeMap.ts | 6 +-- packages/app/hooks/packs/useAddNewPack.ts | 1 - packages/app/hooks/packs/useAddPackItem.ts | 7 +--- packages/app/hooks/packs/useDeletePackItem.ts | 2 - packages/app/hooks/packs/useEditPackItem.ts | 3 -- .../password-reset/usePasswordResetForm.ts | 4 +- packages/app/hooks/trails/index.ts | 2 - packages/app/hooks/useMatchesCurrentUser.ts | 5 --- packages/app/screens/about/AboutContent.tsx | 1 - packages/app/screens/maps/index.tsx | 2 - .../app/screens/trip/createTripStore/store.ts | 4 -- packages/app/utils/apiUtils.ts | 1 - packages/app/utils/mapFunctions.ts | 7 +--- .../src/sources/vite/viteSource.native.js | 3 +- packages/crosspath/types/lib-interface.d.ts | 4 +- packages/crosspath/types/model/types.d.ts | 41 +++++++++++-------- 36 files changed, 57 insertions(+), 96 deletions(-) diff --git a/packages/app/api/getGeoCode.ts b/packages/app/api/getGeoCode.ts index da103f63b..6ce7c2c9b 100644 --- a/packages/app/api/getGeoCode.ts +++ b/packages/app/api/getGeoCode.ts @@ -13,9 +13,7 @@ export const getGeoCode = async (addressArray: string[]): Promise => { .then((result) => { resultReturn = result; }) - .catch((error) => { - - }); + .catch((error) => {}); return resultReturn; }; diff --git a/packages/app/api/getTrails.ts b/packages/app/api/getTrails.ts index bde5121e5..700be63e9 100644 --- a/packages/app/api/getTrails.ts +++ b/packages/app/api/getTrails.ts @@ -45,7 +45,6 @@ export const getTrailsRapid = async ( return trailsArray; } catch (error) { - console.error('error:' + error); return []; } diff --git a/packages/app/auth/hooks/useGoogleAuth.ts b/packages/app/auth/hooks/useGoogleAuth.ts index 3111180ec..e951a3d25 100644 --- a/packages/app/auth/hooks/useGoogleAuth.ts +++ b/packages/app/auth/hooks/useGoogleAuth.ts @@ -3,7 +3,11 @@ import * as Google from 'expo-auth-session/providers/google'; import { queryTrpc } from 'app/trpc'; import { useSessionSignIn } from './useSessionSignIn'; -import { WEB_CLIENT_ID, IOS_CLIENT_ID, ANDROID_CLIENT_ID } from '@packrat/config'; +import { + WEB_CLIENT_ID, + IOS_CLIENT_ID, + ANDROID_CLIENT_ID, +} from '@packrat/config'; const webClientId = String(WEB_CLIENT_ID); const iosClientId = String(IOS_CLIENT_ID); diff --git a/packages/app/auth/provider.tsx b/packages/app/auth/provider.tsx index c8bf03ca9..c90de1b25 100644 --- a/packages/app/auth/provider.tsx +++ b/packages/app/auth/provider.tsx @@ -85,7 +85,7 @@ // const firebaseUser = userCredential.user; // setAuth(firebaseUser); // } catch (error) { -// +// // } // }; @@ -95,7 +95,7 @@ // const firebaseUser = userCredential.user; // setAuth(firebaseUser); // } catch (error) { -// +// // } // }; @@ -106,7 +106,7 @@ // const signUpWithEmailPasswordProvider = async (email, password) => { // try { // const newUser = await createUserWithEmailAndPassword(email, password); -// +// // } catch (e) { // console.log("Error", e) diff --git a/packages/app/components/Dropdown.tsx b/packages/app/components/Dropdown.tsx index b7969a613..da9b8db6b 100644 --- a/packages/app/components/Dropdown.tsx +++ b/packages/app/components/Dropdown.tsx @@ -21,7 +21,7 @@ // width, // style, // }) => { -// // +// // // const items = // data?.map((item, index) => { diff --git a/packages/app/components/card/CustomCard.tsx b/packages/app/components/card/CustomCard.tsx index a47a07925..e01f2a8a5 100644 --- a/packages/app/components/card/CustomCard.tsx +++ b/packages/app/components/card/CustomCard.tsx @@ -38,7 +38,6 @@ export const CustomCard = ({ if (!data) return null; const isWeb = Platform.OS === 'web'; - return ( { {typeof title === 'string' ? {title} : title} - + {user?.id === data.owner_id ? 'Your Profile' diff --git a/packages/app/components/map/MapButtonsOverlay.tsx b/packages/app/components/map/MapButtonsOverlay.tsx index 3b0fc8808..d377528a8 100644 --- a/packages/app/components/map/MapButtonsOverlay.tsx +++ b/packages/app/components/map/MapButtonsOverlay.tsx @@ -44,7 +44,6 @@ const MapButtonsOverlay = ({ progress, navigateToMaps, }: MapButtonsOverlayProps) => { - const [showStyleOptions, setShowStyleOptions] = useState(false); const { enableDarkMode, enableLightMode, isDark, isLight, currentTheme } = useTheme(); diff --git a/packages/app/components/map/NativeMap.native.tsx b/packages/app/components/map/NativeMap.native.tsx index c13a80096..942f3d6bd 100644 --- a/packages/app/components/map/NativeMap.native.tsx +++ b/packages/app/components/map/NativeMap.native.tsx @@ -85,7 +85,6 @@ function NativeMap({ shape: shapeProp }) { const pointLatLong = shape?.features[0]?.geometry?.coordinates; const openMaps = (latLong) => { - const scheme = Platform.select({ ios: 'maps://0,0?q=', android: 'geo:0,0?q=', @@ -149,7 +148,6 @@ function NativeMap({ shape: shapeProp }) { id="destination" coordinate={pointLatLong} onSelected={() => { - openMaps(pointLatLong); }} > diff --git a/packages/app/components/map/useGpxUpload.tsx b/packages/app/components/map/useGpxUpload.tsx index 96750e503..e3663beff 100644 --- a/packages/app/components/map/useGpxUpload.tsx +++ b/packages/app/components/map/useGpxUpload.tsx @@ -9,12 +9,11 @@ mapboxgl.accessToken = MAPBOX_ACCESS_TOKEN; const useGpxUpload = (setShape) => { const handleGpxUpload = async () => { - try { const result = await DocumentPicker.getDocumentAsync({ type: 'application/gpx+xml', }); - + if (result.type === 'success') { const base64Gpx = result.uri.split(',')[1]; const gpxString = atob(base64Gpx); diff --git a/packages/app/components/pack_table/packtable.style.tsx b/packages/app/components/pack_table/packtable.style.tsx index ef0775a92..550d608f1 100644 --- a/packages/app/components/pack_table/packtable.style.tsx +++ b/packages/app/components/pack_table/packtable.style.tsx @@ -2,7 +2,7 @@ import { Platform } from 'react-native'; const isWeb = Platform.OS === 'web'; const loadStyles = (theme) => { const { currentTheme } = theme; - + return { container: { flex: 1, diff --git a/packages/app/components/weather/WeatherCard.tsx b/packages/app/components/weather/WeatherCard.tsx index 2a02fe585..6abf2be14 100644 --- a/packages/app/components/weather/WeatherCard.tsx +++ b/packages/app/components/weather/WeatherCard.tsx @@ -279,7 +279,6 @@ export default function WeatherCard({ style={styles.card} > {restOfWeek.map((day, index) => { - return ( {day} diff --git a/packages/app/constants/api.ts b/packages/app/constants/api.ts index e1ec8847d..3de673360 100644 --- a/packages/app/constants/api.ts +++ b/packages/app/constants/api.ts @@ -4,5 +4,5 @@ import { API_URL } from '@packrat/config'; * The api url. * format: "{scheme}://{serverhost}:{port}/api" * e.g: "http://localhost:4200/api" -*/ + */ export const api = API_URL; diff --git a/packages/app/context/Auth/SessionProvider.tsx b/packages/app/context/Auth/SessionProvider.tsx index 9e780ecc7..30b74a80e 100644 --- a/packages/app/context/Auth/SessionProvider.tsx +++ b/packages/app/context/Auth/SessionProvider.tsx @@ -25,8 +25,6 @@ export function useSession() { export function SessionProvider(props) { const [[isLoading, session], setSession] = useStorageState('session'); - - return ( { * @return {undefined} No return value. */ const enableDarkMode = () => { - dispatch({ type: 'ENABLE_DARK_MODE' }); }; /** @@ -75,7 +74,6 @@ export const ThemeProvider = ({ children }) => { * @return {void} - This function does not return any value. */ const enableLightMode = () => { - dispatch({ type: 'ENABLE_LIGHT_MODE' }); }; diff --git a/packages/app/hooks/chat/useChat.ts b/packages/app/hooks/chat/useChat.ts index b574ed499..7b8d79f9e 100644 --- a/packages/app/hooks/chat/useChat.ts +++ b/packages/app/hooks/chat/useChat.ts @@ -47,7 +47,7 @@ export const useChat = (itemTypeId = null) => { // ); // useEffect(() => { - // + // // setParsedMessages( // conversation ? parseConversationHistory(conversation.history) : [], // ); @@ -60,7 +60,7 @@ export const useChat = (itemTypeId = null) => { ? parseConversationHistory(conversations) : []; - // + // /** * Handles sending a message. diff --git a/packages/app/hooks/chat/useGetAIResponse.ts b/packages/app/hooks/chat/useGetAIResponse.ts index ded421f59..244c72c51 100644 --- a/packages/app/hooks/chat/useGetAIResponse.ts +++ b/packages/app/hooks/chat/useGetAIResponse.ts @@ -27,8 +27,8 @@ export function useGetAIResponse() { // }; // }, // onError: (err, { userId, conversationId, userInput }, context) => { - // - // + // + // // if (context.previousConversation) { // queryTrpc.getConversationById.setData( // { conversationId }, diff --git a/packages/app/hooks/common/useCopyClipboard.ts b/packages/app/hooks/common/useCopyClipboard.ts index b43d82cec..5173d7a54 100644 --- a/packages/app/hooks/common/useCopyClipboard.ts +++ b/packages/app/hooks/common/useCopyClipboard.ts @@ -11,17 +11,13 @@ export const useCopyClipboard = (link: string) => { if (Platform.OS === 'web') { navigator.clipboard .writeText(copyLink) - .then(() => { - - }) + .then(() => {}) .catch((err) => { console.error('Failed to copy text to clipboard', err); }); } else { Clipboard.setStringAsync(copyLink) - .then(() => { - - }) + .then(() => {}) .catch((err) => { console.error('Failed to copy text to clipboard', err); }); diff --git a/packages/app/hooks/common/useValidateSchema.ts b/packages/app/hooks/common/useValidateSchema.ts index 0debb3933..66b6be35a 100644 --- a/packages/app/hooks/common/useValidateSchema.ts +++ b/packages/app/hooks/common/useValidateSchema.ts @@ -17,11 +17,10 @@ export const useValidateSchema = ( typeof formatBeforeValidate === 'function' ? formatBeforeValidate(values) : values; - + await ValidationSchema.parseAsync(finalValues); setIsValid(true); } catch (e) { - setIsValid(false); } finally { setIsValidating(false); diff --git a/packages/app/hooks/favorites/useAddFavorite.ts b/packages/app/hooks/favorites/useAddFavorite.ts index c92348ae5..e81bba72d 100644 --- a/packages/app/hooks/favorites/useAddFavorite.ts +++ b/packages/app/hooks/favorites/useAddFavorite.ts @@ -7,7 +7,6 @@ export function useAddFavorite() { // A wrapper function to abstract away the .mutate call const addFavorite = (newFavorite) => { - mutation.mutate(newFavorite, { onSuccess: () => { // Invalidate and refetch. Update to be more specific diff --git a/packages/app/hooks/map/useNativeMap.ts b/packages/app/hooks/map/useNativeMap.ts index ee704c9ad..79a464ff1 100644 --- a/packages/app/hooks/map/useNativeMap.ts +++ b/packages/app/hooks/map/useNativeMap.ts @@ -47,8 +47,8 @@ export const useNativeMap = ({ shape: shapeProp }) => { // console.log("🚀 ~ file: NativeMap.native.js:99 ~ NativeMap ~ bounds:", bounds) bounds = bounds[0].concat(bounds[1]); const zoomLevel = calculateZoomLevel(bounds, { width: dw, height: 360 }); - // - // + // + // // effects useEffect(() => { @@ -93,7 +93,6 @@ export const useNativeMap = ({ shape: shapeProp }) => { * @param {Event} event - The press event object. */ function onMapPress(event) { - // if (trailCenterPoint) { // mapViewFullScreenRef?.current.setCamera({ // centerCoordinate: trailCenterPoint, @@ -109,7 +108,6 @@ export const useNativeMap = ({ shape: shapeProp }) => { * @returns {void} */ function onDownloadProgress(offlineRegion, offlineRegionStatus) { - setProgress(offlineRegionStatus.percentage); setDownloading(true); if (offlineRegionStatus.percentage == 100) { diff --git a/packages/app/hooks/packs/useAddNewPack.ts b/packages/app/hooks/packs/useAddNewPack.ts index 93dd6c4df..11976b146 100644 --- a/packages/app/hooks/packs/useAddNewPack.ts +++ b/packages/app/hooks/packs/useAddNewPack.ts @@ -69,7 +69,6 @@ export const useAddNewPack = () => { }; }, onError: (_error, _pack, context) => { - utils.getPacks.setData( { ownerId: _pack.owner_id, diff --git a/packages/app/hooks/packs/useAddPackItem.ts b/packages/app/hooks/packs/useAddPackItem.ts index 3c4899ddb..f946dec51 100644 --- a/packages/app/hooks/packs/useAddPackItem.ts +++ b/packages/app/hooks/packs/useAddPackItem.ts @@ -11,8 +11,7 @@ export const useAddPackItem = () => { const previousPack = utils.getPackById.getData({ packId: newItem.packId, }); - - + const newQueryData = { ...previousPack, items: [ @@ -31,15 +30,13 @@ export const useAddPackItem = () => { }, ], }; - + utils.getPackById.setData({ packId: newItem.packId }, newQueryData); return { previousPack, }; }, onError: (err, newItem, context) => { - - // if (context.previousPack) { // utils.getPackById.setData( // { packId: newItem.packId }, diff --git a/packages/app/hooks/packs/useDeletePackItem.ts b/packages/app/hooks/packs/useDeletePackItem.ts index 063d425f3..f6c5aeb96 100644 --- a/packages/app/hooks/packs/useDeletePackItem.ts +++ b/packages/app/hooks/packs/useDeletePackItem.ts @@ -26,8 +26,6 @@ export const useDeletePackItem = () => { // }; }, onError: (err, deleteItem, context) => { - - // if (context.previousPack) { // utils.getPackById.setData( // { packId: deleteItem.packId }, diff --git a/packages/app/hooks/packs/useEditPackItem.ts b/packages/app/hooks/packs/useEditPackItem.ts index a2b485958..16cd0dcdd 100644 --- a/packages/app/hooks/packs/useEditPackItem.ts +++ b/packages/app/hooks/packs/useEditPackItem.ts @@ -48,9 +48,6 @@ export const useEditPackItem = (isItemPage) => { }; }, onError: (err, editedItem, context) => { - - - // if (context.previousPack) { // // Restore the previous pack data in case of an error // utils.getPackById.setData( diff --git a/packages/app/hooks/password-reset/usePasswordResetForm.ts b/packages/app/hooks/password-reset/usePasswordResetForm.ts index d83750efc..23d2a9973 100644 --- a/packages/app/hooks/password-reset/usePasswordResetForm.ts +++ b/packages/app/hooks/password-reset/usePasswordResetForm.ts @@ -20,9 +20,7 @@ export const usePasswordResetForm = () => { try { await resetPassword({ password, resetToken }); setIsPasswordUpdated(true); - } catch (error) { - - } + } catch (error) {} }; return { diff --git a/packages/app/hooks/trails/index.ts b/packages/app/hooks/trails/index.ts index 1b80ef475..47714668e 100644 --- a/packages/app/hooks/trails/index.ts +++ b/packages/app/hooks/trails/index.ts @@ -25,8 +25,6 @@ function useTrails({ latLng, selectedSearch, radius = 1000 }) { }, ); - - // React.useEffect(() => { let filteredTrails = []; if (data) { diff --git a/packages/app/hooks/useMatchesCurrentUser.ts b/packages/app/hooks/useMatchesCurrentUser.ts index eb814bee4..238e47eea 100644 --- a/packages/app/hooks/useMatchesCurrentUser.ts +++ b/packages/app/hooks/useMatchesCurrentUser.ts @@ -4,12 +4,7 @@ import { useAuthUser } from 'app/auth/hooks'; export const useMatchesCurrentUser = (ownerId: string): boolean => { const currentUser = useAuthUser(); - const currentUserId = currentUser?.id; - - - - return currentUserId === ownerId; // Note: I adjusted `id` to `id` based on your other code }; diff --git a/packages/app/screens/about/AboutContent.tsx b/packages/app/screens/about/AboutContent.tsx index 074098089..3fbf7c37b 100644 --- a/packages/app/screens/about/AboutContent.tsx +++ b/packages/app/screens/about/AboutContent.tsx @@ -17,7 +17,6 @@ const AboutContent = ({ desktopContainer, isMobile }: AboutContentProps) => { useTheme(); const styles = useCustomStyles(loadStyles); - const { handleGithubLink, handleDiscordLink, aboutSections } = useAbout(); diff --git a/packages/app/screens/maps/index.tsx b/packages/app/screens/maps/index.tsx index 411e42eb5..3cbb81eeb 100644 --- a/packages/app/screens/maps/index.tsx +++ b/packages/app/screens/maps/index.tsx @@ -79,8 +79,6 @@ export default function DownloadedMaps() { padding: 20, }} onPress={() => { - - setPack(pack); setShowMap(true); }} diff --git a/packages/app/screens/trip/createTripStore/store.ts b/packages/app/screens/trip/createTripStore/store.ts index a89e31ed0..914070758 100644 --- a/packages/app/screens/trip/createTripStore/store.ts +++ b/packages/app/screens/trip/createTripStore/store.ts @@ -43,7 +43,6 @@ export const createTripReducer = ( ) => { if (action.type === 'setDateRange') { try { - const { start_date: startDate, end_date: endDate } = action.payload; const numberOfNights = startDate && endDate @@ -65,7 +64,6 @@ export const createTripReducer = ( duration, }; } catch (e) { - return state; } } @@ -74,8 +72,6 @@ export const createTripReducer = ( payload: { name, value }, } = action; - - return { ...state, [name]: value, diff --git a/packages/app/utils/apiUtils.ts b/packages/app/utils/apiUtils.ts index 8c3cc6777..b379d87fe 100644 --- a/packages/app/utils/apiUtils.ts +++ b/packages/app/utils/apiUtils.ts @@ -9,7 +9,6 @@ export const getErrorMessageFromError = (e: unknown) => { const responseData = e.response?.data; - return ( responseData?.[0]?.error?.message || responseData?.error?.message || diff --git a/packages/app/utils/mapFunctions.ts b/packages/app/utils/mapFunctions.ts index 0cb6d97eb..f5dd3e13e 100644 --- a/packages/app/utils/mapFunctions.ts +++ b/packages/app/utils/mapFunctions.ts @@ -177,9 +177,6 @@ function calculateZoomLevel(bounds, mapDim) { function findTrailCenter(shape) { const trailCoords = shape?.features[0]?.geometry?.coordinates; - - - let latitudes; let longitudes; @@ -206,8 +203,6 @@ function findTrailCenter(shape) { const avgLongitude = longitudes.reduce((a, b) => a + b, 0) / longitudes.length; - - return [avgLatitude, avgLongitude]; } @@ -367,7 +362,7 @@ const multiPolygonBounds = (multipolygonData) => { const centerLng = (minX + maxX) / 2; const centerLat = (minY + maxY) / 2; - + return [centerLng, centerLat]; }; diff --git a/packages/config/src/sources/vite/viteSource.native.js b/packages/config/src/sources/vite/viteSource.native.js index f0efc9221..f46af3ef3 100644 --- a/packages/config/src/sources/vite/viteSource.native.js +++ b/packages/config/src/sources/vite/viteSource.native.js @@ -1,4 +1,3 @@ // DUMMY FILE. This is not actually used in the project. It is to fix Expo's build process. -export const viteSource = {}; - +export const viteSource = {}; diff --git a/packages/crosspath/types/lib-interface.d.ts b/packages/crosspath/types/lib-interface.d.ts index 524b24431..acf8c94d3 100644 --- a/packages/crosspath/types/lib-interface.d.ts +++ b/packages/crosspath/types/lib-interface.d.ts @@ -1,4 +1,6 @@ import { LinkComponent, Router, CreateParam } from './model'; -export declare function Link(props: Parameters): ReturnType; +export declare function Link( + props: Parameters, +): ReturnType; export declare const createParam: CreateParam; export declare function useRouter(): Router; diff --git a/packages/crosspath/types/model/types.d.ts b/packages/crosspath/types/model/types.d.ts index 9c3ee437d..5e7b7414e 100644 --- a/packages/crosspath/types/model/types.d.ts +++ b/packages/crosspath/types/model/types.d.ts @@ -1,27 +1,32 @@ import { FC } from 'react'; import { LinkProps } from 'solito/link'; export interface CreateParamOptions { - initial?: string; - parse?: (param: string) => unknown; - stringify?: (param: unknown) => string; + initial?: string; + parse?: (param: string) => unknown; + stringify?: (param: unknown) => string; } export interface Router { - push: (url: URL) => void; - replace: (url: URL) => void; - back: () => void; + push: (url: URL) => void; + replace: (url: URL) => void; + back: () => void; } export type LinkComponent = FC; -export type URL = string | { - pathname?: string; - query?: Record; - state?: Record; - hash?: string; - as?: string | object; -}; -export type CreateParam = () => { - useParam: (key: keyof T, options?: CreateParamOptions) => [value: any, setValue: (value: any) => void]; - useParams: (key: keyof T) => { - params: T; - setParams: (value: any) => void; +export type URL = + | string + | { + pathname?: string; + query?: Record; + state?: Record; + hash?: string; + as?: string | object; }; +export type CreateParam = () => { + useParam: ( + key: keyof T, + options?: CreateParamOptions, + ) => [value: any, setValue: (value: any) => void]; + useParams: (key: keyof T) => { + params: T; + setParams: (value: any) => void; + }; };