[TS] Enable noUnusedParameters (#3110)

This commit is contained in:
Chenlei Hu
2025-03-17 16:47:45 -04:00
committed by GitHub
parent 7e66e99c3a
commit 7af003fcab
31 changed files with 79 additions and 93 deletions

View File

@@ -45,7 +45,7 @@ const props = withDefaults(
)
const imageBroken = ref(false)
const handleImageError = (e: Event) => {
const handleImageError = () => {
imageBroken.value = true
}

View File

@@ -103,7 +103,7 @@ const fileSize = computed(() =>
const electronDownloadStore = useElectronDownloadStore()
const [savePath, filename] = props.label.split('/')
electronDownloadStore.$subscribe((mutation, { downloads }) => {
electronDownloadStore.$subscribe((_, { downloads }) => {
const download = downloads.find((download) => props.url === download.url)
if (download) {

View File

@@ -34,7 +34,7 @@ describe('SettingItem', () => {
name: 'Node Input Conversion Submenus',
type: 'combo',
value: 'Top',
options: (value: string) => ['Correctly Translated']
options: () => ['Correctly Translated']
}
})

View File

@@ -247,14 +247,14 @@ class ImagePreviewWidget implements ICustomWidget {
draw(
ctx: CanvasRenderingContext2D,
node: LGraphNode,
widget_width: number,
_width: number,
y: number,
H: number
_height: number
): void {
renderPreview(ctx, node, y)
}
computeLayoutSize(this: IBaseWidget, node: LGraphNode) {
computeLayoutSize(this: IBaseWidget) {
return {
minHeight: 220,
minWidth: 1

View File

@@ -9,7 +9,6 @@ import type { ResultItem } from '@/schemas/apiSchema'
import type { InputSpec } from '@/schemas/nodeDefSchema'
import type { ComfyWidgetConstructor } from '@/scripts/widgets'
import { useNodeOutputStore } from '@/stores/imagePreviewStore'
import type { ComfyApp } from '@/types'
import { createAnnotatedPath } from '@/utils/formatUtil'
import { addToComboValues } from '@/utils/litegraphUtil'
@@ -32,8 +31,7 @@ export const useImageUploadWidget = () => {
const widgetConstructor: ComfyWidgetConstructor = (
node: LGraphNode,
inputName: string,
inputData: InputSpec,
app: ComfyApp
inputData: InputSpec
) => {
const inputOptions = inputData[1] ?? {}
const { imageInputName, allow_batch, image_folder = 'input' } = inputOptions

View File

@@ -153,7 +153,7 @@ app.registerExtension({
const weightDelta = event.key === 'ArrowUp' ? delta : -delta
const updatedText = selectedText.replace(
/\((.*):([+-]?\d+(?:\.\d+)?)\)/,
(match, text, weight) => {
(_, text, weight) => {
weight = incrementWeight(weight, weightDelta)
if (weight == 1) {
return text

View File

@@ -1020,7 +1020,7 @@ export class GroupNodeHandler {
// Draw custom collapse icon to identity this as a group
const onDrawTitleBox = this.node.onDrawTitleBox
this.node.onDrawTitleBox = function (ctx, height, size, scale) {
this.node.onDrawTitleBox = function (ctx, height) {
onDrawTitleBox?.apply(this, arguments)
const fill = ctx.fillStyle
@@ -1128,7 +1128,7 @@ export class GroupNodeHandler {
this,
'executing',
(d) => d,
(d, id, node) => id
(_, id) => id
)
const executed = handleEvent.call(
@@ -1223,7 +1223,7 @@ export class GroupNodeHandler {
}
}
populatePrimitive(node, nodeId, oldName, i, linkedShift) {
populatePrimitive(_node, nodeId, oldName) {
// Converted widget, populate primitive if linked
const primitiveId = this.groupData.widgetToPrimitive[nodeId]?.[oldName]
if (primitiveId == null) return
@@ -1301,7 +1301,7 @@ export class GroupNodeHandler {
)
const mainWidget = this.node.widgets[widgetIndex]
if (
this.populatePrimitive(node, nodeId, oldName, i, linkedShift) ||
this.populatePrimitive(node, nodeId, oldName) ||
widgetIndex === -1
) {
// Find the inner widget and shift by the number of linked widgets as they will have been removed too

View File

@@ -394,7 +394,7 @@ export class ManageGroupDialog extends ComfyDialog<HTMLDialogElement> {
$el(
'button.comfy-btn',
{
onclick: (e) => {
onclick: () => {
const node = app.graph.nodes.find(
(n) => n.type === `${PREFIX}${SEPARATOR}` + this.selectedGroup
)

View File

@@ -275,7 +275,7 @@ app.registerExtension({
app.registerExtension({
name: 'Comfy.Preview3D',
async beforeRegisterNodeDef(nodeType, nodeData) {
async beforeRegisterNodeDef(_nodeType, nodeData) {
if ('Preview3D' === nodeData.name) {
// @ts-expect-error InputSpec is not typed correctly
nodeData.input.required.image = ['PREVIEW_3D']
@@ -348,7 +348,7 @@ app.registerExtension({
app.registerExtension({
name: 'Comfy.Preview3DAnimation',
async beforeRegisterNodeDef(nodeType, nodeData) {
async beforeRegisterNodeDef(_nodeType, nodeData) {
if ('Preview3DAnimation' === nodeData.name) {
// @ts-expect-error InputSpec is not typed correctly
nodeData.input.required.image = ['PREVIEW_3D_ANIMATION']

View File

@@ -19,7 +19,7 @@ function dataURLToBlob(dataURL) {
}
function loadImage(imagePath) {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
const image = new Image()
image.onload = function () {
@@ -36,7 +36,6 @@ async function uploadMask(filepath, formData) {
method: 'POST',
body: formData
})
.then((response) => {})
.catch((error) => {
console.error('Error:', error)
})
@@ -625,10 +624,10 @@ export class MaskEditorDialogOld extends ComfyDialog {
maskCanvas.addEventListener('touchmove', (event) =>
this.draw_move(self, event)
)
maskCanvas.addEventListener('pointerover', (event) => {
maskCanvas.addEventListener('pointerover', () => {
this.brush.style.display = 'block'
})
maskCanvas.addEventListener('pointerleave', (event) => {
maskCanvas.addEventListener('pointerleave', () => {
this.brush.style.display = 'none'
})
@@ -763,7 +762,7 @@ export class MaskEditorDialogOld extends ComfyDialog {
brush.style.top = centerY - self.brush_size * this.zoom_ratio + 'px'
}
handleWheelEvent(self, event) {
handleWheelEvent(_, event) {
event.preventDefault()
if (event.ctrlKey) {

View File

@@ -2832,7 +2832,7 @@ class UIManager {
100,
1,
(await this.messageBroker.pull('brushSettings')).size,
(event, value) => {
(_, value) => {
this.messageBroker.publish('setBrushSize', parseInt(value))
this.updateBrushPreview()
}
@@ -2845,7 +2845,7 @@ class UIManager {
1,
0.01,
(await this.messageBroker.pull('brushSettings')).opacity,
(event, value) => {
(_, value) => {
this.messageBroker.publish('setBrushOpacity', parseFloat(value))
this.updateBrushPreview()
}
@@ -2858,7 +2858,7 @@ class UIManager {
1,
0.01,
(await this.messageBroker.pull('brushSettings')).hardness,
(event, value) => {
(_, value) => {
this.messageBroker.publish('setBrushHardness', parseFloat(value))
this.updateBrushPreview()
}
@@ -2871,7 +2871,7 @@ class UIManager {
100,
1,
(await this.messageBroker.pull('brushSettings')).smoothingPrecision,
(event, value) => {
(_, value) => {
this.messageBroker.publish(
'setBrushSmoothingPrecision',
parseInt(value)
@@ -2929,7 +2929,7 @@ class UIManager {
255,
1,
tolerance,
(event, value) => {
(_, value) => {
this.messageBroker.publish('setPaintBucketTolerance', parseInt(value))
}
)
@@ -2942,7 +2942,7 @@ class UIManager {
100,
1,
fillOpacity,
(event, value) => {
(_, value) => {
this.messageBroker.publish('setFillOpacity', parseInt(value))
}
)
@@ -2971,7 +2971,7 @@ class UIManager {
255,
1,
tolerance,
(event, value) => {
(_, value) => {
this.messageBroker.publish('setColorSelectTolerance', parseInt(value))
}
)
@@ -2983,21 +2983,21 @@ class UIManager {
100,
1,
100, // Default to 100%
(event, value) => {
(_, value) => {
this.messageBroker.publish('setSelectionOpacity', parseInt(value))
}
)
const livePreviewToggle = this.createToggle(
t('maskEditor.Live Preview'),
(event, value) => {
(_, value) => {
this.messageBroker.publish('setLivePreview', value)
}
)
const wholeImageToggle = this.createToggle(
t('maskEditor.Apply to Whole Image'),
(event, value) => {
(_, value) => {
this.messageBroker.publish('setWholeImage', value)
}
)
@@ -3006,14 +3006,14 @@ class UIManager {
const methodSelect = this.createDropdown(
t('maskEditor.Method'),
methodOptions,
(event, value) => {
(_, value) => {
this.messageBroker.publish('setColorComparisonMethod', value)
}
)
const maskBoundaryToggle = this.createToggle(
t('maskEditor.Stop at mask'),
(event, value) => {
(_, value) => {
this.messageBroker.publish('setMaskBoundary', value)
}
)
@@ -3024,7 +3024,7 @@ class UIManager {
255,
1,
0,
(event, value) => {
(_, value) => {
this.messageBroker.publish('setMaskTolerance', parseInt(value))
}
)
@@ -3125,7 +3125,7 @@ class UIManager {
1.0,
0.01,
this.mask_opacity,
(event, value) => {
(_, value) => {
this.mask_opacity = parseFloat(value)
this.maskCanvas.style.opacity = String(this.mask_opacity)
@@ -3635,7 +3635,7 @@ class UIManager {
this.messageBroker.publish('pointerUp', event)
})
pointer_zone.addEventListener('pointerleave', (event: PointerEvent) => {
pointer_zone.addEventListener('pointerleave', () => {
this.brush.style.opacity = '0'
this.pointerZone.style.cursor = ''
})
@@ -3656,12 +3656,9 @@ class UIManager {
this.messageBroker.publish('wheel', event)
)
pointer_zone.addEventListener(
'pointerenter',
async (event: PointerEvent) => {
this.updateCursor()
}
)
pointer_zone.addEventListener('pointerenter', async () => {
this.updateCursor()
})
return pointer_zone
}

View File

@@ -64,7 +64,7 @@ class ManageTemplates extends ComfyDialog {
createButtons() {
const btns = super.createButtons()
btns[0].textContent = 'Close'
btns[0].onclick = (e) => {
btns[0].onclick = () => {
clearTimeout(this.saveVisualCue)
this.close()
}
@@ -279,7 +279,7 @@ class ManageTemplates extends ComfyDialog {
fontSize: '12px',
fontWeight: 'normal'
},
onclick: (e) => {
onclick: () => {
const json = JSON.stringify({ templates: [t] }, null, 2) // convert the data to a JSON string
const blob = new Blob([json], {
type: 'application/json'

View File

@@ -35,7 +35,7 @@ app.registerExtension({
})
}
this.onConnectionsChange = (type, index, connected, link_info) => {
this.onConnectionsChange = (type, _index, connected) => {
if (app.configuringGraph) return
// Prevent multiple connections to different types when we have no input

View File

@@ -134,7 +134,7 @@ app.registerExtension({
})
const processMouseDown = LGraphCanvas.prototype.processMouseDown
LGraphCanvas.prototype.processMouseDown = function (e) {
LGraphCanvas.prototype.processMouseDown = function () {
if (touchZooming || touchCount) {
return
}
@@ -143,7 +143,7 @@ LGraphCanvas.prototype.processMouseDown = function (e) {
}
const processMouseMove = LGraphCanvas.prototype.processMouseMove
LGraphCanvas.prototype.processMouseMove = function (e) {
LGraphCanvas.prototype.processMouseMove = function () {
if (touchZooming || touchCount > 1) {
return
}

View File

@@ -23,14 +23,14 @@ app.registerExtension({
step: 1
},
defaultValue: 5,
onChange: (newVal, oldVal) => {
onChange: (newVal) => {
this.setDefaults(newVal)
}
})
},
slot_types_default_out: {},
slot_types_default_in: {},
async beforeRegisterNodeDef(nodeType, nodeData, app) {
async beforeRegisterNodeDef(nodeType, nodeData) {
var nodeId = nodeData.name
const inputs = nodeData['input']?.['required'] //only show required inputs to reduce the mess also not logical to create node with optional inputs
for (const inputKey in inputs) {

View File

@@ -148,7 +148,7 @@ app.registerExtension({
app.registerExtension({
name: 'Comfy.UploadAudio',
async beforeRegisterNodeDef(nodeType, nodeData: ComfyNodeDef) {
async beforeRegisterNodeDef(_nodeType, nodeData: ComfyNodeDef) {
if (nodeData?.input?.required?.audio?.[1]?.audio_upload === true) {
nodeData.input.required.upload = ['AUDIOUPLOAD', {}]
}

View File

@@ -34,7 +34,7 @@ const createUploadInput = (
app.registerExtension({
name: 'Comfy.UploadImage',
beforeRegisterNodeDef(nodeType, nodeData: ComfyNodeDef) {
beforeRegisterNodeDef(_nodeType, nodeData: ComfyNodeDef) {
const { input } = nodeData ?? {}
const { required } = input ?? {}
if (!required) return

View File

@@ -9,7 +9,7 @@ const WEBCAM_READY = Symbol()
app.registerExtension({
name: 'Comfy.WebcamCapture',
getCustomWidgets(app) {
getCustomWidgets() {
return {
WEBCAM(node, inputName) {
let res

View File

@@ -120,7 +120,7 @@ export class PrimitiveNode extends LGraphNode {
}
}
onConnectionsChange(type: ISlotType, index: number, connected: boolean) {
onConnectionsChange(_type: ISlotType, _index: number, connected: boolean) {
if (app.configuringGraph) {
// Dont run while the graph is still setting up
return
@@ -143,7 +143,7 @@ export class PrimitiveNode extends LGraphNode {
onConnectOutput(
slot: number,
type: string,
_type: string,
input: INodeInputSlot,
target_node: LGraphNode,
target_slot: number
@@ -651,7 +651,7 @@ app.registerExtension({
}
)
},
async beforeRegisterNodeDef(nodeType, nodeData, app) {
async beforeRegisterNodeDef(nodeType, _nodeData, app) {
// Add menu options to convert to/from widgets
const origGetExtraMenuOptions = nodeType.prototype.getExtraMenuOptions
// @ts-expect-error adding extra property

View File

@@ -15,8 +15,8 @@ const isFileProtocol = window.location.protocol === 'file:'
const basePath = isElectron() ? '/' : window.location.pathname
const guardElectronAccess = (
to: RouteLocationNormalized,
from: RouteLocationNormalized,
_to: RouteLocationNormalized,
_from: RouteLocationNormalized,
next: NavigationGuardNext
) => {
if (isElectron()) {
@@ -42,7 +42,7 @@ const router = createRouter({
path: '',
name: 'GraphView',
component: () => import('@/views/GraphView.vue'),
beforeEnter: async (to, from, next) => {
beforeEnter: async (_to, _from, next) => {
const userStore = useUserStore()
await userStore.initialize()
if (userStore.needsLogin) {
@@ -121,7 +121,7 @@ const router = createRouter({
}
],
scrollBehavior(to, from, savedPosition) {
scrollBehavior(_to, _from, savedPosition) {
if (savedPosition) {
return savedPosition
} else {

View File

@@ -547,9 +547,8 @@ export class ComfyApp {
node,
ctx,
size,
fgcolor,
bgcolor,
selected
_fgcolor,
bgcolor
) {
const res = origDrawNodeShape.apply(this, arguments)
@@ -627,7 +626,7 @@ export class ComfyApp {
}
const origDrawNode = LGraphCanvas.prototype.drawNode
LGraphCanvas.prototype.drawNode = function (node, ctx) {
LGraphCanvas.prototype.drawNode = function (node) {
const editor_alpha = this.editor_alpha
const old_color = node.color
const old_bgcolor = node.bgcolor
@@ -678,11 +677,11 @@ export class ComfyApp {
this.ui.setStatus(detail)
})
api.addEventListener('progress', ({ detail }) => {
api.addEventListener('progress', () => {
this.graph.setDirtyCanvas(true, false)
})
api.addEventListener('executing', ({ detail }) => {
api.addEventListener('executing', () => {
this.graph.setDirtyCanvas(true, false)
this.revokePreviews(this.runningNodeId)
delete this.nodePreviewImages[this.runningNodeId]
@@ -708,7 +707,7 @@ export class ComfyApp {
}
})
api.addEventListener('execution_start', ({ detail }) => {
api.addEventListener('execution_start', () => {
this.lastExecutionError = null
this.graph.nodes.forEach((node) => {
if (node.onExecutionStart) node.onExecutionStart()

View File

@@ -240,7 +240,7 @@ export class ChangeTracker {
true
)
window.addEventListener('keyup', (e) => {
window.addEventListener('keyup', () => {
if (keyIgnored) {
keyIgnored = false
logger.debug('checkState on keyup')
@@ -352,7 +352,7 @@ export class ChangeTracker {
})
}
static bindInput(app: ComfyApp, activeEl: Element | null): boolean {
static bindInput(_app: ComfyApp, activeEl: Element | null): boolean {
if (
!activeEl ||
activeEl.tagName === 'CANVAS' ||

View File

@@ -280,7 +280,7 @@ export async function importA1111(graph, parameters) {
model(v) {
setWidgetValue(ckptNode, 'ckpt_name', v, true)
},
vae(v) {},
vae() {},
'cfg scale'(v) {
setWidgetValue(samplerNode, 'cfg', +v)
},

View File

@@ -92,7 +92,7 @@ export function $el<TTag extends string>(
return element as ElementType<TTag>
}
function dragElement(dragEl, settings): () => void {
function dragElement(dragEl): () => void {
var posDiffX = 0,
posDiffY = 0,
posStartX = 0,
@@ -640,7 +640,7 @@ export class ComfyUI {
// Hide by default on construction so it does not interfere with other views.
this.menuContainer.style.display = 'none'
this.restoreMenuPosition = dragElement(this.menuContainer, this.settings)
this.restoreMenuPosition = dragElement(this.menuContainer)
// @ts-expect-error
this.setStatus({ exec_info: { queue_remaining: 'X' } })

View File

@@ -287,7 +287,7 @@ export class DraggableList extends EventTarget {
}
unsetItemState() {
this.getIdleItems().forEach((item, i) => {
this.getIdleItems().forEach((item) => {
delete item.dataset.isAbove
delete item.dataset.isToggled
item.style.transform = ''

View File

@@ -74,7 +74,7 @@ export function addValueControlWidget(
node: LGraphNode,
targetWidget: IWidget,
defaultValue?: string,
values?: unknown,
_values?: unknown,
widgetName?: string,
inputData?: InputSpec
): IWidget {

View File

@@ -306,7 +306,7 @@ export const useLitegraphService = () => {
options.push({
content: 'Bypass',
callback: (obj) => {
callback: () => {
const mode =
this.mode === LGraphEventMode.BYPASS
? LGraphEventMode.ALWAYS
@@ -322,7 +322,7 @@ export const useLitegraphService = () => {
if (!ComfyApp.clipspace_return_node) {
options.push({
content: 'Copy (Clipspace)',
callback: (obj) => {
callback: () => {
ComfyApp.copyToClipspace(this)
}
})
@@ -339,7 +339,7 @@ export const useLitegraphService = () => {
if (isImageNode(this)) {
options.push({
content: 'Open in MaskEditor',
callback: (obj) => {
callback: () => {
ComfyApp.copyToClipspace(this)
ComfyApp.clipspace_return_node = this
ComfyApp.open_maskeditor()
@@ -361,19 +361,13 @@ export const useLitegraphService = () => {
/**
* @deprecated No longer needed as we use {@link useImagePreviewWidget}
*/
node.prototype.setSizeForImage = function (
this: LGraphNode,
force: boolean
) {
node.prototype.setSizeForImage = function (this: LGraphNode) {
console.warn(
'node.setSizeForImage is deprecated. Now it has no effect. Please remove the call to it.'
)
}
function unsafeDrawBackground(
this: LGraphNode,
ctx: CanvasRenderingContext2D
) {
function unsafeDrawBackground(this: LGraphNode) {
if (this.flags.collapsed) return
const nodeOutputStore = useNodeOutputStore()
@@ -418,9 +412,9 @@ export const useLitegraphService = () => {
}
}
node.prototype.onDrawBackground = function (ctx) {
node.prototype.onDrawBackground = function () {
try {
unsafeDrawBackground.call(this, ctx)
unsafeDrawBackground.call(this)
} catch (error) {
console.error('Error drawing node background', error)
}

View File

@@ -6,8 +6,7 @@ import type {
ExecutingWsMessage,
ExecutionCachedWsMessage,
ExecutionStartWsMessage,
ProgressWsMessage,
StatusWsMessage
ProgressWsMessage
} from '@/schemas/apiSchema'
import type {
ComfyNode,
@@ -149,7 +148,7 @@ export const useExecutionStore = defineStore('execution', () => {
_executingNodeProgress.value = e.detail
}
function handleStatus(e: CustomEvent<StatusWsMessage>) {
function handleStatus() {
if (api.clientId) {
clientId.value = api.clientId

View File

@@ -80,7 +80,7 @@ describe('colorUtil - adjustColor', () => {
})
}
describe.each(Object.entries(colors))('%s color', (colorName, color) => {
describe.each(Object.entries(colors))('%s color', (_colorName, color) => {
describe.each(formats)('%s format', (format) => {
runAdjustColorTests(color, format as ColorFormat)
})

View File

@@ -22,7 +22,7 @@ describe('useCachedRequest', () => {
)
// Create a mock request function that returns different results based on params
mockRequestFn = vi.fn(async (params: any, signal?: AbortSignal) => {
mockRequestFn = vi.fn(async (params: any) => {
// Simulate a request that takes some time
await new Promise((resolve) => setTimeout(resolve, 8))

View File

@@ -16,7 +16,7 @@
/* Linting */
"strict": false,
"noUnusedLocals": true,
"noUnusedParameters": false,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"downlevelIteration": true,