是否可以在eslint中停用此错误?
Parsing error: 'import' and 'export' may only appear at the top level
Run Code Online (Sandbox Code Playgroud)
Gya*_*eep 29
ESLint本身并不支持这一点,因为这违反了规范.但是如果你使用babel-eslint
解析器然后在你的eslint配置文件中你可以这样做:
{
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": true
}
}
Run Code Online (Sandbox Code Playgroud)
Doc ref:https://github.com/babel/babel-eslint#configuration
Lui*_*grs 16
eslint 6.2 中添加了对动态导入的支持。
不过,您需要将 ecmaVersion 设置为 11(或 2020)。
"parserOptions": {
"ecmaVersion": 11
...
}
Run Code Online (Sandbox Code Playgroud)
您可以在他们的在线演示中进行测试。
may*_*o19 11
我的解决方案柜面其他不起作用
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
19185 次 |
最近记录: |