style: restrict type import (#1589)

This commit is contained in:
Himself65
2023-03-15 11:58:43 -05:00
committed by GitHub
parent 6ab2f83e13
commit efcf1fcaa0
154 changed files with 332 additions and 307 deletions

View File

@@ -1,12 +1,14 @@
/* deepscan-disable USELESS_ARROW_FUNC_BIND */
import { __unstableSchemas, builtInSchemas } from '@blocksuite/blocks/models';
import { EditorContainer } from '@blocksuite/editor';
import { Page, Workspace } from '@blocksuite/store';
import type { EditorContainer } from '@blocksuite/editor';
import type { Page } from '@blocksuite/store';
import { Workspace } from '@blocksuite/store';
import { expect } from '@storybook/jest';
import { Meta, StoryFn } from '@storybook/react';
import type { Meta, StoryFn } from '@storybook/react';
import { useEffect, useState } from 'react';
import { BlockSuiteEditor, EditorProps } from '.';
import type { EditorProps } from '.';
import { BlockSuiteEditor } from '.';
function initPage(page: Page, editor: Readonly<EditorContainer>): void {
// Add page block and surface block at root level

View File

@@ -1,7 +1,8 @@
import { BlockHub } from '@blocksuite/blocks';
import type { BlockHub } from '@blocksuite/blocks';
import { EditorContainer } from '@blocksuite/editor';
import type { Page, Workspace } from '@blocksuite/store';
import { CSSProperties, useEffect, useRef } from 'react';
import type { CSSProperties } from 'react';
import { useEffect, useRef } from 'react';
export type EditorProps = {
blockSuiteWorkspace: Workspace;

View File

@@ -1,7 +1,7 @@
/* deepscan-disable USELESS_ARROW_FUNC_BIND */
import { Link, Typography } from '@mui/material';
import { expect } from '@storybook/jest';
import { Meta, StoryFn } from '@storybook/react';
import type { Meta, StoryFn } from '@storybook/react';
import { within } from '@storybook/testing-library';
import { Breadcrumbs } from '..';

View File

@@ -1,8 +1,8 @@
/* deepscan-disable USELESS_ARROW_FUNC_BIND */
import { Meta, StoryFn } from '@storybook/react';
import type { Meta, StoryFn } from '@storybook/react';
import { Button } from '..';
import { ButtonProps } from '../ui/button/interface';
import type { ButtonProps } from '../ui/button/interface';
export default {
title: 'AFFiNE/Button',

View File

@@ -9,7 +9,7 @@ import {
import type { PropsWithChildren } from 'react';
import { useMemo } from 'react';
import { AffineTheme } from './types';
import type { AffineTheme } from './types';
export { css, keyframes, styled };

View File

@@ -2,7 +2,7 @@ import '@emotion/react';
import type { EditorContainer } from '@blocksuite/editor';
import { AffineTheme, AffineThemeCSSVariables } from './types';
import type { AffineTheme, AffineThemeCSSVariables } from './types';
const basicFontFamily =
'apple-system, BlinkMacSystemFont,Helvetica Neue, Tahoma, PingFang SC, Microsoft Yahei, Arial,Hiragino Sans GB, sans-serif, Apple Color Emoji, Segoe UI Emoji,Segoe UI Symbol, Noto Color Emoji';

View File

@@ -1,5 +1,5 @@
import { EditorContainer } from '@blocksuite/editor';
import { CSSProperties } from 'react';
import type { EditorContainer } from '@blocksuite/editor';
import type { CSSProperties } from 'react';
export type Theme = 'light' | 'dark';
export type ThemeMode = Theme | 'auto';

View File

@@ -1,4 +1,4 @@
import { ThemeMode } from '../types';
import type { ThemeMode } from '../types';
export class LocalStorageThemeHelper {
name = 'Affine-theme-mode';

View File

@@ -1,4 +1,4 @@
import { Theme } from '../types';
import type { Theme } from '../types';
export class SystemThemeHelper {
media: MediaQueryList = window.matchMedia('(prefers-color-scheme: light)');

View File

@@ -1,6 +1,6 @@
import { Children, cloneElement, forwardRef } from 'react';
import { ButtonProps } from './interface';
import type { ButtonProps } from './interface';
import { Loading } from './Loading';
import { StyledButton } from './styles';
import { getSize } from './utils';

View File

@@ -1,11 +1,5 @@
import {
Children,
cloneElement,
CSSProperties,
forwardRef,
HTMLAttributes,
ReactElement,
} from 'react';
import type { CSSProperties, HTMLAttributes, ReactElement } from 'react';
import { Children, cloneElement, forwardRef } from 'react';
import { StyledIconButton } from './styles';
const SIZE_SMALL = 'small' as const;

View File

@@ -1,5 +1,5 @@
import { styled } from '../../styles';
import { ButtonProps } from './interface';
import type { ButtonProps } from './interface';
import { getButtonColors } from './utils';
export const LoadingContainer = styled('div')<Pick<ButtonProps, 'type'>>(
({ theme, type = 'default' }) => {

View File

@@ -1,6 +1,6 @@
import { Children, cloneElement, forwardRef } from 'react';
import { ButtonProps } from './interface';
import type { ButtonProps } from './interface';
import { StyledTextButton } from './styles';
import { getSize } from './utils';
export const TextButton = forwardRef<HTMLButtonElement, ButtonProps>(

View File

@@ -1,4 +1,4 @@
import {
import type {
CSSProperties,
HTMLAttributes,
PropsWithChildren,

View File

@@ -1,7 +1,7 @@
import { CSSProperties } from 'react';
import type { CSSProperties } from 'react';
import { absoluteCenter, displayInlineFlex, styled } from '../../styles';
import { ButtonProps } from './interface';
import type { ButtonProps } from './interface';
import { getButtonColors, getSize } from './utils';
export const StyledIconButton = styled('button', {

View File

@@ -1,11 +1,7 @@
import { Theme } from '@mui/material';
import type { Theme } from '@mui/material';
import {
ButtonProps,
SIZE_DEFAULT,
SIZE_MIDDLE,
SIZE_SMALL,
} from './interface';
import type { ButtonProps } from './interface';
import { SIZE_DEFAULT, SIZE_MIDDLE, SIZE_SMALL } from './interface';
// TODO: Designer is not sure about the size, Now, is just use default size
export const SIZE_CONFIG = {

View File

@@ -1,7 +1,8 @@
import { useTranslation } from '@affine/i18n';
import { Button } from '../button';
import { Modal, ModalCloseButton, ModalProps } from '../modal';
import type { ModalProps } from '../modal';
import { Modal, ModalCloseButton } from '../modal';
import {
StyledColumnButtonWrapper,
StyledConfirmContent,

View File

@@ -1,4 +1,4 @@
import { CSSProperties } from 'react';
import type { CSSProperties } from 'react';
import { EmptySVG } from './EmptySVG';
import { StyledEmptyContainer } from './style';

View File

@@ -1,4 +1,5 @@
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
import type { SvgIconProps } from '@mui/material/SvgIcon';
import SvgIcon from '@mui/material/SvgIcon';
export const EmptySVG = (props: SvgIconProps) => {
return (

View File

@@ -1,11 +1,10 @@
import {
import type {
FocusEventHandler,
HTMLAttributes,
InputHTMLAttributes,
KeyboardEventHandler,
useEffect,
useState,
} from 'react';
import { useEffect, useState } from 'react';
import { StyledInput } from './style';
type inputProps = {

View File

@@ -1,4 +1,4 @@
import { CSSProperties } from 'react';
import type { CSSProperties } from 'react';
import { styled, textEllipsis } from '../../styles';

View File

@@ -1,5 +1,5 @@
import { TooltipProps } from '@mui/material';
import { CSSProperties } from 'react';
import type { TooltipProps } from '@mui/material';
import type { CSSProperties } from 'react';
import { Popper, type PopperProps } from '../popper';
import { StyledMenuWrapper } from './styles';

View File

@@ -1,10 +1,5 @@
import {
cloneElement,
forwardRef,
HTMLAttributes,
PropsWithChildren,
ReactElement,
} from 'react';
import type { HTMLAttributes, PropsWithChildren, ReactElement } from 'react';
import { cloneElement, forwardRef } from 'react';
import { StyledArrow, StyledMenuItem } from './styles';
export type IconMenuProps = PropsWithChildren<{

View File

@@ -1,5 +1,5 @@
import { ArrowRightSmallIcon } from '@blocksuite/icons';
import { CSSProperties } from 'react';
import type { CSSProperties } from 'react';
import { displayFlex, styled } from '../../styles';
import StyledPopperContainer from '../shared/Container';

View File

@@ -1,4 +1,4 @@
import { ModalUnstyledOwnProps } from '@mui/base/ModalUnstyled';
import type { ModalUnstyledOwnProps } from '@mui/base/ModalUnstyled';
import Fade from '@mui/material/Fade';
import { StyledBackdrop, StyledModal } from './styles';

View File

@@ -1,8 +1,9 @@
import { CloseIcon } from '@blocksuite/icons';
import { HTMLAttributes } from 'react';
import type { HTMLAttributes } from 'react';
import { styled } from '../../styles';
import { IconButton, IconButtonProps } from '../button/IconButton';
import type { IconButtonProps } from '../button/IconButton';
import { IconButton } from '../button/IconButton';
export type ModalCloseButtonProps = {
top?: number;
right?: number;

View File

@@ -1,4 +1,4 @@
import { CSSProperties } from 'react';
import type { CSSProperties } from 'react';
import { styled } from '../../styles';

View File

@@ -1,5 +1,5 @@
import ModalUnstyled from '@mui/base/ModalUnstyled';
import { CSSProperties } from 'react';
import type { CSSProperties } from 'react';
import { styled } from '../../styles';
import { Wrapper } from '../layout';

View File

@@ -1,7 +1,8 @@
import { CSSProperties, forwardRef } from 'react';
import type { CSSProperties } from 'react';
import { forwardRef } from 'react';
import { styled } from '../../styles';
import { PopperArrowProps } from './interface';
import type { PopperArrowProps } from './interface';
export const PopperArrow = forwardRef<HTMLElement, PopperArrowProps>(
function PopperArrow({ placement }, ref) {

View File

@@ -11,7 +11,7 @@ import {
} from 'react';
import { styled } from '../../styles';
import { PopperProps, VirtualElement } from './interface';
import type { PopperProps, VirtualElement } from './interface';
import { PopperArrow } from './PopoverArrow';
export const Popper = ({
children,

View File

@@ -1,4 +1,4 @@
import { PopperPlacementType } from '@mui/material';
import type { PopperPlacementType } from '@mui/material';
import { styled } from '../../styles';

View File

@@ -1,4 +1,5 @@
import { Children, HTMLAttributes, PropsWithChildren, ReactNode } from 'react';
import type { HTMLAttributes, PropsWithChildren, ReactNode } from 'react';
import { Children } from 'react';
import { StyledTable } from './styles';
const childrenHasEllipsis = (children: ReactNode | ReactNode[]): boolean => {

View File

@@ -1,4 +1,4 @@
import { HTMLAttributes, PropsWithChildren } from 'react';
import type { HTMLAttributes, PropsWithChildren } from 'react';
import { StyledTableBody } from './styles';
export const TableBody = ({

View File

@@ -1,4 +1,4 @@
import { TableCellProps } from './interface';
import type { TableCellProps } from './interface';
import { StyledTableCell } from './styles';
export const TableCell = ({ children, ...props }: TableCellProps) => {
return <StyledTableCell {...props}>{children}</StyledTableCell>;

View File

@@ -1,4 +1,4 @@
import { HTMLAttributes, PropsWithChildren } from 'react';
import type { HTMLAttributes, PropsWithChildren } from 'react';
import { StyledTableHead } from './styles';

View File

@@ -1,4 +1,4 @@
import { HTMLAttributes, PropsWithChildren } from 'react';
import type { HTMLAttributes, PropsWithChildren } from 'react';
import { StyledTableRow } from './styles';
export const TableRow = ({

View File

@@ -1,4 +1,4 @@
import { CSSProperties, HTMLAttributes, PropsWithChildren } from 'react';
import type { CSSProperties, HTMLAttributes, PropsWithChildren } from 'react';
export type TableCellProps = {
align?: 'left' | 'right' | 'center';

View File

@@ -1,5 +1,5 @@
import { styled, textEllipsis } from '../../styles';
import { TableCellProps } from './interface';
import type { TableCellProps } from './interface';
export const StyledTable = styled('table')<{ tableLayout: 'auto' | 'fixed' }>(
({ theme, tableLayout }) => {

View File

@@ -1,5 +1,6 @@
// Copyright: https://github.com/toeverything/blocksuite/commit/8032ef3ab97aefce01664b36502fc392c5db8b78#diff-bf5b41be21936f9165a8400c7f20e24d3dbc49644ba57b9258e0943f0dc1c464
import { css, html, TemplateResult } from 'lit';
import type { TemplateResult } from 'lit';
import { css, html } from 'lit';
export const sleep = (ms = 0) =>
new Promise(resolve => setTimeout(resolve, ms));

View File

@@ -1,5 +1,5 @@
import { DebugLogger } from '@affine/debug';
import { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import type { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import assert from 'assert';
import { MessageCenter } from './message';

View File

@@ -1,6 +1,6 @@
import { Observable } from 'lib0/observable';
import { Message } from '../types';
import type { Message } from '../types';
import { MessageCode, messages } from './code';
export class MessageCenter extends Observable<string> {

View File

@@ -1,6 +1,6 @@
import { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import assert from 'assert';
import { KyInstance } from 'ky/distribution/types/ky';
import type { KyInstance } from 'ky/distribution/types/ky';
import { MessageCenter } from '../../message';
import type { User } from '../../types';
@@ -12,8 +12,8 @@ import type {
ProviderConstructorParams,
} from '../base';
import { BaseProvider } from '../base';
import type { Apis, WorkspaceDetail } from './apis';
import { getApis, Workspace } from './apis';
import type { Apis, Workspace, WorkspaceDetail } from './apis';
import { getApis } from './apis';
import { createGoogleAuth } from './apis/google';
import { createAuthClient, createBareClient } from './apis/request';
import { WebsocketClient } from './channel';

View File

@@ -1,6 +1,7 @@
import { DebugLogger } from '@affine/debug';
import { initializeApp } from 'firebase/app';
import { connectAuthEmulator, User } from 'firebase/auth';
import type { User } from 'firebase/auth';
import { connectAuthEmulator } from 'firebase/auth';
import {
type Auth as FirebaseAuth,
getAuth as getFirebaseAuth,
@@ -9,7 +10,7 @@ import {
signOut,
} from 'firebase/auth';
import { decode } from 'js-base64';
import { KyInstance } from 'ky/distribution/types/ky';
import type { KyInstance } from 'ky/distribution/types/ky';
import { MessageCenter } from '../../../message';
import { storage } from '../storage';

View File

@@ -1,8 +1,9 @@
export type { Callback } from './google';
import { KyInstance } from 'ky/distribution/types/ky';
import type { KyInstance } from 'ky/distribution/types/ky';
import { createGoogleAuth, getAuthorizer, GoogleAuth } from './google';
import type { createGoogleAuth, GoogleAuth } from './google';
import { getAuthorizer } from './google';
import { createUserApis } from './user';
import { createWorkspaceApis } from './workspace';

View File

@@ -1,7 +1,7 @@
import ky from 'ky-universal';
import { MessageCenter } from '../../../message';
import { GoogleAuth } from './google';
import type { GoogleAuth } from './google';
type KyInstance = typeof ky;

View File

@@ -1,4 +1,4 @@
import { KyInstance } from 'ky/distribution/types/ky';
import type { KyInstance } from 'ky/distribution/types/ky';
export interface GetUserByEmailParams {
email: string;

View File

@@ -1,8 +1,8 @@
import { KyInstance } from 'ky/distribution/types/ky';
import type { KyInstance } from 'ky/distribution/types/ky';
import { MessageCenter } from '../../../message';
import { createBlocksuiteWorkspace as _createBlocksuiteWorkspace } from '../../../utils';
import { GoogleAuth } from './google';
import type { GoogleAuth } from './google';
import RequestError from './request-error';
import type { User } from './user';
const messageCenter = MessageCenter.getInstance();

View File

@@ -2,7 +2,7 @@ import { DebugLogger } from '@affine/debug';
import * as url from 'lib0/url';
import * as websocket from 'lib0/websocket';
import { GoogleAuth } from './apis/google';
import type { GoogleAuth } from './apis/google';
const RECONNECT_INTERVAL_TIME = 500;
const MAX_RECONNECT_TIMES = 50;

View File

@@ -1,12 +1,12 @@
import { DebugLogger } from '@affine/debug';
import { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import type { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import { MessageCenter } from '../message';
import { User } from '../types';
import type { MessageCenter } from '../message';
import type { User } from '../types';
import type { WorkspaceUnit, WorkspaceUnitCtorParams } from '../workspace-unit';
import type { WorkspaceUnitCollectionScope } from '../workspace-unit-collection';
import { Member } from './affine/apis';
import { Permission } from './affine/apis/workspace';
import type { Member } from './affine/apis';
import type { Permission } from './affine/apis/workspace';
export interface ProviderConstructorParams {
workspaces: WorkspaceUnitCollectionScope;

View File

@@ -1,4 +1,5 @@
import { uuidv4, Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import type { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import { uuidv4 } from '@blocksuite/store';
import assert from 'assert';
import { varStorage as storage } from 'lib0/storage';

View File

@@ -1,11 +1,11 @@
import { GetBlob, PutBlob } from '../ipc/types/blob';
import {
import type { GetBlob, PutBlob } from '../ipc/types/blob';
import type {
GetDocumentParameter,
GetDocumentResponse,
YDocumentUpdate,
} from '../ipc/types/document';
import { CreateUser, GetUserParameters, User } from '../ipc/types/user';
import {
import type { CreateUser, GetUserParameters, User } from '../ipc/types/user';
import type {
CreateWorkspace,
CreateWorkspaceResult,
GetWorkspace,

View File

@@ -1,16 +1,19 @@
import { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import type { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import assert from 'assert';
import * as Y from 'yjs';
import { User } from '../../types';
import type { User } from '../../types';
import { applyUpdate } from '../../utils';
import type { WorkspaceUnit } from '../../workspace-unit';
import { CreateWorkspaceInfoParams, ProviderConstructorParams } from '../base';
import type {
CreateWorkspaceInfoParams,
ProviderConstructorParams,
} from '../base';
import { LocalProvider } from '../local';
import { loadWorkspaceUnit } from '../local/utils';
import { IPCBlobProvider } from './blocksuite-provider/blob';
import type { IPCMethodsType } from './ipc/methods';
import { WorkspaceWithPermission } from './ipc/types/workspace';
import type { WorkspaceWithPermission } from './ipc/types/workspace';
import { createWorkspaceUnit } from './utils';
/**

View File

@@ -1,13 +1,13 @@
import { invoke } from '@tauri-apps/api';
import { GetBlob, PutBlob } from './types/blob';
import {
import type { GetBlob, PutBlob } from './types/blob';
import type {
GetDocumentParameter,
GetDocumentResponse,
YDocumentUpdate,
} from './types/document';
import { CreateUser, GetUserParameters } from './types/user';
import {
import type { CreateUser, GetUserParameters } from './types/user';
import type {
CreateWorkspace,
CreateWorkspaceResult,
GetWorkspace,

View File

@@ -1,4 +1,4 @@
import { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import type { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
import assert from 'assert';
import { getDefaultHeadImgBlob } from '../utils';

View File

@@ -8,6 +8,7 @@
// memberCount: number;
// provider: string;
// };
import type { DebugLogger } from '@affine/debug';
declare global {
interface Window {
@@ -24,8 +25,7 @@ export type User = {
};
// export type WorkspaceMeta = Pick<WorkspaceInfo, 'name' | 'avatar'>;
export type Logger = typeof import('@affine/debug').DebugLogger;
export type Logger = DebugLogger;
export type Message = {
code: number;

View File

@@ -1,8 +1,6 @@
import { __unstableSchemas, builtInSchemas } from '@blocksuite/blocks/models';
import {
StoreOptions,
Workspace as BlocksuiteWorkspace,
} from '@blocksuite/store';
import type { StoreOptions } from '@blocksuite/store';
import { Workspace as BlocksuiteWorkspace } from '@blocksuite/store';
export const createBlocksuiteWorkspace = (options: StoreOptions) => {
return new BlocksuiteWorkspace({

View File

@@ -1,4 +1,4 @@
import {
import type {
BlobOptionsGetter,
Workspace as BlocksuiteWorkspace,
} from '@blocksuite/store';

View File

@@ -1,4 +1,5 @@
import i18next, { i18n, Resource } from 'i18next';
import type { i18n, Resource } from 'i18next';
import i18next from 'i18next';
import {
I18nextProvider,
initReactI18next,