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'
posted @ 2020-01-21 16:05  wayne529  阅读(4140)  评论(0编辑  收藏  举报