Fix couple of eslint rules (#4058)
This commit is contained in:
parent
50011f86f2
commit
bb1f78d4e1
28 changed files with 83 additions and 87 deletions
5
.changeset/many-icons-flow.md
Normal file
5
.changeset/many-icons-flow.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"saleor-dashboard": patch
|
||||
---
|
||||
|
||||
Fix couple of eslint rules connected to display name and no-case declarations
|
|
@ -101,16 +101,7 @@
|
|||
"array-callback-return": "off",
|
||||
"import/export": "off",
|
||||
"n/no-callback-literal": "off",
|
||||
"no-case-declarations": "off",
|
||||
"no-empty-pattern": "off",
|
||||
"no-fallthrough": "off",
|
||||
"no-new": "off",
|
||||
"no-prototype-builtins": "off",
|
||||
"no-unreachable": "off",
|
||||
"no-useless-catch": "off",
|
||||
"no-useless-escape": "off",
|
||||
"prefer-promise-reject-errors": "off",
|
||||
"react/display-name": "warn"
|
||||
"no-case-declarations": "warn"
|
||||
},
|
||||
"ignorePatterns": ["node_modules/", "**/types/**/*", "type-policies.ts"]
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { appDetails } from "../../fixtures";
|
|||
import { AppDetailsPage } from "./AppDetailsPage";
|
||||
|
||||
const mockHeader = jest.fn();
|
||||
// eslint-disable-next-line react/display-name
|
||||
jest.mock("./Header", () => props => {
|
||||
mockHeader(props);
|
||||
return <></>;
|
||||
|
|
|
@ -48,6 +48,8 @@ const _AppIFrame = forwardRef<HTMLIFrameElement, AppIFrameProps>(
|
|||
},
|
||||
);
|
||||
|
||||
_AppIFrame.displayName = "AppIFrame";
|
||||
|
||||
export const AppIFrame = memo(_AppIFrame, (prev, next) =>
|
||||
isEqualWith(prev, next),
|
||||
);
|
||||
|
|
|
@ -27,9 +27,8 @@ export const InstallWithManifestFormButton: React.FC<
|
|||
const inputValue = form.get("manifest-url") as string;
|
||||
|
||||
try {
|
||||
new URL(inputValue);
|
||||
|
||||
onSubmitted(inputValue);
|
||||
const parsedURL = new URL(inputValue);
|
||||
onSubmitted(parsedURL.href);
|
||||
} catch (e) {
|
||||
console.error("Invalid URL from input. Should be validated by browser");
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ export const extractQueryParams = (queryString: string) => {
|
|||
if (match) {
|
||||
const arrayKey = match[1];
|
||||
|
||||
if (!queryParams.hasOwnProperty(arrayKey)) {
|
||||
if (!Object.prototype.hasOwnProperty.call(queryParams, arrayKey)) {
|
||||
queryParams[arrayKey] = [];
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ jest.mock("react-intl", () => ({
|
|||
jest.mock("@saleor/macaw-ui", () => ({
|
||||
useStyles: jest.fn(() => () => ({})),
|
||||
makeStyles: jest.fn(() => () => ({})),
|
||||
// eslint-disable-next-line react/display-name
|
||||
DialogHeader: jest.fn(() => () => <></>),
|
||||
}));
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ const _IconButton: React.FC<any> = React.forwardRef(
|
|||
},
|
||||
);
|
||||
|
||||
_IconButton.displayName = "IconButton";
|
||||
|
||||
export const IconButton = _IconButton as <
|
||||
T extends React.ElementType = "button",
|
||||
>(
|
||||
|
|
|
@ -83,3 +83,5 @@ export const Metadata: React.FC<MetadataProps> = memo(({ data, onChange }) => {
|
|||
</Box>
|
||||
);
|
||||
}, propsCompare);
|
||||
|
||||
Metadata.displayName = "Metadata";
|
||||
|
|
|
@ -20,7 +20,7 @@ enum SeoField {
|
|||
description = "seoDescription",
|
||||
}
|
||||
|
||||
const SLUG_REGEX = /^[a-zA-Z0-9\-\_]+$/;
|
||||
const SLUG_REGEX = /^[a-zA-Z0-9\-_]+$/;
|
||||
const maxSlugLength = 255;
|
||||
const maxTitleLength = 70;
|
||||
const maxDescriptionLength = 300;
|
||||
|
|
|
@ -28,17 +28,11 @@ export function useBackgroundTasks(
|
|||
React.useEffect(() => {
|
||||
const intervalId = setInterval(() => {
|
||||
const queue = async () => {
|
||||
try {
|
||||
await Promise.all(
|
||||
tasks.current.map(async task => {
|
||||
if (task.status === TaskStatus.PENDING) {
|
||||
let status: TaskStatus;
|
||||
const status = await handleTask(task);
|
||||
|
||||
try {
|
||||
status = await handleTask(task);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
if (status !== TaskStatus.PENDING) {
|
||||
const taskIndex = tasks.current.findIndex(
|
||||
t => t.id === task.id,
|
||||
|
@ -48,9 +42,6 @@ export function useBackgroundTasks(
|
|||
}
|
||||
}),
|
||||
);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
queue();
|
||||
|
|
|
@ -23,6 +23,7 @@ jest.mock("@saleor/macaw-ui", () => ({
|
|||
useTheme: jest.fn(() => () => ({})),
|
||||
useStyles: jest.fn(() => () => ({})),
|
||||
makeStyles: jest.fn(() => () => ({})),
|
||||
// eslint-disable-next-line react/display-name
|
||||
DialogHeader: jest.fn(() => () => <></>),
|
||||
}));
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ const GiftCardList: React.FC<RouteComponentProps<any>> = () => {
|
|||
return <GiftCardListComponent params={params} />;
|
||||
};
|
||||
|
||||
const Component: React.FC = ({}) => {
|
||||
const Component: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
|
||||
return (
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const Attributes = createSvgIcon(
|
||||
const AttributesIcons = createSvgIcon(
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
@ -11,6 +11,6 @@ const Attributes = createSvgIcon(
|
|||
"Attributes",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<Attributes {...props} viewBox="0 0 32 32" />
|
||||
);
|
||||
export default function Attributes(props: SvgIconProps) {
|
||||
return <AttributesIcons {...props} viewBox="0 0 32 32" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const Channels = createSvgIcon(
|
||||
const ChannelsIcon = createSvgIcon(
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
@ -11,6 +11,6 @@ const Channels = createSvgIcon(
|
|||
"Channels",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<Channels {...props} viewBox="0 0 32 32" />
|
||||
);
|
||||
export default function Channels(props: SvgIconProps) {
|
||||
return <ChannelsIcon {...props} viewBox="0 0 32 32" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const Miscellaneous = createSvgIcon(
|
||||
const MiscellaneousIcon = createSvgIcon(
|
||||
<>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
|
@ -31,6 +31,6 @@ const Miscellaneous = createSvgIcon(
|
|||
"Miscellaneous",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<Miscellaneous {...props} viewBox="0 0 24 24" fill="none" />
|
||||
);
|
||||
export default function Miscellaneous(props: SvgIconProps) {
|
||||
return <MiscellaneousIcon {...props} viewBox="0 0 24 24" fill="none" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const Navigation = createSvgIcon(
|
||||
const NavigationIcon = createSvgIcon(
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
@ -11,6 +11,6 @@ const Navigation = createSvgIcon(
|
|||
"Navigation",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<Navigation {...props} viewBox="0 0 32 32" />
|
||||
);
|
||||
export default function Navigation(props: SvgIconProps) {
|
||||
return <NavigationIcon {...props} viewBox="0 0 32 32" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const PageTypes = createSvgIcon(
|
||||
const PageTypesIcons = createSvgIcon(
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
@ -11,6 +11,6 @@ const PageTypes = createSvgIcon(
|
|||
"PageTypes",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<PageTypes {...props} viewBox="0 0 24 25" />
|
||||
);
|
||||
export default function PageTypes(props: SvgIconProps) {
|
||||
return <PageTypesIcons {...props} viewBox="0 0 24 25" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const PermissionGroups = createSvgIcon(
|
||||
const PermissionGroupsIcon = createSvgIcon(
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
@ -11,6 +11,6 @@ const PermissionGroups = createSvgIcon(
|
|||
"PermissionGroups",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<PermissionGroups {...props} viewBox="0 0 32 32" />
|
||||
);
|
||||
export default function PermissionGroups(props: SvgIconProps) {
|
||||
return <PermissionGroupsIcon {...props} viewBox="0 0 32 32" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const ProductTypes = createSvgIcon(
|
||||
const ProductTypesIcon = createSvgIcon(
|
||||
<>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
|
@ -13,6 +13,6 @@ const ProductTypes = createSvgIcon(
|
|||
"ProductTypes",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<ProductTypes {...props} viewBox="0 0 44 44" />
|
||||
);
|
||||
export default function ProductTypes(props: SvgIconProps) {
|
||||
return <ProductTypesIcon {...props} viewBox="0 0 44 44" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const ShippingMethods = createSvgIcon(
|
||||
const ShippingMethodsIcons = createSvgIcon(
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
@ -11,6 +11,6 @@ const ShippingMethods = createSvgIcon(
|
|||
"ShippingMethods",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<ShippingMethods {...props} viewBox="0 0 32 32" />
|
||||
);
|
||||
export default function ShippingMethods(props: SvgIconProps) {
|
||||
return <ShippingMethodsIcons {...props} viewBox="0 0 32 32" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const SiteSettings = createSvgIcon(
|
||||
const SiteSettingsIcon = createSvgIcon(
|
||||
<>
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
|
@ -19,6 +19,6 @@ const SiteSettings = createSvgIcon(
|
|||
"SiteSettings",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<SiteSettings {...props} viewBox="0 0 32 32" />
|
||||
);
|
||||
export default function SiteSettings(props: SvgIconProps) {
|
||||
return <SiteSettingsIcon {...props} viewBox="0 0 32 32" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const StaffMembers = createSvgIcon(
|
||||
const StaffMembersIcon = createSvgIcon(
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
@ -11,6 +11,6 @@ const StaffMembers = createSvgIcon(
|
|||
"StaffMembers",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<StaffMembers {...props} viewBox="0 0 32 32" />
|
||||
);
|
||||
export default function StaffMembers(props: SvgIconProps) {
|
||||
return <StaffMembersIcon {...props} viewBox="0 0 32 32" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const Taxes = createSvgIcon(
|
||||
const TaxesIcon = createSvgIcon(
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
@ -11,6 +11,6 @@ const Taxes = createSvgIcon(
|
|||
"Taxes",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<Taxes {...props} viewBox="0 0 32 32" />
|
||||
);
|
||||
export default function Taxes(props: SvgIconProps) {
|
||||
return <TaxesIcon {...props} viewBox="0 0 32 32" />;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { createSvgIcon, SvgIconProps } from "@material-ui/core";
|
||||
import React from "react";
|
||||
|
||||
const Warehouses = createSvgIcon(
|
||||
const WarehousesIcon = createSvgIcon(
|
||||
<path
|
||||
fillRule="evenodd"
|
||||
clipRule="evenodd"
|
||||
|
@ -11,6 +11,6 @@ const Warehouses = createSvgIcon(
|
|||
"Warehouses",
|
||||
);
|
||||
|
||||
export default (props: SvgIconProps) => (
|
||||
<Warehouses {...props} viewBox="0 0 32 32" />
|
||||
);
|
||||
export default function Warehouses(props: SvgIconProps) {
|
||||
return <WarehousesIcon {...props} viewBox="0 0 32 32" />;
|
||||
}
|
||||
|
|
|
@ -119,7 +119,6 @@ const MenuDetails: React.FC<MenuDetailsProps> = ({ id, params }) => {
|
|||
|
||||
default:
|
||||
throw unknownTypeError;
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ export const getEventMessage = (
|
|||
defaultMessage: "Order refund information was sent to customer",
|
||||
description: "order history message",
|
||||
});
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
case OrderEventsEnum.FULFILLMENT_CANCELED:
|
||||
return intl.formatMessage({
|
||||
|
|
|
@ -48,7 +48,7 @@ describe("Multiple file upload handler", () => {
|
|||
const handle = createMultiFileUploadHandler((_, fileIndex) => {
|
||||
const promise = new Promise<void>((resolve, reject) => {
|
||||
if (fileIndex === 2) {
|
||||
reject();
|
||||
reject(new Error("mock error"));
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue