Skip to content

Commit 918efb0

Browse files
Myesterychristian-byrne
authored andcommitted
Prune console.log() (#5867)
Introduce a no-console rule in ESLint configuration and remove existing console log statements throughout the codebase, replacing some with warnings or comments. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-5867-Prune-console-log-27e6d73d365081bcbad8c36cfb5b258c) by [Unito](https://www.unito.io)
1 parent 0fe17d6 commit 918efb0

File tree

28 files changed

+61
-140
lines changed

28 files changed

+61
-140
lines changed

eslint.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export default defineConfig([
9090
}
9191
],
9292
'unused-imports/no-unused-imports': 'error',
93+
'no-console': ['error', { allow: ['warn', 'error'] }],
9394
'vue/no-v-html': 'off',
9495
// Enforce dark-theme: instead of dark: prefix
9596
'vue/no-restricted-class': ['error', '/^dark:/'],
@@ -207,5 +208,11 @@ export default defineConfig([
207208
}
208209
]
209210
}
211+
},
212+
{
213+
files: ['**/*.{test,spec,stories}.ts', '**/*.stories.vue'],
214+
rules: {
215+
'no-console': 'off'
216+
}
210217
}
211218
])

src/App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const showContextMenu = (event: MouseEvent) => {
4444
onMounted(() => {
4545
// @ts-expect-error fixme ts strict error
4646
window['__COMFYUI_FRONTEND_VERSION__'] = config.app_version
47-
console.log('ComfyUI Front-end version:', config.app_version)
4847
4948
if (isElectron()) {
5049
document.addEventListener('contextmenu', showContextMenu)

src/components/widget/SampleModelSelector.vue

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
</template>
128128

129129
<script setup lang="ts">
130-
import { computed, provide, ref, watch } from 'vue'
130+
import { computed, provide, ref } from 'vue'
131131
import { useI18n } from 'vue-i18n'
132132
133133
import IconButton from '@/components/button/IconButton.vue'
@@ -202,12 +202,4 @@ const selectedSort = ref<string>('popular')
202202
const selectedNavItem = ref<string | null>('installed')
203203
204204
const gridStyle = computed(() => createGridStyle())
205-
206-
watch(searchText, (newQuery) => {
207-
console.log('searchText:', searchText.value, newQuery)
208-
})
209-
210-
watch(searchQuery, (newQuery) => {
211-
console.log('searchQuery:', searchQuery.value, newQuery)
212-
})
213205
</script>

src/components/widget/layout/BaseModalLayout.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const createStoryTemplate = (args: StoryArgs) => ({
8686
const t = (k: string) => k
8787

8888
const onClose = () => {
89-
console.log('OnClose invoked')
89+
// OnClose handler for story
9090
}
9191
provide(OnCloseKey, onClose)
9292

src/composables/node/useNodePricing.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,6 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
300300
const modeValue = String(modeWidget.value)
301301
const durationValue = String(durationWidget.value)
302302
const modelValue = String(modelWidget.value)
303-
console.log('modelValue', modelValue)
304-
console.log('modeValue', modeValue)
305-
console.log('durationValue', durationValue)
306303

307304
// Same pricing matrix as KlingTextToVideoNode
308305
if (modelValue.includes('v1-6') || modelValue.includes('v1-5')) {
@@ -356,9 +353,6 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
356353
const modeValue = String(modeWidget.value)
357354
const durationValue = String(durationWidget.value)
358355
const modelValue = String(modelWidget.value)
359-
console.log('modelValue', modelValue)
360-
console.log('modeValue', modeValue)
361-
console.log('durationValue', durationValue)
362356

363357
// Same pricing matrix as KlingTextToVideoNode
364358
if (
@@ -564,9 +558,6 @@ const apiNodeCosts: Record<string, { displayPrice: string | PricingFunction }> =
564558
const model = String(modelWidget.value)
565559
const resolution = String(resolutionWidget.value).toLowerCase()
566560
const duration = String(durationWidget.value)
567-
console.log('model', model)
568-
console.log('resolution', resolution)
569-
console.log('duration', duration)
570561

571562
if (model.includes('ray-flash-2')) {
572563
if (duration.includes('5s')) {

src/lib/litegraph/src/LGraph.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ export class LGraph
274274
* @param o data from previous serialization [optional]
275275
*/
276276
constructor(o?: ISerialisedGraph | SerialisableGraph) {
277-
if (LiteGraph.debug) console.log('Graph created')
278-
279277
/** @see MapProxyHandler */
280278
const links = this._links
281279
MapProxyHandler.bindAllMethods(links)
@@ -532,7 +530,7 @@ export class LGraph
532530
this.errors_in_execution = true
533531
if (LiteGraph.throw_errors) throw error
534532

535-
if (LiteGraph.debug) console.log('Error during execution:', error)
533+
if (LiteGraph.debug) console.error('Error during execution:', error)
536534
this.stop()
537535
}
538536
}
@@ -1167,7 +1165,7 @@ export class LGraph
11671165
const ctor = LiteGraph.registered_node_types[node.type]
11681166
if (node.constructor == ctor) continue
11691167

1170-
console.log('node being replaced by newer version:', node.type)
1168+
console.warn('node being replaced by newer version:', node.type)
11711169
const newnode = LiteGraph.createNode(node.type)
11721170
if (!newnode) continue
11731171
_nodes[i] = newnode
@@ -1229,9 +1227,6 @@ export class LGraph
12291227

12301228
/* Called when something visually changed (not the graph!) */
12311229
change(): void {
1232-
if (LiteGraph.debug) {
1233-
console.log('Graph changed')
1234-
}
12351230
this.canvasAction((c) => c.setDirty(true, true))
12361231
this.on_change?.(this)
12371232
}
@@ -1626,12 +1621,6 @@ export class LGraph
16261621
} else {
16271622
throw new TypeError('Subgraph input node is not a SubgraphInput')
16281623
}
1629-
console.debug(
1630-
'Reconnect input links in parent graph',
1631-
{ ...link },
1632-
this.links.get(link.id),
1633-
this.links.get(link.id) === link
1634-
)
16351624

16361625
for (const resolved of others) {
16371626
resolved.link.disconnect(this)
@@ -2233,7 +2222,7 @@ export class LGraph
22332222
let node = LiteGraph.createNode(String(n_info.type), n_info.title)
22342223
if (!node) {
22352224
if (LiteGraph.debug)
2236-
console.log('Node not found or has errors:', n_info.type)
2225+
console.warn('Node not found or has errors:', n_info.type)
22372226

22382227
// in case of error we create a replacement node to avoid losing info
22392228
node = new LGraphNode('')

src/lib/litegraph/src/LGraphCanvas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6406,7 +6406,7 @@ export class LGraphCanvas
64066406

64076407
return true
64086408
}
6409-
console.log(`failed creating ${nodeNewType}`)
6409+
console.error(`failed creating ${nodeNewType}`)
64106410
}
64116411
}
64126412
return false

src/lib/litegraph/src/LGraphNode.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,7 @@ export class LGraphNode
19501950
try {
19511951
this.removeWidget(widget)
19521952
} catch (error) {
1953-
console.debug('Failed to remove widget', error)
1953+
console.error('Failed to remove widget', error)
19541954
}
19551955
}
19561956

@@ -2583,12 +2583,7 @@ export class LGraphNode
25832583
if (slotIndex !== undefined)
25842584
return this.connect(slot, target_node, slotIndex, optsIn?.afterRerouteId)
25852585

2586-
console.debug(
2587-
'[connectByType]: no way to connect type:',
2588-
target_slotType,
2589-
'to node:',
2590-
target_node
2591-
)
2586+
// No compatible slot found - connection not possible
25922587
return null
25932588
}
25942589

@@ -2621,7 +2616,7 @@ export class LGraphNode
26212616
if (slotIndex !== undefined)
26222617
return source_node.connect(slotIndex, this, slot, optsIn?.afterRerouteId)
26232618

2624-
console.debug(
2619+
console.error(
26252620
'[connectByType]: no way to connect type:',
26262621
source_slotType,
26272622
'to node:',
@@ -2661,7 +2656,7 @@ export class LGraphNode
26612656
if (!graph) {
26622657
// could be connected before adding it to a graph
26632658
// due to link ids being associated with graphs
2664-
console.log(
2659+
console.error(
26652660
"Connect: Error, node doesn't belong to any graph. Nodes must be added first to a graph before connecting them."
26662661
)
26672662
return null
@@ -2672,11 +2667,12 @@ export class LGraphNode
26722667
slot = this.findOutputSlot(slot)
26732668
if (slot == -1) {
26742669
if (LiteGraph.debug)
2675-
console.log(`Connect: Error, no slot of name ${slot}`)
2670+
console.error(`Connect: Error, no slot of name ${slot}`)
26762671
return null
26772672
}
26782673
} else if (!outputs || slot >= outputs.length) {
2679-
if (LiteGraph.debug) console.log('Connect: Error, slot number not found')
2674+
if (LiteGraph.debug)
2675+
console.error('Connect: Error, slot number not found')
26802676
return null
26812677
}
26822678

@@ -2696,7 +2692,7 @@ export class LGraphNode
26962692
targetIndex = target_node.findInputSlot(target_slot)
26972693
if (targetIndex == -1) {
26982694
if (LiteGraph.debug)
2699-
console.log(`Connect: Error, no slot of name ${targetIndex}`)
2695+
console.error(`Connect: Error, no slot of name ${targetIndex}`)
27002696
return null
27012697
}
27022698
} else if (target_slot === LiteGraph.EVENT) {
@@ -2728,7 +2724,8 @@ export class LGraphNode
27282724
!target_node.inputs ||
27292725
targetIndex >= target_node.inputs.length
27302726
) {
2731-
if (LiteGraph.debug) console.log('Connect: Error, slot number not found')
2727+
if (LiteGraph.debug)
2728+
console.error('Connect: Error, slot number not found')
27322729
return null
27332730
}
27342731

@@ -2955,11 +2952,12 @@ export class LGraphNode
29552952
slot = this.findOutputSlot(slot)
29562953
if (slot == -1) {
29572954
if (LiteGraph.debug)
2958-
console.log(`Connect: Error, no slot of name ${slot}`)
2955+
console.error(`Connect: Error, no slot of name ${slot}`)
29592956
return false
29602957
}
29612958
} else if (!this.outputs || slot >= this.outputs.length) {
2962-
if (LiteGraph.debug) console.log('Connect: Error, slot number not found')
2959+
if (LiteGraph.debug)
2960+
console.error('Connect: Error, slot number not found')
29632961
return false
29642962
}
29652963

@@ -3075,19 +3073,19 @@ export class LGraphNode
30753073
slot = this.findInputSlot(slot)
30763074
if (slot == -1) {
30773075
if (LiteGraph.debug)
3078-
console.log(`Connect: Error, no slot of name ${slot}`)
3076+
console.error(`Connect: Error, no slot of name ${slot}`)
30793077
return false
30803078
}
30813079
} else if (!this.inputs || slot >= this.inputs.length) {
30823080
if (LiteGraph.debug) {
3083-
console.log('Connect: Error, slot number not found')
3081+
console.error('Connect: Error, slot number not found')
30843082
}
30853083
return false
30863084
}
30873085

30883086
const input = this.inputs[slot]
30893087
if (!input) {
3090-
console.debug('disconnectInput: input not found', slot, this.inputs)
3088+
console.error('disconnectInput: input not found', slot, this.inputs)
30913089
return false
30923090
}
30933091

@@ -3116,19 +3114,16 @@ export class LGraphNode
31163114

31173115
const target_node = graph.getNodeById(link_info.origin_id)
31183116
if (!target_node) {
3119-
console.debug(
3120-
'disconnectInput: target node not found',
3121-
link_info.origin_id
3117+
console.error(
3118+
'disconnectInput: output not found',
3119+
link_info.origin_slot
31223120
)
31233121
return false
31243122
}
31253123

31263124
const output = target_node.outputs[link_info.origin_slot]
31273125
if (!output?.links?.length) {
3128-
console.debug(
3129-
'disconnectInput: output not found',
3130-
link_info.origin_slot
3131-
)
3126+
// Output not found - may have been removed
31323127
return false
31333128
}
31343129

src/lib/litegraph/src/LiteGraphGlobal.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,6 @@ export class LiteGraphGlobal {
398398
throw 'Cannot register a simple object, it must be a class with a prototype'
399399
base_class.type = type
400400

401-
if (this.debug) console.log('Node registered:', type)
402-
403401
const classname = base_class.name
404402

405403
const pos = type.lastIndexOf('/')
@@ -415,7 +413,7 @@ export class LiteGraphGlobal {
415413

416414
const prev = this.registered_node_types[type]
417415
if (prev && this.debug) {
418-
console.log('replacing node type:', type)
416+
console.warn('replacing node type:', type)
419417
}
420418

421419
this.registered_node_types[type] = base_class
@@ -524,7 +522,7 @@ export class LiteGraphGlobal {
524522
): LGraphNode | null {
525523
const base_class = this.registered_node_types[type]
526524
if (!base_class) {
527-
if (this.debug) console.log(`GraphNode type "${type}" not registered.`)
525+
if (this.debug) console.warn(`GraphNode type "${type}" not registered.`)
528526
return null
529527
}
530528

@@ -637,19 +635,16 @@ export class LiteGraphGlobal {
637635
continue
638636

639637
try {
640-
if (this.debug) console.log('Reloading:', src)
641638
const dynamicScript = document.createElement('script')
642639
dynamicScript.type = 'text/javascript'
643640
dynamicScript.src = src
644641
docHeadObj.append(dynamicScript)
645642
script_file.remove()
646643
} catch (error) {
647644
if (this.throw_errors) throw error
648-
if (this.debug) console.log('Error while reloading', src)
645+
if (this.debug) console.error('Error while reloading', src)
649646
}
650647
}
651-
652-
if (this.debug) console.log('Nodes reloaded')
653648
}
654649

655650
// separated just to improve if it doesn't work
@@ -749,7 +744,7 @@ export class LiteGraphGlobal {
749744
// convert pointerevents to touch event when not available
750745
if (sMethod == 'pointer' && !window.PointerEvent) {
751746
console.warn("sMethod=='pointer' && !window.PointerEvent")
752-
console.log(
747+
console.warn(
753748
`Converting pointer[${sEvent}] : down move up cancel enter TO touchstart touchmove touchend, etc ..`
754749
)
755750
switch (sEvent) {
@@ -774,7 +769,7 @@ export class LiteGraphGlobal {
774769
break
775770
}
776771
case 'enter': {
777-
console.log('debug: Should I send a move event?') // ???
772+
// TODO: Determine if a move event should be sent
778773
break
779774
}
780775
// case "over": case "out": not used at now

src/lib/litegraph/src/canvas/LinkConnector.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,6 @@ export class LinkConnector {
906906
if (connectingTo === 'output') {
907907
// Dropping new output link
908908
const output = node.findOutputByType(firstLink.fromSlot.type)?.slot
909-
console.debug('out', node, output, firstLink.fromSlot)
910909
if (output === undefined) {
911910
console.warn(
912911
`Could not find slot for link type: [${firstLink.fromSlot.type}].`
@@ -918,7 +917,6 @@ export class LinkConnector {
918917
} else if (connectingTo === 'input') {
919918
// Dropping new input link
920919
const input = node.findInputByType(firstLink.fromSlot.type)?.slot
921-
console.debug('in', node, input, firstLink.fromSlot)
922920
if (input === undefined) {
923921
console.warn(
924922
`Could not find slot for link type: [${firstLink.fromSlot.type}].`

0 commit comments

Comments
 (0)