From a971fc7f2963d382823bf8c97b4ad3bb9cd3b7c7 Mon Sep 17 00:00:00 2001 From: fengkx Date: Sat, 14 Sep 2024 14:58:33 +0800 Subject: [PATCH] fix: linter (#1733) --- .eslintrc.js | 15 ++++++++++++++- source/knexfile.ts | 3 ++- source/middlewares/sub-multi-url.ts | 4 +++- source/utils/feed.ts | 4 ++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 811c741ab6b..fc20abbf1fe 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -28,6 +28,19 @@ module.exports = { '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/no-explicit-any': 'off', - '@typescript-eslint/ban-ts-comment': 'warn' + '@typescript-eslint/ban-ts-comment': 'warn', + '@typescript-eslint/no-unused-expressions': 'off', + '@typescript-eslint/no-unused-vars': [ + 'error', + { + args: 'all', + argsIgnorePattern: '^_', + caughtErrors: 'all', + caughtErrorsIgnorePattern: '^_', + destructuredArrayIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true + } + ] } }; diff --git a/source/knexfile.ts b/source/knexfile.ts index cb34e32780e..7e7299391ff 100644 --- a/source/knexfile.ts +++ b/source/knexfile.ts @@ -1,8 +1,9 @@ /* eslint @typescript-eslint/explicit-module-boundary-types: 0 */ try { + // eslint-disable-next-line @typescript-eslint/no-require-imports const pg = require('pg'); pg.types.setTypeParser(20, 'text', parseInt); -} catch (err) { +} catch (_err) { logger.info('There is no pg'); } import { config } from './config'; diff --git a/source/middlewares/sub-multi-url.ts b/source/middlewares/sub-multi-url.ts index eae7a05c224..fa17b2be8ec 100644 --- a/source/middlewares/sub-multi-url.ts +++ b/source/middlewares/sub-multi-url.ts @@ -33,7 +33,9 @@ export default async ( ttl: Number.isNaN(rssFeed.ttl) ? 0 : rssFeed.ttl }; } catch (e) { - ctx.reply(`${url} ${i18n[lang]['FETCH_ERROR']}`); + ctx.reply( + `${url} ${i18n[lang]['FETCH_ERROR']} ${e.message}` + ); return undefined; } } diff --git a/source/utils/feed.ts b/source/utils/feed.ts index 7bb61cf4167..fcfa2d89b08 100644 --- a/source/utils/feed.ts +++ b/source/utils/feed.ts @@ -7,7 +7,7 @@ export async function isFeedValid(feedStr: string): Promise> { try { const feed = await parseString(feedStr); return Optional(feed); - } catch (e) { + } catch (_e) { return none; } } @@ -27,7 +27,7 @@ export async function findFeed( const url = linkTag.match(/href="(.+?)"/)[1]; try { return new URL(url).toString(); - } catch (e) { + } catch (_e) { reqURL.pathname = url; return reqURL.toString(); }