Make manual eslint fixes

These are safe fixes, more complicated fixes can be done separately
(just disabled those errors for now).

- Reorder declarations to fix `no-use-before-define`
- Rename parameters for `no-shadow`
- Remove unused parameters, functions, imports
- Switch from `++` and `—` to `+= 1` and `-= 1` for `no-unary`
- Use object spreading instead of parameter reassignment in auth utils
- Use `window.location` instead of `location` global
- Use inline JSX strings instead of unescaped values
-
This commit is contained in:
nimbleghost 2023-05-24 10:20:15 +02:00
parent 8319f1cf26
commit 59011c8a32
20 changed files with 369 additions and 351 deletions

View file

@ -1,5 +1,5 @@
import * as React from "react";
import { createContext, Suspense, useContext, useEffect, useState } from "react";
import { createContext, Suspense, useContext, useEffect, useState, useMemo } from "react";
import Box from "@mui/material/Box";
import { ThemeProvider } from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";
@ -30,11 +30,14 @@ export const AccountContext = createContext(null);
const App = () => {
const [account, setAccount] = useState(null);
const contextValue = useMemo(() => ({ account, setAccount }), [account, setAccount]);
return (
<Suspense fallback={<Loader />}>
<BrowserRouter>
<ThemeProvider theme={theme}>
<AccountContext.Provider value={{ account, setAccount }}>
<AccountContext.Provider value={contextValue}>
<CssBaseline />
<ErrorBoundary>
<Routes>
@ -56,6 +59,10 @@ const App = () => {
);
};
const updateTitle = (newNotificationsCount) => {
document.title = newNotificationsCount > 0 ? `(${newNotificationsCount}) ntfy` : "ntfy";
};
const Layout = () => {
const params = useParams();
const { account, setAccount } = useContext(AccountContext);
@ -115,7 +122,7 @@ const Main = (props) => (
width: { sm: `calc(100% - ${Navigation.width}px)` },
height: "100vh",
overflow: "auto",
backgroundColor: (theme) => (theme.palette.mode === "light" ? theme.palette.grey[100] : theme.palette.grey[900]),
backgroundColor: ({ palette }) => (palette.mode === "light" ? palette.grey[100] : palette.grey[900]),
}}
>
{props.children}
@ -127,15 +134,11 @@ const Loader = () => (
open
sx={{
zIndex: 100000,
backgroundColor: (theme) => (theme.palette.mode === "light" ? theme.palette.grey[100] : theme.palette.grey[900]),
backgroundColor: ({ palette }) => (palette.mode === "light" ? palette.grey[100] : palette.grey[900]),
}}
>
<CircularProgress color="success" disableShrink />
</Backdrop>
);
const updateTitle = (newNotificationsCount) => {
document.title = newNotificationsCount > 0 ? `(${newNotificationsCount}) ntfy` : "ntfy";
};
export default App;