0

我已经设置了 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
  }
}

当我尝试谷歌解决方案时,我已经看到这个问题在网上弹出了很多,我找不到适合我的解决方案。有人知道发生了什么吗?

4

0 回答 0