From 76e181fd4488976e58691d1529639f8580d209bb Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 13 May 2024 15:12:43 +1000 Subject: [PATCH] build(ui): add eslint `no-console` rule --- invokeai/frontend/web/.eslintrc.js | 2 ++ invokeai/frontend/web/scripts/typegen.js | 1 + invokeai/frontend/web/src/app/hooks/useSocketIO.ts | 4 ++++ .../web/src/app/store/middleware/debugLoggerMiddleware.ts | 3 +++ .../listeners/controlAdapterPreprocessor.ts | 1 - 5 files changed, 10 insertions(+), 1 deletion(-) diff --git a/invokeai/frontend/web/.eslintrc.js b/invokeai/frontend/web/.eslintrc.js index 18a6e3a9b9..519e725fb4 100644 --- a/invokeai/frontend/web/.eslintrc.js +++ b/invokeai/frontend/web/.eslintrc.js @@ -10,6 +10,8 @@ module.exports = { 'path/no-relative-imports': ['error', { maxDepth: 0 }], // https://github.com/edvardchen/eslint-plugin-i18next/blob/HEAD/docs/rules/no-literal-string.md 'i18next/no-literal-string': 'error', + // https://eslint.org/docs/latest/rules/no-console + 'no-console': 'error', }, overrides: [ /** diff --git a/invokeai/frontend/web/scripts/typegen.js b/invokeai/frontend/web/scripts/typegen.js index 758a0ef4f5..fa2d791350 100644 --- a/invokeai/frontend/web/scripts/typegen.js +++ b/invokeai/frontend/web/scripts/typegen.js @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import fs from 'node:fs'; import openapiTS from 'openapi-typescript'; diff --git a/invokeai/frontend/web/src/app/hooks/useSocketIO.ts b/invokeai/frontend/web/src/app/hooks/useSocketIO.ts index e1c4cebdb9..aaa3b8f6f2 100644 --- a/invokeai/frontend/web/src/app/hooks/useSocketIO.ts +++ b/invokeai/frontend/web/src/app/hooks/useSocketIO.ts @@ -67,6 +67,8 @@ export const useSocketIO = () => { if ($isDebugging.get() || import.meta.env.MODE === 'development') { window.$socketOptions = $socketOptions; + // This is only enabled manually for debugging, console is allowed. + /* eslint-disable-next-line no-console */ console.log('Socket initialized', socket); } @@ -75,6 +77,8 @@ export const useSocketIO = () => { return () => { if ($isDebugging.get() || import.meta.env.MODE === 'development') { window.$socketOptions = undefined; + // This is only enabled manually for debugging, console is allowed. + /* eslint-disable-next-line no-console */ console.log('Socket teardown', socket); } socket.disconnect(); diff --git a/invokeai/frontend/web/src/app/store/middleware/debugLoggerMiddleware.ts b/invokeai/frontend/web/src/app/store/middleware/debugLoggerMiddleware.ts index b6df6dab94..89010275d1 100644 --- a/invokeai/frontend/web/src/app/store/middleware/debugLoggerMiddleware.ts +++ b/invokeai/frontend/web/src/app/store/middleware/debugLoggerMiddleware.ts @@ -1,3 +1,6 @@ +/* eslint-disable no-console */ +// This is only enabled manually for debugging, console is allowed. + import type { Middleware, MiddlewareAPI } from '@reduxjs/toolkit'; import { diff } from 'jsondiffpatch'; diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlAdapterPreprocessor.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlAdapterPreprocessor.ts index a1f7ebcca1..2a59cc0317 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlAdapterPreprocessor.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/controlAdapterPreprocessor.ts @@ -148,7 +148,6 @@ export const addControlAdapterPreprocessor = (startAppListening: AppStartListeni log.trace('Control Adapter preprocessor cancelled'); } else { // Some other error condition... - console.log(error); log.error({ enqueueBatchArg: parseify(enqueueBatchArg) }, t('queue.graphFailedToQueue')); if (error instanceof Object) {