Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Gettingno-unused-vars on constructor parameters after upgrading to the latest version oftypescript andeslint #2971

Closed
Labels
duplicateThis issue or pull request already exists
@SamiSammour

Description

@SamiSammour
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I haveread the FAQ and my problem is not listed.

I have an issue after I upgraded to the latest version of TypeScript, ESLint & @typescript-eslint/eslint-plugin I didn't have it before upgrading.
Now every time I execute the lint command I get a list ofno-unused-vars errors for used imports & constructor properties, also issues in enums. All of these problem didn't exist before the upgrade.
The versions I had before the upgrade are:

packageversion
@typescript-eslint/eslint-plugin3.7.1
@typescript-eslint/parser3.7.1
TypeScript3.9.7
node14.15.0
npm6.14.8

Repro
Here's my files I'm using:

.eslintrc

{"settings": {"import/parsers": {"@typescript-eslint/parser": [".ts"      ]    }  },"parser":"@typescript-eslint/parser","parserOptions": {"project":"tsconfig.json","sourceType":"module"  },"plugins": ["@typescript-eslint/eslint-plugin"  ],"extends": ["plugin:@typescript-eslint/eslint-recommended","plugin:@typescript-eslint/recommended","plugin:import/typescript","airbnb-base"  ],"root":true,"env": {"node":true,"jest":true  },"rules": {"no-trailing-spaces":"error","comma-dangle": ["error","never"    ],"import/no-extraneous-dependencies":"off","import/no-unresolved":"off","class-methods-use-this":"off","import/extensions":"off","no-empty-function": ["error",      {"allow": ["constructors"        ]      }    ],"no-useless-constructor":"off","brace-style": ["error","stroustrup",      {"allowSingleLine":true      }    ],"max-len": ["error",      {"code":150      }    ],"no-undef":"off"  }}

calendar.contorller.ts

import{Controller,Get,Query}from'@nestjs/common';import{GetUser}from'@alphaapps/nestjs-common';importCalendarServicefrom'./calendar.service';importUserfrom'../users/user.model';importBookingHistoryResponseDtofrom'./dtos/booking-history-response.dto';@Controller('calendar')exportdefaultclassCalendarController{constructor(privateservice:CalendarService){}  @Get('schedule')asyncgetSchedule(@Query('date')date:string, @GetUser()user:User):Promise<{events:BookingHistoryResponseDto[]}>{return{events:awaitthis.service.getSchedule(date,user)};}}

tsconfig.json

{"compilerOptions": {"module":"commonjs","declaration":true,"removeComments":true,"emitDecoratorMetadata":true,"experimentalDecorators":true,"allowSyntheticDefaultImports":true,"target":"es2017","sourceMap":true,"outDir":"./dist","baseUrl":"./","incremental":true,"esModuleInterop":true  },"exclude": ["node_modules","dist"]}

Expected Result
I expect not to have any error.

Actual Result

src/calendar.controller.ts   7:8   error    'BookingHistoryResponseDto' is defined but never used  no-unused-vars   7:8   warning  'BookingHistoryResponseDto' is defined but never used  @typescript-eslint/no-unused-vars  11:23  error    'service' is defined but never used                    no-unused-vars

A you see in the code I sharedBookingHistoryResponseDto is used in the return type of the functiongetSchedule.
also theservice parameter is initialized implicitly and should not raise this error.
Additional Info
this is the command I'm runningeslint "{src,apps,libs,test}/**/*.ts" --fix

Versions

packageversion
@typescript-eslint/eslint-plugin4.14.0
@typescript-eslint/parser4.14.0
@typescript-eslint/typescript-estree4.14.0
@typescript-eslint/experimental-utils4.14.0
TypeScript4.1.3
node14.15.0
npm6.14.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp