首页 > 其他分享 > warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any

warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any

时间:2023-05-13 20:11:44浏览次数:35  
标签:different typescript no Unexpected eslint escape warning any

参考链接

场景描述

使用vue3+ts开发项目时,会遇到很多警告,我们可以在配置文件中关闭它

一、警告: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 = /[/{}[\]#%?\\]+/

标签:different,typescript,no,Unexpected,eslint,escape,warning,any
From: https://www.cnblogs.com/zx529/p/17398083.html

相关文章

  • Stream流anyMatch,allMatch,noneMatch
    publicclassActor{privateStringname;privateintage;privateList<Person>personList=newArrayList<Person>();publicStringgetName(){returnname;}publicvoidsetName(Stringname){this.na......
  • CF1824D LuoTianyi and the Function & 区间历史和模板
    LuoTianyiandtheFunction:LuoTianyigivesyouanarray\(a\)of\(n\)integersandtheindexbeginsfrom\(1\).Define\(g(i,j)\)asfollows:When\(i\lej\),\(g(i,j)\)isthelargestinteger\(x\)thatsatisfies\(\{a_p:i\lep\le......
  • target method '%s' found on bean target class '%s', but not found in any interf
    targetmethod'%s'foundonbeantargetclass'%s',butnotfoundinanyinterface(s)forbeanJDKproxy.Eitherpullthemethoduptoaninterfaceorswitchtosubclass(CGLIB)proxiesbysettingproxy-target-class/proxyTargetClass......
  • docker(一):Develop faster. Run anywhere.
    前言在进行微服务部署时,首先需要进行部署环境的搭建。目前,Docker已经成为了微服务部署的主流解决方案之一。Docker可以帮助我们更快地打包、测试以及部署应用程序,从而缩短从编写到部署运行代码的周期。在本文中,我们将对Docker进行初步的讲解,并介绍如何将映像生成并作为容器......
  • 通用AI大型模型Segment Anything在医学图像分割领域的最新成果!
    前言 SAM是一种在自然图像分割方面取得成功的模型,但在医学图像分割方面表现不佳。MedSAM首次尝试将SAM的成功扩展到医学图像,并成为用于分割各种医学图像的通用工具。为了开发MedSAM,首先需要一个大型医学图像数据集,其中包括来自11种不同模态的超过20万个Mask。该数据集......
  • Unindent does not match any outer indentation level
    出现这个报错是因为格式有问题。查看是否正确缩进,有没有对齐,还有有没有tab和空格混用。可以打开notepad++来查看格式是否出现问题。1.下图的问题if前面有一个空格,应该删去。 2.前面都多出了一个空格,要删除。 3.这个也是因为多出了一个空格所以报错 ......
  • OCR 文字检测(Differentiable Binarization --- DB)
    文本检测基于分割的做法(如蓝色箭头所示):传统的pipeline使用固定的阈值对于分割后的热力图进行二值化处理首先,它们设置了固定的阈值,用于将分割网络生成的概率图转换为二进制图像然后,用一些启发式技术(例如像素聚类)用于将像素分组为文本实例DB的做法(如红色箭头所示):而本文提出......
  • @OneToMany and @OneToOne
    @OneToManyand@OneToOne@OneToMany默认情况下,JPA为具有一对多多重性的多值关联定义一个OneToMany映射。使用@OneToMany批注:将获取类型配置为LAZY由于所使用的Collection不是使用一般参数定义的,因此配置关联的目标实体配置必须层叠到关联目标的操作:例如,如果删除了拥有......
  • CF1824A LuoTianYi and the Show
    题意有\(n\)个人、编号为\(1\)至\(m\)的\(m\)个座位与三种坐座位的方式:坐在最左边的人的左边,当\(1\)号座位也不为空时就不坐了,当没有人坐在座位上时坐在\(m\)号座位上;坐在最右边的人的右边,当\(m\)号座位也不为空时就不坐了,当没有人坐在座位上时坐在\(1\)号座......
  • 使用富文本编辑,内容有<img src=xxx//xx//xx>报错:JSON parse error: Unexpected charac
     前端使用富文本标签,填写内容里面有图片地址或一些特殊字符,保存时导致报错后台json不能解析内容到实体类相应的字段中去报错代码:JSONparseerror:Unexpectedcharacter('\'(code92)):...解决办法:1、有的说在配置xss过滤时开放,保存的请求接口地址。————————......