Repository: nestjs/nest
Pull request #10007 (2022-07-24 13:48:20)

chore(common): remove unused import statement
## PR Checklist
Please check if your PR fulfills the following requirements:

- [ ] The commit message follows our guidelines: https://github.com/nestjs/nest/blob/master/CONTRIBUTING.md
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)


## PR Type
What kind of change does this PR introduce?

<!-- Please check the one that applies to this PR using "x". -->
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Other... Please describe:

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying, or link to a relevant issue. -->

Issue Number: N/A


## What is the new behavior?


## Does this PR introduce a breaking change?
- [ ] Yes
- [ ] No

<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. -->


## Other information


Patch:
diff --git a/packages/common/constants.ts b/packages/common/constants.ts
index bd18972d5..a31e5962d 100644
--- a/packages/common/constants.ts
+++ b/packages/common/constants.ts
@@ -15,7 +15,11 @@ export const OPTIONAL_PROPERTY_DEPS_METADATA = 'optional:properties_metadata';
 export const SCOPE_OPTIONS_METADATA = 'scope:options';
 export const METHOD_METADATA = 'method';
 export const ROUTE_ARGS_METADATA = '__routeArguments__';
-export const CUSTOM_ROUTE_AGRS_METADATA = '__customRouteArgs__';
+export const CUSTOM_ROUTE_ARGS_METADATA = '__customRouteArgs__';
+/**
+  * @deprecated Use `CUSTOM_ROUTE_ARGS_METADATA` instead
+  */
+export const CUSTOM_ROUTE_AGRS_METADATA = CUSTOM_ROUTE_ARGS_METADATA;
 export const EXCEPTION_FILTERS_METADATA = '__exceptionFilters__';
 export const FILTER_CATCH_EXCEPTIONS = '__filterCatchExceptions__';
 export const PIPES_METADATA = '__pipes__';
diff --git a/packages/common/pipes/file/parse-file.pipe.ts b/packages/common/pipes/file/parse-file.pipe.ts
index e952c38f5..2f04024ea 100644
--- a/packages/common/pipes/file/parse-file.pipe.ts
+++ b/packages/common/pipes/file/parse-file.pipe.ts
@@ -4,7 +4,6 @@ import { HttpErrorByCode } from '../../utils/http-error-by-code.util';
 import { PipeTransform } from '../../interfaces/features/pipe-transform.interface';
 import { ParseFileOptions } from './parse-file-options.interface';
 import { FileValidator } from './file-validator.interface';
-import { throws } from 'assert';
 
 /**
  * Defines the built-in ParseFile Pipe. This pipe can be used to validate incoming files
diff --git a/packages/common/pipes/validation.pipe.ts b/packages/common/pipes/validation.pipe.ts
index 27ea9701d..fd37802b5 100644
--- a/packages/common/pipes/validation.pipe.ts
+++ b/packages/common/pipes/validation.pipe.ts
@@ -18,7 +18,7 @@ import {
   HttpErrorByCode,
 } from '../utils/http-error-by-code.util';
 import { loadPackage } from '../utils/load-package.util';
-import { isNil, isObject } from '../utils/shared.utils';
+import { isNil } from '../utils/shared.utils';
 
 export interface ValidationPipeOptions extends ValidatorOptions {
   transform?: boolean;
diff --git a/packages/common/utils/assign-custom-metadata.util.ts b/packages/common/utils/assign-custom-metadata.util.ts
index 3fb311647..38bd926db 100644
--- a/packages/common/utils/assign-custom-metadata.util.ts
+++ b/packages/common/utils/assign-custom-metadata.util.ts
@@ -1,4 +1,4 @@
-import { CUSTOM_ROUTE_AGRS_METADATA } from '../constants';
+import { CUSTOM_ROUTE_ARGS_METADATA } from '../constants';
 import {
   ParamData,
   RouteParamMetadata,
@@ -16,7 +16,7 @@ export function assignCustomParameterMetadata(
 ) {
   return {
     ...args,
-    [`${paramtype}${CUSTOM_ROUTE_AGRS_METADATA}:${index}`]: {
+    [`${paramtype}${CUSTOM_ROUTE_ARGS_METADATA}:${index}`]: {
       index,
       factory,
       data,
diff --git a/packages/core/helpers/external-context-creator.ts b/packages/core/helpers/external-context-creator.ts
index ee9484017..54212533e 100644
--- a/packages/core/helpers/external-context-creator.ts
+++ b/packages/core/helpers/external-context-creator.ts
@@ -1,5 +1,5 @@
 import { ForbiddenException, ParamData } from '@nestjs/common';
-import { CUSTOM_ROUTE_AGRS_METADATA } from '@nestjs/common/constants';
+import { CUSTOM_ROUTE_ARGS_METADATA } from '@nestjs/common/constants';
 import {
   ContextType,
   Controller,
@@ -272,7 +272,7 @@ export class ExternalContextCreator {
       );
       const type = this.contextUtils.mapParamType(key);
 
-      if (key.includes(CUSTOM_ROUTE_AGRS_METADATA)) {
+      if (key.includes(CUSTOM_ROUTE_ARGS_METADATA)) {
         const { factory } = metadata[key];
         const customExtractValue = this.contextUtils.getCustomFactory(
           factory,
diff --git a/packages/core/router/router-execution-context.ts b/packages/core/router/router-execution-context.ts
index 97e514067..5b7479de2 100644
--- a/packages/core/router/router-execution-context.ts
+++ b/packages/core/router/router-execution-context.ts
@@ -7,7 +7,7 @@ import {
   RequestMethod,
 } from '@nestjs/common';
 import {
-  CUSTOM_ROUTE_AGRS_METADATA,
+  CUSTOM_ROUTE_ARGS_METADATA,
   HEADERS_METADATA,
   HTTP_CODE_METADATA,
   REDIRECT_METADATA,
@@ -297,7 +297,7 @@ export class RouterExecutionContext {
       );
       const type = this.contextUtils.mapParamType(key);
 
-      if (key.includes(CUSTOM_ROUTE_AGRS_METADATA)) {
+      if (key.includes(CUSTOM_ROUTE_ARGS_METADATA)) {
         const { factory } = metadata[key];
         const customExtractValue = this.contextUtils.getCustomFactory(
           factory,
diff --git a/packages/microservices/context/rpc-context-creator.ts b/packages/microservices/context/rpc-context-creator.ts
index 003cd646c..a7ee74e02 100644
--- a/packages/microservices/context/rpc-context-creator.ts
+++ b/packages/microservices/context/rpc-context-creator.ts
@@ -1,5 +1,5 @@
 import {
-  CUSTOM_ROUTE_AGRS_METADATA,
+  CUSTOM_ROUTE_ARGS_METADATA,
   PARAMTYPES_METADATA,
 } from '@nestjs/common/constants';
 import {
@@ -225,7 +225,7 @@ export class RpcContextCreator {
         this.pipesContextCreator.createConcreteContext(pipesCollection);
       const type = this.contextUtils.mapParamType(key);
 
-      if (key.includes(CUSTOM_ROUTE_AGRS_METADATA)) {
+      if (key.includes(CUSTOM_ROUTE_ARGS_METADATA)) {
         const { factory } = metadata[key];
         const customExtractValue = this.contextUtils.getCustomFactory(
           factory,
diff --git a/packages/websockets/context/ws-context-creator.ts b/packages/websockets/context/ws-context-creator.ts
index ed0819bf8..7d575ef46 100644
--- a/packages/websockets/context/ws-context-creator.ts
+++ b/packages/websockets/context/ws-context-creator.ts
@@ -1,5 +1,5 @@
 import {
-  CUSTOM_ROUTE_AGRS_METADATA,
+  CUSTOM_ROUTE_ARGS_METADATA,
   PARAMTYPES_METADATA,
 } from '@nestjs/common/constants';
 import {
@@ -210,7 +210,7 @@ export class WsContextCreator {
         this.pipesContextCreator.createConcreteContext(pipesCollection);
       const type = this.contextUtils.mapParamType(key);
 
-      if (key.includes(CUSTOM_ROUTE_AGRS_METADATA)) {
+      if (key.includes(CUSTOM_ROUTE_ARGS_METADATA)) {
         const { factory } = metadata[key];
         const customExtractValue = this.contextUtils.getCustomFactory(
           factory,


Test patch:
diff --git a/packages/core/test/helpers/context-utils.spec.ts b/packages/core/test/helpers/context-utils.spec.ts
index 54111ef6d..802b153e0 100644
--- a/packages/core/test/helpers/context-utils.spec.ts
+++ b/packages/core/test/helpers/context-utils.spec.ts
@@ -1,4 +1,4 @@
-import { CUSTOM_ROUTE_AGRS_METADATA } from '@nestjs/common/constants';
+import { CUSTOM_ROUTE_ARGS_METADATA } from '@nestjs/common/constants';
 import { Body, createParamDecorator, Request } from '@nestjs/common/decorators';
 import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum';
 import { expect } from 'chai';
@@ -40,7 +40,7 @@ describe('ContextUtils', () => {
           data: undefined,
           pipes: [],
         },
-        [`custom${CUSTOM_ROUTE_AGRS_METADATA}:2`]: {
+        [`custom${CUSTOM_ROUTE_ARGS_METADATA}:2`]: {
           index: 2,
           factory: () => {},
           data: undefined,
@@ -54,7 +54,7 @@ describe('ContextUtils', () => {
       );
 
       const keys = Object.keys(metadata);
-      const custom = keys.find(key => key.includes(CUSTOM_ROUTE_AGRS_METADATA));
+      const custom = keys.find(key => key.includes(CUSTOM_ROUTE_ARGS_METADATA));
 
       expect(metadata[custom]).to.be.an('object');
       expect(metadata[custom].index).to.be.eq(2);
diff --git a/packages/core/test/helpers/external-context-creator.spec.ts b/packages/core/test/helpers/external-context-creator.spec.ts
index 98c098eab..cad7ed3b5 100644
--- a/packages/core/test/helpers/external-context-creator.spec.ts
+++ b/packages/core/test/helpers/external-context-creator.spec.ts
@@ -1,5 +1,5 @@
 import { ForbiddenException } from '@nestjs/common';
-import { CUSTOM_ROUTE_AGRS_METADATA } from '@nestjs/common/constants';
+import { CUSTOM_ROUTE_ARGS_METADATA } from '@nestjs/common/constants';
 import { RouteParamtypes } from '@nestjs/common/enums/route-paramtypes.enum';
 import { expect } from 'chai';
 import { of } from 'rxjs';
@@ -138,7 +138,7 @@ describe('ExternalContextCreator', () => {
       const metadata = {
         [RouteParamtypes.REQUEST]: { index: 0, data: 'test', pipes: [] },
         [RouteParamtypes.BODY]: { index: 2, data: 'test', pipes: [] },
-        [`key${CUSTOM_ROUTE_AGRS_METADATA}`]: {
+        [`key${CUSTOM_ROUTE_ARGS_METADATA}`]: {
           index: 3,
           data: 'custom',
           pipes: [],
@@ -154,7 +154,7 @@ describe('ExternalContextCreator', () => {
       const expectedValues = [
         { index: 0, type: RouteParamtypes.REQUEST, data: 'test' },
         { index: 2, type: RouteParamtypes.BODY, data: 'test' },
-        { index: 3, type: `key${CUSTOM_ROUTE_AGRS_METADATA}`, data: 'custom' },
+        { index: 3, type: `key${CUSTOM_ROUTE_ARGS_METADATA}`, data: 'custom' },
       ];
       expect(values[0]).to.deep.include(expectedValues[0]);
       expect(values[1]).to.deep.include(expectedValues[1]);
diff --git a/packages/core/test/router/router-execution-context.spec.ts b/packages/core/test/router/router-execution-context.spec.ts
index 8bd3b150b..b531ee972 100644
--- a/packages/core/test/router/router-execution-context.spec.ts
+++ b/packages/core/test/router/router-execution-context.spec.ts
@@ -4,7 +4,7 @@ import { of } from 'rxjs';
 import * as sinon from 'sinon';
 import { PassThrough } from 'stream';
 import { HttpException, HttpStatus, RouteParamMetadata } from '../../../common';
-import { CUSTOM_ROUTE_AGRS_METADATA } from '../../../common/constants';
+import { CUSTOM_ROUTE_ARGS_METADATA } from '../../../common/constants';
 import { RouteParamtypes } from '../../../common/enums/route-paramtypes.enum';
 import { AbstractHttpAdapter } from '../../adapters';
 import { ApplicationConfig } from '../../application-config';
@@ -183,7 +183,7 @@ describe('RouterExecutionContext', () => {
       const metadata = {
         [RouteParamtypes.REQUEST]: { index: 0, data: 'test', pipes: [] },
         [RouteParamtypes.BODY]: { index: 2, data: 'test', pipes: [] },
-        [`key${CUSTOM_ROUTE_AGRS_METADATA}`]: {
+        [`key${CUSTOM_ROUTE_ARGS_METADATA}`]: {
           index: 3,
           data: 'custom',
           pipes: [],
@@ -194,7 +194,7 @@ describe('RouterExecutionContext', () => {
       const expectedValues = [
         { index: 0, type: RouteParamtypes.REQUEST, data: 'test' },
         { index: 2, type: RouteParamtypes.BODY, data: 'test' },
-        { index: 3, type: `key${CUSTOM_ROUTE_AGRS_METADATA}`, data: 'custom' },
+        { index: 3, type: `key${CUSTOM_ROUTE_ARGS_METADATA}`, data: 'custom' },
       ];
       expect(values[0]).to.deep.include(expectedValues[0]);
       expect(values[1]).to.deep.include(expectedValues[1]);
diff --git a/packages/microservices/test/context/rpc-context-creator.spec.ts b/packages/microservices/test/context/rpc-context-creator.spec.ts
index 6de5a5ca4..1f622a485 100644
--- a/packages/microservices/test/context/rpc-context-creator.spec.ts
+++ b/packages/microservices/test/context/rpc-context-creator.spec.ts
@@ -3,7 +3,7 @@ import { expect } from 'chai';
 import { of } from 'rxjs';
 import * as sinon from 'sinon';
 import { Injectable, UseGuards, UsePipes } from '../../../common';
-import { CUSTOM_ROUTE_AGRS_METADATA } from '../../../common/constants';
+import { CUSTOM_ROUTE_ARGS_METADATA } from '../../../common/constants';
 import { ApplicationConfig } from '../../../core/application-config';
 import { GuardsConsumer } from '../../../core/guards/guards-consumer';
 import { GuardsContextCreator } from '../../../core/guards/guards-context-creator';
@@ -160,7 +160,7 @@ describe('RpcContextCreator', () => {
       const metadata = {
         [RpcParamtype.PAYLOAD]: { index: 0, data: 'test', pipes: [] },
         [RpcParamtype.CONTEXT]: { index: 2, data: 'test', pipes: [] },
-        [`key${CUSTOM_ROUTE_AGRS_METADATA}`]: {
+        [`key${CUSTOM_ROUTE_ARGS_METADATA}`]: {
           index: 3,
           data: 'custom',
           pipes: [],
@@ -177,7 +177,7 @@ describe('RpcContextCreator', () => {
       const expectedValues = [
         { index: 0, type: RpcParamtype.PAYLOAD, data: 'test' },
         { index: 2, type: RpcParamtype.CONTEXT, data: 'test' },
-        { index: 3, type: `key${CUSTOM_ROUTE_AGRS_METADATA}`, data: 'custom' },
+        { index: 3, type: `key${CUSTOM_ROUTE_ARGS_METADATA}`, data: 'custom' },
       ];
       expect(values[0]).to.deep.include(expectedValues[0]);
       expect(values[1]).to.deep.include(expectedValues[1]);
diff --git a/packages/websockets/test/context/ws-context-creator.spec.ts b/packages/websockets/test/context/ws-context-creator.spec.ts
index b51a48987..e6b7b5107 100644
--- a/packages/websockets/test/context/ws-context-creator.spec.ts
+++ b/packages/websockets/test/context/ws-context-creator.spec.ts
@@ -3,7 +3,7 @@ import { expect } from 'chai';
 import { of } from 'rxjs';
 import * as sinon from 'sinon';
 import { Injectable, UseGuards, UsePipes } from '../../../common';
-import { CUSTOM_ROUTE_AGRS_METADATA } from '../../../common/constants';
+import { CUSTOM_ROUTE_ARGS_METADATA } from '../../../common/constants';
 import { GuardsConsumer } from '../../../core/guards/guards-consumer';
 import { GuardsContextCreator } from '../../../core/guards/guards-context-creator';
 import { NestContainer } from '../../../core/injector/container';
@@ -155,7 +155,7 @@ describe('WsContextCreator', () => {
       const metadata = {
         [WsParamtype.SOCKET]: { index: 0, data: 'test', pipes: [] },
         [WsParamtype.PAYLOAD]: { index: 2, data: 'test', pipes: [] },
-        [`key${CUSTOM_ROUTE_AGRS_METADATA}`]: {
+        [`key${CUSTOM_ROUTE_ARGS_METADATA}`]: {
           index: 3,
           data: 'custom',
           pipes: [],
@@ -172,7 +172,7 @@ describe('WsContextCreator', () => {
       const expectedValues = [
         { index: 0, type: WsParamtype.SOCKET, data: 'test' },
         { index: 2, type: WsParamtype.PAYLOAD, data: 'test' },
-        { index: 3, type: `key${CUSTOM_ROUTE_AGRS_METADATA}`, data: 'custom' },
+        { index: 3, type: `key${CUSTOM_ROUTE_ARGS_METADATA}`, data: 'custom' },
       ];
       expect(values[0]).to.deep.include(expectedValues[0]);
       expect(values[1]).to.deep.include(expectedValues[1]);