是否可以在eslint中停用此错误?
Parsing error: 'import' and 'export' may only appear at the top level
发布于 2016-08-26 19:35:40
ESLint本身并不支持这一点,因为这违反了规范。但是如果你使用babel-eslint
解析器,那么在你的eslint配置文件中,你可以这样做:
{
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": true
}
}
发布于 2019-09-25 18:48:59
在eslint 6.2中添加了对动态导入的支持。
不过,您需要将ecmaVersion设置为11 (或2020)。
"parserOptions": {
"ecmaVersion": 11
...
}
你可以在他们的online demo中测试一下。
发布于 2018-08-29 12:09:00
我的解决方案,以防其他方法不起作用
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
}
https://stackoverflow.com/questions/39158552
复制