mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-04-15 16:36:29 +00:00
Fix linting errors
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
74b0562fc8
commit
c017df0a3c
24 changed files with 35 additions and 33 deletions
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import i18n from 'i18next'
|
||||
import i18n, { ResourceKey } from 'i18next'
|
||||
import LanguageDetector from 'i18next-browser-languagedetector'
|
||||
import resourcesToBackend from 'i18next-resources-to-backend'
|
||||
import { Settings } from 'luxon'
|
||||
|
@ -15,10 +15,10 @@ export const setUpI18n = async (): Promise<void> => {
|
|||
.use(
|
||||
resourcesToBackend((language, namespace, callback) => {
|
||||
import(`../../../../../locales/${language}.json`)
|
||||
.then((resources) => {
|
||||
.then((resources: ResourceKey) => {
|
||||
callback(null, resources)
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
callback(error, null)
|
||||
})
|
||||
})
|
||||
|
|
2
src/components/common/cache/cache.ts
vendored
2
src/components/common/cache/cache.ts
vendored
|
@ -40,7 +40,7 @@ export class Cache<K, V> {
|
|||
|
||||
put(key: K, value: V): void {
|
||||
if (this.maxEntries > 0 && this.store.size === this.maxEntries) {
|
||||
this.store.delete(this.store.keys().next().value)
|
||||
this.store.delete(this.store.keys().next().value as K)
|
||||
}
|
||||
this.store.set(key, {
|
||||
entryCreated: Date.now(),
|
||||
|
|
|
@ -30,7 +30,7 @@ export const CopyableField: React.FC<CopyableFieldProps> = ({ content, nativeSha
|
|||
text: content,
|
||||
url: url
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Native sharing failed', error)
|
||||
})
|
||||
}, [content, url])
|
||||
|
|
|
@ -29,7 +29,7 @@ export const getUserDataForRevision = (authors: string[]): UserResponse[] => {
|
|||
.then((userData) => {
|
||||
users.push(userData)
|
||||
})
|
||||
.catch((error) => log.error(error))
|
||||
.catch((error: Error) => log.error(error))
|
||||
})
|
||||
return users
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ export const handleUpload = (file: File, editor: Editor): void => {
|
|||
.then(({ link }) => {
|
||||
insertCode(``)
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('error while uploading file', error)
|
||||
insertCode('')
|
||||
})
|
||||
|
|
|
@ -24,7 +24,7 @@ export const useLoadNoteFromServer = (): [boolean, boolean] => {
|
|||
.then((note) => {
|
||||
setNoteDataFromServer(note)
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
setError(true)
|
||||
log.error('Error while fetching note from server', error)
|
||||
})
|
||||
|
|
|
@ -32,7 +32,7 @@ export const UploadInput: React.FC<UploadInputProps> = ({ onLoad, acceptedFiles,
|
|||
.then(() => {
|
||||
fileInput.value = ''
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Error while uploading file', error)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -20,7 +20,7 @@ export const ClearHistoryButton: React.FC = () => {
|
|||
const handleClose = () => setShow(false)
|
||||
|
||||
const onConfirm = useCallback(() => {
|
||||
deleteAllHistoryEntries().catch((error) => {
|
||||
deleteAllHistoryEntries().catch((error: Error) => {
|
||||
showErrorNotification('landing.history.error.deleteEntry.text')(error)
|
||||
refreshHistoryState().catch(showErrorNotification('landing.history.error.getHistory.text'))
|
||||
})
|
||||
|
|
|
@ -127,7 +127,7 @@ export const HistoryToolbar: React.FC<HistoryToolbarProps> = ({ onSettingsChange
|
|||
.filter((entry) => entry.origin === HistoryEntryOrigin.LOCAL)
|
||||
.map((entry) => entry.identifier)
|
||||
historyEntries.forEach((entry) => (entry.origin = HistoryEntryOrigin.REMOTE))
|
||||
importHistoryEntries(historyEntries).catch((error) => {
|
||||
importHistoryEntries(historyEntries).catch((error: Error) => {
|
||||
showErrorNotification('landing.history.error.setHistory.text')(error)
|
||||
historyEntries.forEach((entry) => {
|
||||
if (localEntries.includes(entry.identifier)) {
|
||||
|
|
|
@ -41,7 +41,7 @@ export const ImportHistoryButton: React.FC = () => {
|
|||
const onImportHistory = useCallback(
|
||||
(entries: HistoryEntry[]): void => {
|
||||
entries.forEach((entry) => (entry.origin = userExists ? HistoryEntryOrigin.REMOTE : HistoryEntryOrigin.LOCAL))
|
||||
importHistoryEntries(mergeHistoryEntries(historyState, entries)).catch((error) => {
|
||||
importHistoryEntries(mergeHistoryEntries(historyState, entries)).catch((error: Error) => {
|
||||
showErrorNotification('landing.history.error.setHistory.text')(error)
|
||||
refreshHistoryState().catch(showErrorNotification('landing.history.error.getHistory.text'))
|
||||
})
|
||||
|
|
|
@ -63,7 +63,7 @@ export const LanguagePicker: React.FC = () => {
|
|||
(event: React.ChangeEvent<HTMLSelectElement>) => {
|
||||
const language = event.currentTarget.value
|
||||
Settings.defaultLocale = language
|
||||
i18n.changeLanguage(language).catch((error) => log.error('Error while switching language', error))
|
||||
i18n.changeLanguage(language).catch((error: Error) => log.error('Error while switching language', error))
|
||||
},
|
||||
[i18n]
|
||||
)
|
||||
|
|
|
@ -30,7 +30,7 @@ export const useReveal = (content: string, slideOptions?: SlideOptions): void =>
|
|||
setDeck(reveal)
|
||||
log.debug('Initialisation finished')
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Error while initializing reveal.js', error)
|
||||
})
|
||||
}, [isInitialized, slideOptions])
|
||||
|
|
|
@ -26,7 +26,7 @@ export const AbcFrame: React.FC<AbcFrameProps> = ({ code }) => {
|
|||
.then((imp) => {
|
||||
imp.renderAbc(actualContainer, code, {})
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Error while loading abcjs', error)
|
||||
})
|
||||
}, [code])
|
||||
|
|
|
@ -46,7 +46,7 @@ export const FlowChart: React.FC<FlowChartProps> = ({ code }) => {
|
|||
setError(true)
|
||||
}
|
||||
})
|
||||
.catch((error) => log.error('Error while loading flowchart.js', error))
|
||||
.catch((error: Error) => log.error('Error while loading flowchart.js', error))
|
||||
|
||||
return () => {
|
||||
Array.from(currentDiagramRef.children).forEach((value) => value.remove())
|
||||
|
|
|
@ -21,7 +21,7 @@ export const GistFrame: React.FC<GistFrameProps> = ({ id }) => {
|
|||
const [frameHeight, onStartResizing] = useResizeGistFrame(150)
|
||||
|
||||
const onStart = useCallback(
|
||||
(event) => {
|
||||
(event: React.MouseEvent | React.TouchEvent) => {
|
||||
onStartResizing(event)
|
||||
},
|
||||
[onStartResizing]
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
||||
|
||||
/**
|
||||
* Determines if the left mouse button is pressed in the given event
|
||||
|
@ -22,7 +22,9 @@ const isLeftMouseButtonPressed = (mouseEvent: MouseEvent): boolean => {
|
|||
* @param moveEvent the vertical position of the mouse pointer or the first touch pointer.
|
||||
* @return the extracted vertical position.
|
||||
*/
|
||||
const extractVerticalPointerPosition = (moveEvent: MouseEvent | TouchEvent): number => {
|
||||
const extractVerticalPointerPosition = (
|
||||
moveEvent: React.MouseEvent | React.TouchEvent | MouseEvent | TouchEvent
|
||||
): number => {
|
||||
if (isMouseEvent(moveEvent)) {
|
||||
return moveEvent.pageY
|
||||
} else {
|
||||
|
@ -31,15 +33,15 @@ const extractVerticalPointerPosition = (moveEvent: MouseEvent | TouchEvent): num
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks if the given {@link Event} is a {@link MouseEvent}
|
||||
* Checks if the given {@link Event} is a {@link MouseEvent} or a {@link React.MouseEvent}
|
||||
* @param event the event to check
|
||||
* @return {@code true} if the given event is a {@link MouseEvent}
|
||||
* @return {@code true} if the given event is a {@link MouseEvent} or a {@link React.MouseEvent}
|
||||
*/
|
||||
const isMouseEvent = (event: Event): event is MouseEvent => {
|
||||
const isMouseEvent = (event: Event | React.UIEvent): event is MouseEvent | React.MouseEvent => {
|
||||
return (event as MouseEvent).buttons !== undefined
|
||||
}
|
||||
|
||||
export type PointerEvent = MouseEvent | TouchEvent
|
||||
export type PointerEvent = React.MouseEvent | React.TouchEvent
|
||||
export type PointerEventHandler = (event: PointerEvent) => void
|
||||
|
||||
/**
|
||||
|
@ -69,7 +71,7 @@ export const useResizeGistFrame = (initialFrameHeight: number): [number, Pointer
|
|||
moveEvent.preventDefault()
|
||||
}, [])
|
||||
|
||||
const onStartResizing: PointerEventHandler = useCallback((event) => {
|
||||
const onStartResizing = useCallback((event: React.MouseEvent | React.TouchEvent) => {
|
||||
lastYPosition.current = extractVerticalPointerPosition(event)
|
||||
}, [])
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ export const GraphvizFrame: React.FC<GraphvizFrameProps> = ({ code }) => {
|
|||
showError(error as string)
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Error while loading graphviz', error)
|
||||
})
|
||||
}, [code, error, frontendBaseUrl, showError])
|
||||
|
|
|
@ -58,7 +58,7 @@ export const HighlightedCode: React.FC<HighlightedCodeProps> = ({ code, language
|
|||
))
|
||||
setDom(replacedDom)
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Error while loading highlight.js', error)
|
||||
})
|
||||
}, [code, language, startLineNumber])
|
||||
|
|
|
@ -60,7 +60,7 @@ export const MarkmapFrame: React.FC<MarkmapFrameProps> = ({ code }) => {
|
|||
log.error(error)
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Error while loading markmap', error)
|
||||
})
|
||||
}, [code])
|
||||
|
|
|
@ -34,7 +34,7 @@ export const MermaidChart: React.FC<MermaidChartProps> = ({ code }) => {
|
|||
mermaid.default.initialize({ startOnLoad: false })
|
||||
mermaidInitialized = true
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Error while loading mermaid', error)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ export const VegaChart: React.FC<VegaChartProps> = ({ code }) => {
|
|||
showError(t('renderer.vega-lite.errorJson'))
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Error while loading vega-light', error)
|
||||
})
|
||||
}, [code, showError, t])
|
||||
|
|
|
@ -39,7 +39,7 @@ export const ProfileAccessTokens: React.FC = () => {
|
|||
setShowAddedModal(true)
|
||||
setNewTokenLabel('')
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error(error)
|
||||
setError(true)
|
||||
})
|
||||
|
@ -52,7 +52,7 @@ export const ProfileAccessTokens: React.FC = () => {
|
|||
.then(() => {
|
||||
setSelectedForDeletion(0)
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error(error)
|
||||
setError(true)
|
||||
})
|
||||
|
|
|
@ -162,7 +162,7 @@ const loadLocalHistory = (): HistoryEntry[] => {
|
|||
const localV1Json = window.localStorage.getItem('notehistory')
|
||||
if (localV1Json) {
|
||||
try {
|
||||
const localV1History = JSON.parse(JSON.parse(localV1Json)) as V1HistoryEntry[]
|
||||
const localV1History = JSON.parse(JSON.parse(localV1Json) as string) as V1HistoryEntry[]
|
||||
window.localStorage.removeItem('notehistory')
|
||||
return convertV1History(localV1History)
|
||||
} catch (error) {
|
||||
|
|
|
@ -109,7 +109,7 @@ function registerValidSW(swUrl: string, config?: Config) {
|
|||
}
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
.catch((error: Error) => {
|
||||
log.error('Error during service worker registration', error)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue