From ee04e6d8eab6794bb75e81cdf7333971e101dd3c Mon Sep 17 00:00:00 2001 From: Alexander Alemayhu Date: Thu, 17 Oct 2024 04:37:45 +0200 Subject: [PATCH] fix: get the new eslint rules working --- .eslintrc.js | 4 +++- src/controllers/FavoritesController.ts | 1 + src/lib/isStaging.ts | 3 --- src/lib/parser/DeckParser.ts | 4 +++- src/lib/parser/ParserRules.ts | 1 + src/lib/storage/types.ts | 2 ++ src/server.ts | 5 +---- .../blocks/media/BlockBookmark/hooks/useMetadata.ts | 1 + 8 files changed, 12 insertions(+), 9 deletions(-) delete mode 100644 src/lib/isStaging.ts diff --git a/.eslintrc.js b/.eslintrc.js index d38321c49..359d8312c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,6 +15,8 @@ module.exports = { 'react/jsx-filename-extension': 'off', 'prettier/prettier': ['error'], 'require-await': 'error', + '@typescript-eslint/lines-between-class-members': 'off', + '@typescript-eslint/no-throw-literal': 'off', }, - "ignorePatterns": ["src/data_layer/public/", "migrations", "*.test.*"], + ignorePatterns: ['src/data_layer/public/', 'migrations', '*.test.*'], }; diff --git a/src/controllers/FavoritesController.ts b/src/controllers/FavoritesController.ts index fc2a3298e..2902b9d7d 100644 --- a/src/controllers/FavoritesController.ts +++ b/src/controllers/FavoritesController.ts @@ -49,6 +49,7 @@ class FavoritesController { ); res.json(favorites); } catch (error) { + console.error(error); res.json([]); } } diff --git a/src/lib/isStaging.ts b/src/lib/isStaging.ts deleted file mode 100644 index 1ae0a46c6..000000000 --- a/src/lib/isStaging.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const isStaging = () => { - return process.env.SPACES_DEFAULT_BUCKET_NAME === 'dev.2anki.net'; -}; diff --git a/src/lib/parser/DeckParser.ts b/src/lib/parser/DeckParser.ts index b9425cc3c..3fd58b789 100644 --- a/src/lib/parser/DeckParser.ts +++ b/src/lib/parser/DeckParser.ts @@ -182,7 +182,8 @@ export class DeckParser { try { const firstHeading = dom('h1').first(); return firstHeading.text(); - } catch (_e) { + } catch (e) { + console.error(e); return undefined; } } @@ -305,6 +306,7 @@ export class DeckParser { } return ma; } catch (error) { + console.error(error); return null; } }); diff --git a/src/lib/parser/ParserRules.ts b/src/lib/parser/ParserRules.ts index ce59a512d..8ee28ae22 100644 --- a/src/lib/parser/ParserRules.ts +++ b/src/lib/parser/ParserRules.ts @@ -54,6 +54,7 @@ class ParserRules { rules.EMAIL_NOTIFICATION = result.email_notification; return rules; } catch (error) { + console.error(error); return new ParserRules(); } } diff --git a/src/lib/storage/types.ts b/src/lib/storage/types.ts index 9cefa393d..2810cbfff 100644 --- a/src/lib/storage/types.ts +++ b/src/lib/storage/types.ts @@ -53,6 +53,7 @@ export function isFileNameEqual(file: File, name: string) { return true; } } catch (error) { + console.error(error); console.debug('Failed to decode name'); } @@ -62,6 +63,7 @@ export function isFileNameEqual(file: File, name: string) { return decodedFilename === decodedName; } catch (error) { + console.error(error); console.debug('Failed to decode names'); } diff --git a/src/server.ts b/src/server.ts index 6fd9f0b6f..6bfc42252 100644 --- a/src/server.ts +++ b/src/server.ts @@ -31,7 +31,6 @@ import webhookRouter from './routes/WebhookRouter'; import { sendError } from './lib/error/sendError'; -import { isStaging } from './lib/isStaging'; import { getDatabase, setupDatabase } from './data_layer'; function registerSignalHandlers(server: http.Server) { @@ -57,9 +56,7 @@ const serve = async () => { app.use(express.json({ limit: '1000mb' }) as RequestHandler); app.use(cookieParser()); - if (isStaging()) { - app.use(morgan('combined') as RequestHandler); - } + app.use(morgan('combined') as RequestHandler); app.use('/templates', express.static(templateDir)); app.use(express.static(BUILD_DIR)); diff --git a/src/services/NotionService/blocks/media/BlockBookmark/hooks/useMetadata.ts b/src/services/NotionService/blocks/media/BlockBookmark/hooks/useMetadata.ts index d2a1a6827..ea83348a7 100644 --- a/src/services/NotionService/blocks/media/BlockBookmark/hooks/useMetadata.ts +++ b/src/services/NotionService/blocks/media/BlockBookmark/hooks/useMetadata.ts @@ -20,6 +20,7 @@ export default async function useMetadata(url: string): Promise { const response = await axios.get(url); return metascraper({ html: response.data, url }); } catch (error) { + console.error(error); return { description: '', title: new URL(url).hostname,