Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read 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 of no-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:
package | version |
---|---|
@typescript-eslint/eslint-plugin |
3.7.1 |
@typescript-eslint/parser |
3.7.1 |
TypeScript |
3.9.7 |
node |
14.15.0 |
npm |
6.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';
import CalendarService from './calendar.service';
import User from '../users/user.model';
import BookingHistoryResponseDto from './dtos/booking-history-response.dto';
@Controller('calendar')
export default class CalendarController {
constructor(private service: CalendarService) {}
@Get('schedule')
async getSchedule(@Query('date') date: string, @GetUser() user: User): Promise<{ events: BookingHistoryResponseDto[] }> {
return {
events: await this.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 shared BookingHistoryResponseDto
is used in the return type of the function getSchedule
.
also the service
parameter is initialized implicitly and should not raise this error.
Additional Info
this is the command I'm running eslint "{src,apps,libs,test}/**/*.ts" --fix
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.14.0 |
@typescript-eslint/parser |
4.14.0 |
@typescript-eslint/typescript-estree |
4.14.0 |
@typescript-eslint/experimental-utils |
4.14.0 |
TypeScript |
4.1.3 |
node |
14.15.0 |
npm |
6.14.8 |