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

2
package-lock.json generated
View File

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

View File

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

View File

@ -64,7 +64,9 @@ export function ProfileView({ attestationApi }: { attestationApi?: ItemsApi<any>
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,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

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