diff --git a/.eslintrc.js b/.eslintrc.js index 09e0cdc9..18dd567c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,9 +23,9 @@ module.exports = { plugins: [ '@typescript-eslint', 'import', - // 'promise', + 'promise', 'security', - // 'no-catch-all', + 'no-catch-all', 'react', 'react-hooks', ], @@ -44,8 +44,8 @@ module.exports = { 'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks 'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies 'react/react-in-jsx-scope': 'off', // Disable requirement for React import - // 'no-catch-all/no-catch-all': 'error', - // 'no-console': 'error', + 'no-catch-all/no-catch-all': 'error', + 'no-console': 'error', 'no-debugger': 'error', camelcase: 'error', indent: ['error', 2], @@ -122,21 +122,21 @@ module.exports = { }, ], 'import/prefer-default-export': 'off', - // // promise - // 'promise/catch-or-return': 'error', - // 'promise/no-return-wrap': 'error', - // 'promise/param-names': 'error', - // 'promise/always-return': 'error', - // 'promise/no-native': 'off', - // 'promise/no-nesting': 'warn', - // 'promise/no-promise-in-callback': 'warn', - // 'promise/no-callback-in-promise': 'warn', - // 'promise/avoid-new': 'warn', - // 'promise/no-new-statics': 'error', - // 'promise/no-return-in-finally': 'warn', - // 'promise/valid-params': 'warn', - // 'promise/prefer-await-to-callbacks': 'error', - // 'promise/no-multiple-resolved': 'error', + // promise + 'promise/catch-or-return': 'error', + 'promise/no-return-wrap': 'error', + 'promise/param-names': 'error', + 'promise/always-return': 'error', + 'promise/no-native': 'off', + 'promise/no-nesting': 'warn', + 'promise/no-promise-in-callback': 'warn', + 'promise/no-callback-in-promise': 'warn', + 'promise/avoid-new': 'warn', + 'promise/no-new-statics': 'error', + 'promise/no-return-in-finally': 'warn', + 'promise/valid-params': 'warn', + 'promise/prefer-await-to-callbacks': 'error', + 'promise/no-multiple-resolved': 'error', }, overrides: [ { diff --git a/README.md b/README.md index d48c4a33..7a627833 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,27 @@ # Utopia UI [![npm version](https://img.shields.io/npm/v/utopia-ui.svg)](https://www.npmjs.com/package/utopia-ui) **UI Framework for Real-Life-Networking-Apps** -*Real change happens in real life when we meet in person and connect as local communities manifesting their ideas with the earth. When we help each other to step out of capitalism and individualism and start building common infrastructure to meet human needs in harmony with Mother Earth.* +*Real change happens in real life when we meet in person and connect as local communities manifesting their ideas with the earth. When we help each other to step out of our bubbles at home and start building common infrastructure to meet human needs in harmony with Mother Earth.* -*That is why Utopia UI exists. It is a UI kit for minimalist, fast, intuitive and mobile-first map apps, as a tool for local connection and decentralised networking. It can work with any backend or p2p database and any kind of data structure.* +*That is why Utopia UI exists. It is a UI kit for minimalist, fast, intuitive and mobile-first map apps, as a tool for local connection and decentralised networking. We believe in maps as the perfect link between digital tools and real life action* + +*It can work with any backend or p2p database and any kind of data structure.* ## Mission Utopia UIs mission is to provide open source building blocks to create beautiful applications with a focus on real life impact, local communities and gamification. The building blocks are designed to allow different networks and communities to assemble their map and app for their specific needs and purpose. -Utopia Game is one of the apps made with Utopia UI. It is an attempt to use gamification to get users to take action and make the map even more alive. Check it out at [utopia-game.org](https://utopia-game.org/) or see the code in the [repository](https://github.com/utopia-os/utopia-game) +It is the base of [Utopia Map](https://github.com/utopia-os/utopia-map) and [Utopia Game](https://github.com/utopia-os/utopia-game). ## Features * Interactive Component Map with customizable Layers (like Projects, Event, People) * Flexible API-Interface to make it work with every backend or p2p database * Create, Update, Delete Items -* User Authentification API-Interface -* User Profiles -* App Shell +* User authentification API-Interface +* Customizable Profiles for users and other items +* App shell with navigation bar and sidebar ## Getting Started @@ -65,7 +67,7 @@ And can open our first map app in the browser 🙂 ### Static Layers -Now we add some static layer. +Now we add some static content in two layer. First we put some sample data in a new file called `src/sample-data.js` diff --git a/package-lock.json b/package-lock.json index 76dff00d..20bb3464 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,9 @@ "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-import": "^2.31.0", "eslint-plugin-json": "^3.1.0", + "eslint-plugin-no-catch-all": "^1.1.0", "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-promise": "^6.1.1", "eslint-plugin-react": "^7.31.8", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-security": "^3.0.1", @@ -2372,6 +2374,16 @@ "node": ">=10" } }, + "node_modules/eslint-plugin-no-catch-all": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-no-catch-all/-/eslint-plugin-no-catch-all-1.1.0.tgz", + "integrity": "sha512-VkP62jLTmccPrFGN/W6V7a3SEwdtTZm+Su2k4T3uyJirtkm0OMMm97h7qd8pRFAHus/jQg9FpUpLRc7sAylBEQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "eslint": ">=2.0.0" + } + }, "node_modules/eslint-plugin-prettier": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", @@ -2409,7 +2421,6 @@ "integrity": "sha512-57Zzfw8G6+Gq7axm2Pdo3gW/Rx3h9Yywgn61uE/3elTCOePEHVrn2i5CdfBwA1BLK0Q0WqctICIUSqXZW/VprQ==", "dev": true, "license": "ISC", - "peer": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" }, diff --git a/package.json b/package.json index 2bdb2d60..094a2e55 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,9 @@ "eslint-import-resolver-typescript": "^3.6.3", "eslint-plugin-import": "^2.31.0", "eslint-plugin-json": "^3.1.0", + "eslint-plugin-no-catch-all": "^1.1.0", "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-promise": "^6.1.1", "eslint-plugin-react": "^7.31.8", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-security": "^3.0.1", diff --git a/src/Components/AppShell/ContextWrapper.tsx b/src/Components/AppShell/ContextWrapper.tsx index 858834e6..cde23c2d 100644 --- a/src/Components/AppShell/ContextWrapper.tsx +++ b/src/Components/AppShell/ContextWrapper.tsx @@ -28,6 +28,7 @@ export const ContextWrapper = ({ children }) => { try { // eslint-disable-next-line react-hooks/rules-of-hooks location = useLocation() + // eslint-disable-next-line no-catch-all/no-catch-all } catch (e) { location = null } diff --git a/src/Components/Auth/SetNewPasswordPage.tsx b/src/Components/Auth/SetNewPasswordPage.tsx index 529bffa8..20f30445 100644 --- a/src/Components/Auth/SetNewPasswordPage.tsx +++ b/src/Components/Auth/SetNewPasswordPage.tsx @@ -17,6 +17,7 @@ export function SetNewPasswordPage() { const onReset = async () => { const token = window.location.search.split('token=')[1] + // eslint-disable-next-line no-console console.log(token) await toast.promise(passwordReset(token, password), { diff --git a/src/Components/Auth/useAuth.tsx b/src/Components/Auth/useAuth.tsx index 5e2a6755..5104c523 100644 --- a/src/Components/Auth/useAuth.tsx +++ b/src/Components/Auth/useAuth.tsx @@ -69,6 +69,7 @@ export const AuthProvider = ({ userApi, children }: AuthProviderProps) => { setLoading(false) return me } else return undefined + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { setLoading(false) return undefined diff --git a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx index 56f1834e..5e77d29c 100644 --- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -63,7 +63,9 @@ export const SearchControl = () => { try { const { data } = await axios.get(`https://photon.komoot.io/api/?q=${value}&limit=5`) setGeoResults(data.features) + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { + // eslint-disable-next-line no-console console.log(error) } } @@ -215,6 +217,7 @@ export const SearchControl = () => { ) .openPopup() .addEventListener('popupclose', (e) => { + // eslint-disable-next-line no-console console.log(e.target.remove()) }) if (geo.properties.extent) @@ -284,6 +287,7 @@ export const SearchControl = () => { ) .openPopup() .addEventListener('popupclose', (e) => { + // eslint-disable-next-line no-console console.log(e.target.remove()) }) map.setView( diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx index bb4f841a..405a3415 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -70,10 +70,12 @@ export function ItemFormPopup(props: ItemFormPopupProps) { try { await props.layer.api?.updateItem!({ ...formItem, id: props.item.id }) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } if (success) { + // eslint-disable-next-line no-console console.log(props.item) updateItem({ ...props.item, ...formItem }) @@ -100,6 +102,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) { name: formItem.name ? formItem.name : user?.first_name, })) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } diff --git a/src/Components/Map/Subcomponents/ItemViewPopup.tsx b/src/Components/Map/Subcomponents/ItemViewPopup.tsx index f7aedff4..27464a54 100644 --- a/src/Components/Map/Subcomponents/ItemViewPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemViewPopup.tsx @@ -63,6 +63,7 @@ export const ItemViewPopup = forwardRef((props: ItemViewPopupProps, ref: any) => props.item.layer?.onlyOnePerOwner && (await props.item.layer.api?.updateItem!({ id: props.item.id, position: null })) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } diff --git a/src/Components/Map/UtopiaMapInner.tsx b/src/Components/Map/UtopiaMapInner.tsx index 36966780..deb3fa59 100644 --- a/src/Components/Map/UtopiaMapInner.tsx +++ b/src/Components/Map/UtopiaMapInner.tsx @@ -94,6 +94,7 @@ export function UtopiaMapInner({ useMapEvents({ click: (e) => { resetMetaTags() + // eslint-disable-next-line no-console console.log(e.latlng.lat + ',' + e.latlng.lng) if (selectNewItemPosition) { setMapClicked({ position: e.latlng, setItemFormPopup }) diff --git a/src/Components/Map/hooks/useSelectPosition.tsx b/src/Components/Map/hooks/useSelectPosition.tsx index 310ce7ad..cc5409d1 100644 --- a/src/Components/Map/hooks/useSelectPosition.tsx +++ b/src/Components/Map/hooks/useSelectPosition.tsx @@ -89,6 +89,7 @@ function useSelectPositionManager(): { position: null, }) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } @@ -113,6 +114,7 @@ function useSelectPositionManager(): { position: updatedItem.position, }) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } @@ -134,6 +136,7 @@ function useSelectPositionManager(): { try { await markerClicked.layer?.api?.updateItem!(updatedItem) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } diff --git a/src/Components/Profile/ProfileView.tsx b/src/Components/Profile/ProfileView.tsx index a54ae222..92a329c4 100644 --- a/src/Components/Profile/ProfileView.tsx +++ b/src/Components/Profile/ProfileView.tsx @@ -60,11 +60,15 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi attestationApi .getItems() .then((value) => { + // eslint-disable-next-line no-console console.log(value) setAttestations(value) + return null }) + // eslint-disable-next-line promise/prefer-await-to-callbacks .catch((error) => { + // eslint-disable-next-line no-console console.error('Error fetching items:', error) }) } diff --git a/src/Components/Profile/Subcomponents/ContactInfoView.tsx b/src/Components/Profile/Subcomponents/ContactInfoView.tsx index 2e9a727b..80bc5f93 100644 --- a/src/Components/Profile/Subcomponents/ContactInfoView.tsx +++ b/src/Components/Profile/Subcomponents/ContactInfoView.tsx @@ -16,6 +16,7 @@ export const ContactInfoView = ({ item, heading }: { item: Item; heading: string const items = useItems() useEffect(() => { + // eslint-disable-next-line no-console console.log( 'user:', items.find( diff --git a/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx b/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx index 71273a26..cd4084dd 100644 --- a/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx +++ b/src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx @@ -30,6 +30,7 @@ export const GroupSubheaderForm = ({ useEffect(() => { if (groupTypes && groupStates) { const groupType = groupTypes.find((gt) => gt.groupTypes_id.name === state.group_type) + // eslint-disable-next-line no-console console.log(state.group_type) setState((prevState) => ({ ...prevState, diff --git a/src/Components/Profile/Subcomponents/SocialShareBar.tsx b/src/Components/Profile/Subcomponents/SocialShareBar.tsx index 13b94910..150fde40 100644 --- a/src/Components/Profile/Subcomponents/SocialShareBar.tsx +++ b/src/Components/Profile/Subcomponents/SocialShareBar.tsx @@ -16,7 +16,9 @@ const SocialShareBar = ({ .writeText(url) .then(() => { toast.success('link copied to clipboard') + return null }) + // eslint-disable-next-line promise/prefer-await-to-callbacks .catch((error: never) => { toast.error('Fehler beim Kopieren des Links: ', error) }) diff --git a/src/Components/Profile/Templates/FlexView.tsx b/src/Components/Profile/Templates/FlexView.tsx index c9f68c18..0fb741e9 100644 --- a/src/Components/Profile/Templates/FlexView.tsx +++ b/src/Components/Profile/Templates/FlexView.tsx @@ -17,6 +17,7 @@ const componentMap = { } export const FlexView = ({ item }: { item: Item }) => { + // eslint-disable-next-line no-console console.log(item) return (
diff --git a/src/Components/Profile/UserSettings.tsx b/src/Components/Profile/UserSettings.tsx index 88d644e7..e98896cd 100644 --- a/src/Components/Profile/UserSettings.tsx +++ b/src/Components/Profile/UserSettings.tsx @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/no-unsafe-argument */ -/* eslint-disable @typescript-eslint/no-floating-promises */ /* eslint-disable @typescript-eslint/restrict-template-expressions */ import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' @@ -43,6 +42,9 @@ export function UserSettings() { }, }) .then(() => navigate('/')) + .catch((e) => { + throw e + }) } return ( diff --git a/src/Components/Profile/itemFunctions.ts b/src/Components/Profile/itemFunctions.ts index 3ad3d1d5..e599912f 100644 --- a/src/Components/Profile/itemFunctions.ts +++ b/src/Components/Profile/itemFunctions.ts @@ -16,6 +16,7 @@ import { encodeTag } from '#utils/FormatTags' import { hashTagRegex } from '#utils/HashTagRegex' import { randomColor } from '#utils/RandomColor' +// eslint-disable-next-line promise/avoid-new const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) export const submitNewItem = async ( @@ -62,6 +63,7 @@ export const submitNewItem = async ( await layer?.api?.createItem!({ ...formItem, id: uuid, type, parent: item.id }) await linkItem(uuid) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } @@ -83,6 +85,7 @@ export const linkItem = async (id: string, item, updateItem) => { try { await item?.layer?.api?.updateItem!(updatedItem) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } @@ -100,6 +103,7 @@ export const unlinkItem = async (id: string, item, updateItem) => { try { await item?.layer?.api?.updateItem!(updatedItem) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } @@ -123,6 +127,7 @@ export const handleDelete = async ( try { await item.layer?.api?.deleteItem!(item.id) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } @@ -243,6 +248,7 @@ export const onUpdateItem = async ( .then(() => { setLoading(false) navigate(`/item/${item.id}${params && '?' + params}`) + return null }) } else { item.new = false @@ -272,6 +278,7 @@ export const onUpdateItem = async ( .then(() => { setLoading(false) navigate(`/${params && '?' + params}`) + return null }) } } diff --git a/src/Components/Templates/MarketView.tsx b/src/Components/Templates/MarketView.tsx index f21cfecb..6009e683 100644 --- a/src/Components/Templates/MarketView.tsx +++ b/src/Components/Templates/MarketView.tsx @@ -56,6 +56,7 @@ export const MarketView = () => { }) return null }) + // eslint-disable-next-line no-console console.log(offers) // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/src/Components/Templates/OverlayItemsIndexPage.tsx b/src/Components/Templates/OverlayItemsIndexPage.tsx index 291abbd4..1496dbdb 100644 --- a/src/Components/Templates/OverlayItemsIndexPage.tsx +++ b/src/Components/Templates/OverlayItemsIndexPage.tsx @@ -91,6 +91,7 @@ export const OverlayItemsIndexPage = ({ try { await layer?.api?.createItem!({ ...formItem, id: uuid }) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } @@ -108,6 +109,7 @@ export const OverlayItemsIndexPage = ({ try { await layer?.api?.deleteItem!(item.id) success = true + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { toast.error(error.toString()) } diff --git a/src/Utils/ReverseGeocoder.ts b/src/Utils/ReverseGeocoder.ts index 3879b291..ca227063 100644 --- a/src/Utils/ReverseGeocoder.ts +++ b/src/Utils/ReverseGeocoder.ts @@ -34,7 +34,9 @@ export async function reverseGeocode(lat: number, lon: number): Promise // Formatiere die Adresse const formattedAddress = `${street} ${houseNumber}, ${city}`.trim() return formattedAddress || '' + // eslint-disable-next-line no-catch-all/no-catch-all } catch (error) { + // eslint-disable-next-line no-console console.error('Error:', error) return '' }