From 7d64e6c20063cdf2e1a095007637927f61508c2a Mon Sep 17 00:00:00 2001 From: James Crowley <509533+jamescrowley@users.noreply.github.com> Date: Fri, 13 Sep 2024 11:14:33 +1000 Subject: [PATCH] Simplify eslint rules that don't need to be disabled --- .eslintrc.cjs | 6 ------ front/src/components/Form/ShipmentOption.tsx | 15 ++++++++++----- front/src/components/Table/Filter.tsx | 2 +- front/src/hooks/useAuthorization.ts | 6 +++--- .../statviz/utils/analytics/heap/index.ts | 1 - statviz/src/App.tsx | 2 +- statviz/src/main.tsx | 2 +- 7 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 6dc230e6b..290370d90 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -63,8 +63,6 @@ module.exports = { // we do not need to import React in every file "react/react-in-jsx-scope": "off", "react/jsx-props-no-spreading": "off", - // matter of preference (allows to use props.propName instead of deconstructing props first) - "react/destructuring-assignment": "off", // allow other than jsx extensions "react/jsx-filename-extension": [1, { extensions: [".js", ".jsx", ".ts", ".tsx"] }], // --------- Import Plugin Rules --------- @@ -72,10 +70,6 @@ module.exports = { "import/no-extraneous-dependencies": ["error"], // ensure that all modules that are imported can be resolved to a module on the local filesystem "import/no-unresolved": [2, { caseSensitive: true }], - // if there is only a single export on a file, it does not have to be a default export - "import/prefer-default-export": "off", - // TODO: enable this rule at some point, we have quite a few circular imports due to type definitions being all over the place. - "import/no-cycle": ["off"], // ensure consistent use of file extension within the import statements "import/extensions": [ "error", diff --git a/front/src/components/Form/ShipmentOption.tsx b/front/src/components/Form/ShipmentOption.tsx index 2cf929971..9246400f4 100644 --- a/front/src/components/Form/ShipmentOption.tsx +++ b/front/src/components/Form/ShipmentOption.tsx @@ -1,18 +1,23 @@ import { chakra } from "@chakra-ui/react"; import { IDropdownOption } from "./SelectField"; +import { GroupBase, OptionProps } from "chakra-react-select"; export function ShipmentOption({ isDisabled, innerProps, data, -}: { - isDisabled: boolean; - innerProps: object; - data: IDropdownOption; -}) { +}: OptionProps< + IDropdownOption | ((prevState: IDropdownOption) => IDropdownOption), + false, + GroupBase IDropdownOption)> +>) { if (isDisabled) { return null; } + // supporting this scenario is not required + if (data != null && typeof data === "function") { + return null; + } const [base, organisation] = (data.label as string).split("-").map((part) => part.trim()); diff --git a/front/src/components/Table/Filter.tsx b/front/src/components/Table/Filter.tsx index f5d375886..7f0d164cb 100644 --- a/front/src/components/Table/Filter.tsx +++ b/front/src/components/Table/Filter.tsx @@ -85,7 +85,7 @@ export function SelectColumnFilter({ column: { render, filterValue, setFilter, preFilteredRows, id }, }: { column: { - render: (string) => string; + render: (type: "Header" | "Footer" | string, props?: object) => React.ReactNode; filterValue: any; setFilter: any; preFilteredRows: any; diff --git a/front/src/hooks/useAuthorization.ts b/front/src/hooks/useAuthorization.ts index e720c92b5..8e0dd5e44 100644 --- a/front/src/hooks/useAuthorization.ts +++ b/front/src/hooks/useAuthorization.ts @@ -10,10 +10,10 @@ export function useAuthorization() { const authorize = ({ requiredAbp, minBeta }: IAuthorizeProps) => user && - (user["https://www.boxtribute.com/roles"].includes("boxtribute_god") || - ((requiredAbp?.every((abp) => user["https://www.boxtribute.com/actions"].includes(abp)) ?? + (user["https://www.boxtribute.com/roles"]?.includes("boxtribute_god") || + ((requiredAbp?.every((abp) => user["https://www.boxtribute.com/actions"]?.includes(abp)) ?? true) && - parseInt(user["https://www.boxtribute.com/beta_user"], 10) >= (minBeta ?? 0))); + parseInt(user["https://www.boxtribute.com/beta_user"] ?? "", 10) >= (minBeta ?? 0))); return authorize; } diff --git a/shared-components/statviz/utils/analytics/heap/index.ts b/shared-components/statviz/utils/analytics/heap/index.ts index eb5f74cec..ba538c3f6 100644 --- a/shared-components/statviz/utils/analytics/heap/index.ts +++ b/shared-components/statviz/utils/analytics/heap/index.ts @@ -10,7 +10,6 @@ export const getHeap = (): IHeap => { return { // Note that on production the global heap object is returned track: (name, event) => { - // eslint-disable-next-line no-console console.log(`Tracked ${name}, event: ${JSON.stringify(event)}`); }, }; diff --git a/statviz/src/App.tsx b/statviz/src/App.tsx index ffb38fd1d..8501a7d13 100644 --- a/statviz/src/App.tsx +++ b/statviz/src/App.tsx @@ -1,5 +1,5 @@ import { Route, Routes } from "react-router-dom"; -import Dashboard from "@boxtribute/shared-components/Statviz/Dashboard/Dashboard"; +import Dashboard from "@boxtribute/shared-components/statviz/dashboard/Dashboard"; // test precommit function App() { diff --git a/statviz/src/main.tsx b/statviz/src/main.tsx index 767cd42ab..a0f5a0e65 100644 --- a/statviz/src/main.tsx +++ b/statviz/src/main.tsx @@ -3,7 +3,7 @@ import ReactDOM from "react-dom/client"; import { ChakraProvider, CSSReset } from "@chakra-ui/react"; import { BrowserRouter } from "react-router-dom"; import { ApolloClient, InMemoryCache, ApolloProvider } from "@apollo/client"; -import { theme } from "@boxtribute/shared-components/Utils/theme"; +import { theme } from "@boxtribute/shared-components/utils/theme"; import App from "./App"; const client = new ApolloClient({