internal: Add lints for promises (#3733)

* Add lints for floating and misued promises

* Add logging async errors in main

* Add async error catch in test-utils

* Change any to unknown

* Trap promise errors and ignore more await warnings

* Add more ignores and toSync helper

* Fix more lint warnings

* Add more ignores and fixes

* Add more reject reporting

* Add accepting arbitrary parameters to toSync()

* Fix more lints

* Revert unintentional change to non-arrow function

* Revert unintentional change to use arrow function

* Fix new warnings in main with auto updater

* Fix formatting

* Change lints to error

This is what the recommended type checked rules do.

* Fix to properly report promise rejections

* Fix formatting

* Fix formatting

* Remove unused import

* Remove unused convenience function

* Move type helpers

* Fix to not return promise when caller doesn't expect it

* Add ignores to lsp code
This commit is contained in:
Jonathan Tran
2024-09-09 18:17:45 -04:00
committed by GitHub
parent 0a72d7a39a
commit 25443eba31
59 changed files with 786 additions and 528 deletions

View File

@ -108,6 +108,7 @@ export const SettingsAuthProviderBase = ({
sceneInfra.baseUnit = newBaseUnit
},
setEngineTheme: ({ context }) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
engineCommandManager.sendSceneCommand({
cmd_id: uuidv4(),
type: 'modeling_cmd_req',
@ -118,6 +119,7 @@ export const SettingsAuthProviderBase = ({
})
const opposingTheme = getOppositeTheme(context.app.theme.current)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
engineCommandManager.sendSceneCommand({
cmd_id: uuidv4(),
type: 'modeling_cmd_req',
@ -137,6 +139,7 @@ export const SettingsAuthProviderBase = ({
sceneInfra.theme = opposingTheme
},
setEngineEdges: ({ context }) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
engineCommandManager.sendSceneCommand({
cmd_id: uuidv4(),
type: 'modeling_cmd_req',
@ -186,6 +189,7 @@ export const SettingsAuthProviderBase = ({
resetSettingsIncludesUnitChange
) {
// Unit changes requires a re-exec of code
// eslint-disable-next-line @typescript-eslint/no-floating-promises
kclManager.executeCode(true)
} else {
// For any future logging we'd like to do
@ -197,8 +201,10 @@ export const SettingsAuthProviderBase = ({
console.error('Error executing AST after settings change', e)
}
},
persistSettings: ({ context }) =>
saveSettings(context, loadedProject?.project?.path),
persistSettings: ({ context }) => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
saveSettings(context, loadedProject?.project?.path)
},
},
}),
{ input: loadedSettings }
@ -289,6 +295,7 @@ export const SettingsAuthProviderBase = ({
actions: {
goToSignInPage: () => {
navigate(PATHS.SIGN_IN)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
logout()
},
goToIndexPage: () => {
@ -330,13 +337,11 @@ export const SettingsAuthProviderBase = ({
export default SettingsAuthProvider
export function logout() {
export async function logout() {
localStorage.removeItem(TOKEN_PERSIST_KEY)
return (
!isDesktop() &&
fetch(withBaseUrl('/logout'), {
method: 'POST',
credentials: 'include',
})
)
if (isDesktop()) return Promise.resolve(null)
return fetch(withBaseUrl('/logout'), {
method: 'POST',
credentials: 'include',
})
}