@ typescript-eslint / eslint-plugin错误:定义了“路由”,但从未使用过(无未使用的变量) [英] @typescript-eslint/eslint-plugin error: 'Route' is defined but never used (no-unused-vars)

查看:1228
本文介绍了@ typescript-eslint / eslint-plugin错误:定义了“路由”,但从未使用过(无未使用的变量)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在eslint添加了打字稿检查之后,当类定义中的属性变量为Array时将出现错误。

After eslint adds typescript check, there will be an error when the attribute variable in the class definition is Array.

< img src = https://i.stack.imgur.com/IfAX9.png alt =在此处输入图片描述>

这是我的eslintrc.js

this is my eslintrc.js

module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': ['plugin:vue/essential', '@vue/standard'],
  rules: {},
  parserOptions: {
    parser: '@typescript-eslint/parser',
    project: "./tsconfig.json"
  },
  plugins: ['@typescript-eslint']
};


推荐答案

更新后的答案



禁用 no-unused-vars 并使用 @ typescript-eslint / no-unused-vars启用它:错误

"rules": {
  "no-unused-vars": "off",
  "@typescript-eslint/no-unused-vars": "error"
}

感谢詹姆斯·米德尔顿的正确答案。

Thanks to James Middleton for the correct answer.

在github上的eslint存储库中,有很多关于 no-unused-vars 规则。以下是一些示例:

Looking at the eslint repository on github, there have been lots of issues opened about the no-unused-vars rule. Here is some examples:

https://github.com/typescript-eslint/typescript-eslint/issues/45

https://github.com/typescript-eslint/typescript-eslint/issues/111

https://github.com/typescript-eslint / typescript-eslint / issues / 171

这是一个持续存在的问题。希望我们能尽快解决这个问题。

It's an ongoing problem. Hopefully we can expect this to be resolved soon.

这篇关于@ typescript-eslint / eslint-plugin错误:定义了“路由”,但从未使用过(无未使用的变量)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆