From 636552698eb4b0a09d1a96c99b735c079ea0d375 Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 15 Apr 2022 11:40:34 +0800 Subject: [PATCH] chore: cleanup --- .eslintrc.js | 13 +++++++++++++ package.json | 1 + pnpm-lock.yaml | 21 +++++++++++++++++++++ src/common/guard/auth.guard.ts | 11 +---------- src/modules/health/health.dto.ts | 9 +-------- src/modules/link/link.service.ts | 1 - src/modules/pageproxy/pageproxy.dto.ts | 2 +- src/modules/user/user.service.ts | 1 - 8 files changed, 38 insertions(+), 21 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 4de4c227..9c7b6e51 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,20 @@ module.exports = { extends: ['@innei-util/eslint-config-ts'], + plugins: ['unused-imports'], rules: { 'no-empty': 'warn', 'no-fallthrough': 'error', + 'no-unused-vars': 'off', // or "@typescript-eslint/no-unused-vars": "off", + '@typescript-eslint/no-unused-vars': 'off', + 'unused-imports/no-unused-imports': 'error', + 'unused-imports/no-unused-vars': [ + 'warn', + { + vars: 'all', + varsIgnorePattern: '^_', + args: 'after-used', + argsIgnorePattern: '^_', + }, + ], }, } diff --git a/package.json b/package.json index 13531ccc..f05c94ae 100644 --- a/package.json +++ b/package.json @@ -159,6 +159,7 @@ "cron": "*", "cross-env": "7.0.3", "eslint": "*", + "eslint-plugin-unused-imports": "2.0.0", "husky": "7.0.4", "ioredis": "5.0.4", "jest": "27.5.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 73fc0021..f8d333a9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,6 +67,7 @@ specifiers: dayjs: 1.11.0 ejs: 3.1.6 eslint: '*' + eslint-plugin-unused-imports: 2.0.0 fastify-cookie: 5.6.0 fastify-multipart: 5.3.1 fastify-swagger: 5.1.1 @@ -217,6 +218,7 @@ devDependencies: cron: 1.7.2 cross-env: 7.0.3 eslint: 8.11.0 + eslint-plugin-unused-imports: 2.0.0_eslint@8.11.0 husky: 7.0.4 ioredis: 5.0.4 jest: 27.5.1_ts-node@10.7.0 @@ -3672,6 +3674,25 @@ packages: tsconfig-paths: 3.14.1 dev: true + /eslint-plugin-unused-imports/2.0.0_eslint@8.11.0: + resolution: {integrity: sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + '@typescript-eslint/eslint-plugin': ^5.0.0 + eslint: ^8.0.0 + peerDependenciesMeta: + '@typescript-eslint/eslint-plugin': + optional: true + dependencies: + eslint: 8.11.0 + eslint-rule-composer: 0.3.0 + dev: true + + /eslint-rule-composer/0.3.0: + resolution: {integrity: sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==} + engines: {node: '>=4.0.0'} + dev: true + /eslint-scope/5.1.1: resolution: {integrity: sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==} engines: {node: '>=8.0.0'} diff --git a/src/common/guard/auth.guard.ts b/src/common/guard/auth.guard.ts index ff20c88b..a717cf03 100644 --- a/src/common/guard/auth.guard.ts +++ b/src/common/guard/auth.guard.ts @@ -1,17 +1,8 @@ -import { Observable } from 'rxjs' - -import { - CanActivate, - ExecutionContext, - Inject, - Injectable, -} from '@nestjs/common' +import { CanActivate, ExecutionContext, Injectable } from '@nestjs/common' import { AuthGuard as _AuthGuard } from '@nestjs/passport' import { isTest } from '~/global/env.global' import { mockUser1 } from '~/mock/user.mock' -import { AuthService } from '~/modules/auth/auth.service' -import { UserService } from '~/modules/user/user.service' import { getNestExecutionContextRequest } from '~/transformers/get-req.transformer' /** diff --git a/src/modules/health/health.dto.ts b/src/modules/health/health.dto.ts index 24899549..9c16b43e 100644 --- a/src/modules/health/health.dto.ts +++ b/src/modules/health/health.dto.ts @@ -1,12 +1,5 @@ import { Transform } from 'class-transformer' -import { - IsIn, - IsInt, - IsOptional, - IsString, - Min, - ValidateIf, -} from 'class-validator' +import { IsIn, IsInt, IsString, Min, ValidateIf } from 'class-validator' export class LogQueryDto { @IsIn(['out', 'error']) diff --git a/src/modules/link/link.service.ts b/src/modules/link/link.service.ts index 994187cc..ed4bfeb5 100644 --- a/src/modules/link/link.service.ts +++ b/src/modules/link/link.service.ts @@ -7,7 +7,6 @@ import { import { BusinessEvents, EventScope } from '~/constants/business-event.constant' import { isDev } from '~/global/env.global' -import { AdminEventsGateway } from '~/processors/gateway/admin/events.gateway' import { EmailService, LinkApplyEmailType, diff --git a/src/modules/pageproxy/pageproxy.dto.ts b/src/modules/pageproxy/pageproxy.dto.ts index bcfd2bd0..76680836 100644 --- a/src/modules/pageproxy/pageproxy.dto.ts +++ b/src/modules/pageproxy/pageproxy.dto.ts @@ -1,5 +1,5 @@ import { Transform } from 'class-transformer' -import { IsBoolean, IsIn, IsOptional, IsSemVer, IsUrl } from 'class-validator' +import { IsBoolean, IsIn, IsOptional, IsSemVer } from 'class-validator' import { IsAllowedUrl } from '~/utils/validator/isAllowedUrl' diff --git a/src/modules/user/user.service.ts b/src/modules/user/user.service.ts index 8aa3f2c0..911091c9 100644 --- a/src/modules/user/user.service.ts +++ b/src/modules/user/user.service.ts @@ -6,7 +6,6 @@ import { BadRequestException, ForbiddenException, Injectable, - InternalServerErrorException, Logger, UnprocessableEntityException, } from '@nestjs/common'