From fa0e14282908862a7afc1ffddd2f020b0f8edb03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dro=C5=84?= Date: Wed, 19 Jul 2023 15:13:35 +0200 Subject: [PATCH] Fix `symbol-description` ESLint rule (#3954) * Add symbol descriptions * Set symbol-description to error & bump migration * add changeset --- .changeset/tasty-cheetahs-change.md | 5 +++++ .eslintrc.json | 3 +-- src/collections/views/consts.ts | 4 ++-- src/components/Datagrid/customCells/NumberCell.tsx | 2 +- src/components/Form/useExitFormDialog.ts | 5 ++--- src/discounts/views/SaleCreate/consts.ts | 2 +- src/discounts/views/SaleDetails/types.ts | 2 +- src/discounts/views/VoucherCreate/types.ts | 2 +- src/discounts/views/VoucherDetails/types.ts | 2 +- src/hooks/useChannels.test.ts | 6 +++--- src/products/views/ProductCreate/consts.ts | 2 +- src/products/views/ProductUpdate/consts.ts | 2 +- .../ShippingZoneRatesCreatePage.stories.tsx | 2 +- .../ShippingZoneRatesPage/ShippingZoneRatesPage.stories.tsx | 2 +- src/shipping/views/RateCreate.tsx | 2 +- src/shipping/views/RateUpdate.tsx | 2 +- 16 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 .changeset/tasty-cheetahs-change.md diff --git a/.changeset/tasty-cheetahs-change.md b/.changeset/tasty-cheetahs-change.md new file mode 100644 index 000000000..51184409a --- /dev/null +++ b/.changeset/tasty-cheetahs-change.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Fix symbol-description ESLint rule diff --git a/.eslintrc.json b/.eslintrc.json index 3b7ea43ee..3ea87a766 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -111,8 +111,7 @@ "no-useless-escape": "off", "prefer-promise-reject-errors": "off", "react/display-name": "off", - "react/jsx-key": "off", - "symbol-description": "warn" + "react/jsx-key": "warn" }, "ignorePatterns": ["node_modules/", "**/types/**/*", "type-policies.ts"] } diff --git a/src/collections/views/consts.ts b/src/collections/views/consts.ts index cbc23fbe5..27044be0a 100644 --- a/src/collections/views/consts.ts +++ b/src/collections/views/consts.ts @@ -1,2 +1,2 @@ -export const COLLECTION_DETAILS_FORM_ID = Symbol(); -export const COLLECTION_CREATE_FORM_ID = Symbol(); +export const COLLECTION_DETAILS_FORM_ID = Symbol("collection-details-form-id"); +export const COLLECTION_CREATE_FORM_ID = Symbol("collection-create-form-id"); diff --git a/src/components/Datagrid/customCells/NumberCell.tsx b/src/components/Datagrid/customCells/NumberCell.tsx index 7ab1b5717..48adc978e 100644 --- a/src/components/Datagrid/customCells/NumberCell.tsx +++ b/src/components/Datagrid/customCells/NumberCell.tsx @@ -10,7 +10,7 @@ import React from "react"; import { Locale } from "../../Locale"; -export const numberCellEmptyValue = Symbol(); +export const numberCellEmptyValue = Symbol("number-cell-empty-value"); interface NumberCellProps { readonly kind: "number-cell"; readonly value: number | typeof numberCellEmptyValue; diff --git a/src/components/Form/useExitFormDialog.ts b/src/components/Form/useExitFormDialog.ts index 26607c250..8b7961a53 100644 --- a/src/components/Form/useExitFormDialog.ts +++ b/src/components/Form/useExitFormDialog.ts @@ -1,4 +1,3 @@ -// @ts-strict-ignore import React, { useContext, useRef } from "react"; import { ExitFormDialogContext } from "./ExitFormDialogProvider"; @@ -12,14 +11,14 @@ export interface UseExitFormDialogResult } export interface UseExitFormDialogProps { - formId: symbol; + formId: symbol | undefined; isDisabled?: boolean; } export const useExitFormDialog = ( { formId, isDisabled }: UseExitFormDialogProps = { formId: undefined }, ): UseExitFormDialogResult => { - const id = useRef(formId || Symbol()).current; + const id = useRef(formId || Symbol("exit-form-fallback-id")).current; const exitDialogProps = useContext(ExitFormDialogContext); const { setIsDirty, setIsSubmitDisabled, setExitDialogSubmitRef } = diff --git a/src/discounts/views/SaleCreate/consts.ts b/src/discounts/views/SaleCreate/consts.ts index 18656e449..79d9257b1 100644 --- a/src/discounts/views/SaleCreate/consts.ts +++ b/src/discounts/views/SaleCreate/consts.ts @@ -1 +1 @@ -export const SALE_CREATE_FORM_ID = Symbol(); +export const SALE_CREATE_FORM_ID = Symbol("sale-create-form-id"); diff --git a/src/discounts/views/SaleDetails/types.ts b/src/discounts/views/SaleDetails/types.ts index a830aa712..cc0797124 100644 --- a/src/discounts/views/SaleDetails/types.ts +++ b/src/discounts/views/SaleDetails/types.ts @@ -1 +1 @@ -export const SALE_UPDATE_FORM_ID = Symbol(); +export const SALE_UPDATE_FORM_ID = Symbol("sale-update-form-id"); diff --git a/src/discounts/views/VoucherCreate/types.ts b/src/discounts/views/VoucherCreate/types.ts index 42f9f2274..1899fe31e 100644 --- a/src/discounts/views/VoucherCreate/types.ts +++ b/src/discounts/views/VoucherCreate/types.ts @@ -1 +1 @@ -export const VOUCHER_CREATE_FORM_ID = Symbol(); +export const VOUCHER_CREATE_FORM_ID = Symbol("voucher-create-form-id"); diff --git a/src/discounts/views/VoucherDetails/types.ts b/src/discounts/views/VoucherDetails/types.ts index 4f5f0f7ef..7db899a13 100644 --- a/src/discounts/views/VoucherDetails/types.ts +++ b/src/discounts/views/VoucherDetails/types.ts @@ -1 +1 @@ -export const VOUCHER_UPDATE_FORM_ID = Symbol(); +export const VOUCHER_UPDATE_FORM_ID = Symbol("voucher-update-form-id"); diff --git a/src/hooks/useChannels.test.ts b/src/hooks/useChannels.test.ts index f69b95f4a..fe90db277 100644 --- a/src/hooks/useChannels.test.ts +++ b/src/hooks/useChannels.test.ts @@ -27,7 +27,7 @@ describe("useChannels", () => { closeModal: jest.fn, openModal: jest.fn, }, - { formId: Symbol() }, + { formId: Symbol("channel-test-form-id") }, ), ); @@ -54,7 +54,7 @@ describe("useChannels", () => { closeModal: jest.fn, openModal: jest.fn, }, - { formId: Symbol() }, + { formId: Symbol("channel-test-form-id") }, ), ); @@ -85,7 +85,7 @@ describe("useChannels", () => { closeModal: jest.fn, openModal: jest.fn, }, - { formId: Symbol() }, + { formId: Symbol("channel-test-form-id") }, ), ); diff --git a/src/products/views/ProductCreate/consts.ts b/src/products/views/ProductCreate/consts.ts index d5b644c98..7f4dfa729 100644 --- a/src/products/views/ProductCreate/consts.ts +++ b/src/products/views/ProductCreate/consts.ts @@ -1 +1 @@ -export const PRODUCT_CREATE_FORM_ID = Symbol(); +export const PRODUCT_CREATE_FORM_ID = Symbol("product-create-form-id"); diff --git a/src/products/views/ProductUpdate/consts.ts b/src/products/views/ProductUpdate/consts.ts index bbf19c3db..3400b0687 100644 --- a/src/products/views/ProductUpdate/consts.ts +++ b/src/products/views/ProductUpdate/consts.ts @@ -1,3 +1,3 @@ export const CHANNELS_AVAILIABILITY_MODAL_SELECTOR = "open-channels-picker"; -export const PRODUCT_UPDATE_FORM_ID = Symbol(); +export const PRODUCT_UPDATE_FORM_ID = Symbol("product-update-form-id"); diff --git a/src/shipping/components/ShippingZoneRatesCreatePage/ShippingZoneRatesCreatePage.stories.tsx b/src/shipping/components/ShippingZoneRatesCreatePage/ShippingZoneRatesCreatePage.stories.tsx index bcab9a7f2..1ced6342e 100644 --- a/src/shipping/components/ShippingZoneRatesCreatePage/ShippingZoneRatesCreatePage.stories.tsx +++ b/src/shipping/components/ShippingZoneRatesCreatePage/ShippingZoneRatesCreatePage.stories.tsx @@ -42,7 +42,7 @@ const defaultChannels = [ const props: ShippingZoneRatesCreatePageProps = { backUrl: "", - formId: Symbol(), + formId: Symbol("shipping-zone-rates-create-form-id"), allChannelsCount: 3, channelErrors: [], disabled: false, diff --git a/src/shipping/components/ShippingZoneRatesPage/ShippingZoneRatesPage.stories.tsx b/src/shipping/components/ShippingZoneRatesPage/ShippingZoneRatesPage.stories.tsx index b7dc51e42..c80508d06 100644 --- a/src/shipping/components/ShippingZoneRatesPage/ShippingZoneRatesPage.stories.tsx +++ b/src/shipping/components/ShippingZoneRatesPage/ShippingZoneRatesPage.stories.tsx @@ -64,7 +64,7 @@ const props: ShippingZoneRatesPageProps = { toggleAll: () => undefined, toolbar: () => undefined, variant: ShippingMethodTypeEnum.PRICE, - formId: Symbol(), + formId: Symbol("shipping-zone-rates-details-form-id"), taxClasses, fetchMoreTaxClasses: undefined, }; diff --git a/src/shipping/views/RateCreate.tsx b/src/shipping/views/RateCreate.tsx index 0b032e695..fd91e99f3 100644 --- a/src/shipping/views/RateCreate.tsx +++ b/src/shipping/views/RateCreate.tsx @@ -30,7 +30,7 @@ import createDialogActionHandlers from "@dashboard/utils/handlers/dialogActionHa import React from "react"; import { useIntl } from "react-intl"; -const FORM_ID = Symbol(); +const FORM_ID = Symbol("shipping-zone-rates-create-form-id"); export interface RateCreateProps { id: string; diff --git a/src/shipping/views/RateUpdate.tsx b/src/shipping/views/RateUpdate.tsx index f26f20828..e1b4dbdb8 100644 --- a/src/shipping/views/RateUpdate.tsx +++ b/src/shipping/views/RateUpdate.tsx @@ -61,7 +61,7 @@ import { mapEdgesToItems } from "@dashboard/utils/maps"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; -const FORM_ID = Symbol(); +const FORM_ID = Symbol("shipping-zone-rates-details-form-id"); export interface RateUpdateProps { id: string;