Fix no-case-declarations eslint rule (#4098)

This commit is contained in:
Paweł Chyła 2023-08-22 09:41:41 +02:00 committed by GitHub
parent fae08cbd32
commit 1cec02e1b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 31 additions and 15 deletions

View file

@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---
Fix eslint rule no-case-declarations

View file

@ -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"]
}

View file

@ -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);
}

View file

@ -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("");
}

View file

@ -147,7 +147,7 @@ const AttributeRow: React.FC<AttributeRowProps> = ({
/>
</BasicAttributeRow>
);
case AttributeInputTypeEnum.RICH_TEXT:
case AttributeInputTypeEnum.RICH_TEXT: {
const {
getShouldMount,
getDefaultValue,
@ -178,6 +178,7 @@ const AttributeRow: React.FC<AttributeRowProps> = ({
)}
</BasicAttributeRow>
);
}
case AttributeInputTypeEnum.NUMERIC:
return (
<BasicAttributeRow

View file

@ -89,7 +89,7 @@ export const createGetCellContent =
last4CodeChars: rowData?.last4CodeChars ?? "",
}),
);
case "status":
case "status": {
const status = getStatusText(rowData);
if (!status) {
@ -121,6 +121,7 @@ export const createGetCellContent =
],
[statusLabel],
);
}
case "tag":
return readonlyTextCell(getTagCellText(rowData?.tags ?? []));
case "product":

View file

@ -130,7 +130,7 @@ export const useGetCellContent = ({
allowOverlay: true,
},
);
case "status":
case "status": {
const orderErrors = getOrderErrors(errors, rowData.id);
const status = getOrderLineStatus(intl, rowData, orderErrors);
@ -142,6 +142,7 @@ export const useGetCellContent = ({
allowOverlay: false,
},
);
}
case "sku":
return readonlyTextCell(rowData?.productSku ?? "", false);
case "variantName":

View file

@ -53,8 +53,9 @@ export const EventStatus: React.FC<EventStatusProps> = ({ status }) => {
label={intl.formatMessage(statusMessages.info)}
/>
);
default:
default: {
const _exhaustiveCheck: never = status;
return _exhaustiveCheck;
}
}
};

View file

@ -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("");
}

View file

@ -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)) {

View file

@ -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 };
}

View file

@ -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: