Skip to content

Commit

Permalink
style: enable import-x/no-duplicates (#6279)
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Mar 25, 2024
1 parent 7ce2bfb commit f2adbda
Show file tree
Hide file tree
Showing 342 changed files with 880 additions and 1,032 deletions.
5 changes: 3 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const config = {
'@typescript-eslint',
'simple-import-sort',
'sonarjs',
'i',
'import-x',
'unused-imports',
'unicorn',
'rxjs',
Expand Down Expand Up @@ -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',
{
Expand Down Expand Up @@ -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',
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 2 additions & 5 deletions packages/backend/server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/src/core/auth/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
8 changes: 2 additions & 6 deletions packages/backend/server/src/core/doc/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/server/src/core/doc/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions packages/backend/server/src/core/quota/service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
5 changes: 3 additions & 2 deletions packages/backend/server/src/core/user/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/src/core/workspaces/permission.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 2 additions & 4 deletions packages/backend/server/src/core/workspaces/resolvers/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 2 additions & 7 deletions packages/backend/server/src/fundamentals/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/backend/server/src/fundamentals/helpers/url.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@nestjs/common';
import { type Response } from 'express';
import type { Response } from 'express';

import { Config } from '../config';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/server/src/fundamentals/throttler/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/server/src/plugins/payment/types.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/src/plugins/redis/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/tests/app.e2e.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/tests/auth.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/tests/feature.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/server/tests/history.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/tests/mailer.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/tests/mailer.spec.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/tests/quota.spec.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/tests/workspace-invite.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/server/tests/workspace.e2e.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
9 changes: 7 additions & 2 deletions packages/common/infra/src/blocksuite/migration/subdoc.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
7 changes: 2 additions & 5 deletions packages/common/infra/src/command/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
8 changes: 4 additions & 4 deletions packages/common/infra/src/di/core/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/common/infra/src/di/react/index.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
Loading

0 comments on commit f2adbda

Please sign in to comment.