From a9137cb7fe5e5a31eafa31a12f765fb798330dac Mon Sep 17 00:00:00 2001 From: David Inga Date: Wed, 3 Jan 2024 13:50:19 +0100 Subject: [PATCH] upgraded eslint and prettier --- client/.eslintrc.js | 8 +- client/.prettierrc.cjs | 10 ++ client/.prettierrc.json | 8 - client/next.config.js | 3 - client/package.json | 9 +- client/src/components/accordion/component.tsx | 4 +- client/src/components/avatar/component.tsx | 2 +- client/src/components/back-link/component.tsx | 4 +- client/src/components/badge/component.tsx | 4 +- .../src/components/button-group/component.tsx | 2 +- client/src/components/button/component.tsx | 4 +- client/src/components/callout/component.tsx | 4 +- .../components/dialogs/delete/component.tsx | 14 +- .../src/components/disclaimer/component.tsx | 8 +- client/src/components/dropdown/component.tsx | 2 +- .../components/file-dropzone/component.tsx | 2 +- .../components/forms/checkbox/component.tsx | 4 +- .../src/components/forms/input/component.tsx | 10 +- .../src/components/forms/label/component.tsx | 2 +- .../src/components/forms/radio/component.tsx | 4 +- .../src/components/forms/range/component.tsx | 10 +- .../forms/select/autocomplete/component.tsx | 24 +-- .../src/components/forms/select/component.tsx | 20 +-- .../components/forms/textarea/component.tsx | 6 +- client/src/components/icons/opacity.tsx | 2 +- .../src/components/info-tooltip/component.tsx | 4 +- .../legend/item/comparisonModeToggle.tsx | 2 +- .../src/components/legend/item/component.tsx | 22 +-- .../src/components/legend/item/dragHandle.tsx | 2 +- .../src/components/legend/item/info-modal.tsx | 12 +- .../components/legend/item/opacityControl.tsx | 10 +- .../legend/types/basic/component.tsx | 4 +- .../legend/types/categorical/component.tsx | 4 +- .../legend/types/choropleth/component.tsx | 6 +- .../legend/types/comparative/component.tsx | 6 +- .../legend/types/gradient/component.tsx | 4 +- .../map/controls/basemap/component.tsx | 8 +- .../map/controls/zoom/component.tsx | 6 +- .../map/layers/mapbox/raster/hooks.tsx | 3 +- client/src/components/map/popup/component.tsx | 2 +- client/src/components/modal/component.tsx | 12 +- client/src/components/pill/component.tsx | 2 +- client/src/components/search/component.tsx | 8 +- .../components/string-avatar/component.tsx | 2 +- client/src/components/table/cell.tsx | 16 +- client/src/components/table/component.tsx | 18 +- .../table/pagination/button/component.tsx | 4 +- .../components/table/pagination/component.tsx | 12 +- client/src/components/table/row.tsx | 6 +- client/src/components/tabs/component.tsx | 4 +- client/src/components/toggle/component.tsx | 8 +- client/src/components/tooltip/component.tsx | 4 +- .../tree-select/checkbox/component.tsx | 2 +- .../src/components/tree-select/component.tsx | 28 ++-- .../components/tree-select/search-input.tsx | 4 +- .../components/tree-select/search-overlay.tsx | 8 +- client/src/components/widget/component.tsx | 2 +- .../containers/admin/data-table/component.tsx | 14 +- .../admin/data-upload-error/component.tsx | 4 +- .../admin/data-uploader/component.tsx | 6 +- .../admin/edit-target-modal/component.tsx | 8 +- .../containers/admin/no-data/component.tsx | 4 +- .../comparison-chart/component.tsx | 8 +- .../comparison-chart/legend/component.tsx | 10 +- .../comparison-chart/tooltip/component.tsx | 10 +- .../analysis-chart/impact-chart/component.tsx | 8 +- .../impact-chart/legend/component.tsx | 8 +- .../impact-chart/tooltip/component.tsx | 6 +- .../containers/analysis-sidebar/component.tsx | 24 +-- .../categories/category-header/component.tsx | 2 +- .../categories/category-layer/component.tsx | 8 +- .../toggle-preview/component.tsx | 4 +- .../analysis-contextual-layer/component.tsx | 18 +- .../materials/component.tsx | 10 +- .../preview-map/component.tsx | 4 +- .../analysis-dynamic-metadata/component.tsx | 8 +- .../analysis-filters/indicators/component.tsx | 2 +- .../more-filters/component.tsx | 12 +- .../analysis-legend/component.tsx | 15 +- .../contextual-legend-item/component.tsx | 1 - .../material-legend-item/component.tsx | 2 +- .../analysis-map/component.tsx | 16 +- .../analysis-map/layers/contextual/hooks.tsx | 6 +- .../analysis-map/layers/impact/hooks.ts | 6 +- .../analysis-map/layers/material/hooks.ts | 6 +- .../comparison-cell/component.tsx | 8 +- .../analysis-table/component.tsx | 20 +-- .../analysis-table/types.d.ts | 4 +- .../containers/collapse-button/component.tsx | 2 +- .../delete-user-modal/component.tsx | 8 +- client/src/containers/edit-user/component.tsx | 2 +- client/src/containers/edit-user/user-form.tsx | 2 +- .../filters/years-range/component.tsx | 8 +- .../interventions/form/component.tsx | 46 +++--- .../containers/mobile-header/component.tsx | 4 +- .../src/containers/mode-control/component.tsx | 6 +- .../navigation/desktop/component.tsx | 10 +- .../containers/navigation/error/component.tsx | 4 +- .../navigation/mobile/component.tsx | 4 +- .../src/containers/page-loading/component.tsx | 6 +- .../containers/scenarios/card/component.tsx | 8 +- .../scenarios/comparison/component.tsx | 2 +- .../scenarios/filters/component.tsx | 2 +- .../containers/scenarios/form/component.tsx | 4 +- .../containers/scenarios/item/component.tsx | 28 ++-- .../scenarios/scenario-items/actions.tsx | 11 +- .../scenarios/scenario-items/growth-rate.tsx | 2 +- .../scenario-items/interventions.tsx | 2 +- .../scenarios/scenario-items/make-public.tsx | 4 +- .../containers/scenarios/table/component.tsx | 2 +- .../targets/input-list/component.tsx | 14 +- .../src/containers/targets/item/component.tsx | 4 +- .../src/containers/targets/list/component.tsx | 8 +- client/src/containers/toaster/component.tsx | 2 +- .../update-password-form/component.tsx | 4 +- .../update-profile-form/component.tsx | 4 +- client/src/containers/uploader/component.tsx | 10 +- .../containers/user-dropdown/component.tsx | 16 +- client/src/containers/years/component.tsx | 1 + client/src/hooks/admin-regions/index.ts | 2 +- client/src/hooks/business-units/index.ts | 4 +- client/src/hooks/sourcing-locations/index.ts | 2 +- client/src/layouts/admin/component.tsx | 6 +- client/src/layouts/analysis/component.tsx | 14 +- client/src/layouts/application/component.tsx | 12 +- .../layouts/application/icons/chart-bar.tsx | 4 +- .../src/layouts/authentication/component.tsx | 4 +- client/src/layouts/clean/component.tsx | 4 +- client/src/pages/404.tsx | 6 +- client/src/pages/_error.tsx | 4 +- client/src/pages/analysis/chart.tsx | 6 +- .../pages/auth/activate-account/[token].tsx | 2 +- client/src/pages/auth/forgot-password.tsx | 20 +-- .../src/pages/auth/reset-password/[token].tsx | 2 +- client/src/pages/auth/signin.tsx | 4 +- client/src/pages/auth/signup.tsx | 4 +- client/src/pages/data/index.tsx | 4 +- .../data/scenarios/[scenarioId]/edit.tsx | 32 ++-- .../interventions/[interventionId]/edit.tsx | 4 +- .../[scenarioId]/interventions/new.tsx | 10 +- client/src/pages/data/scenarios/index.tsx | 26 +-- client/src/pages/data/scenarios/new.tsx | 2 +- client/src/pages/data/targets.tsx | 8 +- client/src/pages/profile/index.tsx | 4 +- client/src/pages/profile/users.tsx | 18 +- client/src/store/index.ts | 4 +- client/src/store/utils.ts | 4 +- client/src/utils/csv-download.ts | 1 - client/tsconfig.eslint.json | 4 + client/tsconfig.json | 26 ++- client/yarn.lock | 155 +++++++++++++----- 151 files changed, 697 insertions(+), 602 deletions(-) create mode 100644 client/.prettierrc.cjs delete mode 100644 client/.prettierrc.json create mode 100644 client/tsconfig.eslint.json diff --git a/client/.eslintrc.js b/client/.eslintrc.js index 36a5955f59..dad9749d5d 100644 --- a/client/.eslintrc.js +++ b/client/.eslintrc.js @@ -3,10 +3,16 @@ module.exports = { extends: [ 'next/core-web-vitals', 'plugin:@typescript-eslint/recommended', - 'plugin:prettier/recommended', 'plugin:import/recommended', 'plugin:import/typescript', + 'plugin:prettier/recommended', ], + parser: '@typescript-eslint/parser', + parserOptions: { + tsconfigRootDir: __dirname, + project: ['./tsconfig.eslint.json'], + }, + plugins: ['@typescript-eslint', 'prettier'], settings: { 'import/resolver': { typescript: true, diff --git a/client/.prettierrc.cjs b/client/.prettierrc.cjs new file mode 100644 index 0000000000..048e029bb2 --- /dev/null +++ b/client/.prettierrc.cjs @@ -0,0 +1,10 @@ +/** @type {import("prettier").Options} */ +module.exports = { + semi: true, + tabWidth: 2, + printWidth: 100, + singleQuote: true, + trailingComma: 'all', + editorconfig: true, + plugins: ['prettier-plugin-tailwindcss'], +}; diff --git a/client/.prettierrc.json b/client/.prettierrc.json deleted file mode 100644 index c73b4c1b4e..0000000000 --- a/client/.prettierrc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "semi": true, - "tabWidth": 2, - "printWidth": 100, - "singleQuote": true, - "trailingComma": "all", - "editorconfig": true -} diff --git a/client/next.config.js b/client/next.config.js index c0df00ee3d..2b183b914f 100644 --- a/client/next.config.js +++ b/client/next.config.js @@ -4,9 +4,6 @@ const nextConfig = { // ! the current approach we follow to handle layers on the map does not work with strict mode enabled, // ! do not enable it unless you know what you are doing or know the issue is fixed. reactStrictMode: false, - eslint: { - dirs: ['src'], - }, output: 'standalone', redirects() { return [ diff --git a/client/package.json b/client/package.json index 9a4553c86e..1931c277c1 100644 --- a/client/package.json +++ b/client/package.json @@ -31,7 +31,7 @@ "@headlessui/react": "v1.7.17", "@heroicons/react": "v1.0.6", "@hookform/resolvers": "2.8.8", - "@json2csv/plainjs": "^6.1.3", + "@json2csv/plainjs": "7.0.4", "@loaders.gl/core": "3.3.1", "@luma.gl/constants": "8.5.18", "@reduxjs/toolkit": "1.8.2", @@ -88,14 +88,15 @@ "cypress": "13.2.0", "eslint": "8.23.1", "eslint-config-next": "13.5.5", - "eslint-config-prettier": "8.6.0", + "eslint-config-prettier": "^9.1.0", "eslint-import-resolver-typescript": "3.6.1", "eslint-plugin-import": "^2.26.0", - "eslint-plugin-prettier": "4.2.1", + "eslint-plugin-prettier": "^5.1.2", "istanbul-reports": "3.0.0", "nyc": "15.1.0", "nyc-report-lcov-absolute": "1.0.0", - "prettier": "2.8.3", + "prettier": "^3.1.1", + "prettier-plugin-tailwindcss": "^0.5.10", "start-server-and-test": "1.14.0", "typescript": "5.2.2", "webpack": "5" diff --git a/client/src/components/accordion/component.tsx b/client/src/components/accordion/component.tsx index 42610023ca..64d9220b4f 100644 --- a/client/src/components/accordion/component.tsx +++ b/client/src/components/accordion/component.tsx @@ -45,12 +45,12 @@ const AccordionEntry = ({ header, children, expanded, onExpandedChange }: Accord })} >
diff --git a/client/src/components/avatar/component.tsx b/client/src/components/avatar/component.tsx index e15ffb0fcf..41ccb4b78b 100644 --- a/client/src/components/avatar/component.tsx +++ b/client/src/components/avatar/component.tsx @@ -6,7 +6,7 @@ import type { ImageProps } from 'next/image'; export type AvatarProps = ImageProps; export const Avatar: React.FC = ({ className, ...props }: AvatarProps) => ( -
+
{props.alt
); diff --git a/client/src/components/back-link/component.tsx b/client/src/components/back-link/component.tsx index 93f19c3859..8849760582 100644 --- a/client/src/components/back-link/component.tsx +++ b/client/src/components/back-link/component.tsx @@ -11,11 +11,11 @@ const BackLink: FC> = forwardRef< >(({ children, className, href, ...props }, ref) => ( - + {children} )); diff --git a/client/src/components/badge/component.tsx b/client/src/components/badge/component.tsx index 25d181f0fe..52d057c8b3 100644 --- a/client/src/components/badge/component.tsx +++ b/client/src/components/badge/component.tsx @@ -26,7 +26,7 @@ const Badge: React.FC = ({ return (
= ({ type="button" className={classNames( THEME_CLASSNAMES[theme].closeIcon, - 'flex-shrink-0 h-4 w-4 rounded-full inline-flex items-center justify-center focus:outline-none', + 'inline-flex h-4 w-4 flex-shrink-0 items-center justify-center rounded-full focus:outline-none', )} onClick={handleClick} aria-label="Remove" diff --git a/client/src/components/button-group/component.tsx b/client/src/components/button-group/component.tsx index 1d609fff91..696a2b13af 100644 --- a/client/src/components/button-group/component.tsx +++ b/client/src/components/button-group/component.tsx @@ -1,5 +1,5 @@ const ButtonGroup: React.FC = ({ children }) => ( -
+
{children}
); diff --git a/client/src/components/button/component.tsx b/client/src/components/button/component.tsx index b7b1740396..32e7c2255f 100644 --- a/client/src/components/button/component.tsx +++ b/client/src/components/button/component.tsx @@ -135,8 +135,8 @@ const ButtonTemplate: React.FC = ({ danger, icon, loading, si {loading && ( diff --git a/client/src/components/callout/component.tsx b/client/src/components/callout/component.tsx index 8477e2220b..27418682a4 100644 --- a/client/src/components/callout/component.tsx +++ b/client/src/components/callout/component.tsx @@ -22,9 +22,9 @@ const Callout = ({ type, children }: React.PropsWithChildren) => { const Icon = ICONS_BY_TYPE[type]; return (
- +
{children}
); diff --git a/client/src/components/dialogs/delete/component.tsx b/client/src/components/dialogs/delete/component.tsx index 4460ab9f0f..55649d87b1 100644 --- a/client/src/components/dialogs/delete/component.tsx +++ b/client/src/components/dialogs/delete/component.tsx @@ -27,11 +27,11 @@ export const DeleteDialog: FC> = ({ leaveFrom="opacity-100" leaveTo="opacity-0" > -
+
-
+
> = ({ leaveFrom="opacity-100 translate-y-0 sm:scale-100" leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" > - +
-
-