简体   繁体   English

nestsjs 中模块和类型的 no-unused-var eslint

[英]no-unused-var eslint for modules and types in nestsjs

I have added eslint to my nestjs 7 projects and got confused with the unused vars error我已将 eslint 添加到我的 nestjs 7 项目中,但对未使用的 vars 错误感到困惑

I got errors on Modules, lifecycle method, and services.我在模块、生命周期方法和服务上遇到错误。 also got errors of types也有类型错误

import { Controller, Get } from '@nestjs/common';
import {
  HealthCheck,
  HealthCheckService,  ---> got here the the error
  MongooseHealthIndicator, ---> got here the  the error
} from '@nestjs/terminus';

@Controller('health')
export class HealthController {
  constructor(
    private health: HealthCheckService,
    private mongoose: MongooseHealthIndicator
  ) {}

  @Get()
  @HealthCheck()
  check() {
    return this.health.check([() => this.mongoose.pingCheck('mongoose')]);
  }
}

elintrc.js configuration : elintrc.js 配置:

module.exports = {
    parser: '@typescript-eslint/parser',
    plugins: ['@typescript-eslint'],
    extends: [
        "eslint:recommended",
        "plugin:@typescript-eslint/eslint-recommended",
        "plugin:@typescript-eslint/recommended",
        "plugin:prettier/recommended",
        "prettier/@typescript-eslint",
    ],
    env: {
        "browser": true,
        "es6": true,
        "node": true
    },
    overrides: [
        {
            "files": ["*.js"],
            "rules": {
                "@typescript-eslint/no-var-requires": "off"
            }
        }
    ]
}

I believe this comes from this issue in typescript-eslint .我相信这来自typescript-eslint 中的这个问题 Only workaround currently is to not use that specific rule.目前唯一的解决方法是不使用该特定规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM