style: enable import-x/no-duplicates (#6279)

This commit is contained in:
EYHN 2024-03-25 03:55:32 +00:00
parent 7ce2bfbf0b
commit f2adbdaba4
No known key found for this signature in database
GPG Key ID: 46C9E26A75AB276C
342 changed files with 881 additions and 1033 deletions

View File

@ -95,7 +95,7 @@ const config = {
'@typescript-eslint',
'simple-import-sort',
'sonarjs',
'i',
'import-x',
'unused-imports',
'unicorn',
'rxjs',
@ -131,6 +131,7 @@ const config = {
'unused-imports/no-unused-imports': 'error',
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'import-x/no-duplicates': 'error',
'@typescript-eslint/ban-ts-comment': [
'error',
{
@ -253,7 +254,7 @@ const config = {
],
'@typescript-eslint/no-misused-promises': ['error'],
'@typescript-eslint/prefer-readonly': 'error',
'i/no-extraneous-dependencies': ['error'],
'import-x/no-extraneous-dependencies': ['error'],
'react-hooks/exhaustive-deps': [
'warn',
{

View File

@ -79,7 +79,7 @@
"electron": "^29.0.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-i": "^2.29.1",
"eslint-plugin-import-x": "^0.4.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-rxjs": "^5.0.3",

View File

@ -18,11 +18,8 @@ import { UserModule } from './core/user';
import { WorkspaceModule } from './core/workspaces';
import { getOptionalModuleMetadata } from './fundamentals';
import { CacheInterceptor, CacheModule } from './fundamentals/cache';
import {
type AvailablePlugins,
Config,
ConfigModule,
} from './fundamentals/config';
import type { AvailablePlugins } from './fundamentals/config';
import { Config, ConfigModule } from './fundamentals/config';
import { EventModule } from './fundamentals/event';
import { GqlModule } from './fundamentals/graphql';
import { HelpersModule } from './fundamentals/helpers';

View File

@ -5,7 +5,8 @@ import {
NotFoundException,
OnApplicationBootstrap,
} from '@nestjs/common';
import { PrismaClient, type User } from '@prisma/client';
import type { User } from '@prisma/client';
import { PrismaClient } from '@prisma/client';
import type { CookieOptions, Request, Response } from 'express';
import { assign, omit } from 'lodash-es';

View File

@ -4,12 +4,8 @@ import { Injectable, Logger } from '@nestjs/common';
import { Cron, CronExpression } from '@nestjs/schedule';
import { PrismaClient } from '@prisma/client';
import {
Config,
type EventPayload,
metrics,
OnEvent,
} from '../../fundamentals';
import type { EventPayload } from '../../fundamentals';
import { Config, metrics, OnEvent } from '../../fundamentals';
import { QuotaService } from '../quota';
import { Permission } from '../workspaces/types';
import { isEmptyBuffer } from './manager';

View File

@ -16,12 +16,12 @@ import {
transact,
} from 'yjs';
import type { EventPayload } from '../../fundamentals';
import {
Cache,
CallTimer,
Config,
EventEmitter,
type EventPayload,
mergeUpdatesInApplyWay as jwstMergeUpdates,
metrics,
OnEvent,

View File

@ -1,11 +1,8 @@
import { Injectable } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import {
type EventPayload,
OnEvent,
PrismaTransaction,
} from '../../fundamentals';
import type { EventPayload } from '../../fundamentals';
import { OnEvent, PrismaTransaction } from '../../fundamentals';
import { FeatureKind } from '../features';
import { QuotaConfig } from './quota';
import { QuotaType } from './types';

View File

@ -7,14 +7,15 @@ import {
ResolveField,
Resolver,
} from '@nestjs/graphql';
import { PrismaClient, type User } from '@prisma/client';
import type { User } from '@prisma/client';
import { PrismaClient } from '@prisma/client';
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
import { isNil, omitBy } from 'lodash-es';
import type { FileUpload } from '../../fundamentals';
import {
CloudThrottlerGuard,
EventEmitter,
type FileUpload,
PaymentRequiredException,
Throttle,
} from '../../fundamentals';

View File

@ -1,5 +1,6 @@
import { ForbiddenException, Injectable } from '@nestjs/common';
import { type Prisma, PrismaClient } from '@prisma/client';
import type { Prisma } from '@prisma/client';
import { PrismaClient } from '@prisma/client';
import { Permission } from './types';

View File

@ -16,9 +16,9 @@ import {
import { SafeIntResolver } from 'graphql-scalars';
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
import type { FileUpload } from '../../../fundamentals';
import {
CloudThrottlerGuard,
type FileUpload,
MakeCache,
PreventCache,
} from '../../../fundamentals';

View File

@ -9,10 +9,8 @@ import {
ResolveField,
Resolver,
} from '@nestjs/graphql';
import {
PrismaClient,
type WorkspacePage as PrismaWorkspacePage,
} from '@prisma/client';
import type { WorkspacePage as PrismaWorkspacePage } from '@prisma/client';
import { PrismaClient } from '@prisma/client';
import { CloudThrottlerGuard } from '../../../fundamentals';
import { CurrentUser } from '../../auth';

View File

@ -20,10 +20,10 @@ import { getStreamAsBuffer } from 'get-stream';
import GraphQLUpload from 'graphql-upload/GraphQLUpload.mjs';
import { applyUpdate, Doc } from 'yjs';
import type { FileUpload } from '../../../fundamentals';
import {
CloudThrottlerGuard,
EventEmitter,
type FileUpload,
MailService,
MutexService,
Throttle,

View File

@ -1,4 +1,5 @@
import { PrismaClient, type User } from '@prisma/client';
import type { User } from '@prisma/client';
import { PrismaClient } from '@prisma/client';
export class UnamedAccount1703756315970 {
// do the migration

View File

@ -5,13 +5,8 @@ import { createPrivateKey, createPublicKey } from 'node:crypto';
import { merge } from 'lodash-es';
import pkg from '../../../package.json' assert { type: 'json' };
import {
type AFFINE_ENV,
AFFiNEConfig,
DeploymentType,
type NODE_ENV,
type ServerFlavor,
} from './def';
import type { AFFINE_ENV, NODE_ENV, ServerFlavor } from './def';
import { AFFiNEConfig, DeploymentType } from './def';
import { readEnv } from './env';
import { getDefaultAFFiNEStorageConfig } from './storage';

View File

@ -1,5 +1,5 @@
import { Injectable } from '@nestjs/common';
import { type Response } from 'express';
import type { Response } from 'express';
import { Config } from '../config';

View File

@ -2,7 +2,8 @@ import { Inject, Injectable, Optional } from '@nestjs/common';
import { Config } from '../config';
import { URLHelper } from '../helpers';
import { MAILER_SERVICE, type MailerService, type Options } from './mailer';
import type { MailerService, Options } from './mailer';
import { MAILER_SERVICE } from './mailer';
import { emailTemplate } from './template';
@Injectable()
export class MailService {

View File

@ -15,11 +15,8 @@ import { IORedisInstrumentation } from '@opentelemetry/instrumentation-ioredis';
import { NestInstrumentation } from '@opentelemetry/instrumentation-nestjs-core';
import { SocketIoInstrumentation } from '@opentelemetry/instrumentation-socket.io';
import { Resource } from '@opentelemetry/resources';
import {
type MeterProvider,
MetricProducer,
MetricReader,
} from '@opentelemetry/sdk-metrics';
import type { MeterProvider } from '@opentelemetry/sdk-metrics';
import { MetricProducer, MetricReader } from '@opentelemetry/sdk-metrics';
import { NodeSDK } from '@opentelemetry/sdk-node';
import {
BatchSpanProcessor,

View File

@ -1,5 +1,4 @@
import { ExecutionContext, Injectable } from '@nestjs/common';
import { Global, Module } from '@nestjs/common';
import { ExecutionContext, Global, Injectable, Module } from '@nestjs/common';
import {
Throttle,
ThrottlerGuard,

View File

@ -1,5 +1,5 @@
import { type User } from '@prisma/client';
import { type Stripe } from 'stripe';
import type { User } from '@prisma/client';
import type { Stripe } from 'stripe';
import type { Payload } from '../../fundamentals/event/def';

View File

@ -1,5 +1,6 @@
import { Global, Provider, Type } from '@nestjs/common';
import { Redis, type RedisOptions } from 'ioredis';
import type { RedisOptions } from 'ioredis';
import { Redis } from 'ioredis';
import { ThrottlerStorageRedisService } from 'nestjs-throttler-storage-redis';
import { Cache, Locker, SessionCache } from '../../fundamentals';

View File

@ -1,5 +1,6 @@
import type { INestApplication } from '@nestjs/common';
import ava, { type TestFn } from 'ava';
import type { TestFn } from 'ava';
import ava from 'ava';
import request from 'supertest';
import { AppModule } from '../src/app.module';

View File

@ -3,7 +3,8 @@ import {
getLatestMailMessage,
} from '@affine-test/kit/utils/cloud';
import type { INestApplication } from '@nestjs/common';
import ava, { type TestFn } from 'ava';
import type { TestFn } from 'ava';
import ava from 'ava';
import { AuthService } from '../src/core/auth/service';
import { MailService } from '../src/fundamentals/mailer';

View File

@ -2,7 +2,8 @@
import { INestApplication, Injectable } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import ava, { type TestFn } from 'ava';
import type { TestFn } from 'ava';
import ava from 'ava';
import { AuthService } from '../src/core/auth/service';
import {

View File

@ -7,7 +7,7 @@ import * as Sinon from 'sinon';
import { DocHistoryManager } from '../src/core/doc';
import { QuotaModule } from '../src/core/quota';
import { StorageModule } from '../src/core/storage';
import { type EventPayload } from '../src/fundamentals/event';
import type { EventPayload } from '../src/fundamentals/event';
import { createTestingModule } from './utils';
let m: TestingModule;

View File

@ -7,7 +7,8 @@ import {
getLatestMailMessage,
} from '@affine-test/kit/utils/cloud';
import { TestingModule } from '@nestjs/testing';
import ava, { type TestFn } from 'ava';
import type { TestFn } from 'ava';
import ava from 'ava';
import { AuthService } from '../src/core/auth/service';
import { ConfigModule } from '../src/fundamentals/config';

View File

@ -1,5 +1,6 @@
import type { INestApplication } from '@nestjs/common';
import ava, { type TestFn } from 'ava';
import type { TestFn } from 'ava';
import ava from 'ava';
import Sinon from 'sinon';
import { AppModule } from '../src/app.module';

View File

@ -1,7 +1,8 @@
/// <reference types="../src/global.d.ts" />
import { TestingModule } from '@nestjs/testing';
import ava, { type TestFn } from 'ava';
import type { TestFn } from 'ava';
import ava from 'ava';
import { AuthService } from '../src/core/auth';
import {

View File

@ -4,7 +4,8 @@ import {
} from '@affine-test/kit/utils/cloud';
import type { INestApplication } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import ava, { type TestFn } from 'ava';
import type { TestFn } from 'ava';
import ava from 'ava';
import { AppModule } from '../src/app.module';
import { AuthService } from '../src/core/auth/service';

View File

@ -1,6 +1,7 @@
import type { INestApplication } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
import ava, { type TestFn } from 'ava';
import type { TestFn } from 'ava';
import ava from 'ava';
import request from 'supertest';
import { AppModule } from '../src/app.module';

View File

@ -1,6 +1,11 @@
import { nanoid } from 'nanoid';
import { Array as YArray, Doc as YDoc, Map as YMap } from 'yjs';
import { applyUpdate, encodeStateAsUpdate } from 'yjs';
import {
applyUpdate,
Array as YArray,
Doc as YDoc,
encodeStateAsUpdate,
Map as YMap,
} from 'yjs';
const migrationOrigin = 'affine-migration';

View File

@ -2,11 +2,8 @@ import { DebugLogger } from '@affine/debug';
// @ts-expect-error upstream type is wrong
import { tinykeys } from 'tinykeys';
import {
type AffineCommand,
type AffineCommandOptions,
createAffineCommand,
} from './command';
import type { AffineCommand, AffineCommandOptions } from './command';
import { createAffineCommand } from './command';
const commandLogger = new DebugLogger('command:registry');

View File

@ -6,10 +6,10 @@ import {
ServiceNotFoundError,
} from './error';
import { parseIdentifier } from './identifier';
import {
type GeneralServiceIdentifier,
type ServiceIdentifierValue,
type ServiceVariant,
import type {
GeneralServiceIdentifier,
ServiceIdentifierValue,
ServiceVariant,
} from './types';
export interface ResolveOptions {

View File

@ -1,7 +1,7 @@
import React, { useContext } from 'react';
import type { ServiceProvider } from '../core';
import { type GeneralServiceIdentifier, ServiceCollection } from '../core';
import type { GeneralServiceIdentifier, ServiceProvider } from '../core';
import { ServiceCollection } from '../core';
export const ServiceProviderContext = React.createContext(
ServiceCollection.EMPTY.provider()

View File

@ -1,22 +1,25 @@
import { DebugLogger } from '@affine/debug';
import type {
InteropObservable,
Observer,
OperatorFunction,
Subscription,
TeardownLogic,
} from 'rxjs';
import {
BehaviorSubject,
combineLatest,
distinctUntilChanged,
EMPTY,
filter,
type InteropObservable,
map,
Observable,
type Observer,
of,
type OperatorFunction,
scan,
skip,
type Subscription,
Subject,
switchMap,
type TeardownLogic,
} from 'rxjs';
import { BehaviorSubject, Subject } from 'rxjs';
export * from './react';

View File

@ -1,6 +1,7 @@
import type { Doc as BlockSuiteDoc } from '@blocksuite/store';
import { createIdentifier, type ServiceCollection } from '../di';
import type { ServiceCollection } from '../di';
import { createIdentifier } from '../di';
import type { PageRecord } from './record';
import { PageScope } from './service-scope';

View File

@ -4,7 +4,8 @@ export * from './record';
export * from './record-list';
export * from './service-scope';
import { type ServiceCollection, ServiceProvider } from '../di';
import type { ServiceCollection } from '../di';
import { ServiceProvider } from '../di';
import { CleanupService } from '../lifecycle';
import { Workspace, WorkspaceLocalState, WorkspaceScope } from '../workspace';
import { BlockSuitePageContext, PageRecordContext } from './context';

View File

@ -2,7 +2,7 @@ import { isEqual } from 'lodash-es';
import { distinctUntilChanged, map, Observable } from 'rxjs';
import { LiveData } from '../livedata';
import { type Workspace, type WorkspaceLocalState } from '../workspace';
import type { Workspace, WorkspaceLocalState } from '../workspace';
import { PageRecord } from './record';
export class PageRecordList {

View File

@ -1,4 +1,5 @@
import { createScope, type ServiceScope } from '../di';
import type { ServiceScope } from '../di';
import { createScope } from '../di';
import { WorkspaceScope } from '../workspace';
export const PageScope: ServiceScope = createScope('page', WorkspaceScope);

View File

@ -23,7 +23,8 @@ import { nanoid } from 'nanoid';
import type { Awareness } from 'y-protocols/awareness.js';
import type { Doc as YDoc } from 'yjs';
import { createIdentifier, type ServiceCollection } from '../di';
import type { ServiceCollection } from '../di';
import { createIdentifier } from '../di';
import { BlobEngine } from './engine/blob';
import { globalBlockSuiteSchema } from './global-schema';
import type { WorkspaceMetadata } from './metadata';

View File

@ -1,7 +1,12 @@
import { nanoid } from 'nanoid';
import { describe, expect, test, vitest } from 'vitest';
import { Doc as YDoc, encodeStateAsUpdate } from 'yjs';
import { diffUpdate, encodeStateVectorFromUpdate, mergeUpdates } from 'yjs';
import {
diffUpdate,
Doc as YDoc,
encodeStateAsUpdate,
encodeStateVectorFromUpdate,
mergeUpdates,
} from 'yjs';
import { AsyncLock } from '../../../../utils';
import { DocEngine } from '..';

View File

@ -9,7 +9,8 @@ import { MANUALLY_STOP } from '../../../utils';
import { DocEngineLocalPart } from './local';
import { DocEngineRemotePart } from './remote';
import type { DocServer } from './server';
import { type DocStorage, DocStorageInner } from './storage';
import type { DocStorage } from './storage';
import { DocStorageInner } from './storage';
const logger = new DebugLogger('doc-engine');

View File

@ -1,10 +1,5 @@
import {
type ByteKV,
type Memento,
MemoryMemento,
ReadonlyByteKV,
wrapMemento,
} from '../../../storage';
import type { ByteKV, Memento } from '../../../storage';
import { MemoryMemento, ReadonlyByteKV, wrapMemento } from '../../../storage';
import { AsyncLock, mergeUpdates, throwIfAborted } from '../../../utils';
import type { DocEventBus } from '.';
import { DocEventBusInner, MemoryDocEventBus } from './event';

View File

@ -1,4 +1,5 @@
import { createIdentifier, type ServiceCollection } from '../di';
import type { ServiceCollection } from '../di';
import { createIdentifier } from '../di';
export interface WorkspaceFactory {
name: string;

View File

@ -11,7 +11,8 @@ export * from './testing';
export * from './upgrade';
export * from './workspace';
import { type ServiceCollection, ServiceProvider } from '../di';
import type { ServiceCollection } from '../di';
import { ServiceProvider } from '../di';
import { CleanupService } from '../lifecycle';
import { GlobalCache, GlobalState, MemoryMemento } from '../storage';
import {

View File

@ -1,5 +1,5 @@
import type { GlobalCache } from '../../storage';
import { type WorkspaceMetadata } from '../metadata';
import type { WorkspaceMetadata } from '../metadata';
const CACHE_STORAGE_KEY = 'jotai-workspaces';

View File

@ -9,7 +9,8 @@ import type { GlobalCache } from '../../storage';
import type { BlobStorage } from '../engine';
import type { WorkspaceMetadata } from '../metadata';
import { readWorkspaceListCache, writeWorkspaceListCache } from './cache';
import { type WorkspaceInfo, WorkspaceInformation } from './information';
import type { WorkspaceInfo } from './information';
import { WorkspaceInformation } from './information';
export * from './information';

View File

@ -4,12 +4,13 @@ import { differenceBy } from 'lodash-es';
import { nanoid } from 'nanoid';
import { applyUpdate, encodeStateAsUpdate } from 'yjs';
import { type ServiceCollection } from '../di';
import { GlobalState, type Memento } from '../storage';
import type { ServiceCollection } from '../di';
import type { Memento } from '../storage';
import { GlobalState } from '../storage';
import { WorkspaceMetadataContext } from './context';
import type { BlobStorage } from './engine';
import {
AwarenessProvider,
type BlobStorage,
DocStorageImpl,
LocalBlobStorage,
MemoryDocStorage,
@ -17,9 +18,8 @@ import {
import { MemoryStorage } from './engine/doc/storage';
import type { WorkspaceFactory } from './factory';
import { globalBlockSuiteSchema } from './global-schema';
import type { WorkspaceListProvider } from './list';
import { type WorkspaceInfo } from './list';
import { type WorkspaceMetadata } from './metadata';
import type { WorkspaceInfo, WorkspaceListProvider } from './list';
import type { WorkspaceMetadata } from './metadata';
import { WorkspaceScope } from './service-scope';
const LIST_STORE_KEY = 'testing-workspace-list';

View File

@ -4,12 +4,16 @@ import { Slot } from '@blocksuite/global/utils';
import type { DocCollection } from '@blocksuite/store';
import { applyUpdate, Doc as YDoc, encodeStateAsUpdate } from 'yjs';
import { checkWorkspaceCompatibility, MigrationPoint } from '../blocksuite';
import { forceUpgradePages, upgradeV1ToV2 } from '../blocksuite';
import { migrateGuidCompatibility } from '../blocksuite';
import {
checkWorkspaceCompatibility,
forceUpgradePages,
migrateGuidCompatibility,
MigrationPoint,
upgradeV1ToV2,
} from '../blocksuite';
import type { DocEngine } from './engine';
import type { WorkspaceManager } from './manager';
import { type WorkspaceMetadata } from './metadata';
import type { WorkspaceMetadata } from './metadata';
export interface WorkspaceUpgradeStatus {
needUpgrade: boolean;

View File

@ -4,11 +4,12 @@ import type { DocCollection } from '@blocksuite/store';
import type { ServiceProvider } from '../di';
import { CleanupService } from '../lifecycle';
import type { WorkspaceEngine } from './engine';
import { type WorkspaceEngineStatus } from './engine';
import { type WorkspaceMetadata } from './metadata';
import type { WorkspaceUpgradeController } from './upgrade';
import { type WorkspaceUpgradeStatus } from './upgrade';
import type { WorkspaceEngine, WorkspaceEngineStatus } from './engine';
import type { WorkspaceMetadata } from './metadata';
import type {
WorkspaceUpgradeController,
WorkspaceUpgradeStatus,
} from './upgrade';
export type { DocCollection } from '@blocksuite/store';

View File

@ -1,22 +1,17 @@
import { assertExists } from '@blocksuite/global/utils';
import type { IDBPDatabase } from 'idb';
import { openDB } from 'idb';
import {
createLazyProvider,
type DocDataSource,
writeOperation,
} from 'y-provider';
import type { DocDataSource } from 'y-provider';
import { createLazyProvider, writeOperation } from 'y-provider';
import type { Doc } from 'yjs';
import { diffUpdate, encodeStateVectorFromUpdate } from 'yjs';
import {
type BlockSuiteBinaryDB,
dbVersion,
DEFAULT_DB_NAME,
type IndexedDBProvider,
type UpdateMessage,
upgradeDB,
import type {
BlockSuiteBinaryDB,
IndexedDBProvider,
UpdateMessage,
} from './shared';
import { dbVersion, DEFAULT_DB_NAME, upgradeDB } from './shared';
import { mergeUpdates } from './utils';
let mergeCount = 500;

View File

@ -1,14 +1,9 @@
import { assertExists } from '@blocksuite/global/utils';
import {
applyUpdate,
type Doc,
encodeStateAsUpdate,
encodeStateVector,
} from 'yjs';
import type { Doc } from 'yjs';
import { applyUpdate, encodeStateAsUpdate, encodeStateVector } from 'yjs';
import type { DocDataSource } from './data-source';
import type { DataSourceAdapter } from './types';
import type { Status } from './types';
import type { DataSourceAdapter, Status } from './types';
function getDoc(doc: Doc, guid: string): Doc | undefined {
if (doc.guid === guid) {

View File

@ -1,6 +1,7 @@
import clsx from 'clsx';
import { Input, type InputProps } from '../../ui/input';
import type { InputProps } from '../../ui/input';
import { Input } from '../../ui/input';
import * as styles from './share.css';
export type AuthInputProps = InputProps & {
label?: string;

View File

@ -1,10 +1,5 @@
import {
type FC,
type PropsWithChildren,
type ReactNode,
useEffect,
useState,
} from 'react';
import type { FC, PropsWithChildren, ReactNode } from 'react';
import { useEffect, useState } from 'react';
import { Empty } from '../../ui/empty';
import { AffineOtherPageLayout } from '../affine-other-page-layout';

View File

@ -1,8 +1,9 @@
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { ArrowLeftSmallIcon } from '@blocksuite/icons';
import { type FC } from 'react';
import type { FC } from 'react';
import { Button, type ButtonProps } from '../../ui/button';
import type { ButtonProps } from '../../ui/button';
import { Button } from '../../ui/button';
export const BackButton: FC<ButtonProps> = props => {
const t = useAFFiNEI18N();

View File

@ -1,4 +1,5 @@
import { forwardRef, type HTMLAttributes } from 'react';
import type { HTMLAttributes } from 'react';
import { forwardRef } from 'react';
const formatTime = (time: number): string => {
const minutes = Math.floor(time / 60);

View File

@ -3,8 +3,9 @@ import { fetchWithTraceReport } from '@affine/graphql';
import { ArrowRightSmallIcon } from '@blocksuite/icons';
import clsx from 'clsx';
import { useEffect, useMemo, useState } from 'react';
import type { Location } from 'react-router-dom';
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
import { type Location, useLocation, useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import useSWR from 'swr';
import { Button } from '../../ui/button';

View File

@ -1,9 +1,10 @@
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { passwordStrength } from 'check-password-strength';
import { type FC, useEffect } from 'react';
import { useCallback, useState } from 'react';
import type { FC } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { Input, type InputProps } from '../../../ui/input';
import type { InputProps } from '../../../ui/input';
import { Input } from '../../../ui/input';
import * as styles from '../share.css';
import { ErrorIcon } from './error';
import { SuccessIcon } from './success';

View File

@ -1,5 +1,6 @@
import clsx from 'clsx';
import { type FC, useMemo } from 'react';
import type { FC } from 'react';
import { useMemo } from 'react';
import type { Status } from './index';
import { tag } from './style.css';

View File

@ -1,5 +1,6 @@
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { type FC, useCallback, useRef, useState } from 'react';
import type { FC } from 'react';
import { useCallback, useRef, useState } from 'react';
import { Button } from '../../ui/button';
import { Wrapper } from '../../ui/layout';

View File

@ -1,4 +1,5 @@
import { forwardRef, type HTMLAttributes, type ReactNode } from 'react';
import type { HTMLAttributes, ReactNode } from 'react';
import { forwardRef } from 'react';
import * as styles from './styles.css';

View File

@ -1,6 +1,7 @@
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { ConfirmModal, type ConfirmModalProps } from '../../ui/modal';
import type { ConfirmModalProps } from '../../ui/modal';
import { ConfirmModal } from '../../ui/modal';
export const PublicLinkDisableModal = (props: ConfirmModalProps) => {
const t = useAFFiNEI18N();

View File

@ -1,5 +1,6 @@
import { useAtomValue } from 'jotai';
import { type ReactNode, useEffect, useState } from 'react';
import type { ReactNode } from 'react';
import { useEffect, useState } from 'react';
import { Loading } from '../../ui/loading';
import * as styles from './index.css';

View File

@ -1,5 +1,5 @@
import { AuthPageContainer } from '@affine/component/auth-components';
import { type GetInviteInfoQuery } from '@affine/graphql';
import type { GetInviteInfoQuery } from '@affine/graphql';
import { useAFFiNEI18N } from '@affine/i18n/hooks';
import { Avatar } from '../../ui/avatar';

View File

@ -1,5 +1,8 @@
import { cssVar } from '@toeverything/theme';
import { darkCssVariables, lightCssVariables } from '@toeverything/theme';
import {
cssVar,
darkCssVariables,
lightCssVariables,
} from '@toeverything/theme';
import { globalStyle } from '@vanilla-extract/css';
globalStyle('body', {
color: cssVar('textPrimaryColor'),

View File

@ -1,7 +1,8 @@
import { CameraIcon } from '@blocksuite/icons';
import type { Meta, StoryFn } from '@storybook/react';
import { Avatar, type AvatarProps } from './avatar';
import type { AvatarProps } from './avatar';
import { Avatar } from './avatar';
export default {
title: 'UI/Avatar',

View File

@ -1,19 +1,27 @@
import { CloseIcon } from '@blocksuite/icons';
import type {
AvatarFallbackProps,
AvatarImageProps,
AvatarProps as RadixAvatarProps,
} from '@radix-ui/react-avatar';
import {
type AvatarFallbackProps,
type AvatarImageProps,
type AvatarProps as RadixAvatarProps,
Fallback as AvatarFallback,
Image as AvatarImage,
Root as AvatarRoot,
} from '@radix-ui/react-avatar';
import { assignInlineVars } from '@vanilla-extract/dynamic';
import clsx from 'clsx';
import type { CSSProperties, HTMLAttributes, MouseEvent } from 'react';
import { forwardRef, type ReactElement, useMemo, useState } from 'react';
import type {
CSSProperties,
HTMLAttributes,
MouseEvent,
ReactElement,
} from 'react';
import { forwardRef, useMemo, useState } from 'react';
import { IconButton } from '../button';
import { Tooltip, type TooltipProps } from '../tooltip';
import type { TooltipProps } from '../tooltip';
import { Tooltip } from '../tooltip';
import { ColorfulFallback } from './colorful-fallback';
import * as style from './style.css';
import { sizeVar } from './style.css';

View File

@ -1,7 +1,8 @@
import { InformationIcon } from '@blocksuite/icons';
import type { Meta, StoryFn } from '@storybook/react';
import { Button, type ButtonProps } from './button';
import type { ButtonProps } from './button';
import { Button } from './button';
export default {
title: 'UI/Button',
component: Button,

View File

@ -1,12 +1,11 @@
import clsx from 'clsx';
import {
type FC,
forwardRef,
type HTMLAttributes,
type PropsWithChildren,
type ReactElement,
useMemo,
import type {
FC,
HTMLAttributes,
PropsWithChildren,
ReactElement,
} from 'react';
import { forwardRef, useMemo } from 'react';
import { Loading } from '../loading';
import { button, buttonIcon } from './button.css';

View File

@ -1,9 +1,6 @@
import { ArrowDownSmallIcon } from '@blocksuite/icons';
import {
type ButtonHTMLAttributes,
forwardRef,
type MouseEventHandler,
} from 'react';
import type { ButtonHTMLAttributes, MouseEventHandler } from 'react';
import { forwardRef } from 'react';
import * as styles from './styles.css';

View File

@ -1,7 +1,8 @@
import { InformationIcon } from '@blocksuite/icons';
import type { Meta, StoryFn } from '@storybook/react';
import { IconButton, type IconButtonProps } from './icon-button';
import type { IconButtonProps } from './icon-button';
import { IconButton } from './icon-button';
export default {
title: 'UI/IconButton',
component: IconButton,

View File

@ -1,6 +1,6 @@
import clsx from 'clsx';
import type { HTMLAttributes, PropsWithChildren } from 'react';
import { forwardRef, type ReactElement } from 'react';
import type { HTMLAttributes, PropsWithChildren, ReactElement } from 'react';
import { forwardRef } from 'react';
import { Loading } from '../loading';
import type { ButtonType } from './button';

View File

@ -4,7 +4,8 @@ import type {
} from '@radix-ui/react-radio-group';
import * as RadioGroup from '@radix-ui/react-radio-group';
import clsx from 'clsx';
import { type CSSProperties, forwardRef } from 'react';
import type { CSSProperties } from 'react';
import { forwardRef } from 'react';
import * as styles from './styles.css';

View File

@ -1,6 +1,7 @@
// components/checkbox.tsx
import clsx from 'clsx';
import { type HTMLAttributes, useCallback, useEffect, useRef } from 'react';
import type { HTMLAttributes } from 'react';
import { useCallback, useEffect, useRef } from 'react';
import * as icons from './icons';
import * as styles from './index.css';

View File

@ -6,8 +6,8 @@ import * as styles from './calendar.css';
import { DATE_MAX, DATE_MIN } from './constants';
import { DayPicker } from './day-picker';
import { MonthPicker } from './month-picker';
import type { SelectMode } from './types';
import { type DatePickerProps, defaultDatePickerProps } from './types';
import type { DatePickerProps, SelectMode } from './types';
import { defaultDatePickerProps } from './types';
import { YearPicker } from './year-picker';
export type { DatePickerProps } from './types';

View File

@ -1,13 +1,8 @@
import { ArrowLeftSmallIcon, ArrowRightSmallIcon } from '@blocksuite/icons';
import { assignInlineVars } from '@vanilla-extract/dynamic';
import clsx from 'clsx';
import {
forwardRef,
type HTMLAttributes,
memo,
type PropsWithChildren,
type ReactNode,
} from 'react';
import type { HTMLAttributes, PropsWithChildren, ReactNode } from 'react';
import { forwardRef, memo } from 'react';
import { IconButton } from '../../button';
import * as styles from './calendar.css';

View File

@ -1,9 +1,8 @@
import { ArrowLeftSmallIcon, ArrowRightSmallIcon } from '@blocksuite/icons';
import clsx from 'clsx';
import dayjs from 'dayjs';
import type { ForwardedRef, HTMLAttributes } from 'react';
import {
type ForwardedRef,
type HTMLAttributes,
memo,
useCallback,
useEffect,

View File

@ -1,6 +1,7 @@
import type { Meta, StoryFn } from '@storybook/react';
import { Divider, type DividerProps } from './index';
import type { DividerProps } from './index';
import { Divider } from './index';
export default {
title: 'UI/Divider',

View File

@ -3,7 +3,8 @@ import { useCallback, useRef, useState } from 'react';
import { Button } from '../button';
import { ResizePanel } from '../resize-panel/resize-panel';
import { InlineEdit, type InlineEditHandle } from './inline-edit';
import type { InlineEditHandle } from './inline-edit';
import { InlineEdit } from './inline-edit';
export default {
title: 'UI/Editable/Inline Edit',

View File

@ -1,6 +1,7 @@
import type { Meta, StoryFn } from '@storybook/react';
import { Empty, type EmptyContentProps } from './index';
import type { EmptyContentProps } from './index';
import { Empty } from './index';
export default {
title: 'UI/Empty',

View File

@ -1,7 +1,8 @@
import { InformationIcon } from '@blocksuite/icons';
import type { Meta, StoryFn } from '@storybook/react';
import { Input, type InputProps } from './index';
import type { InputProps } from './index';
import { Input } from './index';
export default {
title: 'UI/Input',

View File

@ -1,6 +1,7 @@
import type { Meta, StoryFn } from '@storybook/react';
import { Loading, type LoadingProps } from './loading';
import type { LoadingProps } from './loading';
import { Loading } from './loading';
export default {
title: 'UI/Loading',

View File

@ -1,9 +1,7 @@
import type { Meta, StoryFn } from '@storybook/react';
import {
AnimatedCollectionsIcon,
type CollectionsIconProps,
} from './collections-icon';
import type { CollectionsIconProps } from './collections-icon';
import { AnimatedCollectionsIcon } from './collections-icon';
export default {
title: 'UI/Lottie/Collection Icons',

View File

@ -1,5 +1,6 @@
import clsx from 'clsx';
import Lottie, { type LottieRef } from 'lottie-react';
import type { LottieRef } from 'lottie-react';
import Lottie from 'lottie-react';
import { useEffect, useRef } from 'react';
import animationData from './collections-icon.json';

View File

@ -1,6 +1,7 @@
import type { Meta, StoryFn } from '@storybook/react';
import { AnimatedDeleteIcon, type DeleteIconProps } from './delete-icon';
import type { DeleteIconProps } from './delete-icon';
import { AnimatedDeleteIcon } from './delete-icon';
export default {
title: 'UI/Lottie/Delete Icon',

View File

@ -1,5 +1,6 @@
import clsx from 'clsx';
import Lottie, { type LottieRef } from 'lottie-react';
import type { LottieRef } from 'lottie-react';
import Lottie from 'lottie-react';
import { useEffect, useRef } from 'react';
import animationData from './delete-icon.json';

View File

@ -1,6 +1,6 @@
import clsx from 'clsx';
import type { PropsWithChildren, ReactNode } from 'react';
import { forwardRef, type HTMLAttributes, useMemo } from 'react';
import type { HTMLAttributes, PropsWithChildren, ReactNode } from 'react';
import { forwardRef, useMemo } from 'react';
import { menuItemIcon } from './styles.css';

View File

@ -1,6 +1,7 @@
import type { Meta, StoryFn } from '@storybook/react';
import { MenuTrigger, type MenuTriggerProps } from './index';
import type { MenuTriggerProps } from './index';
import { MenuTrigger } from './index';
export default {
title: 'UI/MenuTrigger',

View File

@ -1,13 +1,13 @@
import { ArrowDownSmallIcon } from '@blocksuite/icons';
import { assignInlineVars } from '@vanilla-extract/dynamic';
import clsx from 'clsx';
import type { PropsWithChildren } from 'react';
import {
type CSSProperties,
forwardRef,
type HTMLAttributes,
type ReactNode,
import type {
CSSProperties,
HTMLAttributes,
PropsWithChildren,
ReactNode,
} from 'react';
import { forwardRef } from 'react';
import { MenuIcon } from './menu-icon';
import * as styles from './styles.css';

View File

@ -1,15 +1,15 @@
import { InformationIcon } from '@blocksuite/icons';
import type { Meta, StoryFn } from '@storybook/react';
import { type ReactNode, useCallback, useState } from 'react';
import type { ReactNode } from 'react';
import { useCallback, useState } from 'react';
import { Button } from '../button';
import { Tooltip } from '../tooltip';
import type { MenuItemProps, MenuProps } from './index';
import {
Menu,
MenuIcon,
MenuItem,
type MenuItemProps,
type MenuProps,
MenuSeparator,
MenuSub,
MenuTrigger,

View File

@ -2,7 +2,7 @@ import { DoneIcon } from '@blocksuite/icons';
import clsx from 'clsx';
import { useMemo } from 'react';
import { type MenuItemProps } from './menu.types';
import type { MenuItemProps } from './menu.types';
import { MenuIcon } from './menu-icon';
import * as styles from './styles.css';

View File

@ -3,7 +3,8 @@ import clsx from 'clsx';
import type { ButtonProps } from '../button';
import { Button } from '../button';
import { Modal, type ModalProps } from './modal';
import type { ModalProps } from './modal';
import { Modal } from './modal';
import * as styles from './styles.css';
export interface ConfirmModalProps extends ModalProps {

View File

@ -2,10 +2,14 @@ import type { Meta, StoryFn } from '@storybook/react';
import { useCallback, useState } from 'react';
import { Button } from '../button';
import { Input, type InputProps } from '../input';
import { ConfirmModal, type ConfirmModalProps } from './confirm-modal';
import { Modal, type ModalProps } from './modal';
import { OverlayModal, type OverlayModalProps } from './overlay-modal';
import type { InputProps } from '../input';
import { Input } from '../input';
import type { ConfirmModalProps } from './confirm-modal';
import { ConfirmModal } from './confirm-modal';
import type { ModalProps } from './modal';
import { Modal } from './modal';
import type { OverlayModalProps } from './overlay-modal';
import { OverlayModal } from './overlay-modal';
export default {
title: 'UI/Modal',

View File

@ -8,9 +8,11 @@ import type {
import * as Dialog from '@radix-ui/react-dialog';
import { assignInlineVars } from '@vanilla-extract/dynamic';
import clsx from 'clsx';
import { type CSSProperties, forwardRef } from 'react';
import type { CSSProperties } from 'react';
import { forwardRef } from 'react';
import { IconButton, type IconButtonProps } from '../button';
import type { IconButtonProps } from '../button';
import { IconButton } from '../button';
import * as styles from './styles.css';
export interface ModalProps extends DialogProps {

View File

@ -3,8 +3,10 @@ import { cssVar } from '@toeverything/theme';
import { memo, useCallback } from 'react';
import { Link } from 'react-router-dom';
import { Button, type ButtonProps } from '../button';
import { Modal, type ModalProps } from './modal';
import type { ButtonProps } from '../button';
import { Button } from '../button';
import type { ModalProps } from './modal';
import { Modal } from './modal';
import * as styles from './overlay-modal.css';
const defaultContentOptions: ModalProps['contentOptions'] = {

View File

@ -5,7 +5,8 @@ import type {
} from '@radix-ui/react-popover';
import * as PopoverPrimitive from '@radix-ui/react-popover';
import clsx from 'clsx';
import { type ReactNode, useMemo } from 'react';
import type { ReactNode } from 'react';
import { useMemo } from 'react';
import * as styles from './styles.css';

View File

@ -1,10 +1,6 @@
import clsx from 'clsx';
import {
type HTMLAttributes,
type PropsWithChildren,
useEffect,
useRef,
} from 'react';
import type { HTMLAttributes, PropsWithChildren } from 'react';
import { useEffect, useRef } from 'react';
import * as styles from './styles.css';

View File

@ -1,6 +1,7 @@
import * as ScrollArea from '@radix-ui/react-scroll-area';
import clsx from 'clsx';
import { forwardRef, type RefAttributes } from 'react';
import type { RefAttributes } from 'react';
import { forwardRef } from 'react';
import * as styles from './index.css';

View File

@ -1,6 +1,7 @@
import type { Meta, StoryFn } from '@storybook/react';
import { ScrollableContainer, type ScrollableContainerProps } from './index';
import type { ScrollableContainerProps } from './index';
import { ScrollableContainer } from './index';
export default {
title: 'UI/Scrollbar',

View File

@ -1,6 +1,7 @@
import * as ScrollArea from '@radix-ui/react-scroll-area';
import clsx from 'clsx';
import { type PropsWithChildren, useRef } from 'react';
import type { PropsWithChildren } from 'react';
import { useRef } from 'react';
import * as styles from './index.css';
import { useHasScrollTop } from './use-has-scroll-top';

View File

@ -1,4 +1,5 @@
import { type RefObject, useEffect, useState } from 'react';
import type { RefObject } from 'react';
import { useEffect, useState } from 'react';
export function useHasScrollTop(ref: RefObject<HTMLElement> | null) {
const [hasScrollTop, setHasScrollTop] = useState(false);

Some files were not shown because too many files have changed in this diff Show More