From 251286f2c71b85aeb611545735e43e84792ad1e6 Mon Sep 17 00:00:00 2001 From: f0x Date: Wed, 6 Nov 2024 15:55:00 +0100 Subject: [PATCH] eslint --fix --- web/source/frontend/index.js | 12 +-- web/source/index.js | 38 +++---- .../components/authorization/index.tsx | 3 +- .../components/authorization/login.tsx | 2 +- web/source/settings/components/check-list.tsx | 11 +- web/source/settings/components/error.tsx | 9 +- web/source/settings/components/languages.tsx | 2 +- .../settings/components/pageable-list.tsx | 9 +- web/source/settings/components/status.tsx | 4 +- web/source/settings/components/username.tsx | 8 +- web/source/settings/index.tsx | 2 +- web/source/settings/lib/form/array.ts | 2 +- web/source/settings/lib/form/bool.tsx | 8 +- web/source/settings/lib/form/check-list.tsx | 32 +++--- web/source/settings/lib/form/combo-box.tsx | 16 +-- web/source/settings/lib/form/field-array.tsx | 2 +- web/source/settings/lib/form/file.tsx | 13 ++- .../settings/lib/form/form-with-data.tsx | 4 +- .../settings/lib/form/get-form-mutations.ts | 12 +-- web/source/settings/lib/form/radio.tsx | 10 +- web/source/settings/lib/form/submit.ts | 10 +- web/source/settings/lib/form/text.tsx | 13 ++- web/source/settings/lib/form/types.ts | 15 ++- web/source/settings/lib/navigation/error.tsx | 7 +- web/source/settings/lib/navigation/menu.tsx | 3 +- .../settings/lib/query/admin/actions/index.ts | 14 +-- .../lib/query/admin/custom-emoji/index.ts | 58 +++++----- .../settings/lib/query/admin/debug/index.ts | 8 +- .../query/admin/domain-permissions/export.ts | 26 ++--- .../lib/query/admin/domain-permissions/get.ts | 4 +- .../query/admin/domain-permissions/import.ts | 14 +-- .../query/admin/domain-permissions/process.ts | 15 +-- .../query/admin/domain-permissions/update.ts | 18 ++-- .../admin/http-header-permissions/index.ts | 18 ++-- web/source/settings/lib/query/admin/index.ts | 46 ++++---- .../settings/lib/query/admin/reports/index.ts | 16 +-- web/source/settings/lib/query/gts-api.ts | 10 +- web/source/settings/lib/query/oauth/index.ts | 44 ++++---- .../settings/lib/query/query-modifiers.ts | 6 +- .../settings/lib/query/user/export-import.ts | 32 +++--- web/source/settings/lib/query/user/index.ts | 42 ++++---- .../settings/lib/query/user/interactions.ts | 14 +-- web/source/settings/lib/types/account.ts | 4 +- .../settings/lib/types/domain-permission.ts | 2 +- web/source/settings/lib/types/instance.ts | 102 +++++++++--------- web/source/settings/lib/types/interaction.ts | 8 +- web/source/settings/lib/types/query.ts | 12 +-- web/source/settings/lib/types/report.ts | 12 +-- web/source/settings/lib/types/status.ts | 4 +- .../settings/lib/util/domain-permission.ts | 2 +- web/source/settings/lib/util/index.ts | 2 +- web/source/settings/redux/checklist.ts | 19 ++-- web/source/settings/redux/oauth.ts | 7 +- web/source/settings/redux/store.ts | 10 +- .../views/admin/actions/email/test.tsx | 2 +- .../views/admin/actions/keys/expireremote.tsx | 2 +- .../views/admin/debug/apurl/index.tsx | 2 +- .../views/admin/emoji/category-select.tsx | 9 +- .../views/admin/emoji/local/detail.tsx | 6 +- .../views/admin/emoji/local/new-emoji.tsx | 11 +- .../views/admin/emoji/local/overview.tsx | 12 ++- .../views/admin/emoji/local/use-shortcode.ts | 8 +- .../views/admin/emoji/remote/index.tsx | 2 +- .../admin/emoji/remote/steal-this-look.tsx | 16 +-- .../admin/http-header-permissions/create.tsx | 8 +- .../admin/http-header-permissions/detail.tsx | 14 +-- .../http-header-permissions/overview.tsx | 16 +-- .../views/admin/instance/ruledetail.tsx | 2 +- .../settings/views/admin/instance/rules.tsx | 6 +- .../views/admin/instance/settings.tsx | 16 +-- .../moderation/accounts/detail/actions.tsx | 8 +- .../moderation/accounts/detail/index.tsx | 4 +- .../moderation/accounts/pending/index.tsx | 5 +- .../moderation/accounts/search/index.tsx | 9 +- .../moderation/domain-permissions/detail.tsx | 19 ++-- .../moderation/domain-permissions/form.tsx | 15 ++- .../domain-permissions/import-export.tsx | 4 +- .../domain-permissions/overview.tsx | 7 +- .../moderation/domain-permissions/process.tsx | 27 +++-- .../views/moderation/reports/detail.tsx | 8 +- .../views/moderation/reports/search.tsx | 9 +- .../settings/views/user/emailpassword.tsx | 16 +-- .../views/user/export-import/export.tsx | 24 +++-- .../views/user/export-import/import.tsx | 4 +- .../views/user/interactions/detail.tsx | 4 +- .../views/user/interactions/search.tsx | 15 +-- .../settings/views/user/interactions/util.tsx | 7 +- web/source/settings/views/user/migration.tsx | 12 +-- .../views/user/posts/basic-settings/index.tsx | 6 +- .../interaction-policy-settings/basic.tsx | 5 +- .../interaction-policy-settings/index.tsx | 14 +-- .../something-else.tsx | 5 +- .../interaction-policy-settings/types.ts | 4 +- web/source/settings/views/user/profile.tsx | 25 +++-- 94 files changed, 625 insertions(+), 579 deletions(-) diff --git a/web/source/frontend/index.js b/web/source/frontend/index.js index b88c64680..97a4a3a22 100644 --- a/web/source/frontend/index.js +++ b/web/source/frontend/index.js @@ -46,7 +46,7 @@ new PhotoswipeCaptionPlugin(lightbox, { type: 'auto', captionContent(slide) { return slide.data.alt; - } + }, }); lightbox.addFilter('itemData', (item) => { @@ -68,10 +68,10 @@ lightbox.addFilter('itemData', (item) => { }, pause() { el._player.pause(); - } + }, }, width: parseInt(el.dataset.pswpWidth), - height: parseInt(el.dataset.pswpHeight) + height: parseInt(el.dataset.pswpHeight), }; } return item; @@ -169,12 +169,12 @@ Array.from(document.getElementsByClassName("plyr-video")).forEach((video) => { }, 1); } lightbox.loadAndOpen(parseInt(video.dataset.pswpIndex), { - gallery: video.closest(".photoswipe-gallery") + gallery: video.closest(".photoswipe-gallery"), }); return false; - } - } + }, + }, }); player.elements.container.title = video.title; diff --git a/web/source/index.js b/web/source/index.js index 7b36676e2..2dc154f6f 100644 --- a/web/source/index.js +++ b/web/source/index.js @@ -29,10 +29,10 @@ const prodCfg = { transform: [ ["@browserify/uglifyify", { global: true, - exts: ".js" + exts: ".js", }], - ["@browserify/envify", { global: true }] - ] + ["@browserify/envify", { global: true }], + ], }; skulk({ @@ -42,8 +42,8 @@ skulk({ prodCfg: { servers: { express: false, - livereload: false - } + livereload: false, + }, }, servers: { express: { @@ -54,6 +54,8 @@ skulk({ delete proxyRes.headers['content-security-policy']; }, }, + assets: "/assets", + }, }, bundles: { frontend: { @@ -64,8 +66,8 @@ skulk({ transform: [ ["babelify", { global: true, - ignore: [/node_modules\/(?!(photoswipe.*))/] - }] + ignore: [/node_modules\/(?!(photoswipe.*))/], + }], ], }, settings: { @@ -75,7 +77,7 @@ skulk({ plugin: [ // Additional settings for TS are passed from tsconfig.json. // See: https://github.com/TypeStrong/tsify#tsconfigjson - ["tsify"] + ["tsify"], ], transform: [ // tsify is called before babelify, so we're just babelifying @@ -83,28 +85,28 @@ skulk({ ["babelify", { global: true, ignore: [/node_modules\/(?!(nanoid)|(wouter))/], - }] + }], ], presets: [ "react", ["postcss", { - output: "settings-style.css" - }] - ] + output: "settings-style.css", + }], + ], }, cssThemes: { entryFiles: cssThemes, outputFile: "_discard", presets: [["postcss", { - output: "_split" - }]] + output: "_split", + }]], }, css: { entryFiles: cssFiles, outputFile: "_discard", presets: [["postcss", { - output: "style.css" - }]] - } - } + output: "style.css", + }]], + }, + }, }); diff --git a/web/source/settings/components/authorization/index.tsx b/web/source/settings/components/authorization/index.tsx index e8f4d6673..7cbe6ede0 100644 --- a/web/source/settings/components/authorization/index.tsx +++ b/web/source/settings/components/authorization/index.tsx @@ -19,7 +19,8 @@ import { useLogoutMutation, useVerifyCredentialsQuery } from "../../lib/query/oauth"; import { store } from "../../redux/store"; -import React, { ReactNode } from "react"; +import type { ReactNode } from "react"; +import React from "react"; import Login from "./login"; import Loading from "../loading"; diff --git a/web/source/settings/components/authorization/login.tsx b/web/source/settings/components/authorization/login.tsx index 870e9c343..7e9cce110 100644 --- a/web/source/settings/components/authorization/login.tsx +++ b/web/source/settings/components/authorization/login.tsx @@ -29,7 +29,7 @@ import { TextInput } from "../form/inputs"; export default function Login({ }) { const form = { instance: useTextInput("instance", { - defaultValue: window.location.origin + defaultValue: window.location.origin, }), scopes: useValue("scopes", "user admin"), }; diff --git a/web/source/settings/components/check-list.tsx b/web/source/settings/components/check-list.tsx index aec57e758..7710f15d5 100644 --- a/web/source/settings/components/check-list.tsx +++ b/web/source/settings/components/check-list.tsx @@ -17,10 +17,9 @@ along with this program. If not, see . */ -import React from "react"; +import React, { memo, useDeferredValue, useCallback, useMemo } from "react"; -import { memo, useDeferredValue, useCallback, useMemo } from "react"; -import { Checkable, ChecklistInputHook } from "../lib/form/types"; +import type { Checkable, ChecklistInputHook } from "../lib/form/types"; interface CheckListProps { field: ChecklistInputHook; @@ -75,7 +74,7 @@ const CheckListEntries = memo( getExtraProps={getExtraProps} /> )); - } + }, ); interface CheckListEntryProps { @@ -94,7 +93,7 @@ const CheckListEntry = memo( function CheckListEntry({ entry, updateValue, getExtraProps, EntryComponent }: CheckListEntryProps) { const onChange = useCallback( (value) => updateValue(entry.key, value), - [updateValue, entry.key] + [updateValue, entry.key], ); const extraProps = useMemo(() => getExtraProps?.(entry), [getExtraProps, entry]); @@ -109,5 +108,5 @@ const CheckListEntry = memo( ); - } + }, ); \ No newline at end of file diff --git a/web/source/settings/components/error.tsx b/web/source/settings/components/error.tsx index 977cf06c8..bc497e7e4 100644 --- a/web/source/settings/components/error.tsx +++ b/web/source/settings/components/error.tsx @@ -17,9 +17,10 @@ along with this program. If not, see . */ -import { SerializedError } from "@reduxjs/toolkit"; -import { FetchBaseQueryError } from "@reduxjs/toolkit/query"; -import React, { ReactNode } from "react"; +import type { SerializedError } from "@reduxjs/toolkit"; +import type { FetchBaseQueryError } from "@reduxjs/toolkit/query"; +import type { ReactNode } from "react"; +import React from "react"; function ErrorFallback({ error, resetErrorBoundary }) { return ( @@ -74,7 +75,7 @@ function Error({ error, reset }: ErrorProps) { return null; } - /* eslint-disable-next-line no-console */ + console.error("caught error: ", error); let message: ReactNode; diff --git a/web/source/settings/components/languages.tsx b/web/source/settings/components/languages.tsx index 7c2986438..022261b50 100644 --- a/web/source/settings/components/languages.tsx +++ b/web/source/settings/components/languages.tsx @@ -21,7 +21,7 @@ import React from "react"; import { all } from "langs"; const asElements = all().map((l) => { - let code = l["1"].toUpperCase(); + const code = l["1"].toUpperCase(); let name = l.name; if (l.name != l.local) { name = `${name} - ${l.local}`; diff --git a/web/source/settings/components/pageable-list.tsx b/web/source/settings/components/pageable-list.tsx index 3571fb1cd..2dee2c68d 100644 --- a/web/source/settings/components/pageable-list.tsx +++ b/web/source/settings/components/pageable-list.tsx @@ -17,12 +17,13 @@ along with this program. If not, see . */ -import React, { ReactNode } from "react"; +import type { ReactNode } from "react"; +import React from "react"; import { useLocation } from "wouter"; import { Error } from "./error"; -import { SerializedError } from "@reduxjs/toolkit"; -import { FetchBaseQueryError } from "@reduxjs/toolkit/query"; -import { Links } from "parse-link-header"; +import type { SerializedError } from "@reduxjs/toolkit"; +import type { FetchBaseQueryError } from "@reduxjs/toolkit/query"; +import type { Links } from "parse-link-header"; import Loading from "./loading"; export interface PageableListProps { diff --git a/web/source/settings/components/status.tsx b/web/source/settings/components/status.tsx index 4f6781d77..9b4ecf06d 100644 --- a/web/source/settings/components/status.tsx +++ b/web/source/settings/components/status.tsx @@ -19,14 +19,14 @@ import React from "react"; import { useVerifyCredentialsQuery } from "../lib/query/oauth"; -import { MediaAttachment, Status as StatusType } from "../lib/types/status"; +import type { MediaAttachment, Status as StatusType } from "../lib/types/status"; import sanitize from "sanitize-html"; export function FakeStatus({ children }) { const { data: account = { avatar: "/assets/default_avatars/GoToSocial_icon1.webp", display_name: "", - username: "" + username: "", } } = useVerifyCredentialsQuery(); return ( diff --git a/web/source/settings/components/username.tsx b/web/source/settings/components/username.tsx index 56ba67c4f..c2b8de9d4 100644 --- a/web/source/settings/components/username.tsx +++ b/web/source/settings/components/username.tsx @@ -19,7 +19,7 @@ import React from "react"; import { useLocation } from "wouter"; -import { AdminAccount } from "../lib/types/account"; +import type { AdminAccount } from "../lib/types/account"; interface UsernameProps { account: AdminAccount; @@ -32,7 +32,7 @@ export default function Username({ account, linkTo, backLocation, classNames }: const [ _location, setLocation ] = useLocation(); let className = "username-lozenge"; - let isLocal = account.domain == null; + const isLocal = account.domain == null; if (account.suspended) { className += " suspended"; @@ -46,7 +46,7 @@ export default function Username({ account, linkTo, backLocation, classNames }: className = [ className, classNames ].flat().join(" "); } - let icon = isLocal + const icon = isLocal ? { fa: "fa-home", info: "Local user" } : { fa: "fa-external-link-square", info: "Remote user" }; @@ -71,7 +71,7 @@ export default function Username({ account, linkTo, backLocation, classNames }: // Store the back location in history so // the detail view can use it to return to // this page (including query parameters). - state: { backLocation: backLocation } + state: { backLocation: backLocation }, }); }} role="link" diff --git a/web/source/settings/index.tsx b/web/source/settings/index.tsx index 5317658d2..899219218 100644 --- a/web/source/settings/index.tsx +++ b/web/source/settings/index.tsx @@ -26,7 +26,7 @@ import { PersistGate } from "redux-persist/integration/react"; import { store, persistor } from "./redux/store"; import { Authorization } from "./components/authorization"; import Loading from "./components/loading"; -import { Account } from "./lib/types/account"; +import type { Account } from "./lib/types/account"; import { BaseUrlContext, RoleContext, InstanceDebugContext } from "./lib/navigation/util"; import { SidebarMenu } from "./lib/navigation/menu"; import { Redirect, Route, Router } from "wouter"; diff --git a/web/source/settings/lib/form/array.ts b/web/source/settings/lib/form/array.ts index 7ddf9499c..60451e7ca 100644 --- a/web/source/settings/lib/form/array.ts +++ b/web/source/settings/lib/form/array.ts @@ -87,6 +87,6 @@ export default function useArrayInput( } else { return []; } - } + }, }; } diff --git a/web/source/settings/lib/form/bool.tsx b/web/source/settings/lib/form/bool.tsx index 815b17bd3..21e43fef1 100644 --- a/web/source/settings/lib/form/bool.tsx +++ b/web/source/settings/lib/form/bool.tsx @@ -27,7 +27,7 @@ import type { const _default = false; export default function useBoolInput( { name, Name }: CreateHookNames, - { initialValue = _default }: HookOpts + { initialValue = _default }: HookOpts, ): BoolFormInputHook { const [value, setValue] = useState(initialValue); @@ -45,8 +45,8 @@ export default function useBoolInput( reset, { [name]: value, - [`set${Name}`]: setValue - } + [`set${Name}`]: setValue, + }, ], { name, Name: "", @@ -55,6 +55,6 @@ export default function useBoolInput( value, setter: setValue, hasChanged: () => value != initialValue, - _default + _default, }); } diff --git a/web/source/settings/lib/form/check-list.tsx b/web/source/settings/lib/form/check-list.tsx index e44daefff..167c0c39c 100644 --- a/web/source/settings/lib/form/check-list.tsx +++ b/web/source/settings/lib/form/check-list.tsx @@ -38,20 +38,20 @@ import { const _default: { [k: string]: Checkable } = {}; export default function useCheckListInput( - /* eslint-disable no-unused-vars */ + { name, Name }: CreateHookNames, { entries = [], uniqueKey = "key", initialValue = false, - }: HookOpts + }: HookOpts, ): ChecklistInputHook { const [state, dispatch] = useChecklistReducer(entries, uniqueKey, initialValue); const toggleAllRef = useRef(null); useEffect(() => { if (toggleAllRef.current != null) { - let some = state.selectedEntries.size > 0; + const some = state.selectedEntries.size > 0; let all = false; if (some) { all = state.selectedEntries.size == Object.values(state.entries).length; @@ -64,18 +64,24 @@ export default function useCheckListInput( }, [state.selectedEntries]); const reset = useCallback( - () => dispatch(actions.updateAll(initialValue)), - [initialValue, dispatch] + () => { + dispatch(actions.updateAll(initialValue)); + }, + [initialValue, dispatch], ); const onChange = useCallback( - (key: string, value: Checkable) => dispatch(actions.update({ key, value })), - [dispatch] + (key: string, value: Checkable) => { + dispatch(actions.update({ key, value })); + }, + [dispatch], ); const updateMultiple = useCallback( - (entries: [key: string, value: Partial][]) => dispatch(actions.updateMultiple(entries)), - [dispatch] + (entries: [key: string, value: Partial][]) => { + dispatch(actions.updateMultiple(entries)); + }, + [dispatch], ); return useMemo(() => { @@ -89,14 +95,14 @@ export default function useCheckListInput( function selectedValues() { return Array.from((state.selectedEntries)).map((key) => ({ - ...state.entries[key] // returned as new object, because reducer state is immutable + ...state.entries[key], // returned as new object, because reducer state is immutable })); } return Object.assign([ state, reset, - { name } + { name }, ], { _default, hasChanged: () => true, @@ -110,8 +116,8 @@ export default function useCheckListInput( updateMultiple, toggleAll: { ref: toggleAllRef, - onChange: toggleAll - } + onChange: toggleAll, + }, }); }, [state, reset, name, onChange, updateMultiple, dispatch]); } diff --git a/web/source/settings/lib/form/combo-box.tsx b/web/source/settings/lib/form/combo-box.tsx index e558d298a..3b2ee75ea 100644 --- a/web/source/settings/lib/form/combo-box.tsx +++ b/web/source/settings/lib/form/combo-box.tsx @@ -20,7 +20,7 @@ import { useState } from "react"; import { useComboboxState } from "ariakit/combobox"; -import { +import type { ComboboxFormInputHook, CreateHookNames, HookOpts, @@ -29,14 +29,14 @@ import { const _default = ""; export default function useComboBoxInput( { name, Name }: CreateHookNames, - { initialValue = _default }: HookOpts + { initialValue = _default }: HookOpts, ): ComboboxFormInputHook { const [isNew, setIsNew] = useState(false); const state = useComboboxState({ defaultValue: initialValue, gutter: 0, - sameWidth: true + sameWidth: true, }); function reset() { @@ -50,18 +50,20 @@ export default function useComboBoxInput( [name]: state.value, name, [`${name}IsNew`]: isNew, - [`set${Name}IsNew`]: setIsNew - } + [`set${Name}IsNew`]: setIsNew, + }, ], { reset, name, Name: "", // Will be set by inputHook function. state, value: state.value, - setter: (val: string) => state.setValue(val), + setter: (val: string) => { + state.setValue(val); + }, hasChanged: () => state.value != initialValue, isNew, setIsNew, - _default + _default, }); } diff --git a/web/source/settings/lib/form/field-array.tsx b/web/source/settings/lib/form/field-array.tsx index 1239f033e..7dbbf102d 100644 --- a/web/source/settings/lib/form/field-array.tsx +++ b/web/source/settings/lib/form/field-array.tsx @@ -80,6 +80,6 @@ export default function useFieldArrayInput( } else { return []; } - } + }, }; } diff --git a/web/source/settings/lib/form/file.tsx b/web/source/settings/lib/form/file.tsx index cf9407827..d4d479306 100644 --- a/web/source/settings/lib/form/file.tsx +++ b/web/source/settings/lib/form/file.tsx @@ -17,9 +17,8 @@ along with this program. If not, see . */ -import React from "react"; +import React, { useState } from "react"; -import { useState } from "react"; import prettierBytes from "prettier-bytes"; import type { @@ -35,8 +34,8 @@ export default function useFileInput( { withPreview, maxSize, - initialInfo = "no file selected" - }: HookOpts + initialInfo = "no file selected", + }: HookOpts, ): FileFormInputHook { const [file, setFile] = useState(); const [imageURL, setImageURL] = useState(); @@ -58,7 +57,7 @@ export default function useFileInput( return; } - let file = files[0]; + const file = files[0]; setFile(file); if (imageURL) { @@ -76,7 +75,7 @@ export default function useFileInput( + />, ); } else { setInfo(<>{file.name} ({sizePrettier})); @@ -100,7 +99,7 @@ export default function useFileInput( [name]: file, [`${name}URL`]: imageURL, [`${name}Info`]: infoComponent, - } + }, ], { onChange, reset, diff --git a/web/source/settings/lib/form/form-with-data.tsx b/web/source/settings/lib/form/form-with-data.tsx index 70a162fb0..ebae99201 100644 --- a/web/source/settings/lib/form/form-with-data.tsx +++ b/web/source/settings/lib/form/form-with-data.tsx @@ -17,14 +17,12 @@ along with this program. If not, see . */ -/* eslint-disable no-unused-vars */ - import React from "react"; import { Error } from "../../components/error"; import Loading from "../../components/loading"; import { NoArg } from "../types/query"; -import { FormWithDataQuery } from "./types"; +import type { FormWithDataQuery } from "./types"; export interface FormWithDataProps { dataQuery: FormWithDataQuery, diff --git a/web/source/settings/lib/form/get-form-mutations.ts b/web/source/settings/lib/form/get-form-mutations.ts index 0959fcf95..27eb5e8c0 100644 --- a/web/source/settings/lib/form/get-form-mutations.ts +++ b/web/source/settings/lib/form/get-form-mutations.ts @@ -17,17 +17,17 @@ along with this program. If not, see . */ -import { FormInputHook, HookedForm } from "./types"; +import type { FormInputHook, HookedForm } from "./types"; export default function getFormMutations( form: HookedForm, { changedOnly }: { changedOnly: boolean }, ): { - updatedFields: FormInputHook[]; - mutationData: { - [k: string]: any; - }; -} { + updatedFields: FormInputHook[]; + mutationData: { + [k: string]: any; + }; + } { const updatedFields: FormInputHook[] = []; const mutationData: Array<[string, any]> = []; diff --git a/web/source/settings/lib/form/radio.tsx b/web/source/settings/lib/form/radio.tsx index 164abab9d..12df6979d 100644 --- a/web/source/settings/lib/form/radio.tsx +++ b/web/source/settings/lib/form/radio.tsx @@ -18,7 +18,7 @@ */ import { useState } from "react"; -import { CreateHookNames, HookOpts, RadioFormInputHook } from "./types"; +import type { CreateHookNames, HookOpts, RadioFormInputHook } from "./types"; const _default = ""; export default function useRadioInput( @@ -26,7 +26,7 @@ export default function useRadioInput( { initialValue = _default, options = {}, - }: HookOpts + }: HookOpts, ): RadioFormInputHook { const [value, setValue] = useState(initialValue); @@ -44,8 +44,8 @@ export default function useRadioInput( reset, { [name]: value, - [`set${Name}`]: setValue - } + [`set${Name}`]: setValue, + }, ], { onChange, reset, @@ -55,6 +55,6 @@ export default function useRadioInput( setter: setValue, options, hasChanged: () => value != initialValue, - _default + _default, }); } diff --git a/web/source/settings/lib/form/submit.ts b/web/source/settings/lib/form/submit.ts index aa662086f..c5d73f028 100644 --- a/web/source/settings/lib/form/submit.ts +++ b/web/source/settings/lib/form/submit.ts @@ -60,7 +60,7 @@ interface UseFormSubmitOptions { export default function useFormSubmit( form: HookedForm, mutationQuery: readonly [MutationTrigger, UseMutationStateResult], - opts: UseFormSubmitOptions = { changedOnly: true } + opts: UseFormSubmitOptions = { changedOnly: true }, ): [ FormSubmitFunction, FormSubmitResult ] { if (!Array.isArray(mutationQuery)) { throw "useFormSubmit: mutationQuery was not an Array. Is a valid useMutation RTK Query provided?"; @@ -90,7 +90,7 @@ export default function useFormSubmit( // what at this point. If it's an empty string, fall back to undefined. // // See: https://developer.mozilla.org/en-US/docs/Web/API/SubmitEvent/submitter - action = (e.nativeEvent.submitter as Object as { name: string }).name || undefined; + action = (e.nativeEvent.submitter as object as { name: string }).name || undefined; } else { // No submitter defined. Fall back // to just use the FormSubmitEvent. @@ -125,7 +125,7 @@ export default function useFormSubmit( onFinish(res); } } catch (e) { - // eslint-disable-next-line no-console + console.error(`caught error running mutation: ${e}`); } }; @@ -134,7 +134,7 @@ export default function useFormSubmit( submitForm, { ...mutationResult, - action: usedAction.current - } + action: usedAction.current, + }, ]; } diff --git a/web/source/settings/lib/form/text.tsx b/web/source/settings/lib/form/text.tsx index 822675cdd..4ec9eb812 100644 --- a/web/source/settings/lib/form/text.tsx +++ b/web/source/settings/lib/form/text.tsx @@ -17,7 +17,8 @@ along with this program. If not, see . */ -import React, { +import type React from "react"; +import { useState, useRef, useTransition, @@ -41,7 +42,7 @@ export default function useTextInput( showValidation = true, initValidation, nosubmit = false, - }: HookOpts + }: HookOpts, ): TextFormInputHook { const [text, setText] = useState(initialValue); const textRef = useRef(null); @@ -86,7 +87,7 @@ export default function useTextInput( [`${name}Ref`]: textRef, [`set${Name}`]: setText, [`${name}Valid`]: valid, - } + }, ], { onChange, reset, @@ -97,8 +98,10 @@ export default function useTextInput( ref: textRef, setter: setText, valid, - validate: () => setValidation(validator ? validator(text): ""), + validate: () => { + setValidation(validator ? validator(text): ""); + }, hasChanged: () => text != initialValue, - _default + _default, }); } diff --git a/web/source/settings/lib/form/types.ts b/web/source/settings/lib/form/types.ts index 17fbec53a..f09eb874f 100644 --- a/web/source/settings/lib/form/types.ts +++ b/web/source/settings/lib/form/types.ts @@ -17,12 +17,8 @@ along with this program. If not, see . */ -/* eslint-disable no-unused-vars */ - -import { ComboboxState } from "ariakit"; -import React from "react"; - -import { +import type { ComboboxState } from "ariakit"; +import type React, { ChangeEventHandler, Dispatch, RefObject, @@ -30,6 +26,7 @@ import { SyntheticEvent, } from "react"; + export interface CreateHookNames { name: string; Name: string; @@ -225,9 +222,9 @@ export interface ChecklistInputHook extends FormInputHook<{[k: st _withSelectedFieldValues, _withSomeSelected, _withUpdateMultiple { - // Uses its own funky onChange handler. - onChange: (key: any, value: any) => void - } + // Uses its own funky onChange handler. + onChange: (key: any, value: any) => void +} export type AnyFormInputHook = FormInputHook | diff --git a/web/source/settings/lib/navigation/error.tsx b/web/source/settings/lib/navigation/error.tsx index 08edc83f0..88509a71a 100644 --- a/web/source/settings/lib/navigation/error.tsx +++ b/web/source/settings/lib/navigation/error.tsx @@ -17,7 +17,8 @@ along with this program. If not, see . */ -import React, { Component, ReactNode } from "react"; +import type { ReactNode } from "react"; +import React, { Component } from "react"; interface ErrorBoundaryProps { @@ -48,7 +49,7 @@ class ErrorBoundary extends Component { componentDidCatch(_e, info) { this.setState({ ...this.state, - componentStack: info.componentStack + componentStack: info.componentStack, }); } @@ -83,7 +84,7 @@ function ErrorFallback({ error, componentStack, resetErrorBoundary }) { {componentStack && [ "\n\nComponent trace:", - componentStack + componentStack, ]} {["\n\nError trace: ", error.stack]} diff --git a/web/source/settings/lib/navigation/menu.tsx b/web/source/settings/lib/navigation/menu.tsx index 514e3ea2f..8496abd9d 100644 --- a/web/source/settings/lib/navigation/menu.tsx +++ b/web/source/settings/lib/navigation/menu.tsx @@ -17,7 +17,8 @@ along with this program. If not, see . */ -import React, { PropsWithChildren } from "react"; +import type { PropsWithChildren } from "react"; +import React from "react"; import { Link, useRoute } from "wouter"; import { BaseUrlContext, diff --git a/web/source/settings/lib/query/admin/actions/index.ts b/web/source/settings/lib/query/admin/actions/index.ts index 7bf34c9ba..9caad821e 100644 --- a/web/source/settings/lib/query/admin/actions/index.ts +++ b/web/source/settings/lib/query/admin/actions/index.ts @@ -26,9 +26,9 @@ const extended = gtsApi.injectEndpoints({ method: "POST", url: `/api/v1/admin/media_cleanup`, params: { - remote_cache_days: days - } - }) + remote_cache_days: days, + }, + }), }), instanceKeysExpire: build.mutation({ @@ -36,9 +36,9 @@ const extended = gtsApi.injectEndpoints({ method: "POST", url: `/api/v1/admin/domain_keys_expire`, params: { - domain: domain - } - }) + domain: domain, + }, + }), }), sendTestEmail: build.mutation({ @@ -46,7 +46,7 @@ const extended = gtsApi.injectEndpoints({ method: "POST", url: `/api/v1/admin/email/test`, params: params, - }) + }), }), }), }); diff --git a/web/source/settings/lib/query/admin/custom-emoji/index.ts b/web/source/settings/lib/query/admin/custom-emoji/index.ts index 56684f03b..fef2e3980 100644 --- a/web/source/settings/lib/query/admin/custom-emoji/index.ts +++ b/web/source/settings/lib/query/admin/custom-emoji/index.ts @@ -18,8 +18,8 @@ */ import { gtsApi } from "../../gts-api"; -import { FetchBaseQueryError } from "@reduxjs/toolkit/query"; -import { RootState } from "../../../../redux/store"; +import type { FetchBaseQueryError } from "@reduxjs/toolkit/query"; +import type { RootState } from "../../../../redux/store"; import type { CustomEmoji, EmojisFromItem, ListEmojiParams } from "../../../types/custom-emoji"; @@ -77,39 +77,39 @@ const extended = gtsApi.injectEndpoints({ url: "/api/v1/admin/custom_emojis", params: { limit: 0, - ...params - } + ...params, + }, }), providesTags: (res, _error, _arg) => res ? [ ...res.map((emoji) => ({ type: "Emoji" as const, id: emoji.id })), - { type: "Emoji", id: "LIST" } + { type: "Emoji", id: "LIST" }, ] - : [{ type: "Emoji", id: "LIST" }] + : [{ type: "Emoji", id: "LIST" }], }), getEmoji: build.query({ query: (id) => ({ - url: `/api/v1/admin/custom_emojis/${id}` + url: `/api/v1/admin/custom_emojis/${id}`, }), - providesTags: (_res, _error, id) => [{ type: "Emoji", id }] + providesTags: (_res, _error, id) => [{ type: "Emoji", id }], }), - addEmoji: build.mutation({ + addEmoji: build.mutation({ query: (form) => { return { method: "POST", url: `/api/v1/admin/custom_emojis`, asForm: true, body: form, - discardEmpty: true + discardEmpty: true, }; }, invalidatesTags: (res) => res ? [{ type: "Emoji", id: "LIST" }, { type: "Emoji", id: res.id }] - : [{ type: "Emoji", id: "LIST" }] + : [{ type: "Emoji", id: "LIST" }], }), editEmoji: build.mutation({ @@ -120,22 +120,22 @@ const extended = gtsApi.injectEndpoints({ asForm: true, body: { type: "modify", - ...patch - } + ...patch, + }, }; }, invalidatesTags: (res) => res ? [{ type: "Emoji", id: "LIST" }, { type: "Emoji", id: res.id }] - : [{ type: "Emoji", id: "LIST" }] + : [{ type: "Emoji", id: "LIST" }], }), deleteEmoji: build.mutation({ query: (id) => ({ method: "DELETE", - url: `/api/v1/admin/custom_emojis/${id}` + url: `/api/v1/admin/custom_emojis/${id}`, }), - invalidatesTags: (_res, _error, id) => [{ type: "Emoji", id }] + invalidatesTags: (_res, _error, id) => [{ type: "Emoji", id }], }), searchItemForEmoji: build.mutation({ @@ -145,10 +145,10 @@ const extended = gtsApi.injectEndpoints({ // First search for given url. const searchRes = await fetchWithBQ({ - url: `/api/v2/search?q=${encodeURIComponent(url)}&resolve=true&limit=1` + url: `/api/v2/search?q=${encodeURIComponent(url)}&resolve=true&limit=1`, }); if (searchRes.error) { - return { error: searchRes.error as FetchBaseQueryError }; + return { error: searchRes.error }; } // Parse initial results of search. @@ -178,8 +178,8 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/admin/custom_emojis`, params: { filter: `domain:${domain},shortcode:${emoji.shortcode}`, - limit: 1 - } + limit: 1, + }, }); if (emojiRes.error) { @@ -191,7 +191,7 @@ const extended = gtsApi.injectEndpoints({ // Got it! return emojiRes.data as CustomEmoji; - }) + }), ) ).flatMap((emoji) => { // Remove any nulls. @@ -205,7 +205,7 @@ const extended = gtsApi.injectEndpoints({ status: 400, statusText: 'Bad Request', data: { - error: `One or more errors fetching custom emojis: [${errData}]` + error: `One or more errors fetching custom emojis: [${errData}]`, }, }, }; @@ -218,9 +218,9 @@ const extended = gtsApi.injectEndpoints({ type, domain, list: withIDs, - } + }, }; - } + }, }), patchRemoteEmojis: build.mutation({ @@ -231,7 +231,7 @@ const extended = gtsApi.injectEndpoints({ // Map function to get a promise // of an emoji (or null). const copyEmoji = async(emoji: CustomEmoji) => { - let body: { + const body: { type: string; shortcode?: string; category?: string; @@ -285,7 +285,7 @@ const extended = gtsApi.injectEndpoints({ status: 400, statusText: 'Bad Request', data: { - error: `One or more errors patching custom emojis: [${errData}]` + error: `One or more errors patching custom emojis: [${errData}]`, }, }, }; @@ -293,9 +293,9 @@ const extended = gtsApi.injectEndpoints({ return { data }; }, - invalidatesTags: () => [{ type: "Emoji", id: "LIST" }] - }) - }) + invalidatesTags: () => [{ type: "Emoji", id: "LIST" }], + }), + }), }); /** diff --git a/web/source/settings/lib/query/admin/debug/index.ts b/web/source/settings/lib/query/admin/debug/index.ts index 5dabd4666..b1dd399e8 100644 --- a/web/source/settings/lib/query/admin/debug/index.ts +++ b/web/source/settings/lib/query/admin/debug/index.ts @@ -17,7 +17,7 @@ along with this program. If not, see . */ -import { ApURLResponse } from "../../../types/debug"; +import type { ApURLResponse } from "../../../types/debug"; import { gtsApi } from "../../gts-api"; const extended = gtsApi.injectEndpoints({ @@ -32,13 +32,13 @@ const extended = gtsApi.injectEndpoints({ return { url: `/api/v1/admin/debug/apurl?${urlParam.toString()}`, }; - } + }, }), ClearCaches: build.mutation<{}, void>({ query: () => ({ method: "POST", - url: `/api/v1/admin/debug/caches/clear` - }) + url: `/api/v1/admin/debug/caches/clear`, + }), }), }), }); diff --git a/web/source/settings/lib/query/admin/domain-permissions/export.ts b/web/source/settings/lib/query/admin/domain-permissions/export.ts index 868e3f7a4..c52967aa3 100644 --- a/web/source/settings/lib/query/admin/domain-permissions/export.ts +++ b/web/source/settings/lib/query/admin/domain-permissions/export.ts @@ -21,9 +21,9 @@ import fileDownload from "js-file-download"; import { unparse as csvUnparse } from "papaparse"; import { gtsApi } from "../../gts-api"; -import { RootState } from "../../../../redux/store"; -import { FetchBaseQueryError } from "@reduxjs/toolkit/query"; -import { DomainPerm, ExportDomainPermsParams } from "../../../types/domain-permission"; +import type { RootState } from "../../../../redux/store"; +import type { FetchBaseQueryError } from "@reduxjs/toolkit/query"; +import type { DomainPerm, ExportDomainPermsParams } from "../../../types/domain-permission"; interface _exportProcess { transformEntry: (_entry: DomainPerm) => any; @@ -45,11 +45,11 @@ function exportProcess(formData: ExportDomainPermsParams): _exportProcess { transformEntry: (entry) => ({ domain: entry.domain, public_comment: entry.public_comment, - obfuscate: entry.obfuscate + obfuscate: entry.obfuscate, }), stringify: (list) => JSON.stringify(list), extension: ".json", - mime: "application/json" + mime: "application/json", }; } @@ -61,7 +61,7 @@ function exportProcess(formData: ExportDomainPermsParams): _exportProcess { false, // reject_media false, // reject_reports entry.public_comment ?? "", // public_comment - entry.obfuscate ?? false // obfuscate + entry.obfuscate ?? false, // obfuscate ], stringify: (list) => csvUnparse({ fields: [ @@ -72,10 +72,10 @@ function exportProcess(formData: ExportDomainPermsParams): _exportProcess { "#public_comment", "#obfuscate", ], - data: list + data: list, }), extension: ".csv", - mime: "text/csv" + mime: "text/csv", }; } @@ -84,7 +84,7 @@ function exportProcess(formData: ExportDomainPermsParams): _exportProcess { transformEntry: (entry) => entry.domain, stringify: (list) => list.join("\n"), extension: ".txt", - mime: "text/plain" + mime: "text/plain", }; } @@ -98,7 +98,7 @@ const extended = gtsApi.injectEndpoints({ // we want the untransformed array version. const permsRes = await fetchWithBQ({ url: `/api/v1/admin/domain_${formData.permType}s` }); if (permsRes.error) { - return { error: permsRes.error as FetchBaseQueryError }; + return { error: permsRes.error }; } // Process perms into desired export format. @@ -130,16 +130,16 @@ const extended = gtsApi.injectEndpoints({ fileDownload( exportAsString, filename + process.extension, - process.mime + process.mime, ); // js-file-download handles the // nitty gritty for us, so we can // just return null data. return { data: null }; - } + }, }), - }) + }), }); /** diff --git a/web/source/settings/lib/query/admin/domain-permissions/get.ts b/web/source/settings/lib/query/admin/domain-permissions/get.ts index 3e27742d4..e87a2186c 100644 --- a/web/source/settings/lib/query/admin/domain-permissions/get.ts +++ b/web/source/settings/lib/query/admin/domain-permissions/get.ts @@ -26,14 +26,14 @@ const extended = gtsApi.injectEndpoints({ endpoints: (build) => ({ domainBlocks: build.query({ query: () => ({ - url: `/api/v1/admin/domain_blocks` + url: `/api/v1/admin/domain_blocks`, }), transformResponse: listToKeyedObject("domain"), }), domainAllows: build.query({ query: () => ({ - url: `/api/v1/admin/domain_allows` + url: `/api/v1/admin/domain_allows`, }), transformResponse: listToKeyedObject("domain"), }), diff --git a/web/source/settings/lib/query/admin/domain-permissions/import.ts b/web/source/settings/lib/query/admin/domain-permissions/import.ts index dde488625..5476d3178 100644 --- a/web/source/settings/lib/query/admin/domain-permissions/import.ts +++ b/web/source/settings/lib/query/admin/domain-permissions/import.ts @@ -36,7 +36,7 @@ import { listToKeyedObject } from "../../transforms"; * @returns */ function importEntriesProcessor(formData: ImportDomainPermsParams): (_entry: DomainPerm) => DomainPerm { - let processingFuncs: { (_entry: DomainPerm): void; }[] = []; + const processingFuncs: { (_entry: DomainPerm): void; }[] = []; // Override each obfuscate entry if necessary. if (formData.obfuscate !== undefined) { @@ -49,7 +49,7 @@ function importEntriesProcessor(formData: ImportDomainPermsParams): (_entry: Dom // Check whether we need to append or replace // private_comment and public_comment. ["private_comment","public_comment"].forEach((commentType) => { - let text = formData.commentType?.trim(); + const text = formData.commentType?.trim(); if (!text) { return; } @@ -78,7 +78,9 @@ function importEntriesProcessor(formData: ImportDomainPermsParams): (_entry: Dom return function process(entry) { // Call all the assembled processing functions. - processingFuncs.forEach((f) => f(entry)); + processingFuncs.forEach((f) => { + f(entry); + }); // Unset all internal processing keys // and any undefined keys on this entry. @@ -111,7 +113,7 @@ const extended = gtsApi.injectEndpoints({ [JSON.stringify(domains)], { type: "application/json" }, ), - } + }, }; }, transformResponse: listToKeyedObject("domain"), @@ -125,8 +127,8 @@ const extended = gtsApi.injectEndpoints({ formData.permType.slice(1); return `domain${permType}s`; }), - }) - }) + }), + }), }); /** diff --git a/web/source/settings/lib/query/admin/domain-permissions/process.ts b/web/source/settings/lib/query/admin/domain-permissions/process.ts index 10ba88cc3..4d929f168 100644 --- a/web/source/settings/lib/query/admin/domain-permissions/process.ts +++ b/web/source/settings/lib/query/admin/domain-permissions/process.ts @@ -17,9 +17,10 @@ along with this program. If not, see . */ +import type { + ParseConfig as CSVParseConfig} from "papaparse"; import { - ParseConfig as CSVParseConfig, - parse as csvParse + parse as csvParse, } from "papaparse"; import { nanoid } from "nanoid"; @@ -75,7 +76,7 @@ function parseDomainList(list: string): DomainPerm[] { "reject_reports": true, "public_comment": false, "obfuscate": true, - } + }, }; const { data, errors } = csvParse(list, csvParseCfg); @@ -119,7 +120,7 @@ function parseDomainList(list: string): DomainPerm[] { } function deduplicateDomainList(list: DomainPerm[]): DomainPerm[] { - let domains = new Set(); + const domains = new Set(); return list.filter((entry) => { if (domains.has(entry.domain)) { return false; @@ -168,9 +169,9 @@ const extended = gtsApi.injectEndpoints({ }); return { data: validated }; - } - }) - }) + }, + }), + }), }); /** diff --git a/web/source/settings/lib/query/admin/domain-permissions/update.ts b/web/source/settings/lib/query/admin/domain-permissions/update.ts index a6b4b2039..2de87f68d 100644 --- a/web/source/settings/lib/query/admin/domain-permissions/update.ts +++ b/web/source/settings/lib/query/admin/domain-permissions/update.ts @@ -26,7 +26,7 @@ import { import { listToKeyedObject } from "../../transforms"; import type { DomainPerm, - MappedDomainPerms + MappedDomainPerms, } from "../../../types/domain-permission"; const extended = gtsApi.injectEndpoints({ @@ -37,7 +37,7 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/admin/domain_blocks`, asForm: true, body: formData, - discardEmpty: true + discardEmpty: true, }), transformResponse: listToKeyedObject("domain"), ...replaceCacheOnMutation("domainBlocks"), @@ -49,10 +49,10 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/admin/domain_allows`, asForm: true, body: formData, - discardEmpty: true + discardEmpty: true, }), transformResponse: listToKeyedObject("domain"), - ...replaceCacheOnMutation("domainAllows") + ...replaceCacheOnMutation("domainAllows"), }), removeDomainBlock: build.mutation({ @@ -63,8 +63,8 @@ const extended = gtsApi.injectEndpoints({ ...removeFromCacheOnMutation("domainBlocks", { key: (_draft, newData) => { return newData.domain; - } - }) + }, + }), }), removeDomainAllow: build.mutation({ @@ -75,8 +75,8 @@ const extended = gtsApi.injectEndpoints({ ...removeFromCacheOnMutation("domainAllows", { key: (_draft, newData) => { return newData.domain; - } - }) + }, + }), }), }), }); @@ -105,5 +105,5 @@ export { useAddDomainBlockMutation, useAddDomainAllowMutation, useRemoveDomainBlockMutation, - useRemoveDomainAllowMutation + useRemoveDomainAllowMutation, }; diff --git a/web/source/settings/lib/query/admin/http-header-permissions/index.ts b/web/source/settings/lib/query/admin/http-header-permissions/index.ts index 342b9eb56..893bcfdec 100644 --- a/web/source/settings/lib/query/admin/http-header-permissions/index.ts +++ b/web/source/settings/lib/query/admin/http-header-permissions/index.ts @@ -18,7 +18,7 @@ */ import { gtsApi } from "../../gts-api"; -import { HeaderPermission } from "../../../types/http-header-permissions"; +import type { HeaderPermission } from "../../../types/http-header-permissions"; const extended = gtsApi.injectEndpoints({ endpoints: (build) => ({ @@ -27,7 +27,7 @@ const extended = gtsApi.injectEndpoints({ getHeaderAllows: build.query({ query: () => ({ - url: `/api/v1/admin/header_allows` + url: `/api/v1/admin/header_allows`, }), providesTags: (res) => res @@ -40,7 +40,7 @@ const extended = gtsApi.injectEndpoints({ getHeaderAllow: build.query({ query: (id) => ({ - url: `/api/v1/admin/header_allows/${id}` + url: `/api/v1/admin/header_allows/${id}`, }), providesTags: (_res, _error, id) => [{ type: "HTTPHeaderAllows", id }], }), @@ -51,7 +51,7 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/admin/header_allows`, asForm: true, body: formData, - discardEmpty: true + discardEmpty: true, }), invalidatesTags: [{ type: "HTTPHeaderAllows", id: "LIST" }], }), @@ -59,7 +59,7 @@ const extended = gtsApi.injectEndpoints({ deleteHeaderAllow: build.mutation({ query: (id) => ({ method: "DELETE", - url: `/api/v1/admin/header_allows/${id}` + url: `/api/v1/admin/header_allows/${id}`, }), invalidatesTags: (_res, _error, id) => [{ type: "HTTPHeaderAllows", id }], }), @@ -68,7 +68,7 @@ const extended = gtsApi.injectEndpoints({ getHeaderBlocks: build.query({ query: () => ({ - url: `/api/v1/admin/header_blocks` + url: `/api/v1/admin/header_blocks`, }), providesTags: (res) => res @@ -85,14 +85,14 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/admin/header_blocks`, asForm: true, body: formData, - discardEmpty: true + discardEmpty: true, }), invalidatesTags: [{ type: "HTTPHeaderBlocks", id: "LIST" }], }), getHeaderBlock: build.query({ query: (id) => ({ - url: `/api/v1/admin/header_blocks/${id}` + url: `/api/v1/admin/header_blocks/${id}`, }), providesTags: (_res, _error, id) => [{ type: "HTTPHeaderBlocks", id }], }), @@ -100,7 +100,7 @@ const extended = gtsApi.injectEndpoints({ deleteHeaderBlock: build.mutation({ query: (id) => ({ method: "DELETE", - url: `/api/v1/admin/header_blocks/${id}` + url: `/api/v1/admin/header_blocks/${id}`, }), invalidatesTags: (_res, _error, id) => [{ type: "HTTPHeaderBlocks", id }], }), diff --git a/web/source/settings/lib/query/admin/index.ts b/web/source/settings/lib/query/admin/index.ts index 86388e273..08e2325f9 100644 --- a/web/source/settings/lib/query/admin/index.ts +++ b/web/source/settings/lib/query/admin/index.ts @@ -20,8 +20,8 @@ import { replaceCacheOnMutation, removeFromCacheOnMutation } from "../query-modifiers"; import { gtsApi } from "../gts-api"; import { listToKeyedObject } from "../transforms"; -import { ActionAccountParams, AdminAccount, HandleSignupParams, SearchAccountParams, SearchAccountResp } from "../../types/account"; -import { InstanceRule, MappedRules } from "../../types/rules"; +import type { ActionAccountParams, AdminAccount, HandleSignupParams, SearchAccountParams, SearchAccountResp } from "../../types/account"; +import type { InstanceRule, MappedRules } from "../../types/rules"; import parse from "parse-link-header"; const extended = gtsApi.injectEndpoints({ @@ -32,17 +32,17 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/instance`, asForm: true, body: formData, - discardEmpty: true + discardEmpty: true, }), ...replaceCacheOnMutation("instanceV1"), }), getAccount: build.query({ query: (id) => ({ - url: `/api/v1/admin/accounts/${id}` + url: `/api/v1/admin/accounts/${id}`, }), providesTags: (_result, _error, id) => [ - { type: 'Account', id } + { type: 'Account', id }, ], }), @@ -61,7 +61,7 @@ const extended = gtsApi.injectEndpoints({ } return { - url: `/api/v2/admin/accounts${query}` + url: `/api/v2/admin/accounts${query}`, }; }, // Headers required for paging. @@ -73,7 +73,7 @@ const extended = gtsApi.injectEndpoints({ }, // Only provide LIST tag id since this model is not the // same as getAccount model (due to transformResponse). - providesTags: [{ type: "Account", id: "TRANSFORMED" }] + providesTags: [{ type: "Account", id: "TRANSFORMED" }], }), actionAccount: build.mutation({ @@ -83,8 +83,8 @@ const extended = gtsApi.injectEndpoints({ asForm: true, body: { type: action, - text: reason - } + text: reason, + }, }), // Do an optimistic update on this account to mark // it according to whatever action was submitted. @@ -95,7 +95,7 @@ const extended = gtsApi.injectEndpoints({ draft.suspended = true; draft.account.suspended = true; } - }) + }), ); // Revert optimistic @@ -105,7 +105,7 @@ const extended = gtsApi.injectEndpoints({ } catch { patchResult.undo(); } - } + }, }), handleSignup: build.mutation({ @@ -124,7 +124,7 @@ const extended = gtsApi.injectEndpoints({ // Just invalidate this ID and getAccounts. dispatch(extended.util.invalidateTags([ { type: "Account", id: id }, - { type: "Account", id: "TRANSFORMED" } + { type: "Account", id: "TRANSFORMED" }, ])); return; } @@ -132,7 +132,7 @@ const extended = gtsApi.injectEndpoints({ const patchResult = dispatch( extended.util.updateQueryData("getAccount", id, (draft) => { draft.approved = true; - }) + }), ); // Revert optimistic @@ -142,14 +142,14 @@ const extended = gtsApi.injectEndpoints({ } catch { patchResult.undo(); } - } + }, }), instanceRules: build.query({ query: () => ({ - url: `/api/v1/admin/instance/rules` + url: `/api/v1/admin/instance/rules`, }), - transformResponse: listToKeyedObject("id") + transformResponse: listToKeyedObject("id"), }), addInstanceRule: build.mutation({ @@ -158,7 +158,7 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/admin/instance/rules`, asForm: true, body: formData, - discardEmpty: true + discardEmpty: true, }), transformResponse: listToKeyedObject("id"), ...replaceCacheOnMutation("instanceRules"), @@ -170,11 +170,11 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/admin/instance/rules/${id}`, asForm: true, body: edit, - discardEmpty: true + discardEmpty: true, }), transformResponse: (data) => { return { - [data.id]: data + [data.id]: data, }; }, ...replaceCacheOnMutation("instanceRules"), @@ -183,13 +183,13 @@ const extended = gtsApi.injectEndpoints({ deleteInstanceRule: build.mutation({ query: (id) => ({ method: "DELETE", - url: `/api/v1/admin/instance/rules/${id}` + url: `/api/v1/admin/instance/rules/${id}`, }), ...removeFromCacheOnMutation("instanceRules", { key: (_draft, rule) => rule.id, - }) - }) - }) + }), + }), + }), }); export const { diff --git a/web/source/settings/lib/query/admin/reports/index.ts b/web/source/settings/lib/query/admin/reports/index.ts index 6430cd6b1..3d7ab50c8 100644 --- a/web/source/settings/lib/query/admin/reports/index.ts +++ b/web/source/settings/lib/query/admin/reports/index.ts @@ -44,7 +44,7 @@ const extended = gtsApi.injectEndpoints({ } return { - url: `/api/v1/admin/reports${query}` + url: `/api/v1/admin/reports${query}`, }; }, // Headers required for paging. @@ -56,15 +56,15 @@ const extended = gtsApi.injectEndpoints({ }, // Only provide LIST tag id since this model is not the // same as getReport model (due to transformResponse). - providesTags: [{ type: "Report", id: "TRANSFORMED" }] + providesTags: [{ type: "Report", id: "TRANSFORMED" }], }), getReport: build.query({ query: (id) => ({ - url: `/api/v1/admin/reports/${id}` + url: `/api/v1/admin/reports/${id}`, }), providesTags: (_result, _error, id) => [ - { type: 'Report', id } + { type: 'Report', id }, ], }), @@ -73,14 +73,14 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/admin/reports/${formData.id}/resolve`, method: "POST", asForm: true, - body: formData + body: formData, }), invalidatesTags: (res) => res ? [{ type: "Report", id: "TRANSFORMED" }, { type: "Report", id: res.id }] - : [{ type: "Report", id: "TRANSFORMED" }] - }) - }) + : [{ type: "Report", id: "TRANSFORMED" }], + }), + }), }); /** diff --git a/web/source/settings/lib/query/gts-api.ts b/web/source/settings/lib/query/gts-api.ts index 911ea58c7..c23ff7bc0 100644 --- a/web/source/settings/lib/query/gts-api.ts +++ b/web/source/settings/lib/query/gts-api.ts @@ -26,7 +26,7 @@ import type { import { serialize as serializeForm } from "object-to-formdata"; import type { FetchBaseQueryMeta } from "@reduxjs/toolkit/dist/query/fetchBaseQuery"; import type { RootState } from '../../redux/store'; -import { InstanceV1 } from '../types/instance'; +import type { InstanceV1 } from '../types/instance'; /** * GTSFetchArgs extends standard FetchArgs used by @@ -173,10 +173,10 @@ export const gtsApi = createApi({ endpoints: (build) => ({ instanceV1: build.query({ query: () => ({ - url: `/api/v1/instance` - }) - }) - }) + url: `/api/v1/instance`, + }), + }), + }), }); /** diff --git a/web/source/settings/lib/query/oauth/index.ts b/web/source/settings/lib/query/oauth/index.ts index baf20f748..545092b0e 100644 --- a/web/source/settings/lib/query/oauth/index.ts +++ b/web/source/settings/lib/query/oauth/index.ts @@ -25,8 +25,8 @@ import { remove as oauthRemove, authorize as oauthAuthorize, } from "../../../redux/oauth"; -import { RootState } from '../../../redux/store'; -import { Account } from '../../types/account'; +import type { RootState } from '../../../redux/store'; +import type { Account } from '../../types/account'; export interface OauthTokenRequestBody { client_id: string; @@ -45,7 +45,7 @@ function getSettingsURL() { Also drops anything past /settings/, because authorization urls that are too long get rejected by GTS. */ - let [pre, _past] = window.location.pathname.split("/settings"); + const [pre, _past] = window.location.pathname.split("/settings"); return `${window.location.origin}${pre}/settings`; } @@ -71,14 +71,14 @@ const extended = gtsApi.injectEndpoints({ // return a standard verify_credentials query. if (oauthState.loginState != 'callback') { return fetchWithBQ({ - url: `/api/v1/accounts/verify_credentials` + url: `/api/v1/accounts/verify_credentials`, }); } // We're in the middle of an auth/callback flow. // Try to retrieve callback code from URL query. - let urlParams = new URLSearchParams(window.location.search); - let code = urlParams.get("code"); + const urlParams = new URLSearchParams(window.location.search); + const code = urlParams.get("code"); if (code == undefined) { return { error: { @@ -91,7 +91,7 @@ const extended = gtsApi.injectEndpoints({ // Retrieve app with which the // callback code was generated. - let app = oauthState.app; + const app = oauthState.app; if (app == undefined || app.client_id == undefined) { return { error: { @@ -109,7 +109,7 @@ const extended = gtsApi.injectEndpoints({ client_secret: app.client_secret, redirect_uri: SETTINGS_URL, grant_type: "authorization_code", - code: code + code: code, }; const tokenResult = await fetchWithBQ({ @@ -118,7 +118,7 @@ const extended = gtsApi.injectEndpoints({ body: tokenReqBody, }); if (tokenResult.error) { - return { error: tokenResult.error as FetchBaseQueryError }; + return { error: tokenResult.error }; } // Remove ?code= query param from @@ -131,9 +131,9 @@ const extended = gtsApi.injectEndpoints({ // We're now authed! So return // standard verify_credentials query. return fetchWithBQ({ - url: `/api/v1/accounts/verify_credentials` + url: `/api/v1/accounts/verify_credentials`, }); - } + }, }), authorizeFlow: build.mutation({ @@ -147,7 +147,7 @@ const extended = gtsApi.injectEndpoints({ } instanceUrl = new URL(formData.instance).origin; - if (oauthState?.instanceUrl == instanceUrl && oauthState.app) { + if (oauthState.instanceUrl == instanceUrl && oauthState.app) { return { data: oauthState.app }; } @@ -159,31 +159,31 @@ const extended = gtsApi.injectEndpoints({ client_name: "GoToSocial Settings", scopes: formData.scopes, redirect_uris: SETTINGS_URL, - website: SETTINGS_URL - } + website: SETTINGS_URL, + }, }); if (appResult.error) { - return { error: appResult.error as FetchBaseQueryError }; + return { error: appResult.error }; } - let app = appResult.data as any; + const app = appResult.data; app.scopes = formData.scopes; api.dispatch(oauthAuthorize({ instanceUrl: instanceUrl, app: app, loginState: "callback", - expectingRedirect: true + expectingRedirect: true, })); - let url = new URL(instanceUrl); + const url = new URL(instanceUrl); url.pathname = "/oauth/authorize"; url.searchParams.set("client_id", app.client_id); url.searchParams.set("redirect_uri", SETTINGS_URL); url.searchParams.set("response_type", "code"); url.searchParams.set("scope", app.scopes); - let redirectURL = url.toString(); + const redirectURL = url.toString(); window.location.assign(redirectURL); return { data: null }; }, @@ -193,9 +193,9 @@ const extended = gtsApi.injectEndpoints({ api.dispatch(oauthRemove()); return { data: null }; }, - invalidatesTags: ["Auth"] - }) - }) + invalidatesTags: ["Auth"], + }), + }), }); export const { diff --git a/web/source/settings/lib/query/query-modifiers.ts b/web/source/settings/lib/query/query-modifiers.ts index a80784d04..de24f3b06 100644 --- a/web/source/settings/lib/query/query-modifiers.ts +++ b/web/source/settings/lib/query/query-modifiers.ts @@ -86,13 +86,13 @@ function makeCacheMutation(action: Action): CacheMutation { key = key(draft, newData); } action(draft, newData, { key }); - }) + }), ); } catch (e) { - // eslint-disable-next-line no-console + console.error(`rolling back pessimistic update of ${queryName}: ${JSON.stringify(e)}`); } - } + }, }; }; } diff --git a/web/source/settings/lib/query/user/export-import.ts b/web/source/settings/lib/query/user/export-import.ts index 006203a68..f332a2c3b 100644 --- a/web/source/settings/lib/query/user/export-import.ts +++ b/web/source/settings/lib/query/user/export-import.ts @@ -20,15 +20,15 @@ import fileDownload from "js-file-download"; import { gtsApi } from "../gts-api"; -import { FetchBaseQueryError } from "@reduxjs/toolkit/query"; -import { AccountExportStats } from "../../types/account"; +import type { FetchBaseQueryError } from "@reduxjs/toolkit/query"; +import type { AccountExportStats } from "../../types/account"; const extended = gtsApi.injectEndpoints({ endpoints: (build) => ({ exportStats: build.query({ query: () => ({ - url: `/api/v1/exports/stats` - }) + url: `/api/v1/exports/stats`, + }), }), exportFollowing: build.mutation({ @@ -38,7 +38,7 @@ const extended = gtsApi.injectEndpoints({ acceptContentType: "text/csv", }); if (csvRes.error) { - return { error: csvRes.error as FetchBaseQueryError }; + return { error: csvRes.error }; } if (csvRes.meta?.response?.status !== 200) { @@ -47,7 +47,7 @@ const extended = gtsApi.injectEndpoints({ fileDownload(csvRes.data, "following.csv", "text/csv"); return { data: null }; - } + }, }), exportFollowers: build.mutation({ @@ -57,7 +57,7 @@ const extended = gtsApi.injectEndpoints({ acceptContentType: "text/csv", }); if (csvRes.error) { - return { error: csvRes.error as FetchBaseQueryError }; + return { error: csvRes.error }; } if (csvRes.meta?.response?.status !== 200) { @@ -66,7 +66,7 @@ const extended = gtsApi.injectEndpoints({ fileDownload(csvRes.data, "followers.csv", "text/csv"); return { data: null }; - } + }, }), exportLists: build.mutation({ @@ -76,7 +76,7 @@ const extended = gtsApi.injectEndpoints({ acceptContentType: "text/csv", }); if (csvRes.error) { - return { error: csvRes.error as FetchBaseQueryError }; + return { error: csvRes.error }; } if (csvRes.meta?.response?.status !== 200) { @@ -85,7 +85,7 @@ const extended = gtsApi.injectEndpoints({ fileDownload(csvRes.data, "lists.csv", "text/csv"); return { data: null }; - } + }, }), exportBlocks: build.mutation({ @@ -95,7 +95,7 @@ const extended = gtsApi.injectEndpoints({ acceptContentType: "text/csv", }); if (csvRes.error) { - return { error: csvRes.error as FetchBaseQueryError }; + return { error: csvRes.error }; } if (csvRes.meta?.response?.status !== 200) { @@ -104,7 +104,7 @@ const extended = gtsApi.injectEndpoints({ fileDownload(csvRes.data, "blocks.csv", "text/csv"); return { data: null }; - } + }, }), exportMutes: build.mutation({ @@ -114,7 +114,7 @@ const extended = gtsApi.injectEndpoints({ acceptContentType: "text/csv", }); if (csvRes.error) { - return { error: csvRes.error as FetchBaseQueryError }; + return { error: csvRes.error }; } if (csvRes.meta?.response?.status !== 200) { @@ -123,7 +123,7 @@ const extended = gtsApi.injectEndpoints({ fileDownload(csvRes.data, "mutes.csv", "text/csv"); return { data: null }; - } + }, }), importData: build.mutation({ @@ -132,10 +132,10 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/import`, asForm: true, body: formData, - discardEmpty: true + discardEmpty: true, }), }), - }) + }), }); export const { diff --git a/web/source/settings/lib/query/user/index.ts b/web/source/settings/lib/query/user/index.ts index 0df926eb3..f5f36cfb4 100644 --- a/web/source/settings/lib/query/user/index.ts +++ b/web/source/settings/lib/query/user/index.ts @@ -21,11 +21,11 @@ import { replaceCacheOnMutation } from "../query-modifiers"; import { gtsApi } from "../gts-api"; import type { MoveAccountFormData, - UpdateAliasesFormData + UpdateAliasesFormData, } from "../../types/migration"; import type { Theme } from "../../types/theme"; -import { User } from "../../types/user"; -import { DefaultInteractionPolicies, UpdateDefaultInteractionPolicies } from "../../types/interaction"; +import type { User } from "../../types/user"; +import type { DefaultInteractionPolicies, UpdateDefaultInteractionPolicies } from "../../types/interaction"; const extended = gtsApi.injectEndpoints({ endpoints: (build) => ({ @@ -35,36 +35,36 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/accounts/update_credentials`, asForm: true, body: formData, - discardEmpty: true + discardEmpty: true, }), - ...replaceCacheOnMutation("verifyCredentials") + ...replaceCacheOnMutation("verifyCredentials"), }), user: build.query({ - query: () => ({url: `/api/v1/user`}) + query: () => ({url: `/api/v1/user`}), }), passwordChange: build.mutation({ query: (data) => ({ method: "POST", url: `/api/v1/user/password_change`, - body: data - }) + body: data, + }), }), emailChange: build.mutation({ query: (data) => ({ method: "POST", url: `/api/v1/user/email_change`, - body: data + body: data, }), - ...replaceCacheOnMutation("user") + ...replaceCacheOnMutation("user"), }), aliasAccount: build.mutation({ async queryFn(formData, _api, _extraOpts, fetchWithBQ) { // Pull entries out from the hooked form. - const entries: String[] = []; + const entries: string[] = []; formData.also_known_as_uris.forEach(entry => { if (entry) { entries.push(entry); @@ -76,28 +76,28 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/accounts/alias`, body: { also_known_as_uris: entries }, }); - } + }, }), moveAccount: build.mutation({ query: (data) => ({ method: "POST", url: `/api/v1/accounts/move`, - body: data - }) + body: data, + }), }), accountThemes: build.query({ query: () => ({ - url: `/api/v1/accounts/themes` - }) + url: `/api/v1/accounts/themes`, + }), }), defaultInteractionPolicies: build.query({ query: () => ({ - url: `/api/v1/interaction_policies/defaults` + url: `/api/v1/interaction_policies/defaults`, }), - providesTags: ["DefaultInteractionPolicies"] + providesTags: ["DefaultInteractionPolicies"], }), updateDefaultInteractionPolicies: build.mutation({ @@ -106,7 +106,7 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/interaction_policies/defaults`, body: data, }), - ...replaceCacheOnMutation("defaultInteractionPolicies") + ...replaceCacheOnMutation("defaultInteractionPolicies"), }), resetDefaultInteractionPolicies: build.mutation({ @@ -115,9 +115,9 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/interaction_policies/defaults`, body: {}, }), - invalidatesTags: ["DefaultInteractionPolicies"] + invalidatesTags: ["DefaultInteractionPolicies"], }), - }) + }), }); export const { diff --git a/web/source/settings/lib/query/user/interactions.ts b/web/source/settings/lib/query/user/interactions.ts index 04e3a74ff..b55d519cb 100644 --- a/web/source/settings/lib/query/user/interactions.ts +++ b/web/source/settings/lib/query/user/interactions.ts @@ -17,7 +17,7 @@ along with this program. If not, see . */ -import { +import type { InteractionRequest, SearchInteractionRequestsParams, SearchInteractionRequestsResp, @@ -33,7 +33,7 @@ const extended = gtsApi.injectEndpoints({ url: `/api/v1/interaction_requests/${id}`, }), providesTags: (_result, _error, id) => [ - { type: 'InteractionRequest', id } + { type: 'InteractionRequest', id }, ], }), @@ -52,7 +52,7 @@ const extended = gtsApi.injectEndpoints({ } return { - url: `/api/v1/interaction_requests${query}` + url: `/api/v1/interaction_requests${query}`, }; }, // Headers required for paging. @@ -62,7 +62,7 @@ const extended = gtsApi.injectEndpoints({ const links = parse(linksStr); return { requests, links }; }, - providesTags: [{ type: "InteractionRequest", id: "TRANSFORMED" }] + providesTags: [{ type: "InteractionRequest", id: "TRANSFORMED" }], }), approveInteractionRequest: build.mutation({ @@ -73,7 +73,7 @@ const extended = gtsApi.injectEndpoints({ invalidatesTags: (res) => res ? [{ type: "InteractionRequest", id: "TRANSFORMED" }, { type: "InteractionRequest", id: res.id }] - : [{ type: "InteractionRequest", id: "TRANSFORMED" }] + : [{ type: "InteractionRequest", id: "TRANSFORMED" }], }), rejectInteractionRequest: build.mutation({ @@ -84,9 +84,9 @@ const extended = gtsApi.injectEndpoints({ invalidatesTags: (res) => res ? [{ type: "InteractionRequest", id: "TRANSFORMED" }, { type: "InteractionRequest", id: res.id }] - : [{ type: "InteractionRequest", id: "TRANSFORMED" }] + : [{ type: "InteractionRequest", id: "TRANSFORMED" }], }), - }) + }), }); export const { diff --git a/web/source/settings/lib/types/account.ts b/web/source/settings/lib/types/account.ts index 76055ba53..6c6815f3e 100644 --- a/web/source/settings/lib/types/account.ts +++ b/web/source/settings/lib/types/account.ts @@ -17,8 +17,8 @@ along with this program. If not, see . */ -import { Links } from "parse-link-header"; -import { CustomEmoji } from "./custom-emoji"; +import type { Links } from "parse-link-header"; +import type { CustomEmoji } from "./custom-emoji"; export interface AdminAccount { id: string, diff --git a/web/source/settings/lib/types/domain-permission.ts b/web/source/settings/lib/types/domain-permission.ts index ccf7c9c57..d02cc736b 100644 --- a/web/source/settings/lib/types/domain-permission.ts +++ b/web/source/settings/lib/types/domain-permission.ts @@ -18,7 +18,7 @@ */ import typia from "typia"; -import { PermType } from "./perm"; +import type { PermType } from "./perm"; export const validateDomainPerms = typia.createValidate(); diff --git a/web/source/settings/lib/types/instance.ts b/web/source/settings/lib/types/instance.ts index 11f75032c..99d6196c2 100644 --- a/web/source/settings/lib/types/instance.ts +++ b/web/source/settings/lib/types/instance.ts @@ -18,80 +18,80 @@ */ export interface InstanceV1 { - uri: string; - account_domain: string; - title: string; - description: string; - description_text?: string; - short_description: string; - short_description_text?: string; - email: string; - version: string; - debug?: boolean; - languages: any[]; // TODO: define this - registrations: boolean; - approval_required: boolean; - invites_enabled: boolean; - configuration: InstanceConfiguration; - urls: InstanceUrls; - stats: InstanceStats; - thumbnail: string; - contact_account: Object; // TODO: define this. - max_toot_chars: number; - rules: any[]; // TODO: define this - terms?: string; - terms_text?: string; + uri: string; + account_domain: string; + title: string; + description: string; + description_text?: string; + short_description: string; + short_description_text?: string; + email: string; + version: string; + debug?: boolean; + languages: any[]; // TODO: define this + registrations: boolean; + approval_required: boolean; + invites_enabled: boolean; + configuration: InstanceConfiguration; + urls: InstanceUrls; + stats: InstanceStats; + thumbnail: string; + contact_account: object; // TODO: define this. + max_toot_chars: number; + rules: any[]; // TODO: define this + terms?: string; + terms_text?: string; } export interface InstanceConfiguration { - statuses: InstanceStatuses; - media_attachments: InstanceMediaAttachments; - polls: InstancePolls; - accounts: InstanceAccounts; - emojis: InstanceEmojis; - oidc_enabled?: boolean; + statuses: InstanceStatuses; + media_attachments: InstanceMediaAttachments; + polls: InstancePolls; + accounts: InstanceAccounts; + emojis: InstanceEmojis; + oidc_enabled?: boolean; } export interface InstanceAccounts { - allow_custom_css: boolean; - max_featured_tags: number; - max_profile_fields: number; + allow_custom_css: boolean; + max_featured_tags: number; + max_profile_fields: number; } export interface InstanceEmojis { - emoji_size_limit: number; + emoji_size_limit: number; } export interface InstanceMediaAttachments { - supported_mime_types: string[]; - image_size_limit: number; - image_matrix_limit: number; - video_size_limit: number; - video_frame_rate_limit: number; - video_matrix_limit: number; + supported_mime_types: string[]; + image_size_limit: number; + image_matrix_limit: number; + video_size_limit: number; + video_frame_rate_limit: number; + video_matrix_limit: number; } export interface InstancePolls { - max_options: number; - max_characters_per_option: number; - min_expiration: number; - max_expiration: number; + max_options: number; + max_characters_per_option: number; + min_expiration: number; + max_expiration: number; } export interface InstanceStatuses { - max_characters: number; - max_media_attachments: number; - characters_reserved_per_url: number; - supported_mime_types: string[]; + max_characters: number; + max_media_attachments: number; + characters_reserved_per_url: number; + supported_mime_types: string[]; } export interface InstanceStats { - domain_count: number; - status_count: number; - user_count: number; + domain_count: number; + status_count: number; + user_count: number; } export interface InstanceUrls { - streaming_api: string; + streaming_api: string; } diff --git a/web/source/settings/lib/types/interaction.ts b/web/source/settings/lib/types/interaction.ts index caedd9544..4061fe0f2 100644 --- a/web/source/settings/lib/types/interaction.ts +++ b/web/source/settings/lib/types/interaction.ts @@ -17,9 +17,9 @@ along with this program. If not, see . */ -import { Links } from "parse-link-header"; -import { Account } from "./account"; -import { Status } from "./status"; +import type { Links } from "parse-link-header"; +import type { Account } from "./account"; +import type { Status } from "./status"; export interface DefaultInteractionPolicies { direct: InteractionPolicy; @@ -71,7 +71,7 @@ export { * Interaction request targeting a status by an account. */ export interface InteractionRequest { - /** + /** * ID of the request. */ id: string; diff --git a/web/source/settings/lib/types/query.ts b/web/source/settings/lib/types/query.ts index 8e6901b76..df5646ebd 100644 --- a/web/source/settings/lib/types/query.ts +++ b/web/source/settings/lib/types/query.ts @@ -17,7 +17,7 @@ along with this program. If not, see . */ -import { Draft } from "@reduxjs/toolkit"; +import type { Draft } from "@reduxjs/toolkit"; /** * Pass into a query when you don't @@ -46,25 +46,25 @@ interface MutationStartedParams { /** * A method to get the current state for the store. */ - getState, + getState, /** * extra as provided as thunk.extraArgument to the configureStore getDefaultMiddleware option. */ - extra, + extra, /** * A unique ID generated for the query/mutation. */ - requestId, + requestId, /** * A Promise that will resolve with a data property (the transformed query result), and a * meta property (meta returned by the baseQuery). If the query fails, this Promise will * reject with the error. This allows you to await for the query to finish. */ - queryFulfilled, + queryFulfilled, /** * A function that gets the current value of the cache entry. */ - getCacheEntry, + getCacheEntry, } export type Action = ( diff --git a/web/source/settings/lib/types/report.ts b/web/source/settings/lib/types/report.ts index 4ef694be6..296b99149 100644 --- a/web/source/settings/lib/types/report.ts +++ b/web/source/settings/lib/types/report.ts @@ -17,16 +17,16 @@ along with this program. If not, see . */ -import { Links } from "parse-link-header"; -import { AdminAccount } from "./account"; -import { Status } from "./status"; +import type { Links } from "parse-link-header"; +import type { AdminAccount } from "./account"; +import type { Status } from "./status"; /** * Admin model of a report. Differs from the client * model, which contains less detailed information. */ export interface AdminReport { - /** + /** * ID of the report. */ id: string; @@ -83,7 +83,7 @@ export interface AdminReport { * Rules broken according to the reporter, if any. * TODO: model this properly. */ - rules: Object[]; + rules: object[]; /** * Comment stored about what action (if any) was taken. */ @@ -94,7 +94,7 @@ export interface AdminReport { * Parameters for POST to /api/v1/admin/reports/{id}/resolve. */ export interface AdminReportResolveParams { - /** + /** * The ID of the report to resolve. */ id: string; diff --git a/web/source/settings/lib/types/status.ts b/web/source/settings/lib/types/status.ts index e46f4a6b7..dc1f55629 100644 --- a/web/source/settings/lib/types/status.ts +++ b/web/source/settings/lib/types/status.ts @@ -17,8 +17,8 @@ along with this program. If not, see . */ -import { Account } from "./account"; -import { CustomEmoji } from "./custom-emoji"; +import type { Account } from "./account"; +import type { CustomEmoji } from "./custom-emoji"; export interface Status { id: string; diff --git a/web/source/settings/lib/util/domain-permission.ts b/web/source/settings/lib/util/domain-permission.ts index b8dcbc8aa..19299569c 100644 --- a/web/source/settings/lib/util/domain-permission.ts +++ b/web/source/settings/lib/util/domain-permission.ts @@ -29,7 +29,7 @@ import { get } from "psl"; export function isValidDomainPermission(domain: string): boolean { return isValidDomain(domain, { wildcard: false, - allowUnicode: true + allowUnicode: true, }); } diff --git a/web/source/settings/lib/util/index.ts b/web/source/settings/lib/util/index.ts index d016f3398..d2a1d8f70 100644 --- a/web/source/settings/lib/util/index.ts +++ b/web/source/settings/lib/util/index.ts @@ -19,7 +19,7 @@ import { useMemo } from "react"; -import { AdminAccount } from "../types/account"; +import type { AdminAccount } from "../types/account"; import { store } from "../../redux/store"; export function yesOrNo(b: boolean): string { diff --git a/web/source/settings/redux/checklist.ts b/web/source/settings/redux/checklist.ts index d99f749ba..db2ce4195 100644 --- a/web/source/settings/redux/checklist.ts +++ b/web/source/settings/redux/checklist.ts @@ -17,7 +17,8 @@ along with this program. If not, see . */ -import { PayloadAction, createSlice } from "@reduxjs/toolkit"; +import type { PayloadAction} from "@reduxjs/toolkit"; +import { createSlice } from "@reduxjs/toolkit"; import type { Checkable } from "../lib/form/types"; import { useReducer } from "react"; @@ -57,12 +58,12 @@ function initialHookState({ } return [ key, { ...entry, key, checked } ]; - }) + }), ); return { entries: mappedEntries, - selectedEntries + selectedEntries, }; } @@ -81,7 +82,7 @@ const checklistSlice = createSlice({ } return [entry.key, { ...entry, checked } ]; - }) + }), ); return { entries, selectedEntries }; @@ -97,7 +98,7 @@ const checklistSlice = createSlice({ state.entries[key] = { ...state.entries[key], - ...value + ...value, }; }, updateMultiple: (state, { payload }: PayloadAction]>>) => { @@ -112,11 +113,11 @@ const checklistSlice = createSlice({ state.entries[key] = { ...state.entries[key], - ...value + ...value, }; }); - } - } + }, + }, }); export const actions = checklistSlice.actions; @@ -153,6 +154,6 @@ export const useChecklistReducer = (entries: Checkable[], uniqueKey: string, ini return useReducer( checklistSlice.reducer, initialState, - (_) => initialHookState({ entries, uniqueKey, initialValue }) + (_) => initialHookState({ entries, uniqueKey, initialValue }), ); }; diff --git a/web/source/settings/redux/oauth.ts b/web/source/settings/redux/oauth.ts index 1d6bf9bb1..a3c5c0214 100644 --- a/web/source/settings/redux/oauth.ts +++ b/web/source/settings/redux/oauth.ts @@ -17,7 +17,8 @@ along with this program. If not, see . */ -import { PayloadAction, createSlice } from "@reduxjs/toolkit"; +import type { PayloadAction} from "@reduxjs/toolkit"; +import { createSlice } from "@reduxjs/toolkit"; /** * OAuthToken represents a response @@ -78,8 +79,8 @@ export const oauthSlice = createSlice({ delete state.token; delete state.app; state.loginState = "logout"; - } - } + }, + }, }); export const { diff --git a/web/source/settings/redux/store.ts b/web/source/settings/redux/store.ts index 0c1285187..22a352317 100644 --- a/web/source/settings/redux/store.ts +++ b/web/source/settings/redux/store.ts @@ -50,13 +50,13 @@ const persistedReducer = persistReducer({ // This is a cheeky workaround for // redux-persist being a stickler. - let anyState = state as any; + const anyState = state as any; if (anyState?.oauth != undefined) { anyState.oauth.expectingRedirect = false; } return anyState; - } + }, }, combinedReducers); export const store = configureStore({ @@ -71,10 +71,10 @@ export const store = configureStore({ PERSIST, PURGE, REGISTER, - ] - } + ], + }, }).concat(gtsApi.middleware); - } + }, }); export const persistor = persistStore(store); diff --git a/web/source/settings/views/admin/actions/email/test.tsx b/web/source/settings/views/admin/actions/email/test.tsx index 09b7ed909..c895c33c0 100644 --- a/web/source/settings/views/admin/actions/email/test.tsx +++ b/web/source/settings/views/admin/actions/email/test.tsx @@ -30,7 +30,7 @@ export default function Test({}) { const form = { email: useTextInput("email", { defaultValue: instance?.email }), - message: useTextInput("message") + message: useTextInput("message"), }; const [submit, result] = useFormSubmit(form, useSendTestEmailMutation(), { changedOnly: false }); diff --git a/web/source/settings/views/admin/actions/keys/expireremote.tsx b/web/source/settings/views/admin/actions/keys/expireremote.tsx index 1d62f9439..bd14d512d 100644 --- a/web/source/settings/views/admin/actions/keys/expireremote.tsx +++ b/web/source/settings/views/admin/actions/keys/expireremote.tsx @@ -47,7 +47,7 @@ export default function ExpireRemote({}) { } return "invalid domain"; - } + }, }); const [expire, expireResult] = useInstanceKeysExpireMutation(); diff --git a/web/source/settings/views/admin/debug/apurl/index.tsx b/web/source/settings/views/admin/debug/apurl/index.tsx index b66794132..45950c6a3 100644 --- a/web/source/settings/views/admin/debug/apurl/index.tsx +++ b/web/source/settings/views/admin/debug/apurl/index.tsx @@ -22,7 +22,7 @@ import { useTextInput } from "../../../../lib/form"; import { useLazyApURLQuery } from "../../../../lib/query/admin/debug"; import { TextInput } from "../../../../components/form/inputs"; import MutationButton from "../../../../components/form/mutation-button"; -import { ApURLResponse } from "../../../../lib/types/debug"; +import type { ApURLResponse } from "../../../../lib/types/debug"; import Loading from "../../../../components/loading"; // Used for syntax highlighting of json result. diff --git a/web/source/settings/views/admin/emoji/category-select.tsx b/web/source/settings/views/admin/emoji/category-select.tsx index fabcad9b6..ccc29b18f 100644 --- a/web/source/settings/views/admin/emoji/category-select.tsx +++ b/web/source/settings/views/admin/emoji/category-select.tsx @@ -17,12 +17,13 @@ along with this program. If not, see . */ -import React, { useMemo, useEffect, PropsWithChildren, ReactElement } from "react"; +import type { PropsWithChildren, ReactElement } from "react"; +import React, { useMemo, useEffect } from "react"; import { matchSorter } from "match-sorter"; import ComboBox from "../../../components/combo-box"; import { useListEmojiQuery } from "../../../lib/query/admin/custom-emoji"; -import { CustomEmoji } from "../../../lib/types/custom-emoji"; -import { ComboboxFormInputHook } from "../../../lib/form/types"; +import type { CustomEmoji } from "../../../lib/types/custom-emoji"; +import type { ComboboxFormInputHook } from "../../../lib/form/types"; import Loading from "../../../components/loading"; import { Error } from "../../../components/error"; @@ -97,7 +98,7 @@ export function CategorySelect({ field, children }: PropsWithChildren