From e81a4ade974ba8da2602f49c86c6cd7e8a99920f Mon Sep 17 00:00:00 2001 From: Erb3 <49862976+Erb3@users.noreply.github.com> Date: Sat, 28 Sep 2024 03:28:13 +0200 Subject: [PATCH] chore: run lint (#2411) * chore: run lint * chore: fix lint --- apps/app/src/api/ads.rs | 6 +- .../frontend/src/composables/display-names.ts | 2 +- apps/frontend/src/helpers/highlight.js | 14 +- apps/frontend/src/pages/[type]/[id].vue | 2 +- .../[type]/[id]/version/[version]-new.vue | 2 +- apps/frontend/src/pages/auth/authorize.vue | 4 +- apps/frontend/src/pages/auth/verify-email.vue | 2 +- apps/frontend/src/pages/settings/account.vue | 4 +- .../src/pages/settings/applications.vue | 2 +- apps/frontend/src/pages/settings/language.vue | 2 +- apps/frontend/src/public/promo-frame.html | 160 +++++++++--------- packages/utils/highlight.ts | 14 +- packages/utils/index.d.ts | 2 +- packages/utils/parse.ts | 4 +- 14 files changed, 109 insertions(+), 111 deletions(-) diff --git a/apps/app/src/api/ads.rs b/apps/app/src/api/ads.rs index cf794f567..f0199ac5e 100644 --- a/apps/app/src/api/ads.rs +++ b/apps/app/src/api/ads.rs @@ -2,10 +2,8 @@ use serde::Serialize; use std::collections::HashSet; use std::time::{Duration, Instant}; use tauri::plugin::TauriPlugin; -use tauri::{ - Emitter, Listener, LogicalPosition, LogicalSize, Manager, Runtime, -}; -use tauri_plugin_shell::{open, ShellExt}; +use tauri::{Emitter, LogicalPosition, LogicalSize, Manager, Runtime}; +use tauri_plugin_shell::ShellExt; use tokio::sync::RwLock; pub struct AdsState { diff --git a/apps/frontend/src/composables/display-names.ts b/apps/frontend/src/composables/display-names.ts index b55913655..c070ff7ab 100644 --- a/apps/frontend/src/composables/display-names.ts +++ b/apps/frontend/src/composables/display-names.ts @@ -57,7 +57,7 @@ export function createDisplayNames( try { return dict.of(lookup); - } catch (err) { + } catch { console.warn( `Failed to get display name for ${lookup} using dictionary for ${ this.resolvedOptions().locale diff --git a/apps/frontend/src/helpers/highlight.js b/apps/frontend/src/helpers/highlight.js index 983eb64f1..bb21b435b 100644 --- a/apps/frontend/src/helpers/highlight.js +++ b/apps/frontend/src/helpers/highlight.js @@ -1,21 +1,21 @@ import hljs from "highlight.js/lib/core"; // Scripting import javascript from "highlight.js/lib/languages/javascript"; -import python from "highlight.js/lib/languages/python"; import lua from "highlight.js/lib/languages/lua"; +import python from "highlight.js/lib/languages/python"; // Coding +import groovy from "highlight.js/lib/languages/groovy"; import java from "highlight.js/lib/languages/java"; import kotlin from "highlight.js/lib/languages/kotlin"; import scala from "highlight.js/lib/languages/scala"; -import groovy from "highlight.js/lib/languages/groovy"; // Configs +import { configuredXss, md } from "@modrinth/utils"; import gradle from "highlight.js/lib/languages/gradle"; -import json from "highlight.js/lib/languages/json"; import ini from "highlight.js/lib/languages/ini"; -import yaml from "highlight.js/lib/languages/yaml"; -import xml from "highlight.js/lib/languages/xml"; +import json from "highlight.js/lib/languages/json"; import properties from "highlight.js/lib/languages/properties"; -import { md, configuredXss } from "@modrinth/utils"; +import xml from "highlight.js/lib/languages/xml"; +import yaml from "highlight.js/lib/languages/yaml"; /* REGISTRATION */ // Scripting @@ -54,7 +54,7 @@ export const renderHighlightedString = (string) => if (lang && hljs.getLanguage(lang)) { try { return hljs.highlight(str, { language: lang }).value; - } catch (__) { + } catch { /* empty */ } } diff --git a/apps/frontend/src/pages/[type]/[id].vue b/apps/frontend/src/pages/[type]/[id].vue index 0323e650a..9799a1c49 100644 --- a/apps/frontend/src/pages/[type]/[id].vue +++ b/apps/frontend/src/pages/[type]/[id].vue @@ -1398,7 +1398,7 @@ try { versions = shallowRef(toRaw(versions)); featuredVersions = shallowRef(toRaw(featuredVersions)); -} catch (error) { +} catch { throw createError({ fatal: true, statusCode: 404, diff --git a/apps/frontend/src/pages/[type]/[id]/version/[version]-new.vue b/apps/frontend/src/pages/[type]/[id]/version/[version]-new.vue index 151f75d0e..c24e9a767 100644 --- a/apps/frontend/src/pages/[type]/[id]/version/[version]-new.vue +++ b/apps/frontend/src/pages/[type]/[id]/version/[version]-new.vue @@ -95,7 +95,7 @@ const props = defineProps<{ members: User[]; currentMember: User; dependencies: Dependency[]; - resetProject: Function; + resetProject: (opts?: { dedupe?: "cancel" | "defer" }) => Promise; }>(); const version = computed(() => { diff --git a/apps/frontend/src/pages/auth/authorize.vue b/apps/frontend/src/pages/auth/authorize.vue index 948cc9701..e532e225c 100644 --- a/apps/frontend/src/pages/auth/authorize.vue +++ b/apps/frontend/src/pages/auth/authorize.vue @@ -195,7 +195,7 @@ const onAuthorize = async () => { } throw new Error(formatMessage(messages.noRedirectUrlError)); - } catch (error) { + } catch { data.$notify({ group: "main", title: formatMessage(commonMessages.errorNotificationTitle), @@ -222,7 +222,7 @@ const onReject = async () => { } throw new Error(formatMessage(messages.noRedirectUrlError)); - } catch (error) { + } catch { data.$notify({ group: "main", title: formatMessage(commonMessages.errorNotificationTitle), diff --git a/apps/frontend/src/pages/auth/verify-email.vue b/apps/frontend/src/pages/auth/verify-email.vue index 6b5329752..7385fd3c5 100644 --- a/apps/frontend/src/pages/auth/verify-email.vue +++ b/apps/frontend/src/pages/auth/verify-email.vue @@ -145,7 +145,7 @@ if (route.query.flow) { await useAuth(auth.value.token); } } - } catch (err) { + } catch { success.value = false; } } diff --git a/apps/frontend/src/pages/settings/account.vue b/apps/frontend/src/pages/settings/account.vue index ab39228dc..f383684dd 100644 --- a/apps/frontend/src/pages/settings/account.vue +++ b/apps/frontend/src/pages/settings/account.vue @@ -556,7 +556,7 @@ async function verifyTwoFactorCode() { backupCodes.value = res.backup_codes; twoFactorStep.value = 2; await useAuth(auth.value.token); - } catch (err) { + } catch { twoFactorIncorrect.value = true; } stopLoading(); @@ -573,7 +573,7 @@ async function removeTwoFactor() { }); manageTwoFactorModal.value.hide(); await useAuth(auth.value.token); - } catch (err) { + } catch { twoFactorIncorrect.value = true; } stopLoading(); diff --git a/apps/frontend/src/pages/settings/applications.vue b/apps/frontend/src/pages/settings/applications.vue index d9819b8e1..47e5482e8 100644 --- a/apps/frontend/src/pages/settings/applications.vue +++ b/apps/frontend/src/pages/settings/applications.vue @@ -301,7 +301,7 @@ const canSubmit = computed(() => { const url = new URL(uri); return !!url; }); - } catch (err) { + } catch { allValid = false; } return filledIn && (oneValid || allValid); diff --git a/apps/frontend/src/pages/settings/language.vue b/apps/frontend/src/pages/settings/language.vue index ccaddd5f2..37ff63d73 100644 --- a/apps/frontend/src/pages/settings/language.vue +++ b/apps/frontend/src/pages/settings/language.vue @@ -226,7 +226,7 @@ async function changeLocale(value: string) { try { await vintl.changeLocale(value); $failedLocale.value = undefined; - } catch (err) { + } catch { $failedLocale.value = value; } finally { $changingTo.value = undefined; diff --git a/apps/frontend/src/public/promo-frame.html b/apps/frontend/src/public/promo-frame.html index b1eab69a3..6989923b9 100644 --- a/apps/frontend/src/public/promo-frame.html +++ b/apps/frontend/src/public/promo-frame.html @@ -1,89 +1,89 @@ - - - - Modrinth App Ad - - - - - -
- -
-
- + + + + +
+ +
+
+ - + window.addEventListener( + "message", + (event) => { + if (event.data.modrinthAdClick && window.__TAURI_INTERNALS__) { + window.__TAURI_INTERNALS__.invoke("plugin:ads|record_ads_click", {}); + } + + if (event.data.modrinthOpenUrl && window.__TAURI_INTERNALS__) { + window.__TAURI_INTERNALS__.invoke("plugin:ads|open_link", { + path: event.data.modrinthOpenUrl, + origin: event.origin, + }); + } + }, + false, + ); + + window.addEventListener("mousewheel", (event) => { + if (window.__TAURI_INTERNALS__) { + window.__TAURI_INTERNALS__.invoke("plugin:ads|scroll_ads_window", { + scroll: event.deltaY, + }); + } + }); + + document.addEventListener("contextmenu", (event) => event.preventDefault()); + + diff --git a/packages/utils/highlight.ts b/packages/utils/highlight.ts index d06c662bf..66a7a2392 100644 --- a/packages/utils/highlight.ts +++ b/packages/utils/highlight.ts @@ -1,21 +1,21 @@ import hljs from 'highlight.js/lib/core' // Scripting import javascript from 'highlight.js/lib/languages/javascript' -import python from 'highlight.js/lib/languages/python' import lua from 'highlight.js/lib/languages/lua' +import python from 'highlight.js/lib/languages/python' // Coding +import groovy from 'highlight.js/lib/languages/groovy' import java from 'highlight.js/lib/languages/java' import kotlin from 'highlight.js/lib/languages/kotlin' import scala from 'highlight.js/lib/languages/scala' -import groovy from 'highlight.js/lib/languages/groovy' // Configs import gradle from 'highlight.js/lib/languages/gradle' -import json from 'highlight.js/lib/languages/json' import ini from 'highlight.js/lib/languages/ini' -import yaml from 'highlight.js/lib/languages/yaml' -import xml from 'highlight.js/lib/languages/xml' +import json from 'highlight.js/lib/languages/json' import properties from 'highlight.js/lib/languages/properties' -import { md, configuredXss } from './parse' +import xml from 'highlight.js/lib/languages/xml' +import yaml from 'highlight.js/lib/languages/yaml' +import { configuredXss, md } from './parse' /* REGISTRATION */ // Scripting @@ -54,7 +54,7 @@ export const renderHighlightedString = (string) => if (lang && hljs.getLanguage(lang)) { try { return hljs.highlight(str, { language: lang }).value - } catch (__) { + } catch { /* empty */ } } diff --git a/packages/utils/index.d.ts b/packages/utils/index.d.ts index ce920c9a2..99cbfbefb 100644 --- a/packages/utils/index.d.ts +++ b/packages/utils/index.d.ts @@ -1,4 +1,4 @@ -const BASE62_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' as const +export const BASE62_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' type Base62Char = (typeof BASE62_CHARS)[number] declare global { diff --git a/packages/utils/parse.ts b/packages/utils/parse.ts index 61461fcf0..296e9c031 100644 --- a/packages/utils/parse.ts +++ b/packages/utils/parse.ts @@ -116,7 +116,7 @@ export const configuredXss = new FilterXSS({ ) } return safeAttrValue(tag, name, url.toString(), cssFilter) - } catch (err) { + } catch { /* empty */ } } @@ -153,7 +153,7 @@ export const md = (options = {}) => { if (allowedHostnames.includes(url.hostname)) { return defaultLinkOpenRenderer(tokens, idx, options, env, self) } - } catch (err) { + } catch { /* empty */ } }