From 790bcdbd78aed7c366ea3940f389e9071f1ad45d Mon Sep 17 00:00:00 2001 From: dangered wolf Date: Mon, 8 Aug 2022 15:15:15 -0400 Subject: [PATCH] Run prettier --- .eslintrc | 7 ++----- README.md | 2 +- src/api.ts | 2 +- src/env.d.ts | 2 +- src/server.ts | 38 +++++++++++++++++++++----------------- src/utils.ts | 2 +- webpack.config.js | 22 ++++++++++++---------- 7 files changed, 39 insertions(+), 36 deletions(-) diff --git a/.eslintrc b/.eslintrc index d009afd..0069abb 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,11 +6,8 @@ "plugin:optimize-regex/recommended", "plugin:sonarjs/recommended" ], - "plugins": [ - "eslint-plugin-optimize-regex", - "sonarjs" - ], + "plugins": ["eslint-plugin-optimize-regex", "sonarjs"], "rules": { "sonarjs/cognitive-complexity": ["warn", 20] } -} \ No newline at end of file +} diff --git a/README.md b/README.md index 228cef9..6792fb1 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ In many ways, FixTweet has richer embeds and does more. Here's a table comparing ⁴ On GitHub, BetterTwitFix (vxTwitter) claims to support this feature, however in my testing as of mid-July 2022, this does not seem to work. -⁵ We've temporarily paused multi-image on Telegram due to issues with its embedding service that can cause images to sometimes not show up at all. ([#15](https://github.com/dangeredwolf/FixTweet/issues/15)) However, multi-image continues to work in Discord and most other platforms. +⁵ We've temporarily paused multi-image on Telegram due to issues with its embedding service that can cause images to sometimes not show up at all. ([#15](https://github.com/dangeredwolf/FixTweet/issues/15)) However, multi-image continues to work in Discord and most other platforms. ⁶ External media requiring web containers, such as YouTube, won't embed in Telegram because Telegram doesn't support it. Plain media will work in Telegram, and it works either way inside Discord. diff --git a/src/api.ts b/src/api.ts index 98bea6e..65d0b0c 100644 --- a/src/api.ts +++ b/src/api.ts @@ -134,7 +134,7 @@ const populateTweetProperties = async ( text: unescapeText(linkFixer(tweet, translateAPI?.translation || '')), source_lang: translateAPI?.sourceLanguage || '', target_lang: translateAPI?.destinationLanguage || '', - source_lang_en: translateAPI?.localizedSourceLanguage || '', + source_lang_en: translateAPI?.localizedSourceLanguage || '' }; } } diff --git a/src/env.d.ts b/src/env.d.ts index 02f2594..7650e6f 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -7,4 +7,4 @@ declare const MOSAIC_DOMAIN_LIST: string; declare const API_HOST: string; declare const SENTRY_DSN: string; -declare const RELEASE_NAME: string; \ No newline at end of file +declare const RELEASE_NAME: string; diff --git a/src/server.ts b/src/server.ts index ab7f496..d9dece5 100644 --- a/src/server.ts +++ b/src/server.ts @@ -17,7 +17,9 @@ const statusRequest = async ( const userAgent = request.headers.get('User-Agent') || ''; const isBotUA = - userAgent.match(/bot|facebook|embed|got|firefox\/92|curl|wget|go-http|yahoo|generator|whatsapp|preview|link|proxy|vkshare|images|analyzer|index|crawl|spider/gi) !== null; + userAgent.match( + /bot|facebook|embed|got|firefox\/92|curl|wget|go-http|yahoo|generator|whatsapp|preview|link|proxy|vkshare|images|analyzer|index|crawl|spider/gi + ) !== null; if ( url.pathname.match(/\/status(es)?\/\d+\.(mp4|png|jpg)/g) !== null || @@ -234,23 +236,25 @@ const sentryWrapper = async (event: FetchEvent): Promise => { }); } - event.respondWith((async (): Promise => { - try { - return await cacheWrapper(event) - } catch(err: unknown) { - sentry && sentry.captureException(err); + event.respondWith( + (async (): Promise => { + try { + return await cacheWrapper(event); + } catch (err: unknown) { + sentry && sentry.captureException(err); - return new Response(Strings.ERROR_HTML, { - headers: { - ...Constants.RESPONSE_HEADERS, - 'content-type': 'text/html', - 'cache-control': 'max-age=1' - }, - status: 500 - }); - } - })()) -} + return new Response(Strings.ERROR_HTML, { + headers: { + ...Constants.RESPONSE_HEADERS, + 'content-type': 'text/html', + 'cache-control': 'max-age=1' + }, + status: 500 + }); + } + })() + ); +}; /* Event to receive web requests on Cloudflare Worker diff --git a/src/utils.ts b/src/utils.ts index 7a4b7d5..3fae465 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -13,4 +13,4 @@ export const unescapeText = (text: string) => { .replace(/</g, '<') .replace(/>/g, '>') .replace(/&/g, '&'); -} \ No newline at end of file +}; diff --git a/webpack.config.js b/webpack.config.js index 7c605a5..df3b6b5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,15 +3,17 @@ const webpack = require('webpack'); const SentryWebpackPlugin = require('@sentry/webpack-plugin'); const gitCommit = require('child_process') - .execSync('git rev-parse --short HEAD') - .toString() - .trim(); + .execSync('git rev-parse --short HEAD') + .toString() + .trim(); const gitBranch = require('child_process') - .execSync('git rev-parse --abbrev-ref HEAD') - .toString() - .trim(); + .execSync('git rev-parse --abbrev-ref HEAD') + .toString() + .trim(); -const releaseName = `fixtweet-${gitBranch}-${gitCommit}-${new Date().toISOString().substring(0,19)}` +const releaseName = `fixtweet-${gitBranch}-${gitCommit}-${new Date() + .toISOString() + .substring(0, 19)}`; require('dotenv').config(); @@ -43,7 +45,7 @@ let plugins = [ new webpack.DefinePlugin({ RELEASE_NAME: `'${releaseName}'` }) -] +]; if (process.env.SENTRY_AUTH_TOKEN) { plugins.push( @@ -52,9 +54,9 @@ if (process.env.SENTRY_AUTH_TOKEN) { include: './dist', urlPrefix: '~/', ignore: ['node_modules', 'webpack.config.js'], - authToken: process.env.SENTRY_AUTH_TOKEN, + authToken: process.env.SENTRY_AUTH_TOKEN }) - ) + ); } module.exports = {