Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix eslint rule "no-case-declarations" #2972

Merged
merged 2 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 22 additions & 11 deletions editor.planx.uk/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand All @@ -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",
Expand All @@ -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"
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -555,7 +555,7 @@ export const AnalyticsProvider: React.FC<{ children: React.ReactNode }> = ({
flag,
isAutoAnswered,
};

}
default:
return {
isAutoAnswered,
Expand Down
5 changes: 1 addition & 4 deletions editor.planx.uk/src/pages/FlowEditor/lib/store/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 6 additions & 4 deletions editor.planx.uk/src/pages/Preview/Node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const Node: React.FC<any> = (props: Props) => {
switch (props.node.type) {
case TYPES.Calculate:
return <Calculate {...allProps} />;
case TYPES.Checklist:
case TYPES.Checklist: {
const childNodes = childNodesOf(props.node.id);
return (
<Checklist
Expand All @@ -111,7 +111,8 @@ const Node: React.FC<any> = (props: Props) => {
}
/>
);
case TYPES.Confirmation:
}
case TYPES.Confirmation: {
const payment: GovUKPayment | undefined =
passport.data?.[GOV_PAY_PASSPORT_KEY];

Expand Down Expand Up @@ -147,6 +148,7 @@ const Node: React.FC<any> = (props: Props) => {
color={{ text: "#000", background: "rgba(1, 99, 96, 0.1)" }}
/>
);
}
case TYPES.Content:
return <Content {...allProps} />;

Expand Down Expand Up @@ -177,7 +179,7 @@ const Node: React.FC<any> = (props: Props) => {
case TYPES.Pay:
return <Pay {...allProps} />;

case TYPES.Result:
case TYPES.Result: {
const flagSet = props.node?.data?.flagSet || DEFAULT_FLAG_CATEGORY;
const data = resultData(flagSet, props.node?.data?.overrides);

Expand All @@ -198,7 +200,7 @@ const Node: React.FC<any> = (props: Props) => {
disclaimer={flowSettings?.elements?.legalDisclaimer}
/>
);

}
case TYPES.Review:
return <Review {...allProps} />;

Expand Down
1 change: 0 additions & 1 deletion editor.planx.uk/src/routes/utils.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Loading