[lint] Enforce @typescript-eslint/no-floating-promises (#3402)

This commit is contained in:
Chenlei Hu
2025-04-11 12:19:22 -04:00
committed by GitHub
parent 59e20964a0
commit dc5d7ea1be
60 changed files with 305 additions and 279 deletions

View File

@@ -41,9 +41,7 @@ export const useNodeDragAndDrop = <T>(
if (!isDraggingValidFiles(e)) return false
const files = filterFiles(e.dataTransfer!.files)
onDrop(files).then((results) => {
if (!results?.length) return
})
void onDrop(files)
return true
}
}

View File

@@ -23,9 +23,7 @@ export const useNodePaste = <T>(
const paste = allow_batch ? filteredFiles : filteredFiles.slice(0, 1)
onPaste(paste).then((result) => {
if (!result) return
})
void onPaste(paste)
return true
}
}

View File

@@ -117,7 +117,7 @@ export const useWorkflowPacks = (options: UseNodePacksOptions = {}) => {
workflowPacks: nodePacks,
startFetchWorkflowPacks: async () => {
await getWorkflowPacks() // Parse the packs from the workflow nodes
startFetch() // Fetch the packs infos from the registry
await startFetch() // Fetch the packs infos from the registry
},
filterWorkflowPack
}

View File

@@ -21,7 +21,7 @@ export const useCanvasDrop = (canvasRef: Ref<HTMLCanvasElement>) => {
usePragmaticDroppable(() => canvasRef.value, {
getDropEffect: (args): Exclude<DataTransfer['dropEffect'], 'none'> =>
args.source.data.type === 'tree-explorer-node' ? 'copy' : 'move',
onDrop: (event) => {
onDrop: async (event) => {
const loc = event.location.current.input
const dndData = event.source.data
@@ -79,7 +79,7 @@ export const useCanvasDrop = (canvasRef: Ref<HTMLCanvasElement>) => {
loc.clientX,
loc.clientY
])
workflowService.insertWorkflow(workflow, { position })
await workflowService.insertWorkflow(workflow, { position })
}
}
}

View File

@@ -107,8 +107,8 @@ export function useCoreCommands(): ComfyCommand[] {
icon: 'pi pi-download',
label: 'Export Workflow',
menubarLabel: 'Export',
function: () => {
workflowService.exportWorkflow('workflow', 'workflow')
function: async () => {
await workflowService.exportWorkflow('workflow', 'workflow')
}
},
{
@@ -116,8 +116,8 @@ export function useCoreCommands(): ComfyCommand[] {
icon: 'pi pi-download',
label: 'Export Workflow (API Format)',
menubarLabel: 'Export (API)',
function: () => {
workflowService.exportWorkflow('workflow_api', 'output')
function: async () => {
await workflowService.exportWorkflow('workflow_api', 'output')
}
},
{
@@ -272,16 +272,19 @@ export function useCoreCommands(): ComfyCommand[] {
const settingStore = useSettingStore()
let lastLinksRenderMode = LiteGraph.SPLINE_LINK
return () => {
return async () => {
const currentMode = settingStore.get('Comfy.LinkRenderMode')
if (currentMode === LiteGraph.HIDDEN_LINK) {
// If links are hidden, restore the last positive value or default to spline mode
settingStore.set('Comfy.LinkRenderMode', lastLinksRenderMode)
await settingStore.set('Comfy.LinkRenderMode', lastLinksRenderMode)
} else {
// If links are visible, store the current mode and hide links
lastLinksRenderMode = currentMode
settingStore.set('Comfy.LinkRenderMode', LiteGraph.HIDDEN_LINK)
await settingStore.set(
'Comfy.LinkRenderMode',
LiteGraph.HIDDEN_LINK
)
}
}
})()
@@ -291,9 +294,9 @@ export function useCoreCommands(): ComfyCommand[] {
icon: 'pi pi-play',
label: 'Queue Prompt',
versionAdded: '1.3.7',
function: () => {
function: async () => {
const batchCount = useQueueSettingsStore().batchCount
app.queuePrompt(0, batchCount)
await app.queuePrompt(0, batchCount)
}
},
{
@@ -301,9 +304,9 @@ export function useCoreCommands(): ComfyCommand[] {
icon: 'pi pi-play',
label: 'Queue Prompt (Front)',
versionAdded: '1.3.7',
function: () => {
function: async () => {
const batchCount = useQueueSettingsStore().batchCount
app.queuePrompt(-1, batchCount)
await app.queuePrompt(-1, batchCount)
}
},
{
@@ -345,8 +348,8 @@ export function useCoreCommands(): ComfyCommand[] {
icon: 'pi pi-step-forward',
label: 'Next Opened Workflow',
versionAdded: '1.3.9',
function: () => {
workflowService.loadNextOpenedWorkflow()
function: async () => {
await workflowService.loadNextOpenedWorkflow()
}
},
{
@@ -354,8 +357,8 @@ export function useCoreCommands(): ComfyCommand[] {
icon: 'pi pi-step-backward',
label: 'Previous Opened Workflow',
versionAdded: '1.3.9',
function: () => {
workflowService.loadPreviousOpenedWorkflow()
function: async () => {
await workflowService.loadPreviousOpenedWorkflow()
}
},
{
@@ -438,15 +441,15 @@ export function useCoreCommands(): ComfyCommand[] {
let previousDarkTheme: string = DEFAULT_DARK_COLOR_PALETTE.id
let previousLightTheme: string = DEFAULT_LIGHT_COLOR_PALETTE.id
return () => {
return async () => {
const settingStore = useSettingStore()
const theme = colorPaletteStore.completedActivePalette
if (theme.light_theme) {
previousLightTheme = theme.id
settingStore.set('Comfy.ColorPalette', previousDarkTheme)
await settingStore.set('Comfy.ColorPalette', previousDarkTheme)
} else {
previousDarkTheme = theme.id
settingStore.set('Comfy.ColorPalette', previousLightTheme)
await settingStore.set('Comfy.ColorPalette', previousLightTheme)
}
}
})()
@@ -544,8 +547,8 @@ export function useCoreCommands(): ComfyCommand[] {
icon: 'pi pi-clone',
label: 'Duplicate Current Workflow',
versionAdded: '1.6.15',
function: () => {
workflowService.duplicateWorkflow(workflowStore.activeWorkflow!)
function: async () => {
await workflowService.duplicateWorkflow(workflowStore.activeWorkflow!)
}
},
{
@@ -553,9 +556,9 @@ export function useCoreCommands(): ComfyCommand[] {
icon: 'pi pi-times',
label: 'Close Current Workflow',
versionAdded: '1.7.3',
function: () => {
function: async () => {
if (workflowStore.activeWorkflow)
workflowService.closeWorkflow(workflowStore.activeWorkflow)
await workflowService.closeWorkflow(workflowStore.activeWorkflow)
}
},
{

View File

@@ -55,7 +55,8 @@ export function useDownload(url: string, fileName?: string) {
// Try falling back to normal fetch if using Civitai API fails
whenever(civitaiErr, fetchFileSize, { once: true })
} else {
fetchFileSize()
// Fetch file size in the background
void fetchFileSize()
}
})

View File

@@ -44,7 +44,7 @@ export const useRefreshableSelection = () => {
if (!isRefreshable.value) return
if (isAllNodesSelected.value) {
commandStore.execute('Comfy.RefreshNodeDefinitions')
await commandStore.execute('Comfy.RefreshNodeDefinitions')
} else {
await Promise.all(refreshableWidgets.value.map((item) => item.refresh()))
}

View File

@@ -32,23 +32,23 @@ export const useServerLogs = (options: UseServerLogsOptions = {}) => {
}
}
const start = () => {
api.subscribeLogs(true)
const start = async () => {
await api.subscribeLogs(true)
stop = useEventListener(api, LOGS_MESSAGE_TYPE, handleLogMessage)
}
const stopListening = () => {
const stopListening = async () => {
stop?.()
stop = null
api.subscribeLogs(false)
await api.subscribeLogs(false)
}
if (immediate) {
start()
void start()
}
onUnmounted(() => {
stopListening()
onUnmounted(async () => {
await stopListening()
logs.value = []
})

View File

@@ -189,14 +189,18 @@ export function useRemoteWidget<
* @returns the most recent value of the widget.
*/
function getValue(onFulfilled?: () => void) {
fetchValue().then((data) => {
if (isFirstLoad()) onFirstLoad(data)
if (refreshQueued && data !== defaultValue) {
onRefresh()
refreshQueued = false
}
onFulfilled?.()
})
void fetchValue()
.then((data) => {
if (isFirstLoad()) onFirstLoad(data)
if (refreshQueued && data !== defaultValue) {
onRefresh()
refreshQueued = false
}
onFulfilled?.()
})
.catch((err) => {
console.error(err)
})
return getCachedValue() ?? defaultValue
}