From 97c3ef867ef768a8ffad48d58a19aa418394ad80 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 9 Nov 2024 00:40:44 +0100 Subject: [PATCH 1/8] promise linting --- .eslintrc.js | 32 ++++++++++++++++---------------- package-lock.json | 20 +++++++++++++++++++- package.json | 2 ++ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3836ab1a..b16fbb01 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,7 +23,7 @@ module.exports = { plugins: [ '@typescript-eslint', 'import', - // 'promise', + 'promise', // 'security', // 'no-catch-all', 'react', @@ -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/package-lock.json b/package-lock.json index 74187848..e5f9cdab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,6 +33,7 @@ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", "@types/geojson": "^7946.0.14", "@types/leaflet": "^1.7.11", + "@types/node": "^20.12.1", "@types/react": "^18.2.0", "@types/react-dom": "^18.0.5", "@typescript-eslint/eslint-plugin": "^5.62.0", @@ -46,6 +47,7 @@ "eslint-plugin-import": "^2.31.0", "eslint-plugin-json": "^3.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-yml": "^1.14.0", @@ -453,6 +455,16 @@ "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, + "node_modules/@types/node": { + "version": "20.12.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.1.tgz", + "integrity": "sha512-5lcxgB72hlSF7ZS9ZzX1RCLc9+BovxjL17T00xSmj3c0ygZFjPdNnN0RchfGpot/yniVMkWnyO6aR9Dr1q9qrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~5.26.4" + } + }, "node_modules/@types/offscreencanvas": { "version": "2019.7.1", "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.1.tgz", @@ -2408,7 +2420,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" }, @@ -7157,6 +7168,13 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true, + "license": "MIT" + }, "node_modules/unified": { "version": "11.0.4", "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.4.tgz", diff --git a/package.json b/package.json index 825bc7b7..5fb22ce0 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", "@types/geojson": "^7946.0.14", "@types/leaflet": "^1.7.11", + "@types/node": "^20.12.1", "@types/react": "^18.2.0", "@types/react-dom": "^18.0.5", "@typescript-eslint/eslint-plugin": "^5.62.0", @@ -34,6 +35,7 @@ "eslint-plugin-import": "^2.31.0", "eslint-plugin-json": "^3.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-yml": "^1.14.0", From 782b0fc700842fa2877074839a8c5f7d8cff3163 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 9 Nov 2024 00:40:54 +0100 Subject: [PATCH 2/8] fix errors --- src/Components/Profile/ProfileView.tsx | 2 ++ src/Components/Profile/Subcomponents/SocialShareBar.tsx | 2 ++ src/Components/Profile/UserSettings.tsx | 4 +++- src/Components/Profile/itemFunctions.ts | 8 +++++--- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Components/Profile/ProfileView.tsx b/src/Components/Profile/ProfileView.tsx index a54ae222..ec98a677 100644 --- a/src/Components/Profile/ProfileView.tsx +++ b/src/Components/Profile/ProfileView.tsx @@ -63,7 +63,9 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi console.log(value) setAttestations(value) + return null }) + // eslint-disable-next-line promise/prefer-await-to-callbacks .catch((error) => { console.error('Error fetching items:', error) }) 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/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..d1f35043 100644 --- a/src/Components/Profile/itemFunctions.ts +++ b/src/Components/Profile/itemFunctions.ts @@ -9,6 +9,8 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ +import { setTimeout } from 'timers/promises' + import { toast } from 'react-toastify' import { Item } from '#src/types' @@ -16,8 +18,6 @@ import { encodeTag } from '#utils/FormatTags' import { hashTagRegex } from '#utils/HashTagRegex' import { randomColor } from '#utils/RandomColor' -const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) - export const submitNewItem = async ( evt: any, type: string, @@ -224,7 +224,7 @@ export const onUpdateItem = async ( }) // take care that addTag request comes before item request - await sleep(200) + await setTimeout(200) if (!item.new) { item?.layer?.api?.updateItem && @@ -243,6 +243,7 @@ export const onUpdateItem = async ( .then(() => { setLoading(false) navigate(`/item/${item.id}${params && '?' + params}`) + return null }) } else { item.new = false @@ -272,6 +273,7 @@ export const onUpdateItem = async ( .then(() => { setLoading(false) navigate(`/${params && '?' + params}`) + return null }) } } From 5dd4c676379b6b29a42dc5f2a8f86cedcb4ebb7e Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 11 Nov 2024 17:02:10 +0100 Subject: [PATCH 3/8] lint no console log --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3836ab1a..ad8b6e75 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -45,7 +45,7 @@ module.exports = { '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-console': 'error', 'no-debugger': 'error', camelcase: 'error', indent: ['error', 2], From 5a7bdfe7f70d3c4b4afbe83a91e11de326f8bb4c Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 11 Nov 2024 17:02:21 +0100 Subject: [PATCH 4/8] lint fixes --- src/Components/Auth/SetNewPasswordPage.tsx | 1 + src/Components/Map/Subcomponents/Controls/SearchControl.tsx | 3 +++ src/Components/Map/Subcomponents/ItemFormPopup.tsx | 1 + src/Components/Map/UtopiaMapInner.tsx | 1 + src/Components/Profile/ProfileView.tsx | 2 ++ src/Components/Profile/Subcomponents/ContactInfoView.tsx | 1 + src/Components/Profile/Subcomponents/GroupSubheaderForm.tsx | 1 + src/Components/Profile/Templates/FlexView.tsx | 1 + src/Components/Templates/MarketView.tsx | 1 + src/Utils/ReverseGeocoder.ts | 1 + 10 files changed, 13 insertions(+) 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/Map/Subcomponents/Controls/SearchControl.tsx b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx index 88022721..6ad9404e 100644 --- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -64,6 +64,7 @@ export const SearchControl = () => { const { data } = await axios.get(`https://photon.komoot.io/api/?q=${value}&limit=5`) setGeoResults(data.features) } catch (error) { + // eslint-disable-next-line no-console console.log(error) } } @@ -215,6 +216,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 +286,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..09119a0f 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -74,6 +74,7 @@ export function ItemFormPopup(props: ItemFormPopupProps) { toast.error(error.toString()) } if (success) { + // eslint-disable-next-line no-console console.log(props.item) updateItem({ ...props.item, ...formItem }) 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/Profile/ProfileView.tsx b/src/Components/Profile/ProfileView.tsx index a54ae222..2414075c 100644 --- a/src/Components/Profile/ProfileView.tsx +++ b/src/Components/Profile/ProfileView.tsx @@ -60,11 +60,13 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi attestationApi .getItems() .then((value) => { + // eslint-disable-next-line no-console console.log(value) setAttestations(value) }) .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/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/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/Utils/ReverseGeocoder.ts b/src/Utils/ReverseGeocoder.ts index 3879b291..627626cf 100644 --- a/src/Utils/ReverseGeocoder.ts +++ b/src/Utils/ReverseGeocoder.ts @@ -35,6 +35,7 @@ export async function reverseGeocode(lat: number, lon: number): Promise const formattedAddress = `${street} ${houseNumber}, ${city}`.trim() return formattedAddress || '' } catch (error) { + // eslint-disable-next-line no-console console.error('Error:', error) return '' } From e84061178fc8116bebafbeddcf35f8d635fb5e18 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 12 Nov 2024 09:26:57 +0100 Subject: [PATCH 5/8] remove node environment requirement --- package-lock.json | 18 ------------------ package.json | 1 - src/Components/Profile/itemFunctions.ts | 7 ++++--- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index e5f9cdab..e41b659a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,7 +33,6 @@ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", "@types/geojson": "^7946.0.14", "@types/leaflet": "^1.7.11", - "@types/node": "^20.12.1", "@types/react": "^18.2.0", "@types/react-dom": "^18.0.5", "@typescript-eslint/eslint-plugin": "^5.62.0", @@ -455,16 +454,6 @@ "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" }, - "node_modules/@types/node": { - "version": "20.12.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.1.tgz", - "integrity": "sha512-5lcxgB72hlSF7ZS9ZzX1RCLc9+BovxjL17T00xSmj3c0ygZFjPdNnN0RchfGpot/yniVMkWnyO6aR9Dr1q9qrg==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~5.26.4" - } - }, "node_modules/@types/offscreencanvas": { "version": "2019.7.1", "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.1.tgz", @@ -7168,13 +7157,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", - "dev": true, - "license": "MIT" - }, "node_modules/unified": { "version": "11.0.4", "resolved": "https://registry.npmjs.org/unified/-/unified-11.0.4.tgz", diff --git a/package.json b/package.json index 5fb22ce0..62f70c92 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "@eslint-community/eslint-plugin-eslint-comments": "^4.4.1", "@types/geojson": "^7946.0.14", "@types/leaflet": "^1.7.11", - "@types/node": "^20.12.1", "@types/react": "^18.2.0", "@types/react-dom": "^18.0.5", "@typescript-eslint/eslint-plugin": "^5.62.0", diff --git a/src/Components/Profile/itemFunctions.ts b/src/Components/Profile/itemFunctions.ts index d1f35043..b9baa1d4 100644 --- a/src/Components/Profile/itemFunctions.ts +++ b/src/Components/Profile/itemFunctions.ts @@ -9,8 +9,6 @@ /* eslint-disable @typescript-eslint/no-unsafe-call */ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ -import { setTimeout } from 'timers/promises' - import { toast } from 'react-toastify' import { Item } from '#src/types' @@ -18,6 +16,9 @@ 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 ( evt: any, type: string, @@ -224,7 +225,7 @@ export const onUpdateItem = async ( }) // take care that addTag request comes before item request - await setTimeout(200) + await sleep(200) if (!item.new) { item?.layer?.api?.updateItem && From 8556c07378445fe205725747a6fa0da68f85f5fb Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 11 Nov 2024 16:56:06 +0100 Subject: [PATCH 6/8] install lint no-catch-all rule --- .eslintrc.js | 4 ++-- package-lock.json | 11 +++++++++++ package.json | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index ad8b6e75..3c1e763b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -25,7 +25,7 @@ module.exports = { 'import', // 'promise', // 'security', - // 'no-catch-all', + 'no-catch-all', 'react', 'react-hooks', ], @@ -44,7 +44,7 @@ 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-catch-all/no-catch-all': 'error', 'no-console': 'error', 'no-debugger': 'error', camelcase: 'error', diff --git a/package-lock.json b/package-lock.json index 74187848..da7b17b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,6 +45,7 @@ "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-react": "^7.31.8", "eslint-plugin-react-hooks": "^4.6.0", @@ -2371,6 +2372,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", diff --git a/package.json b/package.json index 825bc7b7..a7b498dd 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "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-react": "^7.31.8", "eslint-plugin-react-hooks": "^4.6.0", From 6e60d47e865e9670f24f1c876a15e6a6f5b78071 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Mon, 11 Nov 2024 16:56:22 +0100 Subject: [PATCH 7/8] fix all lint errors --- src/Components/AppShell/ContextWrapper.tsx | 1 + src/Components/Auth/useAuth.tsx | 1 + src/Components/Map/Subcomponents/Controls/SearchControl.tsx | 1 + src/Components/Map/Subcomponents/ItemFormPopup.tsx | 2 ++ src/Components/Map/Subcomponents/ItemViewPopup.tsx | 1 + src/Components/Map/hooks/useSelectPosition.tsx | 3 +++ src/Components/Profile/itemFunctions.ts | 4 ++++ src/Components/Templates/OverlayItemsIndexPage.tsx | 2 ++ src/Utils/ReverseGeocoder.ts | 1 + 9 files changed, 16 insertions(+) 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/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 6ad9404e..d84fbf62 100644 --- a/src/Components/Map/Subcomponents/Controls/SearchControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/SearchControl.tsx @@ -63,6 +63,7 @@ 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) diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx index 09119a0f..405a3415 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -70,6 +70,7 @@ 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()) } @@ -101,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/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/itemFunctions.ts b/src/Components/Profile/itemFunctions.ts index 3ad3d1d5..869aa686 100644 --- a/src/Components/Profile/itemFunctions.ts +++ b/src/Components/Profile/itemFunctions.ts @@ -62,6 +62,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 +84,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 +102,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 +126,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()) } 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 627626cf..ca227063 100644 --- a/src/Utils/ReverseGeocoder.ts +++ b/src/Utils/ReverseGeocoder.ts @@ -34,6 +34,7 @@ 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) From 0d10422fd28a6d28e3a03ccf7a143c509bce2d0b Mon Sep 17 00:00:00 2001 From: antontranelis <31516529+antontranelis@users.noreply.github.com> Date: Mon, 18 Nov 2024 06:28:58 +0100 Subject: [PATCH 8/8] Update README.md --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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`