Explorar o código

apply noConsole rule

Yuki Takei hai 2 meses
pai
achega
1b0cc95bd7

+ 1 - 1
apps/app/bin/openapi/generate-operation-ids/cli.spec.ts

@@ -90,7 +90,7 @@ describe('cli', () => {
     await cliModule.main();
 
     // Verify error was logged
-    // eslint-disable-next-line no-console
+    // biome-ignore lint/suspicious/noConsole: This is a test file
     expect(console.error).toHaveBeenCalledWith(error);
 
     // Verify writeFileSync was not called

+ 1 - 1
apps/app/bin/openapi/generate-operation-ids/cli.ts

@@ -16,9 +16,9 @@ export const main = async (): Promise<void> => {
   const { out: outputFile, overwriteExisting } = program.opts();
   const [inputFile] = program.args;
 
-  // eslint-disable-next-line no-console
   const jsonStrings = await generateOperationIds(inputFile, {
     overwriteExisting,
+    // biome-ignore lint/suspicious/noConsole: Allow to dump errors
   }).catch(console.error);
   if (jsonStrings != null) {
     writeFileSync(outputFile ?? inputFile, jsonStrings);

+ 1 - 1
apps/app/bin/openapi/generate-operation-ids/generate-operation-ids.spec.ts

@@ -18,7 +18,7 @@ async function cleanup(filePath: string): Promise<void> {
     await fs.unlink(filePath);
     await fs.rmdir(path.dirname(filePath));
   } catch (err) {
-    // eslint-disable-next-line no-console
+    // biome-ignore lint/suspicious/noConsole: This is a test file
     console.error('Cleanup failed:', err);
   }
 }

+ 2 - 0
apps/app/bin/print-memory-consumption.ts

@@ -11,6 +11,8 @@
  *        print-memory-consumption.ts [--port=9229] [--host=localhost] [--json]
  */
 
+/** biome-ignore-all lint/suspicious/noConsole: Allow printing to console */
+
 import { get } from 'node:http';
 import WebSocket from 'ws';
 

+ 6 - 4
apps/app/src/components/utils/use-lazy-loader.ts

@@ -1,6 +1,10 @@
 import type React from 'react';
 import { useCallback, useEffect, useState } from 'react';
 
+import loggerFactory from '~/utils/logger';
+
+const logger = loggerFactory('growi:components:utils:use-lazy-loader');
+
 type ComponentModule<T> = { default: React.ComponentType<T> };
 
 // Global cache for dynamically loaded components
@@ -68,15 +72,13 @@ export const useLazyLoader = <T extends Record<string, unknown>>(
           if (mod?.default) {
             setComponent(() => mod.default);
           } else {
-            // eslint-disable-next-line no-console
-            console.error(
+            logger.error(
               `Failed to load component with key "${importKey}": Module or default export is missing`,
             );
           }
         })
         .catch((error) => {
-          // eslint-disable-next-line no-console
-          console.error(
+          logger.error(
             `Failed to load component with key "${importKey}":`,
             error,
           );

+ 2 - 2
apps/app/src/features/openai/client/services/editor-assistant/error-handling.ts

@@ -187,11 +187,11 @@ export class ClientErrorHandler {
       suggestions: error.details.suggestions?.length || 0,
     };
 
-    // eslint-disable-next-line no-console
+    // biome-ignore lint/suspicious/noConsole: Allow logging
     console.warn('[ClientErrorHandler]', logData);
 
     if (originalError) {
-      // eslint-disable-next-line no-console
+      // biome-ignore lint/suspicious/noConsole: Allow logging
       console.error('[ClientErrorHandler] Original error:', originalError);
     }
   }

+ 8 - 4
apps/app/src/features/openai/client/services/editor-assistant/fuzzy-matching.ts

@@ -6,9 +6,15 @@
 
 import { distance } from 'fastest-levenshtein';
 
+import loggerFactory from '~/utils/logger';
+
 import type { MatchResult, SearchContext } from '../../interfaces/types';
 import { normalizeForBrowserFuzzyMatch } from './text-normalization';
 
+const logger = loggerFactory(
+  'growi:features:openai:client:services:editor-assistant:fuzzy-matching',
+);
+
 // -----------------------------------------------------------------------------
 // Browser-Optimized Similarity Calculation
 // -----------------------------------------------------------------------------
@@ -302,8 +308,7 @@ export class ClientFuzzyMatcher {
     while (leftIndex >= startIndex || rightIndex <= actualEndIndex) {
       // Browser timeout protection
       if (performance.now() - startTime > this.maxSearchTime) {
-        // eslint-disable-next-line no-console
-        console.warn('Fuzzy matching timeout, returning best result found');
+        logger.warn('Fuzzy matching timeout, returning best result found');
         break;
       }
 
@@ -490,8 +495,7 @@ export function measurePerformance<T>(
   const duration = performance.now() - start;
 
   if (duration > 100) {
-    // eslint-disable-next-line no-console
-    console.warn(`${label} took ${duration.toFixed(2)}ms (slow)`);
+    logger.warn(`${label} took ${duration.toFixed(2)}ms (slow)`);
   }
 
   return { result, duration };

+ 2 - 2
apps/app/src/features/openai/client/services/editor-assistant/processor.ts

@@ -401,14 +401,14 @@ export class ClientSearchReplaceProcessor {
       diffsPerSecond: Math.round((totalDiffs / totalTime) * 1000),
     };
 
-    // eslint-disable-next-line no-console
+    // biome-ignore lint/suspicious/noConsole: Allow logging
     console.info(
       '[ClientSearchReplaceProcessor] Performance metrics:',
       metrics,
     );
 
     if (totalTime > 5000) {
-      // eslint-disable-next-line no-console
+      // biome-ignore lint/suspicious/noConsole: Allow warn
       console.warn(
         '[ClientSearchReplaceProcessor] Slow processing detected:',
         metrics,

+ 1 - 1
apps/app/src/features/openai/client/services/editor-assistant/text-normalization.ts

@@ -233,7 +233,7 @@ export function measureNormalization<T>(
 
   // Log slow normalizations for optimization
   if (duration > 10) {
-    // eslint-disable-next-line no-console
+    // biome-ignore lint/suspicious/noConsole: Allow warn
     console.warn(
       `${label} took ${duration.toFixed(2)}ms for ${text.length} characters`,
     );

+ 2 - 1
apps/app/src/server/crowi/dev.js

@@ -23,7 +23,8 @@ class CrowiDev {
 
   initPromiseRejectionWarningHandler() {
     // https://qiita.com/syuilo/items/0800d7e44e93203c7285
-    process.on('unhandledRejection', console.dir); // eslint-disable-line no-console
+    // biome-ignore lint:plugin: Allow to use
+    process.on('unhandledRejection', console.dir);
   }
 
   /**

+ 1 - 1
apps/app/test-with-vite/setup/mongoms.ts

@@ -18,7 +18,7 @@ beforeAll(async () => {
     },
   });
 
-  // eslint-disable-next-line no-console
+  // biome-ignore lint/suspicious/noConsole: Allow logging
   console.log(`MongoMemoryServer is running on ${mongoServer.getUri()}`);
 
   await mongoose.connect(mongoServer.getUri(), mongoOptions);

+ 3 - 0
biome.json

@@ -60,6 +60,9 @@
     "enabled": true,
     "rules": {
       "recommended": true,
+      "suspicious": {
+        "noConsole": "error"
+      },
       "correctness": {
         "useUniqueElementIds": "warn"
       }

+ 1 - 1
packages/editor/src/client/components-internal/playground/Playground.tsx

@@ -48,7 +48,7 @@ export const Playground = (): JSX.Element => {
 
   // set handler to save with shortcut key
   const saveHandler = useCallback(() => {
-    // eslint-disable-next-line no-console
+    // biome-ignore lint/suspicious/noConsole: Allow to use
     console.log({ doc: codeMirrorEditor?.getDocString() });
     toast.success('Saved.', { autoClose: 2000 });
   }, [codeMirrorEditor]);

+ 3 - 3
packages/editor/src/client/components-internal/playground/states/socket.ts

@@ -31,18 +31,18 @@ export const useSetupPlaygroundSocket = (): void => {
 
       // Error handling
       newSocket.on('error', (err) => {
-        // eslint-disable-next-line no-console
+        // biome-ignore lint/suspicious/noConsole: Allow to use
         console.error(err);
       });
       newSocket.on('connect_error', (err) => {
-        // eslint-disable-next-line no-console
+        // biome-ignore lint/suspicious/noConsole: Allow to use
         console.error('Failed to connect with websocket.', err);
       });
 
       // Store connection in atom
       setSocket(newSocket);
     } catch (error) {
-      // eslint-disable-next-line no-console
+      // biome-ignore lint/suspicious/noConsole: Allow to use
       console.error('Failed to initialize WebSocket:', error);
     }
   }, [setSocket]);

+ 2 - 2
packages/editor/src/client/services/use-codemirror-editor/utils/fold-drawio.ts

@@ -24,7 +24,7 @@ const findAllDrawioSection = (view?: EditorView) => {
     return lineNumbers;
   } catch (err) {
     if (err instanceof Error) {
-      // eslint-disable-next-line no-console
+      // biome-ignore lint/suspicious/noConsole: Allow to use
       console.warn(err.toString());
     }
   }
@@ -50,7 +50,7 @@ const foldDrawioSection = (lineNumbers?: number[], view?: EditorView) => {
     });
   } catch (err) {
     if (err instanceof Error) {
-      // eslint-disable-next-line no-console
+      // biome-ignore lint/suspicious/noConsole: Allow to use
       console.warn(err.toString());
     }
   }

+ 2 - 2
packages/editor/vite.config.ts

@@ -23,11 +23,11 @@ const devSocketIOPlugin = (): Plugin => ({
     // setup socket.io
     const io = new Server(server.httpServer);
     io.on('connection', (socket) => {
-      // eslint-disable-next-line no-console
+      // biome-ignore lint/suspicious/noConsole: Allow to use
       console.log('Client connected');
 
       socket.on('disconnect', () => {
-        // eslint-disable-next-line no-console
+        // biome-ignore lint/suspicious/noConsole: Allow to use
         console.log('Client disconnected');
       });
     });

+ 1 - 1
packages/pluginkit/src/v4/server/utils/template/scan.ts

@@ -57,7 +57,7 @@ export const scanTemplate = async (
     }
   }
 
-  // eslint-disable-next-line no-console
+  // biome-ignore lint/suspicious/noConsole: Allow to use
   console.debug(`Template directory (${projectDirRoot}) has scanned`, {
     status,
   });

+ 1 - 1
packages/pluginkit/src/v4/server/utils/template/validate-all-locales.ts

@@ -28,7 +28,7 @@ export const validateAllTemplateLocales = async (
   for (const [id, validMap] of Object.entries(idValidMap)) {
     // warn
     if (!validMap.every((bool) => bool)) {
-      // eslint-disable-next-line no-console
+      // biome-ignore lint/suspicious/noConsole: Allow to use
       console.warn(
         `[WARN] Template '${id}' has some locales that status is invalid`,
       );