Merge branch 'main' into lint-security

This commit is contained in:
antontranelis 2024-11-18 09:28:52 +01:00 committed by GitHub
commit f4e71050a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 81 additions and 28 deletions

View File

@ -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: [
{

View File

@ -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`

13
package-lock.json generated
View File

@ -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"
},

View File

@ -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",

View File

@ -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
}

View File

@ -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), {

View File

@ -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

View File

@ -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(

View File

@ -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())
}

View File

@ -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())
}

View File

@ -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 })

View File

@ -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())
}

View File

@ -60,11 +60,15 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi<any>
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)
})
}

View File

@ -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(

View File

@ -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,

View File

@ -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)
})

View File

@ -17,6 +17,7 @@ const componentMap = {
}
export const FlexView = ({ item }: { item: Item }) => {
// eslint-disable-next-line no-console
console.log(item)
return (
<div className='tw-h-full tw-overflow-y-auto fade'>

View File

@ -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 (

View File

@ -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
})
}
}

View File

@ -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

View File

@ -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())
}

View File

@ -34,7 +34,9 @@ export async function reverseGeocode(lat: number, lon: number): Promise<string>
// 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 ''
}