Merge pull request #33 from utopia-os/lint-promise

feat(other): lint promise
This commit is contained in:
antontranelis 2024-11-18 09:12:20 +01:00 committed by GitHub
commit 4031cd25ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 28 additions and 18 deletions

View File

@ -23,7 +23,7 @@ module.exports = {
plugins: [ plugins: [
'@typescript-eslint', '@typescript-eslint',
'import', 'import',
// 'promise', 'promise',
// 'security', // 'security',
// 'no-catch-all', // 'no-catch-all',
'react', 'react',
@ -122,21 +122,21 @@ module.exports = {
}, },
], ],
'import/prefer-default-export': 'off', 'import/prefer-default-export': 'off',
// // promise // promise
// 'promise/catch-or-return': 'error', 'promise/catch-or-return': 'error',
// 'promise/no-return-wrap': 'error', 'promise/no-return-wrap': 'error',
// 'promise/param-names': 'error', 'promise/param-names': 'error',
// 'promise/always-return': 'error', 'promise/always-return': 'error',
// 'promise/no-native': 'off', 'promise/no-native': 'off',
// 'promise/no-nesting': 'warn', 'promise/no-nesting': 'warn',
// 'promise/no-promise-in-callback': 'warn', 'promise/no-promise-in-callback': 'warn',
// 'promise/no-callback-in-promise': 'warn', 'promise/no-callback-in-promise': 'warn',
// 'promise/avoid-new': 'warn', 'promise/avoid-new': 'warn',
// 'promise/no-new-statics': 'error', 'promise/no-new-statics': 'error',
// 'promise/no-return-in-finally': 'warn', 'promise/no-return-in-finally': 'warn',
// 'promise/valid-params': 'warn', 'promise/valid-params': 'warn',
// 'promise/prefer-await-to-callbacks': 'error', 'promise/prefer-await-to-callbacks': 'error',
// 'promise/no-multiple-resolved': 'error', 'promise/no-multiple-resolved': 'error',
}, },
overrides: [ overrides: [
{ {

2
package-lock.json generated
View File

@ -46,6 +46,7 @@
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-json": "^3.1.0", "eslint-plugin-json": "^3.1.0",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.31.8", "eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-yml": "^1.14.0", "eslint-plugin-yml": "^1.14.0",
@ -2408,7 +2409,6 @@
"integrity": "sha512-57Zzfw8G6+Gq7axm2Pdo3gW/Rx3h9Yywgn61uE/3elTCOePEHVrn2i5CdfBwA1BLK0Q0WqctICIUSqXZW/VprQ==", "integrity": "sha512-57Zzfw8G6+Gq7axm2Pdo3gW/Rx3h9Yywgn61uE/3elTCOePEHVrn2i5CdfBwA1BLK0Q0WqctICIUSqXZW/VprQ==",
"dev": true, "dev": true,
"license": "ISC", "license": "ISC",
"peer": true,
"engines": { "engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0" "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
}, },

View File

@ -34,6 +34,7 @@
"eslint-plugin-import": "^2.31.0", "eslint-plugin-import": "^2.31.0",
"eslint-plugin-json": "^3.1.0", "eslint-plugin-json": "^3.1.0",
"eslint-plugin-prettier": "^5.2.1", "eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-react": "^7.31.8", "eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-yml": "^1.14.0", "eslint-plugin-yml": "^1.14.0",

View File

@ -64,7 +64,9 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi<any>
console.log(value) console.log(value)
setAttestations(value) setAttestations(value)
return null
}) })
// eslint-disable-next-line promise/prefer-await-to-callbacks
.catch((error) => { .catch((error) => {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error('Error fetching items:', error) console.error('Error fetching items:', error)

View File

@ -16,7 +16,9 @@ const SocialShareBar = ({
.writeText(url) .writeText(url)
.then(() => { .then(() => {
toast.success('link copied to clipboard') toast.success('link copied to clipboard')
return null
}) })
// eslint-disable-next-line promise/prefer-await-to-callbacks
.catch((error: never) => { .catch((error: never) => {
toast.error('Fehler beim Kopieren des Links: ', error) toast.error('Fehler beim Kopieren des Links: ', error)
}) })

View File

@ -1,5 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-argument */ /* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-floating-promises */
/* eslint-disable @typescript-eslint/restrict-template-expressions */ /* eslint-disable @typescript-eslint/restrict-template-expressions */
import { useEffect, useState } from 'react' import { useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom' import { useNavigate } from 'react-router-dom'
@ -43,6 +42,9 @@ export function UserSettings() {
}, },
}) })
.then(() => navigate('/')) .then(() => navigate('/'))
.catch((e) => {
throw e
})
} }
return ( return (

View File

@ -16,6 +16,7 @@ import { encodeTag } from '#utils/FormatTags'
import { hashTagRegex } from '#utils/HashTagRegex' import { hashTagRegex } from '#utils/HashTagRegex'
import { randomColor } from '#utils/RandomColor' import { randomColor } from '#utils/RandomColor'
// eslint-disable-next-line promise/avoid-new
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)) const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms))
export const submitNewItem = async ( export const submitNewItem = async (
@ -243,6 +244,7 @@ export const onUpdateItem = async (
.then(() => { .then(() => {
setLoading(false) setLoading(false)
navigate(`/item/${item.id}${params && '?' + params}`) navigate(`/item/${item.id}${params && '?' + params}`)
return null
}) })
} else { } else {
item.new = false item.new = false
@ -272,6 +274,7 @@ export const onUpdateItem = async (
.then(() => { .then(() => {
setLoading(false) setLoading(false)
navigate(`/${params && '?' + params}`) navigate(`/${params && '?' + params}`)
return null
}) })
} }
} }