ESLint变量已定义但从未使用(no-unsed-vars)

时间:2018-08-29 12:25:46

标签: javascript ecmascript-6 visual-studio-code eslint eslintrc

我已经设置了ESLint并对其进行了几天的测试,发现有些东西困扰着我。

我收到以下错误消息: 'Book' is defined but never used. (no-unused-vars)

class Book extends REST {
  sayHi() {
    return `Hi! I am the book ${this.title}. I was written in ${this.year} by ${this.author}!`;
  }
}

在这种情况下,Book出现错误。在另一个文件中,REST遇到相同的错误。他们被定义和使用。。我不明白我在做什么错。 我宁愿不关闭no-unused-vars

这是我所有规则的.eslintrc.json:

{
"env": {
    "browser": true,
    "node": true
},
"extends": "recommended",
"parserOptions": {
    "ecmaVersion": 6,
    "sourceType": "module",
    "ecmaFeatures": {
        "modules": true,
        "experimentalObjectRestSpread": true
    }
},
"rules": {
    "no-restricted-syntax": 0,
    "no-param-reassign": 0,
    "no-return-await": 0,
    "no-underscore-dangle": 0,
    "prefer-template": 0,
    "no-undef": "off",
    "spaced-comment": 0,
    "no-trailing-spaces": 0,
    "no-undefined": 0,
    "space-before-blocks": 0,
    "comma-dangle": 0,
    "no-tabs": 0,
    "no-mixed-spaces-and-tabs": 0,
    "indent": 0,
    "linebreak-style": 0,
    "avoidEscape": true,
    "prefer-const": 0,
    "no-console": 0,
    "getter-return": 1,
    "no-compare-neg-zero": 0,
    "no-constant-condition": 0,
    "no-control-regex": 0,
    "no-empty": 1,
    "no-extra-parens": 1,
    "no-extra-semi": 1,
    "no-inner-declarations": 0,
    "class-methods-use-this": 1,
    "guard-for-in": 0,
    "eqeqeq": 1,
    "dot-notation": 1,
    "no-empty-function": 1,
    "no-empty-pattern": 0,
    "no-eval": 0,
    "no-multi-spaces": 1
  }
}

当我尝试使用Google解决方案时,我在网上看到了很多问题,但是找不到适合我的解决方案。有人知道怎么回事吗?

0 个答案:

没有答案