Skip to content

Commit

Permalink
fix prettier/linting differences?
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Aug 22, 2024
1 parent 3598e8b commit ee794d5
Show file tree
Hide file tree
Showing 30 changed files with 612 additions and 482 deletions.
18 changes: 5 additions & 13 deletions editor.planx.uk/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,16 @@
},
{
"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 Down Expand Up @@ -86,9 +80,7 @@
"files": [
"**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)"
],
"extends": [
"plugin:testing-library/react"
]
"extends": ["plugin:testing-library/react"]
}
]
}
}
15 changes: 8 additions & 7 deletions editor.planx.uk/.storybook/__mocks__/react-navi.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@

// require syntax is used to enable overwriting objects from the original module
const reactNavi = require('react-navi');
const reactNavi = require("react-navi");

const originalUseCurrentRoute = reactNavi.useCurrentRoute;
const originalUseNavigation = reactNavi.useNavigation;

function reactNaviDecorator(story, { parameters }) {
delete reactNavi["useCurrentRoute"];
reactNavi.useCurrentRoute = parameters?.reactNavi?.useCurrentRoute ?? originalUseCurrentRoute;
reactNavi.useCurrentRoute =
parameters?.reactNavi?.useCurrentRoute ?? originalUseCurrentRoute;

delete reactNavi["useNavigation"];
reactNavi.useNavigation = parameters?.reactNavi?.useNavigation ?? originalUseNavigation;
reactNavi.useNavigation =
parameters?.reactNavi?.useNavigation ?? originalUseNavigation;

return story();
return story();
}

reactNavi['reactNaviDecorator'] = reactNaviDecorator;
reactNavi["reactNaviDecorator"] = reactNaviDecorator;

module.exports = reactNavi;
module.exports = reactNavi;
40 changes: 25 additions & 15 deletions editor.planx.uk/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
module.exports = {
stories: ["../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: ["@storybook/addon-links", "@storybook/addon-essentials", "@storybook/preset-create-react-app", "@storybook/addon-a11y"],
webpackFinal: async config => {
addons: [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/preset-create-react-app",
"@storybook/addon-a11y",
],
webpackFinal: async (config) => {
config.resolve.plugins ||= [];
config.resolve.plugins.push(new TsconfigPathsPlugin());
config.resolve.alias["react-navi"] = require.resolve("./__mocks__/react-navi.js");
config.resolve.alias["react-navi"] = require.resolve(
"./__mocks__/react-navi.js",
);
return config;
},
babel: async options => ({
babel: async (options) => ({
...options,
plugins: [...options.plugins, "@babel/plugin-proposal-logical-assignment-operators"],
plugins: [
...options.plugins,
"@babel/plugin-proposal-logical-assignment-operators",
],
presets: [
[
"@babel/preset-env",
{
"targets": {
"chrome": 100
}
}
targets: {
chrome: 100,
},
},
],
"@babel/preset-typescript",
"@babel/preset-react"
]
"@babel/preset-react",
],
}),
staticDirs: ["../public"],
framework: {
name: "@storybook/react-webpack5",
options: {}
options: {},
},
docs: {
autodocs: true
}
};
autodocs: true,
},
};
6 changes: 3 additions & 3 deletions editor.planx.uk/.storybook/manager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { addons } from '@storybook/addons'
import theme from './theme'
import { addons } from "@storybook/addons";
import theme from "./theme";

addons.setConfig({
theme,
})
});
2 changes: 1 addition & 1 deletion editor.planx.uk/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export const decorators = [
</ThemeProvider>
</StyledEngineProvider>
),
reactNaviDecorator
reactNaviDecorator,
];
36 changes: 18 additions & 18 deletions editor.planx.uk/.storybook/theme.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import { create } from '@storybook/theming/create'
import { create } from "@storybook/theming/create";

export default create({
base: 'light',
base: "light",

colorPrimary: '#0ECE83',
colorSecondary: 'rgba(0,0,0,0.4)',
colorPrimary: "#0ECE83",
colorSecondary: "rgba(0,0,0,0.4)",

// UI
appBg: 'white',
appContentBg: '#efefef',
appBorderColor: 'black',
appBg: "white",
appContentBg: "#efefef",
appBorderColor: "black",
appBorderRadius: 0,

// Typography
fontBase: "'Inter', Arial",

// Text colors
textColor: 'black',
textInverseColor: 'rgba(255,255,255,0.9)',
textColor: "black",
textInverseColor: "rgba(255,255,255,0.9)",

// Toolbar default and active colors
barTextColor: 'silver',
barSelectedColor: 'black',
barBg: 'white',
barTextColor: "silver",
barSelectedColor: "black",
barBg: "white",

// Form colors
inputBg: 'white',
inputBorder: 'silver',
inputTextColor: 'black',
inputBg: "white",
inputBorder: "silver",
inputTextColor: "black",
inputBorderRadius: 4,

brandTitle: 'Open Systems Lab',
brandUrl: 'https://opensystemslab.io',
})
brandTitle: "Open Systems Lab",
brandUrl: "https://opensystemslab.io",
});
12 changes: 6 additions & 6 deletions editor.planx.uk/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# editor.planx.uk

Editor is our React frontend, which consists of two main environments: an "editor" for service designers and a "preview" for public applicants. Our components are written with Material UI and broadly follow the [GOV.UK design system](https://design-system.service.gov.uk/) patterns.
Editor is our React frontend, which consists of two main environments: an "editor" for service designers and a "preview" for public applicants. Our components are written with Material UI and broadly follow the [GOV.UK design system](https://design-system.service.gov.uk/) patterns.

## Running locally

Expand All @@ -14,8 +14,8 @@ Run tests `pnpm test`

Development notes:

- if you need to test or pull new changes from @opensystemslab/planx-document-templates or @opensystemslab/planx-core, make sure to update the commit hash in package.json first
- you can also use `pnpm link {{local relative path to @opensystemslab/planx-document-templates or @opensystemslab/planx-core}}` to manage local development changes these packages without having to reinstall. If you do this, remember to also run `pnpm unlink` to unlink the local directory and then also update the commit hash to point to the most recent version of the package.
- if you need to test or pull new changes from @opensystemslab/planx-document-templates or @opensystemslab/planx-core, make sure to update the commit hash in package.json first
- you can also use `pnpm link {{local relative path to @opensystemslab/planx-document-templates or @opensystemslab/planx-core}}` to manage local development changes these packages without having to reinstall. If you do this, remember to also run `pnpm unlink` to unlink the local directory and then also update the commit hash to point to the most recent version of the package.

### Disabling type-checking

Expand All @@ -31,6 +31,6 @@ Start the development server by running `pnpm storybook`

Deployment notes:

- Each open pull request will have its own Storybook available at `storybook.{PR#}.planx.pizza`
- Netlify handles production Storybook deploys on every commit to `#main` and updates link https://storybook.planx.uk/
- Notifications for failed Netlify deploys are posted in #planx-notifications-internal on Slack
- Each open pull request will have its own Storybook available at `storybook.{PR#}.planx.pizza`
- Netlify handles production Storybook deploys on every commit to `#main` and updates link https://storybook.planx.uk/
- Notifications for failed Netlify deploys are posted in #planx-notifications-internal on Slack
2 changes: 1 addition & 1 deletion editor.planx.uk/config-overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = function override(config) {
// Optional: Disable type-checking and rely on the IDE's tsserver instead
if (import.meta.env.DISABLE_TYPE_CHECKING) {
config.plugins = config.plugins.filter(
(plugin) => plugin.constructor.name !== "ForkTsCheckerWebpackPlugin"
(plugin) => plugin.constructor.name !== "ForkTsCheckerWebpackPlugin",
);
}
config.resolve.fallback = {
Expand Down
14 changes: 7 additions & 7 deletions editor.planx.uk/docs/adding-a-new-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

Let's add a `SetValue` component

## Core directory & files
## Core directory & files

1. `planx-core/src/types/component.ts`

Add type to enum in `planx-core` repository

```typescript
SetValue = 380,
```
Expand All @@ -23,7 +24,7 @@ export interface SetValue extends MoreInformation {
}

export const parseContent = (
data: Record<string, any> | undefined
data: Record<string, any> | undefined,
): SetValue => ({
fn: data?.fn || "",
...parseMoreInformation(data),
Expand All @@ -50,7 +51,7 @@ function SetValueComponent(props: Props) {

return (
<form onSubmit={formik.handleSubmit} id="modal">
//...
//...
</form>
);
}
Expand Down Expand Up @@ -87,7 +88,7 @@ function SetValueComponent(props: Props) {

1. `src/@planx/components/ui.tsx`

```typescript
```typescript
import PlaylistAdd from "@mui/icons-material/PlaylistAdd";
[TYPES.SetValue]: PlaylistAdd,
```
Expand All @@ -108,7 +109,7 @@ case TYPES.SetValue:
4. `src/pages/FlowEditor/components/forms/FormModal.tsx`

```jsx
<option value={TYPES.SetValue}>SetValue</option>
<option value={TYPES.SetValue}>SetValue</option>
```

5. `src/pages/FlowEditor/components/forms/index.ts`
Expand Down Expand Up @@ -147,11 +148,10 @@ If/how should this component be formatted in Send data formats such as BOPS?
```typescript
function isTypeForBopsPayload(type?: TYPES) {
switch (type) {
// ...
// ...
case TYPES.SetValue:
return false;
// ...
}
}
```

4 changes: 2 additions & 2 deletions editor.planx.uk/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" id="favicon"/>
<link rel="icon" href="/favicon.ico" id="favicon" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"applicationId": "4469ee56-9275-47f3-b29d-e0df0991099a"
}
]
}
}
6 changes: 3 additions & 3 deletions editor.planx.uk/src/@planx/components/Calculate/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default function Component(props: Props) {
});

/**
* When the formula is updated, remove any defaults which are no longer used
*/
* When the formula is updated, remove any defaults which are no longer used
*/
const removeUnusedDefaults = (variables: Set<string>) => {
const defaultKeys = Object.keys(formik.values.defaults);

Expand All @@ -58,7 +58,7 @@ export default function Component(props: Props) {

const variables = React.useMemo(() => {
try {
const variables = getVariables(formik.values.formula)
const variables = getVariables(formik.values.formula);
removeUnusedDefaults(variables);
return [...variables];
} catch (e) {
Expand Down
36 changes: 21 additions & 15 deletions editor.planx.uk/src/@planx/components/Checklist/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,21 +316,27 @@ export const ChecklistComponent: React.FC<ChecklistProps> = (props) => {
}),
},
},
...[options && options
.filter((o) => o.data.text)
.map((o) => ({
...o,
id: o.id || undefined,
type: TYPES.Answer,
}))],
...[groupedOptions && groupedOptions
.flatMap((gr) => gr.children)
.filter((o) => o.data.text)
.map((o) => ({
...o,
id: o.id || undefined,
type: TYPES.Answer,
}))]
...[
options &&
options
.filter((o) => o.data.text)
.map((o) => ({
...o,
id: o.id || undefined,
type: TYPES.Answer,
})),
],
...[
groupedOptions &&
groupedOptions
.flatMap((gr) => gr.children)
.filter((o) => o.data.text)
.map((o) => ({
...o,
id: o.id || undefined,
type: TYPES.Answer,
})),
],
);
} else {
alert(JSON.stringify({ type, ...values, options }, null, 2));
Expand Down
Loading

0 comments on commit ee794d5

Please sign in to comment.