Skip to content

Commit

Permalink
Enforce consistent usage of type imports (#1987)
Browse files Browse the repository at this point in the history
Enables and applies the [`consistent-type-imports`](https://typescript-eslint.io/rules/consistent-type-imports/) ESLint rule:

- Enable rule to error.
- Apply rule across codebase.
  • Loading branch information
iamacook authored Oct 7, 2024
1 parent ff364b0 commit 9804cee
Show file tree
Hide file tree
Showing 355 changed files with 1,173 additions and 1,093 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default tseslint.config(
'warn',
{ assertionStyle: 'as' },
],
'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-floating-promises': 'warn',
'no-restricted-imports': [
Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/amqp-client.factory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import amqp, { ChannelWrapper } from 'amqp-connection-manager';
import { Channel } from 'amqplib';
import type { ChannelWrapper } from 'amqp-connection-manager';
import amqp from 'amqp-connection-manager';
import type { Channel } from 'amqplib';

export function amqpClientFactory(queue?: string): {
channel: ChannelWrapper;
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/encoder-builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Hex } from 'viem';
import type { Hex } from 'viem';

export interface IEncoder<E = Hex> {
encode(): E;
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/redis-client.factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RedisClientType, createClient } from 'redis';
import type { RedisClientType } from 'redis';
import { createClient } from 'redis';

export async function redisClientFactory(): Promise<RedisClientType> {
const { REDIS_HOST = 'localhost', REDIS_PORT = 6379 } = process.env;
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/test-app.provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { INestApplication } from '@nestjs/common';
import type { INestApplication } from '@nestjs/common';
import { TestingModule } from '@nestjs/testing';
import {
AppProvider,
Expand Down
3 changes: 2 additions & 1 deletion src/app.provider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { INestApplication, VersioningType } from '@nestjs/common';
import type { INestApplication } from '@nestjs/common';
import { VersioningType } from '@nestjs/common';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { NestFactory } from '@nestjs/core';
import { IConfigurationService } from '@/config/configuration.service.interface';
Expand Down
2 changes: 1 addition & 1 deletion src/config/__tests__/fake.configuration.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IConfigurationService } from '@/config/configuration.service.interface';
import type { IConfigurationService } from '@/config/configuration.service.interface';

export class FakeConfigurationService implements IConfigurationService {
private configuration: Record<string, unknown> = {};
Expand Down
3 changes: 2 additions & 1 deletion src/config/configuration.module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Test, TestingModule } from '@nestjs/testing';
import type { TestingModule } from '@nestjs/testing';
import { Test } from '@nestjs/testing';
import { ConfigurationModule } from '@/config/configuration.module';

describe('ConfigurationModule', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/config/configuration.validator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ZodType } from 'zod';
import type { ZodType } from 'zod';

/**
* Validates the configuration against the provided schema
Expand Down
2 changes: 1 addition & 1 deletion src/config/entities/__tests__/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { faker } from '@faker-js/faker';
import configuration from '@/config/entities/configuration';
import type configuration from '@/config/entities/configuration';

export default (): ReturnType<typeof configuration> => ({
about: {
Expand Down
2 changes: 1 addition & 1 deletion src/config/nest.configuration.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NestConfigurationService } from '@/config/nest.configuration.service';
import { faker } from '@faker-js/faker';
import { ConfigService } from '@nestjs/config';
import type { ConfigService } from '@nestjs/config';

const configService = {
get: jest.fn(),
Expand Down
8 changes: 4 additions & 4 deletions src/datasources/accounts/accounts.datasource.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TestDbFactory } from '@/__tests__/db.factory';
import { IConfigurationService } from '@/config/configuration.service.interface';
import type { IConfigurationService } from '@/config/configuration.service.interface';
import { AccountsDatasource } from '@/datasources/accounts/accounts.datasource';
import { FakeCacheService } from '@/datasources/cache/__tests__/fake.cache.service';
import { MAX_TTL } from '@/datasources/cache/constants';
Expand All @@ -8,10 +8,10 @@ import { CachedQueryResolver } from '@/datasources/db/cached-query-resolver';
import { PostgresDatabaseMigrator } from '@/datasources/db/postgres-database.migrator';
import { accountDataTypeBuilder } from '@/domain/accounts/entities/__tests__/account-data-type.builder';
import { upsertAccountDataSettingsDtoBuilder } from '@/domain/accounts/entities/__tests__/upsert-account-data-settings.dto.entity.builder';
import { AccountDataType } from '@/domain/accounts/entities/account-data-type.entity';
import { ILoggingService } from '@/logging/logging.interface';
import type { AccountDataType } from '@/domain/accounts/entities/account-data-type.entity';
import type { ILoggingService } from '@/logging/logging.interface';
import { faker } from '@faker-js/faker';
import postgres from 'postgres';
import type postgres from 'postgres';
import { getAddress } from 'viem';

const mockLoggingService = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { TestDbFactory } from '@/__tests__/db.factory';
import { IConfigurationService } from '@/config/configuration.service.interface';
import type { IConfigurationService } from '@/config/configuration.service.interface';
import { CounterfactualSafesDatasource } from '@/datasources/accounts/counterfactual-safes/counterfactual-safes.datasource';
import { FakeCacheService } from '@/datasources/cache/__tests__/fake.cache.service';
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import { CachedQueryResolver } from '@/datasources/db/cached-query-resolver';
import { PostgresDatabaseMigrator } from '@/datasources/db/postgres-database.migrator';
import { createCounterfactualSafeDtoBuilder } from '@/domain/accounts/counterfactual-safes/entities/__tests__/create-counterfactual-safe.dto.entity.builder';
import { accountBuilder } from '@/domain/accounts/entities/__tests__/account.builder';
import { Account } from '@/domain/accounts/entities/account.entity';
import { ILoggingService } from '@/logging/logging.interface';
import type { Account } from '@/domain/accounts/entities/account.entity';
import type { ILoggingService } from '@/logging/logging.interface';
import { faker } from '@faker-js/faker';
import postgres from 'postgres';
import type postgres from 'postgres';
import { getAddress } from 'viem';

const mockLoggingService = {
Expand Down
6 changes: 3 additions & 3 deletions src/datasources/alerts-api/tenderly-api.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { faker } from '@faker-js/faker';
import { FakeConfigurationService } from '@/config/__tests__/fake.configuration.service';
import { TenderlyApi } from '@/datasources/alerts-api/tenderly-api.service';
import { HttpErrorFactory } from '@/datasources/errors/http-error-factory';
import { INetworkService } from '@/datasources/network/network.service.interface';
import { AlertsRegistration } from '@/domain/alerts/entities/alerts-registration.entity';
import type { INetworkService } from '@/datasources/network/network.service.interface';
import type { AlertsRegistration } from '@/domain/alerts/entities/alerts-registration.entity';
import { DataSourceError } from '@/domain/errors/data-source.error';
import { NetworkResponseError } from '@/datasources/network/entities/network.error.entity';
import { AlertsDeletion } from '@/domain/alerts/entities/alerts-deletion.entity';
import type { AlertsDeletion } from '@/domain/alerts/entities/alerts-deletion.entity';
import { getAddress } from 'viem';

const networkService = {
Expand Down
18 changes: 9 additions & 9 deletions src/datasources/balances-api/balances-api.manager.spec.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { IConfigurationService } from '@/config/configuration.service.interface';
import type { IConfigurationService } from '@/config/configuration.service.interface';
import { BalancesApiManager } from '@/datasources/balances-api/balances-api.manager';
import { CacheFirstDataSource } from '@/datasources/cache/cache.first.data.source';
import { ICacheService } from '@/datasources/cache/cache.service.interface';
import { HttpErrorFactory } from '@/datasources/errors/http-error-factory';
import type { CacheFirstDataSource } from '@/datasources/cache/cache.first.data.source';
import type { ICacheService } from '@/datasources/cache/cache.service.interface';
import type { HttpErrorFactory } from '@/datasources/errors/http-error-factory';
import { chainBuilder } from '@/domain/chains/entities/__tests__/chain.builder';
import { IBalancesApi } from '@/domain/interfaces/balances-api.interface';
import { IConfigApi } from '@/domain/interfaces/config-api.interface';
import { IPricesApi } from '@/datasources/balances-api/prices-api.interface';
import type { IBalancesApi } from '@/domain/interfaces/balances-api.interface';
import type { IConfigApi } from '@/domain/interfaces/config-api.interface';
import type { IPricesApi } from '@/datasources/balances-api/prices-api.interface';
import { faker } from '@faker-js/faker';
import { getAddress } from 'viem';
import { sample } from 'lodash';
import { ITransactionApiManager } from '@/domain/interfaces/transaction-api.manager.interface';
import { ITransactionApi } from '@/domain/interfaces/transaction-api.interface';
import type { ITransactionApiManager } from '@/domain/interfaces/transaction-api.manager.interface';
import type { ITransactionApi } from '@/domain/interfaces/transaction-api.interface';

const configurationService = {
getOrThrow: jest.fn(),
Expand Down
10 changes: 5 additions & 5 deletions src/datasources/balances-api/coingecko-api.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { FakeConfigurationService } from '@/config/__tests__/fake.configuration.
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import { CoingeckoApi } from '@/datasources/balances-api/coingecko-api.service';
import { faker } from '@faker-js/faker';
import { CacheFirstDataSource } from '../cache/cache.first.data.source';
import { AssetPrice } from '@/datasources/balances-api/entities/asset-price.entity';
import { ICacheService } from '@/datasources/cache/cache.service.interface';
import { INetworkService } from '@/datasources/network/network.service.interface';
import type { CacheFirstDataSource } from '../cache/cache.first.data.source';
import type { AssetPrice } from '@/datasources/balances-api/entities/asset-price.entity';
import type { ICacheService } from '@/datasources/cache/cache.service.interface';
import type { INetworkService } from '@/datasources/network/network.service.interface';
import { sortBy } from 'lodash';
import { ILoggingService } from '@/logging/logging.interface';
import type { ILoggingService } from '@/logging/logging.interface';
import { chainBuilder } from '@/domain/chains/entities/__tests__/chain.builder';
import { pricesProviderBuilder } from '@/domain/chains/entities/__tests__/prices-provider.builder';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { faker } from '@faker-js/faker';
import { Builder, IBuilder } from '../../../../__tests__/builder';
import {
import type { IBuilder } from '../../../../__tests__/builder';
import { Builder } from '../../../../__tests__/builder';
import type {
ZerionAttributes,
ZerionBalance,
ZerionBalances,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Builder, IBuilder } from '@/__tests__/builder';
import {
import type { IBuilder } from '@/__tests__/builder';
import { Builder } from '@/__tests__/builder';
import type {
ZerionCollectible,
ZerionCollectibleAttributes,
ZerionCollectibles,
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/balances-api/prices-api.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AssetPrice } from '@/datasources/balances-api/entities/asset-price.entity';
import { Chain } from '@/domain/chains/entities/chain.entity';
import type { AssetPrice } from '@/datasources/balances-api/entities/asset-price.entity';
import type { Chain } from '@/domain/chains/entities/chain.entity';

export const IPricesApi = Symbol('IPricesApi');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FakeConfigurationService } from '@/config/__tests__/fake.configuration.service';
import { ZerionBalancesApi } from '@/datasources/balances-api/zerion-balances-api.service';
import { ICacheService } from '@/datasources/cache/cache.service.interface';
import { HttpErrorFactory } from '@/datasources/errors/http-error-factory';
import { INetworkService } from '@/datasources/network/network.service.interface';
import type { ICacheService } from '@/datasources/cache/cache.service.interface';
import type { HttpErrorFactory } from '@/datasources/errors/http-error-factory';
import type { INetworkService } from '@/datasources/network/network.service.interface';
import { balancesProviderBuilder } from '@/domain/chains/entities/__tests__/balances-provider.builder';
import { chainBuilder } from '@/domain/chains/entities/__tests__/chain.builder';
import { ILoggingService } from '@/logging/logging.interface';
import type { ILoggingService } from '@/logging/logging.interface';
import { faker } from '@faker-js/faker';
import { getAddress } from 'viem';

Expand Down
2 changes: 1 addition & 1 deletion src/datasources/blockchain/blockchain-api.manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import { chainBuilder } from '@/domain/chains/entities/__tests__/chain.builder';
import { rpcUriBuilder } from '@/domain/chains/entities/__tests__/rpc-uri.builder';
import { RpcUriAuthentication } from '@/domain/chains/entities/rpc-uri-authentication.entity';
import { IConfigApi } from '@/domain/interfaces/config-api.interface';
import type { IConfigApi } from '@/domain/interfaces/config-api.interface';
import { faker } from '@faker-js/faker';
import { hexToNumber, toHex } from 'viem';

Expand Down
4 changes: 2 additions & 2 deletions src/datasources/cache/__tests__/fake.cache.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ICacheService } from '@/datasources/cache/cache.service.interface';
import type { ICacheService } from '@/datasources/cache/cache.service.interface';
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import { ICacheReadiness } from '@/domain/interfaces/cache-readiness.interface';
import type { ICacheReadiness } from '@/domain/interfaces/cache-readiness.interface';

export class FakeCacheService implements ICacheService, ICacheReadiness {
private cache: Record<string, Record<string, string> | number> = {};
Expand Down
6 changes: 3 additions & 3 deletions src/datasources/cache/cache.first.data.source.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { faker } from '@faker-js/faker';
import { fakeJson } from '@/__tests__/faker';
import { FakeCacheService } from '@/datasources/cache/__tests__/fake.cache.service';
import { CacheFirstDataSource } from '@/datasources/cache/cache.first.data.source';
import { ICacheService } from '@/datasources/cache/cache.service.interface';
import type { ICacheService } from '@/datasources/cache/cache.service.interface';
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import { NetworkResponseError } from '@/datasources/network/entities/network.error.entity';
import { INetworkService } from '@/datasources/network/network.service.interface';
import { ILoggingService } from '@/logging/logging.interface';
import type { INetworkService } from '@/datasources/network/network.service.interface';
import type { ILoggingService } from '@/logging/logging.interface';
import { FakeConfigurationService } from '@/config/__tests__/fake.configuration.service';

const mockLoggingService: jest.MockedObjectDeep<ILoggingService> = {
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/cache/cache.service.interface.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import type { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';

export const CacheService = Symbol('ICacheService');

Expand Down
6 changes: 3 additions & 3 deletions src/datasources/cache/redis.cache.service.key-prefix.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { faker } from '@faker-js/faker';
import { ILoggingService } from '@/logging/logging.interface';
import type { ILoggingService } from '@/logging/logging.interface';
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import { RedisCacheService } from '@/datasources/cache/redis.cache.service';
import { RedisClientType } from 'redis';
import type { RedisClientType } from 'redis';
import { fakeJson } from '@/__tests__/faker';
import { IConfigurationService } from '@/config/configuration.service.interface';
import type { IConfigurationService } from '@/config/configuration.service.interface';
import clearAllMocks = jest.clearAllMocks;

const redisClientType = {
Expand Down
6 changes: 3 additions & 3 deletions src/datasources/cache/redis.cache.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { faker } from '@faker-js/faker';
import { ILoggingService } from '@/logging/logging.interface';
import type { ILoggingService } from '@/logging/logging.interface';
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import { RedisCacheService } from '@/datasources/cache/redis.cache.service';
import { RedisClientType } from 'redis';
import type { RedisClientType } from 'redis';
import { fakeJson } from '@/__tests__/faker';
import { IConfigurationService } from '@/config/configuration.service.interface';
import type { IConfigurationService } from '@/config/configuration.service.interface';
import clearAllMocks = jest.clearAllMocks;
import { redisClientFactory } from '@/__tests__/redis-client.factory';
import { MAX_TTL } from '@/datasources/cache/constants';
Expand Down
8 changes: 4 additions & 4 deletions src/datasources/config-api/config-api.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { FakeConfigurationService } from '@/config/__tests__/fake.configuration.service';
import { CacheFirstDataSource } from '@/datasources/cache/cache.first.data.source';
import { ICacheService } from '@/datasources/cache/cache.service.interface';
import type { CacheFirstDataSource } from '@/datasources/cache/cache.first.data.source';
import type { ICacheService } from '@/datasources/cache/cache.service.interface';
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import { ConfigApi } from '@/datasources/config-api/config-api.service';
import { HttpErrorFactory } from '@/datasources/errors/http-error-factory';
import type { HttpErrorFactory } from '@/datasources/errors/http-error-factory';
import { chainBuilder } from '@/domain/chains/entities/__tests__/chain.builder';
import { DataSourceError } from '@/domain/errors/data-source.error';
import { safeAppBuilder } from '@/domain/safe-apps/entities/__tests__/safe-app.builder';
import { ILoggingService } from '@/logging/logging.interface';
import type { ILoggingService } from '@/logging/logging.interface';
import { faker } from '@faker-js/faker';

const dataSource = {
Expand Down
4 changes: 2 additions & 2 deletions src/datasources/db/cached-query-resolver.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import postgres from 'postgres';
import type { CacheDir } from '@/datasources/cache/entities/cache-dir.entity';
import type postgres from 'postgres';

export const ICachedQueryResolver = Symbol('ICachedQueryResolver');

Expand Down
5 changes: 3 additions & 2 deletions src/datasources/db/cached-query-resolver.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { fakeJson } from '@/__tests__/faker';
import { FakeCacheService } from '@/datasources/cache/__tests__/fake.cache.service';
import { CachedQueryResolver } from '@/datasources/db/cached-query-resolver';
import { ILoggingService } from '@/logging/logging.interface';
import type { ILoggingService } from '@/logging/logging.interface';
import { faker } from '@faker-js/faker';
import { InternalServerErrorException } from '@nestjs/common';
import postgres, { MaybeRow } from 'postgres';
import type { MaybeRow } from 'postgres';
import type postgres from 'postgres';

const mockLoggingService = jest.mocked({
debug: jest.fn(),
Expand Down
8 changes: 4 additions & 4 deletions src/datasources/db/postgres-database.migration.hook.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { TestDbFactory } from '@/__tests__/db.factory';
import { IConfigurationService } from '@/config/configuration.service.interface';
import type { IConfigurationService } from '@/config/configuration.service.interface';
import { PostgresDatabaseMigrationHook } from '@/datasources/db/postgres-database.migration.hook';
import { PostgresDatabaseMigrator } from '@/datasources/db/postgres-database.migrator';
import { ILoggingService } from '@/logging/logging.interface';
import type { PostgresDatabaseMigrator } from '@/datasources/db/postgres-database.migrator';
import type { ILoggingService } from '@/logging/logging.interface';
import { faker } from '@faker-js/faker';
import postgres from 'postgres';
import type postgres from 'postgres';

const migrator = jest.mocked({
migrate: jest.fn(),
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/db/postgres-database.migrator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PostgresDatabaseMigrator } from '@/datasources/db/postgres-database.mig
import { faker } from '@faker-js/faker';
import fs from 'node:fs';
import path from 'node:path';
import postgres from 'postgres';
import type postgres from 'postgres';

const folder = path.join(__dirname, 'migrations');
const migrations: Array<{
Expand Down
2 changes: 1 addition & 1 deletion src/datasources/db/postgres-database.module.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PostgresDatabaseModule } from '@/datasources/db/postgres-database.modul
import { TestLoggingModule } from '@/logging/__tests__/test.logging.module';
import { Test } from '@nestjs/testing';
import { join } from 'path';
import postgres from 'postgres';
import type postgres from 'postgres';

describe('PostgresDatabaseModule tests', () => {
let sql: postgres.Sql;
Expand Down
Loading

0 comments on commit 9804cee

Please sign in to comment.