ESLint auto fixes
This commit is contained in:
		@@ -1,28 +1,23 @@
 | 
				
			|||||||
import js from "@eslint/js";
 | 
					import js from "@eslint/js";
 | 
				
			||||||
import globals from "globals";
 | 
					import reactDom from "eslint-plugin-react-dom";
 | 
				
			||||||
import reactHooks from "eslint-plugin-react-hooks";
 | 
					import reactHooks from "eslint-plugin-react-hooks";
 | 
				
			||||||
import reactRefresh from "eslint-plugin-react-refresh";
 | 
					import reactRefresh from "eslint-plugin-react-refresh";
 | 
				
			||||||
import tseslint from "typescript-eslint";
 | 
					 | 
				
			||||||
import reactX from "eslint-plugin-react-x";
 | 
					import reactX from "eslint-plugin-react-x";
 | 
				
			||||||
import reactDom from "eslint-plugin-react-dom";
 | 
					import globals from "globals";
 | 
				
			||||||
 | 
					import tseslint from "typescript-eslint";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default tseslint.config(
 | 
					export default tseslint.config(
 | 
				
			||||||
  { ignores: ["dist"] },
 | 
					  { ignores: ["dist"] },
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    extends: [
 | 
					    extends: [
 | 
				
			||||||
      js.configs.recommended,
 | 
					      js.configs.recommended,
 | 
				
			||||||
      // Remove ...tseslint.configs.recommended and replace with this
 | 
					 | 
				
			||||||
      // ...tseslint.configs.recommendedTypeChecked,
 | 
					 | 
				
			||||||
      // Alternatively, use this for stricter rules
 | 
					 | 
				
			||||||
      ...tseslint.configs.strictTypeChecked,
 | 
					      ...tseslint.configs.strictTypeChecked,
 | 
				
			||||||
      // Optionally, add this for stylistic rules
 | 
					 | 
				
			||||||
      ...tseslint.configs.stylisticTypeChecked,
 | 
					      ...tseslint.configs.stylisticTypeChecked,
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
    files: ["**/*.{ts,tsx}"],
 | 
					    files: ["**/*.{ts,tsx}"],
 | 
				
			||||||
    languageOptions: {
 | 
					    languageOptions: {
 | 
				
			||||||
      ecmaVersion: 2020,
 | 
					      ecmaVersion: 2020,
 | 
				
			||||||
      globals: globals.browser,
 | 
					      globals: globals.browser,
 | 
				
			||||||
      // other options...
 | 
					 | 
				
			||||||
      parserOptions: {
 | 
					      parserOptions: {
 | 
				
			||||||
        project: ["./tsconfig.node.json", "./tsconfig.app.json"],
 | 
					        project: ["./tsconfig.node.json", "./tsconfig.app.json"],
 | 
				
			||||||
        tsconfigRootDir: import.meta.dirname,
 | 
					        tsconfigRootDir: import.meta.dirname,
 | 
				
			||||||
@@ -40,9 +35,20 @@ export default tseslint.config(
 | 
				
			|||||||
        "warn",
 | 
					        "warn",
 | 
				
			||||||
        { allowConstantExport: true },
 | 
					        { allowConstantExport: true },
 | 
				
			||||||
      ],
 | 
					      ],
 | 
				
			||||||
 | 
					 | 
				
			||||||
      ...reactX.configs["recommended-typescript"].rules,
 | 
					      ...reactX.configs["recommended-typescript"].rules,
 | 
				
			||||||
      ...reactDom.configs.recommended.rules,
 | 
					      ...reactDom.configs.recommended.rules,
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-non-null-assertion": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-misused-promises": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-floating-promises": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/restrict-template-expressions": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-extraneous-class": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-explicit-any": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-unsafe-assignment": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-unsafe-return": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-unsafe-call": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-unsafe-member-access": "off",
 | 
				
			||||||
 | 
					      "@typescript-eslint/no-unsafe-argument": "off",
 | 
				
			||||||
 | 
					      "react-refresh/only-export-components": "off",
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
);
 | 
					);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,12 +53,12 @@ export function App() {
 | 
				
			|||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <AuthContextK.Provider value={context}>
 | 
					    <AuthContextK value={context}>
 | 
				
			||||||
      <RouterProvider router={router} />
 | 
					      <RouterProvider router={router} />
 | 
				
			||||||
    </AuthContextK.Provider>
 | 
					    </AuthContextK>
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function useAuth(): AuthContext {
 | 
					export function useAuth(): AuthContext {
 | 
				
			||||||
  return React.useContext(AuthContextK)!;
 | 
					  return React.use(AuthContextK)!;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,7 +44,7 @@ export class APIClient {
 | 
				
			|||||||
   */
 | 
					   */
 | 
				
			||||||
  static async exec(args: RequestParams): Promise<APIResponse> {
 | 
					  static async exec(args: RequestParams): Promise<APIResponse> {
 | 
				
			||||||
    let body: string | undefined | FormData = undefined;
 | 
					    let body: string | undefined | FormData = undefined;
 | 
				
			||||||
    let headers: any = {};
 | 
					    const headers: any = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // JSON request
 | 
					    // JSON request
 | 
				
			||||||
    if (args.jsonData) {
 | 
					    if (args.jsonData) {
 | 
				
			||||||
@@ -67,17 +67,17 @@ export class APIClient {
 | 
				
			|||||||
      const res: XMLHttpRequest = await new Promise((resolve, reject) => {
 | 
					      const res: XMLHttpRequest = await new Promise((resolve, reject) => {
 | 
				
			||||||
        const xhr = new XMLHttpRequest();
 | 
					        const xhr = new XMLHttpRequest();
 | 
				
			||||||
        xhr.upload.addEventListener("progress", (e) =>
 | 
					        xhr.upload.addEventListener("progress", (e) =>
 | 
				
			||||||
          args.upProgress!(e.loaded / e.total)
 | 
					          { args.upProgress!(e.loaded / e.total); }
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        xhr.addEventListener("load", () => resolve(xhr));
 | 
					        xhr.addEventListener("load", () => { resolve(xhr); });
 | 
				
			||||||
        xhr.addEventListener("error", () =>
 | 
					        xhr.addEventListener("error", () =>
 | 
				
			||||||
          reject(new Error("File upload failed"))
 | 
					          { reject(new Error("File upload failed")); }
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        xhr.addEventListener("abort", () =>
 | 
					        xhr.addEventListener("abort", () =>
 | 
				
			||||||
          reject(new Error("File upload aborted"))
 | 
					          { reject(new Error("File upload aborted")); }
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        xhr.addEventListener("timeout", () =>
 | 
					        xhr.addEventListener("timeout", () =>
 | 
				
			||||||
          reject(new Error("File upload timeout"))
 | 
					          { reject(new Error("File upload timeout")); }
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        xhr.open(args.method, url, true);
 | 
					        xhr.open(args.method, url, true);
 | 
				
			||||||
        xhr.withCredentials = true;
 | 
					        xhr.withCredentials = true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,7 +39,7 @@ export function AlertDialogProvider(p: PropsWithChildren): React.ReactElement {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <>
 | 
					    <>
 | 
				
			||||||
      <AlertContextK.Provider value={hook}>{p.children}</AlertContextK.Provider>
 | 
					      <AlertContextK value={hook}>{p.children}</AlertContextK>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <Dialog
 | 
					      <Dialog
 | 
				
			||||||
        open={open}
 | 
					        open={open}
 | 
				
			||||||
@@ -64,5 +64,5 @@ export function AlertDialogProvider(p: PropsWithChildren): React.ReactElement {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function useAlert(): AlertContext {
 | 
					export function useAlert(): AlertContext {
 | 
				
			||||||
  return React.useContext(AlertContextK)!;
 | 
					  return React.use(AlertContextK)!;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,13 +53,13 @@ export function ConfirmDialogProvider(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <>
 | 
					    <>
 | 
				
			||||||
      <ConfirmContextK.Provider value={hook}>
 | 
					      <ConfirmContextK value={hook}>
 | 
				
			||||||
        {p.children}
 | 
					        {p.children}
 | 
				
			||||||
      </ConfirmContextK.Provider>
 | 
					      </ConfirmContextK>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <Dialog
 | 
					      <Dialog
 | 
				
			||||||
        open={open}
 | 
					        open={open}
 | 
				
			||||||
        onClose={() => handleClose(false)}
 | 
					        onClose={() => { handleClose(false); }}
 | 
				
			||||||
        aria-labelledby="alert-dialog-title"
 | 
					        aria-labelledby="alert-dialog-title"
 | 
				
			||||||
        aria-describedby="alert-dialog-description"
 | 
					        aria-describedby="alert-dialog-description"
 | 
				
			||||||
        onKeyUp={keyUp}
 | 
					        onKeyUp={keyUp}
 | 
				
			||||||
@@ -71,10 +71,10 @@ export function ConfirmDialogProvider(
 | 
				
			|||||||
          </DialogContentText>
 | 
					          </DialogContentText>
 | 
				
			||||||
        </DialogContent>
 | 
					        </DialogContent>
 | 
				
			||||||
        <DialogActions>
 | 
					        <DialogActions>
 | 
				
			||||||
          <Button onClick={() => handleClose(false)} autoFocus>
 | 
					          <Button onClick={() => { handleClose(false); }} autoFocus>
 | 
				
			||||||
            Cancel
 | 
					            Cancel
 | 
				
			||||||
          </Button>
 | 
					          </Button>
 | 
				
			||||||
          <Button onClick={() => handleClose(true)} color="error">
 | 
					          <Button onClick={() => { handleClose(true); }} color="error">
 | 
				
			||||||
            {confirmButton ?? "Confirm"}
 | 
					            {confirmButton ?? "Confirm"}
 | 
				
			||||||
          </Button>
 | 
					          </Button>
 | 
				
			||||||
        </DialogActions>
 | 
					        </DialogActions>
 | 
				
			||||||
@@ -84,5 +84,5 @@ export function ConfirmDialogProvider(
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function useConfirm(): ConfirmContext {
 | 
					export function useConfirm(): ConfirmContext {
 | 
				
			||||||
  return React.useContext(ConfirmContextK)!;
 | 
					  return React.use(ConfirmContextK)!;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,7 @@ export function DarkThemeProvider(p: PropsWithChildren): React.ReactElement {
 | 
				
			|||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <DarkThemeContextK.Provider
 | 
					    <DarkThemeContextK
 | 
				
			||||||
      value={{
 | 
					      value={{
 | 
				
			||||||
        enabled: enabled,
 | 
					        enabled: enabled,
 | 
				
			||||||
        setEnabled(enabled) {
 | 
					        setEnabled(enabled) {
 | 
				
			||||||
@@ -41,10 +41,10 @@ export function DarkThemeProvider(p: PropsWithChildren): React.ReactElement {
 | 
				
			|||||||
      <ThemeProvider theme={enabled ? darkTheme : lightTheme}>
 | 
					      <ThemeProvider theme={enabled ? darkTheme : lightTheme}>
 | 
				
			||||||
        {p.children}
 | 
					        {p.children}
 | 
				
			||||||
      </ThemeProvider>
 | 
					      </ThemeProvider>
 | 
				
			||||||
    </DarkThemeContextK.Provider>
 | 
					    </DarkThemeContextK>
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function useDarkTheme(): DarkThemeContext {
 | 
					export function useDarkTheme(): DarkThemeContext {
 | 
				
			||||||
  return React.useContext(DarkThemeContextK)!;
 | 
					  return React.use(DarkThemeContextK)!;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,10 +6,10 @@ import {
 | 
				
			|||||||
} from "@mui/material";
 | 
					} from "@mui/material";
 | 
				
			||||||
import React, { PropsWithChildren } from "react";
 | 
					import React, { PropsWithChildren } from "react";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type LoadingMessageContext = {
 | 
					interface LoadingMessageContext {
 | 
				
			||||||
  show: (message: string) => void;
 | 
					  show: (message: string) => void;
 | 
				
			||||||
  hide: () => void;
 | 
					  hide: () => void;
 | 
				
			||||||
};
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const LoadingMessageContextK =
 | 
					const LoadingMessageContextK =
 | 
				
			||||||
  React.createContext<LoadingMessageContext | null>(null);
 | 
					  React.createContext<LoadingMessageContext | null>(null);
 | 
				
			||||||
@@ -34,9 +34,9 @@ export function LoadingMessageProvider(
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <>
 | 
					    <>
 | 
				
			||||||
      <LoadingMessageContextK.Provider value={hook}>
 | 
					      <LoadingMessageContextK value={hook}>
 | 
				
			||||||
        {p.children}
 | 
					        {p.children}
 | 
				
			||||||
      </LoadingMessageContextK.Provider>
 | 
					      </LoadingMessageContextK>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <Dialog open={open}>
 | 
					      <Dialog open={open}>
 | 
				
			||||||
        <DialogContent>
 | 
					        <DialogContent>
 | 
				
			||||||
@@ -60,5 +60,5 @@ export function LoadingMessageProvider(
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function useLoadingMessage(): LoadingMessageContext {
 | 
					export function useLoadingMessage(): LoadingMessageContext {
 | 
				
			||||||
  return React.useContext(LoadingMessageContextK)!;
 | 
					  return React.use(LoadingMessageContextK)!;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,9 +24,9 @@ export function SnackbarProvider(p: PropsWithChildren): React.ReactElement {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <>
 | 
					    <>
 | 
				
			||||||
      <SnackbarContextK.Provider value={hook}>
 | 
					      <SnackbarContextK value={hook}>
 | 
				
			||||||
        {p.children}
 | 
					        {p.children}
 | 
				
			||||||
      </SnackbarContextK.Provider>
 | 
					      </SnackbarContextK>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      <Snackbar
 | 
					      <Snackbar
 | 
				
			||||||
        open={open}
 | 
					        open={open}
 | 
				
			||||||
@@ -39,5 +39,5 @@ export function SnackbarProvider(p: PropsWithChildren): React.ReactElement {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function useSnackbar(): SnackbarContext {
 | 
					export function useSnackbar(): SnackbarContext {
 | 
				
			||||||
  return React.useContext(SnackbarContextK)!;
 | 
					  return React.use(SnackbarContextK)!;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -26,7 +26,7 @@ createRoot(document.getElementById("root")!).render(
 | 
				
			|||||||
              <LoadingMessageProvider>
 | 
					              <LoadingMessageProvider>
 | 
				
			||||||
                <AsyncWidget
 | 
					                <AsyncWidget
 | 
				
			||||||
                  loadKey={1}
 | 
					                  loadKey={1}
 | 
				
			||||||
                  load={async () => await ServerApi.LoadConfig()}
 | 
					                  load={async () => { await ServerApi.LoadConfig(); }}
 | 
				
			||||||
                  errMsg="Failed to load static server configuration!"
 | 
					                  errMsg="Failed to load static server configuration!"
 | 
				
			||||||
                  build={() => <App />}
 | 
					                  build={() => <App />}
 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -64,7 +64,7 @@ export function AsyncWidget(p: {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        <Button onClick={load}>Try again</Button>
 | 
					        <Button onClick={load}>Try again</Button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        {p.errAdditionalElement && p.errAdditionalElement()}
 | 
					        {p.errAdditionalElement?.()}
 | 
				
			||||||
      </Box>
 | 
					      </Box>
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,7 +40,7 @@ export function BaseAuthenticatedPage(): React.ReactElement {
 | 
				
			|||||||
        </>
 | 
					        </>
 | 
				
			||||||
      )}
 | 
					      )}
 | 
				
			||||||
      build={() => (
 | 
					      build={() => (
 | 
				
			||||||
        <AuthInfoContextK.Provider
 | 
					        <AuthInfoContextK
 | 
				
			||||||
          value={{
 | 
					          value={{
 | 
				
			||||||
            info: authInfo!,
 | 
					            info: authInfo!,
 | 
				
			||||||
            reloadAuthInfo: load,
 | 
					            reloadAuthInfo: load,
 | 
				
			||||||
@@ -84,12 +84,12 @@ export function BaseAuthenticatedPage(): React.ReactElement {
 | 
				
			|||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
            </Box>
 | 
					            </Box>
 | 
				
			||||||
          </Box>
 | 
					          </Box>
 | 
				
			||||||
        </AuthInfoContextK.Provider>
 | 
					        </AuthInfoContextK>
 | 
				
			||||||
      )}
 | 
					      )}
 | 
				
			||||||
    />
 | 
					    />
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function useAuthInfo(): AuthInfoContext {
 | 
					export function useAuthInfo(): AuthInfoContext {
 | 
				
			||||||
  return React.useContext(AuthInfoContextK)!;
 | 
					  return React.use(AuthInfoContextK)!;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ export function DarkThemeButton(): React.ReactElement {
 | 
				
			|||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <Tooltip title="Activer / désactiver le mode sombre">
 | 
					    <Tooltip title="Activer / désactiver le mode sombre">
 | 
				
			||||||
      <IconButton
 | 
					      <IconButton
 | 
				
			||||||
        onClick={() => darkTheme.setEnabled(!darkTheme.enabled)}
 | 
					        onClick={() => { darkTheme.setEnabled(!darkTheme.enabled); }}
 | 
				
			||||||
        style={{ color: "inherit" }}
 | 
					        style={{ color: "inherit" }}
 | 
				
			||||||
      >
 | 
					      >
 | 
				
			||||||
        {!darkTheme.enabled ? <DarkModeIcon /> : <Brightness7Icon />}
 | 
					        {!darkTheme.enabled ? <DarkModeIcon /> : <Brightness7Icon />}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,7 +44,7 @@ export function MoneyWebAppBar(p: {
 | 
				
			|||||||
          <DarkThemeButton />
 | 
					          <DarkThemeButton />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          <Button size="large" color="inherit">
 | 
					          <Button size="large" color="inherit">
 | 
				
			||||||
            {authInfo!.info.name}
 | 
					            {authInfo.info.name}
 | 
				
			||||||
          </Button>
 | 
					          </Button>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          <Button
 | 
					          <Button
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -12,7 +12,7 @@ export function CheckboxInput(p: {
 | 
				
			|||||||
        <Checkbox
 | 
					        <Checkbox
 | 
				
			||||||
          disabled={!p.editable}
 | 
					          disabled={!p.editable}
 | 
				
			||||||
          checked={p.checked}
 | 
					          checked={p.checked}
 | 
				
			||||||
          onChange={(e) => p.onValueChange(e.target.checked)}
 | 
					          onChange={(e) => { p.onValueChange(e.target.checked); }}
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      label={p.label}
 | 
					      label={p.label}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user