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:
@ -18,6 +18,7 @@ import toast from 'react-hot-toast'
|
||||
import { SettingsViaQueryString } from 'lib/settings/settingsTypes'
|
||||
import { EXECUTE_AST_INTERRUPT_ERROR_MESSAGE } from 'lib/constants'
|
||||
import { KclManager } from 'lang/KclSingleton'
|
||||
import { reportRejection } from 'lib/trap'
|
||||
|
||||
// TODO(paultag): This ought to be tweakable.
|
||||
const pingIntervalMs = 5_000
|
||||
@ -388,11 +389,12 @@ class EngineConnection extends EventTarget {
|
||||
default:
|
||||
if (this.isConnecting()) break
|
||||
// Means we never could do an initial connection. Reconnect everything.
|
||||
if (!this.pingPongSpan.ping) this.connect()
|
||||
if (!this.pingPongSpan.ping) this.connect().catch(reportRejection)
|
||||
break
|
||||
}
|
||||
}, pingIntervalMs)
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.connect()
|
||||
}
|
||||
|
||||
@ -1464,6 +1466,7 @@ export class EngineCommandManager extends EventTarget {
|
||||
})
|
||||
)
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
this.onEngineConnectionOpened = async () => {
|
||||
// Set the stream background color
|
||||
// This takes RGBA values from 0-1
|
||||
@ -1480,6 +1483,7 @@ export class EngineCommandManager extends EventTarget {
|
||||
|
||||
// Sets the default line colors
|
||||
const opposingTheme = getOppositeTheme(this.settings.theme)
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.sendSceneCommand({
|
||||
cmd_id: uuidv4(),
|
||||
type: 'modeling_cmd_req',
|
||||
@ -1490,6 +1494,7 @@ export class EngineCommandManager extends EventTarget {
|
||||
})
|
||||
|
||||
// Set the edge lines visibility
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.sendSceneCommand({
|
||||
type: 'modeling_cmd_req',
|
||||
cmd_id: uuidv4(),
|
||||
@ -1500,6 +1505,7 @@ export class EngineCommandManager extends EventTarget {
|
||||
})
|
||||
|
||||
this._camControlsCameraChange()
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.sendSceneCommand({
|
||||
// CameraControls subscribes to default_camera_get_settings response events
|
||||
// firing this at connection ensure the camera's are synced initially
|
||||
@ -1512,6 +1518,7 @@ export class EngineCommandManager extends EventTarget {
|
||||
// We want modify the grid first because we don't want it to flash.
|
||||
// Ideally these would already be default hidden in engine (TODO do
|
||||
// that) https://github.com/KittyCAD/engine/issues/2282
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.modifyGrid(!this.settings.showScaleGrid)?.then(async () => {
|
||||
await this.initPlanes()
|
||||
setIsStreamReady(true)
|
||||
@ -1715,6 +1722,7 @@ export class EngineCommandManager extends EventTarget {
|
||||
this.onEngineConnectionNewTrack as EventListener
|
||||
)
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.engineConnection?.connect()
|
||||
}
|
||||
this.engineConnection.addEventListener(
|
||||
@ -2125,6 +2133,7 @@ export class EngineCommandManager extends EventTarget {
|
||||
* @param visible - whether to show or hide the scale grid
|
||||
*/
|
||||
setScaleGridVisibility(visible: boolean) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.modifyGrid(!visible)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user