linting fix

This commit is contained in:
mrjvs 2022-03-06 13:43:32 +01:00
parent bedac626d1
commit 069c5271df
21 changed files with 37 additions and 42 deletions

View File

@ -1,4 +1,3 @@
import { ButtonControlProps, ButtonControl } from "./ButtonControl";
import { Icon, Icons } from "components/Icon";
import React, {
MouseEventHandler,
@ -8,6 +7,7 @@ import React, {
} from "react";
import { Backdrop, useBackdrop } from "components/layout/Backdrop";
import { ButtonControlProps, ButtonControl } from "./ButtonControl";
export interface DropdownButtonProps extends ButtonControlProps {
icon: Icons;

View File

@ -1,5 +1,5 @@
import { ButtonControlProps, ButtonControl } from "./ButtonControl";
import { Icon, Icons } from "components/Icon";
import { ButtonControlProps, ButtonControl } from "./ButtonControl";
export interface IconButtonProps extends ButtonControlProps {
icon: Icons;

View File

@ -1,9 +1,9 @@
import { useState } from "react";
import { MWMediaType, MWQuery } from "providers";
import { DropdownButton } from "./buttons/DropdownButton";
import { Icons } from "./Icon";
import { TextInputControl } from "./text-inputs/TextInputControl";
import { useState } from "react";
import { MWMediaType, MWQuery } from "providers";
export interface SearchBarProps {
buttonText?: string;

View File

@ -43,7 +43,7 @@ export function ArrowLink(props: ArrowLinkProps) {
if (isExternal)
return <a href={(props as IArrowLinkPropsExternal).url}>{content}</a>;
else if (isInternal)
if (isInternal)
return (
<LinkRouter to={(props as IArrowLinkPropsInternal).to}>{content}</LinkRouter>
);

View File

@ -32,7 +32,7 @@ export function Link(props: LinkProps) {
if (isExternal)
return <a target={(props as ILinkPropsExternal).newTab ? "_blank" : undefined} rel="noreferrer" href={(props as ILinkPropsExternal).url}>{content}</a>;
else if (isInternal)
if (isInternal)
return (
<LinkRouter to={(props as ILinkPropsInternal).to}>{content}</LinkRouter>
);

View File

@ -63,6 +63,6 @@ export function Backdrop(props: BackdropProps) {
}`}
{...fadeProps}
onClick={(e) => clickEvent(e.nativeEvent)}
></div>
/>
);
}

View File

@ -28,7 +28,7 @@ export class ErrorBoundary extends Component<{}, ErrorBoundaryState> {
componentDidCatch(error: any, errorInfo: any) {
console.error("Render error caught", error, errorInfo);
if (error instanceof Error) {
let realError: Error = error as Error;
const realError: Error = error as Error;
this.setState((s) => ({
...s,
hasError: true,

View File

@ -8,10 +8,10 @@ export function Loading(props: LoadingProps) {
<div className={props.className}>
<div className="flex flex-col items-center justify-center">
<div className="flex h-12 items-center justify-center">
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full"></div>
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:150ms]"></div>
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:300ms]"></div>
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:450ms]"></div>
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full" />
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:150ms]" />
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:300ms]" />
<div className="animate-loading-pin bg-denim-300 mx-1 h-2 w-2 rounded-full [animation-delay:450ms]" />
</div>
{props.text && props.text.length ? (
<p className="mt-3 max-w-xs text-sm opacity-75">{props.text}</p>

View File

@ -11,7 +11,7 @@ import { DotList } from "components/text/DotList";
export interface MediaCardProps {
media: MWMediaMeta;
watchedPercentage: Number;
watchedPercentage: number;
linkable?: boolean;
}

View File

@ -1,7 +1,7 @@
import React, { useEffect, useState } from "react";
import './useFade.css'
export const useFade = (initial: boolean = false): [boolean, React.Dispatch<React.SetStateAction<boolean>>, any] => {
export const useFade = (initial = false): [boolean, React.Dispatch<React.SetStateAction<boolean>>, any] => {
const [show, setShow] = useState<boolean>(initial);
const [isVisible, setVisible] = useState<boolean>(show);

View File

@ -6,7 +6,7 @@ export function useLoading<T extends (...args: any) => Promise<any>>(
const [loading, setLoading] = useState(false);
const [success, setSuccess] = useState(false);
const [error, setError] = useState<any | undefined>(undefined);
let isMounted = useRef(true);
const isMounted = useRef(true);
// we want action to be memoized forever
const actionMemo = useMemo(() => action, []); // eslint-disable-line react-hooks/exhaustive-deps

View File

@ -2,8 +2,8 @@ import React from "react";
import ReactDOM from "react-dom";
import { HashRouter } from "react-router-dom";
import "./index.css";
import App from "./App";
import { ErrorBoundary } from "components/layout/ErrorBoundary";
import App from "./App";
ReactDOM.render(
<React.StrictMode>

View File

@ -5,6 +5,7 @@ import {
MWMediaStream,
} from "./types";
import contentCache from "./methods/contentCache";
export * from "./types";
export * from "./methods/helpers";
export * from "./methods/providers";
@ -30,7 +31,7 @@ export async function convertPortableToMedia(
portable: MWPortableMedia
): Promise<MWMedia | undefined> {
// consult cache first
let output = contentCache.get(portable);
const output = contentCache.get(portable);
if (output) return output;
const provider = getProviderFromId(portable.providerId);

View File

@ -39,7 +39,7 @@ export const theFlixScraper: MWMediaProvider = {
const searchData = await getDataFromSearch(searchRes, 10);
const results: MWProviderMediaResult[] = [];
for (let item of searchData) {
for (const item of searchData) {
results.push(turnDataIntoMedia(item));
}

View File

@ -4,7 +4,7 @@ import { MWMediaType, MWPortableMedia } from "providers/types";
const getTheFlixUrl = (media: MWPortableMedia, params?: URLSearchParams) => {
if (media.mediaType === MWMediaType.MOVIE) {
return `https://theflix.to/movie/${media.mediaId}?${params}`;
} else if (media.mediaType === MWMediaType.SERIES) {
} if (media.mediaType === MWMediaType.SERIES) {
return `https://theflix.to/tv-show/${media.mediaId}/season-${media.season}/episode-${media.episode}`;
}
@ -29,7 +29,7 @@ export async function getDataFromPortableSearch(
if (media.mediaType === MWMediaType.MOVIE) {
return JSON.parse(node.innerHTML).props.pageProps.movie;
} else if (media.mediaType === MWMediaType.SERIES) {
} if (media.mediaType === MWMediaType.SERIES) {
return JSON.parse(node.innerHTML).props.pageProps.selectedTv;
}
}

View File

@ -16,7 +16,7 @@ export async function searchTheFlix(query: MWQuery): Promise<string> {
).then((d) => d.text());
}
export function getDataFromSearch(page: string, limit: number = 10): any[] {
export function getDataFromSearch(page: string, limit = 10): any[] {
const node: Element = Array.from(
new DOMParser()
.parseFromString(page, "text/html")
@ -31,13 +31,13 @@ export function getDataFromSearch(page: string, limit: number = 10): any[] {
export function turnDataIntoMedia(data: any): MWProviderMediaResult {
return {
mediaId:
data.id +
"-" +
`${data.id
}-${
data.name
.replace(/[^a-z0-9]+|\s+/gim, " ")
.trim()
.replace(/\s+/g, "-")
.toLowerCase(),
.toLowerCase()}`,
title: data.name,
year: new Date(data.releaseDate).getFullYear().toString(),
};

View File

@ -23,7 +23,7 @@ export interface MWMediaMeta extends MWPortableMedia {
year: string;
}
export interface MWMedia extends MWMediaMeta {}
export type MWMedia = MWMediaMeta
export type MWProviderMediaResult = Omit<MWMedia, "mediaType" | "providerId">;

View File

@ -28,7 +28,7 @@ export function BookmarkContextProvider(props: { children: ReactNode }) {
function setBookmarked(data: any) {
setBookmarkStore((old) => {
let old2 = JSON.parse(JSON.stringify(old));
const old2 = JSON.parse(JSON.stringify(old));
let newData = data;
if (data.constructor === Function) {
newData = data(old2);
@ -65,9 +65,7 @@ export function BookmarkContextProvider(props: { children: ReactNode }) {
});
},
getFilteredBookmarks() {
return bookmarkStorage.bookmarks.filter((bookmark) => {
return getProviderMetadata(bookmark.providerId)?.enabled;
});
return bookmarkStorage.bookmarks.filter((bookmark) => getProviderMetadata(bookmark.providerId)?.enabled);
},
bookmarkStore: bookmarkStorage,
};
@ -87,14 +85,12 @@ function getBookmarkIndexFromMedia(
bookmarks: MWMediaMeta[],
media: MWMediaMeta
): number {
const a = bookmarks.findIndex((v) => {
return (
const a = bookmarks.findIndex((v) => (
v.mediaId === media.mediaId &&
v.providerId === media.providerId &&
v.episode === media.episode &&
v.season === media.season
);
});
));
return a;
}

View File

@ -70,9 +70,7 @@ export function WatchedContextProvider(props: { children: ReactNode }) {
});
},
getFilteredWatched() {
return watched.items.filter((item) => {
return getProviderMetadata(item.providerId)?.enabled;
});
return watched.items.filter((item) => getProviderMetadata(item.providerId)?.enabled);
},
watched,
};
@ -92,12 +90,10 @@ export function getWatchedFromPortable(
items: WatchedStoreItem[],
media: MWMediaMeta
): WatchedStoreItem | undefined {
return items.find((v) => {
return (
return items.find((v) => (
v.mediaId === media.mediaId &&
v.providerId === media.providerId &&
v.episode === media.episode &&
v.season === media.season
);
});
));
}

View File

@ -2,7 +2,9 @@ export class SimpleCache<Key, Value> {
protected readonly INTERVAL_MS = 2 * 60 * 1000; // 2 minutes
protected _interval: NodeJS.Timer | null = null;
protected _compare: ((a: Key, b: Key) => boolean) | null = null;
protected _storage: { key: Key; value: Value; expiry: Date }[] = [];
/*

View File

@ -86,7 +86,7 @@ function buildStoreObject(d: any) {
// add a save object to return value
data.save = function save(newData: any) {
let dataToStore = newData || data;
const dataToStore = newData || data;
localStorage.setItem(store.id, JSON.stringify(dataToStore));
};
@ -153,7 +153,7 @@ export function versionedStoreBuilder(): any {
// register version
this._data.versions[version.toString()] = {
version: version, // version number
version, // version number
update: migrate
? (data: any) => {
// update function, and increment version