zoukankan      html  css  js  c++  java
  • Vue3+ts+eslint报错记录及解决:warning Unexpected any. Specify a different type、warning Delete `·` 、Missing return type on function、Require statement not part of import statement、Unnecessary escape character

    一、警告:warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any

      解决方案:关闭any类型的警告。

    // 在 .eslintrc.js文件中找到rules 添加一行代码即可
    "@typescript-eslint/no-explicit-any": ["off"]

      添加完成之后,重新运行项目即可。

    二、使用eslint时总是提醒warning Delete `·` prettier/prettier或者405:15 warning Insert `⏎·····` prettier

      解决方案:可执行代码即可

    npm run lint --fix

      执行之后会自动修改,我这里看到把单引号改成了双引号。

    三、warning: Missing return type on function  (@typescript-eslint/explicit-module-boundary-types) at src\main.ts:32:8

      解决方案:在.eslintrc.js文件里添加规则禁用ta

    "rules": {
        "@typescript-eslint/explicit-module-boundary-types": "off"
    },

    四、Require statement not part of import statement.(@typescript-eslint/no-var-requires)

    // 当在 vue.config.js 中:
    const path = require('path')
    
    // 提示报错:
    Require statement not part of import statement.(@typescript-eslint/no-var-requires)

      解决方案:在 .eslintrc.js中的 rules 属性新增以下内容:

    rules: {
        '@typescript-eslint/no-var-requires': 0
    }

    五、Unnecessary escape character: \/ no-useless-escape

      通常见与写正则时报错:

       79:17  error    Unnecessary escape character: \/  no-useless-escape
       79:21  error    Unnecessary escape character: \[  no-useless-escape
      131:22  warning  Insert `,`                        prettier/prettier
      132:4   warning  Insert `,`                        prettier/prettier

    $ Unnecessary escape character: - no-useless-escape

    禁用不必要的转义字符; \-

      不必要的转义字符,上面都给你提示了,改一下就行。

    const reg = /[\/{}\[\]#%?\\]+/
    
    // 不必要的转义字符去掉
    const reg = /[/{}[\]#%?\\]+/
  • 相关阅读:
    UIAutomator简介
    初识Anrdiod SDK
    Andriod App类型简介
    Mybatis之collection嵌套查询mapper文件写法
    Ubuntu16.04 启动纯文本界面方法
    Ubuntu16.04网络不能访问解决办法
    JavaScript之简易http接口测试工具网页版
    SpringBoot之修改单个文件后立刻生效
    JavaScript之Json的使用
    Ajax之Jquery封装使用举例2(Json和JsonArray处理)
  • 原文地址:https://www.cnblogs.com/goloving/p/15421496.html
Copyright © 2011-2022 走看看