• 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 = /[/{}[\]#%?\\]+/
  • 相关阅读:
    洛谷P3122 [USACO15FEB]圈住牛Fencing the Herd(计算几何+CDQ分治)
    洛谷P4502 [ZJOI2018]保镖(计算几何+三维凸包)
    [Codeforces1137D]Cooperative Game
    洛谷P2287 [HNOI2004]最佳包裹(三维凸包)
    洛谷P4724 【模板】三维凸包
    洛谷P4526 【模板】自适应辛普森法2(Simpson法)
    A + B Problem
    Java中方法next()和nextLine()的区别
    发现环
    分考场
  • 原文地址:https://www.cnblogs.com/goloving/p/15421496.html
Copyright © 2020-2023  润新知