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 = /[/{}[\]#%?\\]+/

 

posted @   古兰精  阅读(6438)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
历史上的今天:
2017-10-18 浅析Java布尔类型引起的空指针问题:boolean与Boolean的区别与使用、boolen赋值为null和Boolean作为 if 判断条件的2种空指针情况
2017-10-18 CSS知识点:text-align-last段落最后一行设置对齐方式、transform:rotateY()翻转、渐变文字、column count列属性、平滑滚动、placeholder伪元素与selection伪类
2017-10-18 List<实体>与List<String>数据互转
点击右上角即可分享
微信分享提示