項目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'