Skip to content
This repository was archived by the owner on Nov 23, 2022. It is now read-only.

Commit c017df0

Browse files
committed
Fix linting errors
Signed-off-by: Tilman Vatteroth <[email protected]>
1 parent 74b0562 commit c017df0

File tree

24 files changed

+35
-33
lines changed

24 files changed

+35
-33
lines changed

src/components/application-loader/initializers/i18n/i18n.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: AGPL-3.0-only
55
*/
66

7-
import i18n from 'i18next'
7+
import i18n, { ResourceKey } from 'i18next'
88
import LanguageDetector from 'i18next-browser-languagedetector'
99
import resourcesToBackend from 'i18next-resources-to-backend'
1010
import { Settings } from 'luxon'
@@ -15,10 +15,10 @@ export const setUpI18n = async (): Promise<void> => {
1515
.use(
1616
resourcesToBackend((language, namespace, callback) => {
1717
import(`../../../../../locales/${language}.json`)
18-
.then((resources) => {
18+
.then((resources: ResourceKey) => {
1919
callback(null, resources)
2020
})
21-
.catch((error) => {
21+
.catch((error: Error) => {
2222
callback(error, null)
2323
})
2424
})

src/components/common/cache/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class Cache<K, V> {
4040

4141
put(key: K, value: V): void {
4242
if (this.maxEntries > 0 && this.store.size === this.maxEntries) {
43-
this.store.delete(this.store.keys().next().value)
43+
this.store.delete(this.store.keys().next().value as K)
4444
}
4545
this.store.set(key, {
4646
entryCreated: Date.now(),

src/components/common/copyable/copyable-field/copyable-field.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const CopyableField: React.FC<CopyableFieldProps> = ({ content, nativeSha
3030
text: content,
3131
url: url
3232
})
33-
.catch((error) => {
33+
.catch((error: Error) => {
3434
log.error('Native sharing failed', error)
3535
})
3636
}, [content, url])

src/components/editor-page/document-bar/revisions/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const getUserDataForRevision = (authors: string[]): UserResponse[] => {
2929
.then((userData) => {
3030
users.push(userData)
3131
})
32-
.catch((error) => log.error(error))
32+
.catch((error: Error) => log.error(error))
3333
})
3434
return users
3535
}

src/components/editor-page/editor-pane/upload-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const handleUpload = (file: File, editor: Editor): void => {
3232
.then(({ link }) => {
3333
insertCode(`![](${link})`)
3434
})
35-
.catch((error) => {
35+
.catch((error: Error) => {
3636
log.error('error while uploading file', error)
3737
insertCode('')
3838
})

src/components/editor-page/hooks/useLoadNoteFromServer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const useLoadNoteFromServer = (): [boolean, boolean] => {
2424
.then((note) => {
2525
setNoteDataFromServer(note)
2626
})
27-
.catch((error) => {
27+
.catch((error: Error) => {
2828
setError(true)
2929
log.error('Error while fetching note from server', error)
3030
})

src/components/editor-page/sidebar/upload-input.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const UploadInput: React.FC<UploadInputProps> = ({ onLoad, acceptedFiles,
3232
.then(() => {
3333
fileInput.value = ''
3434
})
35-
.catch((error) => {
35+
.catch((error: Error) => {
3636
log.error('Error while uploading file', error)
3737
})
3838
})

src/components/history-page/history-toolbar/clear-history-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const ClearHistoryButton: React.FC = () => {
2020
const handleClose = () => setShow(false)
2121

2222
const onConfirm = useCallback(() => {
23-
deleteAllHistoryEntries().catch((error) => {
23+
deleteAllHistoryEntries().catch((error: Error) => {
2424
showErrorNotification('landing.history.error.deleteEntry.text')(error)
2525
refreshHistoryState().catch(showErrorNotification('landing.history.error.getHistory.text'))
2626
})

src/components/history-page/history-toolbar/history-toolbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export const HistoryToolbar: React.FC<HistoryToolbarProps> = ({ onSettingsChange
127127
.filter((entry) => entry.origin === HistoryEntryOrigin.LOCAL)
128128
.map((entry) => entry.identifier)
129129
historyEntries.forEach((entry) => (entry.origin = HistoryEntryOrigin.REMOTE))
130-
importHistoryEntries(historyEntries).catch((error) => {
130+
importHistoryEntries(historyEntries).catch((error: Error) => {
131131
showErrorNotification('landing.history.error.setHistory.text')(error)
132132
historyEntries.forEach((entry) => {
133133
if (localEntries.includes(entry.identifier)) {

src/components/history-page/history-toolbar/import-history-button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const ImportHistoryButton: React.FC = () => {
4141
const onImportHistory = useCallback(
4242
(entries: HistoryEntry[]): void => {
4343
entries.forEach((entry) => (entry.origin = userExists ? HistoryEntryOrigin.REMOTE : HistoryEntryOrigin.LOCAL))
44-
importHistoryEntries(mergeHistoryEntries(historyState, entries)).catch((error) => {
44+
importHistoryEntries(mergeHistoryEntries(historyState, entries)).catch((error: Error) => {
4545
showErrorNotification('landing.history.error.setHistory.text')(error)
4646
refreshHistoryState().catch(showErrorNotification('landing.history.error.getHistory.text'))
4747
})

src/components/landing-layout/footer/language-picker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export const LanguagePicker: React.FC = () => {
6363
(event: React.ChangeEvent<HTMLSelectElement>) => {
6464
const language = event.currentTarget.value
6565
Settings.defaultLocale = language
66-
i18n.changeLanguage(language).catch((error) => log.error('Error while switching language', error))
66+
i18n.changeLanguage(language).catch((error: Error) => log.error('Error while switching language', error))
6767
},
6868
[i18n]
6969
)

src/components/markdown-renderer/hooks/use-reveal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const useReveal = (content: string, slideOptions?: SlideOptions): void =>
3030
setDeck(reveal)
3131
log.debug('Initialisation finished')
3232
})
33-
.catch((error) => {
33+
.catch((error: Error) => {
3434
log.error('Error while initializing reveal.js', error)
3535
})
3636
}, [isInitialized, slideOptions])

src/components/markdown-renderer/replace-components/abc/abc-frame.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const AbcFrame: React.FC<AbcFrameProps> = ({ code }) => {
2626
.then((imp) => {
2727
imp.renderAbc(actualContainer, code, {})
2828
})
29-
.catch((error) => {
29+
.catch((error: Error) => {
3030
log.error('Error while loading abcjs', error)
3131
})
3232
}, [code])

src/components/markdown-renderer/replace-components/flow/flowchart/flowchart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const FlowChart: React.FC<FlowChartProps> = ({ code }) => {
4646
setError(true)
4747
}
4848
})
49-
.catch((error) => log.error('Error while loading flowchart.js', error))
49+
.catch((error: Error) => log.error('Error while loading flowchart.js', error))
5050

5151
return () => {
5252
Array.from(currentDiagramRef.children).forEach((value) => value.remove())

src/components/markdown-renderer/replace-components/gist/gist-frame.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const GistFrame: React.FC<GistFrameProps> = ({ id }) => {
2121
const [frameHeight, onStartResizing] = useResizeGistFrame(150)
2222

2323
const onStart = useCallback(
24-
(event) => {
24+
(event: React.MouseEvent | React.TouchEvent) => {
2525
onStartResizing(event)
2626
},
2727
[onStartResizing]

src/components/markdown-renderer/replace-components/gist/use-resize-gist-frame.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: AGPL-3.0-only
55
*/
66

7-
import { useCallback, useEffect, useRef, useState } from 'react'
7+
import React, { useCallback, useEffect, useRef, useState } from 'react'
88

99
/**
1010
* Determines if the left mouse button is pressed in the given event
@@ -22,7 +22,9 @@ const isLeftMouseButtonPressed = (mouseEvent: MouseEvent): boolean => {
2222
* @param moveEvent the vertical position of the mouse pointer or the first touch pointer.
2323
* @return the extracted vertical position.
2424
*/
25-
const extractVerticalPointerPosition = (moveEvent: MouseEvent | TouchEvent): number => {
25+
const extractVerticalPointerPosition = (
26+
moveEvent: React.MouseEvent | React.TouchEvent | MouseEvent | TouchEvent
27+
): number => {
2628
if (isMouseEvent(moveEvent)) {
2729
return moveEvent.pageY
2830
} else {
@@ -31,15 +33,15 @@ const extractVerticalPointerPosition = (moveEvent: MouseEvent | TouchEvent): num
3133
}
3234

3335
/**
34-
* Checks if the given {@link Event} is a {@link MouseEvent}
36+
* Checks if the given {@link Event} is a {@link MouseEvent} or a {@link React.MouseEvent}
3537
* @param event the event to check
36-
* @return {@code true} if the given event is a {@link MouseEvent}
38+
* @return {@code true} if the given event is a {@link MouseEvent} or a {@link React.MouseEvent}
3739
*/
38-
const isMouseEvent = (event: Event): event is MouseEvent => {
40+
const isMouseEvent = (event: Event | React.UIEvent): event is MouseEvent | React.MouseEvent => {
3941
return (event as MouseEvent).buttons !== undefined
4042
}
4143

42-
export type PointerEvent = MouseEvent | TouchEvent
44+
export type PointerEvent = React.MouseEvent | React.TouchEvent
4345
export type PointerEventHandler = (event: PointerEvent) => void
4446

4547
/**
@@ -69,7 +71,7 @@ export const useResizeGistFrame = (initialFrameHeight: number): [number, Pointer
6971
moveEvent.preventDefault()
7072
}, [])
7173

72-
const onStartResizing: PointerEventHandler = useCallback((event) => {
74+
const onStartResizing = useCallback((event: React.MouseEvent | React.TouchEvent) => {
7375
lastYPosition.current = extractVerticalPointerPosition(event)
7476
}, [])
7577

src/components/markdown-renderer/replace-components/graphviz/graphviz-frame.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const GraphvizFrame: React.FC<GraphvizFrameProps> = ({ code }) => {
5656
showError(error as string)
5757
}
5858
})
59-
.catch((error) => {
59+
.catch((error: Error) => {
6060
log.error('Error while loading graphviz', error)
6161
})
6262
}, [code, error, frontendBaseUrl, showError])

src/components/markdown-renderer/replace-components/highlighted-fence/highlighted-code/highlighted-code.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const HighlightedCode: React.FC<HighlightedCodeProps> = ({ code, language
5858
))
5959
setDom(replacedDom)
6060
})
61-
.catch((error) => {
61+
.catch((error: Error) => {
6262
log.error('Error while loading highlight.js', error)
6363
})
6464
}, [code, language, startLineNumber])

src/components/markdown-renderer/replace-components/markmap/markmap-frame.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const MarkmapFrame: React.FC<MarkmapFrameProps> = ({ code }) => {
6060
log.error(error)
6161
}
6262
})
63-
.catch((error) => {
63+
.catch((error: Error) => {
6464
log.error('Error while loading markmap', error)
6565
})
6666
}, [code])

src/components/markdown-renderer/replace-components/mermaid/mermaid-chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const MermaidChart: React.FC<MermaidChartProps> = ({ code }) => {
3434
mermaid.default.initialize({ startOnLoad: false })
3535
mermaidInitialized = true
3636
})
37-
.catch((error) => {
37+
.catch((error: Error) => {
3838
log.error('Error while loading mermaid', error)
3939
})
4040
}

src/components/markdown-renderer/replace-components/vega-lite/vega-chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const VegaChart: React.FC<VegaChartProps> = ({ code }) => {
6161
showError(t('renderer.vega-lite.errorJson'))
6262
}
6363
})
64-
.catch((error) => {
64+
.catch((error: Error) => {
6565
log.error('Error while loading vega-light', error)
6666
})
6767
}, [code, showError, t])

src/components/profile-page/access-tokens/profile-access-tokens.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const ProfileAccessTokens: React.FC = () => {
3939
setShowAddedModal(true)
4040
setNewTokenLabel('')
4141
})
42-
.catch((error) => {
42+
.catch((error: Error) => {
4343
log.error(error)
4444
setError(true)
4545
})
@@ -52,7 +52,7 @@ export const ProfileAccessTokens: React.FC = () => {
5252
.then(() => {
5353
setSelectedForDeletion(0)
5454
})
55-
.catch((error) => {
55+
.catch((error: Error) => {
5656
log.error(error)
5757
setError(true)
5858
})

src/redux/history/methods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ const loadLocalHistory = (): HistoryEntry[] => {
162162
const localV1Json = window.localStorage.getItem('notehistory')
163163
if (localV1Json) {
164164
try {
165-
const localV1History = JSON.parse(JSON.parse(localV1Json)) as V1HistoryEntry[]
165+
const localV1History = JSON.parse(JSON.parse(localV1Json) as string) as V1HistoryEntry[]
166166
window.localStorage.removeItem('notehistory')
167167
return convertV1History(localV1History)
168168
} catch (error) {

src/service-worker-registration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function registerValidSW(swUrl: string, config?: Config) {
109109
}
110110
}
111111
})
112-
.catch((error) => {
112+
.catch((error: Error) => {
113113
log.error('Error during service worker registration', error)
114114
})
115115
}

0 commit comments

Comments
 (0)