chore: fix most warnings and ignore a few warnings, because the code quality is too bad

This commit is contained in:
DarkSky
2022-12-23 13:36:39 +08:00
parent 5952e9a2bb
commit 5374d351e2
49 changed files with 128 additions and 145 deletions
@@ -1,4 +1,3 @@
import { ResetIcon } from '@blocksuite/icons';
import { styled } from '@/styles';
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
import { Button } from '@/ui/button';
@@ -12,14 +12,17 @@ interface LoginModalProps {
workspaceId: string;
onInviteSuccess: () => void;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const debounce = <T extends (...args: any) => any>(
fn: T,
time?: number,
immediate?: boolean
// eslint-disable-next-line @typescript-eslint/no-explicit-any
): ((...args: any) => any) => {
let timeoutId: null | number;
let defaultImmediate = immediate || false;
const delay = time || 300;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (...args: any) => {
if (defaultImmediate) {
fn.apply(this, args); // 确保引用函数的指向正确,并且函数的参数也不变
@@ -45,10 +48,10 @@ export const InviteMembers = ({
workspaceId,
onInviteSuccess,
}: LoginModalProps) => {
const [canInvite, setCanInvite] = useState<boolean>(true);
const [email, setEmail] = useState<string>('');
const [showMember, setShowMember] = useState<boolean>(false);
const [showTip, setShowTip] = useState<boolean>(false);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [userData, setUserData] = useState<any>({});
const inputChange = (value: string) => {
setEmail(value);
@@ -2,7 +2,7 @@ import { styled } from '@/styles';
import Loading from './loading';
// Used for the full page loading
const StyledLoadingContainer = styled('div')(({ theme }) => {
const StyledLoadingContainer = styled('div')(() => {
return {
height: '100vh',
display: 'flex',
@@ -1,7 +1,7 @@
import { ResetIcon } from '@blocksuite/icons';
import { styled } from '@/styles';
import { Modal, ModalWrapper, ModalCloseButton } from '@/ui/modal';
import { TextButton, Button } from '@/ui/button';
import { TextButton } from '@/ui/button';
import { GoogleLoginButton, StayLogOutButton } from './LoginOptionButton';
interface LoginModalProps {
@@ -1,6 +1,5 @@
import { displayFlex, styled, textEllipsis } from '@/styles';
import { displayFlex, styled } from '@/styles';
import { TableRow } from '@/ui/table';
import Link from 'next/link';
export const StyledTableContainer = styled.div(() => {
return {
@@ -37,7 +36,7 @@ export const StyledTitleLink = styled.div(({ theme }) => {
};
});
export const StyledTableRow = styled(TableRow)(({ theme }) => {
export const StyledTableRow = styled(TableRow)(() => {
return {
cursor: 'pointer',
'&:hover': {
@@ -2,10 +2,12 @@ import { cloneElement, FC, PropsWithChildren, ReactNode } from 'react';
export const ProviderComposer: FC<
PropsWithChildren<{
// eslint-disable-next-line @typescript-eslint/no-explicit-any
contexts: any;
}>
> = ({ contexts, children }) =>
contexts.reduceRight(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(kids: ReactNode, parent: any) =>
cloneElement(parent, {
children: kids,
@@ -38,7 +38,7 @@ export const StyledSubTitle = styled.div(({ theme }) => ({
marginTop: '28px',
padding: '0 16px',
}));
export const StyledModalHeader = styled.div(({ theme }) => ({
export const StyledModalHeader = styled.div(() => ({
...displayFlex('space-between', 'center'),
paddingTop: '8px 4px 0 4px',
width: '100%',
@@ -50,10 +50,10 @@ export class Counter extends LitElement {
</div>`;
}
private _increment(e: Event) {
private _increment() {
this.count++;
}
private _subtract(e: Event) {
private _subtract() {
this.count--;
}
}
@@ -10,7 +10,7 @@ export const StyledPage = styled('div')(({ theme }) => {
};
});
export const StyledWrapper = styled('div')(({ theme }) => {
export const StyledWrapper = styled('div')(() => {
return {
flexGrow: 1,
position: 'relative',
@@ -1,5 +1,4 @@
import { styled } from '@/styles';
import { Button } from '@/ui/button';
export const StyledModalWrapper = styled('div')(({ theme }) => {
return {
@@ -24,7 +23,7 @@ export const StyledModalHeader = styled('div')(({ theme }) => {
// export const StyledModalContent = styled('div')(({ theme }) => {});
export const StyledTextContent = styled('div')(({ theme }) => {
export const StyledTextContent = styled('div')(() => {
return {
margin: 'auto',
width: '425px',
@@ -37,7 +36,7 @@ export const StyledTextContent = styled('div')(({ theme }) => {
};
});
export const StyledInputContent = styled('div')(({ theme }) => {
export const StyledInputContent = styled('div')(() => {
return {
display: 'flex',
flexDirection: 'row',
@@ -46,7 +45,7 @@ export const StyledInputContent = styled('div')(({ theme }) => {
};
});
export const StyledButtonContent = styled('div')(({ theme }) => {
export const StyledButtonContent = styled('div')(() => {
return {
display: 'flex',
flexDirection: 'row',
@@ -55,7 +54,7 @@ export const StyledButtonContent = styled('div')(({ theme }) => {
};
});
export const StyledWorkspaceName = styled('span')(({ theme }) => {
export const StyledWorkspaceName = styled('span')(() => {
return {
color: '#E8178A',
};
@@ -1,16 +1,12 @@
import Modal from '@/ui/modal';
import Input from '@/ui/input';
import {
StyledModalHeader,
StyledTextContent,
StyledModalWrapper,
StyledButtonContent,
} from './style';
import { useState } from 'react';
import { ModalCloseButton } from '@/ui/modal';
import { Button } from '@/ui/button';
import { useRouter } from 'next/router';
import { useAppState } from '@/providers/app-state-provider';
interface WorkspaceDeleteProps {
open: boolean;
@@ -20,17 +16,7 @@ interface WorkspaceDeleteProps {
nextWorkSpaceId: string;
}
export const WorkspaceDelete = ({
open,
onClose,
workspaceId,
workspaceName,
nextWorkSpaceId,
}: WorkspaceDeleteProps) => {
const [deleteStr, setDeleteStr] = useState<string>('');
const router = useRouter();
// const { refreshWorkspacesMeta } = useAppState();
export const WorkspaceDelete = ({ open, onClose }: WorkspaceDeleteProps) => {
const handleLeave = async () => {
// TODO
};
@@ -1,5 +1,4 @@
import { styled } from '@/styles';
import { Button } from '@/ui/button';
export const StyledModalWrapper = styled('div')(({ theme }) => {
return {
@@ -24,7 +23,7 @@ export const StyledModalHeader = styled('div')(({ theme }) => {
// export const StyledModalContent = styled('div')(({ theme }) => {});
export const StyledTextContent = styled('div')(({ theme }) => {
export const StyledTextContent = styled('div')(() => {
return {
margin: 'auto',
width: '425px',
@@ -37,7 +36,7 @@ export const StyledTextContent = styled('div')(({ theme }) => {
};
});
export const StyledButtonContent = styled('div')(({ theme }) => {
export const StyledButtonContent = styled('div')(() => {
return {
display: 'flex',
flexDirection: 'row',
@@ -1,19 +1,19 @@
import { styled } from '@/styles';
import MuiAvatar from '@mui/material/Avatar';
export const StyledSettingInputContainer = styled('div')(({ theme }) => {
export const StyledSettingInputContainer = styled('div')(() => {
return {
marginTop: '12px',
};
});
export const StyledDeleteButtonContainer = styled('div')(({ theme }) => {
export const StyledDeleteButtonContainer = styled('div')(() => {
return {
marginTop: '154px',
};
});
export const StyledSettingAvatarContent = styled('div')(({ theme }) => {
export const StyledSettingAvatarContent = styled('div')(() => {
return {
marginTop: '12px',
display: 'flex',
@@ -23,6 +23,6 @@ export const StyledSettingAvatarContent = styled('div')(({ theme }) => {
};
});
export const StyledSettingAvatar = styled(MuiAvatar)(({ theme }) => {
export const StyledSettingAvatar = styled(MuiAvatar)(() => {
return { height: '72px', width: '72px' };
});
@@ -1,6 +1,5 @@
import Modal, { ModalCloseButton } from '@/ui/modal';
import {
StyledAvatarUploadBtn,
StyledCopyButtonContainer,
StyledMemberAvatar,
StyledMemberButtonContainer,
@@ -33,7 +32,7 @@ import {
EmailIcon,
TrashIcon,
} from '@blocksuite/icons';
import { useEffect, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { Button, IconButton } from '@/ui/button';
import Input from '@/ui/input';
import { InviteMembers } from '../invite-members/index';
@@ -51,7 +50,6 @@ import { Empty } from '@/ui/empty';
import { useAppState } from '@/providers/app-state-provider';
import { WorkspaceDetails } from '../workspace-slider-bar/WorkspaceSelector/SelectorPopperContent';
import { GeneralPage } from './general';
import { Workspace as StoreWorkspaces } from '@blocksuite/store';
enum ActiveTab {
'general' = 'general',
@@ -170,7 +168,7 @@ export const WorkspaceSetting = ({
const MembersPage = ({ workspace }: { workspace: Workspace }) => {
const [isInviteModalShow, setIsInviteModalShow] = useState(false);
const [members, setMembers] = useState<Member[]>([]);
const refreshMembers = () => {
const refreshMembers = useCallback(() => {
getWorkspaceMembers({
id: workspace.id,
})
@@ -180,10 +178,10 @@ const MembersPage = ({ workspace }: { workspace: Workspace }) => {
.catch(err => {
console.log(err);
});
};
}, [workspace.id]);
useEffect(() => {
refreshMembers();
}, [workspace.id]);
}, [refreshMembers]);
return (
<div>
@@ -240,7 +238,7 @@ const MembersPage = ({ workspace }: { workspace: Workspace }) => {
// }).then(confirm => {
removeMember({
permissionId: member.id,
}).then(data => {
}).then(() => {
// console.log('data: ', data);
toast('Moved to Trash');
refreshMembers();
@@ -300,7 +298,7 @@ const PublishPage = ({ workspace }: { workspace: Workspace }) => {
updateWorkspace({
id: workspace.id,
public: flag,
}).then(data => {
}).then(() => {
setPublicStatus(!publicStatus);
toast('Updated');
});
@@ -47,7 +47,7 @@ export const SelectorPopperContent = ({
const refreshDetails = useCallback(async () => {
const workspaceDetailList = await Promise.all(
workspacesMeta?.map(async ({ id, type }) => {
workspacesMeta.map(async ({ id, type }) => {
if (user) {
if (type === WorkspaceType.Private) {
return { id, member_count: 1, owner: user };
@@ -81,7 +81,7 @@ export const SelectorPopperContent = ({
refreshWorkspacesMeta();
refreshDetails();
}
}, [isShow]);
}, [isShow, refreshDetails, refreshWorkspacesMeta]);
return !user ? (
<SelectorPopperContainer placement="bottom-start">
@@ -168,7 +168,7 @@ const WorkspaceGroupTitle = styled('div')(({ theme }) => {
};
});
const WorkspaceWrapper = styled('div')(({ theme }) => {
const WorkspaceWrapper = styled('div')(() => {
return {
maxHeight: '200px',
overflow: 'auto',
@@ -24,7 +24,7 @@ export const StyledModalHeader = styled('div')(({ theme }) => {
// export const StyledModalContent = styled('div')(({ theme }) => {});
export const StyledTextContent = styled('div')(({ theme }) => {
export const StyledTextContent = styled('div')(() => {
return {
margin: 'auto',
width: '425px',
@@ -37,7 +37,7 @@ export const StyledTextContent = styled('div')(({ theme }) => {
};
});
export const StyledInputContent = styled('div')(({ theme }) => {
export const StyledInputContent = styled('div')(() => {
return {
display: 'flex',
flexDirection: 'row',
@@ -46,7 +46,7 @@ export const StyledInputContent = styled('div')(({ theme }) => {
};
});
export const StyledButtonContent = styled('div')(({ theme }) => {
export const StyledButtonContent = styled('div')(() => {
return {
display: 'flex',
flexDirection: 'row',
@@ -55,7 +55,7 @@ export const StyledButtonContent = styled('div')(({ theme }) => {
};
});
export const StyledButton = styled(Button)(({ theme }) => {
export const StyledButton = styled(Button)(() => {
return {
width: '260px',
justifyContent: 'center',
@@ -1,8 +1,4 @@
import {
createWorkspace,
getBlob,
uploadBlob,
} from '@pathfinder/data-services';
import { createWorkspace, uploadBlob } from '@pathfinder/data-services';
import Modal from '@/ui/modal';
import Input from '@/ui/input';
import {
@@ -25,7 +25,7 @@ export const FooterSetting = ({ onClick }: SettingProps) => {
);
};
const Wrapper = styled(IconButton)(({ theme }) => {
const Wrapper = styled(IconButton)(() => {
return {
fontSize: '20px',
};
@@ -19,7 +19,6 @@ import {
ImportIcon,
TrashIcon,
AddIcon,
FavouritedIcon,
} from '@blocksuite/icons';
import Link from 'next/link';
import { Tooltip } from '@/ui/tooltip';
@@ -29,7 +28,6 @@ import { useAppState } from '@/providers/app-state-provider/context';
import { IconButton } from '@/ui/button';
import { WorkspaceSelector } from './WorkspaceSelector';
import useLocalStorage from '@/hooks/use-local-storage';
import { useTranslation } from '@/libs/i18n';
import usePageMetaList from '@/hooks/use-page-meta-list';
import { usePageHelper } from '@/hooks/use-page-helper';
@@ -73,7 +71,6 @@ export const WorkSpaceSliderBar = () => {
const [showTip, setShowTip] = useState(false);
const [show, setShow] = useLocalStorage('AFFINE_SLIDE_BAR', false, true);
const { t } = useTranslation();
const paths = {
all: currentWorkspaceId ? `/workspace/${currentWorkspaceId}/all` : '',
@@ -78,7 +78,7 @@ export const StyledListItemForWorkspace = styled(StyledListItem)({
height: '52px',
});
export const StyledLink = styled(Link)(({ theme }) => {
export const StyledLink = styled(Link)(() => {
return {
flexGrow: 1,
textAlign: 'left',
@@ -93,7 +93,7 @@ export const StyledLink = styled(Link)(({ theme }) => {
},
};
});
export const StyledNewPageButton = styled(StyledListItem)(({ theme }) => {
export const StyledNewPageButton = styled(StyledListItem)(() => {
return {
position: 'absolute',
bottom: '24px',