From 23f185c87722585f8335477960656d4c5e2b8da2 Mon Sep 17 00:00:00 2001 From: AnimeDL Date: Sat, 6 Apr 2024 09:10:48 -0700 Subject: [PATCH] eslint fixes --- .eslintignore | 5 - .eslintrc.json | 56 -- eslint.config.mjs | 24 +- gui/react/src/Layout.tsx | 6 +- gui/react/src/Style.tsx | 4 +- .../DownloadSelector/DownloadSelector.tsx | 410 ++++++------- .../Listing/EpisodeListing.tsx | 24 +- .../AddToQueue/SearchBox/SearchBox.tsx | 4 +- .../src/components/MainFrame/Queue/Queue.tsx | 562 +++++++++--------- gui/react/src/components/MenuBar/MenuBar.tsx | 26 +- gui/react/src/index.tsx | 2 +- gui/react/src/provider/MessageChannel.tsx | 12 +- package.json | 4 +- 13 files changed, 542 insertions(+), 597 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index dd20ec6..0000000 --- a/.eslintignore +++ /dev/null @@ -1,5 +0,0 @@ -lib -/videos/*.ts -build -dev.js -tsc.ts \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 175b10a..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "env": { - "browser": true, - "es2021": true, - "node": true - }, - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:@typescript-eslint/recommended" - ], - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaFeatures": { - "jsx": true - }, - "ecmaVersion": 12, - "sourceType": "module" - }, - "plugins": [ - "react", - "@typescript-eslint" - ], - "overrides": [ - { - "files": ["gui/react/**/*"], - "rules": { - "no-console": 0 - } - } - ], - "rules": { - "no-console": 2, - "react/prop-types": 0, - "react-hooks/exhaustive-deps": 0, - "@typescript-eslint/no-explicit-any": "off", - "@typescript-eslint/no-unsafe-declaration-merging": "warn", - "@typescript-eslint/no-unused-vars" : "warn", - "indent": [ - "error", - 2 - ], - "linebreak-style": [ - "warn", - "windows" - ], - "quotes": [ - "error", - "single" - ], - "semi": [ - "error", - "always" - ] - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs index 68875de..0770387 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -7,15 +7,6 @@ import react from 'eslint-plugin-react'; export default tseslint.config( eslint.configs.recommended, ...tseslint.configs.recommended, - { - ignores: [ - 'lib', - '/videos/*.ts', - 'build', - 'dev.js', - 'tsc.ts' - ] - }, { rules: { 'no-console': 2, @@ -54,5 +45,20 @@ export default tseslint.config( }, parser: tseslint.parser } + }, + { + ignores: [ + '**/lib', + '**/videos/*.ts', + '**/build', + 'dev.js', + 'tsc.ts' + ] + }, + { + files: ['gui/react/**/*'], + rules: { + 'no-console': 0 + } } ); \ No newline at end of file diff --git a/gui/react/src/Layout.tsx b/gui/react/src/Layout.tsx index 54bc212..478ae91 100644 --- a/gui/react/src/Layout.tsx +++ b/gui/react/src/Layout.tsx @@ -23,11 +23,11 @@ const Layout: React.FC = () => { maxWidth: '93rem', maxHeight: '3rem' //backgroundColor: '#ffffff', - }}> + }}> - - + + diff --git a/gui/react/src/Style.tsx b/gui/react/src/Style.tsx index 8ac45f8..1195472 100644 --- a/gui/react/src/Style.tsx +++ b/gui/react/src/Style.tsx @@ -11,8 +11,8 @@ const makeTheme = (mode: 'dark'|'light') : Partial => { const Style: FCWithChildren = ({children}) => { return - - {children} + + {children} ; }; diff --git a/gui/react/src/components/AddToQueue/DownloadSelector/DownloadSelector.tsx b/gui/react/src/components/AddToQueue/DownloadSelector/DownloadSelector.tsx index 9707dc6..586518b 100644 --- a/gui/react/src/components/AddToQueue/DownloadSelector/DownloadSelector.tsx +++ b/gui/react/src/components/AddToQueue/DownloadSelector/DownloadSelector.tsx @@ -86,240 +86,240 @@ const DownloadSelector: React.FC = ({ onFinish }) => { flexDirection: 'column', alignItems: 'center', margin: '5px', - }}> - - - - General Options - - { - dispatch({ - type: 'downloadOptions', - payload: { ...store.downloadOptions, id: e.target.value } - }); - }} label='Show ID'/> - { - const parsed = parseInt(e.target.value); - if (isNaN(parsed) || parsed < 0 || parsed > 10) - return; - dispatch({ - type: 'downloadOptions', - payload: { ...store.downloadOptions, q: parsed } - }); - }} label='Quality Level (0 for max)'/> - - - - - - - Simulcast is only supported on Hidive - } - arrow placement='top' - > - - - - - - - - Episode Options - - { + + General Options + + { dispatch({ type: 'downloadOptions', - payload: { ...store.downloadOptions, e: e.target.value } + payload: { ...store.downloadOptions, id: e.target.value } }); - }} placeholder='Episode Select'/> - - List
Episodes
+ }} label='Show ID'/> + { + const parsed = parseInt(e.target.value); + if (isNaN(parsed) || parsed < 0 || parsed > 10) + return; + dispatch({ + type: 'downloadOptions', + payload: { ...store.downloadOptions, q: parsed } + }); + }} label='Quality Level (0 for max)'/> + + + + + + + Simulcast is only supported on Hidive + } + arrow placement='top' + > + + + +
-
- - -
- + + Episode Options + + + + { + dispatch({ + type: 'downloadOptions', + payload: { ...store.downloadOptions, e: e.target.value } + }); + }} placeholder='Episode Select'/> + + List
Episodes
+
+
+ + +
+ - + }}> + Language Options - - { - dispatch({ - type: 'downloadOptions', - payload: { ...store.downloadOptions, dubLang: e } - }); - }} - allOption - /> + + { + dispatch({ + type: 'downloadOptions', + payload: { ...store.downloadOptions, dubLang: e } + }); + }} + allOption + /> - { - dispatch({ - type: 'downloadOptions', - payload: { ...store.downloadOptions, dlsubs: e } - }); - }} - /> - { + dispatch({ + type: 'downloadOptions', + payload: { ...store.downloadOptions, dlsubs: e } + }); + }} + /> + Hardsubs are only supported on Crunchyroll - } + } arrow placement='top'> - + - - - Hardsub Language - - - + + + Hardsub Language + + + - + Downloads the hardsub version of the selected subtitle.
Subtitles are displayed PERMANENTLY!
You can choose only 1 subtitle per video! - - } arrow placement='top'> - -
+ + } arrow placement='top'> + +
+
+
-
- - - - { - dispatch({ - type: 'downloadOptions', - payload: { ...store.downloadOptions, fileName: e.target.value } - }); - }} sx={{ width: '87%' }} label='Filename Overwrite' /> - + + + { + dispatch({ + type: 'downloadOptions', + payload: { ...store.downloadOptions, fileName: e.target.value } + }); + }} sx={{ width: '87%' }} label='Filename Overwrite' /> + Click here to see the documentation - - } arrow placement='top'> - - - - + + } arrow placement='top'> + + + + - Add to Queue + Add to Queue ; }; diff --git a/gui/react/src/components/AddToQueue/DownloadSelector/Listing/EpisodeListing.tsx b/gui/react/src/components/AddToQueue/DownloadSelector/Listing/EpisodeListing.tsx index d3668a2..0d34d96 100644 --- a/gui/react/src/components/AddToQueue/DownloadSelector/Listing/EpisodeListing.tsx +++ b/gui/react/src/components/AddToQueue/DownloadSelector/Listing/EpisodeListing.tsx @@ -75,21 +75,21 @@ const EpisodeListing: React.FC = () => { {store.episodeListing.filter((a) => season === 'all' ? true : a.season === season).map((item, index, { length }) => { const e = isNaN(parseInt(item.e)) ? item.e : parseInt(item.e); - const idStr = `S${item.season}E${e}` + const idStr = `S${item.season}E${e}`; const isSelected = selected.includes(e.toString()); const imageRef = React.createRef(); const summaryRef = React.createRef(); return { - let arr: string[] = []; - if (isSelected) { - arr = [...selected.filter(a => a !== e.toString())]; - } else { - arr = [...selected, e.toString()]; - } - setSelected(arr.filter(a => a.length > 0)); - }}> + onClick={() => { + let arr: string[] = []; + if (isSelected) { + arr = [...selected.filter(a => a !== e.toString())]; + } else { + arr = [...selected, e.toString()]; + } + setSelected(arr.filter(a => a.length > 0)); + }}> { isSelected ? : } {idStr} @@ -133,9 +133,9 @@ const EpisodeListing: React.FC = () => { await navigator.clipboard.writeText(item.description!); enqueueSnackbar('Copied summary to clipboard', { variant: 'info' - }) + }); }, - text: "Copy summary to clipboard" + text: 'Copy summary to clipboard' } ]} popupItem={summaryRef} /> {index < length - 1 && } diff --git a/gui/react/src/components/AddToQueue/SearchBox/SearchBox.tsx b/gui/react/src/components/AddToQueue/SearchBox/SearchBox.tsx index 6e6e56c..855f26d 100644 --- a/gui/react/src/components/AddToQueue/SearchBox/SearchBox.tsx +++ b/gui/react/src/components/AddToQueue/SearchBox/SearchBox.tsx @@ -100,9 +100,9 @@ const SearchBox: React.FC = () => { await navigator.clipboard.writeText(a.desc!); enqueueSnackbar('Copied summary to clipboard', { variant: 'info' - }) + }); }, - text: "Copy summary to clipboard" + text: 'Copy summary to clipboard' } ]} popupItem={summaryRef} /> } diff --git a/gui/react/src/components/MainFrame/Queue/Queue.tsx b/gui/react/src/components/MainFrame/Queue/Queue.tsx index 315354a..7707f74 100644 --- a/gui/react/src/components/MainFrame/Queue/Queue.tsx +++ b/gui/react/src/components/MainFrame/Queue/Queue.tsx @@ -17,113 +17,9 @@ const Queue: React.FC = () => { return data || queue.length > 0 ? <> {data && <> - - - Thumbnail - - - - - - {data.downloadInfo.parent.title} - - - {data.downloadInfo.title} - - - - - - Downloading: {data.downloadInfo.language.name} - - - - - - - - {data.progress.cur} / {(data.progress.total)} parts ({data.progress.percent}% | {formatTime(data.progress.time)} | {(data.progress.downloadSpeed / 1024 / 1024).toFixed(2)} MB/s | {(data.progress.bytes / 1024 / 1024).toFixed(2)}MB) - - - - - - - - } - { - current && !data && <> @@ -137,104 +33,208 @@ const Queue: React.FC = () => { boxShadow: '0px 0px 50px #00000090', borderRadius: '10px', display: 'flex', - overflow: 'hidden', transition: '250ms' - }}> - + Thumbnail - - - - - - {current.parent.title} - - - {current.title} - - - - - - - Downloading: - - - - - - - - - + - 0 / ? parts (0% | XX:XX | 0 MB/s | 0MB) - + + + + + {data.downloadInfo.parent.title} + + + {data.downloadInfo.title} + + + + + + Downloading: {data.downloadInfo.language.name} + + + + + + + + {data.progress.cur} / {(data.progress.total)} parts ({data.progress.percent}% | {formatTime(data.progress.time)} | {(data.progress.downloadSpeed / 1024 / 1024).toFixed(2)} MB/s | {(data.progress.bytes / 1024 / 1024).toFixed(2)}MB) + + + + + + } + { + current && !data && <> + + + Thumbnail + + + + + + {current.parent.title} + + + {current.title} + + + + + + + Downloading: + + + + + + + + + + 0 / ? parts (0% | XX:XX | 0 MB/s | 0MB) + + + + + - - } {queue.map((queueItem, index, { length }) => { @@ -255,7 +255,7 @@ const Queue: React.FC = () => { borderRadius: '10px', display: 'flex', overflow: 'hidden', - }}> + }}> { display: 'flex', width: '100%', justifyContent: 'space-between', + }}> + - - - {queueItem.parent.title} - - - S{queueItem.parent.season}E{queueItem.episode} - - - {queueItem.title} - - - + {queueItem.parent.title} + + + S{queueItem.parent.season}E{queueItem.episode} + + + {queueItem.title} + + + + - Dub(s): {queueItem.dubLang.join(', ')} - - - Sub(s): {queueItem.dlsubs.join(', ')} - - - Quality: {queueItem.q} - - - + + Sub(s): {queueItem.dlsubs.join(', ')} + + + Quality: {queueItem.q} + + + { - msg.removeFromQueue(index); - }} - sx={{ - backgroundColor: '#ff573a25', - height: '40px', - transition: '250ms', - '&:hover' : { - backgroundColor: '#ff573a', - } - }}> + onClick={() => { + msg.removeFromQueue(index); + }} + sx={{ + backgroundColor: '#ff573a25', + height: '40px', + transition: '250ms', + '&:hover' : { + backgroundColor: '#ff573a', + } + }}> - - - + + + ; })} : { + }}> + }}> @@ -396,12 +396,12 @@ const Queue: React.FC = () => { + }}> + }}> diff --git a/gui/react/src/components/MenuBar/MenuBar.tsx b/gui/react/src/components/MenuBar/MenuBar.tsx index 9efae16..23f5bb6 100644 --- a/gui/react/src/components/MenuBar/MenuBar.tsx +++ b/gui/react/src/components/MenuBar/MenuBar.tsx @@ -2,7 +2,7 @@ import { Box, Button, Menu, MenuItem, Typography } from '@mui/material'; import React from 'react'; import { messageChannelContext } from '../../provider/MessageChannel'; import useStore from '../../hooks/useStore'; -import { StoreState } from '../../provider/Store' +import { StoreState } from '../../provider/Store'; const MenuBar: React.FC = () => { const [ openMenu, setMenuOpen ] = React.useState<'settings'|'help'|undefined>(); @@ -15,20 +15,20 @@ const MenuBar: React.FC = () => { type: 'version', payload: await messageChannel?.version() }); - } + }; getVersion(); const transformService = (service: StoreState['service']) => { switch(service) { - case 'crunchy': - return "Crunchyroll" - case 'funi': - return "Funimation" - case "hidive": - return "Hidive" + case 'crunchy': + return 'Crunchyroll'; + case 'funi': + return 'Funimation'; + case 'hidive': + return 'Hidive'; } - } + }; const msg = React.useContext(messageChannelContext); @@ -46,12 +46,12 @@ const MenuBar: React.FC = () => { return - - + + { diff --git a/gui/react/src/index.tsx b/gui/react/src/index.tsx index 7f4bf6d..42f0a07 100644 --- a/gui/react/src/index.tsx +++ b/gui/react/src/index.tsx @@ -11,7 +11,7 @@ import Store from './provider/Store'; import ErrorHandler from './provider/ErrorHandler'; import QueueProvider from './provider/QueueProvider'; -document.body.style.backgroundColor = "rgb(0, 30, 60)"; +document.body.style.backgroundColor = 'rgb(0, 30, 60)'; document.body.style.display = 'flex'; document.body.style.justifyContent = 'center'; diff --git a/gui/react/src/provider/MessageChannel.tsx b/gui/react/src/provider/MessageChannel.tsx index 0341b7d..60e8b9a 100644 --- a/gui/react/src/provider/MessageChannel.tsx +++ b/gui/react/src/provider/MessageChannel.tsx @@ -15,11 +15,11 @@ export class RandomEventHandler { private handler: { [eventName in keyof RandomEvents]: Handler[] } = { - progress: [], - finish: [], - queueChange: [], - current: [] - }; + progress: [], + finish: [], + queueChange: [], + current: [] + }; public on(name: T, listener: Handler) { if (Object.prototype.hasOwnProperty.call(this.handler, name)) { @@ -212,7 +212,7 @@ const MessageChannelProvider: FCWithChildren = ({ children }) => { } const messageHandler: FrontEndMessages = { - name: "default", + name: 'default', auth: async (data) => (await messageAndResponse(socket, { name: 'auth', data })).data, version: async () => (await messageAndResponse(socket, { name: 'version', data: undefined })).data, checkToken: async () => (await messageAndResponse(socket, { name: 'checkToken', data: undefined })).data, diff --git a/package.json b/package.json index da4ae32..d93fddd 100644 --- a/package.json +++ b/package.json @@ -113,8 +113,8 @@ "build-macos-gui": "pnpm run prebuild-gui && cd lib && node modules/build macos-x64 true", "build-alpine-gui": "pnpm run prebuild-gui && cd lib && node modules/build alpine-x64 true", "build-android-gui": "pnpm run prebuild-gui && cd lib && node modules/build linuxstatic-armv7 true", - "eslint": "npx eslint *.ts modules", - "eslint-fix": "npx eslint *.ts modules --fix", + "eslint": "npx eslint .", + "eslint-fix": "npx eslint . --fix", "pretest": "pnpm run tsc", "test": "pnpm run pretest && cd lib && node modules/build windows-x64 && node modules/build linuxstatic-x64 && node modules/build macos-x64" }