Skip to content

Commit

Permalink
fix: Linting for player
Browse files Browse the repository at this point in the history
  • Loading branch information
matvp91 committed Nov 2, 2024
1 parent 71957f0 commit 18a72c8
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 77 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"scripts": {
"dev": "turbo dev --filter=\"@superstreamer/*\"",
"build": "turbo build --filter=\"@superstreamer/*\"",
"lint": "turbo lint",
"test": "turbo test",
"lint": "turbo lint --force --continue",
"test": "turbo test --force --continue",
"install-bin": "turbo install-bin"
},
"packageManager": "[email protected]",
Expand Down
11 changes: 7 additions & 4 deletions packages/player/src/react/ControllerProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { createContext } from "react";
import { Controller } from "./hooks/useController";
import type { Controller } from "./hooks/useController";
import type { ReactNode } from "react";

export const ControllerContext = createContext({} as Controller);
export const ControllerContext = createContext(
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
{} as Controller,
);

type ControllerProviderProps = {
interface ControllerProviderProps {
children: ReactNode;
controller: Controller;
};
}

export function ControllerProvider({
children,
Expand Down
4 changes: 2 additions & 2 deletions packages/player/src/react/controls/Controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { AppStoreProvider } from "./context/AppStoreProvider";
import { ParamsProvider } from "./context/ParamsProvider";
import type { Lang, Metadata } from "./types";

export type ControlsProps = {
export interface ControlsProps {
metadata?: Metadata;
lang?: Lang;
};
}

export function Controls({ metadata, lang }: ControlsProps) {
return (
Expand Down
18 changes: 9 additions & 9 deletions packages/player/src/react/controls/components/BottomControls.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import SettingsIcon from "../icons/settings.svg?react";
import SubtitlesIcon from "../icons/subtitles.svg?react";
import ForwardIcon from "../icons/forward.svg?react";
import { FullscreenButton } from "./FullscreenButton";
import { Label } from "./Label";
import { PlayPauseButton } from "./PlayPauseButton";
import { SqButton } from "./SqButton";
import { VolumeButton } from "./VolumeButton";
import { Label } from "./Label";
import { useFacade, useSelector } from "../..";
import { useAppStore } from "../hooks/useAppStore";
import { useFakeTime } from "../hooks/useFakeTime";
import { useSeekTo } from "../hooks/useSeekTo";
import { useShowTextAudio } from "../hooks/useShowTextAudio";
import { PlayPauseButton } from "./PlayPauseButton";
import { FullscreenButton } from "./FullscreenButton";
import type { MouseEventHandler } from "react";
import ForwardIcon from "../icons/forward.svg?react";
import SettingsIcon from "../icons/settings.svg?react";
import SubtitlesIcon from "../icons/subtitles.svg?react";
import type { SetAppSettings } from "../hooks/useAppSettings";
import type { MouseEventHandler } from "react";

type BottomControlsProps = {
interface BottomControlsProps {
nudgeVisible(): void;
setAppSettings: SetAppSettings;
toggleFullscreen: MouseEventHandler<HTMLElement>;
};
}

export function BottomControls({
nudgeVisible,
Expand Down
10 changes: 5 additions & 5 deletions packages/player/src/react/controls/components/Center.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useFacade } from "../..";
import { CenterIconPop } from "./CenterIconPop";
import { useRef } from "react";
import type { MouseEventHandler } from "react";
import { CenterIconPop } from "./CenterIconPop";
import { useFacade } from "../..";
import type { CenterIconPopRef } from "./CenterIconPop";
import type { MouseEventHandler } from "react";

type CenterProps = {
interface CenterProps {
onDoubleClick?: MouseEventHandler<HTMLElement>;
};
}

export function Center({ onDoubleClick }: CenterProps) {
const facade = useFacade();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { forwardRef, useCallback, useImperativeHandle, useRef } from "react";
import { useSelector } from "../..";
import playIcon from "../icons/play.svg";
import pauseIcon from "../icons/pause.svg";
import playIcon from "../icons/play.svg";

export interface CenterIconPopRef {
playOrPause(): void;
Expand Down Expand Up @@ -47,7 +47,7 @@ export const CenterIconPop = forwardRef<CenterIconPopRef, unknown>((_, ref) => {
return <div ref={elementRef} />;
});

type LastNudge = {
interface LastNudge {
element: HTMLDivElement;
timerId: number;
};
}
8 changes: 4 additions & 4 deletions packages/player/src/react/controls/components/CheckList.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import cn from "clsx";

export type CheckListItem = {
export interface CheckListItem {
id: number | null;
label: React.ReactNode;
checked: boolean;
};
}

type CheckListProps = {
interface CheckListProps {
onSelect(id: CheckListItem["id"]): void;
items: CheckListItem[];
};
}

export function CheckList({ items, onSelect }: CheckListProps) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import FullscreenIcon from "../icons/fullscreen.svg?react";
import FullscreenExitIcon from "../icons/fullscreen-exit.svg?react";
import { SqButton } from "./SqButton";
import { useAppStore } from "../hooks/useAppStore";
import FullscreenExitIcon from "../icons/fullscreen-exit.svg?react";
import FullscreenIcon from "../icons/fullscreen.svg?react";
import type { MouseEventHandler } from "react";

type FullscreenButtonProps = {
interface FullscreenButtonProps {
toggleFullscreen: MouseEventHandler<HTMLElement>;
};
}

export function FullscreenButton({ toggleFullscreen }: FullscreenButtonProps) {
const fullscreen = useAppStore((state) => state.fullscreen);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { InterstitialAdProgress } from "./InterstitialAdProgress";
import type { Interstitial } from "../..";

type InterstitialProgressProps = {
interface InterstitialProgressProps {
interstitial: Interstitial;
};
}
export function InterstitialProgress({
interstitial,
}: InterstitialProgressProps) {
Expand Down
4 changes: 2 additions & 2 deletions packages/player/src/react/controls/components/Pane.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type PaneProps = {
interface PaneProps {
title: string;
children: React.ReactNode;
};
}

export function Pane({ title, children }: PaneProps) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useFacade, useSelector } from "../..";
import { SqButton } from "./SqButton";
import PlayIcon from "../icons/play.svg?react";
import { useFacade, useSelector } from "../..";
import PauseIcon from "../icons/pause.svg?react";
import PlayIcon from "../icons/play.svg?react";

type PlayPauseButtonProps = {
interface PlayPauseButtonProps {
nudgeVisible(): void;
};
}

export function PlayPauseButton({ nudgeVisible }: PlayPauseButtonProps) {
const facade = useFacade();
Expand Down
12 changes: 6 additions & 6 deletions packages/player/src/react/controls/components/Playback.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import cn from "clsx";
import { Settings } from "./Settings";
import { Center } from "./Center";
import { BottomControls } from "./BottomControls";
import { useAppVisible } from "../hooks/useAppVisible";
import { useAppSettings } from "../hooks/useAppSettings";
import { useAppFullscreen } from "../hooks/useAppFullscreen";
import { useVisibleControls } from "../hooks/useVisibleControls";
import { Center } from "./Center";
import { Seekbar } from "./Seekbar";
import { Settings } from "./Settings";
import { useSelector } from "../..";
import { useAppFullscreen } from "../hooks/useAppFullscreen";
import { useAppSettings } from "../hooks/useAppSettings";
import { useAppVisible } from "../hooks/useAppVisible";
import { useVisibleControls } from "../hooks/useVisibleControls";

export function Playback() {
const ready = useSelector((facade) => facade.ready);
Expand Down
4 changes: 2 additions & 2 deletions packages/player/src/react/controls/components/Progress.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useRef, useState, useEffect, useCallback } from "react";
import { toHMS } from "../utils";
import cn from "clsx";
import { useCallback, useEffect, useRef, useState } from "react";
import { useSelector } from "../..";
import { useAppStore } from "../hooks/useAppStore";
import { useFakeTime } from "../hooks/useFakeTime";
import { useSeekTo } from "../hooks/useSeekTo";
import { toHMS } from "../utils";
import type { PointerEventHandler } from "react";

export function Progress() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import cn from "clsx";
import { CheckList } from "./CheckList";
import { Pane } from "./Pane";
import { Quality, useFacade, useSelector } from "../..";
import { useFacade, useSelector } from "../..";
import { useI18n } from "../hooks/useI18n";
import type { Quality } from "../..";
import type { CheckListItem } from "./CheckList";

export function QualitiesPane() {
Expand Down
4 changes: 2 additions & 2 deletions packages/player/src/react/controls/components/Seekbar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import cn from "clsx";
import { Progress } from "./Progress";
import { InterstitialProgress } from "./InterstitialProgress";
import { Progress } from "./Progress";
import { TimeStat } from "./TimeStat";
import { useAppStore } from "../hooks/useAppStore";
import { useSelector } from "../..";
import { useAppStore } from "../hooks/useAppStore";

export function Seekbar() {
const interstitial = useSelector((facade) => facade.interstitial);
Expand Down
4 changes: 2 additions & 2 deletions packages/player/src/react/controls/components/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import cn from "clsx";
import { useEffect, useLayoutEffect, useRef } from "react";
import usePrevious from "../hooks/usePrevious";
import { SettingsPane } from "./SettingsPane";
import { QualitiesPane } from "./QualitiesPane";
import { SettingsPane } from "./SettingsPane";
import { TextAudioPane } from "./TextAudioPane";
import { useAppStore } from "../hooks/useAppStore";
import usePrevious from "../hooks/usePrevious";
import type { SettingsMode } from "../hooks/useAppSettings";

export function Settings() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import cn from "clsx";

type SettingsPaneProps = {
interface SettingsPaneProps {
children: React.ReactNode;
active: boolean;
};
}

export function SettingsPane({ children, active }: SettingsPaneProps) {
return (
Expand Down
6 changes: 3 additions & 3 deletions packages/player/src/react/controls/components/SqButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import cn from "clsx";
import { useRef } from "react";
import { SqButtonTooltip } from "./SqButtonTooltip";
import type { MouseEventHandler } from "react";
import type { LangKey } from "../i18n";
import type { MouseEventHandler } from "react";

type SqButtonProps = {
interface SqButtonProps {
children: React.ReactNode;
onClick: MouseEventHandler<HTMLButtonElement>;
onIdle?: () => void;
Expand All @@ -13,7 +13,7 @@ type SqButtonProps = {
disabled?: boolean;
tooltip?: LangKey;
tooltipPlacement?: "left" | "right";
};
}

export function SqButton({
children,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import cn from "clsx";
import { useI18n } from "../hooks/useI18n";
import { useSelector } from "../..";
import { useI18n } from "../hooks/useI18n";
import type { LangKey } from "../i18n";

type SqButtonTooltipProps = {
interface SqButtonTooltipProps {
value: LangKey;
placement?: "left" | "right";
};
}

export function SqButtonTooltip({ value, placement }: SqButtonTooltipProps) {
const l = useI18n();
Expand Down
2 changes: 1 addition & 1 deletion packages/player/src/react/controls/components/Start.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cn from "clsx";
import PlayIcon from "../icons/play.svg?react";
import { useFacade, useSelector } from "../..";
import PlayIcon from "../icons/play.svg?react";

export function Start() {
const facade = useFacade();
Expand Down
2 changes: 1 addition & 1 deletion packages/player/src/react/controls/components/TimeStat.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toHMS } from "../utils";
import { useSelector } from "../..";
import { useFakeTime } from "../hooks/useFakeTime";
import { toHMS } from "../utils";

export function TimeStat() {
const fakeTime = useFakeTime();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { SqButton } from "./SqButton";
import cn from "clsx";
import { useRef, useState } from "react";
import { SqButton } from "./SqButton";
import Volume0Icon from "../icons/volume-0.svg?react";
import Volume1Icon from "../icons/volume-1.svg?react";
import Volume2Icon from "../icons/volume-2.svg?react";
import VolumeMutedIcon from "../icons/volume-muted.svg?react";
import { CSSProperties, ReactEventHandler, useRef, useState } from "react";
import type { CSSProperties, ReactEventHandler } from "react";

const rangeStyle: CSSProperties = {
writingMode: "vertical-lr",
Expand All @@ -15,10 +16,10 @@ const rangeStyle: CSSProperties = {
: undefined,
};

type VolumeButtonProps = {
interface VolumeButtonProps {
volume: number;
setVolume(volume: number): void;
};
}

export function VolumeButton({ volume, setVolume }: VolumeButtonProps) {
const [visible, setVisible] = useState(false);
Expand Down
13 changes: 8 additions & 5 deletions packages/player/src/react/controls/context/AppStoreProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createStore } from "zustand";
import { createContext, useContext, useEffect, useState } from "react";
import { createStore } from "zustand";
import { ControllerContext, Events } from "../..";
import type { ReactNode } from "react";
import type { Settings } from "../hooks/useAppSettings";
import type { ReactNode } from "react";

type AppStore = ReturnType<typeof createAppStore>;

Expand All @@ -19,11 +19,14 @@ export interface AppState {
setFullscreen(value: boolean): void;
}

export const StoreContext = createContext<AppStore>({} as AppStore);
export const StoreContext = createContext<AppStore>(
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
{} as AppStore,
);

type StoreProviderProps = {
interface StoreProviderProps {
children: ReactNode;
};
}

export function AppStoreProvider({ children }: StoreProviderProps) {
const [store] = useState(createAppStore);
Expand Down
Loading

0 comments on commit 18a72c8

Please sign in to comment.