Skip to content

Commit

Permalink
chore: fix meteor linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Feb 4, 2025
1 parent 7e5e899 commit 1ebc2d1
Show file tree
Hide file tree
Showing 56 changed files with 156 additions and 155 deletions.
1 change: 1 addition & 0 deletions packages/webui/src/__mocks__/_setupMocks.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-require-imports */
import { resetRandomId } from './random.js'

// This file is run before all tests start.
Expand Down
3 changes: 0 additions & 3 deletions packages/webui/src/__mocks__/helpers/jest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable jest/no-export, jest/valid-title, jest/expect-expect, jest/no-focused-tests */

const orgSetTimeout = setTimeout
const DateOrg = Date
export async function runAllTimers(): Promise<void> {
Expand Down Expand Up @@ -43,7 +41,6 @@ export async function waitUntil(expectFcn: () => void | Promise<void>, maxWaitTi
const iterateInterval = maxWaitTime < 100 ? 10 : 100

const startTime = Date.now()
// eslint-disable-next-line no-constant-condition
while (true) {
await waitTime(iterateInterval)
try {
Expand Down
1 change: 1 addition & 0 deletions packages/webui/src/__mocks__/meteor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
import * as _ from 'underscore'
import type { DDP } from 'meteor/ddp'

Expand Down
2 changes: 1 addition & 1 deletion packages/webui/src/__mocks__/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export namespace TrackerMock {

TrackerMock.currentComputation.onInvalidate(clb)
}
export function afterFlush(_clb: Function): void {
export function afterFlush(_clb: () => void): void {
throw new Error(`Tracker.afterFlush() is not implemented in the mock Tracker`)
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/webui/src/client/__tests__/jest-setup.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable n/no-unpublished-require */
require('@testing-library/jest-dom')

// used by code creating XML with the DOM API to return an XML string
Expand Down
2 changes: 1 addition & 1 deletion packages/webui/src/client/lib/Components/JsonTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function tryParseJson(str: string | undefined): { parsed: object } | unde
try {
const parsed = JSON.parse(str2)
if (typeof parsed === 'object') return { parsed: parsed }
} catch (err) {
} catch (_err) {
// ignore
}
return undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function MultiSelectInputControl({
currentOptionMissing = true
}
}
} catch (e) {
} catch (_e) {
// `value` is probably invalid. We can't do much
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class ConnectionStatusNotifier extends WithManagedTracker {
lastNotificationId = undefined
try {
NotificationCenter.drop(buf)
} catch (e) {
} catch (_e) {
// if the last notification can't be dropped, ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/webui/src/client/lib/EditAttribute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ function useEditAttributeStateHelper(props: IEditAttributeBaseProps): EditAttrib
try {
newValue = props.mutateUpdateValue(newValue)
setValueError(false)
} catch (e) {
} catch (_e) {
setValueError(true)

return
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable react/prefer-stateless-function */

import React, { useState, useEffect, useRef, useCallback } from 'react'
import { Meteor } from 'meteor/meteor'
import { Mongo } from 'meteor/mongo'
Expand All @@ -10,7 +8,7 @@ import { meteorSubscribe } from '../meteorApi.js'
import { stringifyObjects } from '../tempLib.js'
import _ from 'underscore'

const globalTrackerQueue: Array<Function> = []
const globalTrackerQueue: Array<() => void> = []
let globalTrackerTimestamp: number | undefined = undefined
let globalTrackerTimeout: number | undefined = undefined

Expand Down Expand Up @@ -91,7 +89,7 @@ class MeteorDataManager {
globalTrackerQueue.length = 0
}

static enqueueUpdate(func: Function) {
static enqueueUpdate(func: () => void) {
if (globalTrackerTimeout !== undefined) {
clearTimeout(globalTrackerTimeout)
globalTrackerTimeout = undefined
Expand Down Expand Up @@ -310,7 +308,6 @@ export function translateWithTracker<IProps, IState, TrackedProps>(
checkUpdate?: (data: any, props: IProps, nextProps: IProps, state?: IState, nextState?: IState) => boolean,
queueTrackerUpdates?: boolean
): (component: React.ComponentType<Translated<IProps & TrackedProps>>) => React.ComponentType<IProps> {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
return (WrappedComponent) => {
const inner: React.ComponentType<Translated<IProps>> = withTracker<Translated<IProps>, IState, TrackedProps>(
autorunFunction,
Expand Down
2 changes: 1 addition & 1 deletion packages/webui/src/client/lib/UIStateStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export namespace UIStateStorage {
localStorage.removeItem('collapsedItems')
try {
_collapsedState = JSON.parse(localStorage.getItem(NAMESPACE) || '') || {}
} catch (e) {
} catch (_e) {
_collapsedState = {}
}
_cleanUp()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

if (typeof window.requestIdleCallback !== 'function') {
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
window.requestIdleCallback = (clb: Function) => {
return window.requestAnimationFrame(clb as any)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export abstract class WithManagedTracker {

protected autorun(
func: (comp: Tracker.Computation) => void,
options?: { onError: Function | undefined } | undefined
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
options?: { onError: Function | undefined }
): Tracker.Computation {
return Tracker.nonreactive(() => {
const comp = Tracker.autorun(func, options)
Expand Down
5 changes: 3 additions & 2 deletions packages/webui/src/client/lib/uncaughtErrorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MAX_ERROR_CACHE_COUNT = 10

try {
errorCache = JSON.parse(localStorage.getItem('errorCache') || '[]')
} catch (e) {
} catch (_e) {
errorCache = []
}

Expand Down Expand Up @@ -79,7 +79,7 @@ const originalConsoleError = console.error
console.error = (...args: any[]) => {
try {
uncaughtErrorHandler(args, 'console.error')
} catch (e) {
} catch (_e) {
// well, we can't do much then...
}
originalConsoleError(...args)
Expand All @@ -95,6 +95,7 @@ const IGNORED_ERRORS = [
const originalOnError = window.onerror
window.onerror = (event, source, line, col, error) => {
if (event) {
// eslint-disable-next-line @typescript-eslint/no-base-to-string
const eventString = event.toString()
const ignored = IGNORED_ERRORS.find((errorPattern) => !!eventString.match(errorPattern))
if (ignored) return
Expand Down
2 changes: 1 addition & 1 deletion packages/webui/src/client/lib/utilComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function makeTableOfObject(o: any): React.ReactNode {
let json = ''
try {
json = JSON.parse(val)
} catch (e) {
} catch (_e) {
// ignore
}
if (json) {
Expand Down
6 changes: 3 additions & 3 deletions packages/webui/src/client/lib/viewPort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export async function scrollToSegment(
elementToScrollToOrSegmentId: HTMLElement | SegmentId,
forceScroll?: boolean,
noAnimation?: boolean,
partInstanceId?: PartInstanceId | undefined
partInstanceId?: PartInstanceId
): Promise<boolean> {
const getElementToScrollTo = (showHistory: boolean): HTMLElement | null => {
if (isProtectedString(elementToScrollToOrSegmentId)) {
Expand Down Expand Up @@ -172,7 +172,7 @@ async function innerScrollToSegment(
forceScroll?: boolean,
noAnimation?: boolean,
secondStage?: boolean,
partInstanceId?: PartInstanceId | undefined
partInstanceId?: PartInstanceId
): Promise<boolean> {
if (!secondStage) {
currentScrollingElement = elementToScrollTo
Expand Down Expand Up @@ -320,7 +320,7 @@ export function lockPointer(): void {
if (pointerLockTurnstile === 0) {
// pointerLockTurnstile === 0 means that no requests for locking the pointer have been made
// since we last unlocked it
document.body.requestPointerLock()
document.body.requestPointerLock().catch((e) => console.error('Lock pointer failed', e))
// attach the event handlers only once. Once they are attached, we will track the
// locked state and act according to the turnstile
if (!pointerHandlerAttached) {
Expand Down
3 changes: 2 additions & 1 deletion packages/webui/src/client/ui/AfterBroadcastForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ export function AfterBroadcastForm({ playlist }: Readonly<{ playlist: DBRundownP
UserAction.CREATE_SNAPSHOT_FOR_DEBUG,
async (e, ts) =>
MeteorCall.system.generateSingleUseToken().then((tokenResult) => {
if (ClientAPI.isClientResponseError(tokenResult) || !tokenResult.result) throw tokenResult
if (ClientAPI.isClientResponseError(tokenResult)) throw tokenResult.error
if (!tokenResult.result) throw new Error('Failed to generate token')
return MeteorCall.userAction.storeRundownSnapshot(
e,
ts,
Expand Down
4 changes: 2 additions & 2 deletions packages/webui/src/client/ui/Prompter/PrompterView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ const PrompterContent = withTranslation()(
const { top } = anchor.getBoundingClientRect()

if (scrollAnchor.offset !== null) {
this.props.config.debug &&
if (this.props.config.debug)
logger.debug(
`Selected anchor ${scrollAnchor.anchorId} as anchor element in view, restoring position ${scrollAnchor.offset}`
)
Expand All @@ -810,7 +810,7 @@ const PrompterContent = withTranslation()(
// We've scrolled, exit the function!
return
} else {
this.props.config.debug &&
if (this.props.config.debug)
logger.debug(`Selected anchor ${scrollAnchor.anchorId} as anchor element outside of view, jumping to it`)

// Note: config.margin does not have to be taken into account here,
Expand Down
25 changes: 12 additions & 13 deletions packages/webui/src/client/ui/RundownView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -610,13 +610,13 @@ const RundownHeader = withTranslation()(
playlistId: RundownPlaylistId,
rehersal: boolean,
err: UserError,
clb?: Function
clb?: () => void
) => {
const { t } = this.props

function handleResult(err: any, response: void) {
function handleResult(err: any) {
if (!err) {
if (typeof clb === 'function') clb(response)
if (typeof clb === 'function') clb()
} else {
logger.error(err)
doModalDialog({
Expand Down Expand Up @@ -990,9 +990,8 @@ const RundownHeader = withTranslation()(
UserAction.CREATE_SNAPSHOT_FOR_DEBUG,
(e, ts) =>
MeteorCall.system.generateSingleUseToken().then((tokenResponse) => {
if (ClientAPI.isClientResponseError(tokenResponse) || !tokenResponse.result) {
throw tokenResponse
}
if (ClientAPI.isClientResponseError(tokenResponse)) throw tokenResponse.error
if (!tokenResponse.result) throw new Error('Failed to generate token')
return MeteorCall.userAction.storeRundownSnapshot(
e,
ts,
Expand Down Expand Up @@ -3009,9 +3008,9 @@ const RundownViewContent = translateWithTracker<IPropsWithReady, IState, ITracke
async (e, ts) => {
const tokenResponse = await MeteorCall.system.generateSingleUseToken()

if (ClientAPI.isClientResponseError(tokenResponse) || !tokenResponse.result) {
throw tokenResponse
}
if (ClientAPI.isClientResponseError(tokenResponse)) throw tokenResponse.error
if (!tokenResponse.result) throw new Meteor.Error(500, 'Failed to generate token')

return MeteorCall.userAction.storeRundownSnapshot(
e,
ts,
Expand Down Expand Up @@ -3570,9 +3569,9 @@ export function handleRundownReloadResponse(
(err) => {
if (!err) {
notificationHandle.stop()
clb && clb('unsynced')
clb?.('unsynced')
} else {
clb && clb('error')
clb?.('error')
}
}
)
Expand Down Expand Up @@ -3601,9 +3600,9 @@ export function handleRundownReloadResponse(
(err) => {
if (!err) {
notificationHandle.stop()
clb && clb('removed')
clb?.('removed')
} else {
clb && clb('error')
clb?.('error')
}
}
)
Expand Down
4 changes: 2 additions & 2 deletions packages/webui/src/client/ui/RundownView/RundownNotifier.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class RundownViewNotifier extends WithManagedTracker {
if (playlist?.notes) {
const playlistNotesId = playlist._id + '_playlistnotes_'
playlist.notes.forEach((note) => {
const noteId = playlistNotesId + note.origin.name + '_' + note.message + '_' + note.type
const noteId = playlistNotesId + note.origin.name + '_' + note.message.key + '_' + note.type
const notificationFromNote = new Notification(
noteId,
getNoticeLevelForNoteSeverity(note.type),
Expand Down Expand Up @@ -296,7 +296,7 @@ class RundownViewNotifier extends WithManagedTracker {
const rundownNotesId = rundown._id + '_ronotes_'
if (rundown.notes) {
rundown.notes.forEach((note) => {
const rundownNoteId = rundownNotesId + note.origin.name + '_' + note.message + '_' + note.type
const rundownNoteId = rundownNotesId + note.origin.name + '_' + note.message.key + '_' + note.type
const notificationFromNote = new Notification(
rundownNoteId,
getNoticeLevelForNoteSeverity(note.type),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react'
// eslint-disable-next-line n/no-unpublished-import
import { renderHook, act } from '@testing-library/react'
import { SelectedElementProvider, useSelectedElementsContext, useElementSelection } from '../SelectedElementsContext'
import { protectString } from '@sofie-automation/corelib/dist/protectedString'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ export const SegmentAdlibTestingContainer = withResolvedSegment<IProps>(function
_rank: 1,
},
})
segment &&
meteorSubscribe(
CorelibPubSub.piecesInfiniteStartingBefore,
rundownId,
Array.from(segmentsIdsBefore.values()),
Array.from(rundownIdsBefore.values())
)
if (!segment) return

meteorSubscribe(
CorelibPubSub.piecesInfiniteStartingBefore,
rundownId,
Array.from(segmentsIdsBefore.values()),
Array.from(rundownIdsBefore.values())
)
}, [segmentId, rundownId, segmentsIdsBefore.values(), rundownIdsBefore.values()])

const isLiveSegment = useTracker(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function LinePartIndicator({
function onClick(e: React.MouseEvent<HTMLDivElement>) {
const shouldBeOpen = !isMenuOpen
setIsMenuOpen(shouldBeOpen)
onClickExternal && onClickExternal(e)
onClickExternal?.(e)
window.addEventListener('mousedown', onClickAway)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function PieceIndicatorMenu({
const { styles, attributes, update } = usePopper(parentEl, indicatorMenuEl, POPPER_OPTIONS)

useLayoutEffect(() => {
update && update().catch(catchError('pieceIndicatorMenu popper update'))
update?.().catch(catchError('pieceIndicatorMenu popper update'))
}, [pieces.length])

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ export const LinePartSecondaryPiece: React.FC<IProps> = React.memo(function Line

const onClick = useCallback(
(e: React.MouseEvent<HTMLDivElement>) => {
incomingOnClick && incomingOnClick(piece, e)
incomingOnClick?.(piece, e)
},
[piece, incomingOnClick]
)

const onDoubleClick = useCallback(
(e: React.MouseEvent<HTMLDivElement>) => {
incomingOnDoubleClick && incomingOnDoubleClick(piece, e)
incomingOnDoubleClick?.(piece, e)
},
[piece, incomingOnDoubleClick]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ export const SegmentListContainer = withResolvedSegment<IProps>(function Segment
_rank: 1,
},
})
segment &&
meteorSubscribe(
CorelibPubSub.piecesInfiniteStartingBefore,
rundownId,
Array.from(segmentsIdsBefore.values()),
Array.from(rundownIdsBefore.values())
)
if (!segment) return

meteorSubscribe(
CorelibPubSub.piecesInfiniteStartingBefore,
rundownId,
Array.from(segmentsIdsBefore.values()),
Array.from(rundownIdsBefore.values())
)
}, [segmentId, rundownId, segmentsIdsBefore.values(), rundownIdsBefore.values()])

const isLiveSegment = useTracker(
Expand Down
Loading

0 comments on commit 1ebc2d1

Please sign in to comment.