Change to using arrow functions (#1603)

* Change to using arrow functions

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>

* Add lint rule

---------

Co-authored-by: v1b3m <vibenjamin6@gmail.com>
Co-authored-by: Matheus <matheus_benini@hotmail.com>
Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
gitstart-twenty
2023-09-16 02:41:10 +01:00
committed by GitHub
parent 549335054a
commit 00a3c8ca2b
575 changed files with 2848 additions and 3063 deletions

View File

@ -19,6 +19,6 @@ type OwnProps = {
children: JSX.Element;
};
export function ComponentStorybookLayout({ children }: OwnProps) {
return <StyledLayout>{children}</StyledLayout>;
}
export const ComponentStorybookLayout = ({ children }: OwnProps) => (
<StyledLayout>{children}</StyledLayout>
);

View File

@ -11,6 +11,6 @@ type OwnProps = {
children: JSX.Element;
};
export function FullHeightStorybookLayout({ children }: OwnProps) {
return <StyledLayout>{children}</StyledLayout>;
}
export const FullHeightStorybookLayout = ({ children }: OwnProps) => (
<StyledLayout>{children}</StyledLayout>
);

View File

@ -3,7 +3,7 @@ import { useEffect } from 'react';
import { useSetHotkeyScope } from '@/ui/utilities/hotkey/hooks/useSetHotkeyScope';
import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope';
export function InitializeHotkeyStorybookHookEffect() {
export const InitializeHotkeyStorybookHookEffect = () => {
const setHotkeyScope = useSetHotkeyScope();
useEffect(() => {
@ -11,4 +11,4 @@ export function InitializeHotkeyStorybookHookEffect() {
}, [setHotkeyScope]);
return <></>;
}
};

View File

@ -14,11 +14,8 @@ type RouteParams = {
[param: string]: string;
};
function computeLocation(routePath: string, routeParams: RouteParams) {
return routePath.replace(/:(\w+)/g, (paramName) => {
return routeParams[paramName] ?? '';
});
}
const computeLocation = (routePath: string, routeParams: RouteParams) =>
routePath.replace(/:(\w+)/g, (paramName) => routeParams[paramName] ?? '');
export const PageDecorator: Decorator<{
routePath: string;

View File

@ -9,11 +9,11 @@ import {
import { isDefined } from '../../utils/isDefined';
function filterData<DataT>(
const filterData = <DataT>(
data: Array<DataT>,
where: Record<string, any>,
): Array<DataT> {
return data.filter((item) => {
): Array<DataT> =>
data.filter((item) => {
// { firstName: {contains: '%string%' }}
// { lastName: {equals: 'string' }}
// { is: { company: { equals: 'string' }}}
@ -85,9 +85,8 @@ function filterData<DataT>(
return isMatch;
});
}
export function filterAndSortData<DataT>(
export const filterAndSortData = <DataT>(
data: Array<DataT>,
where?: Record<string, any>,
orderBy?: Array<
@ -96,7 +95,7 @@ export function filterAndSortData<DataT>(
UserOrderByWithRelationInput
>,
limit?: number,
): Array<DataT> {
): Array<DataT> => {
let filteredData = data;
if (where) {
@ -131,12 +130,12 @@ export function filterAndSortData<DataT>(
}
return filteredData;
}
};
export function fetchOneFromData<DataT extends { id: string }>(
export const fetchOneFromData = <DataT extends { id: string }>(
data: Array<DataT>,
id: string,
): DataT | undefined {
): DataT | undefined => {
if (!isDefined(id)) {
throw new Error(
`id is not defined in updateOneFromData, check that you provided where.id if needed.`,
@ -144,13 +143,13 @@ export function fetchOneFromData<DataT extends { id: string }>(
}
return data.filter((item) => item.id === id)[0];
}
};
export function updateOneFromData<DataT extends { id: string }>(
export const updateOneFromData = <DataT extends { id: string }>(
data: Array<DataT>,
id: string | undefined,
payload: GraphQLVariables,
): DataT | undefined {
): DataT | undefined => {
if (!isDefined(id)) {
throw new Error(
`id is not defined in updateOneFromData, check that you provided where.id if needed.`,
@ -162,4 +161,4 @@ export function updateOneFromData<DataT extends { id: string }>(
const newObject = Object.assign(object, payload);
return newObject;
}
};

View File

@ -1,5 +1,4 @@
export async function sleep(ms: number) {
return new Promise((resolve) => {
export const sleep = async (ms: number) =>
new Promise((resolve) => {
setTimeout(resolve, ms);
});
}