fix(lint): enforce consistent-type-imports and fix import ordering across codebase
Auto-fix 862 lint errors: convert value imports used only as types to `import type`, fix import group ordering in seed.ts and du-an-api.ts, remove unused imports in auth controller, and clean up stale eslint-disable comments referencing non-existent rules. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { BaseEntity } from './base-entity';
|
||||
import { DomainEvent } from './domain-event';
|
||||
import { type DomainEvent } from './domain-event';
|
||||
|
||||
export abstract class AggregateRoot<TId = string> extends BaseEntity<TId> {
|
||||
private _domainEvents: DomainEvent[] = [];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import { Injectable, type OnModuleInit } from '@nestjs/common';
|
||||
import { InjectMetric } from '@willsoto/nestjs-prometheus';
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports -- NestJS DI requires value imports for emitDecoratorMetadata
|
||||
import { Counter } from 'prom-client';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CachePrefix, CacheService, CacheTTL } from '../cache.service';
|
||||
import { type CachePrefix, CacheService, type CacheTTL } from '../cache.service';
|
||||
|
||||
/**
|
||||
* Metadata key for @Cacheable decorator options.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { UserRole } from '@prisma/client';
|
||||
import { USER_RATE_LIMIT_KEY, UserRateLimitOptions } from '../guards/user-rate-limit.guard';
|
||||
import { type UserRole } from '@prisma/client';
|
||||
import { USER_RATE_LIMIT_KEY, type UserRateLimitOptions } from '../guards/user-rate-limit.guard';
|
||||
|
||||
/**
|
||||
* Decorator to override per-user rate limits for a specific route or controller.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
import { Prisma } from '@prisma/client';
|
||||
import {
|
||||
FieldEncryptionService,
|
||||
type FieldEncryptionService,
|
||||
type ModelEncryptionConfig,
|
||||
type ModelEncryptionFieldConfig,
|
||||
} from './field-encryption.service';
|
||||
|
||||
@@ -27,12 +27,18 @@ const REQUIRED_WHEN_USED: ReadonlyMap<string, string> = new Map([
|
||||
['ZALOPAY_APP_ID', 'ZaloPay payments'],
|
||||
['ZALOPAY_KEY1', 'ZaloPay payments'],
|
||||
['ZALOPAY_KEY2', 'ZaloPay payments'],
|
||||
['BANK_TRANSFER_ACCOUNT_NUMBER', 'Bank transfer payments'],
|
||||
['BANK_TRANSFER_BANK_NAME', 'Bank transfer payments'],
|
||||
['BANK_TRANSFER_ACCOUNT_HOLDER', 'Bank transfer payments'],
|
||||
['BANK_TRANSFER_WEBHOOK_SECRET', 'Bank transfer payments'],
|
||||
['MINIO_ACCESS_KEY', 'Media storage'],
|
||||
['MINIO_SECRET_KEY', 'Media storage'],
|
||||
['GOOGLE_CLIENT_ID', 'Google OAuth'],
|
||||
['GOOGLE_CLIENT_SECRET', 'Google OAuth'],
|
||||
['ZALO_APP_ID', 'Zalo OAuth'],
|
||||
['ZALO_APP_SECRET', 'Zalo OAuth'],
|
||||
['ZALO_OA_ID', 'Zalo OA notifications'],
|
||||
['ZALO_OA_ACCESS_TOKEN', 'Zalo OA notifications'],
|
||||
]);
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-imports -- NestJS DI requires value imports
|
||||
import { EventEmitter2 } from '@nestjs/event-emitter';
|
||||
import { DomainEvent } from '../domain/domain-event';
|
||||
import { type DomainEvent } from '../domain/domain-event';
|
||||
|
||||
@Injectable()
|
||||
export class EventBusService {
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
isEncrypted,
|
||||
type FieldEncryptionConfig,
|
||||
} from './field-encryption';
|
||||
import { LoggerService } from './logger.service';
|
||||
import { type LoggerService } from './logger.service';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Configuration types
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import {
|
||||
type ArgumentsHost,
|
||||
Catch,
|
||||
ExceptionFilter,
|
||||
type ExceptionFilter,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
} from '@nestjs/common';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { Request, Response } from 'express';
|
||||
import { DomainException, ErrorResponseBody } from '../../domain/domain-exception';
|
||||
import { type Request, type Response } from 'express';
|
||||
import { DomainException, type ErrorResponseBody } from '../../domain/domain-exception';
|
||||
import { ErrorCode } from '../../domain/error-codes';
|
||||
import { LoggerService } from '../logger.service';
|
||||
import { type LoggerService } from '../logger.service';
|
||||
|
||||
@Catch()
|
||||
export class GlobalExceptionFilter implements ExceptionFilter {
|
||||
|
||||
@@ -5,14 +5,14 @@ import {
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
} from '@nestjs/common';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
import { Request, Response } from 'express';
|
||||
import { type Reflector } from '@nestjs/core';
|
||||
import { type Request, type Response } from 'express';
|
||||
import {
|
||||
ENDPOINT_RATE_LIMIT_KEY,
|
||||
type EndpointRateLimitOptions,
|
||||
} from '../decorators/endpoint-rate-limit.decorator';
|
||||
import { LoggerService } from '../logger.service';
|
||||
import { RedisService } from '../redis.service';
|
||||
import { type LoggerService } from '../logger.service';
|
||||
import { type RedisService } from '../redis.service';
|
||||
|
||||
/** Express request extended with optional JWT user payload. */
|
||||
interface AuthenticatedRequest extends Request {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { ThrottlerGuard } from '@nestjs/throttler';
|
||||
import { Request } from 'express';
|
||||
import { type Request } from 'express';
|
||||
|
||||
/**
|
||||
* Extends ThrottlerGuard to extract real client IP behind reverse proxies
|
||||
|
||||
@@ -5,10 +5,10 @@ import {
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
} from '@nestjs/common';
|
||||
import { Reflector } from '@nestjs/core';
|
||||
import { UserRole } from '@prisma/client';
|
||||
import { LoggerService } from '../logger.service';
|
||||
import { RedisService } from '../redis.service';
|
||||
import { type Reflector } from '@nestjs/core';
|
||||
import { type UserRole } from '@prisma/client';
|
||||
import { type LoggerService } from '../logger.service';
|
||||
import { type RedisService } from '../redis.service';
|
||||
|
||||
/**
|
||||
* Role-based rate limits (requests per window).
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, LoggerService as NestLoggerService } from '@nestjs/common';
|
||||
import pinoLogger, { Logger, stdTimeFunctions } from 'pino';
|
||||
import { Injectable, type LoggerService as NestLoggerService } from '@nestjs/common';
|
||||
import pinoLogger, { type Logger, stdTimeFunctions } from 'pino';
|
||||
import { maskPii } from './pii-masker';
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
import { Injectable, type NestMiddleware } from '@nestjs/common';
|
||||
import { type NextFunction, type Request, type Response } from 'express';
|
||||
|
||||
const CORRELATION_ID_HEADER = 'x-correlation-id';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { randomBytes } from 'node:crypto';
|
||||
import { ForbiddenException, Injectable, NestMiddleware } from '@nestjs/common';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
import { ForbiddenException, Injectable, type NestMiddleware } from '@nestjs/common';
|
||||
import { type NextFunction, type Request, type Response } from 'express';
|
||||
|
||||
const CSRF_COOKIE = 'XSRF-TOKEN';
|
||||
const CSRF_HEADER = 'x-csrf-token';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
import { LoggerService } from '../logger.service';
|
||||
import { Injectable, type NestMiddleware } from '@nestjs/common';
|
||||
import { type NextFunction, type Request, type Response } from 'express';
|
||||
import { type LoggerService } from '../logger.service';
|
||||
|
||||
@Injectable()
|
||||
export class RequestLoggingMiddleware implements NestMiddleware {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable, NestMiddleware } from '@nestjs/common';
|
||||
import { NextFunction, Request, Response } from 'express';
|
||||
import { Injectable, type NestMiddleware } from '@nestjs/common';
|
||||
import { type NextFunction, type Request, type Response } from 'express';
|
||||
import sanitizeHtml from 'sanitize-html';
|
||||
|
||||
const SANITIZE_OPTIONS: sanitizeHtml.IOptions = {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common';
|
||||
import { Injectable, type OnModuleInit, type OnModuleDestroy } from '@nestjs/common';
|
||||
import { PrismaPg } from '@prisma/adapter-pg';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import pg from 'pg';
|
||||
import { createEncryptionExtension } from './encryption-middleware';
|
||||
import { FieldEncryptionService } from './field-encryption.service';
|
||||
import { LoggerService } from './logger.service';
|
||||
import { type LoggerService } from './logger.service';
|
||||
|
||||
@Injectable()
|
||||
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Injectable, OnModuleDestroy } from '@nestjs/common';
|
||||
import { Injectable, type OnModuleDestroy } from '@nestjs/common';
|
||||
import Redis from 'ioredis';
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Global, MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common';
|
||||
import { Global, type MiddlewareConsumer, Module, type NestModule, RequestMethod } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { APP_FILTER } from '@nestjs/core';
|
||||
import { EventEmitterModule } from '@nestjs/event-emitter';
|
||||
|
||||
Reference in New Issue
Block a user