[英]How to tell eslint to allow staged ECMA-Script dynamic imports
I want to use the now "Stage-3" proposal import()
. 我想使用现在的“Stage-3”提议
import()
。 If I lint my code with ESLint it's complaining about: 如果我用ESLint lint我的代码它抱怨:
Parsing error: 'import' and 'export' may only appear at the top level
Which is correct for the static form of import
but not for the new, dynamic one. 这对于静态
import
形式是正确的,但对于新的动态形式则不正确。 I don't find the right option to make ESLint allow that. 我没有找到让ESLint允许的正确选项。 Can someone give me a hint?
有人能给我一个暗示吗?
Of course is Gyandeep right. 当然Gyandeep是对的。 It's no question of rules but of the parser (That's what parsing error means after all…).
这不是规则的问题,而是解析器的问题(这就是解析错误意味着什么......)。 So I use now
babel-eslint
with the following .eslintrc
(excerpt): 所以我现在使用
babel-eslint
以下.eslintrc
(摘录):
{
"parser": "babel-eslint",
"parserOptions": {
"allowImportExportEverywhere": true
}
}
Also, I made sure I installed and used babel-plugin-syntax-dynamic-import
. 另外,我确保安装并使用了
babel-plugin-syntax-dynamic-import
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.