Fix couple of eslint rules (#4058)

This commit is contained in:
Krzysztof Żuraw 2023-08-03 14:33:51 +02:00 committed by GitHub
parent 50011f86f2
commit bb1f78d4e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 83 additions and 87 deletions

View file

@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---
Fix couple of eslint rules connected to display name and no-case declarations

View file

@ -101,16 +101,7 @@
"array-callback-return": "off", "array-callback-return": "off",
"import/export": "off", "import/export": "off",
"n/no-callback-literal": "off", "n/no-callback-literal": "off",
"no-case-declarations": "off", "no-case-declarations": "warn"
"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"
}, },
"ignorePatterns": ["node_modules/", "**/types/**/*", "type-policies.ts"] "ignorePatterns": ["node_modules/", "**/types/**/*", "type-policies.ts"]
} }

View file

@ -6,6 +6,7 @@ import { appDetails } from "../../fixtures";
import { AppDetailsPage } from "./AppDetailsPage"; import { AppDetailsPage } from "./AppDetailsPage";
const mockHeader = jest.fn(); const mockHeader = jest.fn();
// eslint-disable-next-line react/display-name
jest.mock("./Header", () => props => { jest.mock("./Header", () => props => {
mockHeader(props); mockHeader(props);
return <></>; return <></>;

View file

@ -48,6 +48,8 @@ const _AppIFrame = forwardRef<HTMLIFrameElement, AppIFrameProps>(
}, },
); );
_AppIFrame.displayName = "AppIFrame";
export const AppIFrame = memo(_AppIFrame, (prev, next) => export const AppIFrame = memo(_AppIFrame, (prev, next) =>
isEqualWith(prev, next), isEqualWith(prev, next),
); );

View file

@ -27,9 +27,8 @@ export const InstallWithManifestFormButton: React.FC<
const inputValue = form.get("manifest-url") as string; const inputValue = form.get("manifest-url") as string;
try { try {
new URL(inputValue); const parsedURL = new URL(inputValue);
onSubmitted(parsedURL.href);
onSubmitted(inputValue);
} catch (e) { } catch (e) {
console.error("Invalid URL from input. Should be validated by browser"); console.error("Invalid URL from input. Should be validated by browser");
} }

View file

@ -10,7 +10,7 @@ export const extractQueryParams = (queryString: string) => {
if (match) { if (match) {
const arrayKey = match[1]; const arrayKey = match[1];
if (!queryParams.hasOwnProperty(arrayKey)) { if (!Object.prototype.hasOwnProperty.call(queryParams, arrayKey)) {
queryParams[arrayKey] = []; queryParams[arrayKey] = [];
} }

View file

@ -14,6 +14,7 @@ jest.mock("react-intl", () => ({
jest.mock("@saleor/macaw-ui", () => ({ jest.mock("@saleor/macaw-ui", () => ({
useStyles: jest.fn(() => () => ({})), useStyles: jest.fn(() => () => ({})),
makeStyles: jest.fn(() => () => ({})), makeStyles: jest.fn(() => () => ({})),
// eslint-disable-next-line react/display-name
DialogHeader: jest.fn(() => () => <></>), DialogHeader: jest.fn(() => () => <></>),
})); }));

View file

@ -18,6 +18,8 @@ const _IconButton: React.FC<any> = React.forwardRef(
}, },
); );
_IconButton.displayName = "IconButton";
export const IconButton = _IconButton as < export const IconButton = _IconButton as <
T extends React.ElementType = "button", T extends React.ElementType = "button",
>( >(

View file

@ -83,3 +83,5 @@ export const Metadata: React.FC<MetadataProps> = memo(({ data, onChange }) => {
</Box> </Box>
); );
}, propsCompare); }, propsCompare);
Metadata.displayName = "Metadata";

View file

@ -20,7 +20,7 @@ enum SeoField {
description = "seoDescription", description = "seoDescription",
} }
const SLUG_REGEX = /^[a-zA-Z0-9\-\_]+$/; const SLUG_REGEX = /^[a-zA-Z0-9\-_]+$/;
const maxSlugLength = 255; const maxSlugLength = 255;
const maxTitleLength = 70; const maxTitleLength = 70;
const maxDescriptionLength = 300; const maxDescriptionLength = 300;

View file

@ -28,29 +28,20 @@ export function useBackgroundTasks(
React.useEffect(() => { React.useEffect(() => {
const intervalId = setInterval(() => { const intervalId = setInterval(() => {
const queue = async () => { const queue = async () => {
try { await Promise.all(
await Promise.all( tasks.current.map(async task => {
tasks.current.map(async task => { if (task.status === TaskStatus.PENDING) {
if (task.status === TaskStatus.PENDING) { const status = await handleTask(task);
let status: TaskStatus;
try { if (status !== TaskStatus.PENDING) {
status = await handleTask(task); const taskIndex = tasks.current.findIndex(
} catch (error) { t => t.id === task.id,
throw error; );
} tasks.current[taskIndex].status = status;
if (status !== TaskStatus.PENDING) {
const taskIndex = tasks.current.findIndex(
t => t.id === task.id,
);
tasks.current[taskIndex].status = status;
}
} }
}), }
); }),
} catch (error) { );
throw error;
}
}; };
queue(); queue();

View file

@ -23,6 +23,7 @@ jest.mock("@saleor/macaw-ui", () => ({
useTheme: jest.fn(() => () => ({})), useTheme: jest.fn(() => () => ({})),
useStyles: jest.fn(() => () => ({})), useStyles: jest.fn(() => () => ({})),
makeStyles: jest.fn(() => () => ({})), makeStyles: jest.fn(() => () => ({})),
// eslint-disable-next-line react/display-name
DialogHeader: jest.fn(() => () => <></>), DialogHeader: jest.fn(() => () => <></>),
})); }));

View file

@ -41,7 +41,7 @@ const GiftCardList: React.FC<RouteComponentProps<any>> = () => {
return <GiftCardListComponent params={params} />; return <GiftCardListComponent params={params} />;
}; };
const Component: React.FC = ({}) => { const Component: React.FC = () => {
const intl = useIntl(); const intl = useIntl();
return ( return (

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const Attributes = createSvgIcon( const AttributesIcons = createSvgIcon(
<path <path
fillRule="evenodd" fillRule="evenodd"
clipRule="evenodd" clipRule="evenodd"
@ -11,6 +11,6 @@ const Attributes = createSvgIcon(
"Attributes", "Attributes",
); );
export default (props: SvgIconProps) => ( export default function Attributes(props: SvgIconProps) {
<Attributes {...props} viewBox="0 0 32 32" /> return <AttributesIcons {...props} viewBox="0 0 32 32" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const Channels = createSvgIcon( const ChannelsIcon = createSvgIcon(
<path <path
fillRule="evenodd" fillRule="evenodd"
clipRule="evenodd" clipRule="evenodd"
@ -11,6 +11,6 @@ const Channels = createSvgIcon(
"Channels", "Channels",
); );
export default (props: SvgIconProps) => ( export default function Channels(props: SvgIconProps) {
<Channels {...props} viewBox="0 0 32 32" /> return <ChannelsIcon {...props} viewBox="0 0 32 32" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const Miscellaneous = createSvgIcon( const MiscellaneousIcon = createSvgIcon(
<> <>
<path <path
fillRule="evenodd" fillRule="evenodd"
@ -31,6 +31,6 @@ const Miscellaneous = createSvgIcon(
"Miscellaneous", "Miscellaneous",
); );
export default (props: SvgIconProps) => ( export default function Miscellaneous(props: SvgIconProps) {
<Miscellaneous {...props} viewBox="0 0 24 24" fill="none" /> return <MiscellaneousIcon {...props} viewBox="0 0 24 24" fill="none" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const Navigation = createSvgIcon( const NavigationIcon = createSvgIcon(
<path <path
fillRule="evenodd" fillRule="evenodd"
clipRule="evenodd" clipRule="evenodd"
@ -11,6 +11,6 @@ const Navigation = createSvgIcon(
"Navigation", "Navigation",
); );
export default (props: SvgIconProps) => ( export default function Navigation(props: SvgIconProps) {
<Navigation {...props} viewBox="0 0 32 32" /> return <NavigationIcon {...props} viewBox="0 0 32 32" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const PageTypes = createSvgIcon( const PageTypesIcons = createSvgIcon(
<path <path
fillRule="evenodd" fillRule="evenodd"
clipRule="evenodd" clipRule="evenodd"
@ -11,6 +11,6 @@ const PageTypes = createSvgIcon(
"PageTypes", "PageTypes",
); );
export default (props: SvgIconProps) => ( export default function PageTypes(props: SvgIconProps) {
<PageTypes {...props} viewBox="0 0 24 25" /> return <PageTypesIcons {...props} viewBox="0 0 24 25" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const PermissionGroups = createSvgIcon( const PermissionGroupsIcon = createSvgIcon(
<path <path
fillRule="evenodd" fillRule="evenodd"
clipRule="evenodd" clipRule="evenodd"
@ -11,6 +11,6 @@ const PermissionGroups = createSvgIcon(
"PermissionGroups", "PermissionGroups",
); );
export default (props: SvgIconProps) => ( export default function PermissionGroups(props: SvgIconProps) {
<PermissionGroups {...props} viewBox="0 0 32 32" /> return <PermissionGroupsIcon {...props} viewBox="0 0 32 32" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const ProductTypes = createSvgIcon( const ProductTypesIcon = createSvgIcon(
<> <>
<path <path
fillRule="evenodd" fillRule="evenodd"
@ -13,6 +13,6 @@ const ProductTypes = createSvgIcon(
"ProductTypes", "ProductTypes",
); );
export default (props: SvgIconProps) => ( export default function ProductTypes(props: SvgIconProps) {
<ProductTypes {...props} viewBox="0 0 44 44" /> return <ProductTypesIcon {...props} viewBox="0 0 44 44" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const ShippingMethods = createSvgIcon( const ShippingMethodsIcons = createSvgIcon(
<path <path
fillRule="evenodd" fillRule="evenodd"
clipRule="evenodd" clipRule="evenodd"
@ -11,6 +11,6 @@ const ShippingMethods = createSvgIcon(
"ShippingMethods", "ShippingMethods",
); );
export default (props: SvgIconProps) => ( export default function ShippingMethods(props: SvgIconProps) {
<ShippingMethods {...props} viewBox="0 0 32 32" /> return <ShippingMethodsIcons {...props} viewBox="0 0 32 32" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const SiteSettings = createSvgIcon( const SiteSettingsIcon = createSvgIcon(
<> <>
<path <path
fillRule="evenodd" fillRule="evenodd"
@ -19,6 +19,6 @@ const SiteSettings = createSvgIcon(
"SiteSettings", "SiteSettings",
); );
export default (props: SvgIconProps) => ( export default function SiteSettings(props: SvgIconProps) {
<SiteSettings {...props} viewBox="0 0 32 32" /> return <SiteSettingsIcon {...props} viewBox="0 0 32 32" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const StaffMembers = createSvgIcon( const StaffMembersIcon = createSvgIcon(
<path <path
fillRule="evenodd" fillRule="evenodd"
clipRule="evenodd" clipRule="evenodd"
@ -11,6 +11,6 @@ const StaffMembers = createSvgIcon(
"StaffMembers", "StaffMembers",
); );
export default (props: SvgIconProps) => ( export default function StaffMembers(props: SvgIconProps) {
<StaffMembers {...props} viewBox="0 0 32 32" /> return <StaffMembersIcon {...props} viewBox="0 0 32 32" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const Taxes = createSvgIcon( const TaxesIcon = createSvgIcon(
<path <path
fillRule="evenodd" fillRule="evenodd"
clipRule="evenodd" clipRule="evenodd"
@ -11,6 +11,6 @@ const Taxes = createSvgIcon(
"Taxes", "Taxes",
); );
export default (props: SvgIconProps) => ( export default function Taxes(props: SvgIconProps) {
<Taxes {...props} viewBox="0 0 32 32" /> return <TaxesIcon {...props} viewBox="0 0 32 32" />;
); }

View file

@ -1,7 +1,7 @@
import { createSvgIcon, SvgIconProps } from "@material-ui/core"; import { createSvgIcon, SvgIconProps } from "@material-ui/core";
import React from "react"; import React from "react";
const Warehouses = createSvgIcon( const WarehousesIcon = createSvgIcon(
<path <path
fillRule="evenodd" fillRule="evenodd"
clipRule="evenodd" clipRule="evenodd"
@ -11,6 +11,6 @@ const Warehouses = createSvgIcon(
"Warehouses", "Warehouses",
); );
export default (props: SvgIconProps) => ( export default function Warehouses(props: SvgIconProps) {
<Warehouses {...props} viewBox="0 0 32 32" /> return <WarehousesIcon {...props} viewBox="0 0 32 32" />;
); }

View file

@ -119,7 +119,6 @@ const MenuDetails: React.FC<MenuDetailsProps> = ({ id, params }) => {
default: default:
throw unknownTypeError; throw unknownTypeError;
break;
} }
}; };

View file

@ -100,6 +100,8 @@ export const getEventMessage = (
defaultMessage: "Order refund information was sent to customer", defaultMessage: "Order refund information was sent to customer",
description: "order history message", description: "order history message",
}); });
default:
return "";
} }
case OrderEventsEnum.FULFILLMENT_CANCELED: case OrderEventsEnum.FULFILLMENT_CANCELED:
return intl.formatMessage({ return intl.formatMessage({

View file

@ -48,7 +48,7 @@ describe("Multiple file upload handler", () => {
const handle = createMultiFileUploadHandler((_, fileIndex) => { const handle = createMultiFileUploadHandler((_, fileIndex) => {
const promise = new Promise<void>((resolve, reject) => { const promise = new Promise<void>((resolve, reject) => {
if (fileIndex === 2) { if (fileIndex === 2) {
reject(); reject(new Error("mock error"));
} else { } else {
resolve(); resolve();
} }