【发布时间】:2023-02-08 17:37:49
【问题描述】:
屏幕截图几乎显示了您需要的内容:ESLint + TypeScript ESLint plugin + the no-unused-vars lint rule。
最小的 .eslintrc.json 配置文件可能看起来类似于:
{
"root": true,
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
},
"plugins": [
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/no-unused-vars": ["warn"],
}
}
请注意,TypeScript 本身支持通过 its noUnusedLocals tsconfig setting 为未使用的局部变量发出警告/错误。
【讨论】: