From 547c7d1d744d48b869c1f7f98de28e932752f204 Mon Sep 17 00:00:00 2001 From: Loris Van Katwijk Date: Fri, 12 Apr 2024 14:27:04 +0200 Subject: [PATCH] feat: Lint imports problems as errors and fix them --- .eslintrc.json | 6 +++--- src/components/applications/JobMonitor.tsx | 2 +- src/components/applications/LoginForm.tsx | 6 +++--- src/components/applications/UserDashboard.tsx | 4 ++-- src/components/layout/Dashboard.tsx | 4 ++-- src/components/ui/DashboardDrawer.tsx | 2 +- src/components/ui/JobDataTable.tsx | 13 +++++++------ src/components/ui/ProfileButton.tsx | 2 +- src/hooks/theme.tsx | 2 +- test/unit-tests/Dashboard.test.tsx | 2 +- test/unit-tests/JobDataTable.test.tsx | 2 +- test/unit-tests/ProfileButton.test.tsx | 2 +- test/unit-tests/UserDashboard.test.tsx | 4 ++-- 13 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 71019638..dbf658fa 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -10,8 +10,8 @@ }, "plugins": ["import"], "rules": { - "import/order": ["warn"], - "import/no-unused-modules": ["warn"], - "import/no-useless-path-segments": ["warn"] + "import/order": ["error"], + "import/no-unused-modules": ["error"], + "import/no-useless-path-segments": ["error"] } } diff --git a/src/components/applications/JobMonitor.tsx b/src/components/applications/JobMonitor.tsx index 99321f8b..e4224299 100644 --- a/src/components/applications/JobMonitor.tsx +++ b/src/components/applications/JobMonitor.tsx @@ -2,10 +2,10 @@ import * as React from "react"; import CssBaseline from "@mui/material/CssBaseline"; import { Box } from "@mui/material"; -import { useMUITheme } from "@/hooks/theme"; import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles"; import { JobDataTable } from "../ui/JobDataTable"; import Dashboard from "../layout/Dashboard"; +import { useMUITheme } from "@/hooks/theme"; /** * Build the Job Monitor application diff --git a/src/components/applications/LoginForm.tsx b/src/components/applications/LoginForm.tsx index 8b88ba53..ca15aadc 100644 --- a/src/components/applications/LoginForm.tsx +++ b/src/components/applications/LoginForm.tsx @@ -10,15 +10,15 @@ import MenuItem from "@mui/material/MenuItem"; import Button from "@mui/material/Button"; import Autocomplete from "@mui/material/Autocomplete"; import TextField from "@mui/material/TextField"; -import { useMetadata, Metadata } from "@/hooks/metadata"; import Image from "next/image"; import { CssBaseline, Stack } from "@mui/material"; -import { useMUITheme } from "@/hooks/theme"; import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles"; import { useRouter } from "next/navigation"; -import { useOIDCContext } from "@/hooks/oidcConfiguration"; import * as React from "react"; import { useOidc } from "@axa-fr/react-oidc"; +import { useOIDCContext } from "@/hooks/oidcConfiguration"; +import { useMUITheme } from "@/hooks/theme"; +import { useMetadata, Metadata } from "@/hooks/metadata"; /** * Login form diff --git a/src/components/applications/UserDashboard.tsx b/src/components/applications/UserDashboard.tsx index 7c3c7494..15a701a9 100644 --- a/src/components/applications/UserDashboard.tsx +++ b/src/components/applications/UserDashboard.tsx @@ -2,11 +2,11 @@ import * as React from "react"; import CssBaseline from "@mui/material/CssBaseline"; import { Box } from "@mui/material"; -import { useMUITheme } from "@/hooks/theme"; import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles"; import { useOidcAccessToken } from "@axa-fr/react-oidc"; -import { useOIDCContext } from "@/hooks/oidcConfiguration"; import Dashboard from "../layout/Dashboard"; +import { useOIDCContext } from "@/hooks/oidcConfiguration"; +import { useMUITheme } from "@/hooks/theme"; /** * Build the User Dashboard page diff --git a/src/components/layout/Dashboard.tsx b/src/components/layout/Dashboard.tsx index 3f85fd65..2316b71c 100644 --- a/src/components/layout/Dashboard.tsx +++ b/src/components/layout/Dashboard.tsx @@ -7,11 +7,11 @@ import IconButton from "@mui/material/IconButton"; import MenuIcon from "@mui/icons-material/Menu"; import Toolbar from "@mui/material/Toolbar"; import Stack from "@mui/material/Stack"; +import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles"; import { ProfileButton } from "../ui/ProfileButton"; import DashboardDrawer from "../ui/DashboardDrawer"; -import { useMUITheme } from "@/hooks/theme"; -import { ThemeProvider as MUIThemeProvider } from "@mui/material/styles"; import { ThemeToggleButton } from "../ui/ThemeToggleButton"; +import { useMUITheme } from "@/hooks/theme"; interface DashboardProps { children: React.ReactNode; diff --git a/src/components/ui/DashboardDrawer.tsx b/src/components/ui/DashboardDrawer.tsx index 63cd8d12..ccc641e1 100644 --- a/src/components/ui/DashboardDrawer.tsx +++ b/src/components/ui/DashboardDrawer.tsx @@ -1,4 +1,3 @@ -import { DiracLogo } from "./DiracLogo"; import { usePathname } from "next/navigation"; import NextLink from "next/link"; import { @@ -15,6 +14,7 @@ import { Dashboard, FolderCopy } from "@mui/icons-material"; import MonitorIcon from "@mui/icons-material/Monitor"; import MenuBookIcon from "@mui/icons-material/MenuBook"; import { ReactEventHandler } from "react"; +import { DiracLogo } from "./DiracLogo"; // Define the sections that are accessible to users. // Each section has an associated icon and path. diff --git a/src/components/ui/JobDataTable.tsx b/src/components/ui/JobDataTable.tsx index d41e3c6e..4705ef90 100644 --- a/src/components/ui/JobDataTable.tsx +++ b/src/components/ui/JobDataTable.tsx @@ -1,5 +1,4 @@ import * as React from "react"; -import { DataTable, MenuItem } from "./DataTable"; import Box from "@mui/material/Box"; import { blue, @@ -21,17 +20,19 @@ import { Tooltip, useMediaQuery, useTheme, + Backdrop, + CircularProgress, + Snackbar, } from "@mui/material"; import { useOidcAccessToken } from "@axa-fr/react-oidc"; -import { useOIDCContext } from "../../hooks/oidcConfiguration"; import DeleteIcon from "@mui/icons-material/Delete"; import ClearIcon from "@mui/icons-material/Clear"; import ReplayIcon from "@mui/icons-material/Replay"; -import { Backdrop, CircularProgress, Snackbar } from "@mui/material"; -import { mutate } from "swr"; -import useSWR from "swr"; -import { fetcher } from "@/hooks/utils"; +import useSWR, { mutate } from "swr"; +import { useOIDCContext } from "../../hooks/oidcConfiguration"; +import { DataTable, MenuItem } from "./DataTable"; import { JobHistoryDialog } from "./JobHistoryDialog"; +import { fetcher } from "@/hooks/utils"; import { Filter } from "@/types/Filter"; import { Column } from "@/types/Column"; diff --git a/src/components/ui/ProfileButton.tsx b/src/components/ui/ProfileButton.tsx index 0b143b4f..0ced5160 100644 --- a/src/components/ui/ProfileButton.tsx +++ b/src/components/ui/ProfileButton.tsx @@ -1,5 +1,4 @@ "use client"; -import { useOIDCContext } from "@/hooks/oidcConfiguration"; import { useOidc, useOidcAccessToken } from "@axa-fr/react-oidc"; import { Logout } from "@mui/icons-material"; import { @@ -15,6 +14,7 @@ import { } from "@mui/material"; import { deepOrange } from "@mui/material/colors"; import React from "react"; +import { useOIDCContext } from "@/hooks/oidcConfiguration"; /** * Profile button, expected to vary whether the user is connected diff --git a/src/hooks/theme.tsx b/src/hooks/theme.tsx index 65f45363..10bd83ef 100644 --- a/src/hooks/theme.tsx +++ b/src/hooks/theme.tsx @@ -1,8 +1,8 @@ -import { ThemeContext } from "@/contexts/ThemeProvider"; import { PaletteMode } from "@mui/material"; import { deepOrange, grey, lightGreen } from "@mui/material/colors"; import { createTheme, darken, lighten } from "@mui/material/styles"; import { useContext } from "react"; +import { ThemeContext } from "@/contexts/ThemeProvider"; /** * Custom hook to access the theme context diff --git a/test/unit-tests/Dashboard.test.tsx b/test/unit-tests/Dashboard.test.tsx index 542aece6..39b4686c 100644 --- a/test/unit-tests/Dashboard.test.tsx +++ b/test/unit-tests/Dashboard.test.tsx @@ -1,8 +1,8 @@ import React from "react"; import { render, fireEvent } from "@testing-library/react"; +import { useOidc, useOidcAccessToken } from "@axa-fr/react-oidc"; import Dashboard from "@/components/layout/Dashboard"; import { ThemeProvider } from "@/contexts/ThemeProvider"; -import { useOidc, useOidcAccessToken } from "@axa-fr/react-oidc"; // Mock the module jest.mock("@axa-fr/react-oidc", () => ({ diff --git a/test/unit-tests/JobDataTable.test.tsx b/test/unit-tests/JobDataTable.test.tsx index 62b0a353..815875a6 100644 --- a/test/unit-tests/JobDataTable.test.tsx +++ b/test/unit-tests/JobDataTable.test.tsx @@ -1,8 +1,8 @@ import React from "react"; import { render } from "@testing-library/react"; -import { JobDataTable } from "@/components/ui/JobDataTable"; import useSWR from "swr"; import { useOidcAccessToken } from "@axa-fr/react-oidc"; +import { JobDataTable } from "@/components/ui/JobDataTable"; // Mock modules jest.mock("@axa-fr/react-oidc", () => ({ diff --git a/test/unit-tests/ProfileButton.test.tsx b/test/unit-tests/ProfileButton.test.tsx index 5d0714bc..5698f8eb 100644 --- a/test/unit-tests/ProfileButton.test.tsx +++ b/test/unit-tests/ProfileButton.test.tsx @@ -1,7 +1,7 @@ import React from "react"; import { render, fireEvent } from "@testing-library/react"; -import { ProfileButton } from "@/components/ui/ProfileButton"; import { useOidcAccessToken, useOidc } from "@axa-fr/react-oidc"; +import { ProfileButton } from "@/components/ui/ProfileButton"; import { OIDCConfigurationContext } from "@/contexts/OIDCConfigurationProvider"; // Mocking the hooks diff --git a/test/unit-tests/UserDashboard.test.tsx b/test/unit-tests/UserDashboard.test.tsx index 0a1e3b3d..9ef6e16a 100644 --- a/test/unit-tests/UserDashboard.test.tsx +++ b/test/unit-tests/UserDashboard.test.tsx @@ -1,12 +1,12 @@ import React from "react"; import { render } from "@testing-library/react"; -import UserDashboard from "@/components/applications/UserDashboard"; -import { ThemeProvider } from "@/contexts/ThemeProvider"; import { useOIDCContext, useOidcAccessToken, useOidc, } from "@axa-fr/react-oidc"; +import UserDashboard from "@/components/applications/UserDashboard"; +import { ThemeProvider } from "@/contexts/ThemeProvider"; // Mock the modules jest.mock("@axa-fr/react-oidc", () => ({