node.js - no-unused-var eslint 用于 nestsjs 中的模块和类型
问题描述
我已将 eslint 添加到我的 nestjs 7 项目中,但对未使用的 vars 错误感到困惑
我在模块、生命周期方法和服务上遇到错误。也有类型错误
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 配置:
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"
}
}
]
}
解决方案
我相信这来自typescript-eslint 中的这个问题。目前唯一的解决方法是不使用该特定规则。
推荐阅读
- database - Tiger Geocoder - Postgres SSL SYSCALL 错误:EOF 检测到信号 11 分段错误
- docker - 如何在 Fedora 35 上安装 Docker?
- html - 修复 Cargo Collective 图像库中的图像高度
- server - 如何查看谁占用了 sungrid 引擎上的所有资源?
- c# - 有没有办法通过订阅来限制 Azure API 管理端点?
- c++ - C++ 编译器不考虑友元类声明
- java - 如果我更改对象指针而不是更新对象,是否需要锁?
- python - Python 使用现有缓冲区创建 SharedMemory 实例(来自 marshal.dumps() 的字节)
- html - 如何使页面的图标响应用户的配色方案偏好?
- python - 逐行读取两列文件