vue 项目添加eslint之后警告处理

image
如上图,添加以上报错
image
添加了那段注释就可以了,但总不可能每次新增一个函数都添加这个注释吧,因此想问问有人知道如何统一处理的吗

阅读 3.9k
2 个回答

首先不太明白楼主为什么使用了typescript的规则校验,却没有在这个文件中使用typescript,这似乎失去了eslint对编码规范校验的意义,以下解决方法,楼主可以一试。

Configuring in a mixed JS/TS codebase

If you are working on a codebase within which you lint non-TypeScript code (i.e. .js/.jsx), you should ensure that you should use ESLint overrides to only enable the rule on .ts/.tsx files. If you don't, then you will get unfixable lint errors reported within .js/.jsx files.


{
  "rules": {
    // disable the rule for all files
    "@typescript-eslint/explicit-module-boundary-types": "off"
  },
  "overrides": [
    {
      // enable the rule specifically for TypeScript files
      "files": ["*.ts", "*.tsx"],
      "rules": {
        "@typescript-eslint/explicit-module-boundary-types": ["error"]
      }
    }
  ]
}
  "rules": {
    // disable the rule for all files
    "@typescript-eslint/explicit-module-boundary-types": "off"
  },
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题