From 6f7f16182e104753e3658fb95c46457866092871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Tue, 2 Apr 2024 15:49:59 +0100 Subject: [PATCH 1/2] chore: Fix no-case-declarations rule --- editor.planx.uk/.eslintrc | 33 ++++++++++++------- .../FlowEditor/lib/analyticsProvider.tsx | 4 +-- editor.planx.uk/src/pages/Preview/Node.tsx | 10 +++--- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/editor.planx.uk/.eslintrc b/editor.planx.uk/.eslintrc index 56e7548930..93607025c2 100644 --- a/editor.planx.uk/.eslintrc +++ b/editor.planx.uk/.eslintrc @@ -42,16 +42,22 @@ }, { "name": "@testing-library/react", - "importNames": ["render"], + "importNames": [ + "render" + ], "message": "Please import setup() from testUtils to render test component" }, { "name": "@mui/styles", - "importNames": ["styled"], + "importNames": [ + "styled" + ], "message": "Please import styled from '@mui/material/styles'. Reason: https://mui.com/system/styled/#what-problems-does-it-solve" } ], - "patterns": ["@mui/*/*/*"] + "patterns": [ + "@mui/*/*/*" + ] } ], "@typescript-eslint/no-unused-vars": [ @@ -62,7 +68,6 @@ } ], "no-empty": "warn", - "no-case-declarations": "warn", "no-unsafe-optional-chaining": "warn", "@typescript-eslint/ban-types": "warn", "@typescript-eslint/no-var-requires": "warn", @@ -71,12 +76,18 @@ "@typescript-eslint/ban-ts-comment": "off" }, "settings": { - "jest": { "version": 27 } + "jest": { + "version": 27 + } }, "overrides": [ - { - "files": ["**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)"], - "extends": ["plugin:testing-library/react"] - } - ] -} + { + "files": [ + "**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)" + ], + "extends": [ + "plugin:testing-library/react" + ] + } + ] +} \ No newline at end of file diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/analyticsProvider.tsx b/editor.planx.uk/src/pages/FlowEditor/lib/analyticsProvider.tsx index 363f080783..953a425bff 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/analyticsProvider.tsx +++ b/editor.planx.uk/src/pages/FlowEditor/lib/analyticsProvider.tsx @@ -545,7 +545,7 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({ function getNodeMetadata(node: Store.node, nodeId: string) { const isAutoAnswered = breadcrumbs[nodeId]?.auto || false; switch (node?.type) { - case TYPES.Result: + case TYPES.Result: { const flagSet = node?.data?.flagSet || DEFAULT_FLAG_CATEGORY; const data = resultData(flagSet, node?.data?.overrides); const { displayText, flag } = data[flagSet]; @@ -555,7 +555,7 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({ flag, isAutoAnswered, }; - + } default: return { isAutoAnswered, diff --git a/editor.planx.uk/src/pages/Preview/Node.tsx b/editor.planx.uk/src/pages/Preview/Node.tsx index f91de99ffc..229b59d1aa 100644 --- a/editor.planx.uk/src/pages/Preview/Node.tsx +++ b/editor.planx.uk/src/pages/Preview/Node.tsx @@ -85,7 +85,7 @@ const Node: React.FC = (props: Props) => { switch (props.node.type) { case TYPES.Calculate: return ; - case TYPES.Checklist: + case TYPES.Checklist: { const childNodes = childNodesOf(props.node.id); return ( = (props: Props) => { } /> ); - case TYPES.Confirmation: + } + case TYPES.Confirmation: { const payment: GovUKPayment | undefined = passport.data?.[GOV_PAY_PASSPORT_KEY]; @@ -147,6 +148,7 @@ const Node: React.FC = (props: Props) => { color={{ text: "#000", background: "rgba(1, 99, 96, 0.1)" }} /> ); + } case TYPES.Content: return ; @@ -177,7 +179,7 @@ const Node: React.FC = (props: Props) => { case TYPES.Pay: return ; - case TYPES.Result: + case TYPES.Result: { const flagSet = props.node?.data?.flagSet || DEFAULT_FLAG_CATEGORY; const data = resultData(flagSet, props.node?.data?.overrides); @@ -198,7 +200,7 @@ const Node: React.FC = (props: Props) => { disclaimer={flowSettings?.elements?.legalDisclaimer} /> ); - + } case TYPES.Review: return ; From eab28b81dc877b9c9b83b4b9bb2551295dbe65df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Tue, 2 Apr 2024 15:50:25 +0100 Subject: [PATCH 2/2] chore: Remove unused imports --- editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts | 5 +---- editor.planx.uk/src/routes/utils.ts | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts index ea8a152d34..73dd288e26 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts @@ -9,10 +9,7 @@ import { flatFlags, } from "@opensystemslab/planx-core/types"; import { ComponentType as TYPES } from "@opensystemslab/planx-core/types"; -import { - FileList, - PASSPORT_REQUESTED_FILES_KEY, -} from "@planx/components/FileUploadAndLabel/model"; +import { FileList } from "@planx/components/FileUploadAndLabel/model"; import { sortIdsDepthFirst } from "@planx/graph"; import { logger } from "airbrake"; import { objectWithoutNullishValues } from "lib/objectHelpers"; diff --git a/editor.planx.uk/src/routes/utils.ts b/editor.planx.uk/src/routes/utils.ts index a25ad03560..82a131b366 100644 --- a/editor.planx.uk/src/routes/utils.ts +++ b/editor.planx.uk/src/routes/utils.ts @@ -1,6 +1,5 @@ import { ComponentType as NodeTypes } from "@opensystemslab/planx-core/types"; import gql from "graphql-tag"; -import { hasFeatureFlag } from "lib/featureFlags"; import { NaviRequest, NotFoundError } from "navi"; import { useStore } from "pages/FlowEditor/lib/store"; import { Store } from "pages/FlowEditor/lib/store";