diff --git a/.changeset/tasty-turtles-cover.md b/.changeset/tasty-turtles-cover.md new file mode 100644 index 000000000..44f2c2cf5 --- /dev/null +++ b/.changeset/tasty-turtles-cover.md @@ -0,0 +1,5 @@ +--- +"saleor-dashboard": patch +--- + +Fix eslint rule no-case-declarations diff --git a/.eslintrc.json b/.eslintrc.json index 9df011dbe..95b04b4f0 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -100,8 +100,7 @@ "react-refresh/only-export-components": "off", "array-callback-return": "off", "import/export": "off", - "n/no-callback-literal": "off", - "no-case-declarations": "warn" + "n/no-callback-literal": "warn" }, "ignorePatterns": ["node_modules/", "**/types/**/*", "type-policies.ts"] } diff --git a/src/categories/components/CategoryProductListDatagrid/datagrid.ts b/src/categories/components/CategoryProductListDatagrid/datagrid.ts index 830696643..2410137b4 100644 --- a/src/categories/components/CategoryProductListDatagrid/datagrid.ts +++ b/src/categories/components/CategoryProductListDatagrid/datagrid.ts @@ -35,10 +35,13 @@ export const createGetCellContent = switch (columnId) { case "name": - const name = rowData?.name ?? ""; - return thumbnailCell(name, rowData?.thumbnail?.url ?? "", { - cursor: "pointer", - }); + return thumbnailCell( + rowData?.name ?? "", + rowData?.thumbnail?.url ?? "", + { + cursor: "pointer", + }, + ); default: return readonlyTextCell("", false); } diff --git a/src/collections/components/CollectionListDatagrid/datagrid.ts b/src/collections/components/CollectionListDatagrid/datagrid.ts index 92131e0af..e749b6be0 100644 --- a/src/collections/components/CollectionListDatagrid/datagrid.ts +++ b/src/collections/components/CollectionListDatagrid/datagrid.ts @@ -81,7 +81,7 @@ export const createGetCellContent = return readonlyTextCell( rowData?.products?.totalCount?.toString() ?? "", ); - case "availability": + case "availability": { const { label, color } = !!channel ? getAvailablilityLabelWhenSelectedChannel( channel, @@ -104,6 +104,7 @@ export const createGetCellContent = allowOverlay: false, }, ); + } default: return readonlyTextCell(""); } diff --git a/src/components/Attributes/AttributeRow.tsx b/src/components/Attributes/AttributeRow.tsx index 6a386d2b7..771888bcf 100644 --- a/src/components/Attributes/AttributeRow.tsx +++ b/src/components/Attributes/AttributeRow.tsx @@ -147,7 +147,7 @@ const AttributeRow: React.FC = ({ /> ); - case AttributeInputTypeEnum.RICH_TEXT: + case AttributeInputTypeEnum.RICH_TEXT: { const { getShouldMount, getDefaultValue, @@ -178,6 +178,7 @@ const AttributeRow: React.FC = ({ )} ); + } case AttributeInputTypeEnum.NUMERIC: return ( = ({ status }) => { label={intl.formatMessage(statusMessages.info)} /> ); - default: + default: { const _exhaustiveCheck: never = status; return _exhaustiveCheck; + } } }; diff --git a/src/pages/components/PageListDatagrid/datagrid.ts b/src/pages/components/PageListDatagrid/datagrid.ts index 02e897406..176bee87c 100644 --- a/src/pages/components/PageListDatagrid/datagrid.ts +++ b/src/pages/components/PageListDatagrid/datagrid.ts @@ -64,7 +64,7 @@ export const createGetCellContent = return readonlyTextCell(rowData?.title ?? ""); case "slug": return readonlyTextCell(rowData?.slug ?? ""); - case "visible": + case "visible": { const tag = rowData?.isPublished ? intl.formatMessage(messages.published) : intl.formatMessage(messages.notPublished); @@ -82,6 +82,7 @@ export const createGetCellContent = ], [tag], ); + } default: return readonlyTextCell(""); } diff --git a/src/products/components/ProductVariants/utils.tsx b/src/products/components/ProductVariants/utils.tsx index ee376c7cd..8b7e8470a 100644 --- a/src/products/components/ProductVariants/utils.tsx +++ b/src/products/components/ProductVariants/utils.tsx @@ -122,9 +122,10 @@ export function getData({ switch (columnId) { case "name": - case "sku": + case "sku": { const value = change ?? (dataRow ? dataRow[columnId] : ""); return textCell(value || ""); + } } if (getColumnStock(columnId)) { diff --git a/src/products/views/ProductList/filters.ts b/src/products/views/ProductList/filters.ts index 7a5f916c7..112b27428 100644 --- a/src/products/views/ProductList/filters.ts +++ b/src/products/views/ProductList/filters.ts @@ -331,7 +331,7 @@ export const parseFilterValue = ( lte: isMulti ? value[1] || null : value[0], }), }; - case ProductListUrlFiltersAsDictWithMultipleValues.numericAttributes: + case ProductListUrlFiltersAsDictWithMultipleValues.numericAttributes: { const [gte, lte] = value.map(v => parseFloat(v)); return { @@ -341,6 +341,7 @@ export const parseFilterValue = ( lte: isMulti ? lte || undefined : gte || undefined, }, }; + } default: return { ...name, values: value }; } diff --git a/src/staff/components/StaffListDatagrid/datagrid.ts b/src/staff/components/StaffListDatagrid/datagrid.ts index fa19976cb..00f93b745 100644 --- a/src/staff/components/StaffListDatagrid/datagrid.ts +++ b/src/staff/components/StaffListDatagrid/datagrid.ts @@ -73,7 +73,7 @@ export const createGetCellContent = cursor: "pointer", }, ); - case "status": + case "status": { const isActive = rowData?.isActive; const status = isActive ? intl.formatMessage(commonStatusMessages.active) @@ -96,6 +96,7 @@ export const createGetCellContent = allowOverlay: false, }, ); + } case "email": return readonlyTextCell(rowData?.email ?? PLACEHOLDER); default: