chore(deps): upgrade dependencies for frontend + lint fixes

Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
Erik Michelson 2024-10-23 00:32:55 +02:00
parent f121ca3458
commit df6540163c
15 changed files with 681 additions and 357 deletions

View file

@ -44,7 +44,7 @@ export interface InitTask {
const fetchUserInformation = async (): Promise<void> => {
try {
await fetchAndSetUser()
} catch (error) {
} catch {
logger.error("Couldn't load user. Probably not logged in.")
}
}

View file

@ -46,7 +46,7 @@ describe('Copy to clipboard button', () => {
const mockClipboard = (copyIsSuccessful: boolean): jest.Mock => {
const writeTextToClipboardSpy = jest.fn(() =>
copyIsSuccessful ? Promise.resolve() : Promise.reject('mocked clipboard failed')
copyIsSuccessful ? Promise.resolve() : Promise.reject(new Error('mocked clipboard failed'))
)
Object.assign(global.navigator, {
clipboard: {

View file

@ -23,7 +23,11 @@ export const Redirect: React.FC<RedirectProps> = ({ to, replace }) => {
const router = useRouter()
useEffect(() => {
replace ? router.replace(to) : router.push(to)
if (replace) {
router.replace(to)
} else {
router.push(to)
}
}, [replace, router, to])
return (

View file

@ -32,6 +32,8 @@ export const UploadInput: React.FC<UploadInputProps> = ({ onLoad, allowedFileTyp
}, [])
const onChange = useCallback<React.ChangeEventHandler<HTMLInputElement>>(
// TODO Check and fix this
// eslint-disable-next-line @typescript-eslint/no-misused-promises
async (event) => {
const fileInput = event.currentTarget
if (!fileInput.files || fileInput.files.length < 1) {

View file

@ -28,7 +28,7 @@ describe('fetch motd', () => {
): jest.SpyInstance<Promise<Response>> => {
return jest.spyOn(global, 'fetch').mockImplementation((url: RequestInfo | URL) => {
if (url !== motdUrl) {
return Promise.reject('wrong url')
return Promise.reject(new Error('wrong url'))
}
return Promise.resolve(
Mock.of<Response>({

View file

@ -39,7 +39,7 @@ export class AnchorNodePreprocessor extends TravelerNodeProcessor {
try {
node.attribs.href = new URL(url, this.baseUrl).toString()
} catch (e) {
} catch {
node.attribs.href = url
}
}

View file

@ -74,7 +74,8 @@ export class NodeToReactTransformer {
* @return the created react element
*/
private translateElementToReactElement(element: Element, index: number | string): ValidReactDomElement {
const elementKey = this.calculateUniqueKey(element).orElseGet(() => (-index).toString())
const numericIndex = typeof index === 'number' ? index : Number.parseInt(index)
const elementKey = this.calculateUniqueKey(element).orElseGet(() => (-numericIndex).toString())
const replacement = this.findElementReplacement(element, elementKey)
if (replacement === null) {
return null