eslint-config-standard引入项目的问题


项目eslint使用eslint-config-standard标准,

在执行npm run lint后发现只要有import或者export这类关键词的js文件都会报以下三个错

1:1  error  Definition for rule 'no-async-promise-executor' was not found      no-async-promise-executor
  1:1  error  Definition for rule 'no-misleading-character-class' was not found  no-misleading-character-class
  1:1  error  Definition for rule 'no-useless-catch' was not found               no-useless-catch

 

而这三个规则是检验promise的,显然这里是误报。

找了很久的解决方案

最后查看该npm包的更新日志发现  https://standardjs.com/changelog.html

在13.0版本开始默认增加了这三个规则,但估计是跟某些其他包配合的时候产生了bug,导致误报

解决方法:

方案一:

将eslint-config-standard的npm版本降至12以下

cnpm i eslint-config-standard@10.2.1 --save-dev

 

方案二:

在eslintrc.js的rules里添加off

    'no-async-promise-executor' : 'off',
    'no-misleading-character-class' : 'off',
    'no-useless-catch' : 'off'


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM