From 58d2a2b4385ea66676869ce349dc2e3c9b7732cf Mon Sep 17 00:00:00 2001 From: Jonatan Witoszek Date: Tue, 4 Oct 2022 13:30:51 +0200 Subject: [PATCH] ESLint: No unused variables (#1981) * Update eslint config to inform about unused variables * Remove unused variables --- .eslintrc.json | 4 ++++ src/apps/components/AppsInProgress/AppsInProgress.tsx | 2 -- src/apps/components/AppsListPage/AppListPage.stories.tsx | 2 -- src/apps/components/AppsListPage/AppsListPage.tsx | 3 --- src/apps/components/InstalledApps/InstalledApps.tsx | 3 --- src/apps/views/AppsList/AppsList.tsx | 2 -- src/channels/views/ChannelCreate/ChannelCreate.tsx | 3 --- src/components/CardTitle/CardTitle.tsx | 3 --- src/components/ColorPicker/ColorPicker.tsx | 2 +- src/components/RichTextEditor/RichTextEditor.tsx | 1 - src/components/TableButtonWrapper/TableButtonWrapper.tsx | 3 ++- src/components/TableCellHeader/TableCellHeader.tsx | 1 - .../components/CustomerAddress/CustomerAddress.tsx | 1 - .../GiftCardsListTableHeader/GiftCardsListTableHeader.tsx | 1 + .../components/OrderCustomerAddressesEditDialog/utils.ts | 1 + src/orders/utils/data.ts | 1 + src/products/components/ProductListPage/ProductListPage.tsx | 2 -- src/products/views/ProductList/ProductList.tsx | 6 ------ .../components/ShippingZoneRates/ShippingZoneRates.tsx | 1 - .../ShippingZoneRatesPage/ShippingZoneRatesPage.tsx | 2 -- .../components/ShippingZonesList/ShippingZonesList.tsx | 1 - src/shipping/views/RateUpdate.tsx | 1 - src/storybook/stories/products/ProductListPage.tsx | 1 - src/storybook/webpack.config.js | 2 -- 24 files changed, 10 insertions(+), 39 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 66dbfcc26..e15db3994 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -72,6 +72,10 @@ "@typescript-eslint/triple-slash-reference": "error", "@typescript-eslint/type-annotation-spacing": "off", "@typescript-eslint/unified-signatures": "error", + "@typescript-eslint/no-unused-vars": [ + "error", + { "argsIgnorePattern": "^_" } + ], "arrow-body-style": "error", "arrow-parens": ["off", "as-needed"], "camelcase": "off", diff --git a/src/apps/components/AppsInProgress/AppsInProgress.tsx b/src/apps/components/AppsInProgress/AppsInProgress.tsx index 2f4a58409..0f29fa452 100644 --- a/src/apps/components/AppsInProgress/AppsInProgress.tsx +++ b/src/apps/components/AppsInProgress/AppsInProgress.tsx @@ -27,14 +27,12 @@ import { useStyles } from "../../styles"; export interface AppsInProgressProps { appsList: AppsInstallationsQuery["appsInstallations"]; - disabled: boolean; onAppInstallRetry: (id: string) => void; onRemove: (id: string) => void; } const AppsInProgress: React.FC = ({ appsList, - disabled, onAppInstallRetry, onRemove, ...props diff --git a/src/apps/components/AppsListPage/AppListPage.stories.tsx b/src/apps/components/AppsListPage/AppListPage.stories.tsx index 5a4de8b26..9ca9fec30 100644 --- a/src/apps/components/AppsListPage/AppListPage.stories.tsx +++ b/src/apps/components/AppsListPage/AppListPage.stories.tsx @@ -27,7 +27,6 @@ const props: AppsListPageProps = { customAppsList, disabled: false, installedAppsList: appsList, - loadingAppsInProgress: false, getCustomAppHref: () => "", onAppInProgressRemove: () => undefined, onAppInstallRetry: () => undefined, @@ -51,7 +50,6 @@ storiesOf("Views / Apps / Apps list", module) {...props} appsInProgressList={undefined} disabled={true} - loadingAppsInProgress={true} installedAppsList={undefined} customAppsList={undefined} /> diff --git a/src/apps/components/AppsListPage/AppsListPage.tsx b/src/apps/components/AppsListPage/AppsListPage.tsx index 568ab84a5..7a7f1f36a 100644 --- a/src/apps/components/AppsListPage/AppsListPage.tsx +++ b/src/apps/components/AppsListPage/AppsListPage.tsx @@ -15,7 +15,6 @@ export interface AppsListPageProps extends ListProps { installedAppsList: AppsListQuery["apps"]["edges"]; customAppsList: AppsListQuery["apps"]["edges"]; appsInProgressList?: AppsInstallationsQuery; - loadingAppsInProgress: boolean; getCustomAppHref: (id: string) => string; onInstalledAppRemove: (id: string) => void; onCustomAppRemove: (id: string) => void; @@ -27,7 +26,6 @@ const AppsListPage: React.FC = ({ appsInProgressList, customAppsList, installedAppsList, - loadingAppsInProgress, getCustomAppHref, onInstalledAppRemove, onCustomAppRemove, @@ -58,7 +56,6 @@ const AppsListPage: React.FC = ({ diff --git a/src/apps/components/InstalledApps/InstalledApps.tsx b/src/apps/components/InstalledApps/InstalledApps.tsx index 64d57debd..0c197ef6e 100644 --- a/src/apps/components/InstalledApps/InstalledApps.tsx +++ b/src/apps/components/InstalledApps/InstalledApps.tsx @@ -32,9 +32,6 @@ export interface InstalledAppsProps extends ListProps { const InstalledApps: React.FC = ({ appsList, onRemove, - settings, - disabled, - onUpdateListSettings, ...props }) => { const intl = useIntl(); diff --git a/src/apps/views/AppsList/AppsList.tsx b/src/apps/views/AppsList/AppsList.tsx index 0f81aaf64..9ae4574cf 100644 --- a/src/apps/views/AppsList/AppsList.tsx +++ b/src/apps/views/AppsList/AppsList.tsx @@ -81,7 +81,6 @@ export const AppsList: React.FC = ({ params }) => { const { data: appsInProgressData, - loading: loadingAppsInProgress, refetch: appsInProgressRefetch, } = useAppsInstallationsQuery({ displayLoader: false, @@ -331,7 +330,6 @@ export const AppsList: React.FC = ({ params }) => { installedAppsList={installedApps} customAppsList={customApps} appsInProgressList={appsInProgressData} - loadingAppsInProgress={loadingAppsInProgress} disabled={loading || customAppsLoading} settings={settings} onUpdateListSettings={updateListSettings} diff --git a/src/channels/views/ChannelCreate/ChannelCreate.tsx b/src/channels/views/ChannelCreate/ChannelCreate.tsx index d7948bb94..e250ffe73 100644 --- a/src/channels/views/ChannelCreate/ChannelCreate.tsx +++ b/src/channels/views/ChannelCreate/ChannelCreate.tsx @@ -59,11 +59,8 @@ export const ChannelCreateView = ({}) => { const handleSubmit = async ({ shippingZonesIdsToAdd, - shippingZonesIdsToRemove, warehousesIdsToAdd, - warehousesIdsToRemove, warehousesToDisplay, - shippingZonesToDisplay, currencyCode, allocationStrategy, ...rest diff --git a/src/components/CardTitle/CardTitle.tsx b/src/components/CardTitle/CardTitle.tsx index 788dd6f6f..74ec04f50 100644 --- a/src/components/CardTitle/CardTitle.tsx +++ b/src/components/CardTitle/CardTitle.tsx @@ -4,7 +4,6 @@ import React from "react"; interface CardTitleProps { children?: React.ReactNode; className?: string; - height?: "default" | "const"; title: string | React.ReactNode; subtitle?: string | React.ReactNode; toolbar?: React.ReactNode; @@ -15,11 +14,9 @@ interface CardTitleProps { const CardTitle: React.FC = ({ className, children, - height, title, subtitle, toolbar, - onClick, ...rest }) => ( = ({ ); const [hue, setHue] = useState(convert.hex.hsv(hex)[0]); - const [_, s, v] = convert.hex.hsv(hex); + const [, s, v] = convert.hex.hsv(hex); const [r, g, b] = convert.hex.rgb(hex); const isValidColor = hex.match(/^(?:[0-9a-fA-F]{3}){1,2}$/); diff --git a/src/components/RichTextEditor/RichTextEditor.tsx b/src/components/RichTextEditor/RichTextEditor.tsx index c4b286282..d026a7a37 100644 --- a/src/components/RichTextEditor/RichTextEditor.tsx +++ b/src/components/RichTextEditor/RichTextEditor.tsx @@ -46,7 +46,6 @@ const RichTextEditor: React.FC = ({ helperText, editorRef, onInitialize, - onReady, ...props }) => { const classes = useStyles({}); diff --git a/src/components/TableButtonWrapper/TableButtonWrapper.tsx b/src/components/TableButtonWrapper/TableButtonWrapper.tsx index 3ace74ef1..7af14204d 100644 --- a/src/components/TableButtonWrapper/TableButtonWrapper.tsx +++ b/src/components/TableButtonWrapper/TableButtonWrapper.tsx @@ -19,7 +19,8 @@ interface TableButtonWrapper { */ export const TableButtonWrapper = ({ children, -}: TableButtonWrapper) => { +}: // eslint-disable-next-line @typescript-eslint/no-unused-vars +TableButtonWrapper) => { const onClick = (e: React.MouseEvent) => { if (!children.props.href) { // is a that wraps each diff --git a/src/components/TableCellHeader/TableCellHeader.tsx b/src/components/TableCellHeader/TableCellHeader.tsx index 9d013e69e..2978cd661 100644 --- a/src/components/TableCellHeader/TableCellHeader.tsx +++ b/src/components/TableCellHeader/TableCellHeader.tsx @@ -74,7 +74,6 @@ const TableCellHeader = React.forwardRef( textAlign, disabled = false, onClick, - title, ...rest } = props; diff --git a/src/customers/components/CustomerAddress/CustomerAddress.tsx b/src/customers/components/CustomerAddress/CustomerAddress.tsx index ed8067780..e4c6a97be 100644 --- a/src/customers/components/CustomerAddress/CustomerAddress.tsx +++ b/src/customers/components/CustomerAddress/CustomerAddress.tsx @@ -104,7 +104,6 @@ const CustomerAddress: React.FC = props => { ) } - height="const" toolbar={ = ({ }), }; + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { title, ...headerTooltipItemProps } = headerTooltipItem; return ( diff --git a/src/orders/components/OrderCustomerAddressesEditDialog/utils.ts b/src/orders/components/OrderCustomerAddressesEditDialog/utils.ts index 176078203..987a160a7 100644 --- a/src/orders/components/OrderCustomerAddressesEditDialog/utils.ts +++ b/src/orders/components/OrderCustomerAddressesEditDialog/utils.ts @@ -26,6 +26,7 @@ interface AddressEditCommonProps { } export const stringifyAddress = (address: Partial): string => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { id, ...addressWithoutId } = address; return Object.values(flatten(addressWithoutId)).join(" "); }; diff --git a/src/orders/utils/data.ts b/src/orders/utils/data.ts index d3fea6b12..37076baa1 100644 --- a/src/orders/utils/data.ts +++ b/src/orders/utils/data.ts @@ -278,6 +278,7 @@ export function mergeRepeatedOrderLines( export function addressToAddressInput( address: T & AddressFragment, ): AddressInput { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { id, __typename, ...rest } = address; return { ...rest, diff --git a/src/products/components/ProductListPage/ProductListPage.tsx b/src/products/components/ProductListPage/ProductListPage.tsx index f3fb3cc1f..f94b8c0bc 100644 --- a/src/products/components/ProductListPage/ProductListPage.tsx +++ b/src/products/components/ProductListPage/ProductListPage.tsx @@ -60,7 +60,6 @@ export interface ProductListPageProps currencySymbol: string; gridAttributes: RelayToFlat; limits: RefreshLimitsQuery["shop"]["limits"]; - totalGridAttributes: number; products: RelayToFlat; onAdd: () => void; onExport: () => void; @@ -101,7 +100,6 @@ export const ProductListPage: React.FC = props => { loading, settings, tabs, - totalGridAttributes, onAdd, onAll, onColumnQueryChange, diff --git a/src/products/views/ProductList/ProductList.tsx b/src/products/views/ProductList/ProductList.tsx index 487c8e7fd..02ec48b75 100644 --- a/src/products/views/ProductList/ProductList.tsx +++ b/src/products/views/ProductList/ProductList.tsx @@ -387,12 +387,6 @@ export const ProductList: React.FC = ({ params }) => { defaultSettings={defaultListSettings[ListViews.PRODUCT_LIST]} filterOpts={filterOpts} gridAttributes={mapEdgesToItems(gridAttributes?.data?.grid) || []} - totalGridAttributes={maybe( - () => - availableInGridAttributesOpts.result.data.availableInGrid - .totalCount, - 0, - )} settings={settings} loading={ availableInGridAttributesOpts.result.loading || gridAttributes.loading diff --git a/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx b/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx index d0cad1faa..03eead705 100644 --- a/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx +++ b/src/shipping/components/ShippingZoneRates/ShippingZoneRates.tsx @@ -77,7 +77,6 @@ const ShippingZoneRates: React.FC = props => { return ( = ({ channelErrors, disabled, errors, - havePostalCodesChanged, backHref, onDelete, onSubmit, diff --git a/src/shipping/components/ShippingZonesList/ShippingZonesList.tsx b/src/shipping/components/ShippingZonesList/ShippingZonesList.tsx index 7efe2cf04..79ae08efb 100644 --- a/src/shipping/components/ShippingZonesList/ShippingZonesList.tsx +++ b/src/shipping/components/ShippingZonesList/ShippingZonesList.tsx @@ -70,7 +70,6 @@ const ShippingZonesList: React.FC = props => { return ( = ({ unassignProductOpts?.status === "loading" || assignProductOpts?.status === "loading" } - havePostalCodesChanged={state.havePostalCodesChanged} saveButtonBarState={updateShippingRateOpts.status} onDelete={() => openModal("remove")} backHref={shippingZoneUrl(id)} diff --git a/src/storybook/stories/products/ProductListPage.tsx b/src/storybook/stories/products/ProductListPage.tsx index f4853e801..be9696615 100644 --- a/src/storybook/stories/products/ProductListPage.tsx +++ b/src/storybook/stories/products/ProductListPage.tsx @@ -53,7 +53,6 @@ const props: ProductListPageProps = { ...pageListProps.default.settings, columns: ["availability", "productType", "price"], }, - totalGridAttributes: attributes.length, }; storiesOf("Views / Products / Product list", module) diff --git a/src/storybook/webpack.config.js b/src/storybook/webpack.config.js index 4c241be8a..c11abb470 100644 --- a/src/storybook/webpack.config.js +++ b/src/storybook/webpack.config.js @@ -3,8 +3,6 @@ const path = require("path"); const CheckerPlugin = require("fork-ts-checker-webpack-plugin"); const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin"); -const resolve = resolvePath => path.resolve(__dirname, resolvePath); - module.exports = ({ config }) => { config.module.rules.push({ exclude: /node_modules/,