diff --git a/.eslintrc.js b/.eslintrc.js index ad8b6e75..f666ced6 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..e41b659a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,6 +46,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", @@ -2408,7 +2409,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 825bc7b7..62f70c92 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,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", diff --git a/src/Components/Profile/ProfileView.tsx b/src/Components/Profile/ProfileView.tsx index 2414075c..92a329c4 100644 --- a/src/Components/Profile/ProfileView.tsx +++ b/src/Components/Profile/ProfileView.tsx @@ -64,7 +64,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) => { // eslint-disable-next-line no-console 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..b9baa1d4 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 ( @@ -243,6 +244,7 @@ export const onUpdateItem = async ( .then(() => { setLoading(false) navigate(`/item/${item.id}${params && '?' + params}`) + return null }) } else { item.new = false @@ -272,6 +274,7 @@ export const onUpdateItem = async ( .then(() => { setLoading(false) navigate(`/${params && '?' + params}`) + return null }) } }